Skip to contentSkip to conversation

libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD

PATCH In review Roger Pau Monne 2 participants 4 messages Sep 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD

# HG changeset patch
# User Roger Pau Monne <[email protected]>
# Date 1316091721 -7200
# Node ID 015617579cd36fc58318aaf350bec5f7cc07ef2f
# Parent 63e254468d6e8d81baeafaed68f05791dc21eb4e
libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD.

tools/hotplug/NetBSD/block +3 -1
diff -r 63e254468d6e -r 015617579cd3 tools/hotplug/NetBSD/block
@@ -19,7 +19,7 @@ error() {
 
 xpath=$1
 xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3
 xparams=$(xenstore-read "$xpath/params")
 
 case $xstatus in
@@ -38,6 +38,8 @@ 6)
 		echo "unknown type $xtype" >&2
 		;;
 	esac
+	echo xenstore-write $xpath/hotplug-status disconnected
+	xenstore-write $xpath/hotplug-status disconnected
 	xenstore-rm $xpath
 	exit 0
 	;;
tools/libxl/libxl_device.c +61 -12

124 lines not on this page · raw message

tools/libxl/libxl_osdeps.h +1 -0
diff -r 63e254468d6e -r 015617579cd3 tools/libxl/libxl_osdeps.h
@@ -25,6 +25,7 @@
 
 #if defined(__NetBSD__) || defined(__OpenBSD__)
 #include <util.h>
+#define HAVE_PHY_BACKEND_FILE_SUPPORT
 #elif defined(__linux__)
 #include <pty.h>
 #elif defined(__sun__)
tools/xenbackendd/xenbackendd.c +36 -6

80 lines not on this page · raw message

#1 lore raw
Quoted 8 lines · Roger Pau Monne

# HG changeset patch
# User Roger Pau Monne <[email protected]>
# Date 1316091721 -7200
# Node ID 015617579cd36fc58318aaf350bec5f7cc07ef2f
# Parent 63e254468d6e8d81baeafaed68f05791dc21eb4e
libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD.

This was one long line which mercurial will use as a summary, it's a good idea to make sure that the first line stands somewhat alone as a summary so the e.g. "hg log" is useful.

Also this sounds on the face of it like two bugfixes, if that's the case they should be submitted separately.

Quoted 16 lines

diff -r 63e254468d6e -r 015617579cd3 tools/hotplug/NetBSD/block

tools/hotplug/NetBSD/block +1 -1
@@ -19,7 +19,7 @@ error() {
 
 xpath=$1
 xstatus=$2
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3
 xparams=$(xenstore-read "$xpath/params")
 
 case $xstatus in

tools/hotplug/NetBSD/block 6) · line 41

Quoted 4 lines
tools/hotplug/NetBSD/block +1 -0
@@ -38,6 +38,8 @@ 6)
 		echo "unknown type $xtype" >&2
 		;;
 	esac
+	echo xenstore-write $xpath/hotplug-status disconnected

leftover debugging?

Quoted 19 lines
tools/hotplug/NetBSD/block +1 -0
+	xenstore-write $xpath/hotplug-status disconnected
 	xenstore-rm $xpath
 	exit 0
 	;;
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xs_transaction_t t;
     char *state_path = libxl__sprintf(gc, "%s/state", be_path);
tools/hotplug/NetBSD/block +7 -0
+    char *hotplug_path = libxl__sprintf(gc, "%s/hotplug-status", be_path);
     char *state = libxl__xs_read(gc, XBT_NULL, state_path);
+    char *hotplug = libxl__xs_read(gc, XBT_NULL, hotplug_path);
     int rc = 0;
 
     if (!state)
         goto out;
+
+#ifdef HAVE_PHY_BACKEND_FILE_SUPPORT
+    if (!strstr(be_path, "vbd")) {
+        if (atoi(state) != 4) {
+            xs_rm(ctx->xsh, XBT_NULL, be_path);

tools/hotplug/NetBSD/block

Quoted 10 lines
tools/hotplug/NetBSD/block +10 -0
+            goto out;
+        }
+    } else {
+        if (!hotplug)
+            goto out;
+        if (!strcmp(hotplug, "disconnected")) {
+            xs_rm(ctx->xsh, XBT_NULL, be_path);
+            goto out;
+        }
+    }

