From nobody Mon Feb 9 16:32:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1591739108; cv=none; d=zohomail.com; s=zohoarc; b=Vkc6v2CyoXHbjt9+ceOlXeAL07hoWXUHkyn8xpNps5KeuUPT64Rq3pYSBdX23CxBmDNS2lGs56qtYWogQv46TkipK+DYyLjMNGMhPf1mZOMl83blo+gybvGCL8E2Gh39TmRpz6NibOxs9HyySfVMJxi+5lFDauQxGQayLz0MqsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591739108; 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=z4WhAHiq0JPKmAGtAgOfNnJ+MQ9PAfg3u4j7PifPvrM=; b=SW7oh6qS0hUMrOVDGuANeaeM/gtaDXPldGFH3mNFpcsXa1l8U6KLsFRbLGMbrwl7BbiQN0HYP78zMJDUmNHespW+4Pha3hChtTRGVtNX3b+soz62FzkCES+I3Tx49r5WiA9onycrGf5SqzPII9zdoyWLY7jqOR+sDVaUJiTuo5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1591739108244261.94602960024383; Tue, 9 Jun 2020 14:45: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-38-1aZ2Dn5QMFSoOqEaeklvYw-1; Tue, 09 Jun 2020 17:44: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 A109010082F9; Tue, 9 Jun 2020 21:44: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 80FE48929B; Tue, 9 Jun 2020 21:44: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 53E94B34A9; Tue, 9 Jun 2020 21:44:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 059LhuQH030117 for ; Tue, 9 Jun 2020 17:43:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 308BD7BFE9; Tue, 9 Jun 2020 21:43:56 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-115-112.phx2.redhat.com [10.3.115.112]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03BC97BFE3 for ; Tue, 9 Jun 2020 21:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591739107; 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=z4WhAHiq0JPKmAGtAgOfNnJ+MQ9PAfg3u4j7PifPvrM=; b=WatOL8wm2iXuDOY3BVS3AR2f6bY6UxidTxqp0+TwV1bvOGq8iqkR3OgDVyIzjLI1k8i470 8HjePjh5rEdNuaDwYv4yrcEnFRlM4aBtk0MLOLgMBZtzpWWHdZnJMt4T9XorRFkyL8m3WV CkYhKndoqeNmvz6IfPCjlyHjMNixtCg= X-MC-Unique: 1aZ2Dn5QMFSoOqEaeklvYw-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/10] nodedev: add mdev support to virNodeDeviceDestroy() Date: Tue, 9 Jun 2020 16:43:48 -0500 Message-Id: <20200609214350.14156-9-jjongsma@redhat.com> In-Reply-To: <20200609214350.14156-1-jjongsma@redhat.com> References: <20200609214350.14156-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 | 46 ++++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 3 ++ 2 files changed, 49 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index dbc7eb4d1e..c956bb55fc 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -790,6 +790,45 @@ nodeDeviceCreateXML(virConnectPtr conn, } =20 =20 +virCommandPtr +nodeDeviceGetMdevctlStopCommand(const char *uuid, + bool persist) +{ + g_autofree char *mdevctl =3D virFindFileInPath(MDEVCTL); + const char *subcommand; + + if (!mdevctl) + return NULL; + + if (persist) + subcommand =3D "undefine"; + else + subcommand =3D "stop"; + + virCommandPtr cmd =3D virCommandNewArgList(mdevctl, + subcommand, + "-u", + uuid, + NULL); + + return cmd; +} + +static int +virMdevctlStop(virNodeDeviceDefPtr def) +{ + int status; + g_autoptr(virCommand) cmd =3D NULL; + + cmd =3D nodeDeviceGetMdevctlStopCommand(def->caps->data.mdev.uuid, fal= se); + + if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + return -1; + + return 0; +} + + int nodeDeviceDestroy(virNodeDevicePtr device) { @@ -836,6 +875,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 576f75375f..794cb5dc1c 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -122,3 +122,6 @@ virCommandPtr nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def, bool persist, char **uuid_out); +virCommandPtr +nodeDeviceGetMdevctlStopCommand(const char *uuid, + bool persist); --=20 2.21.3