Testing multipath with qemu

Alternatives{width=”640” height=”361”}

Ever wondered if it was possible to test multipathing with qemu? it turns out it is.

Basic idea: Create two devices which point to the same backing image. Important: Let qemu know that it is the same disk, by using the same serial for both.

$ qemu \
    -drive file=hda.qcow2,media=disk,bus=0,unit=0,if=ide,cache=none,serial=abcde \
    -drive file=hda.qcow2,media=disk,bus=1,unit=1,if=ide,cache=none,serial=abcde \
    -cdrom boot.iso

And in your guest:

# multipath -ll
QEMU_HARDDISK_abcde dm-0 ATA     ,QEMU HARDDISK   
size=30G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 0:0:0:0 sda 8:0  active ready running
`-+- policy='service-time 0' prio=1 status=enabled
  `- 1:0:1:0 sdb 8:16 active ready running

Nifty?

It will probably be re-used in some test automation context.

::: {#footer} [ September 30th, 2014 1:13pm ]{#timestamp} [testing]{.tag} [automation]{.tag} [qemu]{.tag} [fedora]{.tag} [test]{.tag} :::