libxc: prefer using privcmd character device
PATCH 1/4 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.
--- tools/libxc/xc_linux_osdep.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/libxc/xc_linux_osdep.c +7 -1
@@ -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 ) + { +/* Fallback to /proc/xen/privcmd */ + fd =open ("/proc/xen/privcmd" ,O_RDWR ); + }if ( fd ==-1 ) {
Signature · 1 line
2.4.10
PATCH 2/4 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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
Re: [PATCH 2/4] update outdated header comment on privcmd.h
Doug Goldstein writes ("[PATCH 2/4] update outdated header comment on privcmd.h"):
Quoted 3 lines
The BSDs have always accessed privcmd via
/dev/xen/privcmdwhile Linux has used/proc/xen/privcmdbut things are shifting to/dev/xen/privcmdas well.
PATCH 3/4 gdbsx: prefer privcmd character device
In reply to Doug GoldsteinPrefer using the character device over the proc file if the character device exists.
--- tools/debugger/gdbsx/xg/xg_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/debugger/gdbsx/xg/xg_main.c +5 -3
@@ -127,9 +127,11 @@ xg_init()int flags, saved_errno;XGTRC ("E\n" ); -if ((_dom0_fd=open ("/proc/xen/privcmd" ,O_RDWR )) ==-1 ) { -perror ("Failed to open /proc/xen/privcmd\n" ); -return -1 ; +if ((_dom0_fd=open ("/dev/xen/privcmd" ,O_RDWR )) ==-1 ) { +if ((_dom0_fd=open ("/proc/xen/privcmd" ,O_RDWR )) ==-1 ) { +perror ("Failed to open /dev/xen/privcmd or /proc/xen/privcmd\n" ); +return -1 ; + } }/* Although we return the file handle as the 'xc handle' the API * does not specify / guarentee that this integer is in fact
Signature · 1 line
2.4.10
Re: [PATCH 3/4] gdbsx: prefer privcmd character device
Doug Goldstein writes ("[PATCH 3/4] gdbsx: prefer privcmd character device"):
Quoted 2 lines
Prefer using the character device over the proc file if the character device exists.
I think this common logic (which also appears in your 1/4 patch) should be factored out.
Could gdbsx not use a libxc handle ?
Ian.
Re: [PATCH 3/4] gdbsx: prefer privcmd character device
Quoted 11 lines · Ian Jackson
Doug Goldstein writes ("[PATCH 3/4] gdbsx: prefer privcmd character device"):
Quoted 2 lines
Prefer using the character device over the proc file if the character device exists.
I think this common logic (which also appears in your 1/4 patch) should be factored out.
Could gdbsx not use a libxc handle ?
Ian.
I agree. I actually emailed the maintainer about this but his address bounced so I left it as the simpler patch instead. I can make that chance and resubmit if you'd prefer.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] gdbsx: prefer privcmd character device
Quoted 8 lines · Doug Goldstein
Quoted 7 lines · Ian Jackson
Doug Goldstein writes ("[PATCH 3/4] gdbsx: prefer privcmd character device"):
Quoted 2 lines
Prefer using the character device over the proc file if the character device exists.
I think this common logic (which also appears in your 1/4 patch) should be factored out.
Quoted 9 lines
Quoted 4 lines
Could gdbsx not use a libxc handle ?
Ian.
I agree. I actually emailed the maintainer about this but his address bounced so I left it as the simpler patch instead. I can make that chance and resubmit if you'd prefer.
I'll just drop this out of the v2 and look at improving it in another series.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/4] gdbsx: prefer privcmd character device
In reply to Doug GoldsteinDoug Goldstein writes ("Re: [PATCH 3/4] gdbsx: prefer privcmd character device"):
Quoted 3 lines
I agree. I actually emailed the maintainer about this but his address bounced so I left it as the simpler patch instead. I can make that chance and resubmit if you'd prefer.
Yes, please, thanks!
Ian.
Re: [PATCH 3/4] gdbsx: prefer privcmd character device
In reply to Ian JacksonQuoted 8 lines · Ian Jackson
Doug Goldstein writes ("[PATCH 3/4] gdbsx: prefer privcmd character device"):
Quoted 2 lines
Prefer using the character device over the proc file if the character device exists.
I think this common logic (which also appears in your 1/4 patch) should be factored out.
For reasons I don't really understand gdbsc appears to avoid the use of libxenctrl completely and has it's own h/call wrapper and such.
(Perhaps a legacy of it being out of tree?)
PATCH 4/4 xendomains initscript: test for privcmd char device
In reply to Doug GoldsteinAllow the init script to continue if either the character device or the proc file is available.
--- tools/hotplug/Linux/xendomains.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/Linux/xendomains.in +1 -1
@@ -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
Re: [PATCH 4/4] xendomains initscript: test for privcmd char device
Doug Goldstein writes ("[PATCH 4/4] xendomains initscript: test for privcmd char device"):
Quoted 2 lines
Allow the init script to continue if either the character device or the proc file is available.
Doug Goldstein writes ("[PATCH 1/4] libxc: prefer using privcmd character device"):
Quoted 3 lines
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_POSadded in Linux 3.14 and newer.
This is a fine change, but
tools/libxc/xc_linux_osdep.c line 52
Quoted 5 lines
tools/libxc/xc_linux_osdep.c +4
-1-int fd =open ("/proc/xen/privcmd" ,O_RDWR ); +int fd =open ("/dev/xen/privcmd" ,O_RDWR );/* prefer this newer interface */ + +if ( fd ==-1 ) + {
I think this should check the errno value. I expect that any of ENOENT, ENXIO and ENODEV should be tolerated - but others should probaby be a fatal error.
Ian.