All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 07/11] block: Leave BDS.backing_file constant
Date: Wed, 14 Nov 2018 21:01:09 +0100	[thread overview]
Message-ID: <084563e1-9074-6fc4-1b36-391afb351e62@redhat.com> (raw)
In-Reply-To: <c85988da-52e7-b035-8985-d96780678dde@redhat.com>

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

On 13.11.18 00:08, Eric Blake wrote:
> On 8/9/18 5:31 PM, Max Reitz wrote:
>> Parts of the block layer treat BDS.backing_file as if it were whatever
>> the image header says (i.e., if it is a relative path, it is relative to
>> the overlay), other parts treat it like a cache for
>> bs->backing->bs->filename (relative paths are relative to the CWD).
>> Considering bs->backing->bs->filename exists, let us make it mean the
>> former.
>>
>> Among other things, this now allows the user to specify a base when
>> using qemu-img to commit an image file in a directory that is not the
>> CWD (assuming, everything uses relative filenames).
>>
>> Before this patch:
>>
>> $ ./qemu-img create -f qcow2 foo/bot.qcow2 1M
>> $ ./qemu-img create -f qcow2 -b bot.qcow2 foo/mid.qcow2
>> $ ./qemu-img create -f qcow2 -b mid.qcow2 foo/top.qcow2
>> $ ./qemu-img commit -b mid.qcow2 foo/top.qcow2
>> qemu-img: Did not find 'mid.qcow2' in the backing chain of
>> 'foo/top.qcow2'
>> $ ./qemu-img commit -b foo/mid.qcow2 foo/top.qcow2
>> qemu-img: Did not find 'foo/mid.qcow2' in the backing chain of
>> 'foo/top.qcow2'
>> $ ./qemu-img commit -b $PWD/foo/mid.qcow2 foo/top.qcow2
>> qemu-img: Did not find '[...]/foo/mid.qcow2' in the backing chain of
>> 'foo/top.qcow2'
> 
> Three failures in a row - no way to commit short of changing your
> working directory.
> 
>>
>> After this patch:
>>
>> $ ./qemu-img commit -b mid.qcow2 foo/top.qcow2
>> Image committed.
>> $ ./qemu-img commit -b foo/mid.qcow2 foo/top.qcow2
>> qemu-img: Did not find 'foo/mid.qcow2' in the backing chain of
>> 'foo/top.qcow2'
>> $ ./qemu-img commit -b $PWD/foo/mid.qcow2 foo/top.qcow2
>> Image committed.
> 
> Yay, that looks saner.
> 
>>
>> With this change, bdrv_find_backing_image() must look at whether the
>> user has overridden a BDS's backing file.  If so, it can no longer use
>> bs->backing_file, but must instead compare the given filename against
>> the backing node's filename directly.
>>
>> Note that this changes the QAPI output for a node's backing_file.  We
>> had very inconsistent output there (sometimes what the image header
>> said, sometimes the actual filename of the backing image).  This
>> inconsistent output was effectively useless, so we have to decide one
>> way or the other.  Considering that bs->backing_file usually at runtime
>> contained the path to the image relative to qemu's CWD (or absolute),
>> this patch changes QAPI's backing_file to always report the
>> bs->backing->bs->filename from now on.  If you want to receive the image
>> header information, you have to refer to full-backing-filename.
>>
>> This necessitates a change to iotest 228.  The interesting information
>> it really wanted is the image header, and it can get that now, but it
>> has to use full-backing-filename instead of backing_file.  Because of
>> this patch's changes to bs->backing_file's behavior, we also need some
>> reference output changes.
>>
>> Along with the changes to bs->backing_file, stop updating
>> BDS.backing_format in bdrv_backing_attach() as well.  This necessitates
>> a change to the reference output of iotest 191.
> 
> Good explanations for the test changes.
> 
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   include/block/block_int.h  | 14 +++++++++-----
>>   block.c                    | 29 ++++++++++++++++++++++-------
>>   block/qapi.c               |  7 ++++---
>>   qemu-img.c                 | 12 ++++++++++--
>>   tests/qemu-iotests/191.out |  1 -
>>   tests/qemu-iotests/228     |  6 +++---
>>   tests/qemu-iotests/228.out |  6 +++---
>>   7 files changed, 51 insertions(+), 24 deletions(-)
>>
>> diff --git a/include/block/block_int.h b/include/block/block_int.h
>> index d3d8b22155..8f2c515ec1 100644
>> --- a/include/block/block_int.h
>> +++ b/include/block/block_int.h
>> @@ -737,11 +737,15 @@ struct BlockDriverState {
>>       bool walking_aio_notifiers; /* to make removal during iteration
>> safe */
>>         char filename[PATH_MAX];
>> -    char backing_file[PATH_MAX]; /* if non zero, the image is a diff of
>> -                                    this file image */
>> -    /* The backing filename indicated by the image header; if we ever
>> -     * open this file, then this is replaced by the resulting BDS's
>> -     * filename (i.e. after a bdrv_refresh_filename() run). */
>> +    /* If non-zero, the image is a diff of this image file.  Note that
> 
> Pre-existing, but that sentence might read nicer as:
> 
> If not empty, this image is a diff in relation to backing_file.
> 
>> +     * this the name given in the image header and may therefore not
> 
> "this the name" is wrong; did you mean "this is the name" or "this name"
> or "the name"?

Would any of the latter two make more grammatical sense? O:-)

Will fix.

I'll also fix the "may" wording.  Like this it sounds as if this is not
allowed to be equal to .backing->bs->filename, which of course is not
true.  It may or may not be equal.  So, I'll reword to:

"If not empty, this image is a diff in relation to backing_file.  Note
that this is the name given in the image header and therefore may or may
not be equal to .backing->bs->filename.  If this field contains a
relative path, it is to be resolved relatively to the overlay's location."


Thanks for reviewing!

Max

>> +     * be equal to .backing->bs->filename, and relative paths are
>> +     * resolved relatively to their overlay. */
>> +    char backing_file[PATH_MAX];
>> +    /* The backing filename indicated by the image header.  Contrary
>> +     * to backing_file, if we ever open this file, auto_backing_file
>> +     * is replaced by the resulting BDS's filename (i.e. after a
>> +     * bdrv_refresh_filename() run). */
>>       char auto_backing_file[PATH_MAX];
>>       char backing_format[16]; /* if non-zero and backing_file exists */
>>   
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 



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

  reply	other threads:[~2018-11-14 20:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 22:31 [Qemu-devel] [PATCH v2 00/11] block: Deal with filters Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 01/11] block: Mark commit and mirror as filter drivers Max Reitz
2018-09-07 12:37   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 02/11] blockdev: Check @replaces in blockdev_mirror_common Max Reitz
2018-11-09 22:51   ` Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 03/11] block: Filtered children access functions Max Reitz
2018-11-12 22:17   ` Eric Blake
2018-11-14 19:52     ` Max Reitz
2019-02-13 16:42       ` Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 04/11] block: Storage child access function Max Reitz
2018-11-12 22:32   ` Eric Blake
2018-11-14 19:56     ` Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 05/11] block: Fix check_to_replace_node() Max Reitz
2018-11-12 22:47   ` [Qemu-devel] [for 3.1? Qemu-devel] " Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 06/11] iotests: Add tests for mirror @replaces loops Max Reitz
2018-08-09 22:47   ` Max Reitz
2018-11-12 22:54   ` Eric Blake
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 07/11] block: Leave BDS.backing_file constant Max Reitz
2018-11-12 23:08   ` Eric Blake
2018-11-14 20:01     ` Max Reitz [this message]
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 08/11] iotests: Add filter commit test cases Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 09/11] iotests: Add filter mirror " Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 10/11] iotests: Add test for commit in sub directory Max Reitz
2018-08-09 22:31 ` [Qemu-devel] [PATCH v2 11/11] iotests: Test committing to overridden backing Max Reitz
2018-08-09 22:33 ` [Qemu-devel] [PATCH v2 00/11] block: Deal with filters Max Reitz
2018-08-29 13:29 ` Max Reitz
2018-11-09 22:47 ` Eric Blake

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=084563e1-9074-6fc4-1b36-391afb351e62@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@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 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.