Hi Eric:
Thank you for your suggestions. Here is what happened when I tried the
snapshot. I will try the dd a bit later.
VERSIONS
virsh: 0.9.10
qemu: 2.0.12
DOM: webdev
$ ls -l /proc/13196/fd/9
lrwx------. 1 qemu qemu 64 Nov 5 11:57 /proc/13196/fd/9 ->
/tools/vm/images/webdev.img (deleted)
$ cp /proc/13196/fd/9 /tools/vm/images/webdev.img
cp: cannot stat `/proc/13196/fd/9': Stale NFS file handle
$ virsh snapshot-create-as webdev \
--no-metadata \
--disk-only \
--diskspec
/tools/vm/images/webdev.img,file=/tools/vm/images/webdev.img1
error: unsupported configuration: no disk named
'/tools/vm/images/webdev.img'
I think that I must have some sort of typo but I am not familiar enough
with snapshots to see it.
-----Original Message-----
From: Eric Blake [mailto:eblake@redhat.com]
Sent: Monday, November 05, 2012 12:37 PM
To: Joe Linoff
Cc: Henrik Ahlgren; libvirt-users(a)redhat.com
Subject: Re: [libvirt-users] re-create disk image file
On 11/05/2012 01:25 PM, Joe Linoff wrote:
Hi Henrik:
When I tried to copy the file descriptor file a "Stale NFS file
handle"
error was generated:
$ cp -f /proc/13196/fd/9 /tmp/guest.img
cp: cannot stat `/proc/13196/fd/9': Stale NFS file handle
I suppose that makes sense because the file was accidently deleted but
from the NFS server perspective it really isn't there. Do you
know of
any way to work around it?
> Or why not just attach a new disk to the guest and copy stuff inside
the guest?
I understand how that would work to recover individual
files/directories but I don't understand how I would be able to
recover the
entire image.
Can you explain?
Wouldn't something like:
dd /dev/vda /dev/vdb
from within the guest do the trick of copying the entire image? But
that's risky if the guest is actively modifying /dev/vda at the same
time.
What version of libvirt and qemu are you using? If at least 0.9.6 and
1.2 respectively, I think it should be possible to use 'virsh blockpull'
to resolve your conundrum, as follows:
# Create a new qcow2 file that wraps the deleted but still-open file
virsh snapshot-create-as $dom --no-metadata --disk-only \
--diskspec /tmp/guest.img,file=/tmp/guest.img1
# Pull the contents into the new file
virsh blockpull $dom /tmp/guest.img1 --wait --verbose
at which point, the new file /tmp/guest.img1 should contain everything
in use by the old deleted file, while no longer needing to keep the old
file around, so it will finally be safe to stop your guest.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org