[libvirt] [PATCH 09/17] qemu: command: drop QEMU_CAPS_DEVICE for net cli

Cole Robinson crobinso at redhat.com
Fri Jan 22 19:30:24 UTC 2016


-net none is never required anymore, even platforms that can't use
-device abide -nodefaults.

Additionally we conditionalized the cli building on nnets != 0, but that
was redundant.
---
 src/qemu/qemu_command.c | 72 +++++++++++++++++++++++--------------------------
 1 file changed, 33 insertions(+), 39 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a943d69..55c869e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9276,6 +9276,7 @@ qemuBuildCommandLine(virConnectPtr conn,
     virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
     char *fdc_opts_str = NULL;
     int bootCD = 0, bootFloppy = 0, bootDisk = 0, bootHostdevNet = 0;
+    int bootNet = 0;
 
 
     VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
@@ -10228,53 +10229,46 @@ qemuBuildCommandLine(virConnectPtr conn,
         }
     }
 
-    if (!def->nnets) {
-        /* If we have -device, then we set -nodefault already */
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
-            virCommandAddArgList(cmd, "-net", "none", NULL);
-    } else {
-        int bootNet = 0;
 
-        if (emitBootindex) {
-            /* convert <boot dev='network'/> to bootindex since we didn't emit
-             * -boot n
-             */
-            for (i = 0; i < def->os.nBootDevs; i++) {
-                if (def->os.bootDevs[i] == VIR_DOMAIN_BOOT_NET) {
-                    bootNet = i + 1;
-                    break;
-                }
+    if (emitBootindex) {
+        /* convert <boot dev='network'/> to bootindex since we didn't emit
+         * -boot n
+         */
+        for (i = 0; i < def->os.nBootDevs; i++) {
+            if (def->os.bootDevs[i] == VIR_DOMAIN_BOOT_NET) {
+                bootNet = i + 1;
+                break;
             }
         }
+    }
 
-        for (i = 0; i < def->nnets; i++) {
-            virDomainNetDefPtr net = def->nets[i];
-            int vlan;
+    for (i = 0; i < def->nnets; i++) {
+        virDomainNetDefPtr net = def->nets[i];
+        int vlan;
 
-            /* VLANs are not used with -netdev, so don't record them */
-            if (qemuDomainSupportsNetdev(def, qemuCaps, net))
-                vlan = -1;
-            else
-                vlan = i;
+        /* VLANs are not used with -netdev, so don't record them */
+        if (qemuDomainSupportsNetdev(def, qemuCaps, net))
+            vlan = -1;
+        else
+            vlan = i;
 
-            if (qemuBuildInterfaceCommandLine(cmd, driver, def, net,
-                                              qemuCaps, vlan, bootNet, vmop,
-                                              standalone, nnicindexes, nicindexes) < 0)
-                goto error;
+        if (qemuBuildInterfaceCommandLine(cmd, driver, def, net,
+                                          qemuCaps, vlan, bootNet, vmop,
+                                          standalone, nnicindexes, nicindexes) < 0)
+            goto error;
 
-            last_good_net = i;
-            /* if this interface is a type='hostdev' interface and we
-             * haven't yet added a "bootindex" parameter to an
-             * emulated network device, save the bootindex - hostdev
-             * interface commandlines will be built later on when we
-             * cycle through all the hostdevs, and we'll use it then.
-             */
-            if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
-                bootHostdevNet == 0) {
-                bootHostdevNet = bootNet;
-            }
-            bootNet = 0;
+        last_good_net = i;
+        /* if this interface is a type='hostdev' interface and we
+         * haven't yet added a "bootindex" parameter to an
+         * emulated network device, save the bootindex - hostdev
+         * interface commandlines will be built later on when we
+         * cycle through all the hostdevs, and we'll use it then.
+         */
+        if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
+            bootHostdevNet == 0) {
+            bootHostdevNet = bootNet;
         }
+        bootNet = 0;
     }
 
     if (def->nsmartcards) {
-- 
2.5.0




More information about the libvir-list mailing list