[Libvir] [PATCH] Fields in virDomainPtr which appear to be never used

Richard W.M. Jones rjones at redhat.com
Sat May 5 10:25:00 UTC 2007


Below is the definition of struct _virDomain from internal.h.  I may be 
missing something big (well, it wouldn't be the first time), but as far 
as I can see some of these fields are never used, and some are set but 
can never be read.

struct _virDomain {
     unsigned int magic;  /* specific value to check */
OK

     int uses;            /* reference count */
OK

     virConnectPtr conn;  /* pointer back to the connection */
OK

     char *name;          /* the domain external name */
OK

     char *path;          /* the domain internal path */
This field is set in src/xs_internal.c, but nowhere in libvirt does it 
appear to be read.  The only other time it is reference is in hash.c 
where it is freed if non-NULL.

     int id;              /* the domain ID */
OK

     int flags;           /* extra flags */
Apparently this field could be set to DOMAIN_IS_SHUTDOWN or 
DOMAIN_IS_DEFINED.  However neither of these symbols are used, and 
moreover this structure field looks like it is never written or read.

     unsigned char uuid[VIR_UUID_BUFLEN]; /* the domain unique identifier */
OK

     char *xml;           /* the XML description for defined domains */
This field is, as far as I can tell, never set anywhere.  However the 
code in hash.c does check whether it is set and will free it upon 
destruction of the _virDomain object.

};

With this analysis in mind, attached is a patch which removes these 
three fields (path, flags, xml) and the unused virDomainFlags, with no 
apparent ill-effects.

Rich.

-- 
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421

Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.
Registered in England and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David
Owens (Ireland)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-domain-ptr-fields-20070505.patch
Type: text/x-patch
Size: 2387 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070505/73a2b159/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070505/73a2b159/attachment-0003.bin>


More information about the libvir-list mailing list