int vlan,
unsigned int bootindex,
size_t vhostfdSize,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int mtu)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *nic = net->model;
virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
}
- if (usingVirtio && net->mtu) {
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("setting MTU is not supported with this QEMU binary"));
- goto error;
+ if (usingVirtio && mtu) {
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
+
+ virBufferAsprintf(&buf, ",host_mtu=%u", mtu);
+
+ } else {
+ /* log an error if mtu was requested specifically for this
+ * interface, otherwise, if it's just what was reported by
+ * the attached network, ignore it.
+ */
+ if (net->mtu) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("setting MTU is not supported with "
+ "this QEMU binary"));
+ goto error;
+ }
}
- virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
}
if (vlan == -1)
VIR_FREE(netdev);
if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
- queues, qemuCaps))) {
+ queues, qemuCaps, net->mtu))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error generating NIC -device string"));
goto error;
virDomainNetType actualType = virDomainNetGetActualType(net);
virNetDevBandwidthPtr actualBandwidth;
size_t i;
+ unsigned int mtu = net->mtu;
if (!bootindex)
memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
if (qemuInterfaceBridgeConnect(def, driver, net,
- tapfd, &tapfdSize) < 0)
+ tapfd, &tapfdSize, &mtu) < 0)
goto cleanup;
break;
}
if (qemuDomainSupportsNicdev(def, net)) {
if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
- vhostfdSize, qemuCaps)))
+ vhostfdSize, qemuCaps, mtu)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
} else {
bool charDevPlugged = false;
bool netdevPlugged = false;
bool hostPlugged = false;
+ unsigned int mtu = net->mtu;
/* preallocate new slot for device */
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
goto cleanup;
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuInterfaceBridgeConnect(vm->def, driver, net,
- tapfd, &tapfdSize) < 0)
+ tapfd, &tapfdSize, &mtu) < 0)
goto cleanup;
iface_connected = true;
if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps,
VIR_FORCE_CLOSE(vhostfd[i]);
if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
- queueSize, priv->qemuCaps)))
+ queueSize, priv->qemuCaps, mtu)))
goto try_remove;
qemuDomainObjEnterMonitor(driver, vm);