libxc: prefer using privcmd character device
authorDoug Goldstein <cardoe@cardoe.com>
Tue, 1 Dec 2015 19:27:53 +0000 (13:27 -0600)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 2 Dec 2015 15:23:14 +0000 (15:23 +0000)
Prefer using the character device over the proc file if the character
device exists. This follows similar conversions of xenbus to avoid
issues with FMODE_ATOMIC_POS added in Linux 3.14 and newer.

CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/xc_linux_osdep.c

index 76c55ff30498f85d71e5eb356711ff436a1373a8..c3a3a140e277d397f756a9ae139c147935b40e01 100644 (file)
 static xc_osdep_handle linux_privcmd_open(xc_interface *xch)
 {
     int flags, saved_errno;
-    int fd = open("/proc/xen/privcmd", O_RDWR);
+    int fd = open("/dev/xen/privcmd", O_RDWR); /* prefer this newer interface */
+
+    if ( fd == -1 && ( errno == ENOENT || errno == ENXIO || errno == ENODEV ))
+    {
+        /* Fallback to /proc/xen/privcmd */
+        fd = open("/proc/xen/privcmd", O_RDWR);
+    }
 
     if ( fd == -1 )
     {