All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Alex Bligh <alex@alex.org.uk>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] QCOW rebases on running VMs
Date: Wed, 27 Jan 2016 20:01:03 +0100	[thread overview]
Message-ID: <56A913EF.6060200@redhat.com> (raw)
In-Reply-To: <CCBF57B7-04B8-47E9-8786-DB7DE786969B@alex.org.uk>

[-- Attachment #1: Type: text/plain, Size: 2545 bytes --]

On 27.01.2016 19:04, Alex Bligh wrote:
> This question concerns the safety of rebases on backing disks whilst a VM is running from a writing disk.
> 
> Assume that we have the following structure:
> 
>     QEMU ------->   Writing disk
>                     ....
>                     backing disk N
>                     ....
>                     backing disk 1
>                     ....
>                     backing disk 0
> 
> If QEMU is not running, I can happily use 'qemu-img rebase' to merge backing disks 1 ... N (i.e. so backing disk N is now based on backing disk 0).
> 
> Is it safe to do this whilst the server is running using the writing disk which is based on backing disk N?

Maybe. You would rebase 1 through N into a new file and change the
backing file of the writing disk to the new file; because qemu is not
writing to the backing disks, that should probably work, but it's not
nice and may break horribly without prior notice.

> It is attractive to think it might be, as even if QEMU has a stale view of the contents of backing disk N, backing disks N-1 to 1 (inclusive) will still be present, QEMU will still keep an fd open for them, and it will (thus) still be able to read the correct sectors from them.
> 
> If not, do I need to use QMP magic instead?

This is always the best option, and I would strongly recommend doing so.
block-stream or block-commit should be your friend. block-stream streams
data from backing files into backed files, block-commit pushes data from
backed files into backing files; so block-stream transmits data from
bottom to top, and block-commit transmits it from top to bottom.

With block-commit, you can collapse the backing chain to e.g. (from top
to bottom):

Writing disk -> backing disk 1..N -> backing disk 0

like this (I think):

{ 'execute': 'block-commit',
  'arguments': { 'device': '$drive',
                 'base': 'backing disk 1',
                 'top': 'backing disk N' } }

The "backing disk 1..N" is the file which contained "backing disk 1" and
now contains all the data from disks 1 through N.


With block-stream, you can collapse it into

Writing disk -> backing disk 0

like this:

{ 'execute': 'block-stream',
  'arguments': { 'device': '$drive',
                 'base': 'backing disk 0' } }

Here, the writing disk would contain all the data from backing disks 1
through N. You could omit the "base" option, in which case the whole
backing chain would be collapsed into the writing disk.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-01-27 19:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 18:04 [Qemu-devel] QCOW rebases on running VMs Alex Bligh
2016-01-27 19:01 ` Max Reitz [this message]
2016-01-27 20:47 ` Eric Blake
2016-01-28 12:36   ` Alex Bligh
2016-01-28 15:25     ` Eric Blake
2016-01-29 20:16       ` Alberto Garcia

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=56A913EF.6060200@redhat.com \
    --to=mreitz@redhat.com \
    --cc=alex@alex.org.uk \
    --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.