[libvirt] [PATCH] virsh: don't print error info when snapshot xml is not changed

If xml is not changed, error message is printed. So check ret value instead of edit variable for error message. --- tools/virsh-snapshot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index aff91d3..5d84f7a 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) _("Snapshot %s XML configuration not changed.\n"), \ name); \ ret = true; \ - goto cleanup; \ + goto edit_cleanup; \ } #define EDIT_DEFINE \ (strstr(doc, "<state>disk-snapshot</state>") ? \ @@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: + if (!ret) + vshError(ctl, _("Failed to update %s"), name); if (edited) virDomainSnapshotFree(edited); - else - vshError(ctl, _("Failed to update %s"), name); if (snapshot) virDomainSnapshotFree(snapshot); if (dom) -- 1.7.10.1

On 21.08.2012 22:54, Guannan Ren wrote:
If xml is not changed, error message is printed. So check ret value instead of edit variable for error message. --- tools/virsh-snapshot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index aff91d3..5d84f7a 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) _("Snapshot %s XML configuration not changed.\n"), \ name); \ ret = true; \ - goto cleanup; \ + goto edit_cleanup; \
Mea culpa - even though I've specifically stressed in how-to that we have to jump to edit_cleanup in EDIT_NOT_CHANGED somehow I ignored this.
} #define EDIT_DEFINE \ (strstr(doc, "<state>disk-snapshot</state>") ? \ @@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) ret = true;
cleanup: + if (!ret) + vshError(ctl, _("Failed to update %s"), name); if (edited) virDomainSnapshotFree(edited); - else - vshError(ctl, _("Failed to update %s"), name); if (snapshot) virDomainSnapshotFree(snapshot); if (dom)
ACK Michal

On 08/22/2012 05:43 PM, Michal Privoznik wrote:
On 21.08.2012 22:54, Guannan Ren wrote:
If xml is not changed, error message is printed. So check ret value instead of edit variable for error message. --- tools/virsh-snapshot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index aff91d3..5d84f7a 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -449,7 +449,7 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) _("Snapshot %s XML configuration not changed.\n"), \ name); \ ret = true; \ - goto cleanup; \ + goto edit_cleanup; \ Mea culpa - even though I've specifically stressed in how-to that we have to jump to edit_cleanup in EDIT_NOT_CHANGED somehow I ignored this.
} #define EDIT_DEFINE \ (strstr(doc, "<state>disk-snapshot</state>") ? \ @@ -487,10 +487,10 @@ cmdSnapshotEdit(vshControl *ctl, const vshCmd *cmd) ret = true;
cleanup: + if (!ret) + vshError(ctl, _("Failed to update %s"), name); if (edited) virDomainSnapshotFree(edited); - else - vshError(ctl, _("Failed to update %s"), name); if (snapshot) virDomainSnapshotFree(snapshot); if (dom)
ACK
Michal
Thanks for the review. :) pushed. Guannan Ren
participants (2)
-
Guannan Ren
-
Michal Privoznik