From nobody Mon Feb 9 21:37:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=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