diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3b102b3a60917f51e88db304f066b5699165e93..b2c8104e6142c1661c89ac4e693e06c88deaca99 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -817,6 +817,42 @@ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) } +static void virDomainDeviceInfoClearField(virDomainDeviceInfoPtr info) +{ + if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + memset(&info->addr, 0, sizeof(info->addr)); + info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; + } +} + + +static void virDomainDefClearDeviceInfo(virDomainDefPtr def) +{ + int i; + + for (i = 0; i < def->ndisks ; i++) + virDomainDeviceInfoClearField(&def->disks[i]->info); + for (i = 0; i < def->nnets ; i++) + virDomainDeviceInfoClearField(&def->nets[i]->info); + for (i = 0; i < def->nsounds ; i++) + virDomainDeviceInfoClearField(&def->sounds[i]->info); + for (i = 0; i < def->nhostdevs ; i++) + virDomainDeviceInfoClearField(&def->hostdevs[i]->info); + for (i = 0; i < def->nvideos ; i++) + virDomainDeviceInfoClearField(&def->videos[i]->info); + for (i = 0; i < def->ncontrollers ; i++) + virDomainDeviceInfoClearField(&def->controllers[i]->info); + if (def->watchdog) + virDomainDeviceInfoClearField(&def->watchdog->info); +} + + +void virDomainDefClearPCIAddresses(virDomainDefPtr def) +{ + virDomainDefClearDeviceInfo(def); +} + + /* Generate a string representation of a device address * @param address Device address to stringify */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1831d17bcd253157969d1959e2fa2da7915ca186..a6f7ab25513e73313498aec3db681d0933bd1694 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -736,6 +736,8 @@ int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr); int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr); int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); +void virDomainDefClearPCIAddresses(virDomainDefPtr def); + void virDomainDefFree(virDomainDefPtr vm); void virDomainObjRef(virDomainObjPtr vm); /* Returns 1 if the object was freed, 0 if more refs exist */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0d1a82ca51573cf794e097be4730a546c7b4029f..46c0902d640d050f11f5eae413e71efe26bee9e0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -187,6 +187,7 @@ virDomainControllerTypeToString; virDomainControllerDefFree; virDomainDeviceAddressTypeToString; virDomainDefAddDiskControllers; +virDomainDefClearPCIAddresses; # domain_event.h diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bc809001063506e1b52ff3bea7c20ab3d6e158a7..0a35b97bde5972656b5a231ccf3871aac429df34 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3048,6 +3048,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn, VIR_FREE(vm->def->seclabel.imagelabel); } + virDomainDefClearPCIAddresses(vm->def); + if (qemuDomainSetAllDeviceOwnership(conn, driver, vm->def, 1) < 0) VIR_WARN("Failed to restore all device ownership for %s", vm->def->name);