[libvirt] [PATCH] virsh: fix missing return value

Although virsh command raises a correct error information, the command status returns 0(true), this patch is used for fixing this issue. Signed-off-by: Alex Jia <ajia@redhat.com> --- tools/virsh-host.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index da60895..2f3b413 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -701,11 +701,13 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) judge = vshCommandOptInt(cmd, "timeout", &timeout); if (judge < 0) { vshError(ctl, "%s", _("timeout number has to be a number")); + goto cleanup; } else if (judge > 0) { judge = 1; } if (judge && timeout < 1) { vshError(ctl, "%s", _("timeout must be positive")); + goto cleanup; } if (vshCommandOptBool(cmd, "async")) { @@ -719,6 +721,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) if (judge > 1) { vshError(ctl, "%s", _("timeout, async and block options are exclusive")); + goto cleanup; } result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags); -- 1.7.1

On 08/27/2012 08:07 AM, Alex Jia wrote:
Although virsh command raises a correct error information, the command status returns 0(true), this patch is used for fixing this issue.
Signed-off-by: Alex Jia <ajia@redhat.com> --- tools/virsh-host.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/virsh-host.c b/tools/virsh-host.c index da60895..2f3b413 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -701,11 +701,13 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) judge = vshCommandOptInt(cmd, "timeout", &timeout); if (judge < 0) { vshError(ctl, "%s", _("timeout number has to be a number")); + goto cleanup; } else if (judge > 0) { judge = 1; } if (judge && timeout < 1) { vshError(ctl, "%s", _("timeout must be positive")); + goto cleanup; }
if (vshCommandOptBool(cmd, "async")) { @@ -719,6 +721,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
if (judge > 1) { vshError(ctl, "%s", _("timeout, async and block options are exclusive")); + goto cleanup; } result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
ACK, Martin.

Thanks and push now. -- Regards, Alex ----- Original Message ----- From: "Martin Kletzander" <mkletzan@redhat.com> To: "Alex Jia" <ajia@redhat.com> Cc: libvir-list@redhat.com Sent: Monday, August 27, 2012 2:17:00 PM Subject: Re: [libvirt] [PATCH] virsh: fix missing return value On 08/27/2012 08:07 AM, Alex Jia wrote:
Although virsh command raises a correct error information, the command status returns 0(true), this patch is used for fixing this issue.
Signed-off-by: Alex Jia <ajia@redhat.com> --- tools/virsh-host.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/tools/virsh-host.c b/tools/virsh-host.c index da60895..2f3b413 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -701,11 +701,13 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) judge = vshCommandOptInt(cmd, "timeout", &timeout); if (judge < 0) { vshError(ctl, "%s", _("timeout number has to be a number")); + goto cleanup; } else if (judge > 0) { judge = 1; } if (judge && timeout < 1) { vshError(ctl, "%s", _("timeout must be positive")); + goto cleanup; }
if (vshCommandOptBool(cmd, "async")) { @@ -719,6 +721,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd)
if (judge > 1) { vshError(ctl, "%s", _("timeout, async and block options are exclusive")); + goto cleanup; } result = virDomainQemuAgentCommand(dom, guest_agent_cmd, timeout, flags);
ACK, Martin.
participants (2)
-
Alex Jia
-
Martin Kletzander