[libvirt] [PATCH RESEND] qemu: Honor the original properties of PCI device when detaching

Eric Blake eblake at redhat.com
Wed Dec 14 23:01:06 UTC 2011


On 11/29/2011 03:09 AM, Osier Yang wrote:
> This patch fixes two problems:
>     1) The device will be reattached to host even if it's not
>        managed, as there is a "pciDeviceSetManaged".
>     2) The device won't be reattached to host with original
>        driver properly. As it doesn't honor the device original
>        properties which are maintained by driver->activePciHostdevs.
> ---
>  src/qemu/qemu_hotplug.c |   17 +++++++++--------
>  1 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 96c0070..19e4a41 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -1960,6 +1960,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>      int i, ret;
>      pciDevice *pci;
> +    pciDevice *activePci;
>  
>      for (i = 0 ; i < vm->def->nhostdevs ; i++) {
>          if (vm->def->hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
> @@ -2019,16 +2020,16 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver *driver,
>                         detach->source.subsys.u.pci.bus,
>                         detach->source.subsys.u.pci.slot,
>                         detach->source.subsys.u.pci.function);
> -    if (!pci)
> -        ret = -1;
> -    else {

Yay - fixing up a HACKING formatting convention violation in the process.

> -        pciDeviceSetManaged(pci, detach->managed);
> -        pciDeviceListDel(driver->activePciHostdevs, pci);
> -        if (pciResetDevice(pci, driver->activePciHostdevs, NULL) < 0)
> +    if (pci) {
> +        activePci = pciDeviceListSteal(driver->activePciHostdevs, pci);
> +        if (pciResetDevice(activePci, driver->activePciHostdevs, NULL))
> +            qemuReattachPciDevice(activePci, driver);
> +        else
>              ret = -1;
> -        pciDeviceReAttachInit(pci);
> -        qemuReattachPciDevice(pci, driver);
>          pciFreeDevice(pci);
> +        pciFreeDevice(activePci);
> +    } else {
> +        ret = -1;
>      }

ACK, and sorry for the delayed review response.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111214/94affb32/attachment-0001.sig>


More information about the libvir-list mailing list