qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 10/10] qemu-ga: guest_suspend(): improve error r


From: mdroth
Subject: Re: [Qemu-devel] [PATCH 10/10] qemu-ga: guest_suspend(): improve error reporting
Date: Wed, 28 Nov 2012 13:49:55 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Nov 27, 2012 at 11:02:04AM -0200, Luiz Capitulino wrote:
> Most errors are QERR_UNDEFINED_ERROR today.
> 
> Signed-off-by: Luiz Capitulino <address@hidden>

Reviewed-by: Michael Roth <address@hidden>

> ---
>  qga/commands-posix.c | 29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 5a7e308..ce058b5 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -702,8 +702,9 @@ out:
>  static void guest_suspend(const char *pmutils_bin, const char *sysfile_str,
>                            Error **err)
>  {
> +    Error *local_err = NULL;
>      char *pmutils_path;
> -    pid_t rpid, pid;
> +    pid_t pid;
>      int status;
> 
>      pmutils_path = g_find_program_in_path(pmutils_bin);
> @@ -741,23 +742,29 @@ static void guest_suspend(const char *pmutils_bin, 
> const char *sysfile_str,
>          }
> 
>          _exit(EXIT_SUCCESS);
> +    } else if (pid < 0) {
> +        error_setg_errno(err, errno, "failed to create child process");
> +        goto out;
>      }
> 
> -    g_free(pmutils_path);
> +    ga_wait_child(pid, &status, &local_err);
> +    if (error_is_set(&local_err)) {
> +        error_propagate(err, local_err);
> +        goto out;
> +    }
> 
> -    if (pid < 0) {
> -        goto exit_err;
> +    if (!WIFEXITED(status)) {
> +        error_setg(err, "child process has terminated abnormally");
> +        goto out;
>      }
> 
> -    do {
> -        rpid = waitpid(pid, &status, 0);
> -    } while (rpid == -1 && errno == EINTR);
> -    if (rpid == pid && WIFEXITED(status) && !WEXITSTATUS(status)) {
> -        return;
> +    if (WEXITSTATUS(status)) {
> +        error_setg(err, "child process has failed to suspend");
> +        goto out;
>      }
> 
> -exit_err:
> -    error_set(err, QERR_UNDEFINED_ERROR);
> +out:
> +    g_free(pmutils_path);
>  }
> 
>  void qmp_guest_suspend_disk(Error **err)
> -- 
> 1.8.0
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]