Do the other backend types also write this node? It looks like Linux does, at least in some circumstances (tap and vbd AFAICT), in which case perhaps this is suitable as the only test here (i.e. drop the #ifdef and the #else case). That would remove a lot of the conditional code in this patch.

Ian.

#2 lore raw

2011/9/15 Ian Campbell <[email protected]>:

Quoted 10 lines · Roger Pau Monne
Quoted 8 lines

# HG changeset patch
# User Roger Pau Monne <[email protected]>
# Date 1316091721 -7200
# Node ID 015617579cd36fc58318aaf350bec5f7cc07ef2f
# Parent  63e254468d6e8d81baeafaed68f05791dc21eb4e
libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD.

Quoted 5 lines

This was one long line which mercurial will use as a summary, it's a good idea to make sure that the first line stands somewhat alone as a summary so the e.g. "hg log" is useful.
Also this sounds on the face of it like two bugfixes, if that's the case they should be submitted separately.

Well, it's not a bugfix, because NetBSD was not supported by libxl, so I think it's just part of the patch to add support for NetBSD to libxl. I will split the line, and the patch if it's necessary, but one doesn't make sense without the other, and I don't really know what would be in each patch.

Quoted 14 lines
Quoted 14 lines

diff -r 63e254468d6e -r 015617579cd3 tools/hotplug/NetBSD/block

tools/hotplug/NetBSD/block      Thu Sep 15 15:02:01 2011 +0200 renamed from tools/hotplug/NetBSD/block      Wed Sep 14 14:18:40 2011 +0200 +0 -0
@@ -19,7 +19,7 @@ error() {
 

 xpath=$1
 xstatus=$2

tools/hotplug/NetBSD/block      Thu Sep 15 15:02:01 2011 +0200 renamed from tools/hotplug/NetBSD/block      Wed Sep 14 14:18:40 2011 +0200 +1 -1
-xtype=$(xenstore-read "$xpath/type")
+xtype=$3

 xparams=$(xenstore-read "$xpath/params")

Quoted 8 lines
Quoted 6 lines

 case $xstatus in

tools/hotplug/NetBSD/block      Thu Sep 15 15:02:01 2011 +0200 renamed from tools/hotplug/NetBSD/block      Wed Sep 14 14:18:40 2011 +0200 +0 -0
@@ -38,6 +38,8 @@ 6)

              echo "unknown type $xtype" >&2
              ;;
      esac
+     echo xenstore-write $xpath/hotplug-status disconnected

leftover debugging?

The block NetBSD script contains some echos, so I feel it would be interesting to add this one too.

Quoted 27 lines
Quoted 27 lines

+     xenstore-write $xpath/hotplug-status disconnected xenstore-rm $xpath
      exit 0
      ;;
     libxl_ctx *ctx = libxl__gc_owner(gc);
     xs_transaction_t t;
     char *state_path = libxl__sprintf(gc, "%s/state", be_path);
+    char *hotplug_path = libxl__sprintf(gc, "%s/hotplug-status", be_path); char *state = libxl__xs_read(gc, XBT_NULL, state_path);
+    char *hotplug = libxl__xs_read(gc, XBT_NULL, hotplug_path); int rc = 0;

     if (!state)
         goto out;

tools/hotplug/NetBSD/block      Thu Sep 15 15:02:01 2011 +0200 renamed from tools/hotplug/NetBSD/block      Wed Sep 14 14:18:40 2011 +0200 +13 -0
+
+#ifdef HAVE_PHY_BACKEND_FILE_SUPPORT
+    if (!strstr(be_path, "vbd")) {
+        if (atoi(state) != 4) {
+            xs_rm(ctx->xsh, XBT_NULL, be_path);
+            goto out;
+        }
+    } else {
+        if (!hotplug)
+            goto out;
+        if (!strcmp(hotplug, "disconnected")) {
+            xs_rm(ctx->xsh, XBT_NULL, be_path);
+            goto out;
Quoted 8 lines
Quoted 2 lines

+        }
+    }

Do the other backend types also write this node? It looks like Linux does, at least in some circumstances (tap and vbd AFAICT), in which case perhaps this is suitable as the only test here (i.e. drop the #ifdef and the #else case). That would remove a lot of the conditional code in this patch.

If Linux also uses this, I will have to modify the Linux block script, so that it sets hotplug-status to "disconnected" also. This will be nice, I don't like code with #ifdefs as it tends to get messy and it's not easy to understand.

Regards, Roger.

#3 lore raw
Quoted 17 lines · Roger Pau Monné

2011/9/15 Ian Campbell <[email protected]>:

Quoted 10 lines · Roger Pau Monne
Quoted 8 lines

# HG changeset patch
# User Roger Pau Monne <[email protected]>
# Date 1316091721 -7200
# Node ID 015617579cd36fc58318aaf350bec5f7cc07ef2f
# Parent 63e254468d6e8d81baeafaed68f05791dc21eb4e
libxl: add support for booting PV domains from NetBSD using raw files as disks. Fixed the shutdown race problem by checking "hotplug-status" instead of "state" xenstore variable in NetBSD.

Quoted 5 lines

This was one long line which mercurial will use as a summary, it's a good idea to make sure that the first line stands somewhat alone as a summary so the e.g. "hg log" is useful.
Also this sounds on the face of it like two bugfixes, if that's the case they should be submitted separately.

Quoted 5 lines

Well, it's not a bugfix, because NetBSD was not supported by libxl, so I think it's just part of the patch to add support for NetBSD to libxl. I will split the line, and the patch if it's necessary, but one doesn't make sense without the other, and I don't really know what would be in each patch.

I guess I saw "add support" and "fix race" and assumed they were separate (albeit related) changes.

Ian.