I had take some inspiration from libvirt code to check results of qemu monitor command. - pass $conf to create_disks sub - add some checks on results of "drive_del","drive_add","device_del","device_add" - replace "sleep 2" by iterative sub vm_waitfordevicecleanup