Skip to contentSkip to conversation

libxl, hotplug/Linux: default to phy backend for raw format file

PATCH In review Wei Liu 3 participants 4 messages Sep 5, 2013 – Sep 13, 2013

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl, hotplug/Linux: default to phy backend for raw format file

Modify libxl to allow raw format file to use phy backend.

For the hotplug script part, learn from NetBSD's block hotplug script -- test the path and determine the actual type of file (block device or regular file) then use the actual type to determine which branch to run.

With these changes, plus the current ordering of backend preference (phy > qdisk > tap), we will use phy backend for raw format file by default.

Cc Ian Jackson <[email protected]>
Cc Roger Pau Monné <[email protected]>
Cc Stefano Stabellini <[email protected]>
---
 tools/hotplug/Linux/block |   16 +++++++++-------
 tools/libxl/libxl_linux.c |    6 +++---
 2 files changed, 12 insertions(+), 10 deletions(-)
tools/hotplug/Linux/block +9 -7
index da26e22..8d2ee9d 100644
@@ -206,6 +206,13 @@ and so cannot be mounted ${m2}${when}."
 
 
 t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
+p=$(xenstore_read "$XENBUS_PATH/params")
+mode=$(xenstore_read "$XENBUS_PATH/mode")
+if [ -b "$p" ]; then
+    truetype="phy"
+elif [ -f "$p" ]; then
+    truetype="file"
+fi
 
 case "$command" in
   add)
@@ -217,16 +224,11 @@ case "$command" in
       exit 0
     fi
 
-    if [ -n "$t" ]
-    then
-      p=$(xenstore_read "$XENBUS_PATH/params")
-      mode=$(xenstore_read "$XENBUS_PATH/mode")
-    fi
     FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
     FRONTEND_UUID=$(xenstore_read_default \
             "/local/domain/$FRONTEND_ID/vm" 'unknown')
 
-    case $t in 
+    case $truetype in
       phy)
         dev=$(expand_dev $p)
 
@@ -319,7 +321,7 @@ mount it read-write in a guest domain."
     ;;
 
   remove)
-    case $t in 
+    case $truetype in
       phy)
 	exit 0
 	;;
tools/libxl/libxl_linux.c +3 -3
index 37815eb..3cfa6da 100644
@@ -19,11 +19,11 @@
  
 int libxl__try_phy_backend(mode_t st_mode)
 {
-    if (!S_ISBLK(st_mode)) {
-        return 0;
+    if (S_ISBLK(st_mode) || S_ISREG(st_mode)) {
+        return 1;
     }
 
-    return 1;
+    return 0;
 }
 
 #define EXT_SHIFT 28
Signature · 7 lines
1.7.10.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#1 lore raw

Ping?

Quoted 85 lines · Wei Liu

Modify libxl to allow raw format file to use phy backend.

For the hotplug script part, learn from NetBSD's block hotplug script -- test the path and determine the actual type of file (block device or regular file) then use the actual type to determine which branch to run.

With these changes, plus the current ordering of backend preference (phy > qdisk > tap), we will use phy backend for raw format file by default.

Cc Ian Jackson <[email protected]>
Cc Roger Pau Monné <[email protected]>
Cc Stefano Stabellini <[email protected]>
---
 tools/hotplug/Linux/block |   16 +++++++++-------
 tools/libxl/libxl_linux.c |    6 +++---
 2 files changed, 12 insertions(+), 10 deletions(-)
tools/hotplug/Linux/block +9 -7
index da26e22..8d2ee9d 100644
@@ -206,6 +206,13 @@ and so cannot be mounted ${m2}${when}."
 
 
 t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
+p=$(xenstore_read "$XENBUS_PATH/params")
+mode=$(xenstore_read "$XENBUS_PATH/mode")
+if [ -b "$p" ]; then
+    truetype="phy"
+elif [ -f "$p" ]; then
+    truetype="file"
+fi
 
 case "$command" in
   add)
@@ -217,16 +224,11 @@ case "$command" in
       exit 0
     fi
 
-    if [ -n "$t" ]
-    then
-      p=$(xenstore_read "$XENBUS_PATH/params")
-      mode=$(xenstore_read "$XENBUS_PATH/mode")
-    fi
     FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
     FRONTEND_UUID=$(xenstore_read_default \
             "/local/domain/$FRONTEND_ID/vm" 'unknown')
 
-    case $t in 
+    case $truetype in
       phy)
         dev=$(expand_dev $p)
 
@@ -319,7 +321,7 @@ mount it read-write in a guest domain."
     ;;
 
   remove)
-    case $t in 
+    case $truetype in
       phy)
 	exit 0
 	;;
tools/libxl/libxl_linux.c +3 -3
index 37815eb..3cfa6da 100644
@@ -19,11 +19,11 @@
 
 int libxl__try_phy_backend(mode_t st_mode)
 {
-    if (!S_ISBLK(st_mode)) {
-        return 0;
+    if (S_ISBLK(st_mode) || S_ISREG(st_mode)) {
+        return 1;
     }
 
-    return 1;
+    return 0;
 }
 
 #define EXT_SHIFT 28
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#2 lore raw
In reply to Wei Liu
Quoted 11 lines · Wei Liu

Modify libxl to allow raw format file to use phy backend.

For the hotplug script part, learn from NetBSD's block hotplug script -- test the path and determine the actual type of file (block device or regular file) then use the actual type to determine which branch to run.

With these changes, plus the current ordering of backend preference (phy > qdisk > tap), we will use phy backend for raw format file by default.

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