From 8a20e227f64422e99a17cb3e05ec33a4fde4674a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 28 Mar 2014 12:38:43 -0600 Subject: [PATCH] conf: move storage source type to util/ With this patch, all information related to a host resource in a storage file backing chain now lives in util/virstoragefile.h. The next step will be to consolidate various places that have been tracking backing chain details to all use a common struct. The changes to tools/Makefile.am were made necessary by the fact that virstorageencryption includes uses of libxml, and is now pulled in by inclusion from virstoragefile.h. No additional libraries are linked into the final image, and in comparison, the build of the setuid library in src/Makefile.am already was using LIBXML_CFLAGS via AM_CFLAGS. * src/conf/domain_conf.h (virDomainDiskSourceDef): Move... * src/util/virstoragefile.h (virStorageSource): ...and rename. * src/conf/domain_conf.c (virDomainDiskSourceDefClear) (virDomainDiskAuthClear): Adjust clients. * tools/Makefile.am (virt_login_shell_CFLAGS) (virt_host_validate_CFLAGS): Add libxml headers. Signed-off-by: Eric Blake --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 32 ++------------------------------ src/util/virstoragefile.h | 32 ++++++++++++++++++++++++++++++++ tools/Makefile.am | 2 ++ 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5afacfbb5..b38021d0f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1193,7 +1193,7 @@ virDomainDiskSourcePoolDefFree(virStorageSourcePoolDefPtr def) static void -virDomainDiskSourceDefClear(virDomainDiskSourceDefPtr def) +virDomainDiskSourceDefClear(virStorageSourcePtr def) { size_t i; @@ -1237,7 +1237,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def) void -virDomainDiskAuthClear(virDomainDiskSourceDefPtr def) +virDomainDiskAuthClear(virStorageSourcePtr def) { VIR_FREE(def->auth.username); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 52b59a1d0c..b011847ed4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -595,38 +595,10 @@ struct _virDomainBlockIoTuneInfo { }; typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr; -typedef struct _virDomainDiskSourceDef virDomainDiskSourceDef; -typedef virDomainDiskSourceDef *virDomainDiskSourceDefPtr; - -/* Stores information related to a host resource. In the case of - * backing chains, multiple source disks join to form a single guest - * view. TODO Move this to util/ */ -struct _virDomainDiskSourceDef { - int type; /* enum virStorageType */ - char *path; - int protocol; /* enum virStorageNetProtocol */ - size_t nhosts; - virStorageNetHostDefPtr hosts; - virStorageSourcePoolDefPtr srcpool; - struct { - char *username; - int secretType; /* enum virStorageSecretType */ - union { - unsigned char uuid[VIR_UUID_BUFLEN]; - char *usage; - } secret; - } auth; - virStorageEncryptionPtr encryption; - char *driverName; - int format; /* enum virStorageFileFormat */ - - size_t nseclabels; - virSecurityDeviceLabelDefPtr *seclabels; -}; /* Stores the virtual disk configuration */ struct _virDomainDiskDef { - virDomainDiskSourceDef src; + virStorageSource src; int device; /* enum virDomainDiskDevice */ int bus; /* enum virDomainDiskBus */ @@ -2153,7 +2125,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def); void virDomainInputDefFree(virDomainInputDefPtr def); void virDomainDiskDefFree(virDomainDiskDefPtr def); void virDomainLeaseDefFree(virDomainLeaseDefPtr def); -void virDomainDiskAuthClear(virDomainDiskSourceDefPtr def); +void virDomainDiskAuthClear(virStorageSourcePtr def); int virDomainDiskGetType(virDomainDiskDefPtr def); void virDomainDiskSetType(virDomainDiskDefPtr def, int type); int virDomainDiskGetActualType(virDomainDiskDefPtr def); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 68172c80f0..a6dcfa46ec 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -25,6 +25,8 @@ # define __VIR_STORAGE_FILE_H__ # include "virbitmap.h" +# include "virseclabel.h" +# include "virstorageencryption.h" # include "virutil.h" /* Minimum header size required to probe all known formats with @@ -182,6 +184,36 @@ enum virStorageSecretType { }; +typedef struct _virStorageSource virStorageSource; +typedef virStorageSource *virStorageSourcePtr; + +/* Stores information related to a host resource. In the case of + * backing chains, multiple source disks join to form a single guest + * view. */ +struct _virStorageSource { + int type; /* enum virStorageType */ + char *path; + int protocol; /* enum virStorageNetProtocol */ + size_t nhosts; + virStorageNetHostDefPtr hosts; + virStorageSourcePoolDefPtr srcpool; + struct { + char *username; + int secretType; /* enum virStorageSecretType */ + union { + unsigned char uuid[VIR_UUID_BUFLEN]; + char *usage; + } secret; + } auth; + virStorageEncryptionPtr encryption; + char *driverName; + int format; /* enum virStorageFileFormat */ + + size_t nseclabels; + virSecurityDeviceLabelDefPtr *seclabels; +}; + + # ifndef DEV_BSIZE # define DEV_BSIZE 512 # endif diff --git a/tools/Makefile.am b/tools/Makefile.am index 6847f13cb8..93d642da67 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -148,6 +148,7 @@ virt_host_validate_LDADD = \ $(NULL) virt_host_validate_CFLAGS = \ + $(LIBXML_CFLAGS) \ $(WARN_CFLAGS) \ $(PIE_CFLAGS) \ $(COVERAGE_CFLAGS) \ @@ -173,6 +174,7 @@ virt_login_shell_LDADD = \ virt_login_shell_CFLAGS = \ -DLIBVIRT_SETUID_RPC_CLIENT \ + $(LIBXML_CFLAGS) \ $(WARN_CFLAGS) \ $(PIE_CFLAGS) \ $(COVERAGE_CFLAGS) -- GitLab