Re: [PATCHv3 3/3] qemu: Prefer VFIO for PCI device passthrough

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/07/13 16:19, Laine Stump wrote:
> On 10/04/2013 08:55 AM, Peter Krempa wrote:
>> Prefer using VFIO (if available) to the legacy KVM device passthrough.
>>
>> With this patch a PCI passthrough device without the driver configured
>> will be started with VFIO if it's available on the host. If not legacy
>> KVM passthrough is checked and error is reported if it's not available.
>> ---
>>  docs/formatdomain.html.in |  9 ++++-----
>>  src/conf/domain_conf.h    |  2 +-
>>  src/qemu/qemu_command.c   |  3 ++-
>>  src/qemu/qemu_hostdev.c   | 21 +++++++++++++++++++--
>>  src/qemu/qemu_hostdev.h   |  3 ++-
>>  src/qemu/qemu_hotplug.c   |  2 +-
>>  src/qemu/qemu_process.c   | 15 ++++++++-------
>>  tests/qemuxml2argvtest.c  | 11 +++++++++++
>>  8 files changed, 48 insertions(+), 18 deletions(-)
>>

...

>> diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
>> index dbbc2b4..ad408d8 100644
>> --- a/src/qemu/qemu_hostdev.c
>> +++ b/src/qemu/qemu_hostdev.c
>> @@ -1366,7 +1366,8 @@ qemuHostdevHostSupportsPassthroughLegacy(void)
>>
>>  bool
>>  qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs,
>> -                             size_t nhostdevs)
>> +                             size_t nhostdevs,
>> +                             virQEMUCapsPtr qemuCaps)
> 
> Aha. I guess if you follow my recommendation in 2/3, you'll need to pass
> qemuCaps down through the qemuPrepareHostDevices() call chain (and I
> don't think that's a bad thing).

Seems doable. I will post another version incorporating that.

> 
>>  {
>>      int supportsPassthroughKVM = -1;
>>      int supportsPassthroughVFIO = -1;
>> @@ -1387,6 +1388,23 @@ qemuHostdevHostVerifySupport(virDomainHostdevDefPtr *hostdevs,
>>              }
>>
>>              switch ((virDomainHostdevSubsysPciBackendType) *backend) {
>> +            case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
>> +                if (supportsPassthroughVFIO &&
>> +                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
>> +                    *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
>> +                } else if (supportsPassthroughKVM &&
>> +                           (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) ||
>> +                            virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) {
>> +                    *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM;
>> +                } else {
>> +                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> +                                   _("host doesn't support passthrough of "
>> +                                     "host PCI devices"));
>> +                    return false;
>> +                }
>> +
>> +                break;
>> +
> 
> Ah! And there is the separate case I was asking for in 2/3!
> 
> But you're changing the "backend" in the data itself - that will lead to
> incorrect display when someone does a dumpxml (will it cause problems if
> someone loads the vfio driver? I guess not, since this should only be
> the "live" data, not the persistent data)

Hmm, Is this an issue? I think it might be useful to update the info in
the live XML so that the users are notified. If we don't want to do this
I will change it in the next version.

Peter

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]