[libvirt] [PATCH 3/3] virsh: use vshError consistently after virBufferError checks

Nishith Shah nishithshah.2211 at gmail.com
Wed Aug 24 17:11:13 UTC 2016


I guess you meant "If virBufferError() reports an error, then vshError() is
needed to report the error situation instead of a simple vshPrint()." :-)

Had me confused for a bit there.

Nishith

On Wed, Aug 24, 2016 at 7:44 PM, Pino Toscano <ptoscano at redhat.com> wrote:

> If virBufferError() reports an error, then vshError() is needed to
> report the error situation instead of a simple vshError().
> ---
>  tools/virsh-domain.c | 12 ++++++------
>  tools/virsh-pool.c   |  2 +-
>  tools/virsh-volume.c |  2 +-
>  3 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 26b1457..de2a22c 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -737,7 +737,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
>      virBufferAddLit(&buf, "</disk>\n");
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
> +        vshError(ctl, "%s", _("Failed to allocate XML buffer"));
>          goto cleanup;
>      }
>
> @@ -1048,7 +1048,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd
> *cmd)
>      virBufferAddLit(&buf, "</interface>\n");
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
> +        vshError(ctl, "%s", _("Failed to allocate XML buffer"));
>          goto cleanup;
>      }
>
> @@ -7831,7 +7831,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd)
>          type = VIR_DOMAIN_METADATA_DESCRIPTION;
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to collect new description/title"));
> +        vshError(ctl, "%s", _("Failed to collect new description/title"));
>          goto cleanup;
>      }
>      desc = virBufferContentAndReset(&buf);
> @@ -8955,7 +8955,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd
> *cmd)
>      virBufferTrim(&buf, " ", -1);
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to collect command"));
> +        vshError(ctl, "%s", _("Failed to collect command"));
>          goto cleanup;
>      }
>      monitor_cmd = virBufferContentAndReset(&buf);
> @@ -9269,7 +9269,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd
> *cmd)
>          virBufferAdd(&buf, opt->data, -1);
>      }
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to collect command"));
> +        vshError(ctl, "%s", _("Failed to collect command"));
>          goto cleanup;
>      }
>      guest_agent_cmd = virBufferContentAndReset(&buf);
> @@ -10820,7 +10820,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
>
>          /* Ensure we can print our URI */
>          if (virBufferError(&buf)) {
> -            vshPrint(ctl, "%s", _("Failed to create display URI"));
> +            vshError(ctl, "%s", _("Failed to create display URI"));
>              goto cleanup;
>          }
>
> diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
> index f952887..d25851e 100644
> --- a/tools/virsh-pool.c
> +++ b/tools/virsh-pool.c
> @@ -376,7 +376,7 @@ virshBuildPoolXML(vshControl *ctl,
>      virBufferAddLit(&buf, "</pool>\n");
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
> +        vshError(ctl, "%s", _("Failed to allocate XML buffer"));
>          return false;
>      }
>
> diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
> index a2f0432..b7debc2 100644
> --- a/tools/virsh-volume.c
> +++ b/tools/virsh-volume.c
> @@ -337,7 +337,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
>      virBufferAddLit(&buf, "</volume>\n");
>
>      if (virBufferError(&buf)) {
> -        vshPrint(ctl, "%s", _("Failed to allocate XML buffer"));
> +        vshError(ctl, "%s", _("Failed to allocate XML buffer"));
>          goto cleanup;
>      }
>      xml = virBufferContentAndReset(&buf);
> --
> 2.7.4
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160824/d01ebf13/attachment-0001.htm>


More information about the libvir-list mailing list