Re: [libvirt] [PATCH 02/17] conf: relocate virDomainDeviceDef and virDomainHostdevDef

2012-03-02 Thread Eric Blake
On 02/28/2012 01:14 PM, Laine Stump wrote:
 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.
 ---
 
 V2: aside from the fact that there are now more types of device to
 have their definitions/enums relocated, I learned that older versions
 of gcc will not allow a duplicate typedef, even if it is identical to
 the original, so rather than just copying the device typedefs from
 their original locations just above each struct definition, I had to
 move them, removing the original.
 
  src/conf/domain_conf.h |  262 
 ++--
  1 files changed, 141 insertions(+), 121 deletions(-)

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 02/17] conf: relocate virDomainDeviceDef and virDomainHostdevDef

2012-02-28 Thread Laine Stump
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.
---

V2: aside from the fact that there are now more types of device to
have their definitions/enums relocated, I learned that older versions
of gcc will not allow a duplicate typedef, even if it is identical to
the original, so rather than just copying the device typedefs from
their original locations just above each struct definition, I had to
move them, removing the original.

 src/conf/domain_conf.h |  262 ++--
 1 files changed, 141 insertions(+), 121 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9acf1e1..68b7cfd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -44,6 +44,104 @@
 # 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;
+
+typedef struct _virDomainSmartcardDef virDomainSmartcardDef;
+typedef virDomainSmartcardDef *virDomainSmartcardDefPtr;
+
+typedef struct _virDomainChrDef virDomainChrDef;
+typedef virDomainChrDef *virDomainChrDefPtr;
+
+typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
+typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;
+
+/* Flags for the 'type' field in virDomainDeviceDef */
+typedef enum {
+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_SMARTCARD,
+VIR_DOMAIN_DEVICE_CHR,
+VIR_DOMAIN_DEVICE_MEMBALLOON,
+
+VIR_DOMAIN_DEVICE_LAST,
+} virDomainDeviceType;
+
+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;
+virDomainSmartcardDefPtr smartcard;
+virDomainChrDefPtr chr;
+virDomainMemballoonDefPtr memballoon;
+} data;
+};
+
 /* Different types of hypervisor */
 /* NB: Keep in sync with virDomainVirtTypeToString impl */
 enum virDomainVirtType {
@@ -234,8 +332,6 @@ struct _virDomainHostdevOrigStates {
 } states;
 };
 
-typedef struct _virDomainLeaseDef virDomainLeaseDef;
-typedef virDomainLeaseDef *virDomainLeaseDefPtr;
 struct _virDomainLeaseDef {
 char *lockspace;