mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-03 11:51:11 +00:00
conf: add socket for virtiofs filesystems
Allow passing a socket of an externally launched virtiofsd to the vhost-user-fs device. <filesystem type='mount'> <driver type='virtiofs' queue='1024'/> <source socket='/tmp/sock/'/> </filesystem> https://bugzilla.redhat.com/show_bug.cgi?id=1855789 Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e581703148
commit
12967c3e13
@ -2763,9 +2763,18 @@
|
|||||||
<ref name="fsBinary"/>
|
<ref name="fsBinary"/>
|
||||||
</optional>
|
</optional>
|
||||||
<element name="source">
|
<element name="source">
|
||||||
|
<choice>
|
||||||
|
<group>
|
||||||
<attribute name="dir">
|
<attribute name="dir">
|
||||||
<ref name="absDirPath"/>
|
<ref name="absDirPath"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<attribute name="socket">
|
||||||
|
<ref name="absFilePath"/>
|
||||||
|
</attribute>
|
||||||
|
</group>
|
||||||
|
</choice>
|
||||||
<empty/>
|
<empty/>
|
||||||
</element>
|
</element>
|
||||||
</interleave>
|
</interleave>
|
||||||
@ -2827,10 +2836,12 @@
|
|||||||
</group>
|
</group>
|
||||||
</choice>
|
</choice>
|
||||||
<interleave>
|
<interleave>
|
||||||
|
<optional>
|
||||||
<element name="target">
|
<element name="target">
|
||||||
<attribute name="dir"/>
|
<attribute name="dir"/>
|
||||||
<empty/>
|
<empty/>
|
||||||
</element>
|
</element>
|
||||||
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name="accessmode">
|
<attribute name="accessmode">
|
||||||
<choice>
|
<choice>
|
||||||
|
@ -2480,6 +2480,7 @@ void virDomainFSDefFree(virDomainFSDef *def)
|
|||||||
g_free(def->virtio);
|
g_free(def->virtio);
|
||||||
virObjectUnref(def->privateData);
|
virObjectUnref(def->privateData);
|
||||||
g_free(def->binary);
|
g_free(def->binary);
|
||||||
|
g_free(def->sock);
|
||||||
|
|
||||||
g_free(def);
|
g_free(def);
|
||||||
}
|
}
|
||||||
@ -5516,7 +5517,7 @@ virDomainMemoryDefPostParse(virDomainMemoryDef *mem,
|
|||||||
static int
|
static int
|
||||||
virDomainFSDefPostParse(virDomainFSDef *fs)
|
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;
|
fs->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -10031,6 +10032,7 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
g_autofree char *multidevs = NULL;
|
g_autofree char *multidevs = NULL;
|
||||||
g_autofree char *fmode = NULL;
|
g_autofree char *fmode = NULL;
|
||||||
g_autofree char *dmode = NULL;
|
g_autofree char *dmode = NULL;
|
||||||
|
g_autofree char *sock = NULL;
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -10113,9 +10115,9 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
cur = node->children;
|
cur = node->children;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (!source &&
|
if (!source && !sock &&
|
||||||
virXMLNodeNameEqual(cur, "source")) {
|
virXMLNodeNameEqual(cur, "source")) {
|
||||||
|
sock = virXMLPropString(cur, "socket");
|
||||||
if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT ||
|
if (def->type == VIR_DOMAIN_FS_TYPE_MOUNT ||
|
||||||
def->type == VIR_DOMAIN_FS_TYPE_BIND) {
|
def->type == VIR_DOMAIN_FS_TYPE_BIND) {
|
||||||
source = virXMLPropString(cur, "dir");
|
source = virXMLPropString(cur, "dir");
|
||||||
@ -10237,13 +10239,13 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (source == NULL && def->type != VIR_DOMAIN_FS_TYPE_RAM
|
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,
|
virReportError(VIR_ERR_NO_SOURCE,
|
||||||
target ? "%s" : NULL, target);
|
target ? "%s" : NULL, target);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == NULL) {
|
if (target == NULL && !sock) {
|
||||||
virReportError(VIR_ERR_NO_TARGET,
|
virReportError(VIR_ERR_NO_TARGET,
|
||||||
source ? "%s" : NULL, source);
|
source ? "%s" : NULL, source);
|
||||||
goto error;
|
goto error;
|
||||||
@ -10267,6 +10269,7 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
def->src->path = g_steal_pointer(&source);
|
def->src->path = g_steal_pointer(&source);
|
||||||
|
def->sock = g_steal_pointer(&sock);
|
||||||
def->dst = g_steal_pointer(&target);
|
def->dst = g_steal_pointer(&target);
|
||||||
|
|
||||||
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
|
if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info,
|
||||||
@ -22199,7 +22202,7 @@ static bool
|
|||||||
virDomainFsDefCheckABIStability(virDomainFSDef *src,
|
virDomainFsDefCheckABIStability(virDomainFSDef *src,
|
||||||
virDomainFSDef *dst)
|
virDomainFSDef *dst)
|
||||||
{
|
{
|
||||||
if (STRNEQ(src->dst, dst->dst)) {
|
if (STRNEQ_NULLABLE(src->dst, dst->dst)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("Target filesystem guest target %s does not match source %s"),
|
_("Target filesystem guest target %s does not match source %s"),
|
||||||
dst->dst, src->dst);
|
dst->dst, src->dst);
|
||||||
@ -25337,8 +25340,10 @@ virDomainFSDefFormat(virBuffer *buf,
|
|||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_DOMAIN_FS_TYPE_MOUNT:
|
case VIR_DOMAIN_FS_TYPE_MOUNT:
|
||||||
case VIR_DOMAIN_FS_TYPE_BIND:
|
case VIR_DOMAIN_FS_TYPE_BIND:
|
||||||
virBufferEscapeString(buf, "<source dir='%s'/>\n",
|
if (!def->sock)
|
||||||
src);
|
virBufferEscapeString(buf, "<source dir='%s'/>\n", src);
|
||||||
|
else
|
||||||
|
virBufferEscapeString(buf, "<source socket='%s'/>\n", def->sock);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_FS_TYPE_BLOCK:
|
case VIR_DOMAIN_FS_TYPE_BLOCK:
|
||||||
|
@ -861,6 +861,7 @@ struct _virDomainFSDef {
|
|||||||
int multidevs; /* virDomainFSMultidevs */
|
int multidevs; /* virDomainFSMultidevs */
|
||||||
unsigned long long usage; /* in bytes */
|
unsigned long long usage; /* in bytes */
|
||||||
virStorageSource *src;
|
virStorageSource *src;
|
||||||
|
char *sock;
|
||||||
char *dst;
|
char *dst;
|
||||||
bool readonly;
|
bool readonly;
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
|
@ -4162,6 +4162,7 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
|
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
|
||||||
|
if (!fs->sock) {
|
||||||
if (fs->readonly) {
|
if (fs->readonly) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("virtiofs does not yet support read-only mode"));
|
_("virtiofs does not yet support read-only mode"));
|
||||||
@ -4182,6 +4183,8 @@ qemuValidateDomainDeviceDefFS(virDomainFSDef *fs,
|
|||||||
_("virtiofs does not support wrpolicy"));
|
_("virtiofs does not support wrpolicy"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
|
if (fs->model != VIR_DOMAIN_FS_MODEL_DEFAULT) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("virtiofs does not support model"));
|
_("virtiofs does not support model"));
|
||||||
|
39
tests/qemuxml2argvdata/vhost-user-fs-sock.xml
Normal file
39
tests/qemuxml2argvdata/vhost-user-fs-sock.xml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<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>
|
1
tests/qemuxml2xmloutdata/vhost-user-fs-sock.x86_64-latest.xml
Symbolic link
1
tests/qemuxml2xmloutdata/vhost-user-fs-sock.x86_64-latest.xml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../qemuxml2argvdata/vhost-user-fs-sock.xml
|
@ -1434,6 +1434,7 @@ mymain(void)
|
|||||||
|
|
||||||
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
|
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
|
||||||
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
|
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
|
||||||
|
DO_TEST_CAPS_LATEST("vhost-user-fs-sock");
|
||||||
|
|
||||||
DO_TEST("riscv64-virt",
|
DO_TEST("riscv64-virt",
|
||||||
QEMU_CAPS_DEVICE_VIRTIO_MMIO);
|
QEMU_CAPS_DEVICE_VIRTIO_MMIO);
|
||||||
|
Loading…
Reference in New Issue
Block a user