forked from pool/libvirt
9ccf0d308b
- Update to libvirt 5.3.0 - Many incremental improvements and bug fixes, see http://libvirt.org/news.html - Dropped patches: ff376c62-tests-fix-mocking-stat-lstat.patch, ebe9c6ea-qemu-firmware-dirent.patch, 2a07c990-api-CVE-2019-3886.patch, ae076bb4-remote-CVE-2019-3886.patch, f66f70ac-snapshot-fix-use-after-free.patch, 89237d53-conf-expose-virDomainSCSIDriveAddressIsUsed.patch, ee2c5ef3-test-scsi-disk.patch, ddc72f99-qemu-check-dup-drive-address.patch, 22dc3e94-revert-f1d65853.patch OBS-URL: https://build.opensuse.org/request/show/701641 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=752
137 lines
4.6 KiB
Diff
137 lines
4.6 KiB
Diff
>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(-)
|
|
|
|
Index: libvirt-5.3.0/src/xenconfig/xen_common.c
|
|
===================================================================
|
|
--- libvirt-5.3.0.orig/src/xenconfig/xen_common.c
|
|
+++ libvirt-5.3.0/src/xenconfig/xen_common.c
|
|
@@ -386,12 +386,19 @@ xenParsePCI(char *entry)
|
|
int busID;
|
|
int slotID;
|
|
int funcID;
|
|
+ char *opt;
|
|
+ int managed = 0;
|
|
|
|
domain[0] = bus[0] = slot[0] = func[0] = '\0';
|
|
|
|
/* pci=['0000:00:1b.0','0000:00:13.0'] */
|
|
if (!(key = entry))
|
|
return NULL;
|
|
+
|
|
+ opt = strchr(key, ',');
|
|
+ if (opt)
|
|
+ opt++;
|
|
+
|
|
if (!(nextkey = strchr(key, ':')))
|
|
return NULL;
|
|
if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) < 0) {
|
|
@@ -436,10 +443,30 @@ xenParsePCI(char *entry)
|
|
if (virStrToLong_i(func, NULL, 16, &funcID) < 0)
|
|
return NULL;
|
|
|
|
+ if (opt) {
|
|
+ char opt_managed[2];
|
|
+ char *data;
|
|
+
|
|
+ opt_managed[0] = '\0';
|
|
+ data = strchr(opt, '=');
|
|
+ data++;
|
|
+
|
|
+ if (STRPREFIX(opt, "managed=")) {
|
|
+ if (virStrncpy(opt_managed, data, 1, sizeof(opt_managed)) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("managed option %s too big for destination"),
|
|
+ data);
|
|
+ return NULL;
|
|
+ }
|
|
+ }
|
|
+ if (virStrToLong_i(opt_managed, NULL, 10, &managed) < 0)
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
if (!(hostdev = virDomainHostdevDefNew()))
|
|
return NULL;
|
|
|
|
- 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;
|
|
Index: libvirt-5.3.0/src/xenconfig/xen_sxpr.c
|
|
===================================================================
|
|
--- libvirt-5.3.0.orig/src/xenconfig/xen_sxpr.c
|
|
+++ libvirt-5.3.0/src/xenconfig/xen_sxpr.c
|
|
@@ -1054,6 +1054,7 @@ xenParseSxprPCI(virDomainDefPtr def,
|
|
int busID;
|
|
int slotID;
|
|
int funcID;
|
|
+ bool managed;
|
|
|
|
node = cur->u.s.car;
|
|
if (!sexpr_lookup(node, "dev"))
|
|
@@ -1101,11 +1102,13 @@ xenParseSxprPCI(virDomainDefPtr def,
|
|
goto error;
|
|
}
|
|
|
|
+ managed = sexpr_int(node, "dev/opts/managed");
|
|
+
|
|
if (!(dev = virDomainHostdevDefNew()))
|
|
goto error;
|
|
|
|
dev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
|
- dev->managed = false;
|
|
+ dev->managed = managed ? true : false;
|
|
dev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
|
|
dev->source.subsys.u.pci.addr.domain = domainID;
|
|
dev->source.subsys.u.pci.addr.bus = busID;
|
|
@@ -1964,11 +1967,15 @@ static void
|
|
xenFormatSxprPCI(virDomainHostdevDefPtr def,
|
|
virBufferPtr buf)
|
|
{
|
|
- virBufferAsprintf(buf, "(dev (domain 0x%04x)(bus 0x%02x)(slot 0x%02x)(func 0x%x))",
|
|
+ virBufferAsprintf(buf, "(dev (domain 0x%04x)(bus 0x%02x)(slot 0x%02x)(func 0x%x)",
|
|
def->source.subsys.u.pci.addr.domain,
|
|
def->source.subsys.u.pci.addr.bus,
|
|
def->source.subsys.u.pci.addr.slot,
|
|
def->source.subsys.u.pci.addr.function);
|
|
+
|
|
+ if (def->managed)
|
|
+ virBufferAddLit(buf, "(opts (managed 1))");
|
|
+ virBufferAddLit(buf, ")");
|
|
}
|
|
|
|
|
|
@@ -1987,12 +1994,6 @@ xenFormatSxprOnePCI(virDomainHostdevDefP
|
|
virBufferPtr buf,
|
|
int detach)
|
|
{
|
|
- if (def->managed) {
|
|
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
- _("managed PCI devices not supported with XenD"));
|
|
- return -1;
|
|
- }
|
|
-
|
|
virBufferAddLit(buf, "(pci ");
|
|
xenFormatSxprPCI(def, buf);
|
|
if (detach)
|
|
@@ -2047,12 +2048,6 @@ xenFormatSxprAllPCI(virDomainDefPtr def,
|
|
for (i = 0; i < def->nhostdevs; i++) {
|
|
if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
|
|
def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
|
|
- if (def->hostdevs[i]->managed) {
|
|
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
- _("managed PCI devices not supported with XenD"));
|
|
- return -1;
|
|
- }
|
|
-
|
|
xenFormatSxprPCI(def->hostdevs[i], buf);
|
|
}
|
|
}
|