提交 ffc40b63 编写于 作者: L Laine Stump

conf: make virNodeDevCapData an official type

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