[libvirt] [PATCH 2/3] qemu: Clean up network device CLI generator

Peter Krempa pkrempa at redhat.com
Fri Apr 5 10:12:33 UTC 2013


With the default model assigned in the parse callback, this code is now obsolete.
---
 src/qemu/qemu_command.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 493e5f8..8a76fba 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3664,27 +3664,22 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
                    virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    const char *nic;
+    const char *nic = net->model;
     bool usingVirtio = false;
     char macaddr[VIR_MAC_STRING_BUFLEN];

-    if (!net->model) {
-        nic = "rtl8139";
-    } else if (STREQ(net->model, "virtio")) {
-        if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+    if (STREQ(net->model, "virtio")) {
+        if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
             nic = "virtio-net-ccw";
-        } else if (net->info.type ==
-                   VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+        else if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
             nic = "virtio-net-s390";
-        } else  {
+        else
             nic = "virtio-net-pci";
-        }
+
         usingVirtio = true;
-    } else {
-        nic = net->model;
     }

-    virBufferAdd(&buf, nic, strlen(nic));
+    virBufferAdd(&buf, nic, -1);
     if (usingVirtio && net->driver.virtio.txmode) {
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) {
             virBufferAddLit(&buf, ",tx=");
-- 
1.8.1.5




More information about the libvir-list mailing list