diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index aaeb05961f..fbffb16866 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3973,7 +3973,7 @@
<source name='my-vm-template'/>
<target dir='/'/>
</filesystem>
- <filesystem type='mount' accessmode='passthrough'>
+ <filesystem type='mount' accessmode='passthrough' multidevs='remap'>
<driver type='path' wrpolicy='immediate'/>
<source dir='/export/to/guest'/>
<target dir='/import/from/host'/>
@@ -4098,6 +4098,44 @@
for more details.
+
+ The filesystem element has an optional attribute multidevs
+ which specifies how to deal with a filesystem export containing more than
+ one device, in order to avoid file ID collisions on guest when using 9pfs
+ (since 6.3.0, requires QEMU 4.2 ).
+ This attribute is not available for virtiofs. The possible values are:
+
+
+
+ default
+
+ Use QEMU's default setting (which currently is warn
).
+
+ remap
+
+ This setting allows guest to access multiple devices per export without
+ encountering misbehaviours. Inode numbers from host are automatically
+ remapped on guest to actively prevent file ID collisions if guest
+ accesses one export containing multiple devices.
+
+ forbid
+
+ Only allow to access one device per export by guest. Attempts to access
+ additional devices on the same export will cause the individual
+ filesystem access by guest to fail with an error and being logged (once)
+ as error on host side.
+
+ warn
+
+ This setting resembles the behaviour of 9pfs prior to QEMU 4.2, that is
+ no action is performed to prevent any potential file ID collisions if an
+ export contains multiple devices, with the only exception: a warning is
+ logged (once) on host side now. This setting may lead to misbehaviours
+ on guest side if more than one device is exported per export, due to the
+ potential file ID collisions this may cause on guest side in that case.
+
+
+
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 1807df521c..dcf2e09db8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2706,6 +2706,16 @@
+
+
+
+ default
+ remap
+ forbid
+ warn
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 914e03c705..460f8064be 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -502,6 +502,14 @@ VIR_ENUM_IMPL(virDomainFSModel,
"virtio-non-transitional",
);
+VIR_ENUM_IMPL(virDomainFSMultidevs,
+ VIR_DOMAIN_FS_MULTIDEVS_LAST,
+ "default",
+ "remap",
+ "forbid",
+ "warn",
+);
+
VIR_ENUM_IMPL(virDomainFSCacheMode,
VIR_DOMAIN_FS_CACHE_MODE_LAST,
"default",
@@ -11389,6 +11397,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
g_autofree char *usage = NULL;
g_autofree char *units = NULL;
g_autofree char *model = NULL;
+ g_autofree char *multidevs = NULL;
ctxt->node = node;
@@ -11427,6 +11436,17 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
}
}
+ multidevs = virXMLPropString(node, "multidevs");
+ if (multidevs) {
+ if ((def->multidevs = virDomainFSMultidevsTypeFromString(multidevs)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown multidevs '%s'"), multidevs);
+ goto error;
+ }
+ } else {
+ def->multidevs = VIR_DOMAIN_FS_MULTIDEVS_DEFAULT;
+ }
+
if (virDomainParseScaledValue("./space_hard_limit[1]",
NULL, ctxt, &def->space_hard_limit,
1, ULLONG_MAX, false) < 0)
@@ -25385,6 +25405,7 @@ virDomainFSDefFormat(virBufferPtr buf,
const char *accessmode = virDomainFSAccessModeTypeToString(def->accessmode);
const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver);
const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
+ const char *multidevs = virDomainFSMultidevsTypeToString(def->multidevs);
const char *src = def->src->path;
g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) driverBuf = VIR_BUFFER_INIT_CHILD(buf);
@@ -25403,6 +25424,12 @@ virDomainFSDefFormat(virBufferPtr buf,
return -1;
}
+ if (!multidevs) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected multidevs %d"), def->multidevs);
+ return -1;
+ }
+
virBufferAsprintf(buf,
"model));
}
+ if (def->multidevs)
+ virBufferAsprintf(buf, " multidevs='%s'", multidevs);
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 33875d942f..2038b54c32 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -796,6 +796,18 @@ typedef enum {
VIR_DOMAIN_FS_WRPOLICY_LAST
} virDomainFSWrpolicy;
+/* How to handle exports containing multiple devices. */
+typedef enum {
+ VIR_DOMAIN_FS_MULTIDEVS_DEFAULT = 0, /* Use QEMU's default setting */
+ VIR_DOMAIN_FS_MULTIDEVS_REMAP, /* Remap inodes from host to guest */
+ VIR_DOMAIN_FS_MULTIDEVS_FORBID, /* Prohibit more than one device */
+ VIR_DOMAIN_FS_MULTIDEVS_WARN, /* Just log a warning if multiple devices */
+
+ VIR_DOMAIN_FS_MULTIDEVS_LAST
+} virDomainFSMultidevs;
+
+VIR_ENUM_DECL(virDomainFSMultidevs);
+
typedef enum {
VIR_DOMAIN_FS_MODEL_DEFAULT = 0,
VIR_DOMAIN_FS_MODEL_VIRTIO,
@@ -820,6 +832,7 @@ struct _virDomainFSDef {
int wrpolicy; /* enum virDomainFSWrpolicy */
int format; /* virStorageFileFormat */
int model; /* virDomainFSModel */
+ int multidevs; /* virDomainFSMultidevs */
unsigned long long usage; /* in bytes */
virStorageSourcePtr src;
char *dst;
diff --git a/tests/qemuxml2argvdata/virtio-9p-multidevs.xml b/tests/qemuxml2argvdata/virtio-9p-multidevs.xml
new file mode 100644
index 0000000000..7a3b865415
--- /dev/null
+++ b/tests/qemuxml2argvdata/virtio-9p-multidevs.xml
@@ -0,0 +1,53 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmloutdata/virtio-9p-multidevs.x86_64-latest.xml b/tests/qemuxml2xmloutdata/virtio-9p-multidevs.x86_64-latest.xml
new file mode 100644
index 0000000000..4ea75ff8e3
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/virtio-9p-multidevs.x86_64-latest.xml
@@ -0,0 +1,56 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ qemu64
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index a0d27fdcf8..b4c83fccca 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1485,6 +1485,8 @@ mymain(void)
DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-kvm-q35-4.2", "x86_64");
DO_TEST_CAPS_ARCH_LATEST("x86_64-default-cpu-tcg-q35-4.2", "x86_64");
+ DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
+
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);