提交 4f70ae24 编写于 作者: J Jim Fehlig

xen: ensure /usr/sbin/xend exists before checking status

With xend on the way out, installations may not even have
/usr/sbin/xend, which results in the following error when the
drivers are probed

2014-04-28 18:21:19.271+0000: 22129: error : virCommandWait:2426 :
internal error: Child process (/usr/sbin/xend status) unexpected exit
status 127: libvirt:  error : cannot execute binary /usr/sbin/xend:
No such file or directory

Check for existence of /usr/sbin/xend before trying to run it with
the 'status' option.
上级 04515a34
...@@ -223,7 +223,6 @@ static bool ...@@ -223,7 +223,6 @@ static bool
libxlDriverShouldLoad(bool privileged) libxlDriverShouldLoad(bool privileged)
{ {
bool ret = false; bool ret = false;
virCommandPtr cmd;
int status; int status;
char *output = NULL; char *output = NULL;
...@@ -236,7 +235,7 @@ libxlDriverShouldLoad(bool privileged) ...@@ -236,7 +235,7 @@ libxlDriverShouldLoad(bool privileged)
if (!virFileExists(HYPERVISOR_CAPABILITIES)) { if (!virFileExists(HYPERVISOR_CAPABILITIES)) {
VIR_INFO("Disabling driver as " HYPERVISOR_CAPABILITIES VIR_INFO("Disabling driver as " HYPERVISOR_CAPABILITIES
" does not exist"); " does not exist");
return false; return ret;
} }
/* /*
* Don't load if not running on a Xen control domain (dom0). It is not * Don't load if not running on a Xen control domain (dom0). It is not
...@@ -256,14 +255,20 @@ libxlDriverShouldLoad(bool privileged) ...@@ -256,14 +255,20 @@ libxlDriverShouldLoad(bool privileged)
} }
/* Don't load if legacy xen toolstack (xend) is in use */ /* Don't load if legacy xen toolstack (xend) is in use */
cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL); if (virFileExists("/usr/sbin/xend")) {
if (virCommandRun(cmd, &status) == 0 && status == 0) { virCommandPtr cmd;
VIR_INFO("Legacy xen tool stack seems to be in use, disabling "
"libxenlight driver."); cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
if (virCommandRun(cmd, NULL) == 0) {
VIR_INFO("Legacy xen tool stack seems to be in use, disabling "
"libxenlight driver.");
} else {
ret = true;
}
virCommandFree(cmd);
} else { } else {
ret = true; ret = true;
} }
virCommandFree(cmd);
return ret; return ret;
} }
......
...@@ -315,13 +315,16 @@ xenUnifiedProbe(void) ...@@ -315,13 +315,16 @@ xenUnifiedProbe(void)
static bool static bool
xenUnifiedXendProbe(void) xenUnifiedXendProbe(void)
{ {
virCommandPtr cmd;
bool ret = false; bool ret = false;
cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL); if (virFileExists("/usr/sbin/xend")) {
if (virCommandRun(cmd, NULL) == 0) virCommandPtr cmd;
ret = true;
virCommandFree(cmd); cmd = virCommandNewArgList("/usr/sbin/xend", "status", NULL);
if (virCommandRun(cmd, NULL) == 0)
ret = true;
virCommandFree(cmd);
}
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册