[libvirt] [PATCH] Avoid warning message from libxl driver on non-Xen kernels

2014-03-17 Thread Daniel P. Berrange
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 berra...@redhat.com
---
 src/libxl/libxl_driver.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ae7342a..445a61a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -970,6 +970,10 @@ libxlDriverShouldLoad(bool privileged)
 return ret;
 }
 
+if (!virFileExists(/proc/xen/capabilities)) {
+VIR_INFO(Disabling driver as /proc/xen/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
-- 
1.8.5.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Avoid warning message from libxl driver on non-Xen kernels

2014-03-17 Thread Michal Privoznik

On 17.03.2014 13:15, Daniel P. Berrange wrote:

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 berra...@redhat.com
---
  src/libxl/libxl_driver.c | 4 
  1 file changed, 4 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ae7342a..445a61a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -970,6 +970,10 @@ libxlDriverShouldLoad(bool privileged)
  return ret;
  }

+if (!virFileExists(/proc/xen/capabilities)) {
+VIR_INFO(Disabling driver as /proc/xen/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



Unfortunately, the context does not show the path is used again, but it 
is. How about:


diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 09ae075..682f851 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,18 @@ 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);


Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Avoid warning message from libxl driver on non-Xen kernels

2014-03-17 Thread Stefan Bader
On 17.03.2014 13:15, Daniel P. Berrange wrote:
 +if (!virFileExists(/proc/xen/capabilities)) {
 +VIR_INFO(Disabling driver as /proc/xen/capabilities does not 
 exist);
 +return false;
 +}

Oh right, I should have checked the log more carefully in all cases. It would
work in all cases but adding unnecessary error messages is not good.



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list