2013-03-08 20:47:00 +01:00
|
|
|
>From 5aeda96eafd230af55343e7ef835e081ded484aa Mon Sep 17 00:00:00 2001
|
|
|
|
From: Chunyan Liu <cyliu@suse.com>
|
|
|
|
Date: Fri, 25 Jan 2013 17:37:14 +0800
|
|
|
|
Subject: [PATCH] support managed pci devices in xen driver
|
|
|
|
|
|
|
|
---
|
|
|
|
src/xenxs/xen_sxpr.c | 22 ++++++++--------------
|
|
|
|
src/xenxs/xen_xm.c | 28 +++++++++++++++++++++++++++-
|
|
|
|
2 files changed, 35 insertions(+), 15 deletions(-)
|
|
|
|
|
2019-11-06 16:48:56 +01:00
|
|
|
Index: libvirt-5.9.0/src/libxl/xen_common.c
|
2013-03-08 20:47:00 +01:00
|
|
|
===================================================================
|
2019-11-06 16:48:56 +01:00
|
|
|
--- libvirt-5.9.0.orig/src/libxl/xen_common.c
|
|
|
|
+++ libvirt-5.9.0/src/libxl/xen_common.c
|
|
|
|
@@ -383,12 +383,19 @@ xenParsePCI(char *entry)
|
2018-07-16 18:42:10 +02:00
|
|
|
int busID;
|
|
|
|
int slotID;
|
|
|
|
int funcID;
|
2014-09-02 17:52:40 +02:00
|
|
|
+ char *opt;
|
|
|
|
+ int managed = 0;
|
|
|
|
|
2018-07-16 18:42:10 +02:00
|
|
|
domain[0] = bus[0] = slot[0] = func[0] = '\0';
|
|
|
|
|
|
|
|
/* pci=['0000:00:1b.0','0000:00:13.0'] */
|
|
|
|
if (!(key = entry))
|
|
|
|
return NULL;
|
2014-09-02 17:52:40 +02:00
|
|
|
+
|
2018-07-16 18:42:10 +02:00
|
|
|
+ opt = strchr(key, ',');
|
|
|
|
+ if (opt)
|
|
|
|
+ opt++;
|
2014-09-02 17:52:40 +02:00
|
|
|
+
|
2018-07-16 18:42:10 +02:00
|
|
|
if (!(nextkey = strchr(key, ':')))
|
|
|
|
return NULL;
|
2018-08-07 00:52:48 +02:00
|
|
|
if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) < 0) {
|
2019-11-06 16:48:56 +01:00
|
|
|
@@ -433,10 +440,30 @@ xenParsePCI(char *entry)
|
2018-07-16 18:42:10 +02:00
|
|
|
if (virStrToLong_i(func, NULL, 16, &funcID) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
+ if (opt) {
|
|
|
|
+ char opt_managed[2];
|
|
|
|
+ char *data;
|
2014-09-02 17:52:40 +02:00
|
|
|
+
|
2018-07-16 18:42:10 +02:00
|
|
|
+ opt_managed[0] = '\0';
|
|
|
|
+ data = strchr(opt, '=');
|
|
|
|
+ data++;
|
2014-09-02 17:52:40 +02:00
|
|
|
+
|
2018-07-16 18:42:10 +02:00
|
|
|
+ if (STRPREFIX(opt, "managed=")) {
|
2019-04-25 23:19:16 +02:00
|
|
|
+ if (virStrncpy(opt_managed, data, 1, sizeof(opt_managed)) < 0) {
|
2018-07-16 18:42:10 +02:00
|
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
+ _("managed option %s too big for destination"),
|
|
|
|
+ data);
|
|
|
|
+ return NULL;
|
2014-09-02 17:52:40 +02:00
|
|
|
+ }
|
2018-07-16 18:42:10 +02:00
|
|
|
+ }
|
|
|
|
+ if (virStrToLong_i(opt_managed, NULL, 10, &managed) < 0)
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
2014-09-02 17:52:40 +02:00
|
|
|
+
|
2018-07-16 18:42:10 +02:00
|
|
|
if (!(hostdev = virDomainHostdevDefNew()))
|
|
|
|
return NULL;
|
2014-09-02 17:52:40 +02:00
|
|
|
|
2018-07-16 18:42:10 +02:00
|
|
|
- hostdev->managed = false;
|
|
|
|
+ hostdev->managed = managed ? true : false;
|
|
|
|
hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
|
|
|
|
hostdev->source.subsys.u.pci.addr.domain = domainID;
|
|
|
|
hostdev->source.subsys.u.pci.addr.bus = busID;
|