From nobody Tue Apr 30 00:46:42 2024 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=1616773172; cv=none; d=zohomail.com; s=zohoarc; b=ce1CqG8zcMEgPt+UKY2ss6EgXKW3gEfTqBOwsGtHIuHZ7nYlbRiuwDPW0yYoZZ/1GI1VwGhf4thdtnstL9G/f3KthNwmjwZmOle5PUtHOBp2me4l09OXxeIEsZkxwL4aXcfbS9fUNGucrcxC1wUmWDFIt+KLBY0uMA49MUZLVak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616773172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=0m5n8hEWBcqFiodUgh6/4oD56qsVSh8FWrh3gamxh2M=; b=N/WK47ABi8Fa/GuHPH45XiVuzMjsODSwV9EGcIeTl8Q6fzNQmc5/Wz3KEkD/mhWz+n0BDEeyol4KCSPxj251wX8L+W35tZzSfAhbolFp0VkQKPeBKKATywNHi9dXHaG2tHQcu7PPpmNLM01p4ACA/mOr8NshhBsLUUUjAeFw9ng= 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 1616773172342804.9338885377202; Fri, 26 Mar 2021 08:39:32 -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-521-Har-iK4DMhK3cTIuekw1HA-1; Fri, 26 Mar 2021 11:39:20 -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 4B12494F10; Fri, 26 Mar 2021 15:38:23 +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 99EB189D1E; Fri, 26 Mar 2021 15:38:22 +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 747584BB7C; Fri, 26 Mar 2021 15:38:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12QFcJAs027203 for ; Fri, 26 Mar 2021 11:38:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 009CF101E24F; Fri, 26 Mar 2021 15:38:19 +0000 (UTC) Received: from worklaptop.home (ovpn-117-183.rdu2.redhat.com [10.10.117.183]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FB82101E249; Fri, 26 Mar 2021 15:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616773164; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0m5n8hEWBcqFiodUgh6/4oD56qsVSh8FWrh3gamxh2M=; b=WSDCkjDCafPxzni9zdibNOmMIvqeKJix2SPaBK8Ce0gMwx4+c5QsBkylzlqyZbrIx266CT dv9dEHwl8BzGnytIsqvr3o+KFi7QfQAzRzX3PGv3DBAL52WYyEBcd6tSyKY8bSFZcoIzbN GG8BU7ckIbJtfw+26shL8M+4c4O2x1Y= X-MC-Unique: Har-iK4DMhK3cTIuekw1HA-1 From: Cole Robinson To: libvir-list@redhat.com Subject: [PATCH] qemu: virtiofs: support Date: Fri, 26 Mar 2021 11:37:48 -0400 Message-Id: <6f2cb9738070c4274fcfab387c279c28ed2ff35c.1616773068.git.crobinso@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Cole Robinson 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add a new XML element Which maps to `virtiofsd -o sandbox=3Dchroot|namespace`, which was added in qemu 5.2.0: https://git.qemu.org/?p=3Dqemu.git;a=3Dcommit;h=3D06844584b62a43384642f7243= b0fc01c9fff0fc7 Signed-off-by: Cole Robinson --- docs/formatdomain.rst | 4 ++++ docs/schemas/domaincommon.rng | 12 ++++++++++ src/conf/domain_conf.c | 23 +++++++++++++++++++ src/conf/domain_conf.h | 10 ++++++++ src/libvirt_private.syms | 1 + src/qemu/qemu_virtiofs.c | 2 ++ .../vhost-user-fs-fd-memory.xml | 1 + 7 files changed, 53 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 9392c80113..9dda39dbcb 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3234,6 +3234,7 @@ A directory on the host that can be accessed directly= from the guest. + @@ -3358,6 +3359,9 @@ A directory on the host that can be accessed directly= from the guest. ``cache`` element, possible ``mode`` values being ``none`` and ``always= ``. Locking can be controlled via the ``lock`` element - attributes ``posix= `` and ``flock`` both accepting values ``on`` or ``off``. ( :since:`Since 6.2.= 0` ) + The sandboxing method used by virtiofsd can be configured with the ``sa= ndbox`` + element, possible ``mode`` values being ``namespace`` and + ``chroot``. ( :since:`Since 7.2.0` ) ``source`` The resource on the host that is being accessed in the guest. The ``nam= e`` attribute must be used with ``type=3D'template'``, and the ``dir`` attr= ibute diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 1dbfc68f18..6404ebf210 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2960,6 +2960,18 @@ + + + + + + namespace + chroot + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b0eba9f7bd..70a900ee25 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -538,6 +538,13 @@ VIR_ENUM_IMPL(virDomainFSCacheMode, "always", ); =20 +VIR_ENUM_IMPL(virDomainFSSandboxMode, + VIR_DOMAIN_FS_SANDBOX_MODE_LAST, + "default", + "namespace", + "chroot", +); + =20 VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST, @@ -10373,6 +10380,7 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *binary =3D virXPathString("string(./binary/@path)= ", ctxt); g_autofree char *xattr =3D virXPathString("string(./binary/@xattr)= ", ctxt); g_autofree char *cache =3D virXPathString("string(./binary/cache/@= mode)", ctxt); + g_autofree char *sandbox =3D virXPathString("string(./binary/sandb= ox/@mode)", ctxt); g_autofree char *posix_lock =3D virXPathString("string(./binary/lo= ck/@posix)", ctxt); g_autofree char *flock =3D virXPathString("string(./binary/lock/@f= lock)", ctxt); int val; @@ -10406,6 +10414,16 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlop= t, def->cache =3D val; } =20 + if (sandbox) { + if ((val =3D virDomainFSSandboxModeTypeFromString(sandbox)) <= =3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("cannot parse sandbox mode '%s' for virti= ofs"), + sandbox); + goto error; + } + def->sandbox =3D val; + } + if (posix_lock) { if ((val =3D virTristateSwitchTypeFromString(posix_lock)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -25483,6 +25501,11 @@ virDomainFSDefFormat(virBufferPtr buf, virDomainFSCacheModeTypeToString(def->cache)= ); } =20 + if (def->sandbox !=3D VIR_DOMAIN_FS_SANDBOX_MODE_DEFAULT) { + virBufferAsprintf(&binaryBuf, "\n", + virDomainFSSandboxModeTypeToString(def->sand= box)); + } + if (def->posix_lock !=3D VIR_TRISTATE_SWITCH_ABSENT) { virBufferAsprintf(&lockAttrBuf, " posix=3D'%s'", virTristateSwitchTypeToString(def->posix_loc= k)); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0b8895bbdf..d77b04847b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -846,6 +846,14 @@ typedef enum { VIR_DOMAIN_FS_CACHE_MODE_LAST } virDomainFSCacheMode; =20 +typedef enum { + VIR_DOMAIN_FS_SANDBOX_MODE_DEFAULT =3D 0, + VIR_DOMAIN_FS_SANDBOX_MODE_NAMESPACE, + VIR_DOMAIN_FS_SANDBOX_MODE_CHROOT, + + VIR_DOMAIN_FS_SANDBOX_MODE_LAST +} virDomainFSSandboxMode; + struct _virDomainFSDef { int type; int fsdriver; /* enum virDomainFSDriverType */ @@ -870,6 +878,7 @@ struct _virDomainFSDef { virDomainFSCacheMode cache; virTristateSwitch posix_lock; virTristateSwitch flock; + virDomainFSSandboxMode sandbox; virDomainVirtioOptionsPtr virtio; virObjectPtr privateData; }; @@ -3800,6 +3809,7 @@ VIR_ENUM_DECL(virDomainFSAccessMode); VIR_ENUM_DECL(virDomainFSWrpolicy); VIR_ENUM_DECL(virDomainFSModel); VIR_ENUM_DECL(virDomainFSCacheMode); +VIR_ENUM_DECL(virDomainFSSandboxMode); VIR_ENUM_DECL(virDomainNet); VIR_ENUM_DECL(virDomainNetBackend); VIR_ENUM_DECL(virDomainNetVirtioTxMode); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cb9fe7c80a..04b2bc9dcd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -414,6 +414,7 @@ virDomainFSDriverTypeToString; virDomainFSIndexByName; virDomainFSInsert; virDomainFSRemove; +virDomainFSSandboxModeTypeToString; virDomainFSTypeFromString; virDomainFSTypeToString; virDomainFSWrpolicyTypeFromString; diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index 2e239cad66..988b757d6f 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -131,6 +131,8 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfigPtr cfg, virQEMUBuildBufferEscapeComma(&opts, fs->src->path); if (fs->cache) virBufferAsprintf(&opts, ",cache=3D%s", virDomainFSCacheModeTypeTo= String(fs->cache)); + if (fs->sandbox) + virBufferAsprintf(&opts, ",sandbox=3D%s", virDomainFSSandboxModeTy= peToString(fs->sandbox)); =20 if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) virBufferAddLit(&opts, ",xattr"); diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml b/tests/qem= uxml2argvdata/vhost-user-fs-fd-memory.xml index 2277850c2c..abddf0870b 100644 --- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml +++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml @@ -30,6 +30,7 @@ + --=20 2.30.2