[libvirt] [PATCH 1/6] conf: make virNodeDevCapData an official type

Laine Stump laine at laine.org
Fri May 15 15:04:24 UTC 2015


For some reason a union (_virNodeDevCapData) that had only been
declared inside the toplevel struct virNodeDevCapsDef was being used
as an argument to functions all over the place. Since it was only a
union, the "type" attribute wasn't necessarily sent with it. While
this works, it just seems wrong.

This patch creates a toplevel typedef for virNodeDevCapData and
virNodeDevCapDataPtr, making it a struct that has the type attribute
as a member, along with an anonymous union of everything that used to
be in union _virNodeDevCapData. This way we only have to change the
following:

  s/union _virNodeDevCapData */virNodeDevCapDataPtr /

and

  s/caps->type/caps->data.type/

This will make me feel less guilty when adding functions that need a
pointer to one of these.
---
 src/conf/node_device_conf.c               | 50 +++++++++++++++----------------
 src/conf/node_device_conf.h               | 16 ++++++----
 src/libxl/libxl_driver.c                  |  4 +--
 src/node_device/node_device_driver.c      | 14 ++++-----
 src/node_device/node_device_driver.h      |  2 +-
 src/node_device/node_device_hal.c         | 20 ++++++-------
 src/node_device/node_device_linux_sysfs.c |  6 ++--
 src/node_device/node_device_udev.c        | 30 +++++++++----------
 src/qemu/qemu_driver.c                    |  2 +-
 src/test/test_driver.c                    |  6 ++--
 src/xen/xen_driver.c                      |  4 +--
 11 files changed, 79 insertions(+), 75 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index feae3d4..e6f3f27 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1,7 +1,7 @@
 /*
  * node_device_conf.c: config handling for node devices
  *
- * Copyright (C) 2009-2014 Red Hat, Inc.
+ * Copyright (C) 2009-2015 Red Hat, Inc.
  * Copyright (C) 2008 Virtual Iron Software, Inc.
  * Copyright (C) 2008 David F. Lively
  *
@@ -76,9 +76,9 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const char *cap)
 {
     virNodeDevCapsDefPtr caps = dev->def->caps;
     while (caps) {
-        if (STREQ(cap, virNodeDevCapTypeToString(caps->type)))
+        if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type)))
             return 1;
-        else if (caps->type == VIR_NODE_DEV_CAP_SCSI_HOST)
+        else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST)
             if ((STREQ(cap, "fc_host") &&
                 (caps->data.scsi_host.flags &
                  VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)) ||
@@ -285,12 +285,12 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def)
 
     for (caps = def->caps; caps; caps = caps->next) {
         char uuidstr[VIR_UUID_STRING_BUFLEN];
-        union _virNodeDevCapData *data = &caps->data;
+        virNodeDevCapDataPtr data = &caps->data;
 
         virBufferAsprintf(&buf, "<capability type='%s'>\n",
-                          virNodeDevCapTypeToString(caps->type));
+                          virNodeDevCapTypeToString(caps->data.type));
         virBufferAdjustIndent(&buf, 2);
-        switch (caps->type) {
+        switch (caps->data.type) {
         case VIR_NODE_DEV_CAP_SYSTEM:
             if (data->system.product_name)
                 virBufferEscapeString(&buf, "<product>%s</product>\n",
@@ -661,7 +661,7 @@ static int
 virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt,
                              virNodeDeviceDefPtr def,
                              xmlNodePtr node,
-                             union _virNodeDevCapData *data)
+                             virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode, *nodes = NULL;
     size_t i;
@@ -755,7 +755,7 @@ static int
 virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt,
                           virNodeDeviceDefPtr def,
                           xmlNodePtr node,
-                          union _virNodeDevCapData *data)
+                          virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
     int ret = -1;
@@ -800,7 +800,7 @@ static int
 virNodeDevCapSCSITargetParseXML(xmlXPathContextPtr ctxt,
                                 virNodeDeviceDefPtr def,
                                 xmlNodePtr node,
-                                union _virNodeDevCapData *data)
+                                virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
     int ret = -1;
@@ -828,7 +828,7 @@ static int
 virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt,
                               virNodeDeviceDefPtr def,
                               xmlNodePtr node,
-                              union _virNodeDevCapData *data,
+                              virNodeDevCapDataPtr data,
                               int create,
                               const char *virt_type)
 {
@@ -932,7 +932,7 @@ static int
 virNodeDevCapNetParseXML(xmlXPathContextPtr ctxt,
                          virNodeDeviceDefPtr def,
                          xmlNodePtr node,
-                         union _virNodeDevCapData *data)
+                         virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode, lnk;
     size_t i = -1;
@@ -1010,7 +1010,7 @@ static int
 virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPtr ctxt,
                                   virNodeDeviceDefPtr def,
                                   xmlNodePtr node,
-                                  union _virNodeDevCapData *data)
+                                  virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
     int ret = -1;
@@ -1077,7 +1077,7 @@ static int
 virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt,
                             virNodeDeviceDefPtr def,
                             xmlNodePtr node,
-                            union _virNodeDevCapData *data)
+                            virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
     int ret = -1;
@@ -1121,7 +1121,7 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt,
 static int
 virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt,
                                       xmlNodePtr iommuGroupNode,
-                                      union _virNodeDevCapData *data)
+                                      virNodeDevCapDataPtr data)
 {
     xmlNodePtr origNode = ctxt->node;
     xmlNodePtr *addrNodes = NULL;
@@ -1259,7 +1259,7 @@ static int
 virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
                             virNodeDeviceDefPtr def,
                             xmlNodePtr node,
-                            union _virNodeDevCapData *data)
+                            virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode, iommuGroupNode, pciExpress;
     int ret = -1;
@@ -1344,7 +1344,7 @@ static int
 virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt,
                             virNodeDeviceDefPtr def,
                             xmlNodePtr node,
-                            union _virNodeDevCapData *data)
+                            virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
     int ret = -1;
@@ -1411,10 +1411,10 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
         VIR_FREE(tmp);
         goto error;
     }
-    caps->type = val;
+    caps->data.type = val;
     VIR_FREE(tmp);
 
-    switch (caps->type) {
+    switch (caps->data.type) {
     case VIR_NODE_DEV_CAP_SYSTEM:
         ret = virNodeDevCapSystemParseXML(ctxt, def, node, &caps->data);
         break;
@@ -1451,7 +1451,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
     case VIR_NODE_DEV_CAP_LAST:
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unknown capability type '%d' for '%s'"),
-                       caps->type, def->name);
+                       caps->data.type, def->name);
         ret = -1;
         break;
     }
@@ -1607,7 +1607,7 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
 
     cap = def->caps;
     while (cap != NULL) {
-        if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST &&
+        if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
             cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
             if (VIR_STRDUP(*wwnn, cap->data.scsi_host.wwnn) < 0 ||
                 VIR_STRDUP(*wwpn, cap->data.scsi_host.wwpn) < 0) {
@@ -1656,7 +1656,7 @@ virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
 
     cap = parent->def->caps;
     while (cap != NULL) {
-        if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST &&
+        if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
             (cap->data.scsi_host.flags &
              VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)) {
                 *parent_host = cap->data.scsi_host.host;
@@ -1683,9 +1683,9 @@ virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
 void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
 {
     size_t i = 0;
-    union _virNodeDevCapData *data = &caps->data;
+    virNodeDevCapDataPtr data = &caps->data;
 
-    switch (caps->type) {
+    switch (caps->data.type) {
     case VIR_NODE_DEV_CAP_SYSTEM:
         VIR_FREE(data->system.product_name);
         VIR_FREE(data->system.hardware.vendor_name);
@@ -1771,10 +1771,10 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
     virNodeDevCapsDefPtr cap = NULL;
 
     for (cap = devobj->def->caps; cap; cap = cap->next) {
-        if (type == cap->type)
+        if (type == cap->data.type)
             return true;
 
-        if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
+        if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
             if (type == VIR_NODE_DEV_CAP_FC_HOST &&
                 (cap->data.scsi_host.flags &
                  VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST))
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 38c6d45..7dd39ca 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -1,7 +1,7 @@
 /*
  * node_device_conf.h: config handling for node devices
  *
- * Copyright (C) 2009-2014 Red Hat, Inc.
+ * Copyright (C) 2009-2015 Red Hat, Inc.
  * Copyright (C) 2008 Virtual Iron Software, Inc.
  * Copyright (C) 2008 David F. Lively
  *
@@ -82,11 +82,9 @@ typedef enum {
     VIR_NODE_DEV_CAP_FLAG_PCIE                      = (1 << 2),
 } virNodeDevPCICapFlags;
 
-typedef struct _virNodeDevCapsDef virNodeDevCapsDef;
-typedef virNodeDevCapsDef *virNodeDevCapsDefPtr;
-struct _virNodeDevCapsDef {
+typedef struct _virNodeDevCapData {
     virNodeDevCapType type;
-    union _virNodeDevCapData {
+    union {
         struct {
             char *product_name;
             struct {
@@ -181,7 +179,13 @@ struct _virNodeDevCapsDef {
         struct {
             char *path;
         } sg; /* SCSI generic device */
