mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Clear assigned PCI devices at shutdown
The PCI device addresses are only valid while the VM is running, since they are auto-assigned by QEMU. After shutdown they must all be cleared. Future QEMU driver enhancement will allow for persistent PCI address assignment * src/conf/domain_conf.h, src/conf/domain_conf.c, src/libvirt_private.syms Add virDomainDefClearPCIAddresses() method for wiping out auto assigned PCI addresses * src/qemu/qemu_driver.c: Clear PCI addresses at VM shutdown
This commit is contained in:
parent
b030084f07
commit
774c757e67
@ -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
|
||||
*/
|
||||
|
@ -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 */
|
||||
|
@ -187,6 +187,7 @@ virDomainControllerTypeToString;
|
||||
virDomainControllerDefFree;
|
||||
virDomainDeviceAddressTypeToString;
|
||||
virDomainDefAddDiskControllers;
|
||||
virDomainDefClearPCIAddresses;
|
||||
|
||||
|
||||
# domain_event.h
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user