From nobody Mon Feb 9 17:57:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1592514431; cv=none; d=zohomail.com; s=zohoarc; b=JYawfVKE+zJUCbj3LXHFY+ZmQdGuzNr8z5TW5R/2B+IVh+u6//5KdekcVuR5PuHHEIbLQxx61XnsmzSK+VRxUX0ZRTCK7wdbzZva7AHDvH5SKnilq4XLX/7oDIwVRbuyAuaWs/zB4Ml/UgWiXRlaaekPf5hYbad0DO8o3X5KAJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514431; 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=wZbprxEKWmK8bRxQVi8LU3nkrPGC28i9P40IGzrctNk=; b=NkWpOpsvta9q3zqxdoRh0cVAEg+TEz5Tc+XLjr4bZkfH8M1nW5j1iHuPQLRcIAacjmzdxoYUOx7X+FOT//H+vgivcxO9+xKIuNDXFQtRe+iKg9qG1ozYEu4VrZZyT1Bms5+XCx1+89cNdR31vP9YLtnVbKjrmM7cgHXX8bZtxtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1592514431122389.3343932525021; Thu, 18 Jun 2020 14:07:11 -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-113-CExRgxSMM1ukyZHrimKHuw-1; Thu, 18 Jun 2020 17:06:38 -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 2212E107ACF8; Thu, 18 Jun 2020 21:06:32 +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 F2CD319D61; Thu, 18 Jun 2020 21:06:31 +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 C10BB833D3; Thu, 18 Jun 2020 21:06:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05IL6DDO002579 for ; Thu, 18 Jun 2020 17:06:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id B12DC60E1C; Thu, 18 Jun 2020 21:06:13 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-114-51.phx2.redhat.com [10.3.114.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6362C60BF4; Thu, 18 Jun 2020 21:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514429; 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=wZbprxEKWmK8bRxQVi8LU3nkrPGC28i9P40IGzrctNk=; b=R7VtMojJd9+daPwF6s55L+WgqXJyPn8LqtR2eocdwshh1V3y8kit1MTqbckFbS+TQS6X62 y+zrcTMTA7Dy0GjFnhwjpEX/0Fup8pzQ0uHXTfI1Q3hKvpG9MDvM8IGFZmQC54NQJkLBBO VC/zYdcVesnC7acOK7od65oQsxXW0J8= X-MC-Unique: CExRgxSMM1ukyZHrimKHuw-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 09/12] nodedev: add mdev support to virNodeDeviceDestroy() Date: Thu, 18 Jun 2020 16:06:02 -0500 Message-Id: <20200618210605.12308-10-jjongsma@redhat.com> In-Reply-To: <20200618210605.12308-1-jjongsma@redhat.com> References: <20200618210605.12308-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, eskultet@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 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" Add the ability to destroy mdev node devices via the mdevctl utility. Signed-off-by: Jonathon Jongsma --- src/node_device/node_device_driver.c | 33 ++++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 35016782d2..e89c8b0ee5 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -786,6 +786,32 @@ nodeDeviceCreateXML(virConnectPtr conn, } =20 =20 +virCommandPtr +nodeDeviceGetMdevctlStopCommand(const char *uuid) +{ + return virCommandNewArgList(MDEVCTL, + "stop", + "-u", + uuid, + NULL); + +} + +static int +virMdevctlStop(virNodeDeviceDefPtr def) +{ + int status; + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid); + + if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + return -1; + + return 0; +} + + int nodeDeviceDestroy(virNodeDevicePtr device) { @@ -832,6 +858,13 @@ nodeDeviceDestroy(virNodeDevicePtr device) if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0) goto cleanup; =20 + ret =3D 0; + } else if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) { + if (virMdevctlStop(def) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to stop mediated device")); + goto cleanup; + } ret =3D 0; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index e42c14f6c7..be5d397828 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -121,3 +121,5 @@ nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr c= onn, virCommandPtr nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def, char **uuid_out); +virCommandPtr +nodeDeviceGetMdevctlStopCommand(const char *uuid); --=20 2.21.3