public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: KVM list <kvm@vger.kernel.org>
Subject: opening files in exclusive mode?
Date: Sat, 24 Jan 2009 18:03:05 +0300	[thread overview]
Message-ID: <497B2DA9.5070508@msgid.tls.msk.ru> (raw)

KVM (or qemu for that matter) does not care about
concurrent access to disk images it opens.  So it's
possible to mount the same guest block device on
more than one guest, resulting in a badly broken
filesystem.

I wonder if the  right way is to open all the
devices in exclusive mode (O_EXCL).  At least
for real block devices.  On linux this ensures
there's no other holders of that device, open()
errors out with -EBUSY if it's not the case.

With an option to stop adding such a flag, in
order to be able to use some cluster-aware
filesystem or read-only device.

Dunno how it applies to files (qcow etc), but
it *seems* here the situation is even worse,
because not only the filesystem (meta)data
might be damaged, but qcow structure too,
and there's no fsck.qcow program available
to repair it.

So I think kvm should ensure exclusive access
to the files it opens (except of cd-rom images
and the like), using either O_EXCL for block
devices or locking for qcow/raw files, and
have an option to stop that (e.g. exclusive=0).

Comments?

Thanks!

/mjt

             reply	other threads:[~2009-01-24 15:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-24 15:03 Michael Tokarev [this message]
2009-01-24 16:24 ` opening files in exclusive mode? Brian Jackson
2009-01-24 16:39   ` Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=497B2DA9.5070508@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox