#34 - libxc should use /dev/xen/privcmd on Linux

Owner: Ian Campbell <Ian.Campbell@citrix.com>

Date: Mon Jan 13 17:15:02 2014

Last Update: Mon Jan 13 17:15:02 2014

Severity: wishlist

Affects:

State: Closed

[ Retrieve as mbox ]


Missing Control message: <56A8DA9F.9040000@cardoe.com>; (Archives: gmane, marc.info)


From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel List <xen-devel@lists.xen.org>, Ian Campbell <Ian.Campbell@citrix.com>
Subject: [Xen-devel] libxc linux privcmd bugs
Date: Mon, 13 Jan 2014 16:53:35 +0000
Message-ID: <52D41A0F.5030707@citrix.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

Hello,

More bugs for tracking:

1) PERROR("Could not obtain handle on privileged command interface");
doesn't indicate which path(s) were tried.

2) xc_linux_osdep.c:linux_privcmd_open() only tries to open
"/proc/xen/privcmd" which is the classic-xen location, whereas the
expected location under PVops is "/dev/xen/privcmd".  The other open
functions (evtchn, gnttab, gntshr) exclusivly use "/dev/xen/$FOO".

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Ian Campbell <Ian.Campbell@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel List <xen-devel@lists.xen.org>
Subject: Re: [Xen-devel] libxc linux privcmd bugs
Date: Mon, 13 Jan 2014 17:06:00 +0000
Message-ID: <1389632760.13654.107.camel@kazak.uk.xensource.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

create ^
title it libxc should use /dev/xen/privcmd on Linux
severity it wishlist
thanks

On Mon, 2014-01-13 at 16:53 +0000, Andrew Cooper wrote:
> Hello,
> 
> More bugs for tracking:
> 
> 1) PERROR("Could not obtain handle on privileged command interface");
> doesn't indicate which path(s) were tried.
> 
> 2) xc_linux_osdep.c:linux_privcmd_open() only tries to open
> "/proc/xen/privcmd" which is the classic-xen location, whereas the
> expected location under PVops is "/dev/xen/privcmd".

Nothing has ever used /dev/xen/privcmd since it was reimplemented to
replace xenfs, so describing it as expected is a bit strong. At best
there is a wishlist issue here for someone to finish implementing this
transition, which I've now created.

http://lists.xen.org/archives/html/xen-devel/2011-12/msg01344.html
http://lists.xen.org/archives/html/xen-devel/2011-12/msg01345.html
looks to be related patches, not sure why thay didn't go in back then.
Lack of a S-o-b perhaps.

>   The other open
> functions (evtchn, gnttab, gntshr) exclusivly use "/dev/xen/$FOO".

These have only ever been driver rather than proc based so there was
never a transition.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Ian Campbell <Ian.Campbell@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel List <xen-devel@lists.xen.org>
Subject: Re: [Xen-devel] libxc linux privcmd bugs
Date: Mon, 13 Jan 2014 17:06:16 +0000
Message-ID: <1389632776.13654.108.camel@kazak.uk.xensource.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

create ^
title it libxc should use /dev/xen/privcmd on Linux
severity it wishlist
thanks

On Mon, 2014-01-13 at 16:53 +0000, Andrew Cooper wrote:
> Hello,
> 
> More bugs for tracking:
> 
> 1) PERROR("Could not obtain handle on privileged command interface");
> doesn't indicate which path(s) were tried.
> 
> 2) xc_linux_osdep.c:linux_privcmd_open() only tries to open
> "/proc/xen/privcmd" which is the classic-xen location, whereas the
> expected location under PVops is "/dev/xen/privcmd".

Nothing has ever used /dev/xen/privcmd since it was reimplemented to
replace xenfs, so describing it as expected is a bit strong. At best
there is a wishlist issue here for someone to finish implementing this
transition, which I've now created.

http://lists.xen.org/archives/html/xen-devel/2011-12/msg01344.html
http://lists.xen.org/archives/html/xen-devel/2011-12/msg01345.html
looks to be related patches, not sure why thay didn't go in back then.
Lack of a S-o-b perhaps.

>   The other open
> functions (evtchn, gnttab, gntshr) exclusivly use "/dev/xen/$FOO".

These have only ever been driver rather than proc based so there was
never a transition.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


From: Doug Goldstein <cardoe@cardoe.com>
To: xen-devel@lists.xen.org
Cc: Doug Goldstein <cardoe@cardoe.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Ian Campbell <ian.campbell@citrix.com>, Wei Liu <wei.liu2@citrix.com>, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [Xen-devel] [PATCHv3] 1/3] libxc: prefer using privcmd character device
Date: Tue,  1 Dec 2015 13:27:53 -0600
Message-ID: <1448998075-23878-1-git-send-email-cardoe@cardoe.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

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>
---
 tools/libxc/xc_linux_osdep.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c
index 76c55ff..c3a3a14 100644
--- a/tools/libxc/xc_linux_osdep.c
+++ b/tools/libxc/xc_linux_osdep.c
@@ -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 )
     {
-- 
2.4.10


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Doug Goldstein <cardoe@cardoe.com>
To: xen-devel@lists.xen.org
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>, Doug Goldstein <cardoe@cardoe.com>, Ian Campbell <ian.campbell@citrix.com>, Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>
Subject: [Xen-devel] [PATCHv3] 2/3] update outdated header comment on privcmd.h
Date: Tue,  1 Dec 2015 13:27:54 -0600
Message-ID: <1448998075-23878-2-git-send-email-cardoe@cardoe.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

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 <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: Ian Jackson <ian.jackson@eu.citrix.com>
---
 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(-)

