From nobody Thu May 16 20:49:29 2024 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=1618346408; cv=none; d=zohomail.com; s=zohoarc; b=LJUUXno7btDXPguBISCcWxQehK4doM5tCior44hICQkhoB7d+XLuT69vIq8CPrGe6jvVODAjSb8VFnPwLdLWJuj1X90Vjs2WZmzaitkQLy0L5zU9WPOeoKtJNm+WUpuSvN3fQeuBFrHifyaD/FoSjxxMrGtnn/HqDTfwqFJN1uA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346408; 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=iGvcnX0CgdulSarqVjHddChBELvR9aYoISKKuy1Kppk=; b=HT7wFtJEfC6iupvmrjOxCO9oPEsz81LuP2OsecqBRBl2R+NMjfrRayvM9CQKq4BVhfLM8WhCIGfk6QCR+1T2DjwWwcK2B73X6k8urVyxzApnOP144vU1qZT2Ja0ernLrp60rLd6QZ3oZ4jcXNXcUcXhoLtgDocBFbdenJACEz74= 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 1618346408070279.3909308293196; Tue, 13 Apr 2021 13:40:08 -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-548-WoPPM32UMH2y0effCxzjTg-1; Tue, 13 Apr 2021 16:40:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6741510053E6; Tue, 13 Apr 2021 20:39:58 +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 A82A160C04; Tue, 13 Apr 2021 20:39:57 +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 E61221806D15; Tue, 13 Apr 2021 20:39:54 +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 13DKdrXt011658 for ; Tue, 13 Apr 2021 16:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52BC519744; Tue, 13 Apr 2021 20:39:53 +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 238BE1972B for ; Tue, 13 Apr 2021 20:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346406; 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=iGvcnX0CgdulSarqVjHddChBELvR9aYoISKKuy1Kppk=; b=YmA8TBIaAcw6RhA0h2aTnSsFdhWQ9gxlsoA3i2xzkipNZTwJtsd3kRXLNY715NuXP+7qsu asrASRJcuO2qboT1T+ii4CeumY1xTUgMabhMel8u/lt4jmqy2NVrMmAEkY7zdytk6ft1IL wALs7QBNnGsI8pUryJ/sdIe2zPew5k0= X-MC-Unique: WoPPM32UMH2y0effCxzjTg-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 01/12] nodedev: don't log error in nodeDeviceFindAddressByName() Date: Tue, 13 Apr 2021 15:39:37 -0500 Message-Id: <20210413203948.71864-2-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.12 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" The calling function will log the error. Just return NULL if a device cannot be found. Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 5f8995172d..4cf4e4214f 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -630,11 +630,8 @@ nodeDeviceFindAddressByName(const char *name) char *addr =3D NULL; virNodeDeviceObj *dev =3D virNodeDeviceObjListFindByName(driver->devs,= name); =20 - if (!dev) { - virReportError(VIR_ERR_NO_NODE_DEVICE, - _("could not find device '%s'"), name); + if (!dev) return NULL; - } =20 def =3D virNodeDeviceObjGetDef(dev); for (caps =3D def->caps; caps !=3D NULL; caps =3D caps->next) { --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346422; cv=none; d=zohomail.com; s=zohoarc; b=Sp+pXzNMLAWbe+vp4Soh8DEeqezWaRIwe6v9rmI2MQvwOg5tKe/Cpt+eEZyIDG5hHFcprV/0GX+4mkurWClAVRyjGTJCqeDlXO6Zqg0/0MgsMoNkK+xoYUWkSn7lNlNG9M+QeLgMXP+XZUJXSTP7QaQkWwVsATUk3NLDJRfQDqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346422; 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=P/m+pa0n0XtUYrFOhBJXuAn/IZlQcPu9EQ3UkfL6354=; b=ctPIE2YHEg2Sf4/qno36yekknOsQKYrNCh0nTPaOikfFy19X3bukS/rpS4NmM/wTZy1vi9/FLHf6kRobNHXSgY+7MIPnv9ihq/HnF3Tg/cAfroGvKKhAUv+24pvi+wK296a9871rXEjA2WkW9BQZN651dX3Qxz4NLtfANr2y8q4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346422098573.9362997550645; Tue, 13 Apr 2021 13:40:22 -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-279-ny09R7oiOVe2LvLG2k-E7A-1; Tue, 13 Apr 2021 16:40:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 113F5814256; Tue, 13 Apr 2021 20:40:12 +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 D348819744; Tue, 13 Apr 2021 20:40:11 +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 70C35180B617; Tue, 13 Apr 2021 20:40:11 +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 13DKdr2l011671 for ; Tue, 13 Apr 2021 16:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E51F19744; Tue, 13 Apr 2021 20:39:53 +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 6F58B1972B for ; Tue, 13 Apr 2021 20:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346421; 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=P/m+pa0n0XtUYrFOhBJXuAn/IZlQcPu9EQ3UkfL6354=; b=ZeedO6oLGBOWvBnmx70/Jz/FLUlCtzb9r7K2NsWc5eCXtCuabTGR7KjZbx6uMnN3IjBWf3 yb/iNB3/lCgO9KuKMGHAISsmZAvQhKlXpwX0LZbF89Lipf1HGIkAD+BjIMlEl2M6kdzsZ1 o4BQiIWWVon6BwdOJWCtpQLa5Ybl4EY= X-MC-Unique: ny09R7oiOVe2LvLG2k-E7A-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 02/12] nodedev: avoid use of VIR_ERR_NO_* errors internally Date: Tue, 13 Apr 2021 15:39:38 -0500 Message-Id: <20210413203948.71864-3-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.84 on 10.5.11.23 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 errors are demoted to debug statements[1] since they're only intended to be used as return values for public APIs. This makes it difficult to debug the problem when something goes wrong since no error message is logged. Switch instead to VIR_ERR_INTERNAL_ERROR so that the error is logged as expected. [1] See the implementation of daemonErrorLogFilter() for details: https://gitlab.com/libvirt/libvirt/-/blob/e2f82a3704f680fbb37a733476d870c19= 232c23e/src/remote/remote_daemon.c#L89 Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 4cf4e4214f..1d1eaa9561 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -709,7 +709,7 @@ nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceDef= *def, g_autofree char *parent_addr =3D nodeDeviceFindAddressByName(def->pare= nt); =20 if (!parent_addr) { - virReportError(VIR_ERR_NO_NODE_DEVICE, + virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find parent device '%s'"), def->parent= ); return NULL; } --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346409; cv=none; d=zohomail.com; s=zohoarc; b=fwRw5mkU9gBmDZWpWA83E+tFg/oiNhef6XBHXFYJ+oYYEHK4eW1+5+vCE5SOLQgY4ipINDSm9Ho/cpow5QYJ27gthYLNQmukHmKz3uiDx/0xEpB9tv/vftH75rSWPLJl7TU9P3t97gYOjDkcc0aUytUVQXfR2apvR/gKsyG5+js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346409; 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=i2XJR/Qr89mA1ayPOVUdwTqJfVGyBLj7fPUtVmi7To4=; b=eqxEFs6DuxL6RCEMun9eg1imQJVIw11if4io9kjerrhWvYGh3k8Zsss3pEz22qoHH+eLIcRnxKods+DLxcahu6QDSv9pfqDn/+niUiekV3bjQQGm0mQvy7NHwPkKREypoKeWNY+Yj64dZnDOA2t9vUYoYdcQtnrDxhPw9rTurGU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346409133455.95644521029453; Tue, 13 Apr 2021 13:40:09 -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-451-cg8A7L--MFyoM6LGLKU1xQ-1; Tue, 13 Apr 2021 16:40:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0FF1B1922962; Tue, 13 Apr 2021 20:39:59 +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 612216A037; Tue, 13 Apr 2021 20:39:58 +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 E40A044A5B; Tue, 13 Apr 2021 20:39:57 +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 13DKdr4M011676 for ; Tue, 13 Apr 2021 16:39:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id EAF1019744; Tue, 13 Apr 2021 20:39:53 +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 BC5291972B for ; Tue, 13 Apr 2021 20:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346408; 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=i2XJR/Qr89mA1ayPOVUdwTqJfVGyBLj7fPUtVmi7To4=; b=U4s7T4YxTBMsEktt0aXJ5xhZcIS9PIYG5+fl//q4h+6i5aIsCTYwkRskgbrBQT8Ry5RbrA 0EyLSUlhblCEcKK2CbpkpIAZ+Do+x24nctnaFuB6pfv6VAp5kLd7Ap+qYL5W9OHje5kICB g9OVKWVtOupjqphzVJLyc4jEfV8ip60= X-MC-Unique: cg8A7L--MFyoM6LGLKU1xQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 03/12] tests: nodedev: switch all test macros to accept a filename Date: Tue, 13 Apr 2021 15:39:39 -0500 Message-Id: <20210413203948.71864-4-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.13 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" Rather than specifying a UUID string to some test macros, just pass a filename to an xml definition. This helps work toward unifying the test macros and making it more maintainable. Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- tests/nodedevmdevctldata/mdevctl-create.argv | 2 +- tests/nodedevmdevctldata/mdevctl-stop.argv | 2 +- .../nodedevmdevctldata/mdevctl-undefine.argv | 2 +- tests/nodedevmdevctltest.c | 38 +++++++++++-------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/tests/nodedevmdevctldata/mdevctl-create.argv b/tests/nodedevmd= evctldata/mdevctl-create.argv index f19c9780dc..ccb8e2992c 100644 --- a/tests/nodedevmdevctldata/mdevctl-create.argv +++ b/tests/nodedevmdevctldata/mdevctl-create.argv @@ -1,3 +1,3 @@ mdevctl \ start \ --u 8a05ad83-3472-497d-8631-8142f31460e8 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdev= ctldata/mdevctl-stop.argv index cc621191d6..a07d339e47 100644 --- a/tests/nodedevmdevctldata/mdevctl-stop.argv +++ b/tests/nodedevmdevctldata/mdevctl-stop.argv @@ -1,3 +1,3 @@ mdevctl \ stop \ --u e2451f73-c95b-4124-b900-e008af37c576 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-undefine.argv b/tests/nodedev= mdevctldata/mdevctl-undefine.argv index f1a59c5242..dbde32e2a8 100644 --- a/tests/nodedevmdevctldata/mdevctl-undefine.argv +++ b/tests/nodedevmdevctldata/mdevctl-undefine.argv @@ -1,3 +1,3 @@ mdevctl \ undefine \ --u d76a6b78-45ed-4149-a325-005f9abc5281 +-u d069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 99e79c18a5..df4185b5f8 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -125,13 +125,15 @@ testMdevctlStartOrDefineHelper(const void *data) =20 typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); struct UuidCommandTestInfo { - const char *uuid; + const char *filename; MdevctlCmd command; }; =20 static int -testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, cons= t char *outfile) +testMdevctlUuidCommand(GetStopUndefineCmdFunc func, + const char *mdevxml, const char *outfile) { + g_autoptr(virNodeDeviceDef) def =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; @@ -139,7 +141,10 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefi= neCmdFunc func, const char g_autofree char *errmsg =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); =20 - cmd =3D func(uuid, &errmsg); + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEM= U"))) + goto cleanup; + + cmd =3D func(def->caps->data.mdev.uuid, &errmsg); =20 if (!cmd) goto cleanup; @@ -167,6 +172,7 @@ testMdevctlUuidCommandHelper(const void *data) GetStopUndefineCmdFunc func; const char *cmd; g_autofree char *cmdlinefile =3D NULL; + g_autofree char *mdevxml =3D NULL; =20 if (info->command =3D=3D MDEVCTL_CMD_STOP) { cmd =3D "stop"; @@ -181,10 +187,12 @@ testMdevctlUuidCommandHelper(const void *data) return -1; } =20 + 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(info->uuid, func, cmdlinefile); + return testMdevctlUuidCommand(func, mdevxml, cmdlinefile); } =20 static int @@ -405,21 +413,21 @@ mymain(void) #define DO_TEST_DEFINE(filename) \ DO_TEST_CMD("mdevctl define " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_DEFINE) =20 -#define DO_TEST_UUID_COMMAND_FULL(desc, uuid, command) \ +#define DO_TEST_UUID_COMMAND_FULL(desc, filename, command) \ do { \ - struct UuidCommandTestInfo info =3D { uuid, command }; \ + struct UuidCommandTestInfo info =3D { filename, command }; \ DO_TEST_FULL(desc, testMdevctlUuidCommandHelper, &info); \ } \ while (0) =20 -#define DO_TEST_STOP(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl stop " uuid, uuid, MDEVCTL_CMD_STOP) +#define DO_TEST_STOP(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl stop " filename, filename, MDEVCTL_= CMD_STOP) =20 -#define DO_TEST_UNDEFINE(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " uuid, uuid, MDEVCTL_CMD_= UNDEFINE) +#define DO_TEST_UNDEFINE(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEV= CTL_CMD_UNDEFINE) =20 -#define DO_TEST_CREATE(uuid) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl create " uuid, uuid, MDEVCTL_CMD_CR= EATE) +#define DO_TEST_CREATE(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl create " filename, filename, MDEVCT= L_CMD_CREATE) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL) @@ -433,7 +441,7 @@ mymain(void) DO_TEST_START("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); =20 /* Test mdevctl stop command, pass an arbitrary uuid */ - DO_TEST_STOP("e2451f73-c95b-4124-b900-e008af37c576"); + DO_TEST_STOP("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 DO_TEST_LIST_DEFINED(); =20 @@ -443,9 +451,9 @@ mymain(void) DO_TEST_DEFINE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076"); DO_TEST_DEFINE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); =20 - DO_TEST_UNDEFINE("d76a6b78-45ed-4149-a325-005f9abc5281"); + DO_TEST_UNDEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 - DO_TEST_CREATE("8a05ad83-3472-497d-8631-8142f31460e8"); + DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 done: nodedevTestDriverFree(driver); --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 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=1618346464; cv=none; d=zohomail.com; s=zohoarc; b=MPE6LfcUetIvgjeBoOq7NPeMDUa8cn9m1pRuhngvXxRt35yuEDwQiIliIZ8Ock18RV1anyfq1N3ABtnkaKYxs0SVTKFhI/6ZkDclh7uxEzqoPkVGjTKA+kDTYXqi24hKIdSYl3bfwOs+6B5A2pNDg5fYt60qdkKPPiVqcc2eOk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346464; h=Content-Type:Content-Transfer-Encoding:Cc: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=0GP7fUSdi6UhgCcX//pkLReA2xIB67M5RnrfMn3ujX8=; b=Qs3FJIisqbSfIseyoqzl1+5R+E4n864Fz2SeuRoRy39ZHUTyiLHMeONAoeAGWwC+IFOUWm9n6hlJwdohi4s3xFXEPVJ2sGNStFjtykuozgXMUJmapejW+0ptHwHdcvWRFYFPhFzYiuh9Sh2kLxPFL2NriDi0ojxsZx2EQBnuw3Q= 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 1618346464723139.1394298676994; Tue, 13 Apr 2021 13:41: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-279-hU3nPGmUPuasS-OqoHRtng-1; Tue, 13 Apr 2021 16:40:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 008791922962; Tue, 13 Apr 2021 20:40:12 +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 D24FD610A8; Tue, 13 Apr 2021 20:40:11 +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 7380C44A67; Tue, 13 Apr 2021 20:40:11 +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 13DKdsTa011682 for ; Tue, 13 Apr 2021 16:39:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 655571975E; Tue, 13 Apr 2021 20:39:54 +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 179CC1972B; Tue, 13 Apr 2021 20:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346463; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0GP7fUSdi6UhgCcX//pkLReA2xIB67M5RnrfMn3ujX8=; b=g6EhtqSATqfzL7RAbhlO8n8QkH4HeQbYNH+T05VwzSqhnsdRXKlV/AtL2e5ikWj/561DWP SR+wXfEI0gcubiL1CZ7oHlsNmU6Zn79Dck4Ziry4lUUECZUiTvWK/qAwWP1NUyz7SLTS05 n30Mym4qDAd4bsQFCEbzhBMojK9LMJ4= X-MC-Unique: hU3nPGmUPuasS-OqoHRtng-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/12] nodedev: driver: Swap virMdevctlStart and virMdevctlCreate Date: Tue, 13 Apr 2021 15:39:40 -0500 Message-Id: <20210413203948.71864-5-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 Cc: Erik Skultety 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.12 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" From: Erik Skultety "start" in libvirt means - "take this object and create an instance out of it" "create" in libvirt most of the time means - "take and XML description, make an object out of it and use it to create an instance" This gets confusing with mdevctl which uses "start" for both. So, this patch proposes to use virMdevctlStart in cases where from libvirt's POV we're starting a defined device (unlike mdevctl). Analogically, use virMdevctlCreate in scenarios where XML description is passed to libvirt and a transient device is supposed to be created. Signed-off-by: Erik Skultety Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 34 ++++++------- src/node_device/node_device_driver.h | 10 ++-- ...9_36ea_4111_8f0a_8c9a70e21366-create.argv} | 0 ...9_36ea_4111_8f0a_8c9a70e21366-create.json} | 0 ...9_495e_4243_ad9f_beb3f14c23d9-create.argv} | 0 ...9_495e_4243_ad9f_beb3f14c23d9-create.json} | 0 ...6_1ca8_49ac_b176_871d16c13076-create.argv} | 0 ...6_1ca8_49ac_b176_871d16c13076-create.json} | 0 ...mdevctl-create.argv =3D> mdevctl-start.argv} | 0 tests/nodedevmdevctltest.c | 49 +++++++++---------- 10 files changed, 46 insertions(+), 47 deletions(-) rename tests/nodedevmdevctldata/{mdev_d069d019_36ea_4111_8f0a_8c9a70e21366= -start.argv =3D> mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-create.argv} (10= 0%) rename tests/nodedevmdevctldata/{mdev_d069d019_36ea_4111_8f0a_8c9a70e21366= -start.json =3D> mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-create.json} (10= 0%) rename tests/nodedevmdevctldata/{mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9= -start.argv =3D> mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-create.argv} (10= 0%) rename tests/nodedevmdevctldata/{mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9= -start.json =3D> mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-create.json} (10= 0%) rename tests/nodedevmdevctldata/{mdev_fedc4916_1ca8_49ac_b176_871d16c13076= -start.argv =3D> mdev_fedc4916_1ca8_49ac_b176_871d16c13076-create.argv} (10= 0%) rename tests/nodedevmdevctldata/{mdev_fedc4916_1ca8_49ac_b176_871d16c13076= -start.json =3D> mdev_fedc4916_1ca8_49ac_b176_871d16c13076-create.json} (10= 0%) rename tests/nodedevmdevctldata/{mdevctl-create.argv =3D> mdevctl-start.ar= gv} (100%) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 1d1eaa9561..dda118b0e5 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -699,10 +699,10 @@ nodeDeviceFindAddressByName(const char *name) * arguments, so provide a common implementation that can be wrapped by a = more * specific function */ static virCommand* -nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceDef *def, - const char *subcommand, - char **uuid_out, - char **errmsg) +nodeDeviceGetMdevctlDefineCreateCommand(virNodeDeviceDef *def, + const char *subcommand, + char **uuid_out, + char **errmsg) { virCommand *cmd; g_autofree char *json =3D NULL; @@ -737,12 +737,12 @@ nodeDeviceGetMdevctlDefineStartCommand(virNodeDeviceD= ef *def, } =20 virCommand* -nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, +nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def, char **uuid_out, char **errmsg) { - return nodeDeviceGetMdevctlDefineStartCommand(def, "start", uuid_out, - errmsg); + return nodeDeviceGetMdevctlDefineCreateCommand(def, "start", uuid_out, + errmsg); } =20 virCommand* @@ -750,18 +750,18 @@ nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *d= ef, char **uuid_out, char **errmsg) { - return nodeDeviceGetMdevctlDefineStartCommand(def, "define", uuid_out, - errmsg); + return nodeDeviceGetMdevctlDefineCreateCommand(def, "define", uuid_out, + errmsg); } =20 =20 =20 static int -virMdevctlStart(virNodeDeviceDef *def, char **uuid, char **errmsg) +virMdevctlCreate(virNodeDeviceDef *def, char **uuid, char **errmsg) { int status; - g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlStartCommand(def, uu= id, - errmsg); + g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlCreateCommand(def, u= uid, + errmsg); if (!cmd) return -1; =20 @@ -811,7 +811,7 @@ nodeDeviceCreateXMLMdev(virConnectPtr conn, return NULL; } =20 - if (virMdevctlStart(def, &uuid, &errmsg) < 0) { + if (virMdevctlCreate(def, &uuid, &errmsg) < 0) { if (errmsg) virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to start mediated device '%s': %s"), @@ -910,7 +910,7 @@ nodeDeviceGetMdevctlUndefineCommand(const char *uuid, c= har **errmsg) } =20 virCommand * -nodeDeviceGetMdevctlCreateCommand(const char *uuid, char **errmsg) +nodeDeviceGetMdevctlStartCommand(const char *uuid, char **errmsg) { virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "start", @@ -953,12 +953,12 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errm= sg) =20 =20 static int -virMdevctlCreate(virNodeDeviceDef *def, char **errmsg) +virMdevctlStart(virNodeDeviceDef *def, char **errmsg) { int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlCreateCommand(def->caps->data.mdev.uuid, e= rrmsg); + cmd =3D nodeDeviceGetMdevctlStartCommand(def->caps->data.mdev.uuid, er= rmsg); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; @@ -1412,7 +1412,7 @@ nodeDeviceCreate(virNodeDevice *device, if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) { g_autofree char *errmsg =3D NULL; =20 - if (virMdevctlCreate(def, &errmsg) < 0) { + if (virMdevctlStart(def, &errmsg) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to create mediated device: %s"), errmsg && errmsg[0] ? errmsg : "Unknown Error"); diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 5a64558f81..4101e34a8f 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -123,9 +123,9 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr c= onn, int callbackID); =20 virCommand * -nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, - char **uuid_out, - char **errmsg); +nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def, + char **uuid_out, + char **errmsg); =20 virCommand* nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def, @@ -162,8 +162,8 @@ bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst, virNodeDeviceDef *src); =20 virCommand* -nodeDeviceGetMdevctlCreateCommand(const char *uuid, - char **errmsg); +nodeDeviceGetMdevctlStartCommand(const char *uuid, + char **errmsg); =20 int nodeDeviceCreate(virNodeDevice *dev, diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-start.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9= a70e21366-create.argv similarity index 100% rename from tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21= 366-start.argv rename to tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2136= 6-create.argv diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-start.json b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9= a70e21366-create.json similarity index 100% rename from tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21= 366-start.json rename to tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2136= 6-create.json diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-start.argv b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb= 3f14c23d9-create.argv similarity index 100% rename from tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c2= 3d9-start.argv rename to tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d= 9-create.argv diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-start.json b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb= 3f14c23d9-create.json similarity index 100% rename from tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c2= 3d9-start.json rename to tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d= 9-create.json diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-start.argv b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871= d16c13076-create.argv similarity index 100% rename from tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13= 076-start.argv rename to tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1307= 6-create.argv diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-start.json b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871= d16c13076-create.json similarity index 100% rename from tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13= 076-start.json rename to tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1307= 6-create.json diff --git a/tests/nodedevmdevctldata/mdevctl-create.argv b/tests/nodedevmd= evctldata/mdevctl-start.argv similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-create.argv rename to tests/nodedevmdevctldata/mdevctl-start.argv diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index df4185b5f8..188e521f59 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -44,12 +44,12 @@ typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef = *, char **, char **); =20 =20 static int -testMdevctlStartOrDefine(const char *virt_type, - int create, - MdevctlCmdFunc mdevctl_cmd_func, - const char *mdevxml, - const char *cmdfile, - const char *jsonfile) +testMdevctlCreateOrDefine(const char *virt_type, + int create, + MdevctlCmdFunc mdevctl_cmd_func, + const char *mdevxml, + const char *cmdfile, + const char *jsonfile) { g_autoptr(virNodeDeviceDef) def =3D NULL; virNodeDeviceObj *obj =3D NULL; @@ -93,7 +93,7 @@ testMdevctlStartOrDefine(const char *virt_type, } =20 static int -testMdevctlStartOrDefineHelper(const void *data) +testMdevctlCreateOrDefineHelper(const void *data) { const struct startTestInfo *info =3D data; const char *cmd; @@ -102,9 +102,9 @@ testMdevctlStartOrDefineHelper(const void *data) g_autofree char *cmdlinefile =3D NULL; g_autofree char *jsonfile =3D NULL; =20 - if (info->command =3D=3D MDEVCTL_CMD_START) { - cmd =3D "start"; - func =3D nodeDeviceGetMdevctlStartCommand; + 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; @@ -119,8 +119,8 @@ testMdevctlStartOrDefineHelper(const void *data) jsonfile =3D g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_s= rcdir, info->filename, cmd); =20 - return testMdevctlStartOrDefine(info->virt_type, info->create, func, - mdevxml, cmdlinefile, jsonfile); + return testMdevctlCreateOrDefine(info->virt_type, info->create, func, + mdevxml, cmdlinefile, jsonfile); } =20 typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); @@ -180,9 +180,9 @@ testMdevctlUuidCommandHelper(const void *data) } else if (info->command =3D=3D MDEVCTL_CMD_UNDEFINE) { cmd =3D "undefine"; func =3D nodeDeviceGetMdevctlUndefineCommand; - }else if (info->command =3D=3D MDEVCTL_CMD_CREATE) { - cmd =3D "create"; - func =3D nodeDeviceGetMdevctlCreateCommand; + }else if (info->command =3D=3D MDEVCTL_CMD_START) { + cmd =3D "start"; + func =3D nodeDeviceGetMdevctlStartCommand; } else { return -1; } @@ -403,12 +403,12 @@ mymain(void) #define DO_TEST_CMD(desc, virt_type, create, filename, command) \ do { \ struct startTestInfo info =3D { virt_type, create, filename, comma= nd }; \ - DO_TEST_FULL(desc, testMdevctlStartOrDefineHelper, &info); \ + DO_TEST_FULL(desc, testMdevctlCreateOrDefineHelper, &info); \ } \ while (0) =20 -#define DO_TEST_START(filename) \ - DO_TEST_CMD("mdevctl start " filename, "QEMU", CREATE_DEVICE, filename= , MDEVCTL_CMD_START) +#define DO_TEST_CREATE(filename) \ + DO_TEST_CMD("mdevctl create " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_CREATE) =20 #define DO_TEST_DEFINE(filename) \ DO_TEST_CMD("mdevctl define " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_DEFINE) @@ -426,8 +426,8 @@ mymain(void) #define DO_TEST_UNDEFINE(filename) \ DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEV= CTL_CMD_UNDEFINE) =20 -#define DO_TEST_CREATE(filename) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl create " filename, filename, MDEVCT= L_CMD_CREATE) +#define DO_TEST_START(filename) \ + DO_TEST_UUID_COMMAND_FULL("mdevctl start " filename, filename, MDEVCTL= _CMD_START) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL) @@ -435,10 +435,9 @@ mymain(void) #define DO_TEST_PARSE_JSON(filename) \ DO_TEST_FULL("parse mdevctl json " filename, testMdevctlParse, filenam= e) =20 - /* Test mdevctl start commands */ - DO_TEST_START("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); - DO_TEST_START("mdev_fedc4916_1ca8_49ac_b176_871d16c13076"); - DO_TEST_START("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); + DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); + DO_TEST_CREATE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076"); + DO_TEST_CREATE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9"); =20 /* Test mdevctl stop command, pass an arbitrary uuid */ DO_TEST_STOP("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); @@ -453,7 +452,7 @@ mymain(void) =20 DO_TEST_UNDEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 - DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); + DO_TEST_START("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); =20 done: nodedevTestDriverFree(driver); --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346463; cv=none; d=zohomail.com; s=zohoarc; b=gdWxMBQsORnt2gsudFYWiP8RjsCUXrHjsvTAfYqBzUwsDBRQuPRsNvSnwXACONF1FEdPCTaRBV8OW8TE+idSrs22329D7ma974imqwSx9NZpGWBImBlbfvxwqn5fDlySE5QCLcnAU0V8mzV0VU/ECLnPsozSQqiyoJ0hneN0Dys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346463; 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=7IrQLZdh80TowFSSoksIlgK/0eB2e8VpDkXc+AOkMeY=; b=MJqI4CDEpvybLUJL5DIrhcVpTf4Je2xBK+z1898ro2yMq/QWbiQM9bAQPI4YnH7533xUGoNyfPZ64clS0Oy9P8RhCmRM8H42a8lshP9fhhvgWb5MyIccYhGkmO//pTdW70o+x0A+y8M6yaAXU0/G286Pu893D5xDQeqYVEtZYBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346463558191.0023369528883; Tue, 13 Apr 2021 13:41:03 -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-585-Xxk_kMFTNWOUWE2SpUF4AA-1; Tue, 13 Apr 2021 16:40:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D658010053EC; Tue, 13 Apr 2021 20:40:15 +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 B434660C04; Tue, 13 Apr 2021 20:40:15 +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 797BF44A6E; Tue, 13 Apr 2021 20:40:15 +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 13DKds4O011690 for ; Tue, 13 Apr 2021 16:39:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B42AA19744; Tue, 13 Apr 2021 20:39:54 +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 82EEF1972B for ; Tue, 13 Apr 2021 20:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346462; 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=7IrQLZdh80TowFSSoksIlgK/0eB2e8VpDkXc+AOkMeY=; b=GN0RoV2ta3MDJoNnfpU9iWEd4qs28GKMfu/TQQYq97JehE+mJiO4+tx7YAezu/AvrRdlss NnS3clwfipw13A7s/5h/ZJloofMebmVFG6+bRt8Vuvz3NVM73jmQOZglsU2zbHEEc4Bvgs OhJ4IwA8NtF47HNL/5DxocNii7E92MU= X-MC-Unique: Xxk_kMFTNWOUWE2SpUF4AA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/12] nodedev: Switch to using long options for mdevctl Date: Tue, 13 Apr 2021 15:39:41 -0500 Message-Id: <20210413203948.71864-6-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.12 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" rather than using short opentions (e.g. "-p 0000:00:02.0"), use long options everywhere (e.g. "--parent=3D0000:00:02.0") Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 28 ++++++------------- ...19_36ea_4111_8f0a_8c9a70e21366-create.argv | 4 +-- ...19_36ea_4111_8f0a_8c9a70e21366-define.argv | 4 +-- ...39_495e_4243_ad9f_beb3f14c23d9-create.argv | 4 +-- ...39_495e_4243_ad9f_beb3f14c23d9-define.argv | 4 +-- ...16_1ca8_49ac_b176_871d16c13076-create.argv | 4 +-- ...16_1ca8_49ac_b176_871d16c13076-define.argv | 4 +-- tests/nodedevmdevctldata/mdevctl-start.argv | 2 +- tests/nodedevmdevctldata/mdevctl-stop.argv | 2 +- .../nodedevmdevctldata/mdevctl-undefine.argv | 2 +- 10 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index dda118b0e5..56cbae0037 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -720,10 +720,9 @@ nodeDeviceGetMdevctlDefineCreateCommand(virNodeDeviceD= ef *def, return NULL; } =20 - cmd =3D virCommandNewArgList(MDEVCTL, subcommand, - "-p", parent_addr, - "--jsonfile", "/dev/stdin", - NULL); + cmd =3D virCommandNewArgList(MDEVCTL, subcommand, NULL); + virCommandAddArgPair(cmd, "--parent", parent_addr); + virCommandAddArgPair(cmd, "--jsonfile", "/dev/stdin"); =20 virCommandSetInputBuffer(cmd, json); =20 @@ -887,11 +886,8 @@ nodeDeviceCreateXML(virConnectPtr conn, virCommand * nodeDeviceGetMdevctlStopCommand(const char *uuid, char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, - "stop", - "-u", - uuid, - NULL); + virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "stop", NULL); + virCommandAddArgPair(cmd, "--uuid", uuid); virCommandSetErrorBuffer(cmd, errmsg); return cmd; =20 @@ -900,11 +896,8 @@ nodeDeviceGetMdevctlStopCommand(const char *uuid, char= **errmsg) virCommand * nodeDeviceGetMdevctlUndefineCommand(const char *uuid, char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, - "undefine", - "-u", - uuid, - NULL); + virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "undefine", NULL); + virCommandAddArgPair(cmd, "--uuid", uuid); virCommandSetErrorBuffer(cmd, errmsg); return cmd; } @@ -912,11 +905,8 @@ nodeDeviceGetMdevctlUndefineCommand(const char *uuid, = char **errmsg) virCommand * nodeDeviceGetMdevctlStartCommand(const char *uuid, char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, - "start", - "-u", - uuid, - NULL); + virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "start", NULL); + virCommandAddArgPair(cmd, "--uuid", uuid); virCommandSetErrorBuffer(cmd, errmsg); return cmd; } diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-create.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c= 9a70e21366-create.argv index 73a8046d84..3cf66f8a91 100644 --- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-cr= eate.argv +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-cr= eate.argv @@ -1,5 +1,5 @@ mdevctl \ start \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin \ +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin \ --uuid=3Dd069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-define.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c= 9a70e21366-define.argv index b8bb276f9f..a8c2feaed4 100644 --- a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-de= fine.argv +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-de= fine.argv @@ -1,5 +1,5 @@ mdevctl \ define \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin \ +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin \ --uuid=3Dd069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-create.argv b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_be= b3f14c23d9-create.argv index eae63f7a7f..010e562026 100644 --- a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-cr= eate.argv +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-cr= eate.argv @@ -1,4 +1,4 @@ mdevctl \ start \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-define.argv b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_be= b3f14c23d9-define.argv index bf8637ed57..46d1e95f15 100644 --- a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-de= fine.argv +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-de= fine.argv @@ -1,4 +1,4 @@ mdevctl \ define \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-create.argv b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_87= 1d16c13076-create.argv index eae63f7a7f..010e562026 100644 --- a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-cr= eate.argv +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-cr= eate.argv @@ -1,4 +1,4 @@ mdevctl \ start \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-define.argv b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_87= 1d16c13076-define.argv index bf8637ed57..46d1e95f15 100644 --- a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-de= fine.argv +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-de= fine.argv @@ -1,4 +1,4 @@ mdevctl \ define \ --p 0000:00:02.0 \ ---jsonfile /dev/stdin +--parent=3D0000:00:02.0 \ +--jsonfile=3D/dev/stdin diff --git a/tests/nodedevmdevctldata/mdevctl-start.argv b/tests/nodedevmde= vctldata/mdevctl-start.argv index ccb8e2992c..e876d08ad3 100644 --- a/tests/nodedevmdevctldata/mdevctl-start.argv +++ b/tests/nodedevmdevctldata/mdevctl-start.argv @@ -1,3 +1,3 @@ mdevctl \ start \ --u d069d019-36ea-4111-8f0a-8c9a70e21366 +--uuid=3Dd069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdev= ctldata/mdevctl-stop.argv index a07d339e47..e422b2c3ea 100644 --- a/tests/nodedevmdevctldata/mdevctl-stop.argv +++ b/tests/nodedevmdevctldata/mdevctl-stop.argv @@ -1,3 +1,3 @@ mdevctl \ stop \ --u d069d019-36ea-4111-8f0a-8c9a70e21366 +--uuid=3Dd069d019-36ea-4111-8f0a-8c9a70e21366 diff --git a/tests/nodedevmdevctldata/mdevctl-undefine.argv b/tests/nodedev= mdevctldata/mdevctl-undefine.argv index dbde32e2a8..fa35a646be 100644 --- a/tests/nodedevmdevctldata/mdevctl-undefine.argv +++ b/tests/nodedevmdevctldata/mdevctl-undefine.argv @@ -1,3 +1,3 @@ mdevctl \ undefine \ --u d069d019-36ea-4111-8f0a-8c9a70e21366 +--uuid=3Dd069d019-36ea-4111-8f0a-8c9a70e21366 --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 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=1618346426; cv=none; d=zohomail.com; s=zohoarc; b=TLPyPh65a+djX3xvDstH1UWNAoEnMkSlIfgBdQxO2S966xdSFdoc83oMYNkplC0YwVNwqczwDzTR9lPhyc5teiXf3ABP/kzB3X+88TiuyZF+/VS4QRjAg9cJn86o0pdSj98kKuzsOM/ehJ5LdJ5d8wAzmJzsM95xjdxNHW19fl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346426; h=Content-Type:Content-Transfer-Encoding:Cc: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=laaNroyVb0JV0Fz7Zv4Lyr54vHiLVurEfzJIw0Dkd4w=; b=f2nw1VjlWm8M8sWaAPLMl4NZdskRJEmUTuZrZJfsMhKUHNr+eDdcKfydok9aMGngGIKWMIzQGTDUvrjwnF0qojqK8EPAMhtVCPQ3E+k9YCyE+KI3nN/OUdIxiOofEauDrTPYOf1YjpXjyhEzaKLjDS8L0oy+P8u15mU1hPhVWXQ= 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 1618346426163178.17010988125878; Tue, 13 Apr 2021 13:40:26 -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-420-wGOsIyzGNI6T1xfnTO0QpA-1; Tue, 13 Apr 2021 16:40:22 -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 ACE6281431F; Tue, 13 Apr 2021 20:40:14 +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 8D49559456; Tue, 13 Apr 2021 20:40:14 +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 5898B44A6A; Tue, 13 Apr 2021 20:40:14 +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 13DKdtdU011698 for ; Tue, 13 Apr 2021 16:39:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BCCA19744; 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 D0DB01972B; Tue, 13 Apr 2021 20:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346425; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=laaNroyVb0JV0Fz7Zv4Lyr54vHiLVurEfzJIw0Dkd4w=; b=BBgzAodoxOlFU66xE5cAi0LMnTZuJfcflmXl7wnxS1XV2G/9/poYr0Q3tiOMH4awvbchvh T/uxHUpRL0DiVC3DuGh/SvVxNuVMjYGSdIMqyLdVcq7cQKSR3pjnKPQ07evKvvnnFM0s9d UjNYSu2SNSaD4Cuj0zjnv2CrE4m9tQk= X-MC-Unique: wGOsIyzGNI6T1xfnTO0QpA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 06/12] nodedev: driver: Introduce internal mdevctl commands enum Date: Tue, 13 Apr 2021 15:39:42 -0500 Message-Id: <20210413203948.71864-7-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 Cc: Erik Skultety 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 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" From: Erik Skultety This is not a 1:1 mapping to mdevctl because mdevctl doesn't support a 'create' command. It uses 'start' for both starting a defined device as well as creating a transient one. To make our code more readable in that regard and not second-guess what does a specific "start" instance mean, use "create" internally instead only to translate it to "start" just before executing mdevctl. Signed-off-by: Erik Skultety Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 7 +++++++ src/node_device/node_device_driver.h | 19 +++++++++++++++++++ tests/nodedevmdevctltest.c | 12 ++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 56cbae0037..da55e386f0 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -47,6 +47,13 @@ =20 virNodeDeviceDriverState *driver; =20 + +VIR_ENUM_IMPL(virMdevctlCommand, + MDEVCTL_CMD_LAST, + "start", "stop", "define", "undefine", "create" +); + + virDrvOpenStatus nodeConnectOpen(virConnectPtr conn, virConnectAuthPtr auth G_GNUC_UNUSED, diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index 4101e34a8f..d06efbf354 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -33,6 +33,25 @@ int udevNodeRegister(void); #endif =20 + +typedef enum { + MDEVCTL_CMD_START, + MDEVCTL_CMD_STOP, + MDEVCTL_CMD_DEFINE, + MDEVCTL_CMD_UNDEFINE, + + /* mdevctl actually doesn't have a 'create' command, it will be replac= ed + * with 'start' eventually in nodeDeviceGetMdevctlCommand, but this cl= ear + * separation makes our code more readable in terms of knowing when we= 're + * starting a defined device and when we're creating a transient one */ + MDEVCTL_CMD_CREATE, + + MDEVCTL_CMD_LAST, +} virMdevctlCommand; + +VIR_ENUM_DECL(virMdevctlCommand); + + void nodeDeviceLock(void); =20 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 188e521f59..cf8de852a8 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,19 +10,11 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 -typedef enum { - MDEVCTL_CMD_START, - MDEVCTL_CMD_STOP, - MDEVCTL_CMD_DEFINE, - MDEVCTL_CMD_UNDEFINE, - MDEVCTL_CMD_CREATE, -} MdevctlCmd; - struct startTestInfo { const char *virt_type; int create; const char *filename; - MdevctlCmd command; + virMdevctlCommand command; }; =20 /* capture stdin passed to command */ @@ -126,7 +118,7 @@ testMdevctlCreateOrDefineHelper(const void *data) typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); struct UuidCommandTestInfo { const char *filename; - MdevctlCmd command; + virMdevctlCommand command; }; =20 static int --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 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=1618346420; cv=none; d=zohomail.com; s=zohoarc; b=Cun7pWfA+6GBoqjXt7lyW/x+qbC73bQLE7fgnLok0RWRCIGl2egsWgRhu40WslP6CHc1rX9H+ylcz4l6+6wp4SnElslWQWx+NDLwaQHPonGAfaN4ZBgCGbvWtGrfDYgbebw9531LE3w7FoG9qW3iC0gakqT+DRuTBK2JKk9MNW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346420; h=Content-Type:Content-Transfer-Encoding:Cc: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=8fcv2K50G8uezLJ3TtRMsnT3wC0ELyfPTjPblXUAkyo=; b=CvdoNVA92ZUsjK9KlUc6fTYNcnV+Kkm6GlV2y5+PgFBqUY9RuS/8Mk6/1oWmrJRIZp00AvsW04xYZPU1DqglLexfDPDAh7zh37lUjhCyAFVOSSQrRPTCOM2V/N9RYKkuN42LCmE1sJqTWiShqnXtK/xNWdVYw+alzryfFb5Ofy8= 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 1618346420260751.4549858236601; Tue, 13 Apr 2021 13:40:20 -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-132-9SkcTseKOHC_woFvBV-CaQ-1; Tue, 13 Apr 2021 16:40:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 026EF1922963; Tue, 13 Apr 2021 20:40:12 +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 D044D5D9D0; Tue, 13 Apr 2021 20:40:11 +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 71AD2180B654; Tue, 13 Apr 2021 20:40:11 +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 13DKdtwe011706 for ; Tue, 13 Apr 2021 16:39:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78E5A1975E; 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 399B41972B; 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=1618346419; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8fcv2K50G8uezLJ3TtRMsnT3wC0ELyfPTjPblXUAkyo=; b=AcDGoS7+zSB1TRYOiVdmsYg22DdRY1X5901GvOahc2ZZnfzW1HcJv8o86KgDtLE8v3Cljn G2xHRnEnaN4PkH1CAOP+ZaWGeD1gzcL5Y0zGHf1q2LlwZW2igolV2zyefEOtZA/XkDbX6d CLr7XzVOYCp6iqBgWc6espVmks98ClA= X-MC-Unique: 9SkcTseKOHC_woFvBV-CaQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 07/12] nodedev: driver: Create a generic mdevctl command translator Date: Tue, 13 Apr 2021 15:39:43 -0500 Message-Id: <20210413203948.71864-8-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 Cc: Erik Skultety 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.14 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" From: Erik Skultety Currently there are dedicated wrappers to construct mdevctl command. These are mostly fine except for the one that translates both "start" and "define" commands, only because mdevctl takes the same set of arguments. Instead, keep the wrappers, but let them call a single global translator that handles all the mdevctl command differences and commonalities. Signed-off-by: Erik Skultety Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/node_device/node_device_driver.c | 125 ++++++++++++++++----------- src/node_device/node_device_driver.h | 6 +- tests/nodedevmdevctltest.c | 4 +- 3 files changed, 79 insertions(+), 56 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index da55e386f0..bbb01c3967 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -702,42 +702,75 @@ nodeDeviceFindAddressByName(const char *name) } =20 =20 -/* the mdevctl 'start' and 'define' commands accept almost the exact same - * arguments, so provide a common implementation that can be wrapped by a = more - * specific function */ -static virCommand* -nodeDeviceGetMdevctlDefineCreateCommand(virNodeDeviceDef *def, - const char *subcommand, - char **uuid_out, - char **errmsg) +static virCommand * +nodeDeviceGetMdevctlCommand(virNodeDeviceDef *def, + virMdevctlCommand cmd_type, + char **outbuf, + char **errbuf) { - virCommand *cmd; - g_autofree char *json =3D NULL; - g_autofree char *parent_addr =3D nodeDeviceFindAddressByName(def->pare= nt); - - if (!parent_addr) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to find parent device '%s'"), def->parent= ); - return NULL; + g_autofree char *parent_addr =3D NULL; + virCommand *cmd =3D NULL; + const char *subcommand =3D virMdevctlCommandTypeToString(cmd_type); + g_autofree char *inbuf =3D NULL; + + switch (cmd_type) { + case MDEVCTL_CMD_CREATE: + /* now is the time to make sure "create" is replaced with "start" = on + * mdevctl cmdline */ + cmd =3D virCommandNewArgList(MDEVCTL, "start", NULL); + break; + case MDEVCTL_CMD_STOP: + case MDEVCTL_CMD_START: + case MDEVCTL_CMD_DEFINE: + case MDEVCTL_CMD_UNDEFINE: + cmd =3D virCommandNewArgList(MDEVCTL, subcommand, NULL); + break; + case MDEVCTL_CMD_LAST: + default: + /* SHOULD NEVER HAPPEN */ + break; } =20 - if (nodeDeviceDefToMdevctlConfig(def, &json) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("couldn't convert node device def to mdevctl JSON= ")); - return NULL; - } + switch (cmd_type) { + case MDEVCTL_CMD_CREATE: + case MDEVCTL_CMD_DEFINE: + parent_addr =3D nodeDeviceFindAddressByName(def->parent); =20 - cmd =3D virCommandNewArgList(MDEVCTL, subcommand, NULL); - virCommandAddArgPair(cmd, "--parent", parent_addr); - virCommandAddArgPair(cmd, "--jsonfile", "/dev/stdin"); + if (!parent_addr) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to find parent device '%s'"), def->pa= rent); + return NULL; + } + + if (nodeDeviceDefToMdevctlConfig(def, &inbuf) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("couldn't convert node device def to mdevctl = JSON")); + return NULL; + } =20 - virCommandSetInputBuffer(cmd, json); + virCommandAddArgPair(cmd, "--parent", parent_addr); + virCommandAddArgPair(cmd, "--jsonfile", "/dev/stdin"); + + virCommandSetInputBuffer(cmd, inbuf); + virCommandSetOutputBuffer(cmd, outbuf); + break; + + case MDEVCTL_CMD_UNDEFINE: + case MDEVCTL_CMD_STOP: + case MDEVCTL_CMD_START: + /* No special handling here, we only need to pass UUID with these = */ + break; + case MDEVCTL_CMD_LAST: + default: + /* SHOULD NEVER HAPPEN */ + break; + } =20 + /* Fill in UUID for commands that need it */ if (def->caps->data.mdev.uuid) virCommandAddArgPair(cmd, "--uuid", def->caps->data.mdev.uuid); =20 - virCommandSetOutputBuffer(cmd, uuid_out); - virCommandSetErrorBuffer(cmd, errmsg); + virCommandSetErrorBuffer(cmd, errbuf); =20 return cmd; } @@ -747,8 +780,7 @@ nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def, char **uuid_out, char **errmsg) { - return nodeDeviceGetMdevctlDefineCreateCommand(def, "start", uuid_out, - errmsg); + return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_CREATE, uuid_out, = errmsg); } =20 virCommand* @@ -756,8 +788,7 @@ nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def, char **uuid_out, char **errmsg) { - return nodeDeviceGetMdevctlDefineCreateCommand(def, "define", uuid_out, - errmsg); + return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_DEFINE, uuid_out, = errmsg); } =20 =20 @@ -891,31 +922,24 @@ nodeDeviceCreateXML(virConnectPtr conn, =20 =20 virCommand * -nodeDeviceGetMdevctlStopCommand(const char *uuid, char **errmsg) +nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def, + char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "stop", NULL); - virCommandAddArgPair(cmd, "--uuid", uuid); - virCommandSetErrorBuffer(cmd, errmsg); - return cmd; - + return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_STOP, NULL, errmsg= ); } =20 virCommand * -nodeDeviceGetMdevctlUndefineCommand(const char *uuid, char **errmsg) +nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def, + char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "undefine", NULL); - virCommandAddArgPair(cmd, "--uuid", uuid); - virCommandSetErrorBuffer(cmd, errmsg); - return cmd; + return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_UNDEFINE, NULL, er= rmsg); } =20 virCommand * -nodeDeviceGetMdevctlStartCommand(const char *uuid, char **errmsg) +nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, + char **errmsg) { - virCommand *cmd =3D virCommandNewArgList(MDEVCTL, "start", NULL); - virCommandAddArgPair(cmd, "--uuid", uuid); - virCommandSetErrorBuffer(cmd, errmsg); - return cmd; + return nodeDeviceGetMdevctlCommand(def, MDEVCTL_CMD_START, NULL, errms= g); } =20 static int @@ -924,7 +948,7 @@ virMdevctlStop(virNodeDeviceDef *def, char **errmsg) int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid, err= msg); + cmd =3D nodeDeviceGetMdevctlStopCommand(def, errmsg); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; @@ -939,8 +963,7 @@ virMdevctlUndefine(virNodeDeviceDef *def, char **errmsg) int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlUndefineCommand(def->caps->data.mdev.uuid, - errmsg); + cmd =3D nodeDeviceGetMdevctlUndefineCommand(def, errmsg); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) return -1; @@ -955,7 +978,7 @@ virMdevctlStart(virNodeDeviceDef *def, char **errmsg) int status; g_autoptr(virCommand) cmd =3D NULL; =20 - cmd =3D nodeDeviceGetMdevctlStartCommand(def->caps->data.mdev.uuid, er= rmsg); + cmd =3D nodeDeviceGetMdevctlStartCommand(def, errmsg); =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 d06efbf354..105a71dd93 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -152,11 +152,11 @@ nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *d= ef, char **errmsg); =20 virCommand * -nodeDeviceGetMdevctlStopCommand(const char *uuid, +nodeDeviceGetMdevctlStopCommand(virNodeDeviceDef *def, char **errmsg); =20 virCommand * -nodeDeviceGetMdevctlUndefineCommand(const char *uuid, +nodeDeviceGetMdevctlUndefineCommand(virNodeDeviceDef *def, char **errmsg); =20 virCommand * @@ -181,7 +181,7 @@ bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst, virNodeDeviceDef *src); =20 virCommand* -nodeDeviceGetMdevctlStartCommand(const char *uuid, +nodeDeviceGetMdevctlStartCommand(virNodeDeviceDef *def, char **errmsg); =20 int diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index cf8de852a8..188bad6e53 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -115,7 +115,7 @@ testMdevctlCreateOrDefineHelper(const void *data) mdevxml, cmdlinefile, jsonfile); } =20 -typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **err= buf); +typedef virCommand* (*GetStopUndefineCmdFunc)(virNodeDeviceDef *def, char = **errbuf); struct UuidCommandTestInfo { const char *filename; virMdevctlCommand command; @@ -136,7 +136,7 @@ testMdevctlUuidCommand(GetStopUndefineCmdFunc func, if (!(def =3D virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEM= U"))) goto cleanup; =20 - cmd =3D func(def->caps->data.mdev.uuid, &errmsg); + cmd =3D func(def, &errmsg); =20 if (!cmd) goto cleanup; --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 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 From nobody Thu May 16 20:49:29 2024 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=1618346431; cv=none; d=zohomail.com; s=zohoarc; b=T8tvM9v8s02+bus02hY5UwcB1zQxSCsQJJ2+jyF1vVwQBO/uBvC+eTqAlO2BPGFZTUZtmIaTZQ74yrdpunK0gC12/WQ5fDYdAKJ8PT0qzyKxUYTa5DsDY0SvILQLRxS4PZH/uKvDCxWZUJAXUuR5CY90IQaSHRt+P+TY2Hx+MGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346431; h=Content-Type:Content-Transfer-Encoding:Cc: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=m58ly33yR7YRz64kYVupqwy4tK8ZJeivDpnezV7tEMs=; b=OJXW7IoCsSzNgjhIOg6TNQSXTE5fn634TEsUxikl3frZhLgbun2uPHZ422ory3354zhtwAxz8yJfrl7Mfj1/91bnKBUcG9miSm3hBQK4LOdGOqdXYgWK7VldzHlF/JsON8OB2Tk/GvRiSXuXA7fmChlpZyaI5GFKkk0S+92U3yU= 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 1618346431135610.6167321797795; Tue, 13 Apr 2021 13:40:31 -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-134-drrrdTLjOeK_xOLa4J-_2g-1; Tue, 13 Apr 2021 16:40:26 -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 A4E8B84B9AF; Tue, 13 Apr 2021 20:40:20 +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 878D35B698; Tue, 13 Apr 2021 20:40:20 +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 4EA285534C; Tue, 13 Apr 2021 20:40:20 +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 13DKduL2011724 for ; Tue, 13 Apr 2021 16:39:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FADF1975E; Tue, 13 Apr 2021 20:39:56 +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 E57A01972B; 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=1618346429; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=m58ly33yR7YRz64kYVupqwy4tK8ZJeivDpnezV7tEMs=; b=CtS6MFuODpDejuUVa9CxG4QWaFZsaD/dYz8mBXSZrNTUjFkCmJh0f/gyLGafMNlg7o0+RQ Mc0SM3QAY+iiHSlR8MmnSedxL8BWYad7l/aBii4cZD0A/MhQ5BVllnTprT/j7wA6FqQY2G /xa+GpepX2UuYd6m2W3UqQf7fSHRHgM= X-MC-Unique: drrrdTLjOeK_xOLa4J-_2g-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 09/12] tests: nodedev: Make the mdevctl test function and helper generic Date: Tue, 13 Apr 2021 15:39:45 -0500 Message-Id: <20210413203948.71864-10-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 Cc: Erik Skultety 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" From: Erik Skultety Now that we have a generic mdevctl command generator, we can unify the test infrastructure as well. Signed-off-by: Erik Skultety Reviewed-by: Laine Stump --- ...19_36ea_4111_8f0a_8c9a70e21366-start.argv} | 0 ...019_36ea_4111_8f0a_8c9a70e21366-stop.argv} | 0 ...36ea_4111_8f0a_8c9a70e21366-undefine.argv} | 0 tests/nodedevmdevctltest.c | 120 +++++------------- 4 files changed, 31 insertions(+), 89 deletions(-) rename tests/nodedevmdevctldata/{mdevctl-start.argv =3D> mdev_d069d019_36e= a_4111_8f0a_8c9a70e21366-start.argv} (100%) rename tests/nodedevmdevctldata/{mdevctl-stop.argv =3D> mdev_d069d019_36ea= _4111_8f0a_8c9a70e21366-stop.argv} (100%) rename tests/nodedevmdevctldata/{mdevctl-undefine.argv =3D> mdev_d069d019_= 36ea_4111_8f0a_8c9a70e21366-undefine.argv} (100%) diff --git a/tests/nodedevmdevctldata/mdevctl-start.argv b/tests/nodedevmde= vctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-start.argv similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-start.argv rename to tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2136= 6-start.argv diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdev= ctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-stop.argv similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-stop.argv rename to tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2136= 6-stop.argv diff --git a/tests/nodedevmdevctldata/mdevctl-undefine.argv b/tests/nodedev= mdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-undefine.argv similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-undefine.argv rename to tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2136= 6-undefine.argv diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 64ce7fec46..bba521e563 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,7 +10,7 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 -struct startTestInfo { +struct TestInfo { const char *virt_type; int create; const char *filename; @@ -32,24 +32,24 @@ testCommandDryRunCallback(const char *const*args G_GNUC= _UNUSED, *stdinbuf =3D g_strdup(input); } =20 -typedef virCommand* (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char **= ); +typedef virCommand * (*MdevctlCmdFunc)(virNodeDeviceDef *, char **, char *= *); =20 =20 static int -testMdevctlCreateOrDefine(const char *virt_type, - int create, - virMdevctlCommand cmd_type, - const char *mdevxml, - const char *cmdfile, - const char *jsonfile) +testMdevctlCmd(const char *virt_type, + int create, + virMdevctlCommand cmd_type, + const char *mdevxml, + const char *cmdfile, + const char *jsonfile) { g_autoptr(virNodeDeviceDef) def =3D NULL; virNodeDeviceObj *obj =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; - g_autofree char *uuid =3D NULL; - g_autofree char *errmsg =3D NULL; + g_autofree char *outbuf =3D NULL; + g_autofree char *errbuf =3D NULL; g_autofree char *stdinbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); @@ -59,12 +59,17 @@ 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 nodeDeviceGetMdevctlCommand(def, cmd_type, &uuid, &errmsg); + cmd =3D nodeDeviceGetMdevctlCommand(def, cmd_type, &outbuf, &errbuf); =20 if (!cmd) goto cleanup; =20 - virCommandSetDryRun(dryRunToken, &buf, true, true, testCommandDryRunCa= llback, &stdinbuf); + if (create) + virCommandSetDryRun(dryRunToken, &buf, true, true, + testCommandDryRunCallback, &stdinbuf); + else + virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 @@ -74,7 +79,7 @@ testMdevctlCreateOrDefine(const char *virt_type, if (virTestCompareToFileFull(actualCmdline, cmdfile, false) < 0) goto cleanup; =20 - if (virTestCompareToFile(stdinbuf, jsonfile) < 0) + if (create && virTestCompareToFile(stdinbuf, jsonfile) < 0) goto cleanup; =20 ret =3D 0; @@ -84,10 +89,11 @@ testMdevctlCreateOrDefine(const char *virt_type, return ret; } =20 + static int -testMdevctlCreateOrDefineHelper(const void *data) +testMdevctlHelper(const void *data) { - const struct startTestInfo *info =3D data; + const struct TestInfo *info =3D data; const char *cmd =3D virMdevctlCommandTypeToString(info->command); g_autofree char *mdevxml =3D NULL; g_autofree char *cmdlinefile =3D NULL; @@ -100,67 +106,10 @@ 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, info->= command, - mdevxml, cmdlinefile, jsonfile); -} - -typedef virCommand* (*GetStopUndefineCmdFunc)(virNodeDeviceDef *def, char = **errbuf); -struct UuidCommandTestInfo { - const char *filename; - virMdevctlCommand command; -}; - -static int -testMdevctlUuidCommand(virMdevctlCommand command, - const char *mdevxml, const char *outfile) -{ - g_autoptr(virNodeDeviceDef) def =3D NULL; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - const char *actualCmdline =3D NULL; - int ret =3D -1; - g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *errmsg =3D NULL; - g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); - - if (!(def =3D virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEM= U"))) - goto cleanup; - - cmd =3D nodeDeviceGetMdevctlCommand(def, command, NULL, &errmsg); - - if (!cmd) - goto cleanup; - - virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; - - if (!(actualCmdline =3D virBufferCurrentContent(&buf))) - goto cleanup; - - if (virTestCompareToFileFull(actualCmdline, outfile, false) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - return ret; + return testMdevctlCmd(info->virt_type, info->create, info->command, + mdevxml, cmdlinefile, jsonfile); } =20 -static int -testMdevctlUuidCommandHelper(const void *data) -{ - const struct UuidCommandTestInfo *info =3D data; - const char *cmd =3D virMdevctlCommandTypeToString(info->command); - g_autofree char *cmdlinefile =3D NULL; - g_autofree char *mdevxml =3D NULL; - - 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); - - return testMdevctlUuidCommand(info->command, mdevxml, cmdlinefile); -} =20 static int testMdevctlListDefined(const void *data G_GNUC_UNUSED) @@ -369,35 +318,28 @@ mymain(void) =20 #define DO_TEST_CMD(desc, virt_type, create, filename, command) \ do { \ - struct startTestInfo info =3D { virt_type, create, filename, comma= nd }; \ - DO_TEST_FULL(desc, testMdevctlCreateOrDefineHelper, &info); \ + struct TestInfo info =3D { virt_type, create, filename, command };= \ + DO_TEST_FULL(desc, testMdevctlHelper, &info); \ } \ while (0) =20 #define DO_TEST_CREATE(filename) \ - DO_TEST_CMD("mdevctl create " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_CREATE) + DO_TEST_CMD("create mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_CREATE) =20 #define DO_TEST_DEFINE(filename) \ - DO_TEST_CMD("mdevctl define " filename, "QEMU", CREATE_DEVICE, filenam= e, MDEVCTL_CMD_DEFINE) - -#define DO_TEST_UUID_COMMAND_FULL(desc, filename, command) \ - do { \ - struct UuidCommandTestInfo info =3D { filename, command }; \ - DO_TEST_FULL(desc, testMdevctlUuidCommandHelper, &info); \ - } \ - while (0) + DO_TEST_CMD("define mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_DEFINE) =20 #define DO_TEST_STOP(filename) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl stop " filename, filename, MDEVCTL_= CMD_STOP) + DO_TEST_CMD("stop mdev " filename, "QEMU", EXISTING_DEVICE, filename, = MDEVCTL_CMD_STOP) =20 #define DO_TEST_UNDEFINE(filename) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEV= CTL_CMD_UNDEFINE) + DO_TEST_CMD("undefine mdev" filename, "QEMU", EXISTING_DEVICE, filenam= e, MDEVCTL_CMD_UNDEFINE) =20 #define DO_TEST_START(filename) \ - DO_TEST_UUID_COMMAND_FULL("mdevctl start " filename, filename, MDEVCTL= _CMD_START) + DO_TEST_CMD("start mdev " filename, "QEMU", EXISTING_DEVICE, filename,= MDEVCTL_CMD_START) =20 #define DO_TEST_LIST_DEFINED() \ - DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL) + DO_TEST_FULL("list defined mdevs", testMdevctlListDefined, NULL) =20 #define DO_TEST_PARSE_JSON(filename) \ DO_TEST_FULL("parse mdevctl json " filename, testMdevctlParse, filenam= e) --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 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=1618346431; cv=none; d=zohomail.com; s=zohoarc; b=DA5NDGUR8w1UdDDklQzYR+xOu2RWGiW7z66eRPX2p6aaOBxugMdaiatihWIa51nXUDvKfOffZFopBlOtT2Iyek67s6C94JI3GObUIlCoti4g0dUL8oGyMlg3eoSxfZeiYEqSwpRwEdTwvkmswa7p2Kn0hpFIAzi51Xlct+0cV60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346431; 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=5+Yx8nMe25AR+YvThmZya6qaYblk9Qbw0ljbMM7asZY=; b=FA74AEJjv4/5b87fHO2iTt6Z8HCo0mWNoY3JnIZueKoRvHarHEiTCmxRyijGTMXMcUSL/8GrMvZ8u3WgOSBgLQ2OYQM6NcPwpqHkHgfm8BFTuo24mQM9YfXQemC8siUsadOcUhalgRFhA2Uv5EMwwKiTTBE1rn8nAyO9p4WA34k= 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 161834643195038.98553043593495; Tue, 13 Apr 2021 13:40:31 -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-276-l7Quns0LPhSeGm_smcL9yA-1; Tue, 13 Apr 2021 16:40:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F758C73A4; Tue, 13 Apr 2021 20:40:23 +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 6579119744; Tue, 13 Apr 2021 20:40:23 +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 220131806D20; Tue, 13 Apr 2021 20:40:23 +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 13DKdufl011729 for ; Tue, 13 Apr 2021 16:39:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E48F19744; Tue, 13 Apr 2021 20:39:56 +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 4ED071972B for ; Tue, 13 Apr 2021 20:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346430; 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=5+Yx8nMe25AR+YvThmZya6qaYblk9Qbw0ljbMM7asZY=; b=M1KiTbkRGuokZWVEkGJF3awsox1yF6AGM/+UiqOqNpv91N0WKtwEveZ52PHy5NahWylkjB ltm5JsHXkNNEMpU8PdJ/L1yDtn8gsDZunxRtBuV2Qw/G75zfv+jNUrIpju5OBVSCWpG8Lt ht73nWxhoASHrs3Ec+yucRYZb3YjZls= X-MC-Unique: l7Quns0LPhSeGm_smcL9yA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 10/12] tests: nodedev: simplify test macros Date: Tue, 13 Apr 2021 15:39:46 -0500 Message-Id: <20210413203948.71864-11-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.84 on 10.5.11.23 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" We only use the virt_type "QEMU" in this tests, so simply hard-code it in the test function rather than specifying it in the test macro. In addition, we can figure out the appropriate value for 'create' from the command type, so push that into the test function rather than specifying it in the test macro. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tests/nodedevmdevctltest.c | 43 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index bba521e563..4c316e3ed0 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -10,9 +10,9 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 +#define VIRT_TYPE "QEMU" + struct TestInfo { - const char *virt_type; - int create; const char *filename; virMdevctlCommand command; }; @@ -36,9 +36,7 @@ typedef virCommand * (*MdevctlCmdFunc)(virNodeDeviceDef *= , char **, char **); =20 =20 static int -testMdevctlCmd(const char *virt_type, - int create, - virMdevctlCommand cmd_type, +testMdevctlCmd(virMdevctlCommand cmd_type, const char *mdevxml, const char *cmdfile, const char *jsonfile) @@ -53,8 +51,24 @@ testMdevctlCmd(const char *virt_type, g_autofree char *stdinbuf =3D NULL; g_autoptr(virCommand) cmd =3D NULL; g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + int create; + + switch (cmd_type) { + case MDEVCTL_CMD_CREATE: + case MDEVCTL_CMD_DEFINE: + create =3D CREATE_DEVICE; + break; + case MDEVCTL_CMD_START: + case MDEVCTL_CMD_STOP: + case MDEVCTL_CMD_UNDEFINE: + create =3D EXISTING_DEVICE; + break; + case MDEVCTL_CMD_LAST: + default: + goto cleanup; + } =20 - if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, virt_type))) + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, VIRT_TYPE))) goto cleanup; =20 /* this function will set a stdin buffer containing the json configura= tion @@ -106,8 +120,7 @@ testMdevctlHelper(const void *data) jsonfile =3D g_strdup_printf("%s/nodedevmdevctldata/%s-%s.json", abs_s= rcdir, info->filename, cmd); =20 - return testMdevctlCmd(info->virt_type, info->create, info->command, - mdevxml, cmdlinefile, jsonfile); + return testMdevctlCmd(info->command, mdevxml, cmdlinefile, jsonfile); } =20 =20 @@ -316,27 +329,27 @@ mymain(void) if (virTestRun(desc, func, info) < 0) \ ret =3D -1; =20 -#define DO_TEST_CMD(desc, virt_type, create, filename, command) \ +#define DO_TEST_CMD(desc, filename, command) \ do { \ - struct TestInfo info =3D { virt_type, create, filename, command };= \ + struct TestInfo info =3D { filename, command }; \ DO_TEST_FULL(desc, testMdevctlHelper, &info); \ } \ while (0) =20 #define DO_TEST_CREATE(filename) \ - DO_TEST_CMD("create mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_CREATE) + DO_TEST_CMD("create mdev " filename, filename, MDEVCTL_CMD_CREATE) =20 #define DO_TEST_DEFINE(filename) \ - DO_TEST_CMD("define mdev " filename, "QEMU", CREATE_DEVICE, filename, = MDEVCTL_CMD_DEFINE) + DO_TEST_CMD("define mdev " filename, filename, MDEVCTL_CMD_DEFINE) =20 #define DO_TEST_STOP(filename) \ - DO_TEST_CMD("stop mdev " filename, "QEMU", EXISTING_DEVICE, filename, = MDEVCTL_CMD_STOP) + DO_TEST_CMD("stop mdev " filename, filename, MDEVCTL_CMD_STOP) =20 #define DO_TEST_UNDEFINE(filename) \ - DO_TEST_CMD("undefine mdev" filename, "QEMU", EXISTING_DEVICE, filenam= e, MDEVCTL_CMD_UNDEFINE) + DO_TEST_CMD("undefine mdev" filename, filename, MDEVCTL_CMD_UNDEFINE) =20 #define DO_TEST_START(filename) \ - DO_TEST_CMD("start mdev " filename, "QEMU", EXISTING_DEVICE, filename,= MDEVCTL_CMD_START) + DO_TEST_CMD("start mdev " filename, filename, MDEVCTL_CMD_START) =20 #define DO_TEST_LIST_DEFINED() \ DO_TEST_FULL("list defined mdevs", testMdevctlListDefined, NULL) --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346435; cv=none; d=zohomail.com; s=zohoarc; b=VhC9JvmvJrHaJ1Fpql2dJMN5LbipXMhrotN1FbFCEqSQvjI4w/CrlWFIJgYfZ1YQ0w7qLpWabMiFR/SLO0hw93OdaEkeqZmn8siZczGpExWggJ0dRz+bZ4OhlrjXFjTH4fxGVFGCAutxw6zlPqThKpLfhzFySzy8Y/TDQaaphHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346435; 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=niTB+K4qR375Z0eAUaqVgen+ZS9po+c/1zsB6sHAD3Y=; b=Pf8NZRn5XY8qoxzNbnCOOl5ygGqkVkVwPajcX5wu3AmdZTSiGyd4glPU8v/gn/KG/agDrj9vWjoj7h4rOwh/w+CURKIZmppikFt4UcU8S3PdeyuzEj6IpRSSy7u97FZuExBu7VHP3yfup/8/Bmx+6Ww8g7vu9WcAi6awi4SDv8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346435580292.0027875646899; Tue, 13 Apr 2021 13:40:35 -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-487-2dlnWaAlOAWB5bfnyKv9XA-1; Tue, 13 Apr 2021 16:40:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 524F51922966; Tue, 13 Apr 2021 20:40:26 +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 0533460C04; Tue, 13 Apr 2021 20:40:26 +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 C35C75534F; Tue, 13 Apr 2021 20:40:25 +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 13DKdusk011735 for ; Tue, 13 Apr 2021 16:39:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDCCD19744; Tue, 13 Apr 2021 20:39:56 +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 9E1B41972B for ; Tue, 13 Apr 2021 20:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346434; 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=niTB+K4qR375Z0eAUaqVgen+ZS9po+c/1zsB6sHAD3Y=; b=YjtfFAef59kuJPBg80HV6GEKuVZl3BN8NocIJ5e3qW6JfVrti4c3VozC6lwLOqCw7nWQuM +FeMzQU/XbK7HVEd3FNw8c6NzZpPAgow+ilFg/DCk+xnrBx1EDls0hjqRwrOB58axQXOZP KVyAVKI3oSc8QTsFjpO3DQK18fRQNi4= X-MC-Unique: 2dlnWaAlOAWB5bfnyKv9XA-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 11/12] tests: nodedev: remove unused variable Date: Tue, 13 Apr 2021 15:39:47 -0500 Message-Id: <20210413203948.71864-12-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.12 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" This variable was leftover from previous changes but is no longer used. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tests/nodedevmdevctltest.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 4c316e3ed0..65286761c1 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -42,7 +42,6 @@ testMdevctlCmd(virMdevctlCommand cmd_type, const char *jsonfile) { g_autoptr(virNodeDeviceDef) def =3D NULL; - virNodeDeviceObj *obj =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; @@ -99,7 +98,6 @@ testMdevctlCmd(virMdevctlCommand cmd_type, ret =3D 0; =20 cleanup: - virNodeDeviceObjEndAPI(&obj); return ret; } =20 --=20 2.26.3 From nobody Thu May 16 20:49:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618346428; cv=none; d=zohomail.com; s=zohoarc; b=ElI3k15B1ZNLzp4eSxG+3fKCrIbeCIFva3hw7rw+V51bfPXAkdGHbYZjfTCd7b7VCgMHOYhJdh+icFiRq5Foqo060xCHSn2E0rf+u8e7rzgNtjsM+IsIaNI9ISW2WbnZBHxvNZ/aTT8idGtBp05uLSp181NXf6LcOtmd/GoEVvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618346428; 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=Y7VwlBmxWZcxI83GFU50FnZl0XuTKyBy0q1hGvvJlis=; b=Pk+5xJGEfSRrGP7IHSpJuF0Fxp1MJ8WJ/j2ismkyjBrNcJTx8g+oOxNKc0bnblMvGxCWFxZX9uAf52r22R/DlzYWZa/Cqh21XLV8Z+vxjpMQgiUDKtyzqFcbf/SMJ3Q3cvmYAyIIDV8WX8RiU1ZZT8yYrJkPpPTkOxjhPv/2tuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618346428497870.0900267622926; Tue, 13 Apr 2021 13:40:28 -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-241-K0HewiL-N9mGTzOkC2s4KQ-1; Tue, 13 Apr 2021 16:40:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE3CF1005E6B; Tue, 13 Apr 2021 20:40:18 +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 C1A106E419; Tue, 13 Apr 2021 20:40:18 +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 8B0051806D1D; Tue, 13 Apr 2021 20:40:18 +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 13DKdv4K011741 for ; Tue, 13 Apr 2021 16:39:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A43A19744; Tue, 13 Apr 2021 20:39:57 +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 EEF131972B for ; Tue, 13 Apr 2021 20:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618346427; 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=Y7VwlBmxWZcxI83GFU50FnZl0XuTKyBy0q1hGvvJlis=; b=cn8R56QGT3ZxyorqgqMpxO2gsZInaNfMr9jii/eT0SWocKf88QH5pM2cE1aOKMhDmc43sg mxkDBICuiQ1ZoQH5sgBYGx9HTg07XlV9BUqFRxXA7JnnEraYoJnPEshImytXn1i0wUeMqk TraTqJwmSPfV+uJSJ7vLcxhedZABzTg= X-MC-Unique: K0HewiL-N9mGTzOkC2s4KQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 12/12] tests: nodedev: remove unnecessary cleanup label Date: Tue, 13 Apr 2021 15:39:48 -0500 Message-Id: <20210413203948.71864-13-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.13 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" Now that the last cleanup task was removed in the previous commit, just remove the label and return early on error rather than goto cleanup. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety --- tests/nodedevmdevctltest.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 65286761c1..8ba1d2da70 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -44,7 +44,6 @@ testMdevctlCmd(virMdevctlCommand cmd_type, g_autoptr(virNodeDeviceDef) def =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; - int ret =3D -1; g_autofree char *outbuf =3D NULL; g_autofree char *errbuf =3D NULL; g_autofree char *stdinbuf =3D NULL; @@ -64,18 +63,18 @@ testMdevctlCmd(virMdevctlCommand cmd_type, break; case MDEVCTL_CMD_LAST: default: - goto cleanup; + return -1; } =20 if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, VIRT_TYPE))) - goto cleanup; + return -1; =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 nodeDeviceGetMdevctlCommand(def, cmd_type, &outbuf, &errbuf); =20 if (!cmd) - goto cleanup; + return -1; =20 if (create) virCommandSetDryRun(dryRunToken, &buf, true, true, @@ -84,21 +83,18 @@ testMdevctlCmd(virMdevctlCommand cmd_type, virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL); =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 if (!(actualCmdline =3D virBufferCurrentContent(&buf))) - goto cleanup; + return -1; =20 if (virTestCompareToFileFull(actualCmdline, cmdfile, false) < 0) - goto cleanup; + return -1; =20 if (create && virTestCompareToFile(stdinbuf, jsonfile) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 --=20 2.26.3