-    } data;
+    };
+} virNodeDevCapData, *virNodeDevCapDataPtr;
+
+typedef struct _virNodeDevCapsDef virNodeDevCapsDef;
+typedef virNodeDevCapsDef *virNodeDevCapsDefPtr;
+struct _virNodeDevCapsDef {
+    virNodeDevCapData data;
     virNodeDevCapsDefPtr next;          /* next capability */
 };
 
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 60c139e..8a8bc85 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1,7 +1,7 @@
 /*
  * libxl_driver.c: core driver methods for managing libxenlight domains
  *
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
  * Copyright (C) 2011-2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
  * Copyright (C) 2011 Univention GmbH.
  *
@@ -4620,7 +4620,7 @@ libxlNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
 
     cap = def->caps;
     while (cap) {
-        if (cap->type == VIR_NODE_DEV_CAP_PCI_DEV) {
+        if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
             *domain   = cap->data.pci_dev.domain;
             *bus      = cap->data.pci_dev.bus;
             *slot     = cap->data.pci_dev.slot;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index b8d9f4f..a14191c 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -1,7 +1,7 @@
 /*
  * node_device_driver.c: node device enumeration
  *
- * Copyright (C) 2010-2014 Red Hat, Inc.
+ * Copyright (C) 2010-2015 Red Hat, Inc.
  * Copyright (C) 2008 Virtual Iron Software, Inc.
  * Copyright (C) 2008 David F. Lively
  *
@@ -50,9 +50,9 @@ static int update_caps(virNodeDeviceObjPtr dev)
     virNodeDevCapsDefPtr cap = dev->def->caps;
 
     while (cap) {
-        if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST)
+        if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST)
             detect_scsi_host_caps(&dev->def->caps->data);
-        if (cap->type == VIR_NODE_DEV_CAP_NET &&
+        if (cap->data.type == VIR_NODE_DEV_CAP_NET &&
             virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0)
             return -1;
 
@@ -262,7 +262,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
         cap = obj->def->caps;
 
         while (cap) {
-            if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
+            if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
                 detect_scsi_host_caps(&cap->data);
                 if (cap->data.scsi_host.flags &
                     VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
@@ -386,7 +386,7 @@ nodeDeviceNumOfCaps(virNodeDevicePtr dev)
     for (caps = obj->def->caps; caps; caps = caps->next) {
         ++ncaps;
 
-        if (caps->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
+        if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
             if (caps->data.scsi_host.flags &
                 VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)
                 ncaps++;
@@ -429,10 +429,10 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
         goto cleanup;
 
     for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
-        if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->type)) < 0)
+        if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->data.type)) < 0)
             goto cleanup;
 
-        if (caps->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
+        if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
             if (ncaps < maxnames &&
                 caps->data.scsi_host.flags &
                 VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h
index 79583cd..81bca98 100644
--- a/src/node_device/node_device_driver.h
+++ b/src/node_device/node_device_driver.h
@@ -44,7 +44,7 @@ extern virNodeDeviceDriverStatePtr driver;
 
 int nodedevRegister(void);
 
-int detect_scsi_host_caps(union _virNodeDevCapData *d);
+int detect_scsi_host_caps(virNodeDevCapDataPtr d);
 
 int nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags);
 int nodeListDevices(virConnectPtr conn, const char *cap, char **const names,
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index fa37787..38e09c4 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -139,7 +139,7 @@ get_uint64_prop(LibHalContext *ctxt, const char *udi,
 
 static int
 gather_pci_cap(LibHalContext *ctx, const char *udi,
-               union _virNodeDevCapData *d)
+               virNodeDevCapDataPtr d)
 {
     char *sysfs_path;
 
@@ -182,7 +182,7 @@ gather_pci_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_usb_cap(LibHalContext *ctx, const char *udi,
-               union _virNodeDevCapData *d)
+               virNodeDevCapDataPtr d)
 {
     (void)get_int_prop(ctx, udi, "usb.interface.number",
                        (int *)&d->usb_if.number);
@@ -200,7 +200,7 @@ gather_usb_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_usb_device_cap(LibHalContext *ctx, const char *udi,
-                      union _virNodeDevCapData *d)
+                      virNodeDevCapDataPtr d)
 {
     (void)get_int_prop(ctx, udi, "usb_device.bus_number",
                        (int *)&d->usb_dev.bus);
@@ -222,7 +222,7 @@ gather_usb_device_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_net_cap(LibHalContext *ctx, const char *udi,
-               union _virNodeDevCapData *d)
+               virNodeDevCapDataPtr d)
 {
     unsigned long long dummy;
     (void)get_str_prop(ctx, udi, "net.interface", &d->net.ifname);
@@ -242,7 +242,7 @@ gather_net_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_scsi_host_cap(LibHalContext *ctx, const char *udi,
-                     union _virNodeDevCapData *d)
+                     virNodeDevCapDataPtr d)
 {
     int retval = 0;
 
@@ -260,7 +260,7 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_scsi_cap(LibHalContext *ctx, const char *udi,
-                union _virNodeDevCapData *d)
+                virNodeDevCapDataPtr d)
 {
     (void)get_int_prop(ctx, udi, "scsi.host", (int *)&d->scsi.host);
     (void)get_int_prop(ctx, udi, "scsi.bus", (int *)&d->scsi.bus);
@@ -273,7 +273,7 @@ gather_scsi_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_storage_cap(LibHalContext *ctx, const char *udi,
-                   union _virNodeDevCapData *d)
+                   virNodeDevCapDataPtr d)
 {
     int val;
     (void)get_str_prop(ctx, udi, "block.device", &d->storage.block);
@@ -301,7 +301,7 @@ gather_storage_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_scsi_generic_cap(LibHalContext *ctx, const char *udi,
-                        union _virNodeDevCapData *d)
+                        virNodeDevCapDataPtr d)
 {
     (void)get_str_prop(ctx, udi, "scsi_generic.device", &d->sg.path);
     return 0;
@@ -310,7 +310,7 @@ gather_scsi_generic_cap(LibHalContext *ctx, const char *udi,
 
 static int
 gather_system_cap(LibHalContext *ctx, const char *udi,
-                  union _virNodeDevCapData *d)
+                  virNodeDevCapDataPtr d)
 {
     char *uuidstr;
 
@@ -340,7 +340,7 @@ struct _caps_tbl_entry {
     virNodeDevCapType type;
     int (*gather_fn)(LibHalContext *ctx,
                      const char *udi,
-                     union _virNodeDevCapData *data);
+                     virNodeDevCapDataPtr data);
 };
 
 typedef struct _caps_tbl_entry caps_tbl_entry;
diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c
index 4a95b2b..d4c2a3c 100644
--- a/src/node_device/node_device_linux_sysfs.c
+++ b/src/node_device/node_device_linux_sysfs.c
@@ -2,7 +2,7 @@
  * node_device_linux_sysfs.c: Linux specific code to gather device data
  * not available through HAL.
  *
- * Copyright (C) 2009-2013 Red Hat, Inc.
+ * Copyright (C) 2009-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -41,7 +41,7 @@
 VIR_LOG_INIT("node_device.node_device_linux_sysfs");
 
 int
-detect_scsi_host_caps(union _virNodeDevCapData *d)
+detect_scsi_host_caps(virNodeDevCapDataPtr d)
 {
     char *max_vports = NULL;
     char *vports = NULL;
@@ -139,7 +139,7 @@ detect_scsi_host_caps(union _virNodeDevCapData *d)
 #else
 
 int
-detect_scsi_host_caps(union _virNodeDevCapData *d ATTRIBUTE_UNUSED)
+detect_scsi_host_caps(virNodeDevCapDataPtr d ATTRIBUTE_UNUSED)
 {
     return -1;
 }
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 846f570..b6619bd 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -411,7 +411,7 @@ static int udevProcessPCI(struct udev_device *device,
                           virNodeDeviceDefPtr def)
 {
     const char *syspath = NULL;
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     virPCIDeviceAddress addr;
     virPCIEDeviceInfoPtr pci_express = NULL;
     virPCIDevicePtr pciDev = NULL;
@@ -567,7 +567,7 @@ static int udevProcessPCI(struct udev_device *device,
 static int udevProcessUSBDevice(struct udev_device *device,
                                 virNodeDeviceDefPtr def)
 {
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     int ret = -1;
     int err;
 
@@ -639,7 +639,7 @@ static int udevProcessUSBInterface(struct udev_device *device,
                                    virNodeDeviceDefPtr def)
 {
     int ret = -1;
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
 
     if (udevGetUintSysfsAttr(device,
                              "bInterfaceNumber",
@@ -684,7 +684,7 @@ static int udevProcessNetworkInterface(struct udev_device *device,
 {
     int ret = -1;
     const char *devtype = udev_device_get_devtype(device);
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
 
     if (devtype && STREQ(devtype, "wlan")) {
         data->net.subtype = VIR_NODE_DEV_CAP_NET_80211;
@@ -731,7 +731,7 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
                                virNodeDeviceDefPtr def)
 {
     int ret = -1;
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     char *filename = NULL;
 
     filename = last_component(def->sysfs_path);
@@ -766,7 +766,7 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED,
 {
     int ret = -1;
     const char *sysname = NULL;
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
 
     sysname = udev_device_get_sysname(device);
 
@@ -846,7 +846,7 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
 {
     int ret = -1;
     unsigned int tmp = 0;
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     char *filename = NULL, *p = NULL;
 
     filename = last_component(def->sysfs_path);
@@ -905,7 +905,7 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
 static int udevProcessDisk(struct udev_device *device,
                            virNodeDeviceDefPtr def)
 {
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     int ret = 0;
 
     if (udevGetUint64SysfsAttr(device,
@@ -933,7 +933,7 @@ static int udevProcessRemoveableMedia(struct udev_device *device,
                                       virNodeDeviceDefPtr def,
                                       int has_media)
 {
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     int tmp_int = 0, ret = 0;
 
     if ((udevGetIntSysfsAttr(device, "removable", &tmp_int, 0) == PROPERTY_FOUND) &&
@@ -1025,7 +1025,7 @@ static int udevProcessFloppy(struct udev_device *device,
 static int udevProcessSD(struct udev_device *device,
                          virNodeDeviceDefPtr def)
 {
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     int ret = 0;
 
     if (udevGetUint64SysfsAttr(device,
@@ -1098,7 +1098,7 @@ static void udevStripSpaces(char *s)
 static int udevProcessStorage(struct udev_device *device,
                               virNodeDeviceDefPtr def)
 {
-    union _virNodeDevCapData *data = &def->caps->data;
+    virNodeDevCapDataPtr data = &def->caps->data;
     int ret = -1;
     const char* devnode;
 
@@ -1281,7 +1281,7 @@ static int udevGetDeviceDetails(struct udev_device *device,
 {
     int ret = 0;
 
-    switch (def->caps->type) {
+    switch (def->caps->data.type) {
     case VIR_NODE_DEV_CAP_SYSTEM:
         /* There's no libudev equivalent of system, so ignore it. */
         break;
