On Mon, 2010-08-09 at 13:00 +0100, Gianni Tedesco wrote:
> @@ -652,8 +705,9 @@ out:
>
> int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci
> *pcidev)
> {
> + unsigned int orig_vdev, pfunc_mask;
> libxl_device_pci *assigned;
> - int num_assigned, rc;
> + int num_assigned, rc, i;
> int stubdomid = 0;
>
> rc = get_all_assigned_devices(ctx, &assigned, &num_assigned);
> @@ -679,10 +733,43 @@ int libxl_device_pci_add(libxl_ctx *ctx,
> return rc;
> }
>
> - return do_pci_add(ctx, domid, pcidev);
> + orig_vdev = pcidev->vdevfn & ~7U;
> +
> + if ( pcidev->vfunc_mask == LIBXL_PCI_FUNC_ALL ) {
> + if ( !(pcidev->vdevfn >> 3) ) {
> + XL_LOG(ctx, XL_LOG_ERROR, "Must specify a v-slot for
> multi-function devices");
> + return ERROR_INVAL;
> + }
> + if ( pci_multifunction_check(ctx, pcidev, &pfunc_mask) ) {
> + return ERROR_FAIL;
> + }
> + pcidev->vfunc_mask &= pfunc_mask;
> + /* so now vfunc_mask == pfunc_mask */
> + }else{
> + pfunc_mask = (1 << pcidev->func);
> + }
> +
> + for(i = 7; i >= 0; --i) {
> + if ( (1 << i) & pfunc_mask ) {
> + if ( pcidev->vfunc_mask == pfunc_mask ) {
> + pcidev->func = i;
> + pcidev->vdevfn = orig_vdev | i;
> + }else{
> + /* if not passing through multiple devices in a block make
> + * sure that virtual function number 0 is always used
> otherwise
> + * guest won't see the device
> + */
> + pcidev->vdevfn = orig_vdev;
> + }
> + if ( do_pci_add(ctx, domid, pcidev) )
> + rc = ERROR_FAIL;
> + }
> + }
> +
> + return rc;
> }
Not sure that this bit is right for stubdoms, I haven't tested...
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|