qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] qcow2 not cleaning up during image create failure
Date: Fri, 14 Jul 2017 13:07:53 +0100	[thread overview]
Message-ID: <20170714120753.GF28095@redhat.com> (raw)
In-Reply-To: <20170714115742.GG18687@lemon>

On Fri, Jul 14, 2017 at 07:57:43PM +0800, Fam Zheng wrote:
> On Fri, 07/14 12:00, Daniel P. Berrange wrote:
> > I've just been looking at the qcow2 image creation code, and found that
> > if any method in qcow2_create2() returns an error, then we'll report that,
> > but leave the newly created image file on disk in some partially initialized
> > state. A user may unwittingly use this file later with undefined behaviour.
> > This is particularly bad if we fail to setup encryption, because the user
> > is left with a file with no encryption enabled.
> > 
> > So I'm wondering how is the best way to clean up after failure ?
> > 
> > Naively I would like to just unlink(filename), but IIUC, filename is
> > not guaranteed to refer to a local file, and AFAIK, there is not
> > bdrv_delete() method todo this portably.
> > 
> > If we can't delete a file (because its a block device or network
> > volume), then we must at least blank out the just-written qcow2
> > header with zeros.
> > 
> > Ideas / suggestions.
> 
> Or just write the header as the last step?

qcow2 has a multi-step creation process - it writes a minimal header,
then opens the file and writes some more metadata.  So delaying write
of the header is impractical with that approach.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

      parent reply	other threads:[~2017-07-14 12:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-14 11:00 [Qemu-devel] qcow2 not cleaning up during image create failure Daniel P. Berrange
2017-07-14 11:57 ` Fam Zheng
2017-07-14 12:07   ` Eric Blake
2017-07-14 12:07   ` Daniel P. Berrange [this message]

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=20170714120753.GF28095@redhat.com \
    --to=berrange@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).