<h2><a name="StorageVol">Storage volume XML</a></h2>
<p>
- A storage volume will be either a file or a device node.
- The storage volume XML format is available <span class="since">since 0.4.1</span>
+ 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
+ from <code>virStorageVolGetInfo()</code>. The storage volume
+ XML format is available <span class="since">since 0.4.1</span>
</p>
<h3><a name="StorageVolFirst">General metadata</a></h3>
<pre>
- <volume>
+ <volume type='file'>
<name>sparse.img</name>
<key>/var/lib/xen/images/sparse.img</key>
<allocation>0</allocation>
#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",
{
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
+ char *type = NULL;
char *allocation = NULL;
char *capacity = NULL;
char *unit = NULL;
/* 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) {
VIR_FREE(allocation);
VIR_FREE(capacity);
VIR_FREE(unit);
+ VIR_FREE(type);
return ret;
error:
if (options == NULL)
return NULL;
- virBufferAddLit(&buf, "<volume>\n");
+ virBufferAsprintf(&buf, "<volume type='%s'>\n",
+ virStorageVolTypeToString(def->type));
virBufferEscapeString(&buf, " <name>%s</name>\n", def->name);
virBufferEscapeString(&buf, " <key>%s</key>\n", def->key);
virBufferAddLit(&buf, " <source>\n");