Skip to contentSkip to conversation

FreeBSD fixes

PATCH Applied Roger Pau Monne 6 participants 15 messages Jul 20, 2015 – Jul 21, 2015

lore
Share & tools
lore
#0 lore raw

cover FreeBSD fixes

Misc fixes for FreeBSD that affect libxl and the recently added xendriverdomain rc.d script.

#1 lore raw

PATCH 1/3 libxl: include sys/endian.h for FreeBSD

be64toh and friends are declared in sys/endian.h on FreeBSD, so include it as part of libxl_osdeps.h.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/libxl/libxl_osdeps.h | 1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxl_osdeps.h +1 -0
index 08eaf0c..b265df8 100644
@@ -42,6 +42,7 @@
 #define SYSFS_PCIBACK_DRIVER   "/dev/null"
 #define NETBACK_NIC_NAME       "xnb%u.%d"
 #include <libutil.h>
+#include <sys/endian.h>
 #endif
 
 #ifndef SYSFS_PCIBACK_DRIVER
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH for-4.6 1/3] libxl: include sys/endian.h for FreeBSD

Quoted 7 lines · Roger Pau Monne

be64toh and friends are declared in sys/endian.h on FreeBSD, so include it as part of libxl_osdeps.h.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Quoted 18 lines
---
 tools/libxl/libxl_osdeps.h | 1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxl_osdeps.h +1 -0
index 08eaf0c..b265df8 100644
@@ -42,6 +42,7 @@
 #define SYSFS_PCIBACK_DRIVER   "/dev/null"
 #define NETBACK_NIC_NAME       "xnb%u.%d"
 #include <libutil.h>
+#include <sys/endian.h>
 #endif
 
 #ifndef SYSFS_PCIBACK_DRIVER
Signature · 1 line
1.9.5 (Apple Git-50.3)
Applied
#3 lore raw

Re: [PATCH for-4.6 1/3] libxl: include sys/endian.h for FreeBSD

Quoted 11 lines · Wei Liu
Quoted 8 lines · Roger Pau Monne

be64toh and friends are declared in sys/endian.h on FreeBSD, so include it
as part of libxl_osdeps.h.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

Applied.

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

#4 lore raw

PATCH 2/3 libxl/psr: use Xen error codes when checking hypercall return values

In reply to Roger Pau Monne

We cannot use the systems errno values when checking return values from Xen, because some OSes don't have the same set of errno definitions. Instead use the definitions present in Xen public errno.h header.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

---
I have not checked if there are other places in libxl that need similar treatment, I just came around this because FreeBSD doesn't have EBADSLT defined.

---
 tools/libxl/libxl_internal.h |  1 +
 tools/libxl/libxl_psr.c      | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)
tools/libxl/libxl_internal.h +1 -0
index 2b6b2a0..cf5db8a 100644
@@ -55,6 +55,7 @@
 #include "xentoollog.h"
 
 #include <xen/io/xenbus.h>
+#include <xen/errno.h>
 
 #ifdef LIBXL_H
 # error libxl.h should be included via libxl_internal.h, not separately
