mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: avoid corrupting guest info struct on host device PCI hot add
The device path doesn't make use of guestAddr, so the memcpy corrupts the guest info struct. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
ebb0c19c48
commit
ddfd4dba95
@ -7653,7 +7653,6 @@ static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
pciDevice *pci;
|
pciDevice *pci;
|
||||||
int ret;
|
int ret;
|
||||||
virDomainDevicePCIAddress guestAddr;
|
|
||||||
char *devstr = NULL;
|
char *devstr = NULL;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
|
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
|
||||||
@ -7688,20 +7687,24 @@ static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver,
|
|||||||
|
|
||||||
if (!(devstr = qemuBuildPCIHostdevDevStr(hostdev)))
|
if (!(devstr = qemuBuildPCIHostdevDevStr(hostdev)))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
|
|
||||||
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
ret = qemuMonitorAddDevice(priv->mon, devstr);
|
||||||
else
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
|
} else {
|
||||||
|
virDomainDevicePCIAddress guestAddr;
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitorWithDriver(driver, vm);
|
||||||
ret = qemuMonitorAddPCIHostDevice(priv->mon,
|
ret = qemuMonitorAddPCIHostDevice(priv->mon,
|
||||||
&hostdev->source.subsys.u.pci,
|
&hostdev->source.subsys.u.pci,
|
||||||
&guestAddr);
|
&guestAddr);
|
||||||
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
qemuDomainObjExitMonitorWithDriver(driver, vm);
|
||||||
|
|
||||||
|
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
|
memcpy(&hostdev->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
||||||
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto error;
|
goto error;
|
||||||
hostdev->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
|
||||||
memcpy(&hostdev->info.addr.pci, &guestAddr, sizeof(guestAddr));
|
|
||||||
|
|
||||||
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user