libguestfs and md devices
We've recently discovered that libguestfs can't handle guests which use md. There are (at least) 2 reasons for this: Firstly, the appliance doesn't include mdadm. Without this, md devices aren't detected during the boot process. Simply adding mdadm to the appliance package list fixes this. Secondly, md devices referenced in fstab as, e.g. /dev/md0, aren't handled correctly by inspection. This looks a bit more complicated. In my test guest, the guestfs appliance automatically creates the 2 md devices as: * /dev/md/localhost:localdomain:0 * /dev/md/localhost:localdomain:1 These are symlinks to ../md126 and ../md127 respectively. I haven't yet worked out why they aren't created as md0 and md1 as in the guest. I think here we need to either work out how to make the appliance detect and use their names (if this is even possible), or to map the names appropriately using information from /dev/md/md-device-map in the appliance's root, and /etc/mdadm.conf in the guest's root. I don't currently think we'll need any new apis for this. I'm not convinced we need apis for creating and managing md devices, for example. We could do with a test for inspection of a guest which uses md devices, which would obviously require creating that guest. However, we can frig that for the test using debug sh "mdadm ...". Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On Mon, Oct 31, 2011 at 02:45:23PM +0000, Matthew Booth wrote:
We've recently discovered that libguestfs can't handle guests which use md. There are (at least) 2 reasons for this: Firstly, the appliance doesn't include mdadm. Without this, md devices aren't detected during the boot process. Simply adding mdadm to the appliance package list fixes this.
I've added the mdadm package since it sounds useful to have: http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=6f84ef6768e9c625d67f...
Secondly, md devices referenced in fstab as, e.g. /dev/md0, aren't handled correctly by inspection. This looks a bit more complicated. In my test guest, the guestfs appliance automatically creates the 2 md devices as:
* /dev/md/localhost:localdomain:0 * /dev/md/localhost:localdomain:1
That's a very strange name. udev going crazy?
These are symlinks to ../md126 and ../md127 respectively. I haven't yet worked out why they aren't created as md0 and md1 as in the guest. I think here we need to either work out how to make the appliance detect and use their names (if this is even possible), or to map the names appropriately using information from /dev/md/md-device-map in the appliance's root, and /etc/mdadm.conf in the guest's root.
I don't currently think we'll need any new apis for this. I'm not convinced we need apis for creating and managing md devices, for example. We could do with a test for inspection of a guest which uses md devices, which would obviously require creating that guest. However, we can frig that for the test using debug sh "mdadm ...".
New APIs are cheap ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Here's a way to do some tests (assuming libguestfs from git which has the mdadm package): $ rm /tmp/test1.img /tmp/test2.img $ truncate -s 1G /tmp/test1.img /tmp/test2.img $ ./run ./rescue/virt-rescue -a /tmp/test1.img -a /tmp/test2.img [At this point you have to switch to another terminal and kill the rogue 'sed' and/or 'grep' processes launched by libtool -- https://bugzilla.redhat.com/show_bug.cgi?id=729052]
<rescue> mdadm --create /dev/md0 -l1 -n2 /dev/vda /dev/vdb <rescue> blockdev --getsize64 /dev/md0 1073729536 <rescue> cat /proc/mdstat Personalities : [raid1] md0 : active raid1 vdb[1] vda[0] 1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
<rescue> mkfs -t ext3 /dev/md0 <rescue> mount /dev/md0 /sysroot <rescue> touch /sysroot/hello-world <rescue> exit
<fs> run <fs> vfs-type /dev/vda
Oddly this allocates all the space on the second disk, but not the first: $ du -sh /tmp/test1.img /tmp/test2.img 33M /tmp/test1.img 1.0G /tmp/test2.img Then try it in guestfish (add the -v option for more detail): $ ./run ./fish/guestfish -a /tmp/test1.img -a /tmp/test2.img linux_raid_member Like you, I don't see any /dev/md0 device (but also I don't see any weird names either). Does md need a daemon of some sort? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
On Mon, Oct 31, 2011 at 04:45:43PM +0000, Richard W.M. Jones wrote:
On Mon, Oct 31, 2011 at 02:45:23PM +0000, Matthew Booth wrote:
* /dev/md/localhost:localdomain:0 * /dev/md/localhost:localdomain:1
That's a very strange name. udev going crazy?
Apparently not a bug ... https://bugzilla.redhat.com/show_bug.cgi?id=606481#c1 It appears the name can be stored in one of two places, either in /etc/mdadm.conf or in metadata stored in the disk superblock. Go Linux! Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
participants (2)
-
Matthew Booth -
Richard W.M. Jones