libvirt/support-managed-pci-xen-driver.patch
James Fehlig 9462ef6485 Accepting request 593871 from home:jfehlig:branches:Virtualization
- util: improvements in error handling
  09877303-virSocketAddrParseInternal.patch,
  412afdb8-intro-virSocketAddrParseAny.patch
  bsc#1080957

- Update to libvirt 4.2.0
  - Many incremental improvements and bug fixes, see
    http://libvirt.org/news.html
  - Dropped patches:
    6b3d716e-keycodemap-py3.patch,
    33c6eb96-fix-libvirtd-reload-deadlock.patch,
    464889ff-rpc-aquire-ref-dispatch.patch,
    c6f1d519-rpc-simplify-dispatch.patch,
    06e7ebb6-rpc-invoke-dispatch-unlocked.patch,
    86cae503-rpc-fix-pre-exec.patch,
    eefabb38-rpc-virtlockd-virtlogd-single-thread.patch,
    fbf31e1a-CVE-2018-1064.patch,
    fb327ac2-virtlockd-admin-socket.patch,
    64370c4b-libxl-MigrateBegin.patch,
    99486799-libxl-MigrateConfirm.patch,
    f5eacf2a-libxl-MigratePerform.patch,
    4e6fcdb6-libxl-libxlDomObjFromDomain-cleanup.patch,
    fe51dbda-libxl-use-FindByRef.patch,
    60b3fcd9-libxl-MigratePrepare.patch,
    3c89868c-libxl-lock-after-ListRemove.patch,
    13e81fc6-libxl-EndJob-on-error.patch,
    594b8b99-libxl-DefineXMLFlags-API-pattern.patch,
    c66e344e-libxl-dont-deref-NULL.patch,
    83edaf44-libxl-dont-hardcode-sched-weight.patch,
    apibuild-py3.patch

OBS-URL: https://build.opensuse.org/request/show/593871
OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=683
2018-04-05 21:47:55 +00:00

139 lines
5.1 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-4.2.0/src/xenconfig/xen_common.c
===================================================================
--- libvirt-4.2.0.orig/src/xenconfig/xen_common.c
+++ libvirt-4.2.0/src/xenconfig/xen_common.c
@@ -394,6 +394,8 @@ xenParsePCI(virConfPtr conf, virDomainDe
{
virConfValuePtr list = virConfGetValue(conf, "pci");
virDomainHostdevDefPtr hostdev = NULL;
+ char *opt;
+ int managed = 0;
if (list && list->type == VIR_CONF_LIST) {
list = list->list;
@@ -415,6 +417,11 @@ xenParsePCI(virConfPtr conf, virDomainDe
/* pci=['0000:00:1b.0','0000:00:13.0'] */
if (!(key = list->str))
goto skippci;
+
+ opt = strchr(key, ',');
+ if (opt)
+ opt++;
+
if (!(nextkey = strchr(key, ':')))
goto skippci;
if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) == NULL) {
@@ -458,10 +465,31 @@ xenParsePCI(virConfPtr conf, virDomainDe
goto skippci;
if (virStrToLong_i(func, NULL, 16, &funcID) < 0)
goto skippci;
+
+ 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)) == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("managed option %s too big for destination"),
+ data);
+ goto skippci;
+ }
+ }
+ if (virStrToLong_i(opt_managed, NULL, 10, &managed) < 0)
+ goto skippci;
+ }
+
if (!(hostdev = virDomainHostdevDefNew()))
return -1;
- 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-4.2.0/src/xenconfig/xen_sxpr.c
===================================================================
--- libvirt-4.2.0.orig/src/xenconfig/xen_sxpr.c
+++ libvirt-4.2.0/src/xenconfig/xen_sxpr.c
@@ -1057,6 +1057,7 @@ xenParseSxprPCI(virDomainDefPtr def,
int busID;
int slotID;
int funcID;
+ bool managed;
node = cur->u.s.car;
if (!sexpr_lookup(node, "dev"))
@@ -1104,11 +1105,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;
@@ -1972,11 +1975,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, ")");
}
@@ -1995,12 +2002,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)
@@ -2055,12 +2056,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);
}
}