From 2ea9a70efe91c90c9ad0bec8b7f720bdc544c6fc Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Mon, 26 Mar 2012 20:29:49 +0200 Subject: [PATCH] dom0+vm: qvm-block --attach-file Allow to attach disk image from different VM as block device. File attached with qvm-block -A will be visible as loopX device and as such can be detached. File path will be in device description. --- misc/block_add_change | 10 ++++++++++ misc/qubes_block.rules | 3 --- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/misc/block_add_change b/misc/block_add_change index 3d675aa..e1b25ca 100755 --- a/misc/block_add_change +++ b/misc/block_add_change @@ -16,6 +16,11 @@ if [ -n "`ls -A /sys/$DEVPATH/holders 2> /dev/null`" ]; then xenstore-rm "$XS_KEY" exit 0 fi +# ... and "empty" loop devices +if [ "$MAJOR" -eq 7 -a ! -d /sys/$DEVPATH/loop ]; then + xenstore-rm "$XS_KEY" + exit 0 +fi # Special case for CD if [ "$ID_TYPE" = "cd" ]; then @@ -26,6 +31,11 @@ if [ "$ID_TYPE" = "cd" ]; then fi MODE=r fi + +# Special description for loop devices +if [ -d /sys/$DEVPATH/loop ]; then + DESC=$(cat /sys/$DEVPATH/loop/backing_file) +fi xenstore-write "$XS_KEY/desc" "$DESC" "$XS_KEY/size" "$SIZE" "$XS_KEY/mode" "$MODE" # Make sure that block backend is loaded diff --git a/misc/qubes_block.rules b/misc/qubes_block.rules index 1a0864e..343553f 100644 --- a/misc/qubes_block.rules +++ b/misc/qubes_block.rules @@ -6,9 +6,6 @@ SUBSYSTEM!="block", GOTO="qubes_block_end" # Skip xen-blkfront devices ENV{MAJOR}=="202", GOTO="qubes_block_end" -# Skip loop devices -ENV{MAJOR}=="7", GOTO="qubes_block_end" - # Skip device-mapper devices ENV{MAJOR}=="253", GOTO="qubes_block_end"