提交 77780a29 编写于 作者: L Laine Stump

Revert "qemu: propagate bridge MTU into qemu "host_mtu" option"

This reverts commit 2841e675.

It turns out that adding the host_mtu field to the PCI capabilities in
the guest bumps the length of PCI capabilities beyond the 32 byte
boundary, so the virtio-net device gets 64 bytes of ioport space
instead of 32, which offsets the address of all the other following
devices. Migration doesn't work very well when the location and length
of PCI capabilities of devices is changed between source and
destination.

This means that we need to make sure that the absence/presence of
host_mtu on the qemu commandline always matches between source and
destination, which means that we need to make setting of host_mtu an
opt-in thing (it can't happen automatically when the bridge being used
has a non-default MTU, which is what commit 2841e675 implemented).

I do want to re-implement this feature with an <mtu auto='on'/>
setting, but probably won't backport that to any stable branches, so
I'm first reverting the original commit, and that revert can be pushed
to the few releases that have been made since the original (3.1.0 -
3.3.0)

Resolves: https://bugzilla.redhat.com/1449346
上级 dbb85e0c
...@@ -3633,8 +3633,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, ...@@ -3633,8 +3633,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
int vlan, int vlan,
unsigned int bootindex, unsigned int bootindex,
size_t vhostfdSize, size_t vhostfdSize,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps)
unsigned int mtu)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *nic = net->model; const char *nic = net->model;
...@@ -3758,23 +3757,13 @@ qemuBuildNicDevStr(virDomainDefPtr def, ...@@ -3758,23 +3757,13 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size); virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
} }
if (usingVirtio && mtu) { if (usingVirtio && net->mtu) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
virBufferAsprintf(&buf, ",host_mtu=%u", mtu); _("setting MTU is not supported with this QEMU binary"));
goto error;
} 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) if (vlan == -1)
...@@ -8320,7 +8309,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ...@@ -8320,7 +8309,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
VIR_FREE(netdev); VIR_FREE(netdev);
if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex, if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
queues, qemuCaps, net->mtu))) { queues, qemuCaps))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error generating NIC -device string")); "%s", _("Error generating NIC -device string"));
goto error; goto error;
...@@ -8366,7 +8355,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, ...@@ -8366,7 +8355,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
virDomainNetType actualType = virDomainNetGetActualType(net); virDomainNetType actualType = virDomainNetGetActualType(net);
virNetDevBandwidthPtr actualBandwidth; virNetDevBandwidthPtr actualBandwidth;
size_t i; size_t i;
unsigned int mtu = net->mtu;
if (!bootindex) if (!bootindex)
...@@ -8421,7 +8409,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, ...@@ -8421,7 +8409,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
if (qemuInterfaceBridgeConnect(def, driver, net, if (qemuInterfaceBridgeConnect(def, driver, net,
tapfd, &tapfdSize, &mtu) < 0) tapfd, &tapfdSize) < 0)
goto cleanup; goto cleanup;
break; break;
...@@ -8601,7 +8589,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, ...@@ -8601,7 +8589,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
} }
if (qemuDomainSupportsNicdev(def, net)) { if (qemuDomainSupportsNicdev(def, net)) {
if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
vhostfdSize, qemuCaps, mtu))) vhostfdSize, qemuCaps)))
goto cleanup; goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL); virCommandAddArgList(cmd, "-device", nic, NULL);
} else { } else {
......
...@@ -101,8 +101,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def, ...@@ -101,8 +101,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def,
int vlan, int vlan,
unsigned int bootindex, unsigned int bootindex,
size_t vhostfdSize, size_t vhostfdSize,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps);
unsigned int mtu);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk); char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
......
...@@ -968,7 +968,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -968,7 +968,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
bool charDevPlugged = false; bool charDevPlugged = false;
bool netdevPlugged = false; bool netdevPlugged = false;
bool hostPlugged = false; bool hostPlugged = false;
unsigned int mtu = net->mtu;
/* preallocate new slot for device */ /* preallocate new slot for device */
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
...@@ -1025,7 +1024,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1025,7 +1024,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
if (qemuInterfaceBridgeConnect(vm->def, driver, net, if (qemuInterfaceBridgeConnect(vm->def, driver, net,
tapfd, &tapfdSize, &mtu) < 0) tapfd, &tapfdSize) < 0)
goto cleanup; goto cleanup;
iface_connected = true; iface_connected = true;
if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps,
...@@ -1239,7 +1238,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, ...@@ -1239,7 +1238,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
VIR_FORCE_CLOSE(vhostfd[i]); VIR_FORCE_CLOSE(vhostfd[i]);
if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
queueSize, priv->qemuCaps, mtu))) queueSize, priv->qemuCaps)))
goto try_remove; goto try_remove;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
......
...@@ -503,8 +503,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, ...@@ -503,8 +503,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
virQEMUDriverPtr driver, virQEMUDriverPtr driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int *tapfd, int *tapfd,
size_t *tapfdSize, size_t *tapfdSize)
unsigned int *mtu)
{ {
const char *brname; const char *brname;
int ret = -1; int ret = -1;
...@@ -545,7 +544,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, ...@@ -545,7 +544,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
def->uuid, tunpath, tapfd, *tapfdSize, def->uuid, tunpath, tapfd, *tapfdSize,
virDomainNetGetActualVirtPortProfile(net), virDomainNetGetActualVirtPortProfile(net),
virDomainNetGetActualVlan(net), virDomainNetGetActualVlan(net),
net->coalesce, net->mtu, mtu, net->coalesce, 0, NULL,
tap_create_flags) < 0) { tap_create_flags) < 0) {
virDomainAuditNetDevice(def, net, tunpath, false); virDomainAuditNetDevice(def, net, tunpath, false);
goto cleanup; goto cleanup;
......
...@@ -51,8 +51,7 @@ int qemuInterfaceBridgeConnect(virDomainDefPtr def, ...@@ -51,8 +51,7 @@ int qemuInterfaceBridgeConnect(virDomainDefPtr def,
virQEMUDriverPtr driver, virQEMUDriverPtr driver,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int *tapfd, int *tapfd,
size_t *tapfdSize, size_t *tapfdSize)
unsigned int *mtu)
ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(2);
int qemuInterfaceOpenVhostNet(virDomainDefPtr def, int qemuInterfaceOpenVhostNet(virDomainDefPtr def,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册