[libvirt] [PATCH 4/4] qemu: Do not keep PCI device config file open

Osier Yang jyang at redhat.com
Tue Dec 4 14:45:26 UTC 2012


On 2012年12月04日 18:38, Jiri Denemark wrote:
> We only need to access the PCI device config file when
> attaching/detaching the device to a domain. Keeping it open all the time
> the device is attached to a domain is useless.
> ---
>   src/libvirt_private.syms | 1 +
>   src/qemu/qemu_hostdev.c  | 6 ++++--
>   src/util/pci.c           | 6 +++---
>   src/util/pci.h           | 1 +
>   4 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 625490f..672a99a 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -986,6 +986,7 @@ virNWFilterVarValueGetSimple;
>   # pci.h
>   pciConfigAddressToSysfsFile;
>   pciDettachDevice;
> +pciDeviceClose;
>   pciDeviceFileIterate;
>   pciDeviceGetManaged;
>   pciDeviceGetName;
> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
> index a748b8b..ef4722e 100644
> --- a/src/qemu/qemu_hostdev.c
> +++ b/src/qemu/qemu_hostdev.c
> @@ -545,9 +545,11 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
>           pciFreeDevice(dev);
>       }
>
> -    /* Loop 9: Now steal all the devices from pcidevs */
> +    /* Loop 9: Now steal all the devices from pcidevs and close
> +     * their config files
> +     */
>       while (pciDeviceListCount(pcidevs)>  0)
> -        pciDeviceListStealIndex(pcidevs, 0);
> +        pciDeviceClose(pciDeviceListStealIndex(pcidevs, 0));
>
>       ret = 0;
>       goto cleanup;
> diff --git a/src/util/pci.c b/src/util/pci.c
> index 3ebf6f7..e32f2e0 100644
> --- a/src/util/pci.c
> +++ b/src/util/pci.c
> @@ -185,8 +185,8 @@ pciOpenConfig(pciDevice *dev)
>       return 0;
>   }
>
> -static void
> -pciCloseConfig(pciDevice *dev)
> +void
> +pciDeviceClose(pciDevice *dev)
>   {
>       if (!dev)
>           return;
> @@ -1407,7 +1407,7 @@ pciFreeDevice(pciDevice *dev)
>       if (!dev)
>           return;
>       VIR_DEBUG("%s %s: freeing", dev->id, dev->name);
> -    pciCloseConfig(dev);
> +    pciDeviceClose(dev);
>       VIR_FREE(dev->path);
>       VIR_FREE(dev);
>   }
> diff --git a/src/util/pci.h b/src/util/pci.h
> index 814c24e..91ebaff 100644
> --- a/src/util/pci.h
> +++ b/src/util/pci.h
> @@ -65,6 +65,7 @@ unsigned  pciDeviceGetReprobe(pciDevice *dev);
>   void      pciDeviceSetReprobe(pciDevice     *dev,
>                                 unsigned      reprobe);
>   void      pciDeviceReAttachInit(pciDevice   *dev);
> +void      pciDeviceClose(pciDevice *dev);
>
>   pciDeviceList *pciDeviceListNew  (void);
>   void           pciDeviceListFree (pciDeviceList *list);

ACK




More information about the libvir-list mailing list