</dd>
</dl>
+ <h4><a name="elementsVirtio">Virtio-related options</a></h4>
+
+ <p>
+ QEMU's virtio devices have some attributes related to the virtio transport under
+ the <code>driver</code> element:
+ The <code>iommu</code> attribute enables the use of emulated IOMMU
+ by the device. The attribute <code>ats</code> controls the Address
+ Translation Service support for PCIe devices. This is needed to make use
+ of IOTLB support (see <a href="#elementsIommu">IOMMU device</a>).
+ Possible values are <code>on</code> or <code>off</code>.
+ <span class="since">Since 3.5.0</span>
+ </p>
+
<h4><a name="elementsControllers">Controllers</a></h4>
<p>
<b>In general you should leave this option alone, unless you
are very certain you know what you are doing.</b>
</dd>
+ <dt>virtio options</dt>
+ <dd>
+ For virtio interfaces,
+ <a href="#elementsVirtio">Virtio-specific options</a> can also be
+ set. (<span class="since">Since 3.5.0</span>)
+ </dd>
</dl>
<p>
Offloading options for the host and guest can be configured using
return &xmlopt->ns;
}
+static int
+virDomainVirtioOptionsParseXML(xmlXPathContextPtr ctxt,
+ virDomainVirtioOptionsPtr *virtio)
+{
+ char *str = NULL;
+ int ret = -1;
+ int val;
+ virDomainVirtioOptionsPtr res;
+
+ if (VIR_ALLOC(*virtio) < 0)
+ return -1;
+
+ res = *virtio;
+
+ if ((str = virXPathString("string(./driver/@iommu)", ctxt))) {
+ if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("invalid iommu value"));
+ goto cleanup;
+ }
+ res->iommu = val;
+ }
+ VIR_FREE(str);
+
+ if ((str = virXPathString("string(./driver/@ats)", ctxt))) {
+ if ((val = virTristateSwitchTypeFromString(str)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("invalid ats value"));
+ goto cleanup;
+ }
+ res->ats = val;
+ }
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(str);
+ return ret;
+}
+
virSaveCookieCallbacksPtr
virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt)
VIR_FREE(def->ifname);
VIR_FREE(def->ifname_guest);
VIR_FREE(def->ifname_guest_actual);
+ VIR_FREE(def->virtio);
virNetDevIPInfoClear(&def->guestIP);
virNetDevIPInfoClear(&def->hostIP);
}
+static int
+virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio)
+{
+ if (!virtio)
+ return 0;
+
+ if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("iommu driver option is only supported "
+ "for virtio devices"));
+ return -1;
+ }
+ if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ats driver option is only supported "
+ "for virtio devices"));
+ return -1;
+ }
+ return 0;
+}
+
+
static int
virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
const virDomainDef *def,
}
}
+ if (dev->type == VIR_DOMAIN_DEVICE_NET) {
+ virDomainNetDefPtr net = dev->data.net;
+ if (STRNEQ_NULLABLE(net->model, "virtio") &&
+ virDomainCheckVirtioOptions(net->virtio) < 0)
+ return -1;
+ }
+
return 0;
}
}
+static void
+virDomainVirtioOptionsFormat(virBufferPtr buf,
+ virDomainVirtioOptionsPtr virtio)
+{
+ if (!virtio)
+ return;
+
+ if (virtio->iommu != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(buf, " iommu='%s'",
+ virTristateSwitchTypeToString(virtio->iommu));
+ }
+ if (virtio->ats != VIR_TRISTATE_SWITCH_ABSENT) {
+ virBufferAsprintf(buf, " ats='%s'",
+ virTristateSwitchTypeToString(virtio->ats));
+ }
+}
+
+
/* Generate a string representation of a device address
* @info address Device address to stringify
*/
goto error;
}
+ if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
+ goto error;
+
cleanup:
ctxt->node = oldnode;
VIR_FREE(macaddr);
}
+static bool
+virDomainVirtioOptionsCheckABIStability(virDomainVirtioOptionsPtr src,
+ virDomainVirtioOptionsPtr dst)
+{
+ if (src->iommu != dst->iommu) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target device iommu option '%s' does not "
+ "match source '%s'"),
+ virTristateSwitchTypeToString(dst->iommu),
+ virTristateSwitchTypeToString(src->iommu));
+ return false;
+ }
+ if (src->ats != dst->ats) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target device ats option '%s' does not "
+ "match source '%s'"),
+ virTristateSwitchTypeToString(dst->ats),
+ virTristateSwitchTypeToString(src->ats));
+ return false;
+ }
+ return true;
+}
+
+
static bool
virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src,
virDomainDiskDefPtr dst)
return false;
}
+ if (src->virtio && dst->virtio &&
+ !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
+ return false;
+
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
return false;
virBufferAsprintf(&buf, " rx_queue_size='%u'",
def->driver.virtio.rx_queue_size);
+ virDomainVirtioOptionsFormat(&buf, def->virtio);
+
if (virBufferCheckError(&buf) < 0)
return -1;