This patch is only code movement + adding some forward definitions of
typedefs.
virDomainHostdevDef (not just a pointer to it, but an actual object)
will be needed in virDomainNetDef and virDomainActualNetDef, so it
must be relocated earlier in the file.
Likewise, virDomainDeviceDef will be needed in virDomainHostdevDef, so
it must be moved up even earlier. This, in turn, creates a forward
reference problem, but fortunately only with pointers to other device
types, so their typedefs can be moved up in the file, eliminating the
problem.
Also, a DEVICE_TYPE_NONE is added, to indicate that a
virDomainDeviceDef doesn't point to a valid device.
---
src/conf/domain_conf.c | 1 +
src/conf/domain_conf.h | 212 +++++++++++++++++++++++++++++-------------------
2 files changed, 129 insertions(+), 84 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 137fb73..7f53082 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -123,6 +123,7 @@ VIR_ENUM_IMPL(virDomainLifecycleCrash,
VIR_DOMAIN_LIFECYCLE_CRASH_LAST,
"coredump-restart")
VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
+ "none",
"disk",
"lease",
"filesystem",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1f7f25a..25019e7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -44,6 +44,89 @@
# include "virnetdevopenvswitch.h"
# include "virnetdevbandwidth.h"
+/* forward declarations of all device types, required by
+ * virDomainDeviceDef
+ */
+typedef struct _virDomainDiskDef virDomainDiskDef;
+typedef virDomainDiskDef *virDomainDiskDefPtr;
+
+typedef struct _virDomainControllerDef virDomainControllerDef;
+typedef virDomainControllerDef *virDomainControllerDefPtr;
+
+typedef struct _virDomainLeaseDef virDomainLeaseDef;
+typedef virDomainLeaseDef *virDomainLeaseDefPtr;
+
+typedef struct _virDomainFSDef virDomainFSDef;
+typedef virDomainFSDef *virDomainFSDefPtr;
+
+typedef struct _virDomainNetDef virDomainNetDef;
+typedef virDomainNetDef *virDomainNetDefPtr;
+
+typedef struct _virDomainInputDef virDomainInputDef;
+typedef virDomainInputDef *virDomainInputDefPtr;
+
+typedef struct _virDomainSoundDef virDomainSoundDef;
+typedef virDomainSoundDef *virDomainSoundDefPtr;
+
+typedef struct _virDomainVideoDef virDomainVideoDef;
+typedef virDomainVideoDef *virDomainVideoDefPtr;
+
+typedef struct _virDomainHostdevDef virDomainHostdevDef;
+typedef virDomainHostdevDef *virDomainHostdevDefPtr;
+
+typedef struct _virDomainWatchdogDef virDomainWatchdogDef;
+typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;
+
+typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
+typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
+
+typedef struct _virDomainHubDef virDomainHubDef;
+typedef virDomainHubDef *virDomainHubDefPtr;
+
+typedef struct _virDomainRedirdevDef virDomainRedirdevDef;
+typedef virDomainRedirdevDef *virDomainRedirdevDefPtr;
+
+/* Flags for the 'type' field in next struct */
+enum virDomainDeviceType {
+ VIR_DOMAIN_DEVICE_NONE = 0,
+ VIR_DOMAIN_DEVICE_DISK,
+ VIR_DOMAIN_DEVICE_LEASE,
+ VIR_DOMAIN_DEVICE_FS,
+ VIR_DOMAIN_DEVICE_NET,
+ VIR_DOMAIN_DEVICE_INPUT,
+ VIR_DOMAIN_DEVICE_SOUND,
+ VIR_DOMAIN_DEVICE_VIDEO,
+ VIR_DOMAIN_DEVICE_HOSTDEV,
+ VIR_DOMAIN_DEVICE_WATCHDOG,
+ VIR_DOMAIN_DEVICE_CONTROLLER,
+ VIR_DOMAIN_DEVICE_GRAPHICS,
+ VIR_DOMAIN_DEVICE_HUB,
+ VIR_DOMAIN_DEVICE_REDIRDEV,
+
+ VIR_DOMAIN_DEVICE_LAST,
+};
+
+typedef struct _virDomainDeviceDef virDomainDeviceDef;
+typedef virDomainDeviceDef *virDomainDeviceDefPtr;
+struct _virDomainDeviceDef {
+ int type; /* enum virDomainDeviceType */
+ union {
+ virDomainDiskDefPtr disk;
+ virDomainControllerDefPtr controller;
+ virDomainLeaseDefPtr lease;
+ virDomainFSDefPtr fs;
+ virDomainNetDefPtr net;
+ virDomainInputDefPtr input;
+ virDomainSoundDefPtr sound;
+ virDomainVideoDefPtr video;
+ virDomainHostdevDefPtr hostdev;
+ virDomainWatchdogDefPtr watchdog;
+ virDomainGraphicsDefPtr graphics;
+ virDomainHubDefPtr hub;
+ virDomainRedirdevDefPtr redirdev;
+ } data;
+};
+
/* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
enum virDomainVirtType {
@@ -243,6 +326,51 @@ struct _virDomainLeaseDef {
};
+enum virDomainHostdevMode {
+ VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
+ VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
+
+ VIR_DOMAIN_HOSTDEV_MODE_LAST,
+};
+
+enum virDomainHostdevSubsysType {
+ VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
+ VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
+
+ VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
+};
+
+/* basic device for direct passthrough */
+typedef struct _virDomainHostdevDef virDomainHostdevDef;
+typedef virDomainHostdevDef *virDomainHostdevDefPtr;
+struct _virDomainHostdevDef {
+ int mode; /* enum virDomainHostdevMode */
+ unsigned int managed : 1;
+ union {
+ struct {
+ int type; /* enum virDomainHostdevBusType */
+ union {
+ struct {
+ unsigned bus;
+ unsigned device;
+
+ unsigned vendor;
+ unsigned product;
+ } usb;
+ virDomainDevicePCIAddress pci; /* host address */
+ } u;
+ } subsys;
+ struct {
+ /* TBD: struct capabilities see:
+ *
https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
+ */
+ int dummy;
+ } caps;
+ } source;
+ virDomainHostdevOrigStates origstates;
+ virDomainDeviceInfoPtr info; /* Guest address */
+};
+
/* Two types of disk backends */
enum virDomainDiskType {
VIR_DOMAIN_DISK_TYPE_BLOCK,
@@ -1088,50 +1216,6 @@ struct _virDomainGraphicsDef {
virDomainGraphicsListenDefPtr listens;
};
-enum virDomainHostdevMode {
- VIR_DOMAIN_HOSTDEV_MODE_SUBSYS,
- VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES,
-
- VIR_DOMAIN_HOSTDEV_MODE_LAST,
-};
-
-enum virDomainHostdevSubsysType {
- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
-
- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
-};
-
-typedef struct _virDomainHostdevDef virDomainHostdevDef;
-typedef virDomainHostdevDef *virDomainHostdevDefPtr;
-struct _virDomainHostdevDef {
- int mode; /* enum virDomainHostdevMode */
- unsigned int managed : 1;
- union {
- struct {
- int type; /* enum virDomainHostdevBusType */
- union {
- struct {
- unsigned bus;
- unsigned device;
-
- unsigned vendor;
- unsigned product;
- } usb;
- virDomainDevicePCIAddress pci; /* host address */
- } u;
- } subsys;
- struct {
- /* TBD: struct capabilities see:
- *
https://www.redhat.com/archives/libvir-list/2008-July/msg00429.html
- */
- int dummy;
- } caps;
- } source;
- virDomainHostdevOrigStates origstates;
- virDomainDeviceInfoPtr info; /* Guest address */
-};
-
enum virDomainRedirdevBus {
VIR_DOMAIN_REDIRDEV_BUS_USB,
@@ -1175,46 +1259,6 @@ enum virDomainSmbiosMode {
VIR_DOMAIN_SMBIOS_LAST
};
-/* Flags for the 'type' field in next struct */
-enum virDomainDeviceType {
- VIR_DOMAIN_DEVICE_DISK,
- VIR_DOMAIN_DEVICE_LEASE,
- VIR_DOMAIN_DEVICE_FS,
- VIR_DOMAIN_DEVICE_NET,
- VIR_DOMAIN_DEVICE_INPUT,
- VIR_DOMAIN_DEVICE_SOUND,
- VIR_DOMAIN_DEVICE_VIDEO,
- VIR_DOMAIN_DEVICE_HOSTDEV,
- VIR_DOMAIN_DEVICE_WATCHDOG,
- VIR_DOMAIN_DEVICE_CONTROLLER,
- VIR_DOMAIN_DEVICE_GRAPHICS,
- VIR_DOMAIN_DEVICE_HUB,
- VIR_DOMAIN_DEVICE_REDIRDEV,
-
- VIR_DOMAIN_DEVICE_LAST,
-};
-
-typedef struct _virDomainDeviceDef virDomainDeviceDef;
-typedef virDomainDeviceDef *virDomainDeviceDefPtr;
-struct _virDomainDeviceDef {
- int type;
- union {
- virDomainDiskDefPtr disk;
- virDomainControllerDefPtr controller;
- virDomainLeaseDefPtr lease;
- virDomainFSDefPtr fs;
- virDomainNetDefPtr net;
- virDomainInputDefPtr input;
- virDomainSoundDefPtr sound;
- virDomainVideoDefPtr video;
- virDomainHostdevDefPtr hostdev;
- virDomainWatchdogDefPtr watchdog;
- virDomainGraphicsDefPtr graphics;
- virDomainHubDefPtr hub;
- virDomainRedirdevDefPtr redirdev;
- } data;
-};
-
# define VIR_DOMAIN_MAX_BOOT_DEVS 4
--
1.7.7.6