Skip to contentSkip to conversation

hotplug: allow hardlinked files for block device images

PATCH In review Olaf Hering 5 participants 8 messages Nov 26, 2010 – Jan 17, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hotplug: allow hardlinked files for block device images

tools/hotplug/Linux/block change for this losetup -a output:
(inode 12 is listed twice due to hardlinks)

/dev/loop0: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop1: [0809]:139266 (/abuild/vdisk-sles11_1-disk1) /dev/loop3: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop5: [0809]:139273 (/abuild/vdisk-sles11_5-disk1) /dev/loop8: [0809]:12 (/abuild/bootiso-xenpaging-sles11_5.iso) /dev/loop10: [0809]:12 (/abuild/bootiso-xenpaging-sles11_4.iso) /dev/loop11: [0809]:139271 (/abuild/vdisk-sles11_4-disk0)

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

---
 tools/hotplug/Linux/block |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/hotplug/Linux/block +2 -2
@@ -279,8 +279,8 @@ mount it read-write in a guest domain."
             fatal "Unable to lookup $file: dev: $dev inode: $inode"
           fi
 
-          shared_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} |
-                cut -d : -f 1)
+          shared_list=$(losetup -a |
+                sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](${file})\)@\1@p" )
           for dev in "$shared_list"
           do
             if [ -n "$dev" ]
#1 lore raw

Ping?

Quoted 33 lines · Olaf Hering

tools/hotplug/Linux/block change for this losetup -a output:
(inode 12 is listed twice due to hardlinks)

/dev/loop0: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop1: [0809]:139266 (/abuild/vdisk-sles11_1-disk1) /dev/loop3: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop5: [0809]:139273 (/abuild/vdisk-sles11_5-disk1) /dev/loop8: [0809]:12 (/abuild/bootiso-xenpaging-sles11_5.iso) /dev/loop10: [0809]:12 (/abuild/bootiso-xenpaging-sles11_4.iso) /dev/loop11: [0809]:139271 (/abuild/vdisk-sles11_4-disk0)

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

---
 tools/hotplug/Linux/block |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/hotplug/Linux/block +2 -2
@@ -279,8 +279,8 @@ mount it read-write in a guest domain."
             fatal "Unable to lookup $file: dev: $dev inode: $inode"
           fi
 
-          shared_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} |
-                cut -d : -f 1)
+          shared_list=$(losetup -a |
+                sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](${file})\)@\1@p" )
           for dev in "$shared_list"
           do
             if [ -n "$dev" ]
#2 lore raw

Needs an Ack, or to be applied, by a tools maintainer.

-- Keir

Quoted 45 lines · Olaf Hering

Ping?

Quoted 33 lines · Olaf Hering

tools/hotplug/Linux/block change for this losetup -a output:
(inode 12 is listed twice due to hardlinks)

/dev/loop0: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop1: [0809]:139266 (/abuild/vdisk-sles11_1-disk1) /dev/loop3: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop5: [0809]:139273 (/abuild/vdisk-sles11_5-disk1) /dev/loop8: [0809]:12 (/abuild/bootiso-xenpaging-sles11_5.iso) /dev/loop10: [0809]:12 (/abuild/bootiso-xenpaging-sles11_4.iso) /dev/loop11: [0809]:139271 (/abuild/vdisk-sles11_4-disk0)

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

---
 tools/hotplug/Linux/block |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/hotplug/Linux/block +2 -2
@@ -279,8 +279,8 @@ mount it read-write in a guest domain."
             fatal "Unable to lookup $file: dev: $dev inode: $inode"
           fi
 
-          shared_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} |
-                cut -d : -f 1)
+          shared_list=$(losetup -a |
+                sed -n -e
 "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](${file})\)@\1@p" )
           for dev in "$shared_list"
           do
Quoted 1 line
             if [ -n "$dev" ]

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

Acked-by on v1 1/1
#3 lore raw
In reply to Olaf Hering
Quoted 11 lines · Olaf Hering

tools/hotplug/Linux/block change for this losetup -a output:
(inode 12 is listed twice due to hardlinks)

