From nobody Tue Sep 9 09:48:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1745925541; cv=none; d=zohomail.com; s=zohoarc; b=jQ+mL01PCx70lo+o0qc3B5CPasJn5toxF/wT4A1mtwmGSjWqgnFE+Iym7QzxaBkRdz+MXFr4zL64kTno68d02ENYWUEcEX9WveMKwzfxib6Pz1IpDUFVdeZ+VJoq4xfkPZZ4VBBrxYVjj+JQSgbHiz7P6UExaXgwSpXKep1ZwKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745925541; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=8ajpaKBlpBqd5kVjUJfqt2eOsub8V0up/BH0pTl0lME=; b=Ut/ehLDx6L07lHWHKVRMsMjiYP1oawaER+N7NrChej+AfMePOnL1B06OR/8/wgBwwKkL5Y4rbvHjXJYUyC0qN3ckeUUPCNj9ze7zCNRYnfWrY+pBdgBKIW3q2qWDjiYwJ8CU7e36IaOvx5xReDsSQ6tc3H6HJfkwut/5nerPKLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1745925541043362.43736032081847; Tue, 29 Apr 2025 04:19:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2078D13F2; Tue, 29 Apr 2025 07:19:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AFB79144C; Tue, 29 Apr 2025 07:15:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 12D1F138D; Tue, 29 Apr 2025 07:14:56 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4CB6B1402 for ; Tue, 29 Apr 2025 07:14:38 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-38-AStapXj1OTWFgl3M2GNg4Q-1; Tue, 29 Apr 2025 07:14:36 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 684E41800984 for ; Tue, 29 Apr 2025 11:14:35 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.98]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8B3DA195608D; Tue, 29 Apr 2025 11:14:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745925278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FmGAP0BxQDbEj214oO4lkbCKXD/EsK+1LohjdJ7JbCs=; b=LLqrZIJiLnr44v/bTNwXRxYserojODqThrtx7eZ5PdVPcDf9mYIjb4fLN1FAT2CXY5aZ6n vtetEYLkqcUnJWqZ2YX6Xs1gIDoz44KHfeCQjdvOna2B2J09WRA8h7AsCltCucazEqADSL yOyzVL8KBuTx3+qWMTw/37nXXU87YM0= X-MC-Unique: AStapXj1OTWFgl3M2GNg4Q-1 X-Mimecast-MFC-AGG-ID: AStapXj1OTWFgl3M2GNg4Q_1745925275 To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH 11/20] util: remove hardcoded ISCSIADM command path Date: Tue, 29 Apr 2025 12:14:11 +0100 Message-ID: <20250429111420.1748521-12-berrange@redhat.com> In-Reply-To: <20250429111420.1748521-1-berrange@redhat.com> References: <20250429111420.1748521-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Id-NFwXJssfCYIneUvdZueMMRcAJ6Hp0xE-5_IzLkXk_1745925275 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JO7WCU5T2FEYPM2YGWN5WBJEJ6DJVNS3 X-Message-ID-Hash: JO7WCU5T2FEYPM2YGWN5WBJEJ6DJVNS3 X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9_via_Devel?= Reply-To: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1745925542451019100 Content-Type: text/plain; charset="utf-8" From: Daniel P. Berrang=C3=A9 Allow virCommand to find 'dmidecode' in $PATH. This command is only usable when running privileged since it relies on reading from a privileged kernel file. Thus we can assume both 'bin' and 'sbin' dirs will be in $PATH and virFindFileInPath will do the right thing to find it when called by virCommand. Gating the iscsi driver backend on a isciadm probe is likely to do more harm than good as it needlessly disables the code if the dev forgot to install iscsiadm at build time. As a Linux only command it is simpler to gate the feature based on the platform choice and allow missing binaries to be diagnose at runtime. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- meson.build | 5 ++-- src/util/viriscsi.c | 55 ++++++++++++++++++++++---------------------- tests/viriscsitest.c | 16 ++++++------- 3 files changed, 37 insertions(+), 39 deletions(-) diff --git a/meson.build b/meson.build index d355767a53..9759a3322b 100644 --- a/meson.build +++ b/meson.build @@ -854,7 +854,6 @@ optional_test_programs =3D [ ] =20 optional_programs =3D [ - 'iscsiadm', 'mdevctl', 'mm-ctl', 'modprobe', @@ -1825,11 +1824,11 @@ if conf.has('WITH_LIBVIRTD') error('Need glusterfs (libgfapi) for gluster storage driver') endif =20 - if not get_option('storage_iscsi').disabled() and iscsiadm_prog.found() + if not get_option('storage_iscsi').disabled() and host_machine.system() = =3D=3D 'linux' use_storage =3D true conf.set('WITH_STORAGE_ISCSI', 1) elif get_option('storage_iscsi').enabled() - error('We need iscsiadm for iSCSI storage driver') + error('Linux host needed for iSCSI storage driver using iscsiadm') endif =20 if not get_option('storage_iscsi_direct').disabled() and libiscsi_dep.fo= und() diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index a70c87cbdb..f6b2cdba0c 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -88,8 +88,8 @@ virISCSIGetSession(const char *devpath, int exitstatus =3D 0; g_autofree char *error =3D NULL; =20 - g_autoptr(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, "--mode", - "session", NULL); + g_autoptr(virCommand) cmd =3D virCommandNewArgList("iscsiadm", "--mode= ", + "session", NULL); virCommandSetErrorBuffer(cmd, &error); =20 if (virCommandRunRegex(cmd, @@ -123,8 +123,8 @@ virStorageBackendIQNFound(const char *initiatoriqn, g_autofree char *outbuf =3D NULL; g_autofree char *iface =3D NULL; g_autofree char *iqn =3D NULL; - g_autoptr(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "iface", = NULL); + g_autoptr(virCommand) cmd =3D virCommandNewArgList("iscsiadm", + "--mode", "iface", NU= LL); =20 *ifacename =3D NULL; =20 @@ -193,8 +193,8 @@ virStorageBackendIQNFound(const char *initiatoriqn, =20 error: virReportError(VIR_ERR_INTERNAL_ERROR, - _("malformed output of %1$s: %2$s"), - ISCSIADM, line); + _("malformed output of 'iscsiadm': %1$s"), + line); goto cleanup; } =20 @@ -215,7 +215,7 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriq= n, VIR_DEBUG("Attempting to create interface '%s' with IQN '%s'", temp_ifacename, initiatoriqn); =20 - newcmd =3D virCommandNewArgList(ISCSIADM, + newcmd =3D virCommandNewArgList("iscsiadm", "--mode", "iface", "--interface", temp_ifacename, "--op", "new", @@ -225,13 +225,12 @@ virStorageBackendCreateIfaceIQN(const char *initiator= iqn, * We will just rely on whether the interface got created * properly. */ if (virCommandRun(newcmd, &exitstatus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to run command '%1$s' to create new iscsi= interface"), - ISCSIADM); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to run command 'iscsiadm' to create new i= scsi interface")); return -1; } =20 - updatecmd =3D virCommandNewArgList(ISCSIADM, + updatecmd =3D virCommandNewArgList("iscsiadm", "--mode", "iface", "--interface", temp_ifacename, "--op", "update", @@ -244,8 +243,8 @@ virStorageBackendCreateIfaceIQN(const char *initiatoriq= n, * rely on whether iface file got updated properly. */ if (virCommandRun(updatecmd, &exitstatus) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to run command '%1$s' to update iscsi int= erface with IQN '%2$s'"), - ISCSIADM, initiatoriqn); + _("Failed to run command 'iscsiadm' to update iscsi= interface with IQN '%1$s'"), + initiatoriqn); return -1; } =20 @@ -273,7 +272,7 @@ virISCSIConnection(const char *portal, const char **extraargv) { const char *const baseargv[] =3D { - ISCSIADM, + "iscsiadm", "--mode", "node", "--portal", portal, "--targetname", target, @@ -343,11 +342,11 @@ virISCSIConnectionLogout(const char *portal, int virISCSIRescanLUNs(const char *session) { - g_autoptr(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "session", - "-r", session, - "-R", - NULL); + g_autoptr(virCommand) cmd =3D virCommandNewArgList("iscsiadm", + "--mode", "session", + "-r", session, + "-R", + NULL); return virCommandRun(cmd, NULL); } =20 @@ -396,11 +395,11 @@ virISCSIScanTargetsInternal(const char *portal, int vars[] =3D { 2 }; struct virISCSITargetList list =3D { 0 }; size_t i; - g_autoptr(virCommand) cmd =3D virCommandNewArgList(ISCSIADM, - "--mode", "discover= y", - "--type", "sendtarg= ets", - "--portal", portal, - NULL); + g_autoptr(virCommand) cmd =3D virCommandNewArgList("iscsiadm", + "--mode", "discovery", + "--type", "sendtarget= s", + "--portal", portal, + NULL); =20 if (!persist) { virCommandAddArgList(cmd, @@ -512,7 +511,7 @@ virISCSINodeNew(const char *portal, g_autoptr(virCommand) cmd =3D NULL; int status; =20 - cmd =3D virCommandNewArgList(ISCSIADM, + cmd =3D virCommandNewArgList("iscsiadm", "--mode", "node", "--portal", portal, "--targetname", target, @@ -528,8 +527,8 @@ virISCSINodeNew(const char *portal, =20 if (status !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("%1$s failed new mode for target '%2$s' with stat= us '%3$d'"), - ISCSIADM, target, status); + _("'iscsiadm': failed new mode for target '%1$s' wi= th status '%2$d'"), + target, status); return -1; } =20 @@ -546,7 +545,7 @@ virISCSINodeUpdate(const char *portal, g_autoptr(virCommand) cmd =3D NULL; int status; =20 - cmd =3D virCommandNewArgList(ISCSIADM, + cmd =3D virCommandNewArgList("iscsiadm", "--mode", "node", "--portal", portal, "--target", target, diff --git a/tests/viriscsitest.c b/tests/viriscsitest.c index f2539e47b0..ee29b6f259 100644 --- a/tests/viriscsitest.c +++ b/tests/viriscsitest.c @@ -82,7 +82,7 @@ static void testIscsiadmCb(const char *const*args, { struct testIscsiadmCbData *data =3D opaque; =20 - if (args[0] && STREQ(args[0], ISCSIADM) && + if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "session") && args[3] =3D=3D NULL) { @@ -90,7 +90,7 @@ static void testIscsiadmCb(const char *const*args, *output =3D g_strdup(iscsiadmSessionOutputNonFlash); else *output =3D g_strdup(iscsiadmSessionOutput); - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "discovery") && args[3] && STREQ(args[3], "--type") && @@ -101,7 +101,7 @@ static void testIscsiadmCb(const char *const*args, args[8] && STREQ(args[8], "nonpersistent") && args[9] =3D=3D NULL) { *output =3D g_strdup(iscsiadmSendtargetsOutput); - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "node") && args[3] && STREQ(args[3], "--portal") && @@ -120,7 +120,7 @@ static void testIscsiadmCb(const char *const*args, * target: iqn.2004-06.example:example1:iscsi.test, \ * portal: 10.20.30.40:3260,1] successful. */ - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "iface") && args[3] =3D=3D NULL) { @@ -128,7 +128,7 @@ static void testIscsiadmCb(const char *const*args, *output =3D g_strdup(iscsiadmIfaceIfaceOutput); else *output =3D g_strdup(iscsiadmIfaceDefaultOutput); - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "iface") && args[3] && STREQ(args[3], "--interface") && @@ -142,7 +142,7 @@ static void testIscsiadmCb(const char *const*args, * New interface libvirt-iface-03020100 added */ data->iface_created =3D true; - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "iface") && args[3] && STREQ(args[3], "--interface") && @@ -160,7 +160,7 @@ static void testIscsiadmCb(const char *const*args, * * libvirt-iface-03020100 updated. */ - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "discovery") && args[3] && STREQ(args[3], "--type") && @@ -172,7 +172,7 @@ static void testIscsiadmCb(const char *const*args, args[9] =3D=3D NULL && data->iface_created) { *output =3D g_strdup(iscsiadmSendtargetsOutput); - } else if (args[0] && STREQ(args[0], ISCSIADM) && + } else if (args[0] && STREQ(args[0], "iscsiadm") && args[1] && STREQ(args[1], "--mode") && args[2] && STREQ(args[2], "node") && args[3] && STREQ(args[3], "--portal") && --=20 2.49.0