[libvirt] [PATCHv2 3/7] conf: move volume structs to util/

Eric Blake eblake at redhat.com
Wed Apr 2 03:04:59 UTC 2014


Another step towards unification of structures.  While we might
not expose everything in XML via domain disk as we do for
storage volume pointer, both places want to deal with (at least
part of) the backing chain; therefore, moving towards a single
struct usable from both contexts will make the backing chain
code more reusable.

* src/conf/storage_conf.h (_virStoragePerms)
(virStorageTimestamps): Move...
* src/util/virstoragefile.h: ...here.
(_virStorageSource): Add more fields.
* src/util/virstoragefile.c (virStorageSourceClear): Clean
additional fields.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 src/conf/storage_conf.h   | 23 +----------------------
 src/util/virstoragefile.c |  7 +++++++
 src/util/virstoragefile.h | 25 +++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index abff7ec..507f08b 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -26,33 +26,12 @@

 # include "internal.h"
 # include "virstorageencryption.h"
+# include "virstoragefile.h"
 # include "virbitmap.h"
 # include "virthread.h"

 # include <libxml/tree.h>

-typedef struct _virStoragePerms virStoragePerms;
-typedef virStoragePerms *virStoragePermsPtr;
-struct _virStoragePerms {
-    mode_t mode;
-    uid_t uid;
-    gid_t gid;
-    char *label;
-};
-
-typedef struct _virStorageTimestamps virStorageTimestamps;
-typedef virStorageTimestamps *virStorageTimestampsPtr;
-struct _virStorageTimestamps {
-    struct timespec atime;
-    /* if btime.tv_nsec == -1 then
-     * birth time is unknown
-     */
-    struct timespec btime;
-    struct timespec ctime;
-    struct timespec mtime;
-};
-
-
 /*
  * How the volume's data is stored on underlying
  * physical devices - can potentially span many
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index f6146d8..137bacc 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1569,6 +1569,8 @@ virStorageSourceClear(virStorageSourcePtr def)
     VIR_FREE(def->path);
     virStorageSourcePoolDefFree(def->srcpool);
     VIR_FREE(def->driverName);
+    virBitmapFree(def->features);
+    VIR_FREE(def->compat);
     virStorageEncryptionFree(def->encryption);

     if (def->seclabels) {
@@ -1576,6 +1578,11 @@ virStorageSourceClear(virStorageSourcePtr def)
             virSecurityDeviceLabelDefFree(def->seclabels[i]);
         VIR_FREE(def->seclabels);
     }
+    if (def->perms) {
+        VIR_FREE(def->perms->label);
+        VIR_FREE(def->perms);
+    }
+    VIR_FREE(def->timestamps);

     virStorageNetHostDefFree(def->nhosts, def->hosts);
     virStorageSourceAuthClear(def);
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 4980960..00d5456 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -85,6 +85,26 @@ enum virStorageFileFeature {

 VIR_ENUM_DECL(virStorageFileFeature);

+typedef struct _virStoragePerms virStoragePerms;
+typedef virStoragePerms *virStoragePermsPtr;
+struct _virStoragePerms {
+    mode_t mode;
+    uid_t uid;
+    gid_t gid;
+    char *label;
+};
+
+
+typedef struct _virStorageTimestamps virStorageTimestamps;
+typedef virStorageTimestamps *virStorageTimestampsPtr;
+struct _virStorageTimestamps {
+    struct timespec atime;
+    struct timespec btime; /* birth time unknown if btime.tv_nsec == -1 */
+    struct timespec ctime;
+    struct timespec mtime;
+};
+
+
 typedef struct _virStorageFileMetadata virStorageFileMetadata;
 typedef virStorageFileMetadata *virStorageFileMetadataPtr;
 struct _virStorageFileMetadata {
@@ -206,9 +226,14 @@ struct _virStorageSource {
         } secret;
     } auth;
     virStorageEncryptionPtr encryption;
+
     char *driverName;
     int format; /* enum virStorageFileFormat */
+    virBitmapPtr features;
+    char *compat;

+    virStoragePermsPtr perms;
+    virStorageTimestampsPtr timestamps;
     size_t nseclabels;
     virSecurityDeviceLabelDefPtr *seclabels;
 };
-- 
1.9.0




More information about the libvir-list mailing list