qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, tomoki.sekiyama.qu@hitachi.com,
	lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 10/12] qemu-ga: guest_suspend(): improve error reporting
Date: Tue,  8 Jan 2013 17:00:07 -0600	[thread overview]
Message-ID: <1357686009-13139-11-git-send-email-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <1357686009-13139-1-git-send-email-mdroth@linux.vnet.ibm.com>

From: Luiz Capitulino <lcapitulino@redhat.com>

Most errors are QERR_UNDEFINED_ERROR today.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 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 f3ee492..614a421 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.7.9.5

  parent reply	other threads:[~2013-01-08 23:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 22:59 [Qemu-devel] [PULL 0/12] qemu-ga: error handling improvements and fsfreeze hooks Michael Roth
2013-01-08 22:59 ` [Qemu-devel] [PATCH 01/12] qemu-ga: guest_file_handle_find(): take an Error argument Michael Roth
2013-01-08 22:59 ` [Qemu-devel] [PATCH 02/12] qemu-ga: qmp_guest_file_close(): fix fclose() error check Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 03/12] qemu-ga: qmp_guest_file_*: improve error reporting Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 04/12] qemu-ga: qmp_guest_shutdown(): " Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 05/12] qemu-ga: build_fs_mount_list(): take an Error argument Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 06/12] qemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set() Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 07/12] qemu-ga: qmp_guest_fstrim(): " Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 08/12] qemu-ga: qmp_guest_network_get_interfaces(): get rid of snprintf() " Michael Roth
2013-01-08 23:00 ` [Qemu-devel] [PATCH 09/12] qemu-ga: bios_supports_mode(): improve error reporting Michael Roth
2013-01-08 23:00 ` Michael Roth [this message]
2013-01-08 23:00 ` [Qemu-devel] [PATCH 11/12] qemu-ga: execute hook to quiesce the guest on fsfreeze-freeze/thaw Michael Roth
2013-01-09 21:02   ` Blue Swirl
2013-01-10 11:17     ` Luiz Capitulino
2013-01-08 23:00 ` [Qemu-devel] [PATCH 12/12] qemu-ga: sample fsfreeze hooks Michael Roth
2013-01-09 17:01 ` [Qemu-devel] [PULL 0/12] qemu-ga: error handling improvements and " Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357686009-13139-11-git-send-email-mdroth@linux.vnet.ibm.com \
    --to=mdroth@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tomoki.sekiyama.qu@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).