From nobody Thu Sep 19 00:53:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1719325917425939.4592225530251; Tue, 25 Jun 2024 07:31:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5043B13D9; Tue, 25 Jun 2024 10:31:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DA6D01451; Tue, 25 Jun 2024 10:31:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 53F5813F7; Tue, 25 Jun 2024 10:31:10 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7B25C1443 for ; Tue, 25 Jun 2024 10:31:02 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-cpWCRL3ENJG_GKGNTcdkpg-1; Tue, 25 Jun 2024 10:31:00 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EB53C1918051 for ; Tue, 25 Jun 2024 14:28:55 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.105]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E70551956087 for ; Tue, 25 Jun 2024 14:28:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: *** X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719325862; h=from:from: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; bh=5HQiM3+qXztcsm6hJBVLpZRPUTl3R0G2op3ahcz4B5M=; b=FoGgit8U97Y+2BsigJkdiEAsYMFBmXLzgJOjvPgg2wtf8rNFRRsZEoF2uAdbmeaNudrtpA EBYbPE1xiZAi5VHYZynCKo7YVHpKNlxHnGhWmsjJoFLUUevzFKVq2EjlfKQ4k65KRvvAbj G9OjJwFUNOYia+XUYEzVWdYerpJRAgw= X-MC-Unique: cpWCRL3ENJG_GKGNTcdkpg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 2/2] qemu: do not use deprecated options for new virtiofsd Date: Tue, 25 Jun 2024 16:28:00 +0200 Message-ID: <15f1e40bb5510ad43bf23092e22eaf51ee1c72cc.1719325680.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ROCDHQQB7GKQNE22GDLADTZHGMXGSKC6 X-Message-ID-Hash: ROCDHQQB7GKQNE22GDLADTZHGMXGSKC6 X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1719325919540100001 Content-Type: text/plain; charset="utf-8" Use the to-be-introduced virtiofsd capability to mark whether new options are safe to use. Depends on: https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/231 https://issues.redhat.com/browse/RHEL-7108 Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_vhost_user.c | 5 ++- src/qemu/qemu_virtiofs.c | 79 +++++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c index b916412bc0..a31fe6ed53 100644 --- a/src/qemu/qemu_vhost_user.c +++ b/src/qemu/qemu_vhost_user.c @@ -450,6 +450,7 @@ qemuVhostUserFillFSCapabilities(virBitmap **caps, if (!(featuresJSON =3D virJSONValueObjectGetArray(doc, "features"))) return 0; =20 + features =3D virBitmapNew(1); nfeatures =3D virJSONValueArraySize(featuresJSON); =20 for (i =3D 0; i < nfeatures; i++) { @@ -457,8 +458,8 @@ qemuVhostUserFillFSCapabilities(virBitmap **caps, const char *tmpStr =3D virJSONValueGetString(item); int tmp; =20 - if ((tmp =3D qemuVhostUserFSFeatureTypeFromString(tmpStr)) <=3D 0)= { - VIR_DEBUG("ignoring unknown QEMU vhost-user feature '%s'", tmp= Str); + if ((tmp =3D qemuVhostUserFSFeatureTypeFromString(tmpStr)) < 0) { + VIR_DEBUG("ignoring unknown QEMU virtiofs feature '%s'", tmpSt= r); continue; } virBitmapSetBitExpand(features, tmp); diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c index aba6a19562..f16e0c8532 100644 --- a/src/qemu/qemu_virtiofs.c +++ b/src/qemu/qemu_virtiofs.c @@ -139,36 +139,63 @@ qemuVirtioFSBuildCommandLine(virQEMUDriverConfig *cfg, virCommandPassFD(cmd, *fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); *fd =3D -1; =20 - virCommandAddArg(cmd, "-o"); - virBufferAddLit(&opts, "source=3D"); - 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)); - - if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",xattr"); - else if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_xattr"); - - if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",flock"); - else if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_flock"); - - if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_ON) - virBufferAddLit(&opts, ",posix_lock"); - else if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_OFF) - virBufferAddLit(&opts, ",no_posix_lock"); - - virCommandAddArgBuffer(cmd, &opts); + if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_OPTIONS)) { + virCommandAddArg(cmd, "--shared-dir"); + virCommandAddArg(cmd, fs->src->path); + + if (fs->cache) { + virCommandAddArg(cmd, "--cache"); + virCommandAddArg(cmd, virDomainFSCacheModeTypeToString(fs->cac= he)); + } + if (fs->sandbox) { + virCommandAddArg(cmd, "--sandbox"); + virCommandAddArg(cmd, virDomainFSSandboxModeTypeToString(fs->s= andbox)); + } + + if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) + virCommandAddArg(cmd, "--xattr"); + + if (fs->posix_lock !=3D VIR_TRISTATE_SWITCH_ABSENT || + fs->flock !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("locking op= tions are not supported by this virtiofsd")); + return NULL; + } + } else { + virCommandAddArg(cmd, "-o"); + virBufferAddLit(&opts, "source=3D"); + virQEMUBuildBufferEscapeComma(&opts, fs->src->path); + if (fs->cache) + virBufferAsprintf(&opts, ",cache=3D%s", virDomainFSCacheModeTy= peToString(fs->cache)); + if (fs->sandbox) + virBufferAsprintf(&opts, ",sandbox=3D%s", virDomainFSSandboxMo= deTypeToString(fs->sandbox)); + + if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",xattr"); + else if (fs->xattr =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_xattr"); + + if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",flock"); + else if (fs->flock =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_flock"); + + if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_ON) + virBufferAddLit(&opts, ",posix_lock"); + else if (fs->posix_lock =3D=3D VIR_TRISTATE_SWITCH_OFF) + virBufferAddLit(&opts, ",no_posix_lock"); + + virCommandAddArgBuffer(cmd, &opts); + } =20 if (fs->thread_pool_size >=3D 0) virCommandAddArgFormat(cmd, "--thread-pool-size=3D%i", fs->thread_= pool_size); =20 - if (cfg->virtiofsdDebug) - virCommandAddArg(cmd, "-d"); + if (cfg->virtiofsdDebug) { + if (virBitmapIsBitSet(fs->caps, QEMU_VHOST_USER_FS_FEATURE_OPTIONS= )) + virCommandAddArgList(cmd, "--log-level", "debug", NULL); + else + virCommandAddArg(cmd, "-d"); + } =20 for (i =3D 0; i < fs->idmap.nuidmap; i++) { virCommandAddArgFormat(cmd, "--uid-map=3D:%u:%u:%u:", --=20 2.45.2