From nobody Tue Apr 23 12:23:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1592495417; cv=none; d=zohomail.com; s=zohoarc; b=lSorxZeZkfimAT810Ls+geCQNBGVte8VN0/0kVtulOjKQqcx6yZMyqBZE+1pUpVHiPJUUjDBa/9Ch8+D6/pUJA91LVZSntJ28axIa4PbPqJSJSthM4QYStedeWdkbnP2gCq08Z8w3vPy7nsi8EBiPCZTPaEaZczsIHtDNaY3Y+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592495417; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7iPpDKxcYxFLSRjLF6UsH6vWrCt0OMiOnEtIrVt0TOM=; b=eMvNhKJHsbMCmV87gRm/TLFrW23S4BSXpq9hkY+xya6IshQxL29MaiDmc7bD8ZhGFC2fc2aZ9AlAADjhQuHBhOYHF/uDtVLOX8ulBVDLsTAbSRdySdEFBFxoz3HHm80v1uig45IJBbH32/j+WRC1kvAzv9OY7/mMqDxnEQYwKmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1592495417467258.54156481656673; Thu, 18 Jun 2020 08:50:17 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-2t-qcuDkPQuE8DQuHxkrsQ-1; Thu, 18 Jun 2020 11:50:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9203107ACF5; Thu, 18 Jun 2020 15:50:05 +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 9DDF65BAC1; Thu, 18 Jun 2020 15:50:05 +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 110DC180954D; Thu, 18 Jun 2020 15:50:05 +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 05IFnmKp025309 for ; Thu, 18 Jun 2020 11:49:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AC305D9E8; Thu, 18 Jun 2020 15:49:48 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (mustard.gsslab.fab.redhat.com [10.33.8.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D2C95D9D3; Thu, 18 Jun 2020 15:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592495416; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=7iPpDKxcYxFLSRjLF6UsH6vWrCt0OMiOnEtIrVt0TOM=; b=g8lhv2G/msFf/IHDDQlNdVmGX9lXz8wv0SDzR8gYjnvLFrvZyNNrDxUsUFEfZgOuiVII6C 8noOu3URrrZJU3Py3o4GjpEgDh+8Chc4MloRz8YuNvKNvc1oengSd0KO6Kp2/qLnqQ6woC YBHWnAIFi2aOmJ13MFK+XQVVMNTEQQw= X-MC-Unique: 2t-qcuDkPQuE8DQuHxkrsQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] src: remove redundant arg to virKModLoad Date: Thu, 18 Jun 2020 16:42:45 +0100 Message-Id: <20200618154246.2093672-2-berrange@redhat.com> In-Reply-To: <20200618154246.2093672-1-berrange@redhat.com> References: <20200618154246.2093672-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) All callers except for the test suite pass the same value for the second arg, so it can be removed, simplifying the code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/util/virfile.c | 2 +- src/util/virkmod.c | 8 +++----- src/util/virkmod.h | 2 +- src/util/virpci.c | 2 +- tests/virkmodtest.c | 44 +++++++++++--------------------------------- 5 files changed, 17 insertions(+), 41 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 20260a2e58..7b92c8767c 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -905,7 +905,7 @@ virFileNBDLoadDriver(void) } else { g_autofree char *errbuf =3D NULL; =20 - if ((errbuf =3D virKModLoad(NBD_DRIVER, true))) { + if ((errbuf =3D virKModLoad(NBD_DRIVER))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to load nbd module")); return false; diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 12cb5920e8..59cec69816 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -31,8 +31,7 @@ doModprobe(const char *opts, const char *module, char **o= utbuf, char **errbuf) g_autoptr(virCommand) cmd =3D NULL; =20 cmd =3D virCommandNew(MODPROBE); - if (opts) - virCommandAddArg(cmd, opts); + virCommandAddArg(cmd, opts); if (module) virCommandAddArg(cmd, module); if (outbuf) @@ -83,7 +82,6 @@ virKModConfig(void) /** * virKModLoad: * @module: Name of the module to load - * @useBlacklist: True if honoring blacklist * * Attempts to load a kernel module * @@ -92,11 +90,11 @@ virKModConfig(void) * by the caller */ char * -virKModLoad(const char *module, bool useBlacklist) +virKModLoad(const char *module) { char *errbuf =3D NULL; =20 - if (doModprobe(useBlacklist ? "-b" : NULL, module, NULL, &errbuf) < 0) + if (doModprobe("-b", module, NULL, &errbuf) < 0) return errbuf; =20 VIR_FREE(errbuf); diff --git a/src/util/virkmod.h b/src/util/virkmod.h index f05cf83cf6..605da74416 100644 --- a/src/util/virkmod.h +++ b/src/util/virkmod.h @@ -24,7 +24,7 @@ #include "internal.h" =20 char *virKModConfig(void); -char *virKModLoad(const char *, bool) +char *virKModLoad(const char *) ATTRIBUTE_NONNULL(1); char *virKModUnload(const char *) ATTRIBUTE_NONNULL(1); diff --git a/src/util/virpci.c b/src/util/virpci.c index 786b1393e6..24de69c75e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1013,7 +1013,7 @@ virPCIProbeStubDriver(virPCIStubDriver driver) if (!probed) { g_autofree char *errbuf =3D NULL; probed =3D true; - if ((errbuf =3D virKModLoad(drvname, true))) { + if ((errbuf =3D virKModLoad(drvname))) { VIR_WARN("failed to load driver %s: %s", drvname, errbuf); goto cleanup; } diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index e013f8f3b6..2906ad992e 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -27,11 +27,7 @@ # include "virkmod.h" # include "virstring.h" =20 -struct testInfo { - const char *module; - const char *exp_cmd; - bool useBlacklist; -}; +# define MODNAME "vfio-pci" =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -87,24 +83,21 @@ checkOutput(virBufferPtr buf, const char *exp_cmd) =20 =20 static int -testKModLoad(const void *args) +testKModLoad(const void *args G_GNUC_UNUSED) { int ret =3D -1; char *errbuf =3D NULL; - const struct testInfo *info =3D args; - const char *module =3D info->module; - bool useBlacklist =3D info->useBlacklist; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virCommandSetDryRun(&buf, NULL, NULL); =20 - errbuf =3D virKModLoad(module, useBlacklist); + errbuf =3D virKModLoad(MODNAME); if (errbuf) { fprintf(stderr, "Failed to load, error: %s\n", errbuf); goto cleanup; } =20 - if (checkOutput(&buf, info->exp_cmd) < 0) + if (checkOutput(&buf, MODPROBE " -b " MODNAME "\n") < 0) goto cleanup; =20 ret =3D 0; @@ -117,23 +110,21 @@ testKModLoad(const void *args) =20 =20 static int -testKModUnload(const void *args) +testKModUnload(const void *args G_GNUC_UNUSED) { int ret =3D -1; char *errbuf =3D NULL; - const struct testInfo *info =3D args; - const char *module =3D info->module; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virCommandSetDryRun(&buf, NULL, NULL); =20 - errbuf =3D virKModUnload(module); + errbuf =3D virKModUnload(MODNAME); if (errbuf) { fprintf(stderr, "Failed to unload, error: %s\n", errbuf); goto cleanup; } =20 - if (checkOutput(&buf, info->exp_cmd) < 0) + if (checkOutput(&buf, RMMOD " " MODNAME "\n") < 0) goto cleanup; =20 ret =3D 0; @@ -152,23 +143,10 @@ mymain(void) =20 if (virTestRun("config", testKModConfig, NULL) < 0) ret =3D -1; - - /* Although we cannot run the command on the host, we can compare - * the output of the created command against what we'd expect to be - * created. So let's at least do that. - */ -# define DO_TEST(_name, _cb, _blkflag, _exp_cmd) \ - do { \ - struct testInfo data =3D {.module =3D "vfio-pci", \ - .exp_cmd =3D _exp_cmd, \ - .useBlacklist =3D _blkflag}; \ - if (virTestRun(_name, _cb, &data) < 0) \ - ret =3D -1; \ - } while (0) - - DO_TEST("load", testKModLoad, false, MODPROBE " vfio-pci\n"); - DO_TEST("unload", testKModUnload, false, RMMOD " vfio-pci\n"); - DO_TEST("blklist", testKModLoad, true, MODPROBE " -b vfio-pci\n"); + if (virTestRun("load", testKModLoad, NULL) < 0) + ret =3D -1; + if (virTestRun("unload", testKModUnload, NULL) < 0) + ret =3D -1; =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; =20 --=20 2.24.1 From nobody Tue Apr 23 12:23:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1592495464; cv=none; d=zohomail.com; s=zohoarc; b=VEKskepJRXMqFNLLtq2GdK18bQ23XeeyFqkmmyMnArI7F0qrnz/ztXtqCSReo/Nb/C3/T6TIb/ECfhqZbZBkDP6G+ogzr9US/aY6lJFUzOAbFgnKm8+pBi+Gr2t/oIUVsjKxwQ+Dzwx43hLQHc68VE4t+v3QsHMCAG2QSqE2BS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592495464; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jH1RCj+JSHUMb1fRQiGaHfuR0ZNj2qnLRLLjoilW7Ug=; b=kJhnpkXkArhNKvyaifSvfRELguGmMigbHQIYNyTZP5LyxKYwHZIUDRTF/18tSq5eF7RdqqMAZcx/716CVeZt0PPj5uvo4qWZHfgrTVX+cTO1cwB8x810+TnyOsDd0hNMu5pAB8n2zEQUK0xLxOsrW2s+QoDJd7InLbJP9DUEdYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 159249546471162.10065489219858; Thu, 18 Jun 2020 08:51:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-tDalmDdxNQKGEgaxLuuZ0A-1; Thu, 18 Jun 2020 11:50:14 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C056100A8EE; Thu, 18 Jun 2020 15:50:09 +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 3D40B7166A; Thu, 18 Jun 2020 15:50:09 +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 0E129833C9; Thu, 18 Jun 2020 15:50:09 +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 05IFnpkT025323 for ; Thu, 18 Jun 2020 11:49:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 26F135D9E5; Thu, 18 Jun 2020 15:49:51 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (mustard.gsslab.fab.redhat.com [10.33.8.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8914C5D9E8; Thu, 18 Jun 2020 15:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592495463; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jH1RCj+JSHUMb1fRQiGaHfuR0ZNj2qnLRLLjoilW7Ug=; b=ZeSJkV/mdoCSFEoMqIXQLo4B/syMbAwq9ngl2/1pQydGuOt+U1HG7lc47IbbgIg0ia47BM zScHFQLQFZNs2POdDrBXi80jEKuiCV+JCUzNAuugGQ9CyIJIQXzs2ScKFWDP3QfQhUFul0 G64vX0S/5fUmwAtycT6GO/JrurmA5XQ= X-MC-Unique: tDalmDdxNQKGEgaxLuuZ0A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] util: remove unused virKModConfig method Date: Thu, 18 Jun 2020 16:42:46 +0100 Message-Id: <20200618154246.2093672-3-berrange@redhat.com> In-Reply-To: <20200618154246.2093672-1-berrange@redhat.com> References: <20200618154246.2093672-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Using virKModConfig would not simplify any existing code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/virkmod.c | 19 ------------------- src/util/virkmod.h | 1 - tests/virkmodtest.c | 29 ----------------------------- 4 files changed, 50 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7509916dfd..691b5bc5bc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2402,7 +2402,6 @@ virKeycodeValueTranslate; =20 =20 # util/virkmod.h -virKModConfig; virKModIsBlacklisted; virKModLoad; virKModUnload; diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 59cec69816..4400245906 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -59,25 +59,6 @@ doRmmod(const char *module, char **errbuf) return 0; } =20 -/** - * virKModConfig: - * - * Get the current kernel module configuration - * - * Returns NULL on failure or a pointer to the output which - * must be VIR_FREE()'d by the caller - */ -char * -virKModConfig(void) -{ - char *outbuf =3D NULL; - - if (doModprobe("-c", NULL, &outbuf, NULL) < 0) - return NULL; - - return outbuf; -} - =20 /** * virKModLoad: diff --git a/src/util/virkmod.h b/src/util/virkmod.h index 605da74416..3bb161df52 100644 --- a/src/util/virkmod.h +++ b/src/util/virkmod.h @@ -23,7 +23,6 @@ =20 #include "internal.h" =20 -char *virKModConfig(void); char *virKModLoad(const char *) ATTRIBUTE_NONNULL(1); char *virKModUnload(const char *) diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 2906ad992e..3ba8c542d1 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -31,33 +31,6 @@ =20 # define VIR_FROM_THIS VIR_FROM_NONE =20 -static int -testKModConfig(const void *args G_GNUC_UNUSED) -{ - int ret =3D -1; - char *outbuf =3D NULL; - - /* This will return the contents of a 'modprobe -c' which can differ - * from machine to machine - be happy that we get something. - */ - outbuf =3D virKModConfig(); - if (!outbuf) { - if (virFileIsExecutable(MODPROBE)) { - fprintf(stderr, "Failed to get config\n"); - } else { - /* modprobe doesn't exist, do not claim error. */ - ret =3D 0; - } - goto cleanup; - } - ret =3D 0; - - cleanup: - VIR_FREE(outbuf); - return ret; -} - - static int checkOutput(virBufferPtr buf, const char *exp_cmd) { @@ -141,8 +114,6 @@ mymain(void) { int ret =3D 0; =20 - if (virTestRun("config", testKModConfig, NULL) < 0) - ret =3D -1; if (virTestRun("load", testKModLoad, NULL) < 0) ret =3D -1; if (virTestRun("unload", testKModUnload, NULL) < 0) --=20 2.24.1