Re: [PATCH 5/6] device assignment: support for assigning PCI devices to guests

Muli Ben-Yehuda
2008-10-29T10:27:43Z

On Tue, Oct 28, 2008 at 05:53:05PM +0200, Muli Ben-Yehuda wrote:
> On Tue, Oct 28, 2008 at 10:45:57AM -0500, Anthony Liguori wrote:
>
> >> +ifeq ($(USE_KVM), 1)
> >> +OBJS+= device-assignment.o
> >> +endif
> >
> > I don't think you want to build this on PPC so I think you need a
> > stronger check.
>
> Good point. How about checking TARGET_BASE_ARCH = i386?

Turns out this stanza is already enclosed in exactly that.

> >> +#ifdef KVM_CAP_IOMMU
> >> + /* We always enable the IOMMU if present
> >> + * (or when not disabled on the command line)
> >> + */
> >> + r = kvm_check_extension(kvm_context, KVM_CAP_IOMMU);
> >> + if (r && !disable_iommu)
> >> + assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU;
> >> +#endif
> >> + r = kvm_assign_pci_device(kvm_context, &assigned_dev_data);
> >> + if (r < 0) {
> >> + fprintf(stderr, "Could not notify kernel about "
> >> + "assigned device \"%s\"\n", e_dev_name);
> >> + perror("register_real_device");
> >> + goto out;
> >> + }
> >> + }
> >>
> >
> > You still succeed if KVM_CAP_DEVICE_ASSIGNMENT isn't defined?
> > That means a newer userspace compiled on an older kernel will
> > silently fail if they try to do device assignment. There's
> > probably no reason to build this file if KVM_CAP_DEVICE_ASSIGNMENT
> > isn't defined (see how the in-kernel PIT gets conditionally build
> > depending on whether that cap is available).
>
> Ok, I'll take a look at this.

I reworked it per your suggestion so that device assignment is a kvm
only feature for now. I am pretty sure Amit intended for the patches
to support device assignment without kvm too, but getting rid of it
did make things simpler.

cheers,
Muli
--
The First Workshop on I/O Virtualization (WIOV '08)
Dec 2008, San Diego, CA, http://www.usenix.org/wiov08/
<->
SYSTOR 2009---The Israeli Experimental Systems Conference