diff mbox series

[6/6] qemu: command: vhost: cleanup error reporting

Message ID 9db0a71c70e54b2774892ef62cfa1c12bf4ee717.1529426092.git.crobinso@redhat.com
State Accepted
Commit 279d6d1c700f4954b3cf7034ef87458d9da2a458
Headers show
Series qemu: command: Replace vlan= with netdev= | expand

Commit Message

Cole Robinson June 19, 2018, 4:40 p.m. UTC
- Switch to cleanup: label and share free calls
- Don't overwrite qemuBuildNicDevStr error

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/qemu/qemu_command.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f2dbb3fadd..1ffcb5b1ae 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8147,11 +8147,12 @@  qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
     char *netdev = NULL;
     unsigned int queues = net->driver.virtio.queues;
     char *nic = NULL;
+    int ret = -1;
 
     if (!qemuDomainSupportsNicdev(def, net)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("Nicdev support unavailable"));
-        goto error;
+        goto cleanup;
     }
 
     switch ((virDomainChrType)net->data.vhostuser->type) {
@@ -8160,7 +8161,7 @@  qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
                                                net->data.vhostuser,
                                                net->info.alias, qemuCaps, false,
                                                chardevStdioLogd)))
-            goto error;
+            goto cleanup;
         break;
 
     case VIR_DOMAIN_CHR_TYPE_NULL:
@@ -8179,7 +8180,7 @@  qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("vhost-user type '%s' not supported"),
                        virDomainChrTypeToString(net->data.vhostuser->type));
-        goto error;
+        goto cleanup;
     }
 
     if (queues > 1 &&
@@ -8187,45 +8188,38 @@  qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("multi-queue is not supported for vhost-user "
                          "with this QEMU binary"));
-        goto error;
+        goto cleanup;
     }
 
     if (!(netdev = qemuBuildHostNetStr(net, driver,
                                        NULL, 0, NULL, 0)))
-        goto error;
+        goto cleanup;
 
     if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path,
                                                &net->ifname) < 0)
-        goto error;
+        goto cleanup;
 
     virCommandAddArg(cmd, "-chardev");
     virCommandAddArg(cmd, chardev);
-    VIR_FREE(chardev);
 
     virCommandAddArg(cmd, "-netdev");
     virCommandAddArg(cmd, netdev);
-    VIR_FREE(netdev);
 
     if (!(nic = qemuBuildNicDevStr(def, net, bootindex,
                                    queues, qemuCaps))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("Error generating NIC -device string"));
-        goto error;
+        goto cleanup;
     }
 
     virCommandAddArgList(cmd, "-device", nic, NULL);
-    VIR_FREE(nic);
-    virObjectUnref(cfg);
 
-    return 0;
-
- error:
+    ret = 0;
+ cleanup:
     virObjectUnref(cfg);
     VIR_FREE(netdev);
     VIR_FREE(chardev);
     VIR_FREE(nic);
 
-    return -1;
+    return ret;
 }
 
 static int