提交 279d6d1c 编写于 作者: C Cole Robinson

qemu_command: vhost: cleanup error reporting

- Switch to cleanup: label and share free calls
- Don't overwrite qemuBuildNicDevStr error
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 14781dcd
...@@ -8147,11 +8147,12 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ...@@ -8147,11 +8147,12 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
char *netdev = NULL; char *netdev = NULL;
unsigned int queues = net->driver.virtio.queues; unsigned int queues = net->driver.virtio.queues;
char *nic = NULL; char *nic = NULL;
int ret = -1;
if (!qemuDomainSupportsNicdev(def, net)) { if (!qemuDomainSupportsNicdev(def, net)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Nicdev support unavailable")); "%s", _("Nicdev support unavailable"));
goto error; goto cleanup;
} }
switch ((virDomainChrType)net->data.vhostuser->type) { switch ((virDomainChrType)net->data.vhostuser->type) {
...@@ -8160,7 +8161,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ...@@ -8160,7 +8161,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
net->data.vhostuser, net->data.vhostuser,
net->info.alias, qemuCaps, false, net->info.alias, qemuCaps, false,
chardevStdioLogd))) chardevStdioLogd)))
goto error; goto cleanup;
break; break;
case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_NULL:
...@@ -8179,7 +8180,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ...@@ -8179,7 +8180,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("vhost-user type '%s' not supported"), _("vhost-user type '%s' not supported"),
virDomainChrTypeToString(net->data.vhostuser->type)); virDomainChrTypeToString(net->data.vhostuser->type));
goto error; goto cleanup;
} }
if (queues > 1 && if (queues > 1 &&
...@@ -8187,45 +8188,38 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, ...@@ -8187,45 +8188,38 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("multi-queue is not supported for vhost-user " _("multi-queue is not supported for vhost-user "
"with this QEMU binary")); "with this QEMU binary"));
goto error; goto cleanup;
} }
if (!(netdev = qemuBuildHostNetStr(net, driver, if (!(netdev = qemuBuildHostNetStr(net, driver,
NULL, 0, NULL, 0))) NULL, 0, NULL, 0)))
goto error; goto cleanup;
if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path, if (virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path,
&net->ifname) < 0) &net->ifname) < 0)
goto error; goto cleanup;
virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chardev); virCommandAddArg(cmd, chardev);
VIR_FREE(chardev);
virCommandAddArg(cmd, "-netdev"); virCommandAddArg(cmd, "-netdev");
virCommandAddArg(cmd, netdev); virCommandAddArg(cmd, netdev);
VIR_FREE(netdev);
if (!(nic = qemuBuildNicDevStr(def, net, bootindex, if (!(nic = qemuBuildNicDevStr(def, net, bootindex,
queues, qemuCaps))) { queues, qemuCaps))) {
virReportError(VIR_ERR_INTERNAL_ERROR, goto cleanup;
"%s", _("Error generating NIC -device string"));
goto error;
} }
virCommandAddArgList(cmd, "-device", nic, NULL); virCommandAddArgList(cmd, "-device", nic, NULL);
VIR_FREE(nic);
virObjectUnref(cfg);
return 0; ret = 0;
cleanup:
error:
virObjectUnref(cfg); virObjectUnref(cfg);
VIR_FREE(netdev); VIR_FREE(netdev);
VIR_FREE(chardev); VIR_FREE(chardev);
VIR_FREE(nic); VIR_FREE(nic);
return -1; return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册