From e23ca83a0d844fe421187fbbbd8f0151e544b60e Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 17 Mar 2014 12:14:11 +0000 Subject: [PATCH] Avoid warning message from libxl driver on non-Xen kernels The libxl driver reads /proc/xen/capabilities to see if it is on a Dom0 kernel. If that file does not even exist though, an error is logged. Check for the file existance before trying to read its contents to avoid the log message. Signed-off-by: Daniel P. Berrange --- src/libxl/libxl_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 09ae0755a2..2dd0d1aae6 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -66,6 +66,8 @@ #define LIBXL_CONFIG_FORMAT_XM "xen-xm" #define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr" +#define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities" + /* Number of Xen scheduler parameters */ #define XEN_SCHED_CREDIT_NPARAM 2 @@ -970,12 +972,17 @@ libxlDriverShouldLoad(bool privileged) return ret; } + if (!virFileExists(HYPERVISOR_CAPABILITIES)) { + VIR_INFO("Disabling driver as " HYPERVISOR_CAPABILITIES + " does not exist"); + return false; + } /* * Don't load if not running on a Xen control domain (dom0). It is not * sufficient to check for the file to exist as any guest can mount * xenfs to /proc/xen. */ - status = virFileReadAll("/proc/xen/capabilities", 10, &output); + status = virFileReadAll(HYPERVISOR_CAPABILITIES, 10, &output); if (status >= 0) { status = strncmp(output, "control_d", 9); }