How to convert a raw disk image to a copy-on-write image based on another image for use with kvm and
- by Jean-Paul Calderone
I have a virtual Windows machine running on kvm. Presently it has a 90GB raw disk image. I would like to clone this VM without having to keep two copies of the 90GB raw disk image around.
It seems like a good approach for doing this is to make two new qcow or qcow2 images based on the original. First I converted the raw image to a qcow2 image:
qemu-img convert -O qcow2 basewindowsxp.img basewindowsxp.qcow2
Then I tried creating a new image backed by this:
qemu-img create -F qcow2 -f qcow2 -b `pwd`/basewindowsxp.qcow2 windowsxp-1.qcow2
Then I used virt-manager to point the original VM at windowsxp-1.qcow2. However, when I try to start up the VM in this new configuration, virt-manager reports an error:
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/engine.py", line 588, in run_domain
vm.startup()
File "/usr/share/virt-manager/virtManager/domain.py", line 150, in startup
self._backend.create()
File "/usr/lib/python2.6/dist-packages/libvirt.py", line 300, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: internal error unable to start guest: qemu: could not open disk image /var/lib/libvirt/images/windowsxp-1.qcow2
The error suggests that the filename was misspecified or that the filesystem permissions are too restrictive, but neither of these is the case:
$ ls -l /var/lib/libvirt/images/windowsxp-1.qcow2
-rwxrwxrwx 1 root root 262144 2010-05-27 08:32 /var/lib/libvirt/images/windowsxp-1.qcow2
Why won't virt-manager start this vm?