From nobody Mon Feb 9 16:45:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1618346466; cv=none; d=zohomail.com; s=zohoarc; b=iZRQy0zAgS4Xladw2S7LvPtbgJcXtOTrfXoWaQfkmX6FqlTQsj+nb9czsHBDEQwk26ZnGM79JeSUwdiAHTc0xn+kcVHhnWjPZNZXEFk8L8re13yrxCsY/ttTTRvs+iBKLUOB97cE0nT0viHPNeUbDL73hbNeAVQdNHnqiw9sRuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346466; 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=Pg+EpvC6u9vY5HPj0LaXXkyUgTidUJzxNPMHlaqcAa4=; b=Exs8gS2OTTuAS5VSxSJFZFLqSno59oC1B2z3jPgk7S0OE9MmL8CgPnzai8hE1mNH6RJbpXYBWIFebMyJ6ghKY8gGxzCVA1O3rKPHoBcNG0+4+CtGtWmTFOWxc9XGSTQkLL7wQHYQ7N0RWsK/nVwccIE6x1eJ6VgV3BXs/opa5nA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1618346466842459.630676950037; Tue, 13 Apr 2021 13:41:06 -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-588-RgYjmQsMP7KxNktQkO4oUg-1; Tue, 13 Apr 2021 16:40:24 -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 D68C7802B7E; Tue, 13 Apr 2021 20:40:17 +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 B728E5B6AD; Tue, 13 Apr 2021 20:40:17 +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 7D3A91806D1A; Tue, 13 Apr 2021 20:40:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13DKdte5011716 for ; Tue, 13 Apr 2021 16:39:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id C66CA19744; Tue, 13 Apr 2021 20:39:55 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 976211972B for ; Tue, 13 Apr 2021 20:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346465; 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=Pg+EpvC6u9vY5HPj0LaXXkyUgTidUJzxNPMHlaqcAa4=; b=DsBymBWd7YBUAQxKLzoKm78hS28qkixGonCYatapfI+NxxuqreKThVhPztIwYf1DWko8T8 YlyCDtkxnk5525jULdaTyZQ9qbcKzQRm254yZ7+zgZ1BZTDVfIZtmtXhditiUIZ/iMxawg PELlhLyjZiuNEDENfN1tMAtGfYJR01w= X-MC-Unique: RgYjmQsMP7KxNktQkO4oUg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/12] nodedev: Remove GetMdevctl*Command() wrappers Date: Tue, 13 Apr 2021 15:39:44 -0500 Message-Id: <20210413203948.71864-9-jjongsma@redhat.com> In-Reply-To: <20210413203948.71864-1-jjongsma@redhat.com> References: <20210413203948.71864-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These per-command generator functions were only exposed in the header to allow the commandline generation to be tested. Now that we have a generic mdevctl command generator, we can get rid of the per-command wrappers and reduce the noise in the header. Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 56 ++++++---------------------- src/node_device/node_device_driver.h | 24 ++---------- tests/nodedevmdevctltest.c | 41 ++++---------------- 3 files changed, 23 insertions(+), 98 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index bbb01c3967..b8e68d3b27 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -702,7 +702,7 @@ nodeDeviceFindAddressByName(const char *name) } =20 =20 -static virCommand * +virCommand * nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, virMdevctlCommand cmd_type, char **outbuf, @@ -775,30 +775,15 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, return cmd; } =20 -virCommand* -nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_CREATE, uuid_out, = errmsg); -} - -virCommand* -nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_DEFINE, uuid_out, = errmsg); -} - - =20 static int virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg) { int status; - g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlCreateCommand(def, u= uid, - errmsg); + g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlCommand(def, + MDEVCTL_CMD_CR= EATE, + uuid, + errmsg); if (!cmd) return -1; =20 @@ -818,7 +803,9 @@ static int virMdevctlDefine(virNodeDeviceDef *def, char **uuid, char **errmsg) { int status; - g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlDefineCommand(def, u= uid, errmsg); + g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlCommand(def, + MDEVCTL_CMD_DE= FINE, + uuid, errmsg); =20 if (!cmd) return -1; @@ -921,34 +908,13 @@ nodeDeviceCreateXML(virConnectPtr conn, } =20 =20 -virCommand * -nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg= ); -} - -virCommand * -nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, er= rmsg); -} - -virCommand * -nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errms= g); -} - static int virMdevctlStop(virNodeDeviceDef *def, char **errmsg) { int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlStopCommand(def, errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errms= g); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; @@ -963,7 +929,7 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errmsg) int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlUndefineCommand(def, errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, e= rrmsg); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; @@ -978,7 +944,7 @@ virMdevctlStart(virNodeDeviceDef *def, char **errmsg) int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlStartCommand(def, errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errm= sg); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 105a71dd93..edd763f0e4 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -142,22 +142,10 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr= conn, int callbackID); =20 virCommand * -nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg); - -virCommand* -nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg); - -virCommand * -nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def, - char **errmsg); - -virCommand * -nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def, - char **errmsg); +nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, + virMdevctlCommand cmd_type, + char **outbuf, + char **errbuf); =20 virCommand * nodeDeviceGetMdevctlListCommand(bool defined, @@ -180,10 +168,6 @@ nodeDeviceGenerateName(virNodeDeviceDef *def, bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst, virNodeDeviceDef *src); =20 -virCommand* -nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, - char **errmsg); - int nodeDeviceCreate(virNodeDevice *dev, unsigned int flags); diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 188bad6e53..64ce7fec46 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -38,7 +38,7 @@ typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *,= char **, char **); static int testMdevctlCreateOrDefine(const char *virt_type, int create, - MdevctlCmdFunc mdevctl_cmd_func, + virMdevctlCommand cmd_type, const char *mdevxml, const char *cmdfile, const char *jsonfile) @@ -59,7 +59,7 @@ testMdevctlCreateOrDefine(const char *virt_type, =20 /* this function will set a stdin buffer containing the json configura= tion * of the device. The json value is captured in the callback above */ - cmd =3D mdevctl_cmd_func(def, &uuid, &errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, cmd_type, &uuid, &errmsg); =20 if (!cmd) goto cleanup; @@ -88,22 +88,11 @@ static int testMdevctlCreateOrDefineHelper(const void *data) { const struct startTestInfo *info =3D data; - const char *cmd; - MdevctlCmdFunc func; + const char *cmd =3D virMdevctlCommandTypeToString(info->command); g_autofree char *mdevxml =3D NULL; g_autofree char *cmdlinefile =3D NULL; g_autofree char *jsonfile =3D NULL; =20 - if (info->command =3D=3D MDEVCTL_CMD_CREATE) { - cmd =3D "create"; - func =3D nodeDeviceGetMdevctlCreateCommand; - } else if (info->command =3D=3D MDEVCTL_CMD_DEFINE) { - cmd =3D "define"; - func =3D nodeDeviceGetMdevctlDefineCommand; - } else { - return -1; - } - mdevxml =3D g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, info->filename); cmdlinefile =3D g_strdup_printf("%s/nodedevmdevctldata/%s-%s.argv", @@ -111,7 +100,7 @@ testMdevctlCreateOrDefineHelper(const void *data) jsonfile =3D g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_s= rcdir, info->filename, cmd); =20 - return testMdevctlCreateOrDefine(info->virt_type, info->create, func, + return testMdevctlCreateOrDefine(info->virt_type, info->create, info->= command, mdevxml, cmdlinefile, jsonfile); } =20 @@ -122,7 +111,7 @@ struct UuidCommandTestInfo { }; =20 static int -testMdevctlUuidCommand(GetStopUndefineCmdFunc func, +testMdevctlUuidCommand(virMdevctlCommand command, const char *mdevxml, const char *outfile) { g_autoptr(virNodeDeviceDef) def =3D NULL; @@ -136,7 +125,7 @@ testMdevctlUuidCommand(GetStopUndefineCmdFunc func, if (!(def =3D virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEM= U"))) goto cleanup; =20 - cmd =3D func(def, &errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, command, NULL, &errmsg); =20 if (!cmd) goto cleanup; @@ -161,30 +150,16 @@ static int testMdevctlUuidCommandHelper(const void *data) { const struct UuidCommandTestInfo *info =3D data; - GetStopUndefineCmdFunc func; - const char *cmd; + const char *cmd =3D virMdevctlCommandTypeToString(info->command); g_autofree char *cmdlinefile =3D NULL; g_autofree char *mdevxml =3D NULL; =20 - if (info->command =3D=3D MDEVCTL_CMD_STOP) { - cmd =3D "stop"; - func =3D nodeDeviceGetMdevctlStopCommand; - } else if (info->command =3D=3D MDEVCTL_CMD_UNDEFINE) { - cmd =3D "undefine"; - func =3D nodeDeviceGetMdevctlUndefineCommand; - }else if (info->command =3D=3D MDEVCTL_CMD_START) { - cmd =3D "start"; - func =3D nodeDeviceGetMdevctlStartCommand; - } else { - return -1; - } - mdevxml =3D g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir, info->filename); cmdlinefile =3D g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv= ", abs_srcdir, cmd); =20 - return testMdevctlUuidCommand(func, mdevxml, cmdlinefile); + return testMdevctlUuidCommand(info->command, mdevxml, cmdlinefile); } =20 static int --=20 2.26.3