On 07/30/18 23:56, Alex Williamson wrote:
On Sun, 29 Jul 2018 21:19:41 +0000
"Wang, Zhi A" <zhi.a.w...@intel.com> wrote:

BACKGROUND

As the live migration of mdev is going to be supported in VFIO, a scheme of 
deciding if a mdev could be migratable between the source machine and the 
destination machine is needed. Mostly, this email is going to discuss a 
possible solution which needs fewer modifications of libvirt/VFIO.

The configuration of a mdev is located in the domain XML, which guides libvirt 
how to find the mdev and generating the command line for QEMU. It basically 
only includes the UUID of a mdev. The domain XML of the source machine and 
destination machine are going to be compared before the migration really 
happens. Each configuration item would be compared and checked by libvirt. If 
one item of the source machine is different from the item of destination 
machine, the migration fails. For mdev, there is no any check/match before the 
migration happens yet.

The user could use the node device list of libvirt to list the host devices and 
see the capabilities of those devices. The current node device code of libvirt 
has already been able to extract the supported mdev types from a host PCI 
device, plus some basic information, like max supported mdev instance of a host 
PCI device.

THE SOLUTION

To strictly check the mdev type and make sure the migration happens between the 
compatible mediated devices, three new mandatory elements in the domain XML 
below the hostdev element would be introduced:

vendorid: The vendor ID of the mdev, which comes from the host PCI device. A 
user could obtain this information from the host PCI device which supports mdev 
in the node device list.
productid: The product ID of the mdev, which also comes from the host PCI 
device. A user could obtain this information from the same approach above.

The parent of an mdev device is not necessarily a PCI device.
Good point. I didn't get that.

mdevtype: The type of the mdev. As the creation of the mdev is managed by the 
user, the user knows the type of the mdev and would be responsible for filling 
out this information.

These three elements are only needed when the device API of a mdev is 
"vfio-PCI". Take the example of mdev configuration from 
https://libvirt.org/formatdomain.html to illustrate the modification:

   <devices>
     <hostdev mode='subsystem' type='mdev' model='vfio-pci'>
     <source>
       <address uuid='c2177883-f1bb-47f0-914d-32a22e3a8804'/>
       <vendorid>0xdead</vendorid> <!-- The VID of the host PCI device which 
supports this mdev -->
       <productid>0xbeef</productid> <!-- The PID of the host PCI device which 
supports this mdev -->
       <mdevtype>type</mdevtype> <!-- The vendor-specific mdev type string -->
     </source>
     </hostdev>

With the newly introduced elements above, the flow of the creation of a domain 
XML with mdev will be like:

1. The user obtains the vendorid/productid from node device list
2. The user fills the vendorid/productid/mdevtype in the domain XML
3. When a migration happens, libvirt check these elements. If one item is 
different between two domain XML, then migration fails.

I don't see how this solves anything.  The vendor and product are
redundant and specific to PCI hosted mdev devices.  These do nothing
to enhance the definition of an mdev type, where we've decided the
mdev type is a guest software compatible definition of a device.
Simply knowing the type doesn't help me know that the state data
between source and target is compatible.  This is the difference
between knowing I'm migrating from machine 'pc-440fx' to 'pc-440fx'
versus 'pc-i440fx-2.12' to 'pc-440fx-2.11'.  We need somehow to define
a version of a device, what we consider to be compatible versions for
migration, and hopefully some standard(ish) mechanism libvirt could
use to determine this.  Thanks,


I see your point. We could combine these stuff together and improve "mdev" type, not by introducing new stuff to decide the compatibility. Let me know if I misunderstood.

I guess you are now talking about "the thing" we should give libvirt. Are you implying that the mdev type we give in libvirt should be a string? If we could take the inspiration of PCI device? Like:

           class name - vendor name - product name - version

mdev type  gpu-intel-gen9-11
           gpu-nvidia-grid-11

Then every mdev driver needs to fill these information and VFIO could combine and expose them as the name of folder in mdev_supported_types. Libvirt could address the mdev type by reading the mdev_type in UUID folder.

BTW,

As far as I read the code, the migration check function would check quite a lot of things before migration really happens, not only machine type.

Mdev is listed as a sub-hierarchy of hostdev in the migration check function. "hostdev" in the code means "a host device", like a passthrough PCI device. The function would check the compatibility of source device and destination device by types. e.g. for PCI passthrough device, it would check the BDF. For mdev, it doesn't check anything right now. That's how this idea come out: Let libvirt have something to check and know if the mdevs between source machine and destination machine are compatible.

Simply knowing the type is not enough currently and we need prepare something to let libvirt check the compatibility.

For how libvirt could check the compatibility of mdev, the above investigation might be a hint.


Alex


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

Reply via email to