render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From b36260c361f9d8a854c4d5e9c7309aed7cb99834 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <b36260c361f9d8a854c4d5e9c7309aed7cb99834@dist-git>
3e5111
From: Laine Stump <laine@laine.org>
3e5111
Date: Tue, 23 May 2017 13:02:42 -0400
3e5111
Subject: [PATCH] Revert "qemu: propagate bridge MTU into qemu "host_mtu"
3e5111
 option"
3e5111
3e5111
This reverts commit 2841e675.
3e5111
3e5111
It turns out that adding the host_mtu field to the PCI capabilities in
3e5111
the guest bumps the length of PCI capabilities beyond the 32 byte
3e5111
boundary, so the virtio-net device gets 64 bytes of ioport space
3e5111
instead of 32, which offsets the address of all the other following
3e5111
devices. Migration doesn't work very well when the location and length
3e5111
of PCI capabilities of devices is changed between source and
3e5111
destination.
3e5111
3e5111
This means that we need to make sure that the absence/presence of
3e5111
host_mtu on the qemu commandline always matches between source and
3e5111
destination, which means that we need to make setting of host_mtu an
3e5111
opt-in thing (it can't happen automatically when the bridge being used
3e5111
has a non-default MTU, which is what commit 2841e675 implemented).
3e5111
3e5111
I do want to re-implement this feature with an <mtu auto='on'/>
3e5111
setting, but probably won't backport that to any stable branches, so
3e5111
I'm first reverting the original commit, and that revert can be pushed
3e5111
to the few releases that have been made since the original (3.1.0 -
3e5111
3.3.0)
3e5111
3e5111
Resolves: https://bugzilla.redhat.com/1449346
3e5111
(cherry picked from commit 77780a29edace958a1f931d3281b962be4f5290e)
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_command.c   | 32 ++++++++++----------------------
3e5111
 src/qemu/qemu_command.h   |  3 +--
3e5111
 src/qemu/qemu_hotplug.c   |  5 ++---
3e5111
 src/qemu/qemu_interface.c |  5 ++---
3e5111
 src/qemu/qemu_interface.h |  3 +--
3e5111
 5 files changed, 16 insertions(+), 32 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
3e5111
index 30feef1de..4d3a3d8ca 100644
3e5111
--- a/src/qemu/qemu_command.c
3e5111
+++ b/src/qemu/qemu_command.c
3e5111
@@ -3633,8 +3633,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
3e5111
                    int vlan,
3e5111
                    unsigned int bootindex,
3e5111
                    size_t vhostfdSize,
3e5111
-                   virQEMUCapsPtr qemuCaps,
3e5111
-                   unsigned int mtu)
3e5111
+                   virQEMUCapsPtr qemuCaps)
3e5111
 {
3e5111
     virBuffer buf = VIR_BUFFER_INITIALIZER;
3e5111
     const char *nic = net->model;
3e5111
@@ -3758,23 +3757,13 @@ qemuBuildNicDevStr(virDomainDefPtr def,
3e5111
         virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size);
3e5111
     }
3e5111
 
3e5111
-    if (usingVirtio && mtu) {
3e5111
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
3e5111
-
3e5111
-            virBufferAsprintf(&buf, ",host_mtu=%u", mtu);
3e5111
-
3e5111
-        } else {
3e5111
-            /* log an error if mtu was requested specifically for this
3e5111
-             * interface, otherwise, if it's just what was reported by
3e5111
-             * the attached network, ignore it.
3e5111
-             */
3e5111
-            if (net->mtu) {
3e5111
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
3e5111
-                               _("setting MTU is not supported with "
3e5111
-                                 "this QEMU binary"));
3e5111
-                goto error;
3e5111
-            }
3e5111
+    if (usingVirtio && net->mtu) {
3e5111
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
3e5111
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
3e5111
+                           _("setting MTU is not supported with this QEMU binary"));
3e5111
+            goto error;
3e5111
         }
3e5111
+        virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
3e5111
     }
3e5111
 
3e5111
     if (vlan == -1)
3e5111
@@ -8275,7 +8264,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
3e5111
     VIR_FREE(netdev);
3e5111
 
3e5111
     if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
3e5111
-                                   queues, qemuCaps, net->mtu))) {
3e5111
+                                   queues, qemuCaps))) {
3e5111
         virReportError(VIR_ERR_INTERNAL_ERROR,
3e5111
                        "%s", _("Error generating NIC -device string"));
3e5111
         goto error;
3e5111
@@ -8321,7 +8310,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
3e5111
     virDomainNetType actualType = virDomainNetGetActualType(net);
3e5111
     virNetDevBandwidthPtr actualBandwidth;
3e5111
     size_t i;
3e5111
-    unsigned int mtu = net->mtu;
3e5111
 
3e5111
 
3e5111
     if (!bootindex)
3e5111
@@ -8376,7 +8364,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
3e5111
         memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
3e5111
 
3e5111
         if (qemuInterfaceBridgeConnect(def, driver, net,
3e5111
-                                       tapfd, &tapfdSize, &mtu) < 0)
3e5111
+                                       tapfd, &tapfdSize) < 0)
3e5111
             goto cleanup;
3e5111
         break;
3e5111
 
3e5111
@@ -8556,7 +8544,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
3e5111
     }
3e5111
     if (qemuDomainSupportsNicdev(def, net)) {
3e5111
         if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
3e5111
-                                       vhostfdSize, qemuCaps, mtu)))
3e5111
+                                       vhostfdSize, qemuCaps)))
3e5111
             goto cleanup;
3e5111
         virCommandAddArgList(cmd, "-device", nic, NULL);
3e5111
     } else {
3e5111
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
3e5111
index 7da92c8c9..09cb00ee9 100644
3e5111
--- a/src/qemu/qemu_command.h
3e5111
+++ b/src/qemu/qemu_command.h
3e5111
@@ -101,8 +101,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def,
3e5111
                          int vlan,
3e5111
                          unsigned int bootindex,
3e5111
                          size_t vhostfdSize,
3e5111
-                         virQEMUCapsPtr qemuCaps,
3e5111
-                         unsigned int mtu);
3e5111
+                         virQEMUCapsPtr qemuCaps);
3e5111
 
3e5111
 char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
3e5111
 
3e5111
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
3e5111
index 5c3660922..cdeb0617a 100644
3e5111
--- a/src/qemu/qemu_hotplug.c
3e5111
+++ b/src/qemu/qemu_hotplug.c
3e5111
@@ -968,7 +968,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
3e5111
     bool charDevPlugged = false;
3e5111
     bool netdevPlugged = false;
3e5111
     bool hostPlugged = false;
3e5111
-    unsigned int mtu = net->mtu;
3e5111
 
3e5111
     /* preallocate new slot for device */
3e5111
     if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0)
3e5111
@@ -1025,7 +1024,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
3e5111
             goto cleanup;
3e5111
         memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize);
3e5111
         if (qemuInterfaceBridgeConnect(vm->def, driver, net,
3e5111
-                                       tapfd, &tapfdSize, &mtu) < 0)
3e5111
+                                       tapfd, &tapfdSize) < 0)
3e5111
             goto cleanup;
3e5111
         iface_connected = true;
3e5111
         if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps,
3e5111
@@ -1239,7 +1238,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
3e5111
         VIR_FORCE_CLOSE(vhostfd[i]);
3e5111
 
3e5111
     if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
3e5111
-                                      queueSize, priv->qemuCaps, mtu)))
3e5111
+                                      queueSize, priv->qemuCaps)))
3e5111
         goto try_remove;
3e5111
 
3e5111
     qemuDomainObjEnterMonitor(driver, vm);
3e5111
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
3e5111
index c643b76ec..e11d69c3e 100644
3e5111
--- a/src/qemu/qemu_interface.c
3e5111
+++ b/src/qemu/qemu_interface.c
3e5111
@@ -503,8 +503,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
3e5111
                            virQEMUDriverPtr driver,
3e5111
                            virDomainNetDefPtr net,
3e5111
                            int *tapfd,
3e5111
-                           size_t *tapfdSize,
3e5111
-                           unsigned int *mtu)
3e5111
+                           size_t *tapfdSize)
3e5111
 {
3e5111
     const char *brname;
3e5111
     int ret = -1;
3e5111
@@ -545,7 +544,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
3e5111
                                            def->uuid, tunpath, tapfd, *tapfdSize,
3e5111
                                            virDomainNetGetActualVirtPortProfile(net),
3e5111
                                            virDomainNetGetActualVlan(net),
3e5111
-                                           net->coalesce, net->mtu, mtu,
3e5111
+                                           net->coalesce, 0, NULL,
3e5111
                                            tap_create_flags) < 0) {
3e5111
             virDomainAuditNetDevice(def, net, tunpath, false);
3e5111
             goto cleanup;
3e5111
diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h
3e5111
index ba74ac2cf..a7faa0b3d 100644
3e5111
--- a/src/qemu/qemu_interface.h
3e5111
+++ b/src/qemu/qemu_interface.h
3e5111
@@ -51,8 +51,7 @@ int qemuInterfaceBridgeConnect(virDomainDefPtr def,
3e5111
                                virQEMUDriverPtr driver,
3e5111
                                virDomainNetDefPtr net,
3e5111
                                int *tapfd,
3e5111
-                               size_t *tapfdSize,
3e5111
-                               unsigned int *mtu)
3e5111
+                               size_t *tapfdSize)
3e5111
     ATTRIBUTE_NONNULL(2);
3e5111
 
3e5111
 int qemuInterfaceOpenVhostNet(virDomainDefPtr def,
3e5111
-- 
3e5111
2.13.0
3e5111