All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: jcody@redhat.com, qemu-devel <qemu-devel@nongnu.org>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] block-commit & dropping privs
Date: Tue, 7 Apr 2015 11:24:35 +0200	[thread overview]
Message-ID: <20150407092435.GE4635@noname.str.redhat.com> (raw)
In-Reply-To: <5522A857.5050405@msgid.tls.msk.ru>

Am 06.04.2015 um 17:37 hat Michael Tokarev geschrieben:
> 02.04.2015 16:19, Kevin Wolf wrote:
> > Am 02.04.2015 um 14:04 hat Michael Tokarev geschrieben:
> >> 02.04.2015 14:24, Kevin Wolf wrote:
> >> []
> >>>> But overall, I think qemu-system should not modify backing
> >>>> file name in this case.
> >>>
> >>> So you would leave the backing file with the data that you just
> >>> committed down one level in your backing file chain? Wouldn't that
> >>> defeat the whole purpose of committing?
> >>
> >> Um.  I don't think we understood each other.
> >>
> >> I experimented with the "non-live" HMP commit command.  This
> >> one effectively empties everything in the overlay file,
> >> propagating it to the backing file, but keeps the (now
> >> empty) overlay.  So from the stacking perspective nothing
> >> has changed.  Yet, together with with propagation, it also
> >> modifies the overlay file headers and writes a new name
> >> of the backing file -- the one it currently uses, which,
> >> in my case, is virtual /dev/fdset/foo.  It should keep
> >> the original file name in there, such as win.raw, unless
> >> explicitly asked to write a different name there.
> >>
> >> If the stack chain were to be modified by commit command,
> >> yes, the new name should be recorded ofcourse, such as
> >> after rebase.  But since stack chain is not modified,
> >> filename should not be modified either.
> > 
> > For the record, we discussed this on IRC:
> > 
> > Yes, we did talk past each other because HMP commit isn't supposed to
> > touch the backing file name at all, so I didn't expect such behaviour,
> > yet Michael saw it.
> > 
> > The reason is a bug in qcow2_update_header(). Instead of rewriting the
> > same value as is already in the image, it writes bs->backing_file to the
> > image. This was always the same as long as you couldn't override the
> > backing file name on the command line or in blockdev-add, but now it's
> > obviously wrong.
> > 
> > It would also rewrite the backing file name on other occasions such as
> > marking the image dirty with lazy_refcounts=on (i.e. on the first
> > write request).
> 
> Kevin, did you have a chance to fix this prob (for 2.3)?
> 2.1 version does the right thing here.

I started working on it on Thursday, but as both Good Friday and Easter
Monday are public holidays in Germany, it's not ready yet. I hope to get
it ready in time for -rc3.

2.1 does the "right" thing because it doesn't support bdrv_make_empty()
for qcow2 yet, which is the function that triggers the buggy header
rewrite. But without it, your image can't shrink.

> >>>> When performing commit, does qemu mark the areas in the
> >>>> overlay file as free after writing contents to the backing
> >>>> file, or will these areas be written again by a subsequent
> >>>> commit?  Somehow it smells like each next commit writes
> >>>> more and more data and completes in more and more time.
> >>>
> >>> With qcow2 and qcow, the committed data is discarded with HMP 'commit'.
> >>> Other image formats keep the copy.
> >>
> >> Hm.  It is discarded, but the file isn't shrinked.  With "non-live"
> >> commit I don't see a reason why it can't be shrinked too?
> > 
> > This would be a bug as well, but Michael double-checked and it does
> > shrink in fact.
> 
> Actually it WAS a bug.  Initially I tested with 2.1 version,
> and there, neither `commit' HMP command nor `qemu-img commit'
> command shrinks the overlay image, so each new commit re-writes
> both the new data AND the old data, and never shrinks.  With
> 2.2 version it works as expected, except of the above problem
> with rewriting the base file name.

I would call it a new feature rather than a bug fix, but yes, that's new
in 2.2 (see above).

Kevin

  reply	other threads:[~2015-04-07  9:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27  9:07 [Qemu-devel] block-commit & dropping privs Michael Tokarev
2015-03-27 14:49 ` Eric Blake
2015-03-27 15:36   ` Michael Tokarev
2015-03-27 17:12     ` Eric Blake
2015-03-30 15:36       ` Kevin Wolf
2015-04-01  9:26         ` Michael Tokarev
2015-04-01  9:54           ` Michael Tokarev
2015-04-01 12:34             ` Kevin Wolf
2015-04-02 10:58               ` Michael Tokarev
2015-04-02 11:24                 ` Kevin Wolf
2015-04-02 12:04                   ` Michael Tokarev
2015-04-02 13:07                     ` Eric Blake
2015-04-03  4:28                       ` Jeff Cody
2015-04-03 19:49                         ` Eric Blake
2015-04-03 19:57                           ` Jeff Cody
2015-04-02 13:19                     ` Kevin Wolf
2015-04-06 15:37                       ` Michael Tokarev
2015-04-07  9:24                         ` Kevin Wolf [this message]
2015-04-03  3:59                   ` Jeff Cody
2015-04-07  9:18                     ` Kevin Wolf

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=20150407092435.GE4635@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=jcody@redhat.com \
    --cc=mjt@tls.msk.ru \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.