]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: add network-dir as new storage volume type
authorEric Blake <eblake@redhat.com>
Mon, 18 Nov 2013 23:43:06 +0000 (16:43 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 25 Nov 2013 19:29:49 +0000 (12:29 -0700)
In the 'directory' and 'netfs' storage pools, a user can see
both 'file' and 'dir' storage volume types, to know when they
can descend into a subdirectory.  But in a network-based storage
pool, such as the upcoming 'gluster' pool, we use 'network'
instead of 'file', and did not have any counterpart for a
directory until this patch.  Adding a new volume type
'network-dir' is better than reusing 'dir', because it makes
it clear that the only way to access 'network' volumes within
that container is through the network mounting (leaving 'dir'
for something accessible in the local file system).

* include/libvirt/libvirt.h.in (virStorageVolType): Expand enum.
* docs/formatstorage.html.in: Document it.
* docs/schemasa/storagevol.rng (vol): Allow new value.
* src/conf/storage_conf.c (virStorageVol): Use new value.
* src/qemu/qemu_command.c (qemuBuildVolumeString): Fix client.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
* tools/virsh-volume.c (vshVolumeTypeToString): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemVolDelete): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
docs/formatstorage.html.in
docs/schemas/storagevol.rng
include/libvirt/libvirt.h.in
src/conf/storage_conf.c
src/qemu/qemu_command.c
src/qemu/qemu_conf.c
src/storage/storage_backend_fs.c
tools/virsh-volume.c

index 17c0313c66e20353cfee3fd5b353853f035af304..a089a3108b4a2cdb2b8745ac25a84d68aaf0caf4 100644 (file)
       A storage volume will generally be either a file or a device
       node; <span class="since">since 1.2.0</span>, an optional
       output-only attribute <code>type</code> lists the actual type
-      (file, block, dir, or network), which is also available
+      (file, block, dir, network, or netdir), which is also available
       from <code>virStorageVolGetInfo()</code>.  The storage volume
       XML format is available <span class="since">since 0.4.1</span>
     </p>
index f8081d9c51d03f48b67cfd430e6e48c14b90afd4..8f07d8f9d6f1fe8a9ae1b7ba06125685dbef24a1 100644 (file)
@@ -20,6 +20,7 @@
             <value>block</value>
             <value>dir</value>
             <value>network</value>
+            <value>netdir</value>
           </choice>
         </attribute>
       </optional>
index 146a59bb9d09e14ff8db2f499546795137b30256..5aad75c18eca83e6a2bbe48674dd4ffe326c86db 100644 (file)
@@ -2951,6 +2951,8 @@ typedef enum {
     VIR_STORAGE_VOL_BLOCK = 1,    /* Block based volumes */
     VIR_STORAGE_VOL_DIR = 2,      /* Directory-passthrough based volume */
     VIR_STORAGE_VOL_NETWORK = 3,  /* Network volumes like RBD (RADOS Block Device) */
+    VIR_STORAGE_VOL_NETDIR = 4,   /* Network accessible directory that can
+                                   * contain other network volumes */
 
 #ifdef VIR_ENUM_SENTINELS
     VIR_STORAGE_VOL_LAST
index e675777432ef40d2992a0d28588aafdfd25dd745..22e38c13ee02932affba0882c9007623865beaec 100644 (file)
@@ -53,7 +53,7 @@
 
 VIR_ENUM_IMPL(virStorageVol,
               VIR_STORAGE_VOL_LAST,
-              "file", "block", "dir", "network")
+              "file", "block", "dir", "network", "netdir")
 
 VIR_ENUM_IMPL(virStoragePool,
               VIR_STORAGE_POOL_LAST,
index 01fe45b8b138a373f4639aaa99fd0ef333e2e8cb..763417fef1e423db837d47326a08395180c9d052 100644 (file)
@@ -3782,7 +3782,7 @@ qemuBuildVolumeString(virConnectPtr conn,
 {
     int ret = -1;
 
-    switch (disk->srcpool->voltype) {
+    switch ((virStorageVolType) disk->srcpool->voltype) {
     case VIR_STORAGE_VOL_DIR:
         if (!disk->readonly) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3825,10 +3825,12 @@ qemuBuildVolumeString(virConnectPtr conn,
         }
         break;
     case VIR_STORAGE_VOL_NETWORK:
+    case VIR_STORAGE_VOL_NETDIR:
+    case VIR_STORAGE_VOL_LAST:
         /* Keep the compiler quiet, qemuTranslateDiskSourcePool already
          * reported the unsupported error.
          */
-        break;
+        goto cleanup;
     }
 
     ret = 0;
index 580385002989d06e0a199311e8707d780af81145..77df370087f6c823a51501ff0b0c4fc68a5e6017 100644 (file)
@@ -1332,7 +1332,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
         goto cleanup;
     }
 
-    switch (info.type) {
+    switch ((virStorageVolType) info.type) {
     case VIR_STORAGE_VOL_FILE:
     case VIR_STORAGE_VOL_DIR:
         if (!(def->src = virStorageVolGetPath(vol)))
@@ -1377,6 +1377,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
 
         break;
     case VIR_STORAGE_VOL_NETWORK:
+    case VIR_STORAGE_VOL_NETDIR:
+    case VIR_STORAGE_VOL_LAST:
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Using network volume as disk source is not supported"));
         goto cleanup;
index 510a3d63848fe182060df7d30244c34b240e4e1d..11cf2df3af46be8ac26c17024587100fd60979d2 100644 (file)
@@ -1137,7 +1137,7 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
 {
     virCheckFlags(0, -1);
 
-    switch (vol->type) {
+    switch ((virStorageVolType) vol->type) {
     case VIR_STORAGE_VOL_FILE:
         if (unlink(vol->target.path) < 0) {
             /* Silently ignore failures where the vol has already gone away */
@@ -1159,7 +1159,8 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
         break;
     case VIR_STORAGE_VOL_BLOCK:
     case VIR_STORAGE_VOL_NETWORK:
-    default:
+    case VIR_STORAGE_VOL_NETDIR:
+    case VIR_STORAGE_VOL_LAST:
         virReportError(VIR_ERR_NO_SUPPORT,
                        _("removing block or network volumes is not supported: %s"),
                        vol->target.path);
index cbdb3f0fa2265300c4fafe1c52ffff08b6d38c15..22b10d552efe630ec8793ce3acfc5c9be4aa47df 100644 (file)
@@ -947,7 +947,7 @@ out:
 static const char *
 vshVolumeTypeToString(int type)
 {
-    switch (type) {
+    switch ((virStorageVolType) type) {
     case VIR_STORAGE_VOL_FILE:
         return N_("file");
 
@@ -960,6 +960,9 @@ vshVolumeTypeToString(int type)
     case VIR_STORAGE_VOL_NETWORK:
         return N_("network");
 
+    case VIR_STORAGE_VOL_NETDIR:
+        return N_("netdir");
+
     case VIR_STORAGE_VOL_LAST:
         break;
     }