[libvirt] [PATCH 1/8] hostdev: Introduce virDomainHostdevSubsysUSB

Eric Blake eblake at redhat.com
Mon Jul 21 19:32:12 UTC 2014


On 07/11/2014 06:35 AM, John Ferlan wrote:
> Create a separate typedef for the hostdev union data describing USB.
> Then adjust the code to use the new pointer
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/conf/domain_audit.c          |  4 ++--
>  src/conf/domain_conf.c           | 50 +++++++++++++++++++---------------------
>  src/conf/domain_conf.h           | 22 ++++++++++--------
>  src/lxc/lxc_cgroup.c             |  4 ++--
>  src/lxc/lxc_controller.c         | 10 ++++----
>  src/lxc/lxc_driver.c             | 16 ++++++-------
>  src/qemu/qemu_cgroup.c           |  4 ++--
>  src/qemu/qemu_command.c          | 26 ++++++++++-----------
>  src/qemu/qemu_hotplug.c          |  7 +++---
>  src/security/security_apparmor.c |  6 ++---
>  src/security/security_dac.c      | 12 ++++------
>  src/security/security_selinux.c  | 10 ++++----
>  src/security/virt-aa-helper.c    |  5 ++--
>  src/util/virhostdev.c            | 50 +++++++++++++++-------------------------
>  14 files changed, 104 insertions(+), 122 deletions(-)

Mostly mechanical fallout from the type shuffle.

> 
> diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
> index a3d6c67..8277b06 100644
> --- a/src/conf/domain_audit.c
> +++ b/src/conf/domain_audit.c
> @@ -388,6 +388,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
>      char *address = NULL;
>      char *device = NULL;
>      const char *virt;
> +    virDomainHostdevSubsysUSBPtr usbsrc = &hostdev->source.subsys.u.usb;
>  
>      virUUIDFormat(vm->def->uuid, uuidstr);
>      if (!(vmname = virAuditEncode("vm", vm->def->name))) {
> @@ -415,8 +416,7 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr hostdev,
>              break;
>          case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
>              if (virAsprintfQuiet(&address, "%.3d.%.3d",
> -                                 hostdev->source.subsys.u.usb.bus,
> -                                 hostdev->source.subsys.u.usb.device) < 0) {
> +                                 usbsrc->bus, usbsrc->device) < 0) {

I also find it more legible :)


> @@ -10104,15 +10102,18 @@ static int
>  virDomainHostdevMatchSubsysUSB(virDomainHostdevDefPtr a,
>                                 virDomainHostdevDefPtr b)
>  {
> -    if (a->source.subsys.u.usb.bus && a->source.subsys.u.usb.device) {
> +    virDomainHostdevSubsysUSBPtr ausbsrc = &a->source.subsys.u.usb;
> +    virDomainHostdevSubsysUSBPtr busbsrc = &b->source.subsys.u.usb;

I read the second variable as bus_b_src, and tried to figure out what
the first one was (was "aus" a typo for "bus"?).  Until I saw that you
meant b_usb_src.  Might be worth an _ in the naming to keep it easier to
read.  Or even different naming conventions: first, second.

> +++ b/src/conf/domain_conf.h
> @@ -390,20 +390,24 @@ typedef enum {
>  
>  VIR_ENUM_DECL(virDomainHostdevSubsysPCIBackend)
>  
> +typedef struct _virDomainHostdevSubsysUSB virDomainHostdevSubsysUSB;
> +typedef virDomainHostdevSubsysUSB *virDomainHostdevSubsysUSBPtr;
> +struct _virDomainHostdevSubsysUSB {
> +    bool autoAddress; /* bus/device were filled automatically based
> +                         on vedor/product */

Pre-existing typo, but you might as well fix it during the code motion:

> +    unsigned bus;
> +    unsigned device;
> +
> +    unsigned vendor;
> +    unsigned product;
> +};
> +
>  typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
>  typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
>  struct _virDomainHostdevSubsys {
>      int type; /* enum virDomainHostdevSubsysType */
>      union {
> -        struct {
> -            bool autoAddress; /* bus/device were filled automatically based
> -                                 on vedor/product */

s/vedor/vendor/

ACK with nits fixed.

-- 
Eric Blake   eblake 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: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140721/033e98ae/attachment-0001.sig>


More information about the libvir-list mailing list