softmmu/vl.c: Disable default NIC if it has not been compiled into the binary
authorThomas Huth <thuth@redhat.com>
Wed, 10 May 2023 19:26:13 +0000 (21:26 +0200)
committerThomas Huth <thuth@redhat.com>
Mon, 22 May 2023 07:39:15 +0000 (09:39 +0200)
Don't try to instantiate a default NIC if it is not available (since
this will cause QEMU to abort). Emit a warning instead.

Message-Id: <20230512124033.502654-5-thuth@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
softmmu/vl.c

index 43d3b972da55304aa7703c6fb6eb4c271b3f16b6..b0b96f67fac0cb9cc4ac754227c0183d2a33cb4f 100644 (file)
@@ -1294,6 +1294,13 @@ static void qemu_disable_default_devices(void)
         default_monitor = 0;
         default_net = 0;
         default_vga = 0;
+    } else {
+        if (default_net && machine_class->default_nic &&
+            !module_object_class_by_name(machine_class->default_nic)) {
+            warn_report("Default NIC '%s' is not available in this binary",
+                        machine_class->default_nic);
+            default_net = 0;
+        }
     }
 }