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

Re: [libvirt] [PATCH 1/8] Remove virConnectPtr from USB/PCI device iterators



On Wed, Feb 10, 2010 at 01:36:19PM +0000, Daniel P. Berrange wrote:
> All callers now pass a NULL virConnectPtr into the USB/PCi device
> iterator functions. Therefore the virConnectPtr arg can now be
> removed from these functions
> 
> * src/util/hostusb.h, src/util/hostusb.c: Remove virConnectPtr
>   from usbDeviceFileIterate
> * src/util/pci.c, src/util/pci.h: Remove virConnectPtr arg from
>   pciDeviceFileIterate
> * src/qemu/qemu_security_dac.c, src/security/security_selinux.c: Update
>   to drop redundant virConnectPtr arg
> ---
>  src/qemu/qemu_security_dac.c    |   20 ++++++++------------
>  src/security/security_selinux.c |   20 ++++++++------------
>  src/util/hostusb.c              |    5 ++---
>  src/util/hostusb.h              |    5 ++---
>  src/util/pci.c                  |    5 ++---
>  src/util/pci.h                  |    5 ++---
>  6 files changed, 24 insertions(+), 36 deletions(-)
> 
> diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c
> index 11f41b3..f281b96 100644
> --- a/src/qemu/qemu_security_dac.c
> +++ b/src/qemu/qemu_security_dac.c
> @@ -173,8 +173,7 @@ qemuSecurityDACRestoreSecurityImageLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED,
>  
>  
>  static int
> -qemuSecurityDACSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                                   pciDevice *dev ATTRIBUTE_UNUSED,
> +qemuSecurityDACSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
>                                     const char *file,
>                                     void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -183,8 +182,7 @@ qemuSecurityDACSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
>  
>  
>  static int
> -qemuSecurityDACSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                                   usbDevice *dev ATTRIBUTE_UNUSED,
> +qemuSecurityDACSetSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
>                                     const char *file,
>                                     void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -215,7 +213,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!usb)
>              goto done;
>  
> -        ret = usbDeviceFileIterate(NULL, usb, qemuSecurityDACSetSecurityUSBLabel, vm);
> +        ret = usbDeviceFileIterate(usb, qemuSecurityDACSetSecurityUSBLabel, vm);
>          usbFreeDevice(usb);
>          break;
>      }
> @@ -229,7 +227,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!pci)
>              goto done;
>  
> -        ret = pciDeviceFileIterate(NULL, pci, qemuSecurityDACSetSecurityPCILabel, vm);
> +        ret = pciDeviceFileIterate(pci, qemuSecurityDACSetSecurityPCILabel, vm);
>          pciFreeDevice(pci);
>  
>          break;
> @@ -246,8 +244,7 @@ done:
>  
>  
>  static int
> -qemuSecurityDACRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                                       pciDevice *dev ATTRIBUTE_UNUSED,
> +qemuSecurityDACRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
>                                         const char *file,
>                                         void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -256,8 +253,7 @@ qemuSecurityDACRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
>  
>  
>  static int
> -qemuSecurityDACRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                                       usbDevice *dev ATTRIBUTE_UNUSED,
> +qemuSecurityDACRestoreSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
>                                         const char *file,
>                                         void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -288,7 +284,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED,
>          if (!usb)
>              goto done;
>  
> -        ret = usbDeviceFileIterate(NULL, usb, qemuSecurityDACRestoreSecurityUSBLabel, NULL);
> +        ret = usbDeviceFileIterate(usb, qemuSecurityDACRestoreSecurityUSBLabel, NULL);
>          usbFreeDevice(usb);
>  
>          break;
> @@ -303,7 +299,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED,
>          if (!pci)
>              goto done;
>  
> -        ret = pciDeviceFileIterate(NULL, pci, qemuSecurityDACRestoreSecurityPCILabel, NULL);
> +        ret = pciDeviceFileIterate(pci, qemuSecurityDACRestoreSecurityPCILabel, NULL);
>          pciFreeDevice(pci);
>  
>          break;
> diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
> index 7507549..06a2479 100644
> --- a/src/security/security_selinux.c
> +++ b/src/security/security_selinux.c
> @@ -455,8 +455,7 @@ SELinuxSetSecurityImageLabel(virDomainObjPtr vm,
>  
>  
>  static int
> -SELinuxSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                           pciDevice *dev ATTRIBUTE_UNUSED,
> +SELinuxSetSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
>                             const char *file, void *opaque)
>  {
>      virDomainObjPtr vm = opaque;
> @@ -466,8 +465,7 @@ SELinuxSetSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
>  }
>  
>  static int
> -SELinuxSetSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                           usbDevice *dev ATTRIBUTE_UNUSED,
> +SELinuxSetSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
>                             const char *file, void *opaque)
>  {
>      virDomainObjPtr vm = opaque;
> @@ -500,7 +498,7 @@ SELinuxSetSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!usb)
>              goto done;
>  
> -        ret = usbDeviceFileIterate(NULL, usb, SELinuxSetSecurityUSBLabel, vm);
> +        ret = usbDeviceFileIterate(usb, SELinuxSetSecurityUSBLabel, vm);
>          usbFreeDevice(usb);
>          break;
>      }
> @@ -514,7 +512,7 @@ SELinuxSetSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!pci)
>              goto done;
>  
> -        ret = pciDeviceFileIterate(NULL, pci, SELinuxSetSecurityPCILabel, vm);
> +        ret = pciDeviceFileIterate(pci, SELinuxSetSecurityPCILabel, vm);
>          pciFreeDevice(pci);
>  
>          break;
> @@ -531,8 +529,7 @@ done:
>  
>  
>  static int
> -SELinuxRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                               pciDevice *dev ATTRIBUTE_UNUSED,
> +SELinuxRestoreSecurityPCILabel(pciDevice *dev ATTRIBUTE_UNUSED,
>                                 const char *file,
>                                 void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -540,8 +537,7 @@ SELinuxRestoreSecurityPCILabel(virConnectPtr conn ATTRIBUTE_UNUSED,
>  }
>  
>  static int
> -SELinuxRestoreSecurityUSBLabel(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                               usbDevice *dev ATTRIBUTE_UNUSED,
> +SELinuxRestoreSecurityUSBLabel(usbDevice *dev ATTRIBUTE_UNUSED,
>                                 const char *file,
>                                 void *opaque ATTRIBUTE_UNUSED)
>  {
> @@ -572,7 +568,7 @@ SELinuxRestoreSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!usb)
>              goto done;
>  
> -        ret = usbDeviceFileIterate(NULL, usb, SELinuxRestoreSecurityUSBLabel, NULL);
> +        ret = usbDeviceFileIterate(usb, SELinuxRestoreSecurityUSBLabel, NULL);
>          usbFreeDevice(usb);
>  
>          break;
> @@ -587,7 +583,7 @@ SELinuxRestoreSecurityHostdevLabel(virDomainObjPtr vm,
>          if (!pci)
>              goto done;
>  
> -        ret = pciDeviceFileIterate(NULL, pci, SELinuxRestoreSecurityPCILabel, NULL);
> +        ret = pciDeviceFileIterate(pci, SELinuxRestoreSecurityPCILabel, NULL);
>          pciFreeDevice(pci);
>  
>          break;
> diff --git a/src/util/hostusb.c b/src/util/hostusb.c
> index 7ed262b..3cce66b 100644
> --- a/src/util/hostusb.c
> +++ b/src/util/hostusb.c
> @@ -202,10 +202,9 @@ usbFreeDevice(usbDevice *dev)
>  }
>  
>  
> -int usbDeviceFileIterate(virConnectPtr conn,
> -                         usbDevice *dev,
> +int usbDeviceFileIterate(usbDevice *dev,
>                           usbDeviceFileActor actor,
>                           void *opaque)
>  {
> -    return (actor)(conn, dev, dev->path, opaque);
> +    return (actor)(dev, dev->path, opaque);
>  }
> diff --git a/src/util/hostusb.h b/src/util/hostusb.h
> index 2579bdb..bc22671 100644
> --- a/src/util/hostusb.h
> +++ b/src/util/hostusb.h
> @@ -39,11 +39,10 @@ void       usbFreeDevice     (usbDevice     *dev);
>   * Should return 0 if successfully processed, or
>   * -1 to indicate error and abort iteration
>   */
> -typedef int (*usbDeviceFileActor)(virConnectPtr conn, usbDevice *dev,
> +typedef int (*usbDeviceFileActor)(usbDevice *dev,
>                                    const char *path, void *opaque);
>  
> -int usbDeviceFileIterate(virConnectPtr conn,
> -                         usbDevice *dev,
> +int usbDeviceFileIterate(usbDevice *dev,
>                           usbDeviceFileActor actor,
>                           void *opaque);
>  
> diff --git a/src/util/pci.c b/src/util/pci.c
> index e639910..44eb439 100644
> --- a/src/util/pci.c
> +++ b/src/util/pci.c
> @@ -1194,8 +1194,7 @@ pciDeviceListFind(pciDeviceList *list, pciDevice *dev)
>  }
>  
>  
> -int pciDeviceFileIterate(virConnectPtr conn,
> -                         pciDevice *dev,
> +int pciDeviceFileIterate(pciDevice *dev,
>                           pciDeviceFileActor actor,
>                           void *opaque)
>  {
> @@ -1228,7 +1227,7 @@ int pciDeviceFileIterate(virConnectPtr conn,
>                  virReportOOMError();
>                  goto cleanup;
>              }
> -            if ((actor)(conn, dev, file, opaque) < 0)
> +            if ((actor)(dev, file, opaque) < 0)
>                  goto cleanup;
>  
>              VIR_FREE(file);
> diff --git a/src/util/pci.h b/src/util/pci.h
> index ad518a5..b31d0cf 100644
> --- a/src/util/pci.h
> +++ b/src/util/pci.h
> @@ -61,11 +61,10 @@ pciDevice *    pciDeviceListFind (pciDeviceList *list,
>   * Should return 0 if successfully processed, or
>   * -1 to indicate error and abort iteration
>   */
> -typedef int (*pciDeviceFileActor)(virConnectPtr conn, pciDevice *dev,
> +typedef int (*pciDeviceFileActor)(pciDevice *dev,
>                                    const char *path, void *opaque);
>  
> -int pciDeviceFileIterate(virConnectPtr conn,
> -                         pciDevice *dev,
> +int pciDeviceFileIterate(pciDevice *dev,
>                           pciDeviceFileActor actor,
>                           void *opaque);
>  

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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