From nobody Sun Feb 8 10:50:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543942067376449.7767000266666; Tue, 4 Dec 2018 08:47:47 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA2AB58E47; Tue, 4 Dec 2018 16:47:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 622B917AC0; Tue, 4 Dec 2018 16:47:44 +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 0B16B181B9F6; Tue, 4 Dec 2018 16:47:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wB4GlK9p022363 for ; Tue, 4 Dec 2018 11:47:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8D4D817AC0; Tue, 4 Dec 2018 16:47:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-18.phx2.redhat.com [10.3.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B5D417D44 for ; Tue, 4 Dec 2018 16:47:20 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:10 -0500 Message-Id: <20181204164717.5013-2-jferlan@redhat.com> In-Reply-To: <20181204164717.5013-1-jferlan@redhat.com> References: <20181204164717.5013-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] storage: Extract out mount command creation for FS Backend 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 04 Dec 2018 16:47:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Extract out the code that is used to create the MOUNT command for starting the pool. We can use this for Storage Pool XML to Argv testing to ensure code changes don't alter how a storage pool is started. Signed-off-by: John Ferlan --- src/storage/storage_backend_fs.c | 70 +++++++++++++++++++------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 0837443391..4bf411b330 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -330,19 +330,11 @@ virStorageBackendFileSystemIsMounted(virStoragePoolOb= jPtr pool) return ret; } =20 -/** - * @pool storage pool to mount - * - * Ensure that a FS storage pool is mounted on its target location. - * If already mounted, this is a no-op - * - * Returns 0 if successfully mounted, -1 on error - */ -static int -virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) + +static virCommandPtr +virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, + const char *src) { - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); - char *src =3D NULL; /* 'mount -t auto' doesn't seem to auto determine nfs (or cifs), * while plain 'mount' does. We have to craft separate argvs to * accommodate this */ @@ -353,23 +345,6 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr = pool) bool cifsfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS); virCommandPtr cmd =3D NULL; - int ret =3D -1; - int rc; - - if (virStorageBackendFileSystemIsValid(pool) < 0) - return -1; - - if ((rc =3D virStorageBackendFileSystemIsMounted(pool)) < 0) - return -1; - - /* Short-circuit if already mounted */ - if (rc =3D=3D 1) { - VIR_INFO("Target '%s' is already mounted", def->target.path); - return 0; - } - - if (!(src =3D virStorageBackendFileSystemGetPoolSource(pool))) - return -1; =20 if (netauto) cmd =3D virCommandNewArgList(MOUNT, @@ -404,6 +379,43 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr = pool) def->target.path, NULL); =20 + return cmd; +} + + +/** + * @pool storage pool to mount + * + * Ensure that a FS storage pool is mounted on its target location. + * If already mounted, this is a no-op + * + * Returns 0 if successfully mounted, -1 on error + */ +static int +virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) +{ + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + char *src =3D NULL; + virCommandPtr cmd =3D NULL; + int ret =3D -1; + int rc; + + if (virStorageBackendFileSystemIsValid(pool) < 0) + return -1; + + if ((rc =3D virStorageBackendFileSystemIsMounted(pool)) < 0) + return -1; + + /* Short-circuit if already mounted */ + if (rc =3D=3D 1) { + VIR_INFO("Target '%s' is already mounted", def->target.path); + return 0; + } + + if (!(src =3D virStorageBackendFileSystemGetPoolSource(pool))) + return -1; + + cmd =3D virStorageBackendFileSystemMountCmd(def, src); if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list