mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add support for storage format in FS <driver>
Extend the <driver> element in filesystem devices to allow a storage format to be set. The new attribute uses 'format' to reflect the storage format. This is different from the <driver> element in disk devices which use 'type' to reflect the storage format. This is because the 'type' attribute on filesystem devices is already used for the driver backend, for which the disk devices use the 'name' attribute. Arggggh. Anyway for disks we have <driver name="qemu" type="raw"/> And for filesystems this change means we now have <driver type="loop" format="raw"/> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
23fbda20a7
commit
ada14b86cc
@ -1883,6 +1883,13 @@
|
|||||||
<target dir='/import/from/host'/>
|
<target dir='/import/from/host'/>
|
||||||
<readonly/>
|
<readonly/>
|
||||||
</filesystem>
|
</filesystem>
|
||||||
|
<filesystem type='file' accessmode='passthrough'>
|
||||||
|
<driver name='loop' type='raw'/>
|
||||||
|
<driver type='path' wrpolicy='immediate'/>
|
||||||
|
<source file='/export/to/guest.img'/>
|
||||||
|
<target dir='/import/from/host'/>
|
||||||
|
<readonly/>
|
||||||
|
</filesystem>
|
||||||
...
|
...
|
||||||
</devices>
|
</devices>
|
||||||
...</pre>
|
...</pre>
|
||||||
@ -1974,6 +1981,23 @@
|
|||||||
|
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><code>driver</code></dt>
|
||||||
|
<dd>
|
||||||
|
The optional driver element allows specifying further details
|
||||||
|
related to the hypervisor driver used to provide the filesystem.
|
||||||
|
<span class="since">Since 1.0.6</span>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
If the hypervisor supports multiple backend drivers, then
|
||||||
|
the <code>type</code> attribute selects the primary
|
||||||
|
backend driver name, while the <code>format</code>
|
||||||
|
attribute provides the format type. For example, LXC
|
||||||
|
supports a type of "loop", with a format of "raw". QEMU
|
||||||
|
supports a type of "path" or "handle", but no formats.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt><code>source</code></dt>
|
<dt><code>source</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
The resource on the host that is being accessed in the guest. The
|
The resource on the host that is being accessed in the guest. The
|
||||||
|
@ -888,7 +888,7 @@
|
|||||||
<define name="diskspec">
|
<define name="diskspec">
|
||||||
<interleave>
|
<interleave>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="driver"/>
|
<ref name="diskDriver"/>
|
||||||
</optional>
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name='diskMirror'/>
|
<ref name='diskMirror'/>
|
||||||
@ -1270,7 +1270,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Disk may use a special driver for access.
|
Disk may use a special driver for access.
|
||||||
-->
|
-->
|
||||||
<define name="driver">
|
<define name="diskDriver">
|
||||||
<element name="driver">
|
<element name="driver">
|
||||||
<choice>
|
<choice>
|
||||||
<group>
|
<group>
|
||||||
@ -1314,13 +1314,13 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<attribute name='type'>
|
<attribute name='type'>
|
||||||
<choice>
|
<choice>
|
||||||
<ref name='diskFormat'/>
|
<ref name='storageFormat'/>
|
||||||
<value>aio</value> <!-- back-compat for 'raw' -->
|
<value>aio</value> <!-- back-compat for 'raw' -->
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
</define>
|
</define>
|
||||||
<define name='diskFormat'>
|
<define name='storageFormat'>
|
||||||
<choice>
|
<choice>
|
||||||
<value>raw</value>
|
<value>raw</value>
|
||||||
<value>dir</value>
|
<value>dir</value>
|
||||||
@ -1518,6 +1518,9 @@
|
|||||||
<attribute name="type">
|
<attribute name="type">
|
||||||
<value>file</value>
|
<value>file</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="file">
|
<attribute name="file">
|
||||||
@ -1531,6 +1534,9 @@
|
|||||||
<attribute name="type">
|
<attribute name="type">
|
||||||
<value>block</value>
|
<value>block</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="dev">
|
<attribute name="dev">
|
||||||
@ -1547,6 +1553,9 @@
|
|||||||
<value>mount</value>
|
<value>mount</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="dir">
|
<attribute name="dir">
|
||||||
@ -1554,22 +1563,6 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<empty/>
|
<empty/>
|
||||||
</element>
|
</element>
|
||||||
<optional>
|
|
||||||
<element name="driver">
|
|
||||||
<attribute name="type">
|
|
||||||
<choice>
|
|
||||||
<value>path</value>
|
|
||||||
<value>handle</value>
|
|
||||||
</choice>
|
|
||||||
</attribute>
|
|
||||||
<optional>
|
|
||||||
<attribute name="wrpolicy">
|
|
||||||
<value>immediate</value>
|
|
||||||
</attribute>
|
|
||||||
</optional>
|
|
||||||
<empty/>
|
|
||||||
</element>
|
|
||||||
</optional>
|
|
||||||
</interleave>
|
</interleave>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
@ -1578,6 +1571,9 @@
|
|||||||
<value>bind</value>
|
<value>bind</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="dir">
|
<attribute name="dir">
|
||||||
@ -1591,6 +1587,9 @@
|
|||||||
<attribute name="type">
|
<attribute name="type">
|
||||||
<value>template</value>
|
<value>template</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="name">
|
<attribute name="name">
|
||||||
@ -1604,6 +1603,9 @@
|
|||||||
<attribute name="type">
|
<attribute name="type">
|
||||||
<value>ram</value>
|
<value>ram</value>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<ref name="fsDriver"/>
|
||||||
|
</optional>
|
||||||
<interleave>
|
<interleave>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
<attribute name="usage">
|
<attribute name="usage">
|
||||||
@ -1661,6 +1663,35 @@
|
|||||||
</interleave>
|
</interleave>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
<define name="fsDriver">
|
||||||
|
<element name="driver">
|
||||||
|
<!-- Annoying inconsistency. 'disk' uses 'name'
|
||||||
|
for this kind of info, and 'type' for the
|
||||||
|
storage format. We need the latter too, so
|
||||||
|
had to invent a new attribute name -->
|
||||||
|
<optional>
|
||||||
|
<attribute name="type">
|
||||||
|
<choice>
|
||||||
|
<value>path</value>
|
||||||
|
<value>handle</value>
|
||||||
|
<value>loop</value>
|
||||||
|
</choice>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="format">
|
||||||
|
<ref name="storageFormat"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="wrpolicy">
|
||||||
|
<value>immediate</value>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<empty/>
|
||||||
|
</element>
|
||||||
|
</define>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
An interface description can either be of type bridge in which case
|
An interface description can either be of type bridge in which case
|
||||||
it will use a bridging source, or of type ethernet which uses a device
|
it will use a bridging source, or of type ethernet which uses a device
|
||||||
@ -3838,7 +3869,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name='format'>
|
<attribute name='format'>
|
||||||
<ref name='diskFormat'/>
|
<ref name='storageFormat'/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
|
@ -128,7 +128,7 @@
|
|||||||
<element name='driver'>
|
<element name='driver'>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name='type'>
|
<attribute name='type'>
|
||||||
<ref name='diskFormat'/>
|
<ref name='storageFormat'/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
<empty/>
|
<empty/>
|
||||||
|
@ -342,7 +342,8 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
|
|||||||
VIR_ENUM_IMPL(virDomainFSDriverType, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
VIR_ENUM_IMPL(virDomainFSDriverType, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
||||||
"default",
|
"default",
|
||||||
"path",
|
"path",
|
||||||
"handle")
|
"handle",
|
||||||
|
"loop")
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virDomainFSAccessMode, VIR_DOMAIN_FS_ACCESSMODE_LAST,
|
VIR_ENUM_IMPL(virDomainFSAccessMode, VIR_DOMAIN_FS_ACCESSMODE_LAST,
|
||||||
"passthrough",
|
"passthrough",
|
||||||
@ -5596,6 +5597,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
|
|||||||
char *fsdriver = NULL;
|
char *fsdriver = NULL;
|
||||||
char *source = NULL;
|
char *source = NULL;
|
||||||
char *target = NULL;
|
char *target = NULL;
|
||||||
|
char *format = NULL;
|
||||||
char *accessmode = NULL;
|
char *accessmode = NULL;
|
||||||
char *wrpolicy = NULL;
|
char *wrpolicy = NULL;
|
||||||
char *usage = NULL;
|
char *usage = NULL;
|
||||||
@ -5664,9 +5666,13 @@ virDomainFSDefParseXML(xmlNodePtr node,
|
|||||||
target = virXMLPropString(cur, "dir");
|
target = virXMLPropString(cur, "dir");
|
||||||
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) {
|
||||||
def->readonly = true;
|
def->readonly = true;
|
||||||
} else if (!fsdriver && xmlStrEqual(cur->name, BAD_CAST "driver")) {
|
} else if (xmlStrEqual(cur->name, BAD_CAST "driver")) {
|
||||||
fsdriver = virXMLPropString(cur, "type");
|
if (!fsdriver)
|
||||||
wrpolicy = virXMLPropString(cur, "wrpolicy");
|
fsdriver = virXMLPropString(cur, "type");
|
||||||
|
if (!wrpolicy)
|
||||||
|
wrpolicy = virXMLPropString(cur, "wrpolicy");
|
||||||
|
if (!format)
|
||||||
|
format = virXMLPropString(cur, "format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -5674,12 +5680,20 @@ virDomainFSDefParseXML(xmlNodePtr node,
|
|||||||
|
|
||||||
if (fsdriver) {
|
if (fsdriver) {
|
||||||
if ((def->fsdriver = virDomainFSDriverTypeTypeFromString(fsdriver)) <= 0) {
|
if ((def->fsdriver = virDomainFSDriverTypeTypeFromString(fsdriver)) <= 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown fs driver type '%s'"), fsdriver);
|
_("unknown fs driver type '%s'"), fsdriver);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format) {
|
||||||
|
if ((def->format = virStorageFileFormatTypeFromString(format)) <= 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("unknown driver format value '%s'"), format);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wrpolicy) {
|
if (wrpolicy) {
|
||||||
if ((def->wrpolicy = virDomainFSWrpolicyTypeFromString(wrpolicy)) <= 0) {
|
if ((def->wrpolicy = virDomainFSWrpolicyTypeFromString(wrpolicy)) <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
@ -5739,6 +5753,7 @@ cleanup:
|
|||||||
VIR_FREE(wrpolicy);
|
VIR_FREE(wrpolicy);
|
||||||
VIR_FREE(usage);
|
VIR_FREE(usage);
|
||||||
VIR_FREE(unit);
|
VIR_FREE(unit);
|
||||||
|
VIR_FREE(format);
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
@ -13947,10 +13962,13 @@ virDomainFSDefFormat(virBufferPtr buf,
|
|||||||
if (def->fsdriver) {
|
if (def->fsdriver) {
|
||||||
virBufferAsprintf(buf, " <driver type='%s'", fsdriver);
|
virBufferAsprintf(buf, " <driver type='%s'", fsdriver);
|
||||||
|
|
||||||
|
if (def->format)
|
||||||
|
virBufferAsprintf(buf, " format='%s'",
|
||||||
|
virStorageFileFormatTypeToString(def->format));
|
||||||
|
|
||||||
/* Don't generate anything if wrpolicy is set to default */
|
/* Don't generate anything if wrpolicy is set to default */
|
||||||
if (def->wrpolicy) {
|
if (def->wrpolicy)
|
||||||
virBufferAsprintf(buf, " wrpolicy='%s'", wrpolicy);
|
virBufferAsprintf(buf, " wrpolicy='%s'", wrpolicy);
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
|
@ -800,6 +800,7 @@ enum virDomainFSDriverType {
|
|||||||
VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
|
VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
|
||||||
VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
|
VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
|
||||||
VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
|
VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
|
||||||
|
VIR_DOMAIN_FS_DRIVER_TYPE_LOOP,
|
||||||
|
|
||||||
VIR_DOMAIN_FS_DRIVER_TYPE_LAST
|
VIR_DOMAIN_FS_DRIVER_TYPE_LAST
|
||||||
};
|
};
|
||||||
@ -826,9 +827,10 @@ enum virDomainFSWrpolicy {
|
|||||||
|
|
||||||
struct _virDomainFSDef {
|
struct _virDomainFSDef {
|
||||||
int type;
|
int type;
|
||||||
int fsdriver;
|
int fsdriver; /* enum virDomainFSDriverType */
|
||||||
int accessmode;
|
int accessmode; /* enum virDomainFSAccessMode */
|
||||||
int wrpolicy; /* enum virDomainFSWrpolicy */
|
int wrpolicy; /* enum virDomainFSWrpolicy */
|
||||||
|
int format; /* enum virStorageFileFormat */
|
||||||
unsigned long long usage;
|
unsigned long long usage;
|
||||||
char *src;
|
char *src;
|
||||||
char *dst;
|
char *dst;
|
||||||
|
@ -139,7 +139,8 @@ VIR_ENUM_DECL(qemuDomainFSDriver)
|
|||||||
VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
|
||||||
"local",
|
"local",
|
||||||
"local",
|
"local",
|
||||||
"handle");
|
"handle",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
26
tests/lxcxml2xmldata/lxc-disk-formats.xml
Normal file
26
tests/lxcxml2xmldata/lxc-disk-formats.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<domain type='lxc'>
|
||||||
|
<name>demo</name>
|
||||||
|
<uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
|
||||||
|
<memory unit='KiB'>500000</memory>
|
||||||
|
<currentMemory unit='KiB'>500000</currentMemory>
|
||||||
|
<vcpu placement='static'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64'>exe</type>
|
||||||
|
<init>/bin/sh</init>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/libexec/libvirt_lxc</emulator>
|
||||||
|
<filesystem type='file' accessmode='passthrough'>
|
||||||
|
<driver type='loop' format='raw'/>
|
||||||
|
<source file='/root/container.img'/>
|
||||||
|
<target dir='/'/>
|
||||||
|
</filesystem>
|
||||||
|
<console type='pty'>
|
||||||
|
<target type='lxc' port='0'/>
|
||||||
|
</console>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -128,6 +128,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST("systemd");
|
DO_TEST("systemd");
|
||||||
DO_TEST("hostdev");
|
DO_TEST("hostdev");
|
||||||
|
DO_TEST("disk-formats");
|
||||||
|
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virObjectUnref(xmlopt);
|
virObjectUnref(xmlopt);
|
||||||
|
Loading…
Reference in New Issue
Block a user