Image Corruption Possible with qemu and qemu-kvm
i thought it might be good to post this on qemu-devel as well, as i see this as a general qemu / kvm / xen /whatevercomesnext issue .
are there any plans to implement a default in qemu to prevent accessing the same image multiple times ?
i know that in xen they deal with this problem somehow xen specific. wouldn't it be good to prevent multiple access to the same image by default and add a switch to overwrite it ?
i am sure other people had the same issue as i had (corrupting images) and would be great to prevent people in the future messing around with data loss :-)
Sven
Sven Oehme/Germany/IBM@IBMDE
Sent by: [email protected] 08/27/2007 09:38 PM
Please respond to
Fedora/Linux Management Tools <[email protected]>
To
Fedora/Linux Management Tools <[email protected]> cc
Subject
[et-mgmt-tools] Image Corruption Possible with qemu and qemu-kvm
Hi,
i corrupted a couple of virtual Linux images last week as i accidentally started them two times ..
i opened a bug against qemu (not sure if this was a good idea) -->
https://bugzilla.redhat.com/show_bug.cgi?id=253533
are there any plans to ensure that this can't happen in future releases of virt-manager with lock files in the image directory or similar ?
thanks. Sven
_______________________________________________
et-mgmt-tools mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/et-mgmt-tools
Quoted 5 lines · Sven Oehme
i thought it might be good to post this on qemu-devel as well, as i see this as a general qemu / kvm / xen /whatevercomesnext issue .
are there any plans to implement a default in qemu to prevent accessing the same image multiple times ?
Each QEMU instance is unware of each other so can't directly check this. One possiblity would be for QEMU to use fcntl() to take a lock on a disk image when opening it. With raw disk images at least, it is, however, safe to let multiple QEMU instances use it at once *provided* you have a clustered filesystem installed, rather than regular FAT or ext2/3, so one wouldn't want to exclude this use case.
Quoted 3 lines
i know that in xen they deal with this problem somehow xen specific. wouldn't it be good to prevent multiple access to the same image by default and add a switch to overwrite it ?
In the scenario you mention, libvirt should probably do a sanity check for this before letting you start the guest. libvirt already supports the idea of 'shared' disk images where two or more guests can be optionally configured to have write access - basically assumes the admin requesting sharing knows what they're doing.
Quoted 7 lines
i corrupted a couple of virtual Linux images last week as i accidentally started them two times ..
i opened a bug against qemu (not sure if this was a good idea) -->
https://bugzilla.redhat.com/show_bug.cgi?id=253533are there any plans to ensure that this can't happen in future releases of virt-manager with lock files in the image directory or similar ?
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Quoted 7 lines · Daniel P. Berrange
Quoted 4 lines · Sven Oehme
i thought it might be good to post this on qemu-devel as well, as i see this as a general qemu / kvm / xen /whatevercomesnext issue .
are there any plans to implement a default in qemu to prevent accessing the same image multiple times ?
Quoted 7 lines
Each QEMU instance is unware of each other so can't directly check this. One possiblity would be for QEMU to use
fcntl()to take a lock on a disk image when opening it. With raw disk images at least, it is, however, safe to let multiple QEMU instances use it at once *provided* you have a clustered filesystem installed, rather than regular FAT or ext2/3, so one wouldn't want to exclude this use case.
Yes, taking an advisory lock is a good idea, provided there is an option to override it.
I've killed a few images myself...
Signature · 1 line
Any sufficiently difficult bug is indistinguishable from a feature.
Quoted 18 lines · Daniel P. Berrange
Quoted 5 lines · Sven Oehme
i thought it might be good to post this on qemu-devel as well, as i see this as a general qemu / kvm / xen /whatevercomesnext issue .
are there any plans to implement a default in qemu to prevent accessing the same image multiple times ?
Each QEMU instance is unware of each other so can't directly check this. One possiblity would be for QEMU to use
fcntl()to take a lock on a disk image when opening it. With raw disk images at least, it is, however, safe to let multiple QEMU instances use it at once *provided* you have a clustered filesystem installed, rather than regular FAT or ext2/3, so one wouldn't want to exclude this use case.Quoted 3 lines
i know that in xen they deal with this problem somehow xen specific. wouldn't it be good to prevent multiple access to the same image by default and add a switch to overwrite it ?
Quoted 5 lines
In the scenario you mention, libvirt should probably do a sanity check for this before letting you start the guest. libvirt already supports the idea of 'shared' disk images where two or more guests can be optionally configured to have write access - basically assumes the admin requesting sharing knows what they're doing.
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you have a clustered filesystem in the host. I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
Regards,
Anthony Liguori
Quoted 9 lines
Quoted 7 lines
i corrupted a couple of virtual Linux images last week as i accidentally started them two times ..
i opened a bug against qemu (not sure if this was a good idea) -->
https://bugzilla.redhat.com/show_bug.cgi?id=253533are there any plans to ensure that this can't happen in future releases of virt-manager with lock files in the image directory or similar ?
Dan.
Quoted 13 lines · Anthony Liguori
Quoted 10 lines · Daniel P. Berrange
Quoted 3 lines · Sven Oehme
i know that in xen they deal with this problem somehow xen specific. wouldn't it be good to prevent multiple access to the same image by default and add a switch to overwrite it ?
In the scenario you mention, libvirt should probably do a sanity check for this before letting you start the guest. libvirt already supports the idea of 'shared' disk images where two or more guests can be optionally configured to have write access - basically assumes the admin requesting sharing knows what they're doing.
Quoted 5 lines
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you have a clustered filesystem in the host. I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
Well initially I was really of the position that checking had to be
done at the hypervisor level, but as this thread pointed out we can't always do this (there is also the potential of conflict between different hypervisor though that sounds more theorical than practical).
Daniel
Signature · 4 lines
Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [email protected] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Quoted 6 lines · Anthony Liguori
Quoted 5 lines
In the scenario you mention, libvirt should probably do a sanity check for
this before letting you start the guest. libvirt already supports the idea
of 'shared' disk images where two or more guests can be optionally configured to have write access - basically assumes the admin requesting sharing knows what they're doing.
Quoted 6 lines
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you have a clustered filesystem in the host. I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
There's still the unmanaged use case to worry about. I think qemu can default to advisory locking, and management tools can do their own locking and always override qemu.
It's too easy to kill an image by starting up another instance right now.
Signature · 1 line
Any sufficiently difficult bug is indistinguishable from a feature.
[email protected] wrote on 08/28/2007 04:13:02 AM:
Quoted 2 lines
Quoted 1 line · Anthony Liguori
Quoted 1 line
In the scenario you mention, libvirt should probably do a sanity
check for
Quoted 1 line
Quoted 1 line
Quoted 1 line
this before letting you start the guest. libvirt already supports the
idea
Quoted 3 lines
Quoted 1 line
Quoted 1 line
of 'shared' disk images where two or more guests can be
optionally configured
Quoted 1 line
Quoted 1 line
to have write access - basically assumes the admin requesting sharing
knows
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
what they're doing.
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you
have
Quoted 1 line
Quoted 1 line
a clustered filesystem in the host. I think it would do more harm
than
Quoted 9 lines
Quoted 3 lines
good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
There's still the unmanaged use case to worry about. I think qemu can default to advisory locking, and management tools can do their own locking and always override qemu.
It's too easy to kill an image by starting up another instance right
now.
Quoted 1 line
i agree default should be advisory locking and a switch to disable it .. would that be hard to implement ?
thanks. Sven
Quoted 5 lines · Anthony Liguori
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you have a clustered filesystem in the host. I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
^^^^^^^^^^^^^^^^^^^^^^
Are you trying to say that any kind of significant portion of QEMU users have clustered file-systems?
I think that's unlikely, and it'd be nice if QEMU by default did a fcntl() on writeable image files to lock itself from multiple access, that'd benefit the vast majority of users.
Let the 0.x% of users who need to run with weird/esoteric fses cope..
regards,
Signature · 4 lines
Paul Jakma [email protected] [email protected] Key ID: 64A2FF6A Fortune: Fashions have done more harm than revolutions. -- Victor Hugo
Quoted 12 lines · Paul Jakma
Quoted 5 lines · Anthony Liguori
I think this is the right level myself. Advisory locks work okay but not all filesystems support them. It's particularly nasty when you have a clustered filesystem in the host. I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
^^^^^^^^^^^^^^^^^^^^^^Are you trying to say that any kind of significant portion of QEMU users have clustered file-systems?
Quoted 7 lines
I think that's unlikely, and it'd be nice if QEMU by default did a
fcntl()on writeable image files to lock itself from multiple access, that'd benefit the vast majority of users.Let the 0.x% of users who need to run with weird/esoteric fses cope..
regards,
I'm usually running one "main" qemu instance that has read/write access to the disk file and several others for tests that use the -snapshot option, so I think it's very important to have an easy means of switching this check off.
just my 2 cents,
Alexander Graf
Quoted 4 lines · Alexander Graf
Quoted 2 lines · Paul Jakma
I think that's unlikely, and it'd be nice if QEMU by default did a
fcntl()on writeable image files to lock itself from multiple access,
^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 3 lines
I'm usually running one "main" qemu instance that has read/write access to the disk file and several others for tests that use the -snapshot option, so I think it's very important to have an easy
means of switching this check off.
Of course. Though, I said 'writeable' - so you might not need to use such an option.. ;)
regards,
Signature · 3 lines
Paul Jakma [email protected] [email protected] Key ID: 64A2FF6A Fortune: This report is filled with omissions.
Hi all,
Quoted 11 lines · Alexander Graf
Quoted 8 lines · Paul Jakma
Quoted 1 line · Anthony Liguori
I think this is the right level myself. Advisory locks work okay but not all filesystems support them... I think it would do more harm than good to have a feature like that was supposed to provide a safe-guard but then frequently didn't work.
^^^^^^^^^^^^^^^^^^^^^^Are you trying to say that any kind of significant portion of QEMU users have clustered file-systems?
I think that's unlikely, and it'd be nice if QEMU by default did a
fcntl()on writeable image files to lock itself from multiple access, that'd benefit the vast majority of users.I'm usually running one "main" qemu instance that has read/write access to the disk file and several others for tests that use the -snapshot option, so I think it's very important to have an easy means of switching this check off.
Would it make sense to take a read lock (preventing concurrent writes) on read-only snapshot images, and a write lock on all writable files? That should allow one to run as many instances as you want off a single snapshot in snapshot mode, but still prevent one from (accidentally) running a non-snapshot QEMU on the same image, or from (accidentally) running two instances writing to the same COW file.
By removing the need to add the lock-override command line switch to qemu in this case, it would reduce the risk of accidental image corruption by accidentally overriding the lock.
Cheers, Chris.
Signature · 4 lines
_____ __ _ \ __/ / ,__(_)_ | Chris Wilson <0000 at qwirx.com> - Cambs UK | / (_/ ,\/ _/ /_ \ | Security/C/C++/Java/Perl/SQL/HTML Developer | \ _/_/_/_//_/___/ | We are GNU-free your mind-and your software |