diff --git a/tools/include/xen-sys/FreeBSD/privcmd.h b/tools/include/xen-sys/FreeBSD/privcmd.h
index 0434d4d..cf1241f 100644
--- a/tools/include/xen-sys/FreeBSD/privcmd.h
+++ b/tools/include/xen-sys/FreeBSD/privcmd.h
@@ -1,7 +1,7 @@
 /******************************************************************************
  * privcmd.h
  *
- * Interface to /proc/xen/privcmd.
+ * Interface to /dev/xen/privcmd.
  *
  * Copyright (c) 2003-2005, K A Fraser
  *
diff --git a/tools/include/xen-sys/Linux/privcmd.h b/tools/include/xen-sys/Linux/privcmd.h
index 5be860a..e4e666a 100644
--- a/tools/include/xen-sys/Linux/privcmd.h
+++ b/tools/include/xen-sys/Linux/privcmd.h
@@ -1,7 +1,7 @@
 /******************************************************************************
  * privcmd.h
  * 
- * Interface to /proc/xen/privcmd.
+ * Interface to /dev/xen/privcmd.
  * 
  * Copyright (c) 2003-2005, K A Fraser
  * 
diff --git a/tools/include/xen-sys/NetBSD/privcmd.h b/tools/include/xen-sys/NetBSD/privcmd.h
index 1296b30..555bad9 100644
--- a/tools/include/xen-sys/NetBSD/privcmd.h
+++ b/tools/include/xen-sys/NetBSD/privcmd.h
@@ -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
 {
diff --git a/tools/include/xen-sys/NetBSDRump/privcmd.h b/tools/include/xen-sys/NetBSDRump/privcmd.h
index 1296b30..555bad9 100644
--- a/tools/include/xen-sys/NetBSDRump/privcmd.h
+++ b/tools/include/xen-sys/NetBSDRump/privcmd.h
@@ -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
 {
-- 
2.4.10


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Doug Goldstein <cardoe@cardoe.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>, Ian Campbell <ian.campbell@citrix.com>, Doug Goldstein <cardoe@cardoe.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [Xen-devel] [PATCHv3] 3/3] xendomains initscript: test for privcmd char device
Date: Tue,  1 Dec 2015 13:27:55 -0600
Message-ID: <1448998075-23878-3-git-send-email-cardoe@cardoe.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

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

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: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/hotplug/Linux/xendomains.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hotplug/Linux/xendomains.in b/tools/hotplug/Linux/xendomains.in
index 0603842..686f061 100644
--- a/tools/hotplug/Linux/xendomains.in
+++ b/tools/hotplug/Linux/xendomains.in
@@ -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
 
-- 
2.4.10


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Wei Liu <wei.liu2@citrix.com>
To: Doug Goldstein <cardoe@cardoe.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>, xen-devel@lists.xen.org, Ian Campbell <ian.campbell@citrix.com>, Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [Xen-devel] [PATCHv3] 1/3] libxc: prefer using privcmd character device
Date: Wed, 2 Dec 2015 11:42:49 +0000
Message-ID: <20151202114249.GE21588@citrix.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

On Tue, Dec 01, 2015 at 01:27:53PM -0600, Doug Goldstein wrote:
> 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 | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c
> index 76c55ff..c3a3a14 100644
> --- a/tools/libxc/xc_linux_osdep.c
> +++ b/tools/libxc/xc_linux_osdep.c
> @@ -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 )
>      {
> -- 
> 2.4.10
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Ian Campbell <ian.campbell@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>, Doug Goldstein <cardoe@cardoe.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>, xen-devel@lists.xen.org, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: Re: [Xen-devel] [PATCHv3] 1/3] libxc: prefer using privcmd character device
Date: Wed, 2 Dec 2015 15:52:10 +0000
Message-ID: <1449071530.4424.87.camel@citrix.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

On Wed, 2015-12-02 at 11:42 +0000, Wei Liu wrote:
> On Tue, Dec 01, 2015 at 01:27:53PM -0600, Doug Goldstein wrote:
> > 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>

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.

> 
> > ---
> >  tools/libxc/xc_linux_osdep.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/libxc/xc_linux_osdep.c
> > b/tools/libxc/xc_linux_osdep.c
> > index 76c55ff..c3a3a14 100644
> > --- a/tools/libxc/xc_linux_osdep.c
> > +++ b/tools/libxc/xc_linux_osdep.c
> > @@ -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 )
> >      {

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

From: Doug Goldstein <cardoe@cardoe.com>
To: xen@bugs.xenproject.org
Cc: xen-devel@lists.xen.org
Subject: Re: [Xen-devel] [PATCHv3] 1/3] libxc: prefer using privcmd character device
Date: Wed, 27 Jan 2016 08:40:56 -0600
Message-ID: <56A8D6F8.5080806@cardoe.com>

[ Reply to this message; Retrieve Raw Message; Archives: gmane, marc.info ]

[Part 1 (text/plain, inline)]
graft 34 ^
close it
thanks

On 12/1/15 1:27 PM, Doug Goldstein wrote:
> 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>
> ---
>  tools/libxc/xc_linux_osdep.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c
> index 76c55ff..c3a3a14 100644
> --- a/tools/libxc/xc_linux_osdep.c
> +++ b/tools/libxc/xc_linux_osdep.c
> @@ -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 )
>      {
> 


-- 
Doug Goldstein
[signature.asc (application/pgp-signature, attachment)]
[Part 3 (text/plain, inline)]