</devices>
...
+The second interface in this example is referencing a network that is
+a pool of SRIOV VFs (i.e. a "hostdev network"). You could instead
+directly reference an SRIOV VF device:
+
+::
+
+ ...
+ <interface type='hostdev'>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </source>
+ <mac address='00:11:22:33:44:55:66'/>
+ <teaming type='transient' persistent='ua-backup0'/>
+ </interface>
+ ...
+
The ``<teaming>`` element required attribute ``type`` will be set to either
``"persistent"`` to indicate a device that should always be present in the
domain, or ``"transient"`` to indicate a device that may periodically be
will use the virtio NIC. (Of course the emulated virtio NIC and the hostdev NIC
must be connected to the same subnet for bonding to work properly).
+:since:`Since 7.1.0` The ``<teaming>`` element can also be added to a
+plain ``<hostdev>`` device.
+
+::
+
+ ...
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </source>
+ <mac address='00:11:22:33:44:55:66'/>
+ <teaming type='transient' persistent='ua-backup0'/>
+ </interface>
+ ...
+
+This device must be a network device, but not necessarily an SRIOV
+VF. Using plain ``<hostdev>`` rather than ``<interface
+type='hostdev'>`` or ``<interface type='network'>`` is useful if the
+device that will be assigned with VFIO is a standard NIC (not a VF) or
+if libvirt doesn't have the necessary resources and privileges to set
+the VF's MAC address (e.g. if libvirt is running unprivileged, or in a
+container). This of course means that the user (or another
+application) is responsible for setting the MAC address of the device
+in a way such that it will survive guest driver initialization. For
+standard NICs (i.e. not an SRIOV VF) this probably means that the
+NIC's factory-programmed MAC address will need to be used for the
+teaming pair (since any driver init in the guest will reset the MAC
+back to factory). If it is an SRIOV VF, then its MAC address will need
+to be set via the VF's PF, e.g. if you are going to use VF 2 of the PF
+enp2s0f1, you would use something like this command:
+
+::
+
+ ip link set enp2s0f1 vf 2 mac 52:54:00:11:22:33
+
NB1: Since you must know the alias name of the virtio NIC when configuring the
hostdev NIC, it will need to be manually set in the virtio NIC's configuration
(as with all other manually set alias names, this means it must start with
<empty/>
</element>
</optional>
+ <optional>
+ <ref name="teaming"/>
+ </optional>
<element name="source">
<optional>
<ref name="startupPolicy"/>
if (!def->parentnet)
virDomainDeviceInfoFree(def->info);
+ virDomainNetTeamingInfoFree(def->teaming);
+
switch (def->mode) {
case VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES:
switch ((virDomainHostdevCapsType) def->source.caps.type) {
}
}
+ if (virDomainNetTeamingInfoParseXML(ctxt, &def->teaming) < 0)
+ goto error;
+
return def;
error:
break;
}
+ virDomainNetTeamingInfoFormat(def->teaming, buf);
+
if (def->readonly)
virBufferAddLit(buf, "<readonly/>\n");
if (def->shareable)
virDomainHostdevCaps caps;
} source;
virDomainHostdevOrigStates origstates;
+ virDomainNetTeamingInfoPtr teaming;
virDomainDeviceInfoPtr info; /* Guest address */
};
break;
}
}
+
+ if (hostdev->teaming) {
+ if (hostdev->teaming->type != VIR_DOMAIN_NET_TEAMING_TYPE_TRANSIENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("teaming hostdev devices must have type='transient'"));
+ return -1;
+ }
+ if (!hostdev->teaming->persistent) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("missing required persistent attribute in hostdev teaming element"));
+ return -1;
+ }
+ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+ hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("teaming is only supported for pci hostdev devices"));
+ return -1;
+ }
+ }
return 0;
}
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <interface type='user'>
+ <mac address='66:44:33:22:11:00'/>
+ <model type='virtio'/>
+ <teaming type='persistent'/>
+ <alias name='ua-backup1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <source>
+ <address domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <source>
+ <address domain='0x0000' bus='0x03' slot='0x07' function='0x2'/>
+ </source>
+ <teaming type='transient' persistent='ua-backup1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </hostdev>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
--- /dev/null
+../qemuxml2argvdata/net-virtio-teaming-hostdev.xml
\ No newline at end of file
DO_TEST("net-virtio-teaming-network",
QEMU_CAPS_VIRTIO_NET_FAILOVER,
QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST("net-virtio-teaming-hostdev",
+ QEMU_CAPS_VIRTIO_NET_FAILOVER,
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST_CAPS_LATEST("net-isolated-port");
DO_TEST("net-hostdev", NONE);
DO_TEST("net-hostdev-bootorder", NONE);