<ref name="fsBinary"/>
</optional>
<element name="source">
+ <choice>
+ <group>
<attribute name="dir">
<ref name="absDirPath"/>
</attribute>
+ </group>
+ <group>
+ <attribute name="socket">
+ <ref name="absFilePath"/>
+ </attribute>
+ </group>
+ </choice>
<empty/>
</element>
</interleave>
</group>
</choice>
<interleave>
+ <optional>
<element name="target">
<attribute name="dir"/>
<empty/>
</element>
+ </optional>
<optional>
<attribute name="accessmode">
<choice>
g_free(def->virtio);
virObjectUnref(def->privateData);
g_free(def->binary);
+ g_free(def->sock);
g_free(def);
}
static int
virDomainFSDefPostParse(virDomainFSDef *fs)
{
- if (fs->accessmode == VIR_DOMAIN_FS_ACCESSMODE_DEFAULT)
+ if (fs->accessmode == VIR_DOMAIN_FS_ACCESSMODE_DEFAULT && !fs->sock)
fs->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
return 0;
g_autofree char *multidevs = NULL;
g_autofree char *fmode = NULL;
g_autofree char *dmode = NULL;
+ g_autofree char *sock = NULL;
ctxt->node = node;
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
- if (!source &&
+ if (!source && !sock &&
virXMLNodeNameEqual(cur, "source")) {
-
+ sock = virXMLPropString(cur, "socket");
if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT ||
def->type == VIR_DOMAIN_FS_TYPE_BIND) {
source = virXMLPropString(cur, "dir");
}
if (source == NULL && def->type != VIR_DOMAIN_FS_TYPE_RAM
- && def->type != VIR_DOMAIN_FS_TYPE_VOLUME) {
+ && def->type != VIR_DOMAIN_FS_TYPE_VOLUME && !sock) {
virReportError(VIR_ERR_NO_SOURCE,
target ? "%s" : NULL, target);
goto error;
}
- if (target == NULL) {
+ if (target == NULL && !sock) {
virReportError(VIR_ERR_NO_TARGET,
source ? "%s" : NULL, source);
goto error;
}
def->src->path = g_steal_pointer(&source);
+ def->sock = g_steal_pointer(&sock);
def->dst = g_steal_pointer(&target);
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
virDomainFsDefCheckABIStability(virDomainFSDef *src,
virDomainFSDef *dst)
{
- if (STRNEQ(src->dst, dst->dst)) {
+ if (STRNEQ_NULLABLE(src->dst, dst->dst)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target filesystem guest target %s does not match source %s"),
dst->dst, src->dst);
switch (def->type) {
case VIR_DOMAIN_FS_TYPE_MOUNT:
case VIR_DOMAIN_FS_TYPE_BIND:
- virBufferEscapeString(buf, "<source dir='%s'/>\n",
- src);
+ if (!def->sock)
+ virBufferEscapeString(buf, "<source dir='%s'/>\n", src);
+ else
+ virBufferEscapeString(buf, "<source socket='%s'/>\n", def->sock);
break;
case VIR_DOMAIN_FS_TYPE_BLOCK:
int multidevs; /* virDomainFSMultidevs */
unsigned long long usage; /* in bytes */
virStorageSource *src;
+ char *sock;
char *dst;
bool readonly;
virDomainDeviceInfo info;
return -1;
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
- if (fs->readonly) {
+ if (!fs->sock) {
+ if (fs->readonly) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("virtiofs does not yet support read-only mode"));
return -1;
- }
- if (!driver->privileged) {
+ }
+ if (!driver->privileged) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("virtiofs is not yet supported in session mode"));
return -1;
- }
- if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
+ }
+ if (fs->accessmode != VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("virtiofs only supports passthrough accessmode"));
return -1;
- }
- if (fs->wrpolicy != VIR_DOMAIN_FS_WRPOLICY_DEFAULT) {
+ }
+ if (fs->wrpolicy != VIR_DOMAIN_FS_WRPOLICY_DEFAULT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("virtiofs does not support wrpolicy"));
return -1;
+ }
}
+
if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("virtiofs does not support model"));
--- /dev/null
+<domain type='kvm'>
+ <name>guest</name>
+ <uuid>126f2720-6f8e-45ab-a886-ec9277079a67</uuid>
+ <memory unit='KiB'>14680064</memory>
+ <currentMemory unit='KiB'>14680064</currentMemory>
+ <memoryBacking>
+ <source type='file'/>
+ <access mode='shared'/>
+ </memoryBacking>
+ <vcpu placement='static'>2</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>
+ <numa>
+ <cell id='0' cpus='0-1' memory='14680064' unit='KiB' memAccess='shared'/>
+ </numa>
+ </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='none'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <filesystem type='mount'>
+ <driver type='virtiofs' queue='1024'/>
+ <source socket='/tmp/sock'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </filesystem>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
--- /dev/null
+../qemuxml2argvdata/vhost-user-fs-sock.xml
\ No newline at end of file
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
+ DO_TEST_CAPS_LATEST("vhost-user-fs-sock");
DO_TEST("riscv64-virt",
QEMU_CAPS_DEVICE_VIRTIO_MMIO);