[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 1/2] qemu: avoid corrupting guest info struct on host device PCI hot add



On Mon, May 24, 2010 at 01:33:27PM -0400, Alex Williamson wrote:
> 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>
> ---
> 
>  src/qemu/qemu_driver.c |   19 +++++++++++--------
>  1 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f027dc3..32ce835 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7654,7 +7654,6 @@ static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver,
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>      pciDevice *pci;
>      int ret;
> -    virDomainDevicePCIAddress guestAddr;
>      char *devstr = NULL;
>  
>      if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0) {
> @@ -7689,20 +7688,24 @@ static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver,
>  
>          if (!(devstr = qemuBuildPCIHostdevDevStr(hostdev)))
>              goto error;
> -    }
>  
> -    qemuDomainObjEnterMonitorWithDriver(driver, vm);
> -    if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)
> +        qemuDomainObjEnterMonitorWithDriver(driver, vm);
>          ret = qemuMonitorAddDevice(priv->mon, devstr);
> -    else
> +        qemuDomainObjExitMonitorWithDriver(driver, vm);
> +    } else {
> +        virDomainDevicePCIAddress guestAddr;
> +
> +        qemuDomainObjEnterMonitorWithDriver(driver, vm);
>          ret = qemuMonitorAddPCIHostDevice(priv->mon,
>                                            &hostdev->source.subsys.u.pci,
>                                            &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)
>          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;

ACK

Net + disk hotplug have already got such fixes, somehow I missed PCI.


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]