Domain cannot be booted up after imported from an existed disk image


After building a guest around an existed disk image, the guest booting stalls with "No boot device". (One can start the guest successfully using qemu command directly).


Let's look into the command to import the the existed disk image first:

% virt-install --connect qemu:///system --ram 1024 -n rhel_64 -r 2048 --os-type=linux --os-variant=rhel5 --disk path=/root/RHEL-Server-5.8-64-virtio.qcow2,device=disk,format=qcow2 --vcpus=2 --vnc --noautoconsole --import

NB, the "bus" type for disk is not specified.

Then the command line which is used to boot up the guest using qemu directly:

% ps -ef | grep qemu /usr/libexec/qemu-kvm -monitor stdio -drive file=/root/RHEL-Server-5.8-32-virtio.qcow2,index=0,if=virtio,media=disk,cache=none,format=qcow2 -net nic,vlan=0,model=rtl8139,macaddr=00:30:91:aa:04:74 -net tap,vlan=0,script=/etc/qemu-ifup,downscript=no -m 2048 -smp 2,cores=1,threads=1,sockets=2 -cpu qemu64,+sse2 -soundhw ac97 -rtc-td-hack -M rhel5.6.0 -usbdevice tablet -vnc :10 -boot c -no-kvm-pit-reinjection

NB, it uses "virtio" bus type.

Then the domain XML generated by libvirt for the imported guest:

<domain type='qemu'>
   <type arch='x86_64' machine='rhel5.4.0'>hvm</type>
   <boot dev='hd'/>
 <clock offset='utc'>
   <timer name='pit' tickpolicy='delay'/>
   <disk type='file' device='disk'>
     <driver name='qemu' type='qcow2' cache='none'/>
     <source file='/root/RHEL-Server-5.8-64-virtio.qcow2'/>
     <target dev='hda' bus='ide'/>
     <address type='drive' controller='0' bus='0' unit='0'/>
   <controller type='ide' index='0'/>
   <interface type='bridge'>
     <mac address='54:52:00:08:3e:8c'/>
     <source bridge='br0'/>
   <serial type='pty'>
     <target port='0'/>
   <console type='pty'>
     <target port='0'/>
   <input type='mouse' bus='ps2'/>
   <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
     <model type='cirrus' vram='9216' heads='1'/>

NB, the bus type for the disk is "ide", which is the default value set by libvirt. And now we could have a conclusion, the cause for the imported guest can't be boot up successfully is the wrong "bus" type.


  1. undefine the imported guest, and re-import is with "bus=virtio". e.g.

% virsh destroy rhel_64
% virsh undefine rhel_64
% virt-install --connect qemu:///system --ram 1024 -n rhel_64 -r 2048 --os-type=linux --os-variant=rhel5  --disk path=/root/RHEL-Server-5.8-64-virtio.qcow2,device=disk,bus=virtio,format=qcow2 --vcpus=2 --vnc --noautoconsole --import

2. edit the imported domain XML using "virsh edit", correct the disk bus type.