diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 90eeaa3ab3..c90d7b1baa 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -283,14 +283,18 @@
- A storage volume will be either a file or a device node.
- The storage volume XML format is available since 0.4.1
+ A storage volume will generally be either a file or a device
+ node; since 1.2.0 , an optional
+ output-only attribute type
lists the actual type
+ (file, block, dir, or network), which is also available
+ from virStorageVolGetInfo()
. The storage volume
+ XML format is available since 0.4.1
- <volume>
+ <volume type='file'>
<name>sparse.img</name>
<key>/var/lib/xen/images/sparse.img</key>
<allocation>0</allocation>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index e79bc35919..f8081d9c51 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -13,6 +13,16 @@
+
+
+
+ file
+ block
+ dir
+ network
+
+
+
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b378c208e..0cd80c32c4 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -51,6 +51,10 @@
#define DEFAULT_POOL_PERM_MODE 0755
#define DEFAULT_VOL_PERM_MODE 0600
+VIR_ENUM_IMPL(virStorageVol,
+ VIR_STORAGE_VOL_LAST,
+ "file", "block", "dir", "network")
+
VIR_ENUM_IMPL(virStoragePool,
VIR_STORAGE_POOL_LAST,
"dir", "fs", "netfs",
@@ -1253,6 +1257,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
{
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
+ char *type = NULL;
char *allocation = NULL;
char *capacity = NULL;
char *unit = NULL;
@@ -1278,6 +1283,16 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
/* Normally generated by pool refresh, but useful for unit tests */
ret->key = virXPathString("string(./key)", ctxt);
+ /* Technically overridden by pool refresh, but useful for unit tests */
+ type = virXPathString("string(./@type)", ctxt);
+ if (type) {
+ if ((ret->type = virStorageVolTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown volume type '%s'"), type);
+ goto error;
+ }
+ }
+
capacity = virXPathString("string(./capacity)", ctxt);
unit = virXPathString("string(./capacity/@unit)", ctxt);
if (capacity == NULL) {
@@ -1394,6 +1409,7 @@ cleanup:
VIR_FREE(allocation);
VIR_FREE(capacity);
VIR_FREE(unit);
+ VIR_FREE(type);
return ret;
error:
@@ -1563,7 +1579,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
if (options == NULL)
return NULL;
- virBufferAddLit(&buf, "\n");
+ virBufferAsprintf(&buf, "\n",
+ virStorageVolTypeToString(def->type));
virBufferEscapeString(&buf, " %s \n", def->name);
virBufferEscapeString(&buf, " %s \n", def->key);
virBufferAddLit(&buf, " \n");
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index f062bd8213..c4dd403459 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -116,6 +116,7 @@ struct _virStorageVolDefList {
virStorageVolDefPtr *objs;
};
+VIR_ENUM_DECL(virStorageVol)
enum virStoragePoolType {
VIR_STORAGE_POOL_DIR, /* Local directory */
diff --git a/tests/storagevolxml2xmlin/vol-logical-backing.xml b/tests/storagevolxml2xmlin/vol-logical-backing.xml
index b4141a5c99..38ff8c5121 100644
--- a/tests/storagevolxml2xmlin/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-logical-backing.xml
@@ -1,4 +1,4 @@
-
+
Swap
r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0
diff --git a/tests/storagevolxml2xmlin/vol-logical.xml b/tests/storagevolxml2xmlin/vol-logical.xml
index cd4d3f7f03..46a607acb6 100644
--- a/tests/storagevolxml2xmlin/vol-logical.xml
+++ b/tests/storagevolxml2xmlin/vol-logical.xml
@@ -1,4 +1,4 @@
-
+
Swap
r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0
diff --git a/tests/storagevolxml2xmlin/vol-partition.xml b/tests/storagevolxml2xmlin/vol-partition.xml
index 6990bb5903..d810fff3ee 100644
--- a/tests/storagevolxml2xmlin/vol-partition.xml
+++ b/tests/storagevolxml2xmlin/vol-partition.xml
@@ -1,4 +1,4 @@
-
+
sda1
/dev/sda1
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index 49e221ca55..d6e920bb81 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -1,4 +1,4 @@
-
+
test2
diff --git a/tests/storagevolxml2xmlout/vol-file-backing.xml b/tests/storagevolxml2xmlout/vol-file-backing.xml
index 8d2fb57624..cd33bee523 100644
--- a/tests/storagevolxml2xmlout/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-file-backing.xml
@@ -1,4 +1,4 @@
-
+
sparse.img
/var/lib/libvirt/images/sparse.img
diff --git a/tests/storagevolxml2xmlout/vol-file-naming.xml b/tests/storagevolxml2xmlout/vol-file-naming.xml
index 7022b0287e..e515502af1 100644
--- a/tests/storagevolxml2xmlout/vol-file-naming.xml
+++ b/tests/storagevolxml2xmlout/vol-file-naming.xml
@@ -1,4 +1,4 @@
-
+
<sparse>.img
diff --git a/tests/storagevolxml2xmlout/vol-file.xml b/tests/storagevolxml2xmlout/vol-file.xml
index b97dd50401..2923188e65 100644
--- a/tests/storagevolxml2xmlout/vol-file.xml
+++ b/tests/storagevolxml2xmlout/vol-file.xml
@@ -1,4 +1,4 @@
-
+
sparse.img
diff --git a/tests/storagevolxml2xmlout/vol-logical-backing.xml b/tests/storagevolxml2xmlout/vol-logical-backing.xml
index bf34b08678..07fe27767d 100644
--- a/tests/storagevolxml2xmlout/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-logical-backing.xml
@@ -1,4 +1,4 @@
-
+
Swap
r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0
diff --git a/tests/storagevolxml2xmlout/vol-logical.xml b/tests/storagevolxml2xmlout/vol-logical.xml
index e9b4e4baf4..0df5cc0864 100644
--- a/tests/storagevolxml2xmlout/vol-logical.xml
+++ b/tests/storagevolxml2xmlout/vol-logical.xml
@@ -1,4 +1,4 @@
-
+
Swap
r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0
diff --git a/tests/storagevolxml2xmlout/vol-partition.xml b/tests/storagevolxml2xmlout/vol-partition.xml
index 9be1cf175b..147899edb1 100644
--- a/tests/storagevolxml2xmlout/vol-partition.xml
+++ b/tests/storagevolxml2xmlout/vol-partition.xml
@@ -1,4 +1,4 @@
-
+
sda1
/dev/sda1
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
index fd3d6069e0..1f799dae01 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
@@ -1,4 +1,4 @@
-
+
OtherDemo.img
/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
index 99fb5acafb..14f805ff2a 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
@@ -1,4 +1,4 @@
-
+
OtherDemo.img
/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
index 3708ea742b..68a9756d4f 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
@@ -1,4 +1,4 @@
-
+
OtherDemo.img
/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
index f6a2e2183d..075dc6996b 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
@@ -1,4 +1,4 @@
-
+
OtherDemo.img
/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml
index b9adcb4e20..31dc57873c 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2.xml
@@ -1,4 +1,4 @@
-
+
OtherDemo.img
/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml
index bd5d6d8f06..e08e36c1ca 100644
--- a/tests/storagevolxml2xmlout/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -1,4 +1,4 @@
-
+
test2