提交 9c74414d 编写于 作者: E Eric Blake

hooks: let virCommand do the error reporting

The code was reporting raw exit status without decoding it into
normal vs. signal exit.  virCommandRun already does this, but
with a different error type, so all we have to do is recast
the error to the correct type.
Reported by li guang.

* src/util/hooks.c (virHookCall): Simplify.
上级 60dea2c6
/* /*
* hooks.c: implementation of the synchronous hooks support * hooks.c: implementation of the synchronous hooks support
* *
* Copyright (C) 2010-2011 Red Hat, Inc. * Copyright (C) 2010-2012 Red Hat, Inc.
* Copyright (C) 2010 Daniel Veillard * Copyright (C) 2010 Daniel Veillard
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -206,7 +206,6 @@ virHookCall(int driver, ...@@ -206,7 +206,6 @@ virHookCall(int driver,
char **output) char **output)
{ {
int ret; int ret;
int exitstatus;
char *path; char *path;
virCommandPtr cmd; virCommandPtr cmd;
const char *drvstr; const char *drvstr;
...@@ -279,12 +278,11 @@ virHookCall(int driver, ...@@ -279,12 +278,11 @@ virHookCall(int driver,
if (output) if (output)
virCommandSetOutputBuffer(cmd, output); virCommandSetOutputBuffer(cmd, output);
ret = virCommandRun(cmd, &exitstatus); ret = virCommandRun(cmd, NULL);
if (ret == 0 && exitstatus != 0) { if (ret < 0) {
virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, /* Convert INTERNAL_ERROR into known error. */
_("Hook script %s %s failed with error code %d"), virErrorPtr err = virGetLastError();
path, drvstr, exitstatus); virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, "%s", err->message);
ret = -1;
} }
virCommandFree(cmd); virCommandFree(cmd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册