qemu-ga: guest_suspend(): improve error reporting

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>
This commit is contained in:
Luiz Capitulino 2012-11-27 11:02:04 -02:00 committed by Michael Roth
parent 6b26e837a4
commit 7b3760879b
1 changed files with 22 additions and 15 deletions

View File

@ -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;
}
ga_wait_child(pid, &status, &local_err);
if (error_is_set(&local_err)) {
error_propagate(err, local_err);
goto out;
}
if (!WIFEXITED(status)) {
error_setg(err, "child process has terminated abnormally");
goto out;
}
if (WEXITSTATUS(status)) {
error_setg(err, "child process has failed to suspend");
goto out;
}
out:
g_free(pmutils_path);
if (pid < 0) {
goto exit_err;
}
do {
rpid = waitpid(pid, &status, 0);
} while (rpid == -1 && errno == EINTR);
if (rpid == pid && WIFEXITED(status) && !WEXITSTATUS(status)) {
return;
}
exit_err:
error_set(err, QERR_UNDEFINED_ERROR);
}
void qmp_guest_suspend_disk(Error **err)