fixed nbd device
authorAndrew Tridgell <tridge@samba.org>
Wed, 16 Jul 2008 04:15:13 +0000 (14:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 16 Jul 2008 04:15:13 +0000 (14:15 +1000)
config.default
functions

index 795615506c5f3c48115e2541005f0e95960eea28..05c0c167745cf34c8b3c9d9ae357b070b790c62e 100644 (file)
@@ -173,3 +173,7 @@ BOOT_TEMPLATE="$installdir/templates/bootbase.xml"
 
 # where to get the base templates from
 BASE_TEMPLATES="$installdir/base"
+
+# nbd device to use
+NBD_DEVICE="/dev/nbd0"
+
index c26e52331a51e2564bf88b52f10dc252217c86aa..07b0f9c5f0d92f3ef97281c0cfb6672254aa4a3e 100644 (file)
--- a/functions
+++ b/functions
@@ -20,21 +20,22 @@ connect_nbd() {
     echo "Connecting nbd to $1"
     mkdir -p mnt
     modprobe nbd
+    killall -9 -q qemu-nbd || true
     qemu-nbd -p 1300 $1 &
-    [ -r /dev/nb0 ] || {
-       mknod /dev/nb0 b 43 0
+    [ -r $NBD_DEVICE ] || {
+       mknod $NBD_DEVICE b 43 0
     }
     umount mnt 2> /dev/null || true
-    nbd-client -d /dev/nb0 > /dev/null 2>&1 || true
+    nbd-client -d $NBD_DEVICE > /dev/null 2>&1 || true
     killall -9 -q nbd-client || true
-    nbd-client localhost 1300 /dev/nb0 > /dev/null 2>&1 || true &
+    nbd-client localhost 1300 $NBD_DEVICE > /dev/null 2>&1 || true &
 }
 
 # disconnect nbd
 disconnect_nbd() {
     echo "Disconnecting nbd"
     sync; sync
-    nbd-client -d /dev/nb0 > /dev/null 2>&1 || true
+    nbd-client -d $NBD_DEVICE > /dev/null 2>&1 || true
     killall -9 -q nbd-client || true
     killall -q qemu-nbd || true
 }
@@ -45,7 +46,7 @@ mount_disk() {
     echo "Mounting disk $1"
     mount_ok=0
     for i in `seq 1 5`; do
-       mount -o offset=32256 /dev/nb0 mnt && {
+       mount -o offset=32256 $NBD_DEVICE mnt && {
            mount_ok=1
            break
        }
@@ -67,7 +68,7 @@ mount_disk() {
 unmount_disk() {
     echo "Unmounting disk"
     sync; sync;
-    umount mnt || umount mnt
+    umount mnt || umount mnt || true
     disconnect_nbd
 }