|
|
c401cc |
From ec8647d704e0b7a3025f05a2a0391c69b5b5921a Mon Sep 17 00:00:00 2001
|
|
|
c401cc |
Message-Id: <ec8647d704e0b7a3025f05a2a0391c69b5b5921a@dist-git>
|
|
|
c401cc |
From: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
Date: Wed, 26 Feb 2014 14:54:24 +0100
|
|
|
c401cc |
Subject: [PATCH] storage: add network-dir as new storage volume type
|
|
|
c401cc |
|
|
|
c401cc |
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
|
|
|
c401cc |
|
|
|
c401cc |
In the 'directory' and 'netfs' storage pools, a user can see
|
|
|
c401cc |
both 'file' and 'dir' storage volume types, to know when they
|
|
|
c401cc |
can descend into a subdirectory. But in a network-based storage
|
|
|
c401cc |
pool, such as the upcoming 'gluster' pool, we use 'network'
|
|
|
c401cc |
instead of 'file', and did not have any counterpart for a
|
|
|
c401cc |
directory until this patch. Adding a new volume type
|
|
|
c401cc |
'network-dir' is better than reusing 'dir', because it makes
|
|
|
c401cc |
it clear that the only way to access 'network' volumes within
|
|
|
c401cc |
that container is through the network mounting (leaving 'dir'
|
|
|
c401cc |
for something accessible in the local file system).
|
|
|
c401cc |
|
|
|
c401cc |
* include/libvirt/libvirt.h.in (virStorageVolType): Expand enum.
|
|
|
c401cc |
* docs/formatstorage.html.in: Document it.
|
|
|
c401cc |
* docs/schemasa/storagevol.rng (vol): Allow new value.
|
|
|
c401cc |
* src/conf/storage_conf.c (virStorageVol): Use new value.
|
|
|
c401cc |
* src/qemu/qemu_command.c (qemuBuildVolumeString): Fix client.
|
|
|
c401cc |
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
|
|
|
c401cc |
* tools/virsh-volume.c (vshVolumeTypeToString): Likewise.
|
|
|
c401cc |
* src/storage/storage_backend_fs.c
|
|
|
c401cc |
(virStorageBackendFileSystemVolDelete): Likewise.
|
|
|
c401cc |
|
|
|
c401cc |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
c401cc |
(cherry picked from commit ecd881b7a77873dc7ca752522f7401f88722f471)
|
|
|
c401cc |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c401cc |
---
|
|
|
c401cc |
docs/formatstorage.html.in | 2 +-
|
|
|
c401cc |
docs/schemas/storagevol.rng | 1 +
|
|
|
c401cc |
include/libvirt/libvirt.h.in | 2 ++
|
|
|
c401cc |
src/conf/storage_conf.c | 2 +-
|
|
|
c401cc |
src/qemu/qemu_command.c | 6 ++++--
|
|
|
c401cc |
src/qemu/qemu_conf.c | 4 +++-
|
|
|
c401cc |
src/storage/storage_backend_fs.c | 5 +++--
|
|
|
c401cc |
tools/virsh-volume.c | 5 ++++-
|
|
|
c401cc |
8 files changed, 19 insertions(+), 8 deletions(-)
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
|
|
|
c401cc |
index 015de1e..d85fe1c 100644
|
|
|
c401cc |
--- a/docs/formatstorage.html.in
|
|
|
c401cc |
+++ b/docs/formatstorage.html.in
|
|
|
c401cc |
@@ -292,7 +292,7 @@
|
|
|
c401cc |
A storage volume will generally be either a file or a device
|
|
|
c401cc |
node; since 1.2.0, an optional
|
|
|
c401cc |
output-only attribute type lists the actual type
|
|
|
c401cc |
- (file, block, dir, or network), which is also available
|
|
|
c401cc |
+ (file, block, dir, network, or netdir), which is also available
|
|
|
c401cc |
from virStorageVolGetInfo() . The storage volume
|
|
|
c401cc |
XML format is available since 0.4.1
|
|
|
c401cc |
|
|
|
c401cc |
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
|
|
|
c401cc |
index f8081d9..8f07d8f 100644
|
|
|
c401cc |
--- a/docs/schemas/storagevol.rng
|
|
|
c401cc |
+++ b/docs/schemas/storagevol.rng
|
|
|
c401cc |
@@ -20,6 +20,7 @@
|
|
|
c401cc |
<value>block</value>
|
|
|
c401cc |
<value>dir</value>
|
|
|
c401cc |
<value>network</value>
|
|
|
c401cc |
+ <value>netdir</value>
|
|
|
c401cc |
</choice>
|
|
|
c401cc |
</attribute>
|
|
|
c401cc |
</optional>
|
|
|
c401cc |
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
|
|
|
c401cc |
index 91d89ec..4e98bcc 100644
|
|
|
c401cc |
--- a/include/libvirt/libvirt.h.in
|
|
|
c401cc |
+++ b/include/libvirt/libvirt.h.in
|
|
|
c401cc |
@@ -2937,6 +2937,8 @@ typedef enum {
|
|
|
c401cc |
VIR_STORAGE_VOL_BLOCK = 1, /* Block based volumes */
|
|
|
c401cc |
VIR_STORAGE_VOL_DIR = 2, /* Directory-passthrough based volume */
|
|
|
c401cc |
VIR_STORAGE_VOL_NETWORK = 3, /* Network volumes like RBD (RADOS Block Device) */
|
|
|
c401cc |
+ VIR_STORAGE_VOL_NETDIR = 4, /* Network accessible directory that can
|
|
|
c401cc |
+ * contain other network volumes */
|
|
|
c401cc |
|
|
|
c401cc |
#ifdef VIR_ENUM_SENTINELS
|
|
|
c401cc |
VIR_STORAGE_VOL_LAST
|
|
|
c401cc |
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
|
|
|
c401cc |
index 0723ca9..e64b331 100644
|
|
|
c401cc |
--- a/src/conf/storage_conf.c
|
|
|
c401cc |
+++ b/src/conf/storage_conf.c
|
|
|
c401cc |
@@ -53,7 +53,7 @@
|
|
|
c401cc |
|
|
|
c401cc |
VIR_ENUM_IMPL(virStorageVol,
|
|
|
c401cc |
VIR_STORAGE_VOL_LAST,
|
|
|
c401cc |
- "file", "block", "dir", "network")
|
|
|
c401cc |
+ "file", "block", "dir", "network", "netdir")
|
|
|
c401cc |
|
|
|
c401cc |
VIR_ENUM_IMPL(virStoragePool,
|
|
|
c401cc |
VIR_STORAGE_POOL_LAST,
|
|
|
c401cc |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
c401cc |
index d303d96..4305052 100644
|
|
|
c401cc |
--- a/src/qemu/qemu_command.c
|
|
|
c401cc |
+++ b/src/qemu/qemu_command.c
|
|
|
c401cc |
@@ -3703,7 +3703,7 @@ qemuBuildVolumeString(virConnectPtr conn,
|
|
|
c401cc |
{
|
|
|
c401cc |
int ret = -1;
|
|
|
c401cc |
|
|
|
c401cc |
- switch (disk->srcpool->voltype) {
|
|
|
c401cc |
+ switch ((virStorageVolType) disk->srcpool->voltype) {
|
|
|
c401cc |
case VIR_STORAGE_VOL_DIR:
|
|
|
c401cc |
if (!disk->readonly) {
|
|
|
c401cc |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c401cc |
@@ -3746,10 +3746,12 @@ qemuBuildVolumeString(virConnectPtr conn,
|
|
|
c401cc |
}
|
|
|
c401cc |
break;
|
|
|
c401cc |
case VIR_STORAGE_VOL_NETWORK:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETDIR:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_LAST:
|
|
|
c401cc |
/* Keep the compiler quiet, qemuTranslateDiskSourcePool already
|
|
|
c401cc |
* reported the unsupported error.
|
|
|
c401cc |
*/
|
|
|
c401cc |
- break;
|
|
|
c401cc |
+ goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
ret = 0;
|
|
|
c401cc |
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
|
c401cc |
index ba32959..ec5a895 100644
|
|
|
c401cc |
--- a/src/qemu/qemu_conf.c
|
|
|
c401cc |
+++ b/src/qemu/qemu_conf.c
|
|
|
c401cc |
@@ -1301,7 +1301,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
}
|
|
|
c401cc |
|
|
|
c401cc |
- switch (info.type) {
|
|
|
c401cc |
+ switch ((virStorageVolType) info.type) {
|
|
|
c401cc |
case VIR_STORAGE_VOL_FILE:
|
|
|
c401cc |
case VIR_STORAGE_VOL_DIR:
|
|
|
c401cc |
if (!(def->src = virStorageVolGetPath(vol)))
|
|
|
c401cc |
@@ -1346,6 +1346,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
|
|
|
c401cc |
|
|
|
c401cc |
break;
|
|
|
c401cc |
case VIR_STORAGE_VOL_NETWORK:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETDIR:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_LAST:
|
|
|
c401cc |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
c401cc |
_("Using network volume as disk source is not supported"));
|
|
|
c401cc |
goto cleanup;
|
|
|
c401cc |
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
|
|
|
c401cc |
index 8bbee92..0374ea1 100644
|
|
|
c401cc |
--- a/src/storage/storage_backend_fs.c
|
|
|
c401cc |
+++ b/src/storage/storage_backend_fs.c
|
|
|
c401cc |
@@ -1121,7 +1121,7 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
c401cc |
{
|
|
|
c401cc |
virCheckFlags(0, -1);
|
|
|
c401cc |
|
|
|
c401cc |
- switch (vol->type) {
|
|
|
c401cc |
+ switch ((virStorageVolType) vol->type) {
|
|
|
c401cc |
case VIR_STORAGE_VOL_FILE:
|
|
|
c401cc |
if (unlink(vol->target.path) < 0) {
|
|
|
c401cc |
/* Silently ignore failures where the vol has already gone away */
|
|
|
c401cc |
@@ -1143,7 +1143,8 @@ virStorageBackendFileSystemVolDelete(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
c401cc |
break;
|
|
|
c401cc |
case VIR_STORAGE_VOL_BLOCK:
|
|
|
c401cc |
case VIR_STORAGE_VOL_NETWORK:
|
|
|
c401cc |
- default:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETDIR:
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_LAST:
|
|
|
c401cc |
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
c401cc |
_("removing block or network volumes is not supported: %s"),
|
|
|
c401cc |
vol->target.path);
|
|
|
c401cc |
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
|
|
|
c401cc |
index f5303ba..00104a6 100644
|
|
|
c401cc |
--- a/tools/virsh-volume.c
|
|
|
c401cc |
+++ b/tools/virsh-volume.c
|
|
|
c401cc |
@@ -938,7 +938,7 @@ out:
|
|
|
c401cc |
static const char *
|
|
|
c401cc |
vshVolumeTypeToString(int type)
|
|
|
c401cc |
{
|
|
|
c401cc |
- switch (type) {
|
|
|
c401cc |
+ switch ((virStorageVolType) type) {
|
|
|
c401cc |
case VIR_STORAGE_VOL_FILE:
|
|
|
c401cc |
return N_("file");
|
|
|
c401cc |
|
|
|
c401cc |
@@ -951,6 +951,9 @@ vshVolumeTypeToString(int type)
|
|
|
c401cc |
case VIR_STORAGE_VOL_NETWORK:
|
|
|
c401cc |
return N_("network");
|
|
|
c401cc |
|
|
|
c401cc |
+ case VIR_STORAGE_VOL_NETDIR:
|
|
|
c401cc |
+ return N_("netdir");
|
|
|
c401cc |
+
|
|
|
c401cc |
case VIR_STORAGE_VOL_LAST:
|
|
|
c401cc |
break;
|
|
|
c401cc |
}
|
|
|
c401cc |
--
|
|
|
c401cc |
1.9.0
|
|
|
c401cc |
|