Commit 1d446bd4 authored by Brian Turek's avatar Brian Turek Committed by Jano Tomko
Browse files

qemu: add 'fmode' and 'dmode' options



Expose QEMU's 9pfs 'fmode' and 'dmode' options via attributes on the
'filesystem' node in the domain XML. These options control the creation
mode of files and directories, respectively, when using
accessmode=mapped.
Signed-off-by: Brian Turek's avatarBrian Turek <brian.turek@gmail.com>
Signed-off-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
Reviewed-by: Jano Tomko's avatarJán Tomko <jtomko@redhat.com>
parent b0f0e96c
......@@ -26,6 +26,12 @@
</element>
</define>
<define name="createMode">
<data type="unsignedInt">
<param name="pattern">0[0-7]{3}|[0-7]{1,3}</param>
</data>
</define>
<!--
We handle only document defining a domain
-->
......@@ -2746,6 +2752,16 @@
</choice>
</attribute>
</optional>
<optional>
<attribute name="fmode">
<ref name="createMode"/>
</attribute>
</optional>
<optional>
<attribute name="dmode">
<ref name="createMode"/>
</attribute>
</optional>
<optional>
<element name="readonly">
<empty/>
......
......@@ -11476,6 +11476,8 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
g_autofree char *units = NULL;
g_autofree char *model = NULL;
g_autofree char *multidevs = NULL;
g_autofree char *fmode = NULL;
g_autofree char *dmode = NULL;
 
ctxt->node = node;
 
......@@ -11504,6 +11506,26 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
}
 
fmode = virXMLPropString(node, "fmode");
if (fmode) {
if ((virStrToLong_uip(fmode, NULL, 8, &def->fmode) < 0) ||
(def->fmode > 0777)) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid fmode: '%s'"), fmode);
goto error;
}
}
dmode = virXMLPropString(node, "dmode");
if (dmode) {
if ((virStrToLong_uip(dmode, NULL, 8, &def->dmode) < 0) ||
(def->dmode > 0777)) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid dmode: '%s'"), dmode);
goto error;
}
}
model = virXMLPropString(node, "model");
if (model) {
if ((def->model = virDomainFSModelTypeFromString(model)) < 0 ||
......@@ -26181,6 +26203,13 @@ virDomainFSDefFormat(virBufferPtr buf,
}
if (def->multidevs)
virBufferAsprintf(buf, " multidevs='%s'", multidevs);
if (def->fmode)
virBufferAsprintf(buf, " fmode='%04o'", def->fmode);
if (def->dmode)
virBufferAsprintf(buf, " dmode='%04o'", def->dmode);
virBufferAddLit(buf, ">\n");
 
virBufferAdjustIndent(buf, 2);
......@@ -849,6 +849,8 @@ struct _virDomainFSDef {
int wrpolicy; /* enum virDomainFSWrpolicy */
int format; /* virStorageFileFormat */
int model; /* virDomainFSModel */
unsigned int fmode;
unsigned int dmode;
int multidevs; /* virDomainFSMultidevs */
unsigned long long usage; /* in bytes */
virStorageSourcePtr src;
......
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<filesystem type='mount' accessmode='mapped' fmode='644'>
<source dir='/export/fs0'/>
<target dir='fs0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped' dmode='755'>
<source dir='/export/fs1'/>
<target dir='fs1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped' fmode='0640' dmode='0750'>
<source dir='/export/fs2'/>
<target dir='fs2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped'>
<source dir='/export/fs3'/>
<target dir='fs3'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</filesystem>
<serial type='pty'>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
</memballoon>
</devices>
</domain>
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<controller type='usb' index='0' model='piix3-uhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<filesystem type='mount' accessmode='mapped' fmode='0644'>
<source dir='/export/fs0'/>
<target dir='fs0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped' dmode='0755'>
<source dir='/export/fs1'/>
<target dir='fs1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped' fmode='0640' dmode='0750'>
<source dir='/export/fs2'/>
<target dir='fs2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</filesystem>
<filesystem type='mount' accessmode='mapped'>
<source dir='/export/fs3'/>
<target dir='fs3'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</filesystem>
<serial type='pty'>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
</memballoon>
</devices>
</domain>
......@@ -1513,6 +1513,7 @@ mymain(void)
DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64");
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
DO_TEST_CAPS_LATEST("virtio-9p-createmode");
DO_TEST("downscript", NONE);
cleanup:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment