]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: use common struct in storage volumes
authorEric Blake <eblake@redhat.com>
Tue, 1 Apr 2014 21:11:30 +0000 (15:11 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 2 Apr 2014 12:03:00 +0000 (06:03 -0600)
A fairly smooth transition.  And now that domain disks and
storage volumes share a common struct, it opens the doors for
a future patch to expose more details in the XML for both
objects.

* src/conf/storage_conf.h (_virStorageVolTarget): Delete.
(_virStorageVolDef): Use common type.
* src/conf/storage_conf.c (virStorageVolDefFree)
(virStorageVolTargetDefFormat): Update clients.
* src/storage/storage_backend.h: Likewise.
* src/storage/storage_backend.c
(virStorageBackendDetectBlockVolFormatFD)
(virStorageBackendUpdateVolTargetInfo)
(virStorageBackendUpdateVolTargetInfoFD): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/conf/storage_conf.c
src/conf/storage_conf.h
src/storage/storage_backend.c
src/storage/storage_backend.h
src/storage/storage_backend_fs.c

index e4986e686ecf9edd4f642d7980396d4ce66a4a2c..a96f4d615fd2426c48f2c04c058be32963291968 100644 (file)
@@ -329,22 +329,8 @@ virStorageVolDefFree(virStorageVolDefPtr def)
     }
     VIR_FREE(def->source.extents);
 
-    VIR_FREE(def->target.compat);
-    virBitmapFree(def->target.features);
-    VIR_FREE(def->target.path);
-    if (def->target.perms) {
-        VIR_FREE(def->target.perms->label);
-        VIR_FREE(def->target.perms);
-    }
-    VIR_FREE(def->target.timestamps);
-    virStorageEncryptionFree(def->target.encryption);
-    VIR_FREE(def->backingStore.path);
-    if (def->backingStore.perms) {
-        VIR_FREE(def->backingStore.perms->label);
-        VIR_FREE(def->backingStore.perms);
-    }
-    VIR_FREE(def->backingStore.timestamps);
-    virStorageEncryptionFree(def->backingStore.encryption);
+    virStorageSourceClear(&def->target);
+    virStorageSourceClear(&def->backingStore);
     VIR_FREE(def);
 }
 
@@ -1528,7 +1514,7 @@ virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
 static int
 virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
                              virBufferPtr buf,
-                             virStorageVolTargetPtr def,
+                             virStorageSourcePtr def,
                              const char *type)
 {
     virBufferAsprintf(buf, "<%s>\n", type);
index 507f08bc503dfb9f420030b2a2b07aa94df263b1..66b5a3b64c0c4835d82a63861b93baeb8d1125fe 100644 (file)
@@ -56,24 +56,6 @@ struct _virStorageVolSource {
 };
 
 
-/*
- * How the volume appears on the host
- */
-typedef struct _virStorageVolTarget virStorageVolTarget;
-typedef virStorageVolTarget *virStorageVolTargetPtr;
-struct _virStorageVolTarget {
-    char *path;
-    int format; /* enum virStorageFileFormat */
-    virStoragePermsPtr perms;
-    virStorageTimestampsPtr timestamps;
-
-    /* The next three are currently only used in vol->target,
-     * not in vol->backingStore. */
-    virStorageEncryptionPtr encryption;
-    virBitmapPtr features;
-    char *compat;
-};
-
 typedef struct _virStorageVolDef virStorageVolDef;
 typedef virStorageVolDef *virStorageVolDefPtr;
 struct _virStorageVolDef {
@@ -87,8 +69,8 @@ struct _virStorageVolDef {
     unsigned long long capacity; /* bytes */
 
     virStorageVolSource source;
-    virStorageVolTarget target;
-    virStorageVolTarget backingStore;
+    virStorageSource target;
+    virStorageSource backingStore;
 };
 
 typedef struct _virStorageVolDefList virStorageVolDefList;
index c21504d12d295906f7f5bebf20a75fb6c461c190..9abaccd3026c3d853af859d9eea8d07b83fb1bd7 100644 (file)
@@ -1236,7 +1236,7 @@ static struct diskType const disk_types[] = {
 
 
 static int
-virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target,
+virStorageBackendDetectBlockVolFormatFD(virStorageSourcePtr target,
                                         int fd)
 {
     size_t i;
@@ -1384,7 +1384,7 @@ virStorageBackendVolOpen(const char *path, struct stat *sb,
 }
 
 int
-virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
+virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
                                      unsigned long long *allocation,
                                      unsigned long long *capacity,
                                      bool withBlockVolFormat,
@@ -1451,7 +1451,7 @@ virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
  * Returns 0 for success, -1 on a legitimate error condition.
  */
 int
-virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
+virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                        int fd,
                                        struct stat *sb,
                                        unsigned long long *allocation,
index c0d16685a6be28e578f370fdca37d2fbcbf59acd..8442c13e973d4ebb4bed75fd85ee51d6bc8c57a0 100644 (file)
@@ -141,12 +141,12 @@ int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
                                    bool withCapacity,
                                    bool withBlockVolFormat,
                                    unsigned int openflags);
-int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
+int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
                                          unsigned long long *allocation,
                                          unsigned long long *capacity,
                                          bool withBlockVolFormat,
                                          unsigned int openflags);
-int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
+int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
                                            int fd,
                                            struct stat *sb,
                                            unsigned long long *allocation,
index b3618048c8b063187e3c9bc8432735e3b22d0ec7..113593b741a75ad122ebfdc9a15f5cd69a0946aa 100644 (file)
@@ -62,7 +62,7 @@ VIR_LOG_INIT("storage.storage_backend_fs");
                                              ~VIR_STORAGE_VOL_OPEN_ERROR)
 
 static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-virStorageBackendProbeTarget(virStorageVolTargetPtr target,
+virStorageBackendProbeTarget(virStorageSourcePtr target,
                              char **backingStore,
                              int *backingStoreFormat,
                              unsigned long long *allocation,