@@ -1313,7 +1313,7 @@ static int udevGetDeviceDetails(struct udev_device *device,
         ret = udevProcessSCSIGeneric(device, def);
         break;
     default:
-        VIR_ERROR(_("Unknown device type %d"), def->caps->type);
+        VIR_ERROR(_("Unknown device type %d"), def->caps->data.type);
         ret = -1;
         break;
     }
@@ -1414,7 +1414,7 @@ static int udevAddOneDevice(struct udev_device *device)
     if (VIR_ALLOC(def->caps) != 0)
         goto out;
 
-    if (udevGetDeviceType(device, &def->caps->type) != 0)
+    if (udevGetDeviceType(device, &def->caps->data.type) != 0)
         goto out;
 
     if (udevGetDeviceDetails(device, def) != 0)
@@ -1588,7 +1588,7 @@ static void udevEventHandleCallback(int watch ATTRIBUTE_UNUSED,
 /* DMI is intel-compatible specific */
 #if defined(__x86_64__) || defined(__i386__) || defined(__amd64__)
 static void
-udevGetDMIData(union _virNodeDevCapData *data)
+udevGetDMIData(virNodeDevCapDataPtr data)
 {
     struct udev *udev = NULL;
     struct udev_device *device = NULL;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2668011..8c00cdc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13091,7 +13091,7 @@ qemuNodeDeviceGetPCIInfo(virNodeDeviceDefPtr def,
 
     cap = def->caps;
     while (cap) {
-        if (cap->type == VIR_NODE_DEV_CAP_PCI_DEV) {
+        if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
             *domain   = cap->data.pci_dev.domain;
             *bus      = cap->data.pci_dev.bus;
             *slot     = cap->data.pci_dev.slot;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 51ab2e0..038b2b8 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1,7 +1,7 @@
 /*
  * test_driver.c: A "mock" hypervisor for use by application unit tests
  *
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -5798,7 +5798,7 @@ testNodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
     }
 
     for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
-        if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->type)) < 0)
+        if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->data.type)) < 0)
             goto cleanup;
     }
     ret = ncaps;
@@ -5856,7 +5856,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
      * since this would also come from the backend */
     caps = def->caps;
     while (caps) {
-        if (caps->type != VIR_NODE_DEV_CAP_SCSI_HOST)
+        if (caps->data.type != VIR_NODE_DEV_CAP_SCSI_HOST)
             continue;
 
         caps->data.scsi_host.host = virRandomBits(10);
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 7711f33..da9e6f4 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1,7 +1,7 @@
 /*
  * xen_driver.c: Unified Xen driver.
  *
- * Copyright (C) 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2007-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2488,7 +2488,7 @@ xenUnifiedNodeDeviceGetPCIInfo(virNodeDevicePtr dev,
 
     cap = def->caps;
     while (cap) {
-        if (cap->type == VIR_NODE_DEV_CAP_PCI_DEV) {
+        if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
             *domain   = cap->data.pci_dev.domain;
             *bus      = cap->data.pci_dev.bus;
             *slot     = cap->data.pci_dev.slot;
-- 
2.1.0




More information about the libvir-list mailing list