/dev/loop0: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop1: [0809]:139266 (/abuild/vdisk-sles11_1-disk1) /dev/loop3: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop5: [0809]:139273 (/abuild/vdisk-sles11_5-disk1) /dev/loop8: [0809]:12 (/abuild/bootiso-xenpaging-sles11_5.iso) /dev/loop10: [0809]:12 (/abuild/bootiso-xenpaging-sles11_4.iso) /dev/loop11: [0809]:139271 (/abuild/vdisk-sles11_4-disk0)

Quoted 5 lines

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

#4 lore raw
In reply to Olaf Hering
Quoted 23 lines · Olaf Hering

tools/hotplug/Linux/block change for this losetup -a output:
(inode 12 is listed twice due to hardlinks)

/dev/loop0: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop1: [0809]:139266 (/abuild/vdisk-sles11_1-disk1) /dev/loop3: [0809]:139267 (/abuild/vdisk-sles11_2-disk0) /dev/loop5: [0809]:139273 (/abuild/vdisk-sles11_5-disk1) /dev/loop8: [0809]:12 (/abuild/bootiso-xenpaging-sles11_5.iso) /dev/loop10: [0809]:12 (/abuild/bootiso-xenpaging-sles11_4.iso) /dev/loop11: [0809]:139271 (/abuild/vdisk-sles11_4-disk0)

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

---
  tools/hotplug/Linux/block |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

tools/hotplug/Linux/block mount it read-write in a guest domain." · line 283

Quoted 7 lines
tools/hotplug/Linux/block +2 -2
@@ -279,8 +279,8 @@ mount it read-write in a guest domain."
              fatal "Unable to lookup $file: dev: $dev inode: $inode"
            fi
 
-          shared_list=$(losetup -a | grep ' \[0*'${dev}'\]:'${inode} |
-                cut -d : -f 1)
+          shared_list=$(losetup -a |
+                sed -n -e "s@^\([^:]\+\)\(:[[:blank:]]\[${dev}\]:${inode}[[:blank:]](${file})\)@\1@p" )

Isn't this incorrect in case ${file} contains a character that is a regex escape (e.g. a star or backslash)?

Paolo

#5 lore raw
Quoted 2 lines · Paolo Bonzini

Isn't this incorrect in case ${file} contains a character that is a regex escape (e.g. a star or backslash)?

I'm sure there are pathnames which break the regex in some way. Adding an escape for '@' could be added, for example.

How well can the rest of Xen cope with odd filenames? In other words, does it even get there if the configured pathnames have odd chars in it?

Olaf

#6 lore raw
Quoted 5 lines · Olaf Hering

I'm sure there are pathnames which break the regex in some way. Adding an escape for '@' could be added, for example.

How well can the rest of Xen cope with odd filenames? In other words, does it even get there if the configured pathnames have odd chars in it?

@ is definitely not so odd...

Paolo

#7 lore raw

Re: [PATCH] hotplug: allow hardlinked files for block device images [and 1 more messages]

In reply to Olaf Hering

Olaf Hering writes ("[Xen-devel] [PATCH] hotplug: allow hardlinked files for block device images"):

Quoted 2 lines

Without this change, $dev would contain /dev/loop8\n/dev/loop10 Applies to 4.0 and 4.1

Thanks. I have applied this to xen-unstable.hg. I'm always a bit suspicious of hotplug script changes, so we'll wait with backporting it to see if it doesn't cause immediate trouble ...

Paolo Bonzini writes ("[Xen-devel] Re: [PATCH] hotplug: allow hardlinked files for block device images"):

Quoted 8 lines · Olaf Hering
Quoted 5 lines

I'm sure there are pathnames which break the regex in some way. Adding an escape for '@' could be added, for example.

How well can the rest of Xen cope with odd filenames? In other words, does it even get there if the configured pathnames have odd chars in it?

@ is definitely not so odd...

Yes, this is a good point. However, I think the patch as it stands is an improvement. Feel free to submit changes to make it more robust :-).

Thanks,
Ian.