From nobody Sat Apr 27 02:32:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1592514386; cv=none; d=zohomail.com; s=zohoarc; b=D9+SSyKwuklcguRMEP7HOpjipeTAOnkvMwqMfTcRSMiJt9C8aaPXZjNeHtmxLEI4RTCE1QmGkwR2owxGEFFy7ck9tVBu5BBwu7Unegf59+Rt0B5bf5tIShUkRKTZHNbvY+ZuU4bdTpGE3dwRwcDBi7P52mXRXrKTHdcuK6tgN7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514386; 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=1qDLr37I6OEgzcGdqWEnxSJFN+bm0BRKGGlBGUhFrH8=; b=Ypbat2Enscm1hj4GSqieXpb6sWVOMhdqxexqFxHYfjs1ALnr36hZXLFNqHSUOlIDNZ22x292TWXTtpIJyC2LfjtDyFyU+Cyl9oMcFNKKUITnpfGl5xlYm3DAskB6Ecshw1Z3WMNMw/kv5MLiopNInoV1SSGlDBaH1FFIRkVr3U8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1592514386026709.4450549960669; Thu, 18 Jun 2020 14:06: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-390-YL-_QUF-OmGcO_ZOCBAHcw-1; Thu, 18 Jun 2020 17:06: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 4A317107ACCA; Thu, 18 Jun 2020 21:06: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 C576F60E1C; Thu, 18 Jun 2020 21:06: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 F0D3D833C1; Thu, 18 Jun 2020 21:06:11 +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 05IL6AB3002510 for ; Thu, 18 Jun 2020 17:06:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2E16360CD3; Thu, 18 Jun 2020 21:06:10 +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 D494E60E3E; Thu, 18 Jun 2020 21:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514384; 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=1qDLr37I6OEgzcGdqWEnxSJFN+bm0BRKGGlBGUhFrH8=; b=BJQ0pqTweqBa7GjQk+5LE0ObX+WvalbrUvytreKRa8HY+UgCh/Ep2iXj5UmYUvUn4FELTo 9w4s7O6UhuhvNhF6cWbz76ujfR3MWPcxjphCL+ypvpkRjW+nuJMVFEofCRZtBDyLmb26+I jShs4q7CX+fi6kTlBIGES59xn0saByE= X-MC-Unique: YL-_QUF-OmGcO_ZOCBAHcw-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 01/12] nodedev: make iommuGroup optional for mdevs Date: Thu, 18 Jun 2020 16:05:54 -0500 Message-Id: <20200618210605.12308-2-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.79 on 10.5.11.12 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" When parsing a nodedev xml file, the iommuGroup element should be optional. This element should be read-only and is determined by the device driver. While this is a change to existing behavior, it doesn't break backwards-compatibility because it makes the parser less strict. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- docs/formatnode.html.in | 5 +++-- docs/schemas/nodedev.rng | 12 +++++++----- src/conf/node_device_conf.c | 14 ++++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 76eae928de..4ed43ec0cb 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -390,8 +390,9 @@
iommuGroup
This element supports a single attribute number - which holds the IOMMU group number the mediated device bel= ongs - to. + which holds the IOMMU group number to which the mediated d= evice + belongs. This is a read-only field that is reported by the + device driver.
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index fe6ffa0b53..ca3a79db87 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -629,11 +629,13 @@ - - - - - + + + + + + + =20 diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index bccdbd0af8..2ef4514f05 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1775,13 +1775,15 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, goto out; } =20 - if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctx= t, - &mdev->iommuGroupNumber, def, - _("missing iommuGroup number attribute= for " - "'%s'"), - _("invalid iommuGroup number attribute= for " - "'%s'")) < 0) + /* 'iommuGroup' is optional, only report an error if the supplied valu= e is + * invalid (-2), not if it's missing (-1) */ + if (virXPathUInt("number(./iommuGroup[1]/@number)", + ctxt, &mdev->iommuGroupNumber) < -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid iommuGroup number attribute for '%s'"), + def->name); goto out; + } =20 ret =3D 0; out: --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514385; cv=none; d=zohomail.com; s=zohoarc; b=IkwUdn+lgciMGpuwuEEYx31Pfa9klESh+W5SImD/nms4aKBvQAtkr9j3kFHM0XdroLxwb3JC6awnMscIjfovbhz4sxxNZH+uY9QWsiiOxQX8PBKJbUzeUSF9jyEzD8LPBbyThTXgSCounQDzHAmk+4Dnt3zebT9iHTgpf1Z7Fg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514385; 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=N3hTaVGVwHUqmVte6DOVoXYX5lLb6NrzDQlJ+l2SDvM=; b=eT7snAOR9iHcCC94tvUbC9r/thoaoIb0VNIYJCHCb2GiJDo010d5I497adQVeS7kiMRzNZtTztB7PuJIIxzb7Hfbgef8XK0oMwk8WebxLerzwTd+OMX94iCKiBTHw/Gr5Gjx5L6wWs5efC7QziqkUy1AjuXixkCgxJ9RrrpKvyk= 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 1592514385000371.6782453232712; Thu, 18 Jun 2020 14:06:25 -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-376-5pwRVfPWMhWy_eIzUUQ-MQ-1; Thu, 18 Jun 2020 17:06:21 -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 7CBE7107ACF2; Thu, 18 Jun 2020 21:06:15 +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 5F0FC71666; Thu, 18 Jun 2020 21:06: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 F0D78180954D; Thu, 18 Jun 2020 21:06:11 +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 05IL6AEo002520 for ; Thu, 18 Jun 2020 17:06:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97CA060CD3; Thu, 18 Jun 2020 21:06:10 +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 4A84F60BF4; Thu, 18 Jun 2020 21:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514383; 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=N3hTaVGVwHUqmVte6DOVoXYX5lLb6NrzDQlJ+l2SDvM=; b=aYXcC1o/Mya0Rw4ak4q+3lYlTxlNLbe4fwcfNLSRD5mYve9PYzDMiMp7aYaHk9Hg42y5wT FLoKUkeCmhJo/X9lmW+ies/JqrMJEIw/fMOcn3Ykyuv/E/eSCr7MS32Q3iKmFlnpWlanRZ OBjhunQpYM8uD6xjSxJuxWRglS9mrE8= X-MC-Unique: 5pwRVfPWMhWy_eIzUUQ-MQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 02/12] nodedev: factor out nodeDeviceHasCapability() Date: Thu, 18 Jun 2020 16:05:55 -0500 Message-Id: <20200618210605.12308-3-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.79 on 10.5.11.11 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" Currently nodeDeviceCreateXML() and nodeDeviceDestroy() only support NPIV HBAs, but we want to be able to create mdev devices as well. This is a first step to enabling that support. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- src/node_device/node_device_driver.c | 91 ++++++++++++++++++---------- 1 file changed, 58 insertions(+), 33 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ee175e1095..ba7ea50e5b 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -488,6 +488,21 @@ nodeDeviceFindNewDevice(virConnectPtr conn, } =20 =20 +static bool +nodeDeviceHasCapability(virNodeDeviceDefPtr def, virNodeDevCapType type) +{ + virNodeDevCapsDefPtr cap =3D def->caps; + + while (cap !=3D NULL) { + if (cap->data.type =3D=3D type) + return true; + cap =3D cap->next; + } + + return false; +} + + virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn, const char *xmlDesc, @@ -513,24 +528,29 @@ nodeDeviceCreateXML(virConnectPtr conn, if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0) return NULL; =20 - if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) =3D=3D -1) - return NULL; + if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_SCSI_HOST)) { + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) =3D=3D -1) + return NULL; =20 - if ((parent_host =3D virNodeDeviceObjListGetParentHost(driver->devs, d= ef)) < 0) - return NULL; + if ((parent_host =3D virNodeDeviceObjListGetParentHost(driver->dev= s, def)) < 0) + return NULL; =20 - if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0) - return NULL; + if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0) + return NULL; =20 - device =3D nodeDeviceFindNewDevice(conn, wwnn, wwpn); - /* We don't check the return value, because one way or another, - * we're returning what we get... */ + device =3D nodeDeviceFindNewDevice(conn, wwnn, wwpn); + /* We don't check the return value, because one way or another, + * we're returning what we get... */ =20 - if (device =3D=3D NULL) - virReportError(VIR_ERR_NO_NODE_DEVICE, - _("no node device for '%s' with matching " - "wwnn '%s' and wwpn '%s'"), - def->name, wwnn, wwpn); + if (device =3D=3D NULL) + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("no node device for '%s' with matching " + "wwnn '%s' and wwpn '%s'"), + def->name, wwnn, wwpn); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unsupported device type")); + } =20 return device; } @@ -557,31 +577,36 @@ nodeDeviceDestroy(virNodeDevicePtr device) if (virNodeDeviceDestroyEnsureACL(device->conn, def) < 0) goto cleanup; =20 - if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) < 0) - goto cleanup; + if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_SCSI_HOST)) { + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) < 0) + goto cleanup; =20 - /* Because we're about to release the lock and thus run into a race - * possibility (however improbable) with a udevAddOneDevice change - * event which would essentially free the existing @def (obj->def) and - * replace it with something new, we need to grab the parent field - * and then find the parent obj in order to manage the vport */ - parent =3D g_strdup(def->parent); + /* Because we're about to release the lock and thus run into a race + * possibility (however improbable) with a udevAddOneDevice change + * event which would essentially free the existing @def (obj->def)= and + * replace it with something new, we need to grab the parent field + * and then find the parent obj in order to manage the vport */ + parent =3D g_strdup(def->parent); =20 - virNodeDeviceObjEndAPI(&obj); + virNodeDeviceObjEndAPI(&obj); =20 - if (!(obj =3D virNodeDeviceObjListFindByName(driver->devs, parent))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find parent '%s' definition"), parent); - goto cleanup; - } + if (!(obj =3D virNodeDeviceObjListFindByName(driver->devs, parent)= )) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot find parent '%s' definition"), parent= ); + goto cleanup; + } =20 - if (virSCSIHostGetNumber(parent, &parent_host) < 0) - goto cleanup; + if (virSCSIHostGetNumber(parent, &parent_host) < 0) + goto cleanup; =20 - if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0) - goto cleanup; + if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0) + goto cleanup; =20 - ret =3D 0; + ret =3D 0; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unsupported device type")); + } =20 cleanup: virNodeDeviceObjEndAPI(&obj); --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1592514397; cv=none; d=zohomail.com; s=zohoarc; b=DWRLghNOXfoHKxv47NdVtTvCaJItvuTm2RpdvN4RE+zzH8GyMoIGL8wOtHCCEIZusgen9JUxkkxPJ4OJ/3j5G9MMni/OlnWKgoI0/ndNBWxu/8HZJPn6TXbd1NvoRlNJVgSzhw318wZXY5/lTg7kk2IThxxVhCIlnQt1nWVcOW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514397; 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=fQe/tOyGQkK3hJ+VSUoQtRBB9YzMmqqbXeH93ge/FLE=; b=cNqByHsL98rXcAVqSVorrneLuWDIaf6C7satRQkHZOiNWHekst2jJmgftLdRRSzYXFC+XdAfN1XfEnhCufXRUkj9fUp8BKz4x3vPylraBCzCkZLePf/JJt7WZbZTAQhO2NpLNxS6p/LJsCyemtdfH2vQYrmqc5mL8ZTdZ+TDgbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1592514397341798.780529671011; Thu, 18 Jun 2020 14:06:37 -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-334-V9qThB9lM-uEPMllNYd42A-1; Thu, 18 Jun 2020 17:06:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B48D1A0BDF; Thu, 18 Jun 2020 21:06:27 +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 949AA5C1D6; Thu, 18 Jun 2020 21:06:27 +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 643B71809547; Thu, 18 Jun 2020 21:06:27 +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 05IL6Bmm002527 for ; Thu, 18 Jun 2020 17:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DABD60E1C; Thu, 18 Jun 2020 21:06:11 +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 B45FD60BF4; Thu, 18 Jun 2020 21:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514395; 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=fQe/tOyGQkK3hJ+VSUoQtRBB9YzMmqqbXeH93ge/FLE=; b=ezGVWhEtfqGGzP/FZDcMHnxETn/WcCkj+4Ndy6PmSsnKLXuyNAH3AMwwN2Q/dReOgMI6oW bilyQ3AhBZJLebwWkS8ZnpssOTPc4bhsvOMUTxJMng+bdI6ARe9aOM2vZezoAZ03y0tEr0 2m9rzV29UuGe4qwhAnZlMaAa8FOaXfA= X-MC-Unique: V9qThB9lM-uEPMllNYd42A-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 03/12] nodedev: add support for mdev attributes Date: Thu, 18 Jun 2020 16:05:56 -0500 Message-Id: <20200618210605.12308-4-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.79 on 10.5.11.16 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" Mediated devices support arbitrary vendor-specific attributes that can be attached to a mediated device. These attributes are ordered, and are written to sysfs in order after a device is created. This patch adds support for these attributes to the mdev data types and XML schema. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- docs/formatnode.html.in | 7 +++++ docs/schemas/nodedev.rng | 6 +++++ src/conf/node_device_conf.c | 53 ++++++++++++++++++++++++++++++++++--- src/conf/node_device_conf.h | 2 ++ src/libvirt_private.syms | 2 ++ src/util/virmdev.c | 12 +++++++++ src/util/virmdev.h | 11 ++++++++ 7 files changed, 90 insertions(+), 3 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 4ed43ec0cb..0637d457ee 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -394,6 +394,13 @@ belongs. This is a read-only field that is reported by the device driver. +
attr
+
+ This optional element can occur multiple times. It represe= nts a + vendor-specific attribute that is used to configure this + mediated device. It has two required attributes: + name and value. +
ccw
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index ca3a79db87..4b2b350fd8 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -636,6 +636,12 @@ + + + + + +
=20 diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 2ef4514f05..623a2cb79c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -500,6 +500,22 @@ virNodeDeviceCapStorageDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 +static void +virNodeDeviceCapMdevDefFormat(virBufferPtr buf, + const virNodeDevCapData *data) +{ + size_t i; + + virBufferEscapeString(buf, "\n", data->mdev.type); + virBufferAsprintf(buf, "\n", + data->mdev.iommuGroupNumber); + + for (i =3D 0; i < data->mdev.nattributes; i++) { + virMediatedDeviceAttrPtr attr =3D data->mdev.attributes[i]; + virBufferAsprintf(buf, "\n", + attr->name, attr->value); + } +} =20 char * virNodeDeviceDefFormat(const virNodeDeviceDef *def) @@ -583,9 +599,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) virBufferEscapeString(&buf, "%s\n", virNodeDevDRM= TypeToString(data->drm.type)); break; case VIR_NODE_DEV_CAP_MDEV: - virBufferEscapeString(&buf, "\n", data->mdev.= type); - virBufferAsprintf(&buf, "\n", - data->mdev.iommuGroupNumber); + virNodeDeviceCapMdevDefFormat(&buf, data); break; case VIR_NODE_DEV_CAP_CCW_DEV: virBufferAsprintf(&buf, "0x%x\n", @@ -1757,6 +1771,27 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, return ret; } =20 +static int +virNodeDevCapMdevAttributeParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapMdevPtr mdev) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + g_autoptr(virMediatedDeviceAttr) attr =3D virMediatedDeviceAttrNew(); + + ctxt->node =3D node; + attr->name =3D virXPathString("string(./@name)", ctxt); + attr->value =3D virXPathString("string(./@value)", ctxt); + if (!attr->name || !attr->value) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("mdev attribute missing name or value")); + return -1; + } + + return VIR_APPEND_ELEMENT(mdev->attributes, + mdev->nattributes, + attr); +} =20 static int virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, @@ -1766,6 +1801,9 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, { VIR_XPATH_NODE_AUTORESTORE(ctxt); int ret =3D -1; + int nattrs =3D 0; + g_autofree xmlNodePtr *attrs =3D NULL; + size_t i; =20 ctxt->node =3D node; =20 @@ -1785,6 +1823,12 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, goto out; } =20 + if ((nattrs =3D virXPathNodeSet("./attr", ctxt, &attrs)) < 0) + goto out; + + for (i =3D 0; i < nattrs; i++) + virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], mdev); + ret =3D 0; out: return ret; @@ -2174,6 +2218,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) break; case VIR_NODE_DEV_CAP_MDEV: VIR_FREE(data->mdev.type); + for (i =3D 0; i < data->mdev.nattributes; i++) + virMediatedDeviceAttrFree(data->mdev.attributes[i]); + VIR_FREE(data->mdev.attributes); break; case VIR_NODE_DEV_CAP_MDEV_TYPES: case VIR_NODE_DEV_CAP_DRM: diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 9e4b0847fb..e3e1e788d4 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -141,6 +141,8 @@ typedef virNodeDevCapMdev *virNodeDevCapMdevPtr; struct _virNodeDevCapMdev { char *type; unsigned int iommuGroupNumber; + virMediatedDeviceAttrPtr *attributes; + size_t nattributes; }; =20 typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 284c6c3880..22bd8b9c17 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2487,6 +2487,8 @@ virMacMapRemove; virMacMapWriteFile; =20 # util/virmdev.h +virMediatedDeviceAttrFree; +virMediatedDeviceAttrNew; virMediatedDeviceFree; virMediatedDeviceGetIOMMUGroupDev; virMediatedDeviceGetIOMMUGroupNum; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 51a88a91d7..b8023dd991 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -512,3 +512,15 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, =20 return 0; } + +virMediatedDeviceAttrPtr virMediatedDeviceAttrNew(void) +{ + return g_new0(virMediatedDeviceAttr, 1); +} + +void virMediatedDeviceAttrFree(virMediatedDeviceAttrPtr attr) +{ + g_free(attr->name); + g_free(attr->value); + g_free(attr); +} diff --git a/src/util/virmdev.h b/src/util/virmdev.h index 51f7f608a2..eb167ccb48 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -37,6 +37,17 @@ typedef struct _virMediatedDevice virMediatedDevice; typedef virMediatedDevice *virMediatedDevicePtr; typedef struct _virMediatedDeviceList virMediatedDeviceList; typedef virMediatedDeviceList *virMediatedDeviceListPtr; +typedef struct _virMediatedDeviceAttr virMediatedDeviceAttr; +typedef virMediatedDeviceAttr *virMediatedDeviceAttrPtr; + +struct _virMediatedDeviceAttr { + char *name; + char *value; +}; + +virMediatedDeviceAttrPtr virMediatedDeviceAttrNew(void); +void virMediatedDeviceAttrFree(virMediatedDeviceAttrPtr attr); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceAttr, virMediatedDeviceAttr= Free); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceList, virObjectUnref); =20 --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514396; cv=none; d=zohomail.com; s=zohoarc; b=SSoSJca5sx6qMss5bvbMwCvOBMdpqk/G3KvvUoaKycFFGBv4DSvVdYeuaIhHGaptaFYcrf6jQrU9OOoibnZVWQWJGz1VT4ER4XehRJ9skYFqdMiuaAbeBYH3+vjI9m9y4pzmoO8GZuBhqtxFV5U2DedJTfDitmJHuiljXxp6goU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514396; 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=SRAvtoqXGzSJy4iTD8KVOUh5IIAZWYEzo8XpC8JyUKU=; b=ZqpSuQsAaOxfp2IsxyjLLHmyYBrHTBHmIsBSbkJTovtH1XGRvMTAjVMxj1IQVuI+1hCWr5f19AOJDpB7pHzeXdbiV7fmU0Ei2i3GyrLghKRbGWhOXiTXbwbt+8xoWbnNa9BDVYRqp5HGax5FLAvLbcPherxu3BirbI8LGPk0HKg= 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 1592514396530739.9414764939539; Thu, 18 Jun 2020 14:06:36 -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-461-FRfqZ-P6PGeQKY42_O6s7g-1; Thu, 18 Jun 2020 17:06:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 848EE801503; Thu, 18 Jun 2020 21:06:27 +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 653275C1D0; Thu, 18 Jun 2020 21:06:27 +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 36312833CF; Thu, 18 Jun 2020 21:06:27 +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 05IL6Btp002533 for ; Thu, 18 Jun 2020 17:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78B3E60E1C; Thu, 18 Jun 2020 21:06:11 +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 2ABE860BF4; Thu, 18 Jun 2020 21:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514395; 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=SRAvtoqXGzSJy4iTD8KVOUh5IIAZWYEzo8XpC8JyUKU=; b=dbAAptfYozslnJLdsuYmaImcxV72x4N8aVVauwBF6TD90gWzMZzeXIIP89qz2Wru1NpRbf ZZogbGHbObx5/NKsCCYZUJVrW7VAEUvXLLRc/7YPLHk36IVuts/hjxOvONlXufn0pDDwzT vuP8imJBOFwF8aZt1yEsVs3hM4A/0dQ= X-MC-Unique: FRfqZ-P6PGeQKY42_O6s7g-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 04/12] nodedev: refactor nodeDeviceFindNewDevice() Date: Thu, 18 Jun 2020 16:05:57 -0500 Message-Id: <20200618210605.12308-5-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.79 on 10.5.11.16 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" In preparation for creating mediated devices in libvirt, we will need to wait for new mediated devices to be created as well. Refactor nodeDeviceFindNewDevice() so that we can re-use the main logic from this function to wait for different device types by passing a different 'find' function. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- src/node_device/node_device_driver.c | 41 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ba7ea50e5b..d6255a43c8 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -447,6 +447,10 @@ nodeDeviceGetTime(time_t *t) } =20 =20 +typedef virNodeDevicePtr (*nodeDeviceFindNewDeviceFunc)(virConnectPtr conn, + const void* opaque= ); + + /* When large numbers of devices are present on the host, it's * possible for udev not to realize that it has work to do before we * get here. We thus keep trying to find the new device we just @@ -462,8 +466,8 @@ nodeDeviceGetTime(time_t *t) */ static virNodeDevicePtr nodeDeviceFindNewDevice(virConnectPtr conn, - const char *wwnn, - const char *wwpn) + nodeDeviceFindNewDeviceFunc func, + const void *opaque) { virNodeDevicePtr device =3D NULL; time_t start =3D 0, now =3D 0; @@ -474,7 +478,7 @@ nodeDeviceFindNewDevice(virConnectPtr conn, =20 virWaitForDevices(); =20 - device =3D nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); + device =3D func(conn, opaque); =20 if (device !=3D NULL) break; @@ -488,6 +492,35 @@ nodeDeviceFindNewDevice(virConnectPtr conn, } =20 =20 +typedef struct _NewSCSIHostFuncData NewSCSIHostFuncData; +struct _NewSCSIHostFuncData +{ + const char *wwnn; + const char *wwpn; +}; + + +static virNodeDevicePtr +nodeDeviceFindNewSCSIHostFunc(virConnectPtr conn, + const void *opaque) +{ + const NewSCSIHostFuncData *data =3D opaque; + + return nodeDeviceLookupSCSIHostByWWN(conn, data->wwnn, data->wwpn, 0); +} + + +static virNodeDevicePtr +nodeDeviceFindNewSCSIHost(virConnectPtr conn, + const char *wwnn, + const char *wwpn) +{ + NewSCSIHostFuncData data =3D { .wwnn =3D wwnn, .wwpn =3D wwpn}; + + return nodeDeviceFindNewDevice(conn, nodeDeviceFindNewSCSIHostFunc, &d= ata); +} + + static bool nodeDeviceHasCapability(virNodeDeviceDefPtr def, virNodeDevCapType type) { @@ -538,7 +571,7 @@ nodeDeviceCreateXML(virConnectPtr conn, if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_CREATE) < 0) return NULL; =20 - device =3D nodeDeviceFindNewDevice(conn, wwnn, wwpn); + device =3D nodeDeviceFindNewSCSIHost(conn, wwnn, wwpn); /* We don't check the return value, because one way or another, * we're returning what we get... */ =20 --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514495; cv=none; d=zohomail.com; s=zohoarc; b=M5OApidAPS8mqpETYGiiWNEU9QYwdXkYa1Mj5nTraWgZEv9wErJWM/ukn0uYMRqAWXGjOuxdDyYkcsd5kVhJDYDP50Oh3YKaLPXxZB5Q+dXlQV49JdzyFcsI0EkwLa+7c3gkrQgiUKCPvPdOU60i24/5aH2xZccOkZfAc1JQuH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514495; 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=0HctAVn078jdt5q8ARLmBlfnzfCe5PK3h66k0jH6MSA=; b=irzvYmiB9LuRkVpSqJVyTjUYJSGAByb43nsJ9U9/vTnyb+oH/LvqgbuJp+pzR8rD26qtb51fqOEjeLZmGuIxiVk56DeHZwuqh594QjL0eWlPxDg5hMzU6XhZq+S4Rba4boZ6jDQp6Vu+SsPwv4yWh1CeYutJkRSOJ+suFttsvVI= 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 1592514495723941.8739607155227; Thu, 18 Jun 2020 14:08:15 -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-163-5uDm_ONYNWathdAFB4LZ4g-1; Thu, 18 Jun 2020 17:06:39 -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 3F718107ACF4; Thu, 18 Jun 2020 21:06:32 +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 1E6A371671; Thu, 18 Jun 2020 21:06:32 +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 B60FA1809557; 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 05IL6BSh002538 for ; Thu, 18 Jun 2020 17:06:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2AFE60E3E; Thu, 18 Jun 2020 21:06:11 +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 952BA60BF4; Thu, 18 Jun 2020 21:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514494; 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=0HctAVn078jdt5q8ARLmBlfnzfCe5PK3h66k0jH6MSA=; b=NOr3ho/Q9niXTK9AtOAE4PNHF/jQhAUkgZmtQrhJZ2/CjzALTUzF3aO+KQQh2vGuHoqg9X sjvBqWC9vk0x6ww3+ZEA7qVoK8k0jdvNuu3eS4EgXRN1MQ24jf0O4CJRjMTRE0EqektQZY UPW5x2QwgWJ9d61LO58ENpbvlE6EtTY= X-MC-Unique: 5uDm_ONYNWathdAFB4LZ4g-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 05/12] nodedev: store mdev UUID in mdev caps Date: Thu, 18 Jun 2020 16:05:58 -0500 Message-Id: <20200618210605.12308-6-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.79 on 10.5.11.11 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" In order to allow libvirt to create and start new mediated devices, we need to be able to verify that the device has been started. In order to do this, we'll need to save the UUID of newly-discovered devices within the virNodeDevCapMdev structure. This allows us to search the device list by UUID and verify whether the expected device has been started. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- src/conf/node_device_conf.c | 1 + src/conf/node_device_conf.h | 1 + src/node_device/node_device_udev.c | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 623a2cb79c..78a537d0ea 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2218,6 +2218,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) break; case VIR_NODE_DEV_CAP_MDEV: VIR_FREE(data->mdev.type); + VIR_FREE(data->mdev.uuid); for (i =3D 0; i < data->mdev.nattributes; i++) virMediatedDeviceAttrFree(data->mdev.attributes[i]); VIR_FREE(data->mdev.attributes); diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index e3e1e788d4..9b8c7aadea 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -141,6 +141,7 @@ typedef virNodeDevCapMdev *virNodeDevCapMdevPtr; struct _virNodeDevCapMdev { char *type; unsigned int iommuGroupNumber; + char *uuid; virMediatedDeviceAttrPtr *attributes; size_t nattributes; }; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 386f23ef3a..bdf0b03add 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1013,7 +1013,6 @@ udevProcessMediatedDevice(struct udev_device *dev, virNodeDeviceDefPtr def) { int ret =3D -1; - const char *uuidstr =3D NULL; int iommugrp =3D -1; char *linkpath =3D NULL; char *canonicalpath =3D NULL; @@ -1041,8 +1040,8 @@ udevProcessMediatedDevice(struct udev_device *dev, =20 data->type =3D g_path_get_basename(canonicalpath); =20 - uuidstr =3D udev_device_get_sysname(dev); - if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0) + data->uuid =3D g_strdup(udev_device_get_sysname(dev)); + if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0) goto cleanup; =20 if (udevGenerateDeviceName(dev, def, NULL) !=3D 0) --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1592514402; cv=none; d=zohomail.com; s=zohoarc; b=I8idcQa7Y59Ju07YYYWGcc9yFAWZceycPqQJNBWOS6Axiz+v106gV3QdtMspMTD1g1QFJJi0gRrdf06OUKQHrkj9dxbnHqSyPHCCbSfUhjcquOw4VNh0VJz9/MuxE7NymBsFs57DMknrK0ZGC27MdxJ7hT07yAJf6cXa7SFpQao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514402; 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=Qbo6EIlEgovq/QD+0DLOMCRlwDJTrSPjUib20G54Ts4=; b=cLR4ZUj52miXEkwqQqcg6X4JH1xAi8X3m8yQf9ZY8pj9chI75zoxqQ2zxwrKRB91zqMiAiwzzmCtmEpIF41kMroIr2+DaOYXc9E+zJ+R4T/jwnblNvh1X/OB+0m71fWU+SyilMDOG0E1jxSXgUTmjy3nxTXWLQYDrwE/lzVEsJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1592514402164924.0761220841081; Thu, 18 Jun 2020 14:06:42 -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-45-pjXA3DbJMheHeFnybrtfwQ-1; Thu, 18 Jun 2020 17:06:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5CFA107ACF6; Thu, 18 Jun 2020 21:06:29 +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 B0D891000239; Thu, 18 Jun 2020 21:06:29 +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 81EBA833D1; Thu, 18 Jun 2020 21:06:29 +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 05IL6CB8002546 for ; Thu, 18 Jun 2020 17:06:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 661C060E3E; Thu, 18 Jun 2020 21:06:12 +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 0AA8B60BF4; Thu, 18 Jun 2020 21:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514400; 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=Qbo6EIlEgovq/QD+0DLOMCRlwDJTrSPjUib20G54Ts4=; b=WmxqLvZPULzkQN0iKwhfOrpFWMmNyUnnn2z4fP8VinTzQ3s8x7Ww6gPuGE33JtqvGseUKL JRKa+Q1lUiDkwiMK4NhdSmbrxDzHP0tsrJmGnJyi9WI9odAKKR1jDOon8LjSUsxg8RSO5t JIzt1khwi2gR1RZU56zcWSYGHWCFinw= X-MC-Unique: pjXA3DbJMheHeFnybrtfwQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 06/12] nodedev: add mdev support to virNodeDeviceCreateXML() Date: Thu, 18 Jun 2020 16:05:59 -0500 Message-Id: <20200618210605.12308-7-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.22 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" With recent additions to the node device xml schema, an xml schema can now describe a mdev device sufficiently for libvirt to create and start the device using the mdevctl utility. Note that some of the the configuration for a mediated device must be passed to mdevctl as a JSON-formatted file. In order to avoid creating and cleaning up temporary files, the JSON is instead fed to stdin and we pass the filename /dev/stdin to mdevctl. While this may not be portable, neither are mediated devices, so I don't believe it should cause any problems. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- libvirt.spec.in | 2 + m4/virt-external-programs.m4 | 3 + src/conf/virnodedeviceobj.c | 34 +++++ src/conf/virnodedeviceobj.h | 3 + src/libvirt_private.syms | 1 + src/node_device/node_device_driver.c | 197 +++++++++++++++++++++++++++ src/node_device/node_device_driver.h | 5 + 7 files changed, 245 insertions(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 450c97b46d..cd7c33ab1a 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -522,6 +522,8 @@ Requires: libvirt-daemon =3D %{version}-%{release} Requires: libvirt-libs =3D %{version}-%{release} # needed for device enumeration Requires: systemd >=3D 185 +# For managing persistent mediated devices +Requires: mdevctl =20 %description daemon-driver-nodedev The nodedev driver plugin for the libvirtd daemon, providing diff --git a/m4/virt-external-programs.m4 b/m4/virt-external-programs.m4 index 9046e3bf07..bd3cb1f757 100644 --- a/m4/virt-external-programs.m4 +++ b/m4/virt-external-programs.m4 @@ -65,6 +65,7 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [ AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl], [$LIBVIRT_SBIN_PATH]) AC_PATH_PROG([SCRUB], [scrub], [scrub], [$LIBVIRT_SBIN_PATH]) AC_PATH_PROG([ADDR2LINE], [addr2line], [addr2line], [$LIBVIRT_SBIN_PATH]) + AC_PATH_PROG([MDEVCTL], [mdevctl], [mdevctl], [$LIBVIRT_SBIN_PATH]) =20 AC_DEFINE_UNQUOTED([DMIDECODE], ["$DMIDECODE"], [Location or name of the dmidecode program]) @@ -88,6 +89,8 @@ AC_DEFUN([LIBVIRT_CHECK_EXTERNAL_PROGRAMS], [ [Location or name of the scrub program (for wiping al= gorithms)]) AC_DEFINE_UNQUOTED([ADDR2LINE], ["$ADDR2LINE"], [Location of addr2line program]) + AC_DEFINE_UNQUOTED([MDEVCTL], ["$MDEVCTL"], + [Location or name of the mdevctl program]) =20 AC_PATH_PROG([IP_PATH], [ip], [/sbin/ip], [$LIBVIRT_SBIN_PATH]) AC_DEFINE_UNQUOTED([IP_PATH], ["$IP_PATH"], [path to ip binary]) diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 3a34a324ca..fd20d5f9e2 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -399,6 +399,40 @@ virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceOb= jListPtr devs, &data); } =20 +static int +virNodeDeviceObjListFindMediatedDeviceByUUIDCallback(const void *payload, + const void *name G_GN= UC_UNUSED, + const void *opaque G_= GNUC_UNUSED) +{ + virNodeDeviceObjPtr obj =3D (virNodeDeviceObjPtr) payload; + const char *uuid =3D (const char *) opaque; + virNodeDevCapsDefPtr cap; + int want =3D 0; + + virObjectLock(obj); + + for (cap =3D obj->def->caps; cap !=3D NULL; cap =3D cap->next) { + if (cap->data.type =3D=3D VIR_NODE_DEV_CAP_MDEV) { + if (STREQ(cap->data.mdev.uuid, uuid)) { + want =3D 1; + break; + } + } + } + + virObjectUnlock(obj); + return want; +} + + +virNodeDeviceObjPtr +virNodeDeviceObjListFindMediatedDeviceByUUID(virNodeDeviceObjListPtr devs, + const char *uuid) +{ + return virNodeDeviceObjListSearch(devs, + virNodeDeviceObjListFindMediatedDevi= ceByUUIDCallback, + uuid); +} =20 static void virNodeDeviceObjListDispose(void *obj) diff --git a/src/conf/virnodedeviceobj.h b/src/conf/virnodedeviceobj.h index c9df8dedab..6efdb23d36 100644 --- a/src/conf/virnodedeviceobj.h +++ b/src/conf/virnodedeviceobj.h @@ -118,3 +118,6 @@ virNodeDeviceObjListExport(virConnectPtr conn, void virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj, bool skipUpdateCaps); +virNodeDeviceObjPtr +virNodeDeviceObjListFindMediatedDeviceByUUID(virNodeDeviceObjListPtr devs, + const char *uuid); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 22bd8b9c17..42f8d7c222 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1179,6 +1179,7 @@ virNodeDeviceObjListAssignDef; virNodeDeviceObjListExport; virNodeDeviceObjListFindByName; virNodeDeviceObjListFindBySysfsPath; +virNodeDeviceObjListFindMediatedDeviceByUUID; virNodeDeviceObjListFindSCSIHostByWWNs; virNodeDeviceObjListFree; virNodeDeviceObjListGetNames; diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index d6255a43c8..35016782d2 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -30,6 +30,7 @@ #include "datatypes.h" #include "viralloc.h" #include "virfile.h" +#include "virjson.h" #include "virstring.h" #include "node_device_conf.h" #include "node_device_event.h" @@ -40,6 +41,7 @@ #include "viraccessapicheck.h" #include "virnetdev.h" #include "virutil.h" +#include "vircommand.h" =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 @@ -304,6 +306,30 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn, return device; } =20 +static virNodeDevicePtr +nodeDeviceLookupMediatedDeviceByUUID(virConnectPtr conn, + const char *uuid, + unsigned int flags) +{ + virNodeDeviceObjPtr obj =3D NULL; + virNodeDeviceDefPtr def; + virNodeDevicePtr device =3D NULL; + + virCheckFlags(0, NULL); + + if (!(obj =3D virNodeDeviceObjListFindMediatedDeviceByUUID(driver->dev= s, + uuid))) + return NULL; + + def =3D virNodeDeviceObjGetDef(obj); + + if ((device =3D virGetNodeDevice(conn, def->name))) + device->parentName =3D g_strdup(def->parent); + + virNodeDeviceObjEndAPI(&obj); + return device; +} + =20 char * nodeDeviceGetXMLDesc(virNodeDevicePtr device, @@ -492,6 +518,26 @@ nodeDeviceFindNewDevice(virConnectPtr conn, } =20 =20 +static virNodeDevicePtr +nodeDeviceFindNewMediatedDeviceFunc(virConnectPtr conn, + const void *opaque) +{ + const char *uuid =3D opaque; + + return nodeDeviceLookupMediatedDeviceByUUID(conn, uuid, 0); +} + + +static virNodeDevicePtr +nodeDeviceFindNewMediatedDevice(virConnectPtr conn, + const char *mdev_uuid) +{ + return nodeDeviceFindNewDevice(conn, + nodeDeviceFindNewMediatedDeviceFunc, + mdev_uuid); +} + + typedef struct _NewSCSIHostFuncData NewSCSIHostFuncData; struct _NewSCSIHostFuncData { @@ -536,6 +582,155 @@ nodeDeviceHasCapability(virNodeDeviceDefPtr def, virN= odeDevCapType type) } =20 =20 +/* format a json string that provides configuration information about this= mdev + * to the mdevctl utility */ +static int +nodeDeviceDefToMdevctlConfig(virNodeDeviceDefPtr def, char **buf) +{ + size_t i; + virNodeDevCapMdevPtr mdev =3D &def->caps->data.mdev; + g_autoptr(virJSONValue) json =3D virJSONValueNewObject(); + + if (virJSONValueObjectAppendString(json, "mdev_type", mdev->type) < 0) + return -1; + + if (virJSONValueObjectAppendString(json, "start", "manual") < 0) + return -1; + + if (mdev->attributes) { + g_autoptr(virJSONValue) attributes =3D virJSONValueNewArray(); + + for (i =3D 0; i < mdev->nattributes; i++) { + virMediatedDeviceAttrPtr attr =3D mdev->attributes[i]; + g_autoptr(virJSONValue) jsonattr =3D virJSONValueNewObject(); + + if (virJSONValueObjectAppendString(jsonattr, attr->name, attr-= >value) < 0) + return -1; + + if (virJSONValueArrayAppend(attributes, g_steal_pointer(&jsona= ttr)) < 0) + return -1; + } + + if (virJSONValueObjectAppend(json, "attrs", g_steal_pointer(&attri= butes)) < 0) + return -1; + } + + *buf =3D virJSONValueToString(json, false); + if (!*buf) + return -1; + + return 0; +} + + +static char * +nodeDeviceFindAddressByName(const char *name) +{ + virNodeDeviceDefPtr def =3D NULL; + virNodeDevCapsDefPtr caps =3D NULL; + char *pci_addr =3D NULL; + virNodeDeviceObjPtr dev =3D virNodeDeviceObjListFindByName(driver->dev= s, name); + + if (!dev) { + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("could not find device '%s'"), name); + return NULL; + } + + def =3D virNodeDeviceObjGetDef(dev); + for (caps =3D def->caps; caps !=3D NULL; caps =3D caps->next) { + if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_PCI_DEV) { + virPCIDeviceAddress addr =3D { + .domain =3D caps->data.pci_dev.domain, + .bus =3D caps->data.pci_dev.bus, + .slot =3D caps->data.pci_dev.slot, + .function =3D caps->data.pci_dev.function + }; + + pci_addr =3D virPCIDeviceAddressAsString(&addr); + break; + } + } + + virNodeDeviceObjEndAPI(&dev); + + return pci_addr; +} + + +virCommandPtr +nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def, + char **uuid_out) +{ + virCommandPtr cmd; + g_autofree char *json =3D NULL; + g_autofree char *parent_pci =3D nodeDeviceFindAddressByName(def->paren= t); + + if (!parent_pci) { + virReportError(VIR_ERR_NO_NODE_DEVICE, + _("unable to find PCI address for parent device '%s= '"), def->parent); + return NULL; + } + + if (nodeDeviceDefToMdevctlConfig(def, &json) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("couldn't convert node device def to mdevctl JSON= ")); + return NULL; + } + + cmd =3D virCommandNewArgList(MDEVCTL, "start", + "-p", parent_pci, + "--jsonfile", "/dev/stdin", + NULL); + + virCommandSetInputBuffer(cmd, json); + virCommandSetOutputBuffer(cmd, uuid_out); + + return cmd; +} + +static int +virMdevctlStart(virNodeDeviceDefPtr def, char **uuid) +{ + int status; + g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlStartCommand(def, uu= id); + if (!cmd) + return -1; + + /* an auto-generated uuid is returned via stdout if no uuid is specifi= ed in + * the mdevctl args */ + if (virCommandRun(cmd, &status) < 0 || status !=3D 0) + return -1; + + /* remove newline */ + *uuid =3D g_strstrip(*uuid); + + return 0; +} + + +static virNodeDevicePtr +nodeDeviceCreateXMLMdev(virConnectPtr conn, + virNodeDeviceDefPtr def) +{ + g_autofree char *uuid =3D NULL; + + if (!def->parent) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("cannot create a mediated device without a parent= ")); + return NULL; + } + + if (virMdevctlStart(def, &uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to start mediated device")); + return NULL; + } + + return nodeDeviceFindNewMediatedDevice(conn, uuid); +} + + virNodeDevicePtr nodeDeviceCreateXML(virConnectPtr conn, const char *xmlDesc, @@ -580,6 +775,8 @@ nodeDeviceCreateXML(virConnectPtr conn, _("no node device for '%s' with matching " "wwnn '%s' and wwpn '%s'"), def->name, wwnn, wwpn); + } else if (nodeDeviceHasCapability(def, VIR_NODE_DEV_CAP_MDEV)) { + device =3D nodeDeviceCreateXMLMdev(conn, def); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unsupported device type")); diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_de= vice_driver.h index eae5e2cb17..e42c14f6c7 100644 --- a/src/node_device/node_device_driver.h +++ b/src/node_device/node_device_driver.h @@ -24,6 +24,7 @@ #include "internal.h" #include "driver.h" #include "virnodedeviceobj.h" +#include "vircommand.h" =20 #define LINUX_NEW_DEVICE_WAIT_TIME 60 =20 @@ -116,3 +117,7 @@ nodeConnectNodeDeviceEventRegisterAny(virConnectPtr con= n, int nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn, int callbackID); + +virCommandPtr +nodeDeviceGetMdevctlStartCommand(virNodeDeviceDefPtr def, + char **uuid_out); --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1592514420; cv=none; d=zohomail.com; s=zohoarc; b=gykVp4HAfIqPmP+reeRp8hoB5eDaO+HiRy+3hqhCKp8AgwNasRDFNKX7dFYWc0kzwPMF5mFjlwyOanUIcLg4YpomHs98OWcnwsJ/hMykMgFsrpK5FYhCPjW7s9DpuBm6l9etSTx6I+VCVi2a3wKbPOET2kj9/Sz6kFoXKmUtoXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514420; 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=hA2cs+ARia4N4iPiv2vKi8AxcNC/kt7VVjomey0pTy4=; b=Rh0vtikCc79sT1/qtbySCp3mQkRCWtCLBWTkkkAbxY5XiVvZNAQOR9/MWwLx8ZLDYjzdIuJBN9F3poXkB20YYc7PuC/OoZqhiWjn1I5kNkPQcqMDsxRcaJ41vVCIGZsrsv4tiXK88D2soyLeiKgEd1orUtkfZM8p2eXfdham2iQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1592514420410430.63164329185724; Thu, 18 Jun 2020 14:07:00 -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-447-z1s5sPF7NJ-a8usIjTZVWw-1; Thu, 18 Jun 2020 17:06:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F7FBA0BE2; Thu, 18 Jun 2020 21:06:30 +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 01C0D5C1D0; Thu, 18 Jun 2020 21:06:30 +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 C492B180043B; Thu, 18 Jun 2020 21:06:29 +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 05IL6CbM002556 for ; Thu, 18 Jun 2020 17:06:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id D005960E3E; Thu, 18 Jun 2020 21:06:12 +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 8241860BF4; Thu, 18 Jun 2020 21:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514419; 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=hA2cs+ARia4N4iPiv2vKi8AxcNC/kt7VVjomey0pTy4=; b=aI1wQTtf7u4x2QI4yRQj9hudFEgn2eVMNdC3m3pD7YtyhPlVH8ZiGDA6+N5iDMHq5hhWOt EjYAcwmIic2r7evfVNZ/ssqS99x3hPvhOhRyk/zwAd1ZQV9X6m0k70F+MkwIFOftp7sChm BXGvLFMvN6EPb4NCS084iFKY/tqeeKc= X-MC-Unique: z1s5sPF7NJ-a8usIjTZVWw-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 07/12] nodedev: Build a non-loadable driver lib Date: Thu, 18 Jun 2020 16:06:00 -0500 Message-Id: <20200618210605.12308-8-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.79 on 10.5.11.16 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" In order to test the nodedev driver, we need to link against a non-loadable module. Similar to other loadable modules already in the repository, create an _impl library that can be linked against the unit tests and then create a loadable module from that. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- src/node_device/Makefile.inc.am | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/node_device/Makefile.inc.am b/src/node_device/Makefile.inc= .am index 788563665f..5993165b56 100644 --- a/src/node_device/Makefile.inc.am +++ b/src/node_device/Makefile.inc.am @@ -34,34 +34,37 @@ EXTRA_DIST +=3D \ =20 if WITH_NODE_DEVICES # Needed to keep automake quiet about conditionals +noinst_LTLIBRARIES +=3D libvirt_driver_nodedev_impl.la +libvirt_driver_nodedev_la_SOURCES =3D +libvirt_driver_nodedev_la_LIBADD =3D libvirt_driver_nodedev_impl.la mod_LTLIBRARIES +=3D libvirt_driver_nodedev.la -libvirt_driver_nodedev_la_SOURCES =3D $(NODE_DEVICE_DRIVER_SOURCES) +libvirt_driver_nodedev_impl_la_SOURCES =3D $(NODE_DEVICE_DRIVER_SOURCES) =20 -libvirt_driver_nodedev_la_CFLAGS =3D \ +libvirt_driver_nodedev_impl_la_CFLAGS =3D \ -I$(srcdir)/access \ -I$(builddir)/access \ -I$(srcdir)/conf \ $(AM_CFLAGS) \ $(LIBNL_CFLAGS) \ $(NULL) -libvirt_driver_nodedev_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) -libvirt_driver_nodedev_la_LIBADD =3D \ +libvirt_driver_nodedev_impl_la_LDFLAGS =3D $(AM_LDFLAGS_MOD_NOUNDEF) +libvirt_driver_nodedev_impl_la_LIBADD =3D \ libvirt.la \ $(GLIB_LIBS) \ $(NULL) =20 if WITH_HAL -libvirt_driver_nodedev_la_SOURCES +=3D $(NODE_DEVICE_DRIVER_HAL_SOURCES) -libvirt_driver_nodedev_la_CFLAGS +=3D $(HAL_CFLAGS) -libvirt_driver_nodedev_la_LIBADD +=3D $(HAL_LIBS) +libvirt_driver_nodedev_impl_la_SOURCES +=3D $(NODE_DEVICE_DRIVER_HAL_SOURC= ES) +libvirt_driver_nodedev_impl_la_CFLAGS +=3D $(HAL_CFLAGS) +libvirt_driver_nodedev_impl_la_LIBADD +=3D $(HAL_LIBS) endif WITH_HAL if WITH_UDEV -libvirt_driver_nodedev_la_SOURCES +=3D $(NODE_DEVICE_DRIVER_UDEV_SOURCES) -libvirt_driver_nodedev_la_CFLAGS +=3D \ +libvirt_driver_nodedev_impl_la_SOURCES +=3D $(NODE_DEVICE_DRIVER_UDEV_SOUR= CES) +libvirt_driver_nodedev_impl_la_CFLAGS +=3D \ $(UDEV_CFLAGS) \ $(PCIACCESS_CFLAGS) \ $(NULL) -libvirt_driver_nodedev_la_LIBADD +=3D \ +libvirt_driver_nodedev_impl_la_LIBADD +=3D \ $(UDEV_LIBS) \ $(PCIACCESS_LIBS) \ $(NULL) --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514401; cv=none; d=zohomail.com; s=zohoarc; b=TEGgzuXQpkHajAGLJqy67ioROs0JRpsEDLQoG6OHCBR4M7kpSaib7EfmDgBxU4rEQhKWVygLI+qdyVhxDTL8kM9ocTWoD4+rbu3tp7baDlWQKCaZptZDFyJ91YWhO9TzYAvriE4eUtIfvjkUu62ynIRULmTURH6yr3xMZbj+bcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514401; 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=sSkiHWAr3QlMefsTEWJssbpDK3Uyqj8eCP6jsYq+LEs=; b=lnL52X+IDZuhMep15XY97klM8mVwlGdfZckiPe61I0GAJDH6El0vQQVK7uJzQ2GW0MANTJJVtyFL2eUXB8edo1zRk/ZITBGCBHXJTTiBfgD7KrbD0Q2+ZH85LrCOcXlHW48TQYYF9yEKRvrzTKpSFUH3RpK6q7ZygGo6AuUm8cw= 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 1592514401863984.5920992051618; Thu, 18 Jun 2020 14:06:41 -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-90-maoElnJZN6CP4WwuOSOd5w-1; Thu, 18 Jun 2020 17:06:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 838F5107ACF9; 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 5FF3D10002B5; Thu, 18 Jun 2020 21:06:32 +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 34532833D5; Thu, 18 Jun 2020 21:06:32 +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 05IL6D18002568 for ; Thu, 18 Jun 2020 17:06:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 46CA760E1C; 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 ED24B60BF4; Thu, 18 Jun 2020 21:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514400; 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=sSkiHWAr3QlMefsTEWJssbpDK3Uyqj8eCP6jsYq+LEs=; b=GPr86AztEphLTSzCy8clJX4a8kmqf3AqFsCOVW0QH/ftn/4FbcI3uRjcKC6+h/UmbcL0KL IXjLw3JnDVu0rPhNuNi+m6o3LXD4ZL+DqWYWdCqMmVzdKtBi6MwOoc8j94DrXF5KioGZQm h3M1cvSV66mv1KvhIO4nhFuynKmheB0= X-MC-Unique: maoElnJZN6CP4WwuOSOd5w-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 08/12] nodedev: Add testing for 'mdevctl start' Date: Thu, 18 Jun 2020 16:06:01 -0500 Message-Id: <20200618210605.12308-9-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.22 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" Test that we run 'mdevctl' with the proper arguments when creating new mediated devices with virNodeDeviceCreateXML(). Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- build-aux/syntax-check.mk | 2 +- tests/Makefile.am | 15 + ...019_36ea_4111_8f0a_8c9a70e21366-start.argv | 1 + ...019_36ea_4111_8f0a_8c9a70e21366-start.json | 1 + ...d39_495e_4243_ad9f_beb3f14c23d9-start.argv | 1 + ...d39_495e_4243_ad9f_beb3f14c23d9-start.json | 1 + ...916_1ca8_49ac_b176_871d16c13076-start.argv | 1 + ...916_1ca8_49ac_b176_871d16c13076-start.json | 1 + tests/nodedevmdevctltest.c | 262 ++++++++++++++++++ ...v_d069d019_36ea_4111_8f0a_8c9a70e21366.xml | 7 + ...v_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml | 9 + ...v_fedc4916_1ca8_49ac_b176_871d16c13076.xml | 8 + 12 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8= c9a70e21366-start.argv create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8= c9a70e21366-start.json create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_b= eb3f14c23d9-start.argv create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_b= eb3f14c23d9-start.json create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_8= 71d16c13076-start.argv create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_8= 71d16c13076-start.json create mode 100644 tests/nodedevmdevctltest.c create mode 100644 tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c= 9a70e21366.xml create mode 100644 tests/nodedevschemadata/mdev_d2441d39_495e_4243_ad9f_be= b3f14c23d9.xml create mode 100644 tests/nodedevschemadata/mdev_fedc4916_1ca8_49ac_b176_87= 1d16c13076.xml diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index bf8832a2a5..d47a92b530 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2015,7 +2015,7 @@ exclude_file_name_regexp--sc_prohibit_close =3D \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt= -stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/= nss/libvirt_nss_(leases|macs)\.c)$$) =20 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF =3D \ - (^tests/(virhostcpu|virpcitest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|= \.diff|tests/virconfdata/no-newline\.conf$$) + (^tests/(nodedevmdevctl|virhostcpu|virpcitest)data/|docs/js/.*\.js|docs/= fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$) =20 exclude_file_name_regexp--sc_prohibit_fork_wrappers =3D \ (^(src/(util/(vircommand|virdaemon)|lxc/lxc_controller)|tests/testutils)= \.c$$) diff --git a/tests/Makefile.am b/tests/Makefile.am index f5766a7790..3505c40f42 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -103,6 +103,7 @@ EXTRA_DIST =3D \ networkxml2xmlupdatein \ networkxml2xmlupdateout \ nodedevschemadata \ + nodedevmdevctldata \ virhostcpudata \ nssdata \ nwfilterxml2firewalldata \ @@ -388,6 +389,10 @@ test_programs +=3D storagevolxml2xmltest =20 test_programs +=3D nodedevxml2xmltest =20 +if WITH_NODE_DEVICES +test_programs +=3D nodedevmdevctltest +endif WITH_NODE_DEVICES + test_programs +=3D interfacexml2xmltest =20 test_programs +=3D cputest @@ -970,6 +975,16 @@ nodedevxml2xmltest_SOURCES =3D \ testutils.c testutils.h nodedevxml2xmltest_LDADD =3D $(LDADDS) =20 +if WITH_NODE_DEVICES +nodedevmdevctltest_SOURCES =3D \ + nodedevmdevctltest.c \ + testutils.c testutils.h + +nodedevmdevctltest_LDADD =3D \ + ../src/libvirt_driver_nodedev_impl.la \ + $(LDADDS) +endif WITH_NODE_DEVICES + interfacexml2xmltest_SOURCES =3D \ interfacexml2xmltest.c \ testutils.c testutils.h diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-start.argv b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9= a70e21366-start.argv new file mode 100644 index 0000000000..eb7262035e --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-st= art.argv @@ -0,0 +1 @@ +$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e2= 1366-start.json b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9= a70e21366-start.json new file mode 100644 index 0000000000..bfc6dcace3 --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366-st= art.json @@ -0,0 +1 @@ +{"mdev_type":"i915-GVTg_V5_8","start":"manual"} \ No newline at end of file diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-start.argv b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb= 3f14c23d9-start.argv new file mode 100644 index 0000000000..eb7262035e --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-st= art.argv @@ -0,0 +1 @@ +$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c= 23d9-start.json b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb= 3f14c23d9-start.json new file mode 100644 index 0000000000..e5b22b2c44 --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9-st= art.json @@ -0,0 +1 @@ +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e-1":"attribute-value-1"},{"example-attribute-2":"attribute-value-2"}]} \ No newline at end of file diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-start.argv b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871= d16c13076-start.argv new file mode 100644 index 0000000000..eb7262035e --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-st= art.argv @@ -0,0 +1 @@ +$MDEVCTL_BINARY$ start -p 0000:00:02.0 --jsonfile /dev/stdin diff --git a/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c1= 3076-start.json b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871= d16c13076-start.json new file mode 100644 index 0000000000..2e03d0bd8e --- /dev/null +++ b/tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076-st= art.json @@ -0,0 +1 @@ +{"mdev_type":"i915-GVTg_V5_8","start":"manual","attrs":[{"example-attribut= e":"attribute-value"}]} \ No newline at end of file diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c new file mode 100644 index 0000000000..4b029c7286 --- /dev/null +++ b/tests/nodedevmdevctltest.c @@ -0,0 +1,262 @@ +#include + +#include "internal.h" +#include "testutils.h" +#include "datatypes.h" +#include "node_device/node_device_driver.h" +#include "vircommand.h" +#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW +#include "vircommandpriv.h" + +#define VIR_FROM_THIS VIR_FROM_NODEDEV + +struct startTestInfo { + const char *virt_type; + int create; + const char *filename; +}; + +/* capture stdin passed to command */ +static void +testCommandDryRunCallback(const char *const*args G_GNUC_UNUSED, + const char *const*env G_GNUC_UNUSED, + const char *input, + char **output G_GNUC_UNUSED, + char **error G_GNUC_UNUSED, + int *status G_GNUC_UNUSED, + void *opaque G_GNUC_UNUSED) +{ + char **stdinbuf =3D opaque; + + *stdinbuf =3D g_strdup(input); +} + +/* We don't want the result of the test to depend on the path to the mdevc= tl + * binary on the developer's machine, so replace the path to mdevctl with a + * placeholder string before comparing to the expected output */ +static int +nodedevCompareToFile(const char *actual, + const char *filename) +{ + g_autofree char *replacedCmdline =3D NULL; + + replacedCmdline =3D virStringReplace(actual, MDEVCTL, "$MDEVCTL_BINARY= $"); + + return virTestCompareToFile(replacedCmdline, filename); +} + +static int +testMdevctlStart(const char *virt_type, + int create, + const char *mdevxml, + const char *startcmdfile, + const char *startjsonfile) +{ + g_autoptr(virNodeDeviceDef) def =3D NULL; + virNodeDeviceObjPtr obj =3D NULL; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + const char *actualCmdline =3D NULL; + int ret =3D -1; + g_autofree char *uuid =3D NULL; + g_autofree char *stdinbuf =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; + + if (!(def =3D virNodeDeviceDefParseFile(mdevxml, create, virt_type))) + goto cleanup; + + /* 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 nodeDeviceGetMdevctlStartCommand(def, &uuid); + + if (!cmd) + goto cleanup; + + virCommandSetDryRun(&buf, testCommandDryRunCallback, &stdinbuf); + if (virCommandRun(cmd, NULL) < 0) + goto cleanup; + + if (!(actualCmdline =3D virBufferCurrentContent(&buf))) + goto cleanup; + + if (nodedevCompareToFile(actualCmdline, startcmdfile) < 0) + goto cleanup; + + if (virTestCompareToFile(stdinbuf, startjsonfile) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virBufferFreeAndReset(&buf); + virCommandSetDryRun(NULL, NULL, NULL); + virNodeDeviceObjEndAPI(&obj); + return ret; +} + +static int +testMdevctlStartHelper(const void *data) +{ + const struct startTestInfo *info =3D data; + + g_autofree char *mdevxml =3D g_strdup_printf("%s/nodedevschemadata/%s.= xml", + abs_srcdir, info->filename); + g_autofree char *cmdlinefile =3D g_strdup_printf("%s/nodedevmdevctldat= a/%s-start.argv", + abs_srcdir, info->filen= ame); + g_autofree char *jsonfile =3D g_strdup_printf("%s/nodedevmdevctldata/%= s-start.json", + abs_srcdir, info->filen= ame); + + return testMdevctlStart(info->virt_type, + info->create, mdevxml, cmdlinefile, + jsonfile); +} + +static void +nodedevTestDriverFree(virNodeDeviceDriverStatePtr drv) +{ + if (!drv) + return; + + virNodeDeviceObjListFree(drv->devs); + virCondDestroy(&drv->initCond); + virMutexDestroy(&drv->lock); + VIR_FREE(drv->stateDir); + VIR_FREE(drv); +} + +/* Add a fake root 'computer' device */ +static virNodeDeviceDefPtr +fakeRootDevice(void) +{ + virNodeDeviceDefPtr def =3D NULL; + + if (VIR_ALLOC(def) !=3D 0 || VIR_ALLOC(def->caps) !=3D 0) { + virNodeDeviceDefFree(def); + return NULL; + } + + def->name =3D g_strdup("computer"); + + return def; +} + +/* Add a fake pci device that can be used as a parent device for mediated + * devices. For our purposes, it only needs to have a name that matches the + * parent of the mdev, and it needs a PCI address + */ +static virNodeDeviceDefPtr +fakeParentDevice(void) +{ + virNodeDeviceDefPtr def =3D NULL; + virNodeDevCapPCIDevPtr pci_dev; + + if (VIR_ALLOC(def) !=3D 0 || VIR_ALLOC(def->caps) !=3D 0) { + virNodeDeviceDefFree(def); + return NULL; + } + + def->name =3D g_strdup("pci_0000_00_02_0"); + def->parent =3D g_strdup("computer"); + + def->caps->data.type =3D VIR_NODE_DEV_CAP_PCI_DEV; + pci_dev =3D &def->caps->data.pci_dev; + pci_dev->domain =3D 0; + pci_dev->bus =3D 0; + pci_dev->slot =3D 2; + pci_dev->function =3D 0; + + return def; +} + +static int +addDevice(virNodeDeviceDefPtr def) +{ + if (!def) + return -1; + + virNodeDeviceObjPtr obj =3D virNodeDeviceObjListAssignDef(driver->devs= , def); + + if (!obj) { + virNodeDeviceDefFree(def); + return -1; + } + + virNodeDeviceObjEndAPI(&obj); + return 0; +} + +static int +nodedevTestDriverAddTestDevices(void) +{ + if (addDevice(fakeRootDevice()) < 0 || + addDevice(fakeParentDevice()) < 0) + return -1; + + return 0; +} + +/* Bare minimum driver init to be able to test nodedev functionality */ +static int +nodedevTestDriverInit(void) +{ + int ret =3D -1; + if (VIR_ALLOC(driver) < 0) + return -1; + + driver->lockFD =3D -1; + if (virMutexInit(&driver->lock) < 0 || + virCondInit(&driver->initCond) < 0) { + VIR_TEST_DEBUG("Unable to initialize test nodedev driver"); + goto error; + } + + if (!(driver->devs =3D virNodeDeviceObjListNew())) + goto error; + + return 0; + + error: + nodedevTestDriverFree(driver); + return ret; +} + +static int +mymain(void) +{ + int ret =3D 0; + + if (nodedevTestDriverInit() < 0) + return EXIT_FAILURE; + + /* add a mock device to the device list so it can be used as a parent + * reference */ + if (nodedevTestDriverAddTestDevices() < 0) { + ret =3D EXIT_FAILURE; + goto done; + } + +#define DO_TEST_FULL(desc, func, info) \ + if (virTestRun(desc, func, &info) < 0) \ + ret =3D -1; + +#define DO_TEST_START_FULL(virt_type, create, filename) \ + do { \ + struct startTestInfo info =3D { virt_type, create, filename }; \ + DO_TEST_FULL("mdevctl start " filename, testMdevctlStartHelper, in= fo); \ + } \ + while (0); + +#define DO_TEST_START(filename) \ + DO_TEST_START_FULL("QEMU", CREATE_DEVICE, filename) + + /* 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"); + + done: + nodedevTestDriverFree(driver); + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIR_TEST_MAIN(mymain) diff --git a/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21= 366.xml b/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366= .xml new file mode 100644 index 0000000000..d6a2e99edc --- /dev/null +++ b/tests/nodedevschemadata/mdev_d069d019_36ea_4111_8f0a_8c9a70e21366.xml @@ -0,0 +1,7 @@ + + mdev_d069d019_36ea_4111_8f0a_8c9a70e21366 + pci_0000_00_02_0 + + + + diff --git a/tests/nodedevschemadata/mdev_d2441d39_495e_4243_ad9f_beb3f14c2= 3d9.xml b/tests/nodedevschemadata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9= .xml new file mode 100644 index 0000000000..89568d06ce --- /dev/null +++ b/tests/nodedevschemadata/mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9.xml @@ -0,0 +1,9 @@ + + mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9 + pci_0000_00_02_0 + + + + + + diff --git a/tests/nodedevschemadata/mdev_fedc4916_1ca8_49ac_b176_871d16c13= 076.xml b/tests/nodedevschemadata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076= .xml new file mode 100644 index 0000000000..7cd0a46e3d --- /dev/null +++ b/tests/nodedevschemadata/mdev_fedc4916_1ca8_49ac_b176_871d16c13076.xml @@ -0,0 +1,8 @@ + + mdev_fedc4916_1ca8_49ac_b176_871d16c13076 + pci_0000_00_02_0 + + + + + --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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 Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- 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 From nobody Sat Apr 27 02:32:08 2024 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=1592514405; cv=none; d=zohomail.com; s=zohoarc; b=MXqbBEgVVqs7lXTxL8cQuLNZ6/CtCjpJE06QnAUQjKmtcQmvZy/J8zUHtj71TcDTWhl4XhN0j4f61kG04YfOU5yU3AwbMiAvDrH8bnJs4ZhbAFEuaajfgpG9dSl3cYPxSI1/RhaxkPiCooTI7/o6uAiPOSSAHaicOwz1dBMJ3IQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514405; 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=s5oZFD9GFqZaVEfqSqVdoCTpBxUlr3krG6xhF2IV9HU=; b=ZfMPVrw/GjUlMa5Il5b3ogqe7lBLwtvjEJPp8T8bZ6xNhrlL4+Z9nGv2s7877trSpudFhHsf6pnYbIomcUTIMCG7DWiM/oNwwP6OKFv323zqJboIazyHkErlrepmN3jlxxoVHfWU1M9vgAGVoYb3PbtyOLl216oRO1W/DmrCI5A= 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 1592514405578988.1566376796401; Thu, 18 Jun 2020 14:06:45 -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-175-JbxjDO_4NDu1V7QgTWTiGQ-1; Thu, 18 Jun 2020 17:06:42 -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 6387F108BD10; Thu, 18 Jun 2020 21:06:34 +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 43DC25D9F1; Thu, 18 Jun 2020 21:06:34 +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 105861806B0B; Thu, 18 Jun 2020 21:06:34 +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 05IL6Esb002586 for ; Thu, 18 Jun 2020 17:06:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 28B0360CD3; Thu, 18 Jun 2020 21:06:14 +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 CDE7D60BF4; 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=1592514404; 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=s5oZFD9GFqZaVEfqSqVdoCTpBxUlr3krG6xhF2IV9HU=; b=RNRrzvncYv+aE6uVoYmZsxqlFwRLBgwhyz40kx8cfJIloMfC/pp3xs4Kqg3YwmNDt50NfV eFq3Qk3IAqww9RzVFbQyC8UqN01RxznEXgUKVuhRD9tyBSQzrWALhHCSQAfx6+qHZ3zS+P MVZv61IKhM5vyyyGrqokh5I+mE7UWRk= X-MC-Unique: JbxjDO_4NDu1V7QgTWTiGQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 10/12] nodedev: Add testing for 'mdevctl stop' Date: Thu, 18 Jun 2020 16:06:03 -0500 Message-Id: <20200618210605.12308-11-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.79 on 10.5.11.14 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" Test that we run 'mdevctl' with the proper arguments when we destroy mediated devices with virNodeDeviceDestroy() Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- tests/nodedevmdevctldata/mdevctl-stop.argv | 1 + tests/nodedevmdevctltest.c | 41 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/nodedevmdevctldata/mdevctl-stop.argv diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdev= ctldata/mdevctl-stop.argv new file mode 100644 index 0000000000..3dbaab671b --- /dev/null +++ b/tests/nodedevmdevctldata/mdevctl-stop.argv @@ -0,0 +1 @@ +$MDEVCTL_BINARY$ stop -u e2451f73-c95b-4124-b900-e008af37c576 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 4b029c7286..f5bcf5227d 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -110,6 +110,41 @@ testMdevctlStartHelper(const void *data) jsonfile); } =20 +static int +testMdevctlStop(const void *data) +{ + const char *uuid =3D data; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + const char *actualCmdline =3D NULL; + int ret =3D -1; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *cmdlinefile =3D + g_strdup_printf("%s/nodedevmdevctldata/mdevctl-stop.argv", + abs_srcdir); + + cmd =3D nodeDeviceGetMdevctlStopCommand(uuid); + + if (!cmd) + goto cleanup; + + virCommandSetDryRun(&buf, NULL, NULL); + if (virCommandRun(cmd, NULL) < 0) + goto cleanup; + + if (!(actualCmdline =3D virBufferCurrentContent(&buf))) + goto cleanup; + + if (nodedevCompareToFile(actualCmdline, cmdlinefile) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virBufferFreeAndReset(&buf); + virCommandSetDryRun(NULL, NULL, NULL); + return ret; +} + static void nodedevTestDriverFree(virNodeDeviceDriverStatePtr drv) { @@ -248,11 +283,17 @@ mymain(void) #define DO_TEST_START(filename) \ DO_TEST_START_FULL("QEMU", CREATE_DEVICE, filename) =20 +#define DO_TEST_STOP(uuid) \ + DO_TEST_FULL("mdevctl stop " uuid, testMdevctlStop, uuid) + /* 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"); =20 + /* Test mdevctl stop command, pass an arbitrary uuid */ + DO_TEST_STOP("e2451f73-c95b-4124-b900-e008af37c576"); + done: nodedevTestDriverFree(driver); =20 --=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514403; cv=none; d=zohomail.com; s=zohoarc; b=Y20W8YmY1/OgnQ/hNqoO9vncArwUueuOoblBS2Scq3/9AhqOFKEFbL5ggPoIcS1hE++Y4tAbw9D8fwfc3/xdZd6TIWo0upM2KbV55jq2gxycZoAcMio6itKvx69ZWlNIdvrcYbs9TsBmkFroSlIjPCscniz743dE+WcO4ypRzB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514403; 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=r4DNHlA8fsqMtQU+EbXPBoNIuB3HI8aX4Q2ByrCrXNI=; b=DyJGpvVh2hUiLcYRPkOAwC8jjs3aI6DjpWVaRx6cD01Sbr+ZKatdpNYkPxsrYXhNGcRKGueoiLADjiD7t4RFSQpeVu5d7Kucdx10YNhD4QtKjgsmTWT1+4Y2Ojn1cVP3ShiLnU2pATDBNyijwuS22RtbrSDSnMdJBHYKCOYVhnE= 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 1592514403910282.48217117582067; Thu, 18 Jun 2020 14:06:43 -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-243-CnJFH7TwPLuUCg5MjMr_sQ-1; Thu, 18 Jun 2020 17:06:40 -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 6F7E28035CD; Thu, 18 Jun 2020 21:06:34 +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 4F5F77166D; Thu, 18 Jun 2020 21:06:34 +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 0CDB1833D8; Thu, 18 Jun 2020 21:06:34 +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 05IL6EiB002591 for ; Thu, 18 Jun 2020 17:06:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93B7B60E3E; Thu, 18 Jun 2020 21:06:14 +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 4548B60BF4; Thu, 18 Jun 2020 21:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514402; 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=r4DNHlA8fsqMtQU+EbXPBoNIuB3HI8aX4Q2ByrCrXNI=; b=Cs7mv+x9SixRGoOiWEdRqWlIBWvBNJWBFzY0qtrWuzD/4TXhXgB/Y1DlxZIMlHWBrp2rRh lBFuC9ARwFur64CsUbk4zvTD0ZeYpwC4gAx+/yacJ3EX4F+ozuzTlpIZSoSHlPYPuuKT/5 tUAp+AC1jdDtnd7YOfBbg7AKn0l938c= X-MC-Unique: CnJFH7TwPLuUCg5MjMr_sQ-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 11/12] docs: note node device fields that are read-only Date: Thu, 18 Jun 2020 16:06:04 -0500 Message-Id: <20200618210605.12308-12-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.79 on 10.5.11.11 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" As noted by Erik Skultety, we use the same XML schema to report existing devices and to define new devices. However, some schema elements are "read-only". In other words, they are used to report information from the node device driver and cannot be used to define a new device. Note these in the documentation. Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- docs/formatnode.html.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index 0637d457ee..e4328fedbe 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -31,11 +31,16 @@ name is just the bus type and address, as in "pci_0000_00_02_1" or "usb_1_5_3", but some devices are able to provide more specific names, such as - "net_eth1_00_27_13_6a_fe_00". + "net_eth1_00_27_13_6a_fe_00". This is a read-only field that is + reported by the device driver. If this element is set when definin= g a + new device, it will be ignored. +
path
- Fully qualified sysfs path to the device. + Fully qualified sysfs path to the device. This is a read-only field + that is reported by the device driver. If this element is set when + defining a new device, it will be ignored.
parent
--=20 2.21.3 From nobody Sat Apr 27 02:32:08 2024 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=1592514471; cv=none; d=zohomail.com; s=zohoarc; b=AnEk7ZSFTAJ1NeQSO+5dj/BrEG7pUkgMAZx0bPovDz+m5+o6r/lGD9LuulkP2OazIyeKXAtJAmczpzGLr/B+qpV/9TbnJLt4wvAryrGaDEYLpVUzN3kUMW5ReQw3sVzf1bPQ5APAiAxq2gEV7rU0C9Ei+NR0M1kvcWvnfyzEzsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592514471; 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=H2r4mUt8awmdU1I0rF8H16MxGHq4TF9ANMsU097wLXA=; b=I18v7emrjqLE/CnfPMXrt22F+6OyY3kv3aXiMWXaFYH6fccOaC5lhggpaxwiN/tOJCQ9UqGJ/0tqs8tJgCuZAG6B8/Z+HokH+8mBRIYzKzzQWjhy23P+46xOAhCXmQqqv7/o4bIBbaYve+r53Y6i+unjKWevTZsadDEizgTPQLU= 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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15925144716181000.5876541735033; Thu, 18 Jun 2020 14:07:51 -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-5-wTbl6IR9Owq5EMzey-7V0Q-1; Thu, 18 Jun 2020 17:06:42 -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 748178AB385; Thu, 18 Jun 2020 21:06:35 +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 53E105BACA; Thu, 18 Jun 2020 21:06:35 +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 21EC0180530A; Thu, 18 Jun 2020 21:06:35 +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 05IL6F3w002596 for ; Thu, 18 Jun 2020 17:06:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A1E360CD3; Thu, 18 Jun 2020 21:06:15 +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 B0B8E60BF4; Thu, 18 Jun 2020 21:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514444; 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=H2r4mUt8awmdU1I0rF8H16MxGHq4TF9ANMsU097wLXA=; b=Nntp7kKHQD+G6hIJRVh+98ykvYaUcBAbV6PtsgH2/no3gDTPD6JqXwMYz2nbBVRJ7m5mYs sEkKFWGrBIXXP32NnurqFnlG7Gg0urnQlN8jAuSzN+Y1dGtmacgQvAaoC/cj1CGcweh/ri u4JZL8UApOEjf1cJd3NEZM9t1mzREkU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592514470; 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=H2r4mUt8awmdU1I0rF8H16MxGHq4TF9ANMsU097wLXA=; b=byZWQcHhyH2xMQao8OdCiOJ+hUMVcENw9fB4alXNlm4MyEOjFlP2HgpQimIom12E1qkEyp xy0W0ueAG/kCRhZpJdf7IudtMNy15yDknXPfH/QGGo1Wud3L/cLaZYzBeLo8Qo+ZuhhYAU 3Yw8wyMhwzyg4yBZZvzyFJ1XRq1qYek= X-MC-Unique: wTbl6IR9Owq5EMzey-7V0Q-1 From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 12/12] news: mediated devices can be created Date: Thu, 18 Jun 2020 16:06:05 -0500 Message-Id: <20200618210605.12308-13-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.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) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jonathon Jongsma Reviewed-by: Erik Skultety Reviewed-by: Michal Privoznik --- NEWS.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 20964b94d7..42d159b233 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -21,6 +21,13 @@ v6.5.0 (unreleased) It's possible to either specify new value as a string or provide a filename which contents then serve as the value. =20 + * nodedev: Add ability to create mediated devices + + Mediated devices can now be created with ``virNodeDeviceCreateXML()``.= This + functionality requires the ``mdevctl`` utility to be installed. The XML + schema for node devices was expanded to support attributes for mediated + devices. + * **Improvements** =20 * **Bug fixes** --=20 2.21.3