From nobody Sun Feb 8 14:12:37 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 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