From nobody Tue Feb 10 17:08:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1618004116; cv=none; d=zohomail.com; s=zohoarc; b=iqkKCR/wYObjs1mqHnQMh9OSRVW5HnMt5f6Zwp50u8lQ4MdJ4aW2rLHRsKJ4YZX7Q36scTTv/bZzjBNF89F60r94ZAYCD0lyohXp/rQ1eV1gdhuoCOgGIk6qk7Lv89QhYCAYzY8lk7htY/sT0zEX0kzU9ZEeAJtwZ0Dd2JeYyyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618004116; 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=FqG3GDIiT1bfXEachtv3c0/noz1pbSgfM7+kPrD17Ao=; b=h4vzZdjggwaNUZDTggOgTbAyRyTRKQgKvbOxncF65XIVcGePef5z9C6GbGoCUKi8w3DuXiGEmMrHsC56Aym7Y3VKyt2LT5QiWcS5NnVc5Hhpg4h4xCvHMT0gHSucU9ZBeMG+FbnMqfjVVuvdqx90T39qdWyuiLZ3tmDZ16KSvoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1618004116070573.3824849489819; Fri, 9 Apr 2021 14:35:16 -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-599-KMWNdFcvNlif1La9_7ER_A-1; Fri, 09 Apr 2021 17:33:55 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF5001007495; Fri, 9 Apr 2021 21:33:48 +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 BDF1B5C3E9; Fri, 9 Apr 2021 21:33:48 +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 7FAFD1806D22; Fri, 9 Apr 2021 21:33:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139LXEj7032651 for ; Fri, 9 Apr 2021 17:33:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5F2CE5D6AD; Fri, 9 Apr 2021 21:33:14 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31CAC5D6A1 for ; Fri, 9 Apr 2021 21:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618004114; 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=FqG3GDIiT1bfXEachtv3c0/noz1pbSgfM7+kPrD17Ao=; b=HZQ24gVcvWCGPA6hTVxDjA9CvOG282XD0fAQ+ukplLYWvt48JInVo1DHK9BuY46crqF1gu vwR7IGtM3GYUeDDMtfML4TT6Deeg94HZ5tPJtApqgICEmaFO3w7H4l3syYB2yeVxkwz/aS ll1Jp2giI14lwEvNl7YH5SViowsiSYM= X-MC-Unique: KMWNdFcvNlif1La9_7ER_A-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH 08/11] nodedev: Remove GetMdevctl*Command() wrappers Date: Fri, 9 Apr 2021 16:33:03 -0500 Message-Id: <20210409213306.3971286-9-jjongsma@redhat.com> In-Reply-To: <20210409213306.3971286-1-jjongsma@redhat.com> References: <20210409213306.3971286-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.16 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 --- 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 0fddfdde86..76019b8631 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(virNodeDeviceDefPtr def, virMdevctlCommand cmd_type, char **outbuf, @@ -775,30 +775,15 @@ nodeDeviceGetMdevctlCommand(virNodeDeviceDefPtr 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(virNodeDeviceDefPtr 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(virNodeDeviceDefPtr 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 -virCommandPtr -nodeDeviceGetMdevctlStopCommand(virNodeDeviceDefPtr def, - char **errmsg) -{ - return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg= ); -} - -virCommand * -nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDefPtr 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(virNodeDeviceDefPtr 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 0fea75a118..482a5cfb3e 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -141,23 +141,11 @@ int nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn, int callbackID); =20 -virCommandPtr -nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDefPtr def, - char **uuid_out, - char **errmsg); - -virCommand* -nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg); - -virCommandPtr -nodeDeviceGetMdevctlStopCommand(virNodeDeviceDefPtr def, - char **errmsg); - virCommand * -nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDefPtr def, - char **errmsg); +nodeDeviceGetMdevctlCommand(virNodeDeviceDefPtr def, + virMdevctlCommand cmd_type, + char **outbuf, + char **errbuf); =20 virCommandPtr nodeDeviceGetMdevctlListCommand(bool defined, @@ -180,10 +168,6 @@ nodeDeviceGenerateName(virNodeDeviceDef *def, bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst, virNodeDeviceDef *src); =20 -virCommand* -nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def, - char **errmsg); - int nodeDeviceCreate(virNodeDevice *dev, unsigned int flags); diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index e766ae8f34..c467c798e7 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -53,7 +53,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) @@ -73,7 +73,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; @@ -103,22 +103,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", @@ -126,7 +115,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 @@ -137,7 +126,7 @@ struct UuidCommandTestInfo { }; =20 static int -testMdevctlUuidCommand(GetStopUndefineCmdFunc func, +testMdevctlUuidCommand(virMdevctlCommand command, const char *mdevxml, const char *outfile) { g_autoptr(virNodeDeviceDef) def =3D NULL; @@ -150,7 +139,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; @@ -176,30 +165,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