# HG changeset patch
# User Allen M Kay <allen.m.kay@xxxxxxxxx>
# Date 1300295307 0
# Node ID 01ac4fa9541e7e140d5a5e06a0713247b0e9a1cd
# Parent 762155e9debda6c70861b8bd388efc53a49ff50c
libxl: passthrough: avoid passing through devices not owned by pciback
This patch makes sure the passthrough device belongs to pciback before
allow them passthrough to the guest. There are still many other
checks missing.
xm terminates the guest startup process when this type of condition is
found. This patch just allows the guest to continue to boot but with
no device passthrough.
Signed-off-by: Allen Kay <allen.m.kay@xxxxxxxxx>
Acked-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
diff -r 762155e9debd -r 01ac4fa9541e tools/libxl/libxl_pci.c
--- a/tools/libxl/libxl_pci.c Tue Mar 15 13:55:40 2011 +0000
+++ b/tools/libxl/libxl_pci.c Wed Mar 16 17:08:27 2011 +0000
@@ -763,6 +763,24 @@
return libxl__device_pci_add(ctx, domid, pcidev, 0);
}
+static int libxl_pcidev_assignable(libxl_ctx *ctx, libxl_device_pci *pcidev)
+{
+ libxl_device_pci *pcidevs;
+ int num, i;
+
+ libxl_device_pci_list_assignable(ctx, &pcidevs, &num);
+ for (i = 0; i < num; i++) {
+ if (pcidevs[i].domain == pcidev->domain &&
+ pcidevs[i].bus == pcidev->bus &&
+ pcidevs[i].dev == pcidev->dev &&
+ pcidevs[i].func == pcidev->func)
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
int libxl__device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci
*pcidev, int starting)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
@@ -771,6 +789,13 @@
int num_assigned, i, rc;
int stubdomid = 0;
+ if (!libxl_pcidev_assignable(ctx, pcidev)) {
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device %x:%x:%x.%x is not
assignable",
+ pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
rc = get_all_assigned_devices(&gc, &assigned, &num_assigned);
if ( rc ) {
LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot determine if device is
assigned, refusing to continue");
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|