[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl: passthrough: avoid passing through devices not owned by pciback
# HG changeset patch # User Xudong Hao <xudong.hao@xxxxxxxxx> # Date 1335349125 -3600 # Node ID 8fd318f89728cc42f5ab9c1885dd39e04a1f3b11 # Parent 8fddae41cd1b874e4991c6fd3d51a2b63642d914 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> Signed-off-by: Xudong Hao <xudong.hao@xxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- diff -r 8fddae41cd1b -r 8fd318f89728 tools/libxl/libxl_pci.c --- a/tools/libxl/libxl_pci.c Tue Apr 24 19:06:42 2012 +0100 +++ b/tools/libxl/libxl_pci.c Wed Apr 25 11:18:45 2012 +0100 @@ -664,6 +664,24 @@ int libxl_device_pci_add(libxl_ctx *ctx, return rc; } +static int libxl_pcidev_assignable(libxl_ctx *ctx, libxl_device_pci *pcidev) +{ + libxl_device_pci *pcidevs; + int num, i; + + pcidevs = libxl_device_pci_list_assignable(ctx, &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__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting) { libxl_ctx *ctx = libxl__gc_owner(gc); @@ -675,6 +693,13 @@ int libxl__device_pci_add(libxl__gc *gc, rc = libxl__device_pci_setdefault(gc, pcidev); if (rc) goto out; + 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@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |