]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_command.c: move QEMU_CAPS_VIRTIO_NET_HOST_MTU check to qemu_validate.c
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Fri, 9 Oct 2020 14:30:35 +0000 (11:30 -0300)
committerDaniel Henrique Barboza <danielhb413@gmail.com>
Thu, 15 Oct 2020 13:50:34 +0000 (10:50 -0300)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_validate.c
tests/qemuxml2xmltest.c

index 9f45faa4909d26ce95b99fa52e9ddb0b6178dda2..62b8df1a1333b2f454c72e3305da238c61609a00 100644 (file)
@@ -3408,14 +3408,9 @@ qemuBuildNicDevStr(virDomainDefPtr def,
     if (usingVirtio && net->driver.virtio.tx_queue_size)
         virBufferAsprintf(&buf, ",tx_queue_size=%u", net->driver.virtio.tx_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"));
-            return NULL;
-        }
+    if (usingVirtio && net->mtu)
         virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu);
-    }
+
     if (usingVirtio && net->teaming.type == VIR_DOMAIN_NET_TEAMING_TYPE_PERSISTENT)
        virBufferAddLit(&buf, ",failover=on");
 
index 6b2e48dbc31cfe2381bee831958e7a9042a62470..01fc318741efc883aeee17546394181408a4f85e 100644 (file)
@@ -1277,6 +1277,14 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
             return -1;
         }
 
+        if (net->mtu &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("setting MTU is not supported with this "
+                             "QEMU binary"));
+            return -1;
+        }
+
         if (net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("rx_queue_size has to be a power of two"));
index e85f2188dbad5ea1747b9699d5fa41c7a5bf4b36..a9037101de410f515d1eba32541c8cbb8b697544 100644 (file)
@@ -499,7 +499,7 @@ mymain(void)
     DO_TEST("watchdog", NONE);
     DO_TEST("net-bandwidth", QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_VNC);
     DO_TEST("net-bandwidth2", QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_VNC);
-    DO_TEST("net-mtu", NONE);
+    DO_TEST("net-mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU);
     DO_TEST("net-coalesce", NONE);
     DO_TEST("net-many-models", NONE);