[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt-users] re-create disk image file

Hi Eric:

Thank you for your suggestions. Here is what happened when I tried the
snapshot. I will try the dd a bit later.

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 \
error: unsupported configuration: no disk named

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 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
> 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

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 redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]