|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2 of 2] libxl_pci: verify device is assignable before adding to a domain
On Tue, 2012-01-17 at 15:25 +0000, Doug Magee wrote:
> Previously, libxl__device_pci_add only checks that the device is not assigned
> to another domain. This patch updates this function to check against the
> list of assignable devices, which only includes devices owned by pciback and
> already excludes devices assigned to other domains.
>
> Signed-off-by: Doug Magee <djmagee@xxxxxxxxxxxx>
>
> diff -r 3becc1652693 -r be1313a6b489 tools/libxl/libxl_pci.c
> --- a/tools/libxl/libxl_pci.c Tue Jan 17 10:14:15 2012 -0500
> +++ b/tools/libxl/libxl_pci.c Tue Jan 17 10:19:24 2012 -0500
> @@ -793,18 +793,15 @@ int libxl__device_pci_add(libxl__gc *gc,
> {
> libxl_ctx *ctx = libxl__gc_owner(gc);
> unsigned int orig_vdev, pfunc_mask;
> - libxl_device_pci *assigned;
> - int num_assigned, i, rc;
> + libxl_device_pci *assignable;
> + int num_assignable, i, rc;
> int stubdomid = 0;
>
> - 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");
> - goto out;
> - }
> - if ( is_pcidev_in_array(assigned, num_assigned, pcidev->domain,
> + assignable = libxl_device_pci_list_assignable(ctx, &num_assignable);
Unlike get_all_assigned_devices you need to free the returned assignable
array explicitly (since it is in a different category per the comment
near the top of libxl.h).
Ian.
> +
> + if ( !is_pcidev_in_array(assignable, num_assignable, pcidev->domain,
> pcidev->bus, pcidev->dev, pcidev->func) ) {
> - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device already attached to a
> domain");
> + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "PCI device is either assigned to
> another domain, or not owned by pciback");
> rc = ERROR_FAIL;
> goto out;
> }
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |