From nobody Sat Apr 20 06:01:40 2024 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 From nobody Sat Apr 20 06:01:40 2024 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 1543942048614161.60161080414753; Tue, 4 Dec 2018 08:47:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0BBC5F; Tue, 4 Dec 2018 16:47:24 +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 2855B1054FC9; Tue, 4 Dec 2018 16:47:24 +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 2BFA04EA3B; Tue, 4 Dec 2018 16:47:22 +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 wB4GlLoQ022368 for ; Tue, 4 Dec 2018 11:47:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05CB517AC0; Tue, 4 Dec 2018 16:47:21 +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 B74A35DD8A 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:11 -0500 Message-Id: <20181204164717.5013-3-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 2/8] storage: Move FS backend mount creation command helper 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 04 Dec 2018 16:47:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move virStorageBackendFileSystemMountCmd to storage_util so that it can be used by the test harness. Signed-off-by: John Ferlan --- src/storage/storage_backend_fs.c | 52 -------------------------------- src/storage/storage_util.c | 52 ++++++++++++++++++++++++++++++++ src/storage/storage_util.h | 4 +++ 3 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 4bf411b330..b341ba84fa 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -331,58 +331,6 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObj= Ptr pool) } =20 =20 -static virCommandPtr -virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, - const char *src) -{ - /* '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 */ - bool netauto =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && - def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_AUTO); - bool glusterfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && - def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_GLU= STERFS); - 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; - - if (netauto) - cmd =3D virCommandNewArgList(MOUNT, - src, - def->target.path, - NULL); - else if (glusterfs) - cmd =3D virCommandNewArgList(MOUNT, - "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), - src, - "-o", - "direct-io-mode=3D1", - def->target.path, - NULL); - else if (cifsfs) - cmd =3D virCommandNewArgList(MOUNT, - "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), - src, - def->target.path, - "-o", - "guest", - NULL); - else - cmd =3D virCommandNewArgList(MOUNT, - "-t", - (def->type =3D=3D VIR_STORAGE_POOL_FS ? - virStoragePoolFormatFileSystemTypeToSt= ring(def->source.format) : - virStoragePoolFormatFileSystemNetTypeT= oString(def->source.format)), - src, - def->target.path, - NULL); - - return cmd; -} - - /** * @pool storage pool to mount * diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 318a556656..180d7b1fa3 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4226,3 +4226,55 @@ virStorageBackendZeroPartitionTable(const char *path, return storageBackendVolWipeLocalFile(path, VIR_STORAGE_VOL_WIPE_ALG_Z= ERO, size, true); } + + +virCommandPtr +virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, + const char *src) +{ + /* '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 */ + bool netauto =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_AUTO); + bool glusterfs =3D (def->type =3D=3D VIR_STORAGE_POOL_NETFS && + def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_GLU= STERFS); + 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; + + if (netauto) + cmd =3D virCommandNewArgList(MOUNT, + src, + def->target.path, + NULL); + else if (glusterfs) + cmd =3D virCommandNewArgList(MOUNT, + "-t", + virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), + src, + "-o", + "direct-io-mode=3D1", + def->target.path, + NULL); + else if (cifsfs) + cmd =3D virCommandNewArgList(MOUNT, + "-t", + virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), + src, + def->target.path, + "-o", + "guest", + NULL); + else + cmd =3D virCommandNewArgList(MOUNT, + "-t", + (def->type =3D=3D VIR_STORAGE_POOL_FS ? + virStoragePoolFormatFileSystemTypeToSt= ring(def->source.format) : + virStoragePoolFormatFileSystemNetTypeT= oString(def->source.format)), + src, + def->target.path, + NULL); + + return cmd; +} diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 58b991c772..5b0baf56c4 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -177,4 +177,8 @@ int virStorageBackendZeroPartitionTable(const char *path, unsigned long long size); =20 +virCommandPtr +virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, + const char *src); + #endif /* __VIR_STORAGE_UTIL_H__ */ --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 1543942075611184.2942580642324; Tue, 4 Dec 2018 08:47:55 -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 E9EFB307D867; Tue, 4 Dec 2018 16:47:50 +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 7DE1318B8E; Tue, 4 Dec 2018 16:47:50 +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 1A4444EA42; Tue, 4 Dec 2018 16:47:50 +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 wB4GlLmb022373 for ; Tue, 4 Dec 2018 11:47:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 749D117AC0; Tue, 4 Dec 2018 16:47:21 +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 30CB36128A for ; Tue, 4 Dec 2018 16:47:21 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:12 -0500 Message-Id: <20181204164717.5013-4-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 3/8] storage: Move virStorageBackendFileSystemGetPoolSource 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.48]); Tue, 04 Dec 2018 16:47:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move into storage_util for reuse by test harness Signed-off-by: John Ferlan --- src/storage/storage_backend_fs.c | 33 -------------------------------- src/storage/storage_util.c | 33 ++++++++++++++++++++++++++++++++ src/storage/storage_util.h | 3 +++ 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index b341ba84fa..c5e75627b5 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -245,39 +245,6 @@ virStorageBackendFileSystemIsValid(virStoragePoolObjPt= r pool) } =20 =20 -/** - * virStorageBackendFileSystemGetPoolSource - * @pool: storage pool object pointer - * - * Allocate/return a string representing the FS storage pool source. - * It is up to the caller to VIR_FREE the allocated string - */ -static char * -virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool) -{ - virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); - char *src =3D NULL; - - if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) { - if (def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS) { - if (virAsprintf(&src, "//%s/%s", - def->source.hosts[0].name, - def->source.dir) < 0) - return NULL; - } else { - if (virAsprintf(&src, "%s:%s", - def->source.hosts[0].name, - def->source.dir) < 0) - return NULL; - } - } else { - if (VIR_STRDUP(src, def->source.devices[0].path) < 0) - return NULL; - } - return src; -} - - /** * @pool storage pool to check for status * diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 180d7b1fa3..c9f6096687 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4228,6 +4228,39 @@ virStorageBackendZeroPartitionTable(const char *path, } =20 =20 +/** + * virStorageBackendFileSystemGetPoolSource + * @pool: storage pool object pointer + * + * Allocate/return a string representing the FS storage pool source. + * It is up to the caller to VIR_FREE the allocated string + */ +char * +virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool) +{ + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + char *src =3D NULL; + + if (def->type =3D=3D VIR_STORAGE_POOL_NETFS) { + if (def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS) { + if (virAsprintf(&src, "//%s/%s", + def->source.hosts[0].name, + def->source.dir) < 0) + return NULL; + } else { + if (virAsprintf(&src, "%s:%s", + def->source.hosts[0].name, + def->source.dir) < 0) + return NULL; + } + } else { + if (VIR_STRDUP(src, def->source.devices[0].path) < 0) + return NULL; + } + return src; +} + + virCommandPtr virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, const char *src) diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 5b0baf56c4..28b3e0b9c9 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -177,6 +177,9 @@ int virStorageBackendZeroPartitionTable(const char *path, unsigned long long size); =20 +char * +virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool); + virCommandPtr virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, const char *src); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 1543942051161629.9362930994391; Tue, 4 Dec 2018 08:47:31 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D94B237E74; Tue, 4 Dec 2018 16:47:25 +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 8EE9B1054FD2; Tue, 4 Dec 2018 16:47:25 +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 1D33A181B9E7; Tue, 4 Dec 2018 16:47:25 +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 wB4GlLd6022381 for ; Tue, 4 Dec 2018 11:47:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id E03AA17C1E; Tue, 4 Dec 2018 16:47:21 +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 9D28717AC0 for ; Tue, 4 Dec 2018 16:47:21 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:13 -0500 Message-Id: <20181204164717.5013-5-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 4/8] tests: Introduce tests for storage pool xml to argv checks 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 04 Dec 2018 16:47:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Similar to qemuxml2argv and storagevolxml2argv, let's create some tests to ensure that the XML generates a consistent command line. Using the same list of pools as storagepoolxml2xmltest, start with the file system tests (fs, netfs, netfs-cifs, netfs-gluster). Signed-off-by: John Ferlan --- tests/Makefile.am | 12 ++ tests/storagepoolxml2argvdata/pool-fs.argv | 1 + .../pool-netfs-cifs.argv | 1 + .../pool-netfs-gluster.argv | 1 + tests/storagepoolxml2argvdata/pool-netfs.argv | 1 + tests/storagepoolxml2argvtest.c | 171 ++++++++++++++++++ 6 files changed, 187 insertions(+) create mode 100644 tests/storagepoolxml2argvdata/pool-fs.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-cifs.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-gluster.argv create mode 100644 tests/storagepoolxml2argvdata/pool-netfs.argv create mode 100644 tests/storagepoolxml2argvtest.c diff --git a/tests/Makefile.am b/tests/Makefile.am index d7ec7e3a6f..bec0930c11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -140,6 +140,7 @@ EXTRA_DIST =3D \ storagepoolschemadata \ storagepoolxml2xmlin \ storagepoolxml2xmlout \ + storagepoolxml2argvdata \ storagevolschemadata \ storagevolxml2argvdata \ storagevolxml2xmlin \ @@ -363,6 +364,7 @@ endif WITH_NWFILTER =20 if WITH_STORAGE test_programs +=3D storagevolxml2argvtest +test_programs +=3D storagepoolxml2argvtest test_programs +=3D virstorageutiltest endif WITH_STORAGE =20 @@ -901,6 +903,16 @@ storagevolxml2argvtest_LDADD =3D \ ../src/libvirt_util.la \ $(LDADDS) =20 +storagepoolxml2argvtest_SOURCES =3D \ + storagepoolxml2argvtest.c \ + testutils.c testutils.h +storagepoolxml2argvtest_LDADD =3D \ + $(LIBXML_LIBS) \ + ../src/libvirt_driver_storage_impl.la \ + ../src/libvirt_conf.la \ + ../src/libvirt_util.la \ + $(LDADDS) + else ! WITH_STORAGE EXTRA_DIST +=3D storagevolxml2argvtest.c EXTRA_DIST +=3D virstorageutiltest.c diff --git a/tests/storagepoolxml2argvdata/pool-fs.argv b/tests/storagepool= xml2argvdata/pool-fs.argv new file mode 100644 index 0000000000..4a94148114 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-fs.argv @@ -0,0 +1 @@ +/usr/bin/mount -t ext3 /dev/sda6 /mnt diff --git a/tests/storagepoolxml2argvdata/pool-netfs-cifs.argv b/tests/sto= ragepoolxml2argvdata/pool-netfs-cifs.argv new file mode 100644 index 0000000000..7a06f86f66 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-cifs.argv @@ -0,0 +1 @@ +/usr/bin/mount -t cifs //example.com/samba_share /mnt/cifs -o guest diff --git a/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv b/tests/= storagepoolxml2argvdata/pool-netfs-gluster.argv new file mode 100644 index 0000000000..90e94f6f13 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-gluster.argv @@ -0,0 +1 @@ +/usr/bin/mount -t glusterfs example.com:/volume -o direct-io-mode=3D1 /mnt= /gluster diff --git a/tests/storagepoolxml2argvdata/pool-netfs.argv b/tests/storagep= oolxml2argvdata/pool-netfs.argv new file mode 100644 index 0000000000..f890a03f7e --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs.argv @@ -0,0 +1 @@ +/usr/bin/mount -t nfs localhost:/var/lib/libvirt/images /mnt diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c new file mode 100644 index 0000000000..74f8561379 --- /dev/null +++ b/tests/storagepoolxml2argvtest.c @@ -0,0 +1,171 @@ +#include + +#include "internal.h" +#include "testutils.h" +#include "datatypes.h" +#include "storage/storage_util.h" +#include "testutilsqemu.h" +#include "virstring.h" + +#define VIR_FROM_THIS VIR_FROM_NONE + + +static int +testCompareXMLToArgvFiles(bool shouldFail, + const char *poolxml, + const char *cmdline) +{ + VIR_AUTOFREE(char *) actualCmdline =3D NULL; + VIR_AUTOFREE(char *) src =3D NULL; + int ret =3D -1; + virCommandPtr cmd =3D NULL; + virStoragePoolDefPtr def =3D NULL; + virStoragePoolObjPtr pool =3D NULL; + + if (!(def =3D virStoragePoolDefParseFile(poolxml))) + goto cleanup; + + switch ((virStoragePoolType)def->type) { + case VIR_STORAGE_POOL_FS: + case VIR_STORAGE_POOL_NETFS: + if (!(pool =3D virStoragePoolObjNew())) { + VIR_TEST_DEBUG("pool type %d alloc pool obj fails\n", def->typ= e); + virStoragePoolDefFree(def); + goto cleanup; + } + virStoragePoolObjSetDef(pool, def); + + if (!(src =3D virStorageBackendFileSystemGetPoolSource(pool))) { + VIR_TEST_DEBUG("pool type %d has no pool source\n", def->type); + goto cleanup; + } + + cmd =3D virStorageBackendFileSystemMountCmd(def, src); + break; + + case VIR_STORAGE_POOL_DIR: + case VIR_STORAGE_POOL_LOGICAL: + case VIR_STORAGE_POOL_DISK: + case VIR_STORAGE_POOL_ISCSI: + case VIR_STORAGE_POOL_ISCSI_DIRECT: + case VIR_STORAGE_POOL_SCSI: + case VIR_STORAGE_POOL_MPATH: + case VIR_STORAGE_POOL_RBD: + case VIR_STORAGE_POOL_SHEEPDOG: + case VIR_STORAGE_POOL_GLUSTER: + case VIR_STORAGE_POOL_ZFS: + case VIR_STORAGE_POOL_VSTORAGE: + case VIR_STORAGE_POOL_LAST: + default: + VIR_TEST_DEBUG("pool type %d has no xml2argv test\n", def->type); + goto cleanup; + }; + + if (!(actualCmdline =3D virCommandToString(cmd))) { + VIR_TEST_DEBUG("pool type %d failed to get commandline\n", def->ty= pe); + goto cleanup; + } + + if (virTestCompareToFile(actualCmdline, cmdline) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virCommandFree(cmd); + VIR_FREE(actualCmdline); + virStoragePoolObjEndAPI(&pool); + if (shouldFail) { + virResetLastError(); + ret =3D 0; + } + return ret; +} + +struct testInfo { + bool shouldFail; + const char *pool; +}; + +static int +testCompareXMLToArgvHelper(const void *data) +{ + int result =3D -1; + const struct testInfo *info =3D data; + char *poolxml =3D NULL; + char *cmdline =3D NULL; + + if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml", + abs_srcdir, info->pool) < 0) + goto cleanup; + + if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s.argv", + abs_srcdir, info->pool) < 0 && !info->shouldFail) + goto cleanup; + + result =3D testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdlin= e); + + cleanup: + VIR_FREE(poolxml); + VIR_FREE(cmdline); + + return result; +} + + +static int +mymain(void) +{ + int ret =3D 0; + +#define DO_TEST_FULL(shouldFail, pool) \ + do { \ + struct testInfo info =3D { shouldFail, pool }; \ + if (virTestRun("Storage Pool XML-2-argv " pool, \ + testCompareXMLToArgvHelper, &info) < 0) \ + ret =3D -1; \ + } \ + while (0); + +#define DO_TEST(pool, ...) \ + DO_TEST_FULL(false, pool) + +#define DO_TEST_FAIL(pool, ...) \ + DO_TEST_FULL(true, pool) + + DO_TEST_FAIL("pool-dir"); + DO_TEST_FAIL("pool-dir-naming"); + DO_TEST("pool-fs"); + DO_TEST_FAIL("pool-logical"); + DO_TEST_FAIL("pool-logical-nopath"); + DO_TEST_FAIL("pool-logical-create"); + DO_TEST_FAIL("pool-logical-noname"); + DO_TEST_FAIL("pool-disk"); + DO_TEST_FAIL("pool-disk-device-nopartsep"); + DO_TEST_FAIL("pool-iscsi"); + DO_TEST_FAIL("pool-iscsi-auth"); + DO_TEST("pool-netfs"); + DO_TEST("pool-netfs-gluster"); + DO_TEST("pool-netfs-cifs"); + DO_TEST_FAIL("pool-scsi"); + DO_TEST_FAIL("pool-scsi-type-scsi-host"); + DO_TEST_FAIL("pool-scsi-type-fc-host"); + DO_TEST_FAIL("pool-scsi-type-fc-host-managed"); + DO_TEST_FAIL("pool-mpath"); + DO_TEST_FAIL("pool-iscsi-multiiqn"); + DO_TEST_FAIL("pool-iscsi-vendor-product"); + DO_TEST_FAIL("pool-sheepdog"); + DO_TEST_FAIL("pool-gluster"); + DO_TEST_FAIL("pool-gluster-sub"); + DO_TEST_FAIL("pool-scsi-type-scsi-host-stable"); + DO_TEST_FAIL("pool-zfs"); + DO_TEST_FAIL("pool-zfs-sourcedev"); + DO_TEST_FAIL("pool-rbd"); + DO_TEST_FAIL("pool-vstorage"); + DO_TEST_FAIL("pool-iscsi-direct-auth"); + DO_TEST_FAIL("pool-iscsi-direct"); + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIR_TEST_MAIN(mymain) --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 1543942068384152.08892005143377; Tue, 4 Dec 2018 08:47:48 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02D5430842AA; Tue, 4 Dec 2018 16:47:45 +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 9443F9069; 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 16A184EA3E; 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 wB4GlMsm022396 for ; Tue, 4 Dec 2018 11:47:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 58CEC17AC0; Tue, 4 Dec 2018 16:47:22 +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 155A75DD8A for ; Tue, 4 Dec 2018 16:47:21 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:14 -0500 Message-Id: <20181204164717.5013-6-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 5/8] tests: Add storagepool xml test for netfs-auto 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 04 Dec 2018 16:47:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Cover the case where @netauto would be used to create the command line in virStorageBackendFileSystemMountCmd. Essentially when the pool type is "netfs", but the "source.format" is empty, create the command line properly. Signed-off-by: John Ferlan --- .../pool-netfs-auto.argv | 1 + tests/storagepoolxml2argvtest.c | 1 + .../storagepoolxml2xmlin/pool-netfs-auto.xml | 19 ++++++++++++++++++ .../storagepoolxml2xmlout/pool-netfs-auto.xml | 20 +++++++++++++++++++ tests/storagepoolxml2xmltest.c | 1 + 5 files changed, 42 insertions(+) create mode 100644 tests/storagepoolxml2argvdata/pool-netfs-auto.argv create mode 100644 tests/storagepoolxml2xmlin/pool-netfs-auto.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs-auto.xml diff --git a/tests/storagepoolxml2argvdata/pool-netfs-auto.argv b/tests/sto= ragepoolxml2argvdata/pool-netfs-auto.argv new file mode 100644 index 0000000000..217fcc786b --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-netfs-auto.argv @@ -0,0 +1 @@ +/usr/bin/mount localhost:/var/lib/libvirt/images /mnt diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index 74f8561379..42044e3518 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -145,6 +145,7 @@ mymain(void) DO_TEST_FAIL("pool-iscsi"); DO_TEST_FAIL("pool-iscsi-auth"); DO_TEST("pool-netfs"); + DO_TEST("pool-netfs-auto"); DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST_FAIL("pool-scsi"); diff --git a/tests/storagepoolxml2xmlin/pool-netfs-auto.xml b/tests/storage= poolxml2xmlin/pool-netfs-auto.xml new file mode 100644 index 0000000000..d7f7ce8168 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs-auto.xml @@ -0,0 +1,19 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmlout/pool-netfs-auto.xml b/tests/storag= epoolxml2xmlout/pool-netfs-auto.xml new file mode 100644 index 0000000000..a180ca521c --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs-auto.xml @@ -0,0 +1,20 @@ + + nfsimages + 7641d5a8-af11-f730-a34e-0a7dfcede71f + 0 + 0 + 0 + + + + + + + /mnt + + 0700 + 0 + 0 + + + diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 8230dc8ddc..707d09f5c2 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -82,6 +82,7 @@ mymain(void) DO_TEST("pool-iscsi"); DO_TEST("pool-iscsi-auth"); DO_TEST("pool-netfs"); + DO_TEST("pool-netfs-auto"); DO_TEST("pool-netfs-gluster"); DO_TEST("pool-netfs-cifs"); DO_TEST("pool-scsi"); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 1543942069183288.6391414477757; Tue, 4 Dec 2018 08:47:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15732307D861; Tue, 4 Dec 2018 16:47:44 +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 CD20854183; Tue, 4 Dec 2018 16:47:43 +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 6FF244EA3E; Tue, 4 Dec 2018 16:47:43 +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 wB4GlMVh022404 for ; Tue, 4 Dec 2018 11:47:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id C456E17C1E; Tue, 4 Dec 2018 16:47:22 +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 81A805DD8A for ; Tue, 4 Dec 2018 16:47:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:15 -0500 Message-Id: <20181204164717.5013-7-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 6/8] storage: Rework virStorageBackendFileSystemMountCmd 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 04 Dec 2018 16:47:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's create helpers for each style of command line created. This primarily is easier on the eyes rather than the large multi line if-then-else-else clause used, but may also be useful if in the future any particular pool needs to add to the command line based on pool xml format. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 84 +++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c9f6096687..789f270f2a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4261,6 +4261,56 @@ virStorageBackendFileSystemGetPoolSource(virStorageP= oolObjPtr pool) } =20 =20 +static void +virStorageBackendFileSystemMountNFSArgs(virCommandPtr cmd, + const char *src, + virStoragePoolDefPtr def) +{ + virCommandAddArgList(cmd, src, def->target.path, NULL); +} + + +static void +virStorageBackendFileSystemMountGlusterArgs(virCommandPtr cmd, + const char *src, + virStoragePoolDefPtr def) +{ + const char *fmt; + + fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); + virCommandAddArgList(cmd, "-t", fmt, src, "-o", "direct-io-mode=3D1", + def->target.path, NULL); +} + + +static void +virStorageBackendFileSystemMountCIFSArgs(virCommandPtr cmd, + const char *src, + virStoragePoolDefPtr def) +{ + const char *fmt; + + fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.form= at); + virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, + "-o", "guest", NULL); +} + + +static void +virStorageBackendFileSystemMountDefaultArgs(virCommandPtr cmd, + const char *src, + virStoragePoolDefPtr def) +{ + const char *fmt; + + if (def->type =3D=3D VIR_STORAGE_POOL_FS) + fmt =3D virStoragePoolFormatFileSystemTypeToString(def->source.for= mat); + else + fmt =3D virStoragePoolFormatFileSystemNetTypeToString(def->source.= format); + virCommandAddArgList(cmd, "-t", fmt, src, def->target.path, NULL); +} + + virCommandPtr virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, const char *src) @@ -4276,38 +4326,14 @@ virStorageBackendFileSystemMountCmd(virStoragePoolD= efPtr def, def->source.format =3D=3D VIR_STORAGE_POOL_NETFS_CIFS); virCommandPtr cmd =3D NULL; =20 + cmd =3D virCommandNew(MOUNT); if (netauto) - cmd =3D virCommandNewArgList(MOUNT, - src, - def->target.path, - NULL); + virStorageBackendFileSystemMountNFSArgs(cmd, src, def); else if (glusterfs) - cmd =3D virCommandNewArgList(MOUNT, - "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), - src, - "-o", - "direct-io-mode=3D1", - def->target.path, - NULL); + virStorageBackendFileSystemMountGlusterArgs(cmd, src, def); else if (cifsfs) - cmd =3D virCommandNewArgList(MOUNT, - "-t", - virStoragePoolFormatFileSystemNetTypeTo= String(def->source.format), - src, - def->target.path, - "-o", - "guest", - NULL); + virStorageBackendFileSystemMountCIFSArgs(cmd, src, def); else - cmd =3D virCommandNewArgList(MOUNT, - "-t", - (def->type =3D=3D VIR_STORAGE_POOL_FS ? - virStoragePoolFormatFileSystemTypeToSt= ring(def->source.format) : - virStoragePoolFormatFileSystemNetTypeT= oString(def->source.format)), - src, - def->target.path, - NULL); - + virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); return cmd; } --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 154394207453468.60242610175055; Tue, 4 Dec 2018 08:47:54 -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 C58805277B; Tue, 4 Dec 2018 16:47:51 +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 8782C18BA1; Tue, 4 Dec 2018 16:47:51 +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 3222B18005AF; Tue, 4 Dec 2018 16:47:50 +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 wB4GlNoQ022409 for ; Tue, 4 Dec 2018 11:47:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D15E17D44; Tue, 4 Dec 2018 16:47:23 +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 ED8FE5DD8A for ; Tue, 4 Dec 2018 16:47:22 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:16 -0500 Message-Id: <20181204164717.5013-8-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 7/8] logical: Fix @on argument type 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.29]); Tue, 04 Dec 2018 16:47:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's only pass as 0 or 1 and used as a bool, let's just use a bool Signed-off-by: John Ferlan --- src/storage/storage_backend_logical.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index cad88756cb..44cff61af7 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -48,7 +48,7 @@ VIR_LOG_INIT("storage.storage_backend_logical"); =20 static int virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, - int on) + bool on) { int ret; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -731,7 +731,7 @@ virStorageBackendLogicalStartPool(virStoragePoolObjPtr = pool) * that the pool's source devices match the pvs output. */ if (!virStorageBackendLogicalMatchPoolSource(pool) || - virStorageBackendLogicalSetActive(pool, 1) < 0) + virStorageBackendLogicalSetActive(pool, true) < 0) return -1; =20 return 0; @@ -858,7 +858,7 @@ virStorageBackendLogicalRefreshPool(virStoragePoolObjPt= r pool) static int virStorageBackendLogicalStopPool(virStoragePoolObjPtr pool) { - if (virStorageBackendLogicalSetActive(pool, 0) < 0) + if (virStorageBackendLogicalSetActive(pool, false) < 0) return -1; =20 return 0; --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 06:01:40 2024 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 1543942077462198.54555115845062; Tue, 4 Dec 2018 08:47:57 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6505A2D80D; Tue, 4 Dec 2018 16:47:55 +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 237745C25D; Tue, 4 Dec 2018 16:47:55 +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 B6B774EA44; Tue, 4 Dec 2018 16:47:54 +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 wB4GlNVL022414 for ; Tue, 4 Dec 2018 11:47:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id A5C5417AC0; Tue, 4 Dec 2018 16:47:23 +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 63DB35DD8A for ; Tue, 4 Dec 2018 16:47:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 4 Dec 2018 11:47:17 -0500 Message-Id: <20181204164717.5013-9-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 8/8] storage: Add tests for logical backend startup 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 04 Dec 2018 16:47:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the logical storage pool startup validation (xml2argv) tests. Signed-off-by: John Ferlan --- src/storage/storage_backend_logical.c | 6 +----- src/storage/storage_util.c | 11 +++++++++++ src/storage/storage_util.h | 4 ++++ .../pool-logical-create.argv | 1 + .../pool-logical-noname.argv | 1 + .../pool-logical-nopath.argv | 1 + tests/storagepoolxml2argvdata/pool-logical.argv | 1 + tests/storagepoolxml2argvtest.c | 13 ++++++++----- 8 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 tests/storagepoolxml2argvdata/pool-logical-create.argv create mode 100644 tests/storagepoolxml2argvdata/pool-logical-noname.argv create mode 100644 tests/storagepoolxml2argvdata/pool-logical-nopath.argv create mode 100644 tests/storagepoolxml2argvdata/pool-logical.argv diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 44cff61af7..12fff651e8 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -52,11 +52,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr p= ool, { int ret; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); - virCommandPtr cmd =3D - virCommandNewArgList(VGCHANGE, - on ? "-aly" : "-aln", - def->source.name, - NULL); + virCommandPtr cmd =3D virStorageBackendLogicalChangeCmd(def, on); =20 ret =3D virCommandRun(cmd, NULL); virCommandFree(cmd); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 789f270f2a..01f3c93008 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -4337,3 +4337,14 @@ virStorageBackendFileSystemMountCmd(virStoragePoolDe= fPtr def, virStorageBackendFileSystemMountDefaultArgs(cmd, src, def); return cmd; } + + +virCommandPtr +virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def, + bool on) +{ + return virCommandNewArgList(VGCHANGE, + on ? "-aly" : "-aln", + def->source.name, + NULL); +} diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 28b3e0b9c9..a2ef2ac07d 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -184,4 +184,8 @@ virCommandPtr virStorageBackendFileSystemMountCmd(virStoragePoolDefPtr def, const char *src); =20 +virCommandPtr +virStorageBackendLogicalChangeCmd(virStoragePoolDefPtr def, + bool on); + #endif /* __VIR_STORAGE_UTIL_H__ */ diff --git a/tests/storagepoolxml2argvdata/pool-logical-create.argv b/tests= /storagepoolxml2argvdata/pool-logical-create.argv new file mode 100644 index 0000000000..203da86e48 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-logical-create.argv @@ -0,0 +1 @@ +/usr/sbin/vgchange -aly HostVG diff --git a/tests/storagepoolxml2argvdata/pool-logical-noname.argv b/tests= /storagepoolxml2argvdata/pool-logical-noname.argv new file mode 100644 index 0000000000..0813467120 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-logical-noname.argv @@ -0,0 +1 @@ +/usr/sbin/vgchange -aly zily diff --git a/tests/storagepoolxml2argvdata/pool-logical-nopath.argv b/tests= /storagepoolxml2argvdata/pool-logical-nopath.argv new file mode 100644 index 0000000000..203da86e48 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-logical-nopath.argv @@ -0,0 +1 @@ +/usr/sbin/vgchange -aly HostVG diff --git a/tests/storagepoolxml2argvdata/pool-logical.argv b/tests/storag= epoolxml2argvdata/pool-logical.argv new file mode 100644 index 0000000000..203da86e48 --- /dev/null +++ b/tests/storagepoolxml2argvdata/pool-logical.argv @@ -0,0 +1 @@ +/usr/sbin/vgchange -aly HostVG diff --git a/tests/storagepoolxml2argvtest.c b/tests/storagepoolxml2argvtes= t.c index 42044e3518..26b12c8fc3 100644 --- a/tests/storagepoolxml2argvtest.c +++ b/tests/storagepoolxml2argvtest.c @@ -43,8 +43,11 @@ testCompareXMLToArgvFiles(bool shouldFail, cmd =3D virStorageBackendFileSystemMountCmd(def, src); break; =20 - case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_LOGICAL: + cmd =3D virStorageBackendLogicalChangeCmd(def, true); + break; + + case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_DISK: case VIR_STORAGE_POOL_ISCSI: case VIR_STORAGE_POOL_ISCSI_DIRECT: @@ -136,10 +139,10 @@ mymain(void) DO_TEST_FAIL("pool-dir"); DO_TEST_FAIL("pool-dir-naming"); DO_TEST("pool-fs"); - DO_TEST_FAIL("pool-logical"); - DO_TEST_FAIL("pool-logical-nopath"); - DO_TEST_FAIL("pool-logical-create"); - DO_TEST_FAIL("pool-logical-noname"); + DO_TEST("pool-logical"); + DO_TEST("pool-logical-nopath"); + DO_TEST("pool-logical-create"); + DO_TEST("pool-logical-noname"); DO_TEST_FAIL("pool-disk"); DO_TEST_FAIL("pool-disk-device-nopartsep"); DO_TEST_FAIL("pool-iscsi"); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list