Add VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN. For legacy xen, it will use "pciback"
as
stub driver.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/libxl/libxl_domain.c | 9 +++++++++
src/qemu/qemu_command.c | 3 +--
src/qemu/qemu_hostdev.c | 1 +
src/qemu/qemu_hotplug.c | 4 +---
src/util/virhostdev.c | 10 ++++++++++
8 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 601e7ac..bcd8142 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3421,6 +3421,7 @@
<choice>
<value>kvm</value>
<value>vfio</value>
+ <value>xen</value>
</choice>
</attribute>
<empty/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1d5cc14..6d778a5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -627,7 +627,8 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysPciBackend,
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST,
"default",
"kvm",
- "vfio")
+ "vfio",
+ "xen")
VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST,
"storage",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2467f65..2840539 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -415,6 +415,7 @@ typedef enum {
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, /* detect automaticaly, prefer VFIO */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM, /* force legacy kvm style */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO, /* force vfio */
+ VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN, /* force legacy xen style, use pciback */
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST
} virDomainHostdevSubsysPciBackendType;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index fdc4661..274fb6c 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -478,6 +478,15 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+ if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
+ virDomainHostdevDefPtr hostdev = dev->data.hostdev;
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI
&&
+ hostdev->source.subsys.u.pci.backend ==
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT)
+ hostdev->source.subsys.u.pci.backend =
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
+ }
+
return 0;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9ee84a0..8ed62bd 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5548,8 +5548,7 @@ qemuBuildPCIHostdevDevStr(virDomainDefPtr def,
virBufferAddLit(&buf, "vfio-pci");
break;
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
+ default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid PCI passthrough type '%s'"),
virDomainHostdevSubsysPciBackendTypeToString(backend));
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 56afe0a..b60017a 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -213,6 +213,7 @@ qemuPrepareHostdevPCICheckSupport(virDomainHostdevDefPtr *hostdevs,
break;
+ case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
break;
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a213929..0348968 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1193,9 +1193,7 @@ qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
virProcessSetMaxMemLock(vm->pid, memKB * 1024);
break;
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
- case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
+ default:
break;
}
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 73844a6..56d5b98 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -146,6 +146,12 @@ virHostdevGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int
nhostdevs)
virObjectUnref(list);
return NULL;
}
+ } else if (hostdev->source.subsys.u.pci.backend
+ == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) {
+ if (virPCIDeviceSetStubDriver(dev, "pciback") < 0) {
+ virObjectUnref(list);
+ return NULL;
+ }
} else {
if (virPCIDeviceSetStubDriver(dev, "pci-stub") < 0) {
virObjectUnref(list);
@@ -802,6 +808,10 @@ virHostdevUpdateActivePciHostdevs(virHostdevManagerPtr mgr,
== VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
if (virPCIDeviceSetStubDriver(dev, "vfio-pci") < 0)
goto cleanup;
+ } else if (hostdev->source.subsys.u.pci.backend
+ == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) {
+ if (virPCIDeviceSetStubDriver(dev, "pciback") < 0)
+ goto cleanup;
} else {
if (virPCIDeviceSetStubDriver(dev, "pci-stub") < 0)
goto cleanup;
--
1.6.0.2