From nobody Wed May 15 23:29:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1656683211; cv=none; d=zohomail.com; s=zohoarc; b=WDxxFB6VL33ppA8r4YAGPYew9FhnbT2jkSrKRFjRBEhmh93hsvqZswUzcz/lp3XEKayAPB9Qmx1m1iLVivKcZG2iUN0nRzD05c2aKnwnaEhdKnqlVo6I0t7m/NL+Y53LUDBPW8CdXL1gfokG7PSHttKtcXNZA+9u/J9knFIy4T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656683211; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=2at8xaZGqFDy2yJmVmZOhrEv5ooZCnanVRya2PiqD8Y=; b=C0UBtPci0dFuQpCdZPpeAtcSkqdkiaRpyrGOlkFI6y6l5ox4E0FqhtExB5azW3JXdJVMOaNQ4eBwkHBFjNNQvSqfjn+Es0mP9hnEeEGnx8CGm4L/5a3ELT0EJeIgfMmI0dY8QZyE6HRKczcLa2OrFhhq68w74qxFTf3z19Tt8UA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1656683211324952.2438881178824; Fri, 1 Jul 2022 06:46:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-mohdrELLMtGiPlz9ZBxNeA-1; Fri, 01 Jul 2022 09:46:44 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E8133C11748; Fri, 1 Jul 2022 13:46:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85147416154; Fri, 1 Jul 2022 13:46:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C26C1947064; Fri, 1 Jul 2022 13:46:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9E7051947058 for ; Fri, 1 Jul 2022 13:46:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 64F95416154; Fri, 1 Jul 2022 13:46:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id C811A40336E for ; Fri, 1 Jul 2022 13:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656683210; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2at8xaZGqFDy2yJmVmZOhrEv5ooZCnanVRya2PiqD8Y=; b=YjJQnjNRkK2oA1V6WAxze1mAnYhaB/WBEyYaZpcFDtWrlo3A28LCPtTO+zVJI2jhiw5og5 wTCOw7oRLfJhbto2V0NJRWwmYRcu+HAy3BYfWG02wigckBEA3mIVAqVdtLiOg9nvNf5otX vaImANuREW1dDiwDpNhkeNA3+7NBcA0= X-MC-Unique: mohdrELLMtGiPlz9ZBxNeA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCHv2] storage: pool: Allow more intricate nfs protocol versions Date: Fri, 1 Jul 2022 15:46:36 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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) X-ZM-MESSAGEID: 1656683211907100001 Content-Type: text/plain; charset="utf-8" Treat the 'protocolVer' field as a string so that e.g. '4.1' can be used. Forbid only ',' in the string as it's a separator of arguments for mount options. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- v2: - forbid ',' in the version string. docs/formatstorage.rst | 2 +- src/conf/schemas/storagepool.rng | 4 +--- src/conf/storage_conf.c | 17 ++++++++--------- src/conf/storage_conf.h | 2 +- src/storage/storage_util.c | 4 ++-- .../pool-netfs-protocol-ver-linux.argv | 2 +- .../pool-netfs-protocol-ver.xml | 2 +- .../pool-netfs-protocol-ver.xml | 2 +- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/docs/formatstorage.rst b/docs/formatstorage.rst index ef15c0ac5c..83d7d141ac 100644 --- a/docs/formatstorage.rst +++ b/docs/formatstorage.rst @@ -350,7 +350,7 @@ following child elements: ``protocol`` For a ``netfs`` Storage Pool provide a mechanism to define which NFS pr= otocol version number will be used to contact the server's NFS service. The - attribute ``ver`` accepts an unsigned integer as the version number to = use. + attribute ``ver`` accepts the version number to use. :since:`Since 5.1.0` ``vendor`` Provides optional information about the vendor of the storage device. T= his diff --git a/src/conf/schemas/storagepool.rng b/src/conf/schemas/storagepoo= l.rng index bd24b8b8d0..d81ead532a 100644 --- a/src/conf/schemas/storagepool.rng +++ b/src/conf/schemas/storagepool.rng @@ -577,9 +577,7 @@ - - - + diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5da0bf20dd..79f16aadf3 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -483,6 +483,7 @@ virStoragePoolSourceClear(virStoragePoolSource *source) virStorageAuthDefFree(source->auth); VIR_FREE(source->vendor); VIR_FREE(source->product); + VIR_FREE(source->protocolVer); } @@ -526,7 +527,6 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolOptions *options; int n; g_autoptr(virStorageAuthDef) authdef =3D NULL; - g_autofree char *ver =3D NULL; g_autofree xmlNodePtr *nodeset =3D NULL; g_autofree char *sourcedir =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) @@ -634,7 +634,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, } /* Option protocol version string (NFSvN) */ - if ((ver =3D virXPathString("string(./protocol/@ver)", ctxt))) { + if ((source->protocolVer =3D virXPathString("string(./protocol/@ver)",= ctxt))) { if ((source->format !=3D VIR_STORAGE_POOL_NETFS_NFS) && (source->format !=3D VIR_STORAGE_POOL_NETFS_AUTO)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -643,10 +643,11 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, virStoragePoolFormatFileSystemNetTypeToString(s= ource->format)); return -1; } - if (virStrToLong_uip(ver, NULL, 0, &source->protocolVer) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("storage pool protocol ver '%s' is malformed"= ), - ver); + + if (strchr(source->protocolVer, ',')) { + virReportError(VIR_ERR_XML_DETAIL, + _("storage pool protocol ver '%s' must not cont= ain ','"), + source->protocolVer); return -1; } } @@ -1099,9 +1100,7 @@ virStoragePoolSourceFormat(virBuffer *buf, if (src->auth) virStorageAuthDefFormat(buf, src->auth); - if (src->protocolVer) - virBufferAsprintf(buf, "\n", src->protocolVe= r); - + virBufferEscapeString(buf, "\n", src->protocolVe= r); virBufferEscapeString(buf, "\n", src->vendor); virBufferEscapeString(buf, "\n", src->product); diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index de39c3f294..a1bf243935 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -213,7 +213,7 @@ struct _virStoragePoolSource { int format; /* Protocol version value for netfs */ - unsigned int protocolVer; + char *protocolVer; }; typedef struct _virStoragePoolTarget virStoragePoolTarget; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 6ed2078b65..3871718b09 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4201,8 +4201,8 @@ virStorageBackendFileSystemMountCmd(const char *cmdst= r, virCommand *cmd =3D NULL; g_autofree char *nfsVers =3D NULL; - if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.protocolVer= > 0) - nfsVers =3D g_strdup_printf("nfsvers=3D%u", def->source.protocolVe= r); + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.protocolVer) + nfsVers =3D g_strdup_printf("nfsvers=3D%s", def->source.protocolVe= r); cmd =3D virCommandNew(cmdstr); if (netauto) diff --git a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.ar= gv b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv index dac46a074f..da3e0c5927 100644 --- a/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv +++ b/tests/storagepoolxml2argvdata/pool-netfs-protocol-ver-linux.argv @@ -1,5 +1,5 @@ mount \ --o nodev,nosuid,noexec,nfsvers=3D3 \ +-o nodev,nosuid,noexec,nfsvers=3D4.1 \ -t nfs \ localhost:/var/lib/libvirt/images \ /mnt diff --git a/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml b/tests= /storagepoolxml2xmlin/pool-netfs-protocol-ver.xml index 40f3f94e41..f35992e3c8 100644 --- a/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml +++ b/tests/storagepoolxml2xmlin/pool-netfs-protocol-ver.xml @@ -8,7 +8,7 @@ - + /mnt diff --git a/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml b/test= s/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml index 5fcad1305b..74c2f5edfe 100644 --- a/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml +++ b/tests/storagepoolxml2xmlout/pool-netfs-protocol-ver.xml @@ -8,7 +8,7 @@ - + /mnt --=20 2.36.1