From nobody Wed May 1 11:32:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 148710646473677.31001879962264; Tue, 14 Feb 2017 13:07:44 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4aGf021444; Tue, 14 Feb 2017 16:04:36 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4Lwx005026 for ; Tue, 14 Feb 2017 16:04:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id D6BF174A1C; Tue, 14 Feb 2017 21:04:21 +0000 (UTC) Received: from localhost (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC2B892450; Tue, 14 Feb 2017 21:04:20 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 01:04:09 +0400 Message-Id: <20170214210413.23142-2-marcandre.lureau@redhat.com> In-Reply-To: <20170214210413.23142-1-marcandre.lureau@redhat.com> References: <20170214210413.23142-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 1/5] nodedev: fix extra space in dump 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau This is a cosmetic change, shouldn't change XML parsing, and doesn't break any test. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/conf/node_device_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 4d3268f12..6163fd5ed 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -678,7 +678,7 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *de= f) data->storage.num_blocks); } if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABL= E) - virBufferAddLit(&buf, "\n"); + virBufferAddLit(&buf, "= \n"); break; case VIR_NODE_DEV_CAP_SCSI_GENERIC: virBufferEscapeString(&buf, "%s\n", --=20 2.11.0.295.gd7dffce1c.dirty -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:32:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487106503661427.8804253816264; Tue, 14 Feb 2017 13:08:23 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4cIP029237; Tue, 14 Feb 2017 16:04:38 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4QQf005037 for ; Tue, 14 Feb 2017 16:04:26 -0500 Received: from localhost (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1EL4NQw029418; Tue, 14 Feb 2017 16:04:25 -0500 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 01:04:10 +0400 Message-Id: <20170214210413.23142-3-marcandre.lureau@redhat.com> In-Reply-To: <20170214210413.23142-1-marcandre.lureau@redhat.com> References: <20170214210413.23142-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 2/5] nodedev: add paths 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Add new top-level element, that list the associated /dev files. Distinguish the main /dev name from symlinks with a 'type' attribute of value 'dev' or 'symlink'. Update a test to check XML schema, and actually add it to the test list since it was missing. Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/formatnode.html.in | 6 +++ docs/schemas/nodedev.rng | 16 +++++++ src/conf/node_device_conf.c | 54 ++++++++++++++++++= +++- src/conf/node_device_conf.h | 12 +++++ src/node_device/node_device_udev.c | 31 +++++++++++++ ...ge_serial_3600c0ff000d7a2a5d463ff4902000000.xml | 4 ++ tests/nodedevxml2xmltest.c | 1 + 7 files changed, 123 insertions(+), 1 deletion(-) diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index f8d0e1234..ecdd1dbcb 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -37,6 +37,12 @@
If this element is present, it names the parent device (that is, a controller to which this node belongs).
+
devnode
+
This node appears for each associated /dev + special file. A mandatory attribute type specify + the kind of file path, which may be either dev for + the main name, or link for additional symlinks. +
capability
This node appears for each capability that libvirt associates with a node. A mandatory diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index b100a6e16..62e29b6cc 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -16,6 +16,22 @@ + + + dev + + + + + + + + link + + + + + =20 diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 6163fd5ed..49ecc8897 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -40,6 +40,10 @@ =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 +VIR_ENUM_IMPL(virNodeDevDevnode, VIR_NODE_DEV_DEVNODE_LAST, + "dev", + "link") + VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, "system", "pci", @@ -252,6 +256,8 @@ void virNodeDeviceDefFree(virNodeDeviceDefPtr def) VIR_FREE(def->driver); VIR_FREE(def->sysfs_path); VIR_FREE(def->parent_sysfs_path); + VIR_FREE(def->devnode); + virStringListFree(def->devlinks); =20 caps =3D def->caps; while (caps) { @@ -387,6 +393,14 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *d= ef) virBufferAdjustIndent(&buf, 2); virBufferEscapeString(&buf, "%s\n", def->name); virBufferEscapeString(&buf, "%s\n", def->sysfs_path); + if (def->devnode) + virBufferEscapeString(&buf, "%s\n", + def->devnode); + if (def->devlinks) { + for (i =3D 0; def->devlinks[i]; i++) + virBufferEscapeString(&buf, "%s\n", + def->devlinks[i]); + } if (def->parent) virBufferEscapeString(&buf, "%s\n", def->parent); if (def->driver) { @@ -1703,7 +1717,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def; virNodeDevCapsDefPtr *next_cap; xmlNodePtr *nodes; - int n; + int n, m; size_t i; =20 if (VIR_ALLOC(def) < 0) @@ -1722,6 +1736,44 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, goto error; } =20 + /* Parse devnodes */ + nodes =3D NULL; + if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) + goto error; + + if (VIR_ALLOC_N(def->devlinks, n + 1) < 0) + goto error; + + for (i =3D 0, m =3D 0; i < n; i++) { + xmlNodePtr node =3D nodes[i]; + char *tmp =3D virXMLPropString(node, "type"); + virNodeDevDevnodeType type; + + if (!tmp) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing devnode type")); + goto error; + } + + if ((type =3D virNodeDevDevnodeTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown devnode type '%s'"), tmp); + VIR_FREE(tmp); + goto error; + } + + switch (type) { + case VIR_NODE_DEV_DEVNODE_DEV: + def->devnode =3D (char*)xmlNodeGetContent(node); + break; + case VIR_NODE_DEV_DEVNODE_LINK: + def->devlinks[m++] =3D (char*)xmlNodeGetContent(node); + break; + case VIR_NODE_DEV_DEVNODE_LAST: + break; + } + } + /* Extract device parent, if any */ def->parent =3D virXPathString("string(./parent[1])", ctxt); def->parent_wwnn =3D virXPathString("string(./parent[1]/@wwnn)", ctxt); diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 163448333..f46e9841a 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -40,6 +40,16 @@ =20 typedef enum { /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ + VIR_NODE_DEV_DEVNODE_DEV, + VIR_NODE_DEV_DEVNODE_LINK, + + VIR_NODE_DEV_DEVNODE_LAST +} virNodeDevDevnodeType; + +VIR_ENUM_DECL(virNodeDevDevnode) + +typedef enum { + /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ VIR_NODE_DEV_CAP_SYSTEM, /* System capability */ VIR_NODE_DEV_CAP_PCI_DEV, /* PCI device */ VIR_NODE_DEV_CAP_USB_DEV, /* USB device */ @@ -204,6 +214,8 @@ struct _virNodeDeviceDef { char *parent_wwpn; /* optional parent wwpn */ char *parent_fabric_wwn; /* optional parent fabric_wwn */ char *driver; /* optional driver name */ + char *devnode; /* /dev path */ + char **devlinks; /* /dev links */ virNodeDevCapsDefPtr caps; /* optional device capabilities */ }; =20 diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 4b813127c..d7658410a 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -918,6 +918,34 @@ udevProcessSCSIGeneric(struct udev_device *dev, } =20 static int +udevGetDeviceNodes(struct udev_device *device, + virNodeDeviceDefPtr def) +{ + const char *devnode =3D NULL; + struct udev_list_entry *list_entry =3D NULL; + int n =3D 0; + + devnode =3D udev_device_get_devnode(device); + + if (VIR_STRDUP(def->devnode, devnode) < 0) + return -1; + + udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) + n++; + + if (VIR_ALLOC_N(def->devlinks, n + 1) < 0) + return -1; + + n =3D 0; + udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) { + if (VIR_STRDUP(def->devlinks[n++], udev_list_entry_get_name(list_e= ntry)) < 0) + return -1; + } + + return 0; +} + +static int udevGetDeviceType(struct udev_device *device, virNodeDevCapType *type) { @@ -1125,6 +1153,9 @@ static int udevAddOneDevice(struct udev_device *devic= e) if (udevGetDeviceType(device, &def->caps->data.type) !=3D 0) goto cleanup; =20 + if (udevGetDeviceNodes(device, def) !=3D 0) + goto cleanup; + if (udevGetDeviceDetails(device, def) !=3D 0) goto cleanup; =20 diff --git a/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff= 4902000000.xml b/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d4= 63ff4902000000.xml index d9d61da44..d225dca8f 100644 --- a/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000= 000.xml +++ b/tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000= 000.xml @@ -1,5 +1,9 @@ storage_serial_3600c0ff000d7a2a5d463ff4902000000 + /dev/sdb + /dev/disk/by-id/usb-SanDisk_Ultra_Fit_4C530001051= 009112405-0:0 + /dev/disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-sc= si-0:0:0:0 + /dev/disk/by-uuid/661A1A460111DA18 pci_10df_fe00_scsi_host_scsi_device_lun8 /dev/sdj diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index eb32dd31d..ec96943cb 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -87,6 +87,7 @@ mymain(void) DO_TEST("pci_8086_27c5_scsi_host_scsi_host"); DO_TEST("pci_8086_27c5_scsi_host"); DO_TEST("storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE"); + DO_TEST("storage_serial_3600c0ff000d7a2a5d463ff4902000000"); DO_TEST("usb_device_1d6b_1_0000_00_1d_0_if0"); DO_TEST("usb_device_1d6b_1_0000_00_1d_0"); DO_TEST("pci_8086_4238_pcie_wireless"); --=20 2.11.0.295.gd7dffce1c.dirty -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:32:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487106469556895.1065452717049; Tue, 14 Feb 2017 13:07:49 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4a8T029226; Tue, 14 Feb 2017 16:04:36 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4Tej005047 for ; Tue, 14 Feb 2017 16:04:29 -0500 Received: from localhost (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1EL4Rkq010537; Tue, 14 Feb 2017 16:04:28 -0500 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 01:04:11 +0400 Message-Id: <20170214210413.23142-4-marcandre.lureau@redhat.com> In-Reply-To: <20170214210413.23142-1-marcandre.lureau@redhat.com> References: <20170214210413.23142-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 3/5] nodedev: parse 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau This should have been added with c4a4603de (or 0bdefd9b04). Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/conf/node_device_conf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 49ecc8897..0d1dafcd6 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1736,6 +1736,8 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, goto error; } =20 + def->sysfs_path =3D virXPathString("string(./path[1])", ctxt); + /* Parse devnodes */ nodes =3D NULL; if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) --=20 2.11.0.295.gd7dffce1c.dirty -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:32:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487106490904913.1685087877571; Tue, 14 Feb 2017 13:08:10 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4YQc021432; Tue, 14 Feb 2017 16:04:34 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4Xj4005058 for ; Tue, 14 Feb 2017 16:04:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id A76B174A1C; Tue, 14 Feb 2017 21:04:33 +0000 (UTC) Received: from localhost (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1C007239B; Tue, 14 Feb 2017 21:04:32 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 01:04:12 +0400 Message-Id: <20170214210413.23142-5-marcandre.lureau@redhat.com> In-Reply-To: <20170214210413.23142-1-marcandre.lureau@redhat.com> References: <20170214210413.23142-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 4/5] nodedev: add drm capability 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Add a new 'drm' capability for Direct Rendering Manager (DRM) devices, providing device type information. Teach the udev backend to populate those devices. Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/formatnode.html.in | 10 +++++++ docs/schemas/nodedev.rng | 14 ++++++++++ src/conf/node_device_conf.c | 44 ++++++++++++++++++++++++++= +++- src/conf/node_device_conf.h | 15 ++++++++++ src/node_device/node_device_driver.c | 1 + src/node_device/node_device_udev.c | 41 ++++++++++++++++++++++++++= ++ tests/nodedevschemadata/drm_renderD129.xml | 10 +++++++ tests/nodedevxml2xmltest.c | 1 + 8 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 tests/nodedevschemadata/drm_renderD129.xml diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in index ecdd1dbcb..a368ffc07 100644 --- a/docs/formatnode.html.in +++ b/docs/formatnode.html.in @@ -314,6 +314,16 @@ and media_label.
+
drm
+
Describes a Direct Rendering Manager (DRM) device. + Sub-elements include: +
+
type
+
The type of DRM device. Could be + primary, control or + render.
+
+
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng index 62e29b6cc..0f90a73c8 100644 --- a/docs/schemas/nodedev.rng +++ b/docs/schemas/nodedev.rng @@ -82,6 +82,7 @@ + @@ -540,6 +541,19 @@ =20 + + + drm + + + + primary + control + render + + + + diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 0d1dafcd6..04b63cc93 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -56,12 +56,18 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, "storage", "fc_host", "vports", - "scsi_generic") + "scsi_generic", + "drm") =20 VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST, "80203", "80211") =20 +VIR_ENUM_IMPL(virNodeDevDRM, VIR_NODE_DEV_DRM_LAST, + "primary", + "control", + "render") + static int virNodeDevCapsDefParseString(const char *xpath, xmlXPathContextPtr ctxt, @@ -698,6 +704,9 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *de= f) virBufferEscapeString(&buf, "%s\n", data->sg.path); break; + case VIR_NODE_DEV_CAP_DRM: + virBufferEscapeString(&buf, "%s\n", virNodeDevDRM= TypeToString(data->drm.type)); + break; case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_LAST: @@ -799,6 +808,35 @@ virNodeDevCapsDefParseULongLong(const char *xpath, } =20 static int +virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, + xmlNodePtr node, + virNodeDevCapDataPtr data) +{ + xmlNodePtr orignode; + int ret =3D -1; + char *type =3D NULL; + + orignode =3D ctxt->node; + ctxt->node =3D node; + + type =3D virXPathString("string(./type[1])", ctxt); + + if ((data->drm.type =3D virNodeDevDRMTypeFromString(type)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown drm type '%s' for '%s'"), type, def->nam= e); + goto out; + } + + ret =3D 0; + +out: + VIR_FREE(type); + ctxt->node =3D orignode; + return ret; +} + +static int virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def, xmlNodePtr node, @@ -1689,6 +1727,9 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, case VIR_NODE_DEV_CAP_STORAGE: ret =3D virNodeDevCapStorageParseXML(ctxt, def, node, &caps->data); break; + case VIR_NODE_DEV_CAP_DRM: + ret =3D virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data); + break; case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_SCSI_GENERIC: @@ -2116,6 +2157,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) case VIR_NODE_DEV_CAP_SCSI_GENERIC: VIR_FREE(data->sg.path); break; + case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_LAST: diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index f46e9841a..be7e0e003 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -62,6 +62,7 @@ typedef enum { VIR_NODE_DEV_CAP_FC_HOST, /* FC Host Bus Adapter */ VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */ VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */ + VIR_NODE_DEV_CAP_DRM, /* DRM device */ =20 VIR_NODE_DEV_CAP_LAST } virNodeDevCapType; @@ -93,6 +94,17 @@ typedef enum { VIR_NODE_DEV_CAP_FLAG_PCIE =3D (1 << 2), } virNodeDevPCICapFlags; =20 +typedef enum { + /* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */ + VIR_NODE_DEV_DRM_PRIMARY, + VIR_NODE_DEV_DRM_CONTROL, + VIR_NODE_DEV_DRM_RENDER, + + VIR_NODE_DEV_DRM_LAST +} virNodeDevDRMType; + +VIR_ENUM_DECL(virNodeDevDRM) + typedef struct _virNodeDevCapData { virNodeDevCapType type; union { @@ -192,6 +204,9 @@ typedef struct _virNodeDevCapData { struct { char *path; } sg; /* SCSI generic device */ + struct { + virNodeDevDRMType type; + } drm; }; } virNodeDevCapData, *virNodeDevCapDataPtr; =20 diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 5238e231d..d04713f5e 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -72,6 +72,7 @@ static int update_caps(virNodeDeviceObjPtr dev) /* all types that (supposedly) don't require any updates * relative to what's in the cache. */ + case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_USB_DEV: case VIR_NODE_DEV_CAP_USB_INTERFACE: diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index d7658410a..6a91e0722 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -410,6 +410,42 @@ static int udevProcessPCI(struct udev_device *device, return ret; } =20 +static int drmGetMinorType(int minor) +{ + int type =3D minor >> 6; + + if (minor < 0) + return -1; + + switch (type) { + case VIR_NODE_DEV_DRM_PRIMARY: + case VIR_NODE_DEV_DRM_CONTROL: + case VIR_NODE_DEV_DRM_RENDER: + return type; + default: + return -1; + } +} + +static int udevProcessDRMDevice(struct udev_device *device, + virNodeDeviceDefPtr def) +{ + virNodeDevCapDataPtr data =3D &def->caps->data; + int minor; + + if (udevGenerateDeviceName(device, def, NULL) !=3D 0) + return -1; + + if (udevGetIntProperty(device, "MINOR", &minor, 10) < 0) + return -1; + + if ((minor =3D drmGetMinorType(minor)) =3D=3D -1) + return -1; + + data->drm.type =3D minor; + + return 0; +} =20 static int udevProcessUSBDevice(struct udev_device *device, virNodeDeviceDefPtr def) @@ -971,6 +1007,8 @@ udevGetDeviceType(struct udev_device *device, *type =3D VIR_NODE_DEV_CAP_STORAGE; else if (STREQ(devtype, "wlan")) *type =3D VIR_NODE_DEV_CAP_NET; + else if (STREQ(devtype, "drm_minor")) + *type =3D VIR_NODE_DEV_CAP_DRM; } else { /* PCI devices don't set the DEVTYPE property. */ if (udevHasDeviceProperty(device, "PCI_CLASS")) @@ -1039,6 +1077,9 @@ static int udevGetDeviceDetails(struct udev_device *d= evice, case VIR_NODE_DEV_CAP_SCSI_GENERIC: ret =3D udevProcessSCSIGeneric(device, def); break; + case VIR_NODE_DEV_CAP_DRM: + ret =3D udevProcessDRMDevice(device, def); + break; default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown device type %d"), def->caps->data.type); diff --git a/tests/nodedevschemadata/drm_renderD129.xml b/tests/nodedevsche= madata/drm_renderD129.xml new file mode 100644 index 000000000..161481624 --- /dev/null +++ b/tests/nodedevschemadata/drm_renderD129.xml @@ -0,0 +1,10 @@ + + drm_renderD129 + /sys/devices/pci0000:00/0000:00:02.0/drm/renderD129 + /dev/dri/renderD129 + /dev/dri/by-path/pci-0000:00:02.0-render + pci_0000_00_02_0 + + render + + diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index ec96943cb..5e1ae170c 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -100,6 +100,7 @@ mymain(void) DO_TEST("pci_0000_02_10_7_sriov_zero_vfs_max_count"); DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all"); DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type"); + DO_TEST("drm_renderD129"); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.11.0.295.gd7dffce1c.dirty -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 11:32:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1487106489315164.9965654219368; Tue, 14 Feb 2017 13:08:09 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1EL4d3n057426; Tue, 14 Feb 2017 16:04:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1EL4bkA005074 for ; Tue, 14 Feb 2017 16:04:37 -0500 Received: from localhost (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1EL4ZOc029496; Tue, 14 Feb 2017 16:04:36 -0500 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Wed, 15 Feb 2017 01:04:13 +0400 Message-Id: <20170214210413.23142-6-marcandre.lureau@redhat.com> In-Reply-To: <20170214210413.23142-1-marcandre.lureau@redhat.com> References: <20170214210413.23142-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 5/5] qemu: add rendernode argument 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Add a new attribute 'rendernode' to spice element. Give it to QEMU if qemu supports it (queued for 2.9). Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/formatdomain.html.in | 7 +++++- docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 28 ++++++++++++++++++= +--- src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 10 ++++++++ .../qemuxml2argv-video-virtio-gpu-spice-gl.args | 2 +- .../qemuxml2argv-video-virtio-gpu-spice-gl.xml | 2 +- tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 2 +- 11 files changed, 54 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0a115f5dc..67f486747 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5619,7 +5619,7 @@ qemu-kvm -net nic,model=3D? /dev/null <clipboard copypaste=3D'no'/> <mouse mode=3D'client'/> <filetransfer enable=3D'no'/> - <gl enable=3D'yes'/> + <gl enable=3D'yes' rendernode=3D'/dev/dri/by-path/pci-0000:00:02.0-re= nder'/> </graphics>

