Skip to contentSkip to conversation

1/3] libxc: prefer using privcmd character device

PATCH In review Doug Goldstein 4 participants 7 messages Dec 1, 2015 – Jan 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 1/3] libxc: prefer using privcmd character device

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 <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxc/xc_linux_osdep.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxc/xc_linux_osdep.c +7 -1
index 76c55ff..c3a3a14 100644
@@ -46,7 +46,13 @@
 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 )
     {
Signature · 1 line
2.4.10
#1 lore raw

PATCH v3 1/1 2/3] update outdated header comment on privcmd.h

The BSDs have always accessed privcmd via /dev/xen/privcmd while Linux has used /proc/xen/privcmd but things are shifting to /dev/xen/privcmd as well.

CC Ian Jackson <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/include/xen-sys/FreeBSD/privcmd.h    | 2 +-
 tools/include/xen-sys/Linux/privcmd.h      | 2 +-
 tools/include/xen-sys/NetBSD/privcmd.h     | 2 +-
 tools/include/xen-sys/NetBSDRump/privcmd.h | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tools/include/xen-sys/FreeBSD/privcmd.h +1 -1
index 0434d4d..cf1241f 100644
@@ -1,7 +1,7 @@
 /******************************************************************************
  * privcmd.h
  *
- * Interface to /proc/xen/privcmd.
+ * Interface to /dev/xen/privcmd.
  *
  * Copyright (c) 2003-2005, K A Fraser
  *
tools/include/xen-sys/Linux/privcmd.h +1 -1
index 5be860a..e4e666a 100644
@@ -1,7 +1,7 @@
 /******************************************************************************
  * privcmd.h
  * 
- * Interface to /proc/xen/privcmd.
+ * Interface to /dev/xen/privcmd.
  * 
  * Copyright (c) 2003-2005, K A Fraser
  * 
tools/include/xen-sys/NetBSD/privcmd.h +1 -1
index 1296b30..555bad9 100644
@@ -30,7 +30,7 @@
 #ifndef __NetBSD_PRIVCMD_H__
 #define __NetBSD_PRIVCMD_H__
 
-/* Interface to /proc/xen/privcmd */
+/* Interface to /dev/xen/privcmd */
 
 typedef struct privcmd_hypercall
 {
tools/include/xen-sys/NetBSDRump/privcmd.h +1 -1
index 1296b30..555bad9 100644
@@ -30,7 +30,7 @@
 #ifndef __NetBSD_PRIVCMD_H__
 #define __NetBSD_PRIVCMD_H__
 
-/* Interface to /proc/xen/privcmd */
+/* Interface to /dev/xen/privcmd */
 
 typedef struct privcmd_hypercall
 {
Signature · 1 line
2.4.10
#2 lore raw

PATCH v3 1/1 3/3] xendomains initscript: test for privcmd char device

In reply to Doug Goldstein

Allow the init script to continue if either the character device or the proc file is available.

CC Ian Jackson <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/hotplug/Linux/xendomains.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/xendomains.in +1 -1
index 0603842..686f061 100644
@@ -45,7 +45,7 @@ fi
 
 # Correct exit code would probably be 5, but it's enough
 # if xend complains if we're not running as privileged domain
-if ! [ -e /proc/xen/privcmd ]; then
+if ! [ -e /dev/xen/privcmd ] || [ -e /proc/xen/privcmd ]; then
 	exit 0
 fi
 
Signature · 1 line
2.4.10
Acked-by on v3 1/1
#3 lore raw
In reply to Doug Goldstein
Quoted 9 lines · Doug Goldstein

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 <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
Quoted 26 lines
---
 tools/libxc/xc_linux_osdep.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxc/xc_linux_osdep.c +7 -1
index 76c55ff..c3a3a14 100644
@@ -46,7 +46,13 @@
 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 )
     {
Signature · 1 line
2.4.10
#4 lore raw
Quoted 5 lines · Wei Liu
Quoted 4 lines · Doug Goldstein

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.

Quoted 7 lines
Quoted 5 lines
CC Ian Jackson <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>

I believe this version also satisfies Ian's comments on v1, so I've applied all 3 patches.

NB the extra "]" in the subject meant git am produced things like "1/3]
libxc: prefer using privcmd character device". I've fixed that up.

Quoted 19 lines
Quoted 19 lines

---
 tools/libxc/xc_linux_osdep.c | 8 +++++++-

 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxc/xc_linux_osdep.c +1 -1
index 76c55ff..c3a3a14 100644
@@ -46,7 +46,13 @@
  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 ==

Quoted 8 lines
Quoted 8 lines

ENODEV ))
+    {
+        /* Fallback to /proc/xen/privcmd */
+        fd = open("/proc/xen/privcmd", O_RDWR);
+    }

     if ( fd == -1 )
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
In reply to Doug Goldstein

graft 34 ^
close it
thanks

Quoted 33 lines · Doug Goldstein

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 <[email protected]>
CC Stefano Stabellini <[email protected]>
CC Ian Campbell <[email protected]>
CC Wei Liu <[email protected]>
---
 tools/libxc/xc_linux_osdep.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxc/xc_linux_osdep.c +7 -1
index 76c55ff..c3a3a14 100644
@@ -46,7 +46,13 @@
 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 )
     {
Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Processed: Re: [PATCHv3] 1/3] libxc: prefer using privcmd character device

Processing commands for [email protected]:

Quoted 1 line

graft 34 ^

Graft `<[email protected]>' onto #34

Quoted 1 line

close it

Command failed: No previous bug found at /srv/xen-devel-bugs/lib/emesinae/control.pl line 273, <GEN4> line 2. Stop processing here.

Modified/created Bugs:
- 34: http://bugs.xenproject.org/xen/bug/34

---
Xen Hypervisor Bug Tracker
See http://wiki.xen.org/wiki/Reporting_Bugs_against_Xen for information on reporting bugs Contact [email protected] with any infrastructure issues