From nobody Thu May 16 06:04:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1655997509; cv=none; d=zohomail.com; s=zohoarc; b=fWOfl/oa62KWSKFXcNoUuFDCOrr/kueXIwMKLRE4H63LZScLds/orm2/kyOWP4MwopVYdN8Hh1w94JGvG/FwFd82Xc3VIRIxmpK5KcuzYgqn/Xw+8TM9ozCQTlp7K9GpGrcCfATVxLGA521KwTnH/aVfZCBgSGbv2LLHJM5lYW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655997509; 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=DF9kDjGrUfK6GXqhTCV3vlQ7YPVMKy8EQfWNEbeZufs=; b=GXrkYHsSPg7n5ZBIp8Xo4VqAw/fzOebMeA3Phy93Z69p4wveeIRqvLEhEShKUSp8oBgzXwjr0Xzlx+k7kgbms8hL7f9Jo9PR7yb050ZsBltKTBX75h3RbpTbajMfs7Lq6ODh9hybjFZV6i2NJpbGaBISHfkZeOgZr0qqx+9qtW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1655997509980342.95707124677267; Thu, 23 Jun 2022 08:18:29 -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-62-nRwxQbZMO-ul6l7seEdSTA-1; Thu, 23 Jun 2022 11:18:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20EA93C0D19F; Thu, 23 Jun 2022 15:18:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D071E40466B4; Thu, 23 Jun 2022 15:18:21 +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 4C4A0194B955; Thu, 23 Jun 2022 15:18:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 826FE194B950 for ; Thu, 23 Jun 2022 15:18:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5FA222166B29; Thu, 23 Jun 2022 15:18:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7FC12166B26 for ; Thu, 23 Jun 2022 15:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655997508; 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=DF9kDjGrUfK6GXqhTCV3vlQ7YPVMKy8EQfWNEbeZufs=; b=ZcGG8jCaUJcglXjOEKC02k72MQKNTU2bfrFUImHQ/oWbq0/PlNmW6wdf4oBmPAcD8gHD9S G1eQZfia3QIXvWRgRm1zV8Wn7czgySBFjRX5nnkIZdMksxnYZ0bEhuNvGi10lWmilMMrHo cYR0EgWhrIBdcY32mo+FjMHQorBUAO4= X-MC-Unique: nRwxQbZMO-ul6l7seEdSTA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] storage: pool: Allow more intricate nfs protocol versions Date: Thu, 23 Jun 2022 17:18:18 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.84 on 10.11.54.1 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: 1655997510579100001 Content-Type: text/plain; charset="utf-8" Treat the 'protocolVer' field as a string so that e.g. '4.1' can be used. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/schemas/storagepool.rng | 4 +--- src/conf/storage_conf.c | 14 +++----------- 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 +- 7 files changed, 10 insertions(+), 20 deletions(-) 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..251fb9f0a2 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,12 +643,6 @@ 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); - return -1; - } } source->vendor =3D virXPathString("string(./vendor/@name)", ctxt); @@ -1099,9 +1093,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