tools/libxl/libxl_psr.c +13 -13
index 2a07777..5711c38 100644
@@ -24,17 +24,17 @@ static void libxl__psr_log_err_msg(libxl__gc *gc, int err)
     char *msg;
 
     switch (err) {
-    case ENOSYS:
-    case EOPNOTSUPP:
+    case XEN_ENOSYS:
+    case XEN_EOPNOTSUPP:
         msg = "unsupported operation";
         break;
-    case ESRCH:
+    case XEN_ESRCH:
         msg = "invalid domain ID";
         break;
-    case EBADSLT:
+    case XEN_EBADSLT:
         msg = "socket is not supported";
         break;
-    case EFAULT:
+    case XEN_EFAULT:
         msg = "failed to exchange data with Xen";
         break;
     default:
@@ -50,16 +50,16 @@ static void libxl__psr_cmt_log_err_msg(libxl__gc *gc, int err)
     char *msg;
 
     switch (err) {
-    case ENODEV:
+    case XEN_ENODEV:
         msg = "CMT is not supported in this system";
         break;
-    case EEXIST:
+    case XEN_EEXIST:
         msg = "CMT is already attached to this domain";
         break;
-    case ENOENT:
+    case XEN_ENOENT:
         msg = "CMT is not attached to this domain";
         break;
-    case EUSERS:
+    case XEN_EUSERS:
         msg = "no free RMID available";
         break;
     default:
@@ -75,16 +75,16 @@ static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
     char *msg;
 
     switch (err) {
-    case ENODEV:
+    case XEN_ENODEV:
         msg = "CAT is not supported in this system";
         break;
-    case ENOENT:
+    case XEN_ENOENT:
         msg = "CAT is not enabled on the socket";
         break;
-    case EUSERS:
+    case XEN_EUSERS:
         msg = "no free COS available";
         break;
-    case EEXIST:
+    case XEN_EEXIST:
         msg = "The same CBM is already set to this domain";
         break;
 
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 2/3
#5 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Roger Pau Monne writes ("[PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values"):

Quoted 8 lines

We cannot use the systems errno values when checking return values from Xen, because some OSes don't have the same set of errno definitions. Instead use the definitions present in Xen public errno.h header.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Quoted 3 lines

I have not checked if there are other places in libxl that need similar treatment, I just came around this because FreeBSD doesn't have EBADSLT defined.

Right. There is probably more of this, but that's not a blocker for this patch.

Maybe it would be worth mentioning this issue in CODING_STYLE.

Ian.

#6 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Ian Jackson writes ("Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values"):

Quoted 1 line

Actually, I withdraw that. I was confused about how things worked. To summarise an irc discussion:

* On NetBSD, hypercall numbers are translated by the privcmd driver. This is probably correct. (Not sure if FreeBSD does the same.)

* So the libxc API is that errno values are OS errno values. Roger's patch is wrong.

* A corrollary is that the hypervisor may not use errno values which are not in the toolstack OS. Since the hypervisor is supposed to be fairly portable to different toolstacks, that means we shouldn't be using errno values which are not in POSIX.

* Re EBADSLT in particular:
- There is one return site in 4.5, which is in hvm_save_one, which is toolstack-onloy functionality. We can therefore change it for 4.6.
- The other sites where EBADSLT are generated in staging must also be fixed.

So the correct approach is:

- Patch to change EBADSLT to something else, everywhere.
- Patch to remove EBADSLT from hypervisor errno list (if it's not just been renamed/renumbered).
- If FreeBSD privcmd does not translate errno numbers, make it do so.

Ian.

#7 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Quoted 23 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values"):

Quoted 1 line

Actually, I withdraw that. I was confused about how things worked. To summarise an irc discussion:

* On NetBSD, hypercall numbers are translated by the privcmd driver. This is probably correct. (Not sure if FreeBSD does the same.)

* So the libxc API is that errno values are OS errno values. Roger's patch is wrong.

* A corrollary is that the hypervisor may not use errno values which are not in the toolstack OS. Since the hypervisor is supposed to be fairly portable to different toolstacks, that means we shouldn't be using errno values which are not in POSIX.

* Re EBADSLT in particular:
- There is one return site in 4.5, which is in hvm_save_one, which is toolstack-onloy functionality. We can therefore change it for 4.6.
- The other sites where EBADSLT are generated in staging must also be fixed.

Quoted 6 lines

So the correct approach is:

- Patch to change EBADSLT to something else, everywhere.
- Patch to remove EBADSLT from hypervisor errno list (if it's not just been renamed/renumbered).
- If FreeBSD privcmd does not translate errno numbers, make it do so.

EBADSLT isn't the only example here. I believe ENODATA is a similar example.

If we are going to do this, we should prune all non-posix errnos out of the hypervisor errno list.

~Andrew

#8 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values"):

Quoted 2 lines

EBADSLT isn't the only example here. I believe ENODATA is a similar example.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/errno.h?rev=1.40&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

But

http://fxr.watson.org/fxr/source/sys/errno.h

How annoying.

Ian.

#9 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Quoted 8 lines · Ian Jackson

Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.6 2/3] libxl/psr:
use Xen error codes when checking hypercall return values"):

Quoted 3 lines

EBADSLT isn't the only example here. I believe ENODATA is a similar
example.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html

Quoted 8 lines

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/errno.h?rev=1.40&cont
ent-type=text/x-cvsweb-markup&only_with_tag=MAIN

But

http://fxr.watson.org/fxr/source/sys/errno.h

How annoying.

THat's just a FreeBSD bug then?

#10 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 21.07.15 at 14:47, <[email protected]> wrote:
Quoted 11 lines · Ian Jackson

Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.6 2/3] libxl/psr:
use Xen error codes when checking hypercall return values"):

Quoted 3 lines

EBADSLT isn't the only example here. I believe ENODATA is a similar
example.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/errno.h?rev=1.40&cont
ent-type=text/x-cvsweb-markup&only_with_tag=MAIN

Quoted 7 lines
Quoted 5 lines

But

http://fxr.watson.org/fxr/source/sys/errno.h

How annoying.

THat's just a FreeBSD bug then?

Why? The OpenGroup page above clearly says that the two so far identified values are an extension.

Jan

#11 lore raw

Re: [PATCH for-4.6 2/3] libxl/psr: use Xen error codes when checking hypercall return values

Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 2 lines
Quoted 2 lines · On 21.07.15 at 14:47, <[email protected]> wrote:
Quoted 16 lines · Ian Jackson

Andrew Cooper writes ("Re: [Xen-devel] [PATCH for-4.6 2/3] libxl/psr:
use Xen error codes when checking hypercall return values"):

Quoted 3 lines

EBADSLT isn't the only example here. I believe ENODATA is a similar
example.

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.
html

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/errno.h?rev=1.40&
cont
ent-type=text/x-cvsweb-markup&only_with_tag=MAIN

But

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

http://fxr.watson.org/fxr/source/sys/errno.h

How annoying.

THat's just a FreeBSD bug then?

Why? The OpenGroup page above clearly says that the two so far identified values are an extension.

I didn't realise that was what the XSR tag meant, sorry.

I note that OB is obsolete too FWIW...

I suppose it could be worse than "POSIX plus a couple of grandfathered in exceptions (sorry)"...

Ian.

#12 lore raw

PATCH 3/3 hotplug/FreeBSD: fix xendriverdomain rc.d script

In reply to Roger Pau Monne

hotplugpath.sh by default is located in /usr/local/etc/xen/scripts on FreeBSD. Instead of hardcoding it's location use the XEN_SCRIPT_DIR variable like it's used on the xencommons rc.d script.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
---
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in +1 -1
index 25e3edd..4063c06 100644
@@ -7,7 +7,7 @@
 
 . /etc/rc.subr
 
-. /etc/xen/scripts/hotplugpath.sh
+. @XEN_SCRIPT_DIR@/hotplugpath.sh
 
 LD_LIBRARY_PATH="${libdir}"
 export LD_LIBRARY_PATH
Signature · 7 lines
1.9.5 (Apple Git-50.3)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v1 3/3
#13 lore raw

Re: [PATCH for-4.6 3/3] hotplug/FreeBSD: fix xendriverdomain rc.d script

Quoted 8 lines · Roger Pau Monne

hotplugpath.sh by default is located in /usr/local/etc/xen/scripts on FreeBSD. Instead of hardcoding it's location use the XEN_SCRIPT_DIR variable like it's used on the xencommons rc.d script.

Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Quoted 19 lines
---
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in +1 -1
index 25e3edd..4063c06 100644
@@ -7,7 +7,7 @@
 
 . /etc/rc.subr
 
-. /etc/xen/scripts/hotplugpath.sh
+. @XEN_SCRIPT_DIR@/hotplugpath.sh
 
 LD_LIBRARY_PATH="${libdir}"
 export LD_LIBRARY_PATH
Signature · 1 line
1.9.5 (Apple Git-50.3)
#14 lore raw

Re: [PATCH for-4.6 3/3] hotplug/FreeBSD: fix xendriverdomain rc.d script

Quoted 7 lines · Wei Liu
Quoted 6 lines · Roger Pau Monne

hotplugpath.sh by default is located in /usr/local/etc/xen/scripts on
FreeBSD. Instead of hardcoding it's location use the XEN_SCRIPT_DIR variable
like it's used on the xencommons rc.d script.

Quoted 6 lines
Quoted 4 lines
Cc Ian Jackson <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

Me too, plus applied.

Thanks Roger, sorry for the breakage.

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