Spice supports variable compression settings for audio, imag= es and @@ -5665,6 +5665,11 @@ qemu-kvm -net nic,model=3D? /dev/null the gl element, by setting the enable property. (QEMU only, since 1.3.3).

+

+ By default, QEMU will pick the first available GPU DRM rende= r node. + You may specify a DRM render node path to use instead. (QEMU= only, + since 3.1). +

rdp
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d715bff29..c5f101325 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3033,6 +3033,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1bc72a4e9..b577d0aba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1300,6 +1300,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr= def) break; =20 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + VIR_FREE(def->data.spice.rendernode); VIR_FREE(def->data.spice.keymap); virDomainGraphicsAuthDefClear(&def->data.spice.auth); break; @@ -12141,6 +12142,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, def->data.spice.filetransfer =3D enableVal; } else if (xmlStrEqual(cur->name, BAD_CAST "gl")) { char *enable =3D virXMLPropString(cur, "enable"); + char *rendernode =3D virXMLPropString(cur, "rendernode"); int enableVal; =20 if (!enable) { @@ -12159,6 +12161,8 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, VIR_FREE(enable); =20 def->data.spice.gl =3D enableVal; + def->data.spice.rendernode =3D rendernode; + } else if (xmlStrEqual(cur->name, BAD_CAST "mouse")) { char *mode =3D virXMLPropString(cur, "mode"); int modeVal; @@ -22839,6 +22843,23 @@ virDomainGraphicsListenDefFormatAddr(virBufferPtr = buf, virBufferAsprintf(buf, " listen=3D'%s'", glisten->address); } =20 +static int +virDomainSpiceGLDefFormat(virBufferPtr buf, virDomainGraphicsDefPtr def) +{ + if (def->data.spice.gl =3D=3D VIR_TRISTATE_BOOL_ABSENT) { + return 0; + } + + virBufferAsprintf(buf, "data.spice.gl)); + + if (def->data.spice.rendernode) + virBufferEscapeString(buf, " rendernode=3D'%s'", def->data.spice.r= endernode); + + virBufferAddLit(buf, "/>\n"); + + return 0; +} =20 static int virDomainGraphicsDefFormat(virBufferPtr buf, @@ -23082,9 +23103,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf, if (def->data.spice.filetransfer) virBufferAsprintf(buf, "\n", virTristateBoolTypeToString(def->data.spice.= filetransfer)); - if (def->data.spice.gl) - virBufferAsprintf(buf, "\n", - virTristateBoolTypeToString(def->data.spice.= gl)); + + if (virDomainSpiceGLDefFormat(buf, def) < 0) { + return -1; + } } =20 if (children) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index dd79206f6..7e1afa475 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1544,6 +1544,7 @@ struct _virDomainGraphicsDef { virTristateBool copypaste; virTristateBool filetransfer; virTristateBool gl; + char *rendernode; } spice; } data; /* nListens, listens, and *port are only useful if type is vnc, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 399e31447..e851eec7a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -357,6 +357,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, =20 "query-cpu-model-expansion", /* 245 */ "virtio-net.host_mtu", + "spice-rendernode", ); =20 =20 @@ -2950,6 +2951,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCaps= CommandLine[] =3D { { "spice", "unix", QEMU_CAPS_SPICE_UNIX }, { "drive", "throttling.bps-total-max-length", QEMU_CAPS_DRIVE_IOTUNE_M= AX_LENGTH }, { "drive", "throttling.group", QEMU_CAPS_DRIVE_IOTUNE_GROUP }, + { "spice", "rendernode", QEMU_CAPS_SPICE_RENDERNODE }, }; =20 static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 95bb67d44..0f998c473 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -393,6 +393,7 @@ typedef enum { /* 245 */ QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION, /* qmp query-cpu-model-expansion = */ QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */ + QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c00a47a91..f4bcfd467 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7920,6 +7920,16 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfi= gPtr cfg, * TristateSwitch helper */ virBufferAsprintf(&opt, "gl=3D%s,", virTristateSwitchTypeToString(graphics->data.spi= ce.gl)); + + if (graphics->data.spice.rendernode) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU doesn't support spice OpenGL r= endernode")); + goto error; + } + + virBufferAsprintf(&opt, "rendernode=3D%s,", graphics->data.spi= ce.rendernode); + } } =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION)) { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.= args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args index f1ebb62e4..84439cddc 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args @@ -19,6 +19,6 @@ QEMU_AUDIO_DRV=3Dspice \ -drive file=3D/var/lib/libvirt/images/QEMUGuest1,format=3Dqcow2,if=3Dnone,\ id=3Ddrive-ide0-0-0,cache=3Dnone \ -device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ --spice port=3D0,gl=3Don \ +-spice port=3D0,gl=3Don,rendernode=3D/dev/dri/foo \ -device virtio-gpu-pci,id=3Dvideo0,virgl=3Don,bus=3Dpci.0,addr=3D0x2 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.= xml b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml index b9c7c8af0..fd2580635 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.xml @@ -26,7 +26,7 @@ - +