From nobody Sun Feb 8 19:30:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617216963; cv=none; d=zohomail.com; s=zohoarc; b=Ubz0LDsZunMSOeWDIfnMESrydPzmalQMIzLnob85TxAkk2gJ1/KRvqy47KDwxt/Q7jcEyYbhB6tdqti7DM4r21PQ5btk38DOh6DeqWko2SbNBSKGBHf/a7SN8lxbYJ92oyKHyc+56MObpCAFNQK2AwALC9WQ2IKqJOMWYzwboCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617216963; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3SuD2+XGPoqNjYs3OIzBhEPVasSRQWAafg7s+7Yydt8=; b=Dh5cKmgeJ1iDfFWAHsiUdc8+/i0QbojwS5fUuauhgwMsMCGmwjosMBGEfC0rEQX+DguuEvEGE0TmTwoBGSAArpHplgqplAVgG14QWJX1P7Q3ISdl0QyVW1qBc5ee+8I9x/rehE+0oCt2gbg9SM4kHLVlaSZsQTH627LWIZLCCUM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617216963058119.89246548005815; Wed, 31 Mar 2021 11:56:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-Lx9zIFUXMaixYBMscyVuHg-1; Wed, 31 Mar 2021 14:55:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9F1CA0CB3; Wed, 31 Mar 2021 18:55:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7509C12D9A6; Wed, 31 Mar 2021 18:55:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 244EE4BB7C; Wed, 31 Mar 2021 18:55:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12VItm89004628 for ; Wed, 31 Mar 2021 14:55:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6638A2B0A7; Wed, 31 Mar 2021 18:55:48 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id B684A6060F for ; Wed, 31 Mar 2021 18:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617216962; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3SuD2+XGPoqNjYs3OIzBhEPVasSRQWAafg7s+7Yydt8=; b=gPIFeEF2BFSACe2esmGysvoC1hLkKEsMM1bS8F1Ld0Qev1fDUc/LRibgCtf24iOqR/pilz hJGPj0CuUaykdoqYKLxcky5kU3PQzpNmRVDBJ7FDaFDBx8y5iEuvN+hTUnJHdkGGmYdArO 2RO3A+69GWPWYdiHMsyf9JR5HIGcZDM= X-MC-Unique: Lx9zIFUXMaixYBMscyVuHg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv1 3/4] conf: add socket for virtiofs filesystems Date: Wed, 31 Mar 2021 20:55:37 +0200 Message-Id: <5d5202db1cff6b580df34d3921b3854ddc473d53.1617216815.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Allow passing a socket of an externally launched virtiofsd to the vhost-user-fs device. https://bugzilla.redhat.com/show_bug.cgi?id=3D1855789 Signed-off-by: J=C3=A1n Tomko --- docs/schemas/domaincommon.rng | 11 ++++++ src/conf/domain_conf.c | 21 ++++++---- src/conf/domain_conf.h | 1 + src/qemu/qemu_validate.c | 17 ++++---- tests/qemuxml2argvdata/vhost-user-fs-sock.xml | 39 +++++++++++++++++++ .../vhost-user-fs-sock.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 7 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 tests/qemuxml2argvdata/vhost-user-fs-sock.xml create mode 120000 tests/qemuxml2xmloutdata/vhost-user-fs-sock.x86_64-late= st.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f5ced5b7a2..361cd44e4e 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2747,9 +2747,18 @@ + + + + + + + + + @@ -2811,10 +2820,12 @@ + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5a1e193b2d..ddf072783b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2472,6 +2472,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def) g_free(def->virtio); virObjectUnref(def->privateData); g_free(def->binary); + g_free(def->sock); =20 g_free(def); } @@ -5490,7 +5491,7 @@ virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, static int virDomainFSDefPostParse(virDomainFSDefPtr fs) { - if (fs->accessmode =3D=3D VIR_DOMAIN_FS_ACCESSMODE_DEFAULT) + if (fs->accessmode =3D=3D VIR_DOMAIN_FS_ACCESSMODE_DEFAULT && !fs->soc= k) fs->accessmode =3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH; =20 return 0; @@ -10252,6 +10253,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *multidevs =3D NULL; g_autofree char *fmode =3D NULL; g_autofree char *dmode =3D NULL; + g_autofree char *sock =3D NULL; =20 ctxt->node =3D node; =20 @@ -10334,9 +10336,9 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, cur =3D node->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (!source && + if (!source && !sock && virXMLNodeNameEqual(cur, "source")) { - + sock =3D virXMLPropString(cur, "socket"); if (def->type =3D=3D VIR_DOMAIN_FS_TYPE_MOUNT || def->type =3D=3D VIR_DOMAIN_FS_TYPE_BIND) { source =3D virXMLPropString(cur, "dir"); @@ -10458,13 +10460,13 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlo= pt, } =20 if (source =3D=3D NULL && def->type !=3D VIR_DOMAIN_FS_TYPE_RAM - && def->type !=3D VIR_DOMAIN_FS_TYPE_VOLUME) { + && def->type !=3D VIR_DOMAIN_FS_TYPE_VOLUME && !sock) { virReportError(VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target); goto error; } =20 - if (target =3D=3D NULL) { + if (target =3D=3D NULL && !sock) { virReportError(VIR_ERR_NO_TARGET, source ? "%s" : NULL, source); goto error; @@ -10488,6 +10490,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, } =20 def->src->path =3D g_steal_pointer(&source); + def->sock =3D g_steal_pointer(&sock); def->dst =3D g_steal_pointer(&target); =20 if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, @@ -22372,7 +22375,7 @@ static bool virDomainFsDefCheckABIStability(virDomainFSDefPtr src, virDomainFSDefPtr 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); @@ -25508,8 +25511,10 @@ virDomainFSDefFormat(virBufferPtr buf, switch (def->type) { case VIR_DOMAIN_FS_TYPE_MOUNT: case VIR_DOMAIN_FS_TYPE_BIND: - virBufferEscapeString(buf, "\n", - src); + if (!def->sock) + virBufferEscapeString(buf, "\n", src); + else + virBufferEscapeString(buf, "\n", def->s= ock); break; =20 case VIR_DOMAIN_FS_TYPE_BLOCK: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9c47df99f6..0c1124078b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -859,6 +859,7 @@ struct _virDomainFSDef { int multidevs; /* virDomainFSMultidevs */ unsigned long long usage; /* in bytes */ virStorageSourcePtr src; + char *sock; char *dst; bool readonly; virDomainDeviceInfo info; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 6043f974ce..0843a7f74a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4102,26 +4102,29 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs, return -1; =20 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 mod= e")); return -1; - } - if (fs->accessmode !=3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) { + } + if (fs->accessmode !=3D VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtiofs only supports passthrough accessmod= e")); return -1; - } - if (fs->wrpolicy !=3D VIR_DOMAIN_FS_WRPOLICY_DEFAULT) { + } + if (fs->wrpolicy !=3D VIR_DOMAIN_FS_WRPOLICY_DEFAULT) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtiofs does not support wrpolicy")); return -1; + } } + if (fs->model !=3D VIR_DOMAIN_FS_MODEL_DEFAULT) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtiofs does not support model")); diff --git a/tests/qemuxml2argvdata/vhost-user-fs-sock.xml b/tests/qemuxml2= argvdata/vhost-user-fs-sock.xml new file mode 100644 index 0000000000..aef005d3fd --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-user-fs-sock.xml @@ -0,0 +1,39 @@ + + guest + 126f2720-6f8e-45ab-a886-ec9277079a67 + 14680064 + 14680064 + + + + + 2 + + hvm + + + + qemu64 + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + + +