1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

conf: Clean up the _virNodeDevCapData

Rather than a bunch of embedded union structs, let's create structs
for each of the structs within the union and make the struct easier
to read.
This commit is contained in:
John Ferlan 2017-03-02 10:08:53 -05:00
parent 25ad94ecf5
commit a6c3382e8e

View File

@ -103,108 +103,160 @@ typedef enum {
VIR_ENUM_DECL(virNodeDevDRM)
typedef struct _virNodeDevCapSystemHardware virNodeDevCapSystemHardware;
typedef virNodeDevCapSystemHardware *virNodeDevCapSystemHardwarePtr;
struct _virNodeDevCapSystemHardware {
char *vendor_name;
char *version;
char *serial;
unsigned char uuid[VIR_UUID_BUFLEN];
};
typedef struct _virNodeDevCapSystemFirmware virNodeDevCapSystemFirmware;
typedef virNodeDevCapSystemFirmware *virNodeDevCapSystemFirmwarePtr;
struct _virNodeDevCapSystemFirmware {
char *vendor_name;
char *version;
char *release_date;
};
typedef struct _virNodeDevCapSystem virNodeDevCapSystem;
typedef virNodeDevCapSystem *virNodeDevCapSystemPtr;
struct _virNodeDevCapSystem {
char *product_name;
virNodeDevCapSystemHardware hardware;
virNodeDevCapSystemFirmware firmware;
};
typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev;
typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr;
struct _virNodeDevCapPCIDev {
unsigned int domain;
unsigned int bus;
unsigned int slot;
unsigned int function;
unsigned int product;
unsigned int vendor;
unsigned int class;
char *product_name;
char *vendor_name;
virPCIDeviceAddressPtr physical_function;
virPCIDeviceAddressPtr *virtual_functions;
size_t num_virtual_functions;
unsigned int max_virtual_functions;
unsigned int flags;
virPCIDeviceAddressPtr *iommuGroupDevices;
size_t nIommuGroupDevices;
unsigned int iommuGroupNumber;
int numa_node;
virPCIEDeviceInfoPtr pci_express;
int hdrType; /* enum virPCIHeaderType or -1 */
};
typedef struct _virNodeDevCapUSBDev virNodeDevCapUSBDev;
typedef virNodeDevCapUSBDev *virNodeDevCapUSBDevPtr;
struct _virNodeDevCapUSBDev {
unsigned int bus;
unsigned int device;
unsigned int product;
unsigned int vendor;
char *product_name;
char *vendor_name;
};
typedef struct _virNodeDevCapUSBIf virNodeDevCapUSBIf;
typedef virNodeDevCapUSBIf *virNodeDevCapUSBIfPtr;
struct _virNodeDevCapUSBIf {
unsigned int number;
unsigned int _class; /* "class" is reserved in C */
unsigned int subclass;
unsigned int protocol;
char *description;
};
typedef struct _virNodeDevCapNet virNodeDevCapNet;
typedef virNodeDevCapNet *virNodeDevCapNetPtr;
struct _virNodeDevCapNet {
char *address;
unsigned int address_len;
char *ifname;
virNetDevIfLink lnk;
virNodeDevNetCapType subtype; /* LAST -> no subtype */
virBitmapPtr features; /* enum virNetDevFeature */
};
typedef struct _virNodeDevCapSCSIHost virNodeDevCapSCSIHost;
typedef virNodeDevCapSCSIHost *virNodeDevCapSCSIHostPtr;
struct _virNodeDevCapSCSIHost {
unsigned int host;
int unique_id;
char *wwnn;
char *wwpn;
char *fabric_wwn;
unsigned int flags;
int max_vports;
int vports;
};
typedef struct _virNodeDevCapSCSITarget virNodeDevCapSCSITarget;
typedef virNodeDevCapSCSITarget *virNodeDevCapSCSITargetPtr;
struct _virNodeDevCapSCSITarget {
char *name;
};
typedef struct _virNodeDevCapSCSI virNodeDevCapSCSI;
typedef virNodeDevCapSCSI *virNodeDevCapSCSIPtr;
struct _virNodeDevCapSCSI {
unsigned int host;
unsigned int bus;
unsigned int target;
unsigned int lun;
char *type;
};
typedef struct _virNodeDevCapStorage virNodeDevCapStorage;
typedef virNodeDevCapStorage *virNodeDevCapStoragePtr;
struct _virNodeDevCapStorage {
unsigned long long size;
unsigned long long num_blocks;
unsigned long long logical_block_size;
unsigned long long removable_media_size;
char *block;
char *bus;
char *drive_type;
char *model;
char *vendor;
char *serial;
char *media_label;
unsigned int flags; /* virNodeDevStorageCapFlags bits */
};
typedef struct _virNodeDevCapSCSIGeneric virNodeDevCapSCSIGeneric;
typedef virNodeDevCapSCSIGeneric *virNodeDevCapSCSIGenericPtr;
struct _virNodeDevCapSCSIGeneric {
char *path;
};
typedef struct _virNodeDevCapDRM virNodeDevCapDRM;
typedef virNodeDevCapDRM *virNodeDevCapDRMPtr;
struct _virNodeDevCapDRM {
virNodeDevDRMType type;
};
typedef struct _virNodeDevCapData {
virNodeDevCapType type;
union {
struct {
char *product_name;
struct {
char *vendor_name;
char *version;
char *serial;
unsigned char uuid[VIR_UUID_BUFLEN];
} hardware;
struct {
char *vendor_name;
char *version;
char *release_date;
} firmware;
} system;
struct {
unsigned int domain;
unsigned int bus;
unsigned int slot;
unsigned int function;
unsigned int product;
unsigned int vendor;
unsigned int class;
char *product_name;
char *vendor_name;
virPCIDeviceAddressPtr physical_function;
virPCIDeviceAddressPtr *virtual_functions;
size_t num_virtual_functions;
unsigned int max_virtual_functions;
unsigned int flags;
virPCIDeviceAddressPtr *iommuGroupDevices;
size_t nIommuGroupDevices;
unsigned int iommuGroupNumber;
int numa_node;
virPCIEDeviceInfoPtr pci_express;
int hdrType; /* enum virPCIHeaderType or -1 */
} pci_dev;
struct {
unsigned int bus;
unsigned int device;
unsigned int product;
unsigned int vendor;
char *product_name;
char *vendor_name;
} usb_dev;
struct {
unsigned int number;
unsigned int _class; /* "class" is reserved in C */
unsigned int subclass;
unsigned int protocol;
char *description;
} usb_if;
struct {
char *address;
unsigned int address_len;
char *ifname;
virNetDevIfLink lnk;
virNodeDevNetCapType subtype; /* LAST -> no subtype */
virBitmapPtr features; /* enum virNetDevFeature */
} net;
struct {
unsigned int host;
int unique_id;
char *wwnn;
char *wwpn;
char *fabric_wwn;
unsigned int flags;
int max_vports;
int vports;
} scsi_host;
struct {
char *name;
} scsi_target;
struct {
unsigned int host;
unsigned int bus;
unsigned int target;
unsigned int lun;
char *type;
} scsi;
struct {
unsigned long long size;
unsigned long long num_blocks;
unsigned long long logical_block_size;
unsigned long long removable_media_size;
char *block;
char *bus;
char *drive_type;
char *model;
char *vendor;
char *serial;
char *media_label;
unsigned int flags; /* virNodeDevStorageCapFlags bits */
} storage;
struct {
char *path;
} sg; /* SCSI generic device */
struct {
virNodeDevDRMType type;
} drm;
virNodeDevCapSystem system;
virNodeDevCapPCIDev pci_dev;
virNodeDevCapUSBDev usb_dev;
virNodeDevCapUSBIf usb_if;
virNodeDevCapNet net;
virNodeDevCapSCSIHost scsi_host;
virNodeDevCapSCSITarget scsi_target;
virNodeDevCapSCSI scsi;
virNodeDevCapStorage storage;
virNodeDevCapSCSIGeneric sg;
virNodeDevCapDRM drm;
};
} virNodeDevCapData, *virNodeDevCapDataPtr;