qemu-img: Document --force-share / -U
v6 cover qemu-img: Document --force-share / -U
v6: Tweak wording ("concurrent writers"). [Max]
Fam Zheng (2):
qemu-img.texi: Clean up parameter list
qemu-img: Document --force-share / -U
qemu-img.texi | 73 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 27 deletions(-)
Signature · 1 line
2.14.3
PATCH v6 1/2 qemu-img.texi: Clean up parameter list
Split options out of the "@table @var" section and create a "@table @option", then use whitespaces and blank lines consistently.
--- qemu-img.texi | 66 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 27 deletions(-)
qemu-img.texi +39 -27
@@ -33,38 +33,14 @@ The following commands are supported: Command parameters: @table @var + @item filename - is a disk image filename - -@item --object @var{objectdef} - -is a QEMU user creatable object definition. See the @code{qemu(1)} manual -page for a description of the object properties. The most common object -type is a @code{secret}, which is used to supply passwords and/or encryption -keys. - -@item --image-opts - -Indicates that the source @var{filename} parameter is to be interpreted as a -full option string, not a plain filename. This parameter is mutually -exclusive with the @var{-f} parameter. - -@item --target-image-opts - -Indicates that the @var{output_filename} parameter(s) are to be interpreted as -a full option string, not a plain filename. This parameter is mutually -exclusive with the @var{-O} parameters. It is currently required to also use -the @var{-n} parameter to skip image creation. This restriction may be relaxed -in a future release. +is a disk image filename @item fmt is the disk image format. It is guessed automatically in most cases. See below for a description of the supported disk formats. -@item --backing-chain -will enumerate information about backing files in a disk image chain. Refer -below for further description. - @item size is the disk image size in bytes. Optional suffixes @code{k} or @code{K} (kilobyte, 1024) @code{M} (megabyte, 1024k) and @code{G} (gigabyte, 1024M)
@@ -74,42 +50,78 @@ and T (terabyte, 1024G) are supported. @code{b} is ignored. is the destination disk image filename @item output_fmt - is the destination format +is the destination format + @item options is a comma separated list of format specific options in a name=value format. Use @code{-o ?} for an overview of the options supported by the used format or see the format descriptions below for details. + @item snapshot_param is param used for internal snapshot, format is 'snapshot.id=[ID],snapshot.name=[NAME]' or '[ID_OR_NAME]' + @item snapshot_id_or_name is deprecated, use snapshot_param instead +@end table + +@table @option + +@item --object @var{objectdef} +is a QEMU user creatable object definition. See the @code{qemu(1)} manual +page for a description of the object properties. The most common object +type is a @code{secret}, which is used to supply passwords and/or encryption +keys. + +@item --image-opts +Indicates that the source @var{filename} parameter is to be interpreted as a +full option string, not a plain filename. This parameter is mutually +exclusive with the @var{-f} parameter. + +@item --target-image-opts +Indicates that the @var{output_filename} parameter(s) are to be interpreted as +a full option string, not a plain filename. This parameter is mutually +exclusive with the @var{-O} parameters. It is currently required to also use +the @var{-n} parameter to skip image creation. This restriction may be relaxed +in a future release. + +@item --backing-chain +will enumerate information about backing files in a disk image chain. Refer +below for further description. + @item -c indicates that target image must be compressed (qcow format only) + @item -h with or without a command shows help and lists the supported formats + @item -p display progress bar (compare, convert and rebase commands only). If the @var{-p} option is not used for a command that supports it, the progress is reported when the process receives a @code{SIGUSR1} or @code{SIGINFO} signal. + @item -q Quiet mode - do not print any output (except errors). There's no progress bar in case both @var{-q} and @var{-p} options are used. + @item -S @var{size} indicates the consecutive number of bytes that must contain only zeros for qemu-img to create a sparse image during conversion. This value is rounded down to the nearest 512 bytes. You may use the common size suffixes like @code{k} for kilobytes. + @item -t @var{cache} specifies the cache mode that should be used with the (destination) file. See the documentation of the emulator's @code{-drive cache=...} option for allowed values. + @item -T @var{src_cache} specifies the cache mode that should be used with the source file(s). See the documentation of the emulator's @code{-drive cache=...} option for allowed values. + @end table Parameters to snapshot subcommand:
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v6 1/2] qemu-img.texi: Clean up parameter list
Quoted 8 lines · Fam Zheng
Split options out of the "@table @var" section and create a "@table @option", then use whitespaces and blank lines consistently.
Suggested-by Kevin Wolf <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- qemu-img.texi | 66 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 27 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v6 2/2 qemu-img: Document --force-share / -U
In reply to Fam Zheng--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)
qemu-img.texi +7 -0
@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release. +@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image information +(with 'info' subcommand) when the image is used by a running guest. Note that +this could produce inconsistent results because of concurrent metadata changes, +etc. This option is only allowed when opening images in read-only mode. + @item --backing-chain will enumerate information about backing files in a disk image chain. Refer below for further description.
Signature · 1 line
2.14.3
Quoted 6 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 11 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.texi +0
-0
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 6 lines
qemu-img.texi +3
-0@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release. +@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image information
Actually, we only permit one writer at a time. Would it be better to say "allowing a concurrent writer"?
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 94
Quoted 3 lines
qemu-img.texi +3
-0+(with 'info' subcommand) when the image is used by a running guest. Note that +this could produce inconsistent results because of concurrent metadata changes, +etc. This option is only allowed when opening images in read-only mode.
After all, we are stating that this process (which must be read-only, because we can't have two writers at once) is permitting some other process to be the concurrent writer (but not multiple processes to be concurrent writers)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Kashyap Chamarthy
Reviewed-byQuoted 1 line · Eric Blake
On 01/30/2018 12:34 AM, Fam Zheng wrote:
[...]
Quoted 5 lines
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 2 lines
qemu-img.texi +2
-0+If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image informationActually, we only permit one writer at a time. Would it be better to say "allowing a concurrent writer"?
Definitely worth rewording. Otherwise the two sentences:
"If specified, @code{qemu-img} will open the image in shared mode,
allowing concurrent writers."
"This option is only allowed when opening images in read-only mode."
are at odds with each other --- it says "concurrent writers" are allowed, BUT "allowed only when opening images in 'read-only' mode".
Quoted 8 lines
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 94
Quoted 3 lines
qemu-img.texi +3
-0+(with 'info' subcommand) when the image is used by a running guest. Note that +this could produce inconsistent results because of concurrent metadata changes, +etc. This option is only allowed when opening images in read-only mode.After all, we are stating that this process (which must be read-only, because we can't have two writers at once) is permitting some other process to be the concurrent writer (but not multiple processes to be concurrent writers)
Precisely. So it's worth being clearer.
With the rewording suggested by Eric:
Signature · 1 line
/kashyap
Am 30.01.2018 um 15:23 hat Eric Blake geschrieben:
Quoted 15 lines · Fam Zheng
Quoted 14 lines
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.texi +0
-0@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release.
Quoted 6 lines
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 3 lines
qemu-img.texi +3
-0+@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image informationActually, we only permit one writer at a time. Would it be better to say "allowing a concurrent writer"?
As far as qemu-img is concerned, multiple writers to the image are allowed. There may be further restrictions imposed by a writer so that a second writer isn't allowed, but with raw images and share-rw=on nothing prevents two qemu instances writing to the same image while qemu-img is accessing it read-only.
Kevin
Quoted 23 lines · Kevin Wolf
Am 30.01.2018 um 15:23 hat Eric Blake geschrieben:
Quoted 15 lines · Fam Zheng
Quoted 14 lines
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.texi +0
-0@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release.Quoted 6 lines
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 3 lines
qemu-img.texi +3
-0+@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image informationActually, we only permit one writer at a time. Would it be better to say "allowing a concurrent writer"?
Quoted 5 lines
As far as qemu-img is concerned, multiple writers to the image are allowed. There may be further restrictions imposed by a writer so that a second writer isn't allowed, but with raw images and share-rw=on nothing prevents two qemu instances writing to the same image while qemu-img is accessing it read-only.
I agree with what you wrote and it's technically correct, but this is a confusing place to mention concurrent writers. They are a common source of user error and that's why locking was introduced in the first place.
There should be a separate paragraph in docs/qemu-block-drivers.texi explaining that share-rw=on can be used safely with format=raw if the guests are configured to safely access a shared disk. It should also mention that share-rw=on is unsafe for image formats.
Stefan
Am 31.01.2018 um 15:12 hat Stefan Hajnoczi geschrieben:
Quoted 30 lines · Kevin Wolf
Quoted 23 lines
Am 30.01.2018 um 15:23 hat Eric Blake geschrieben:
Quoted 15 lines · Fam Zheng
Quoted 14 lines
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.texi +0
-0@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release.Quoted 6 lines
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 3 lines
qemu-img.texi +3
-0+@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers. For example, this can be used to get the image informationActually, we only permit one writer at a time. Would it be better to say "allowing a concurrent writer"?
Quoted 5 lines
As far as qemu-img is concerned, multiple writers to the image are allowed. There may be further restrictions imposed by a writer so that a second writer isn't allowed, but with raw images and share-rw=on nothing prevents two qemu instances writing to the same image while qemu-img is accessing it read-only.
Quoted 3 lines
I agree with what you wrote and it's technically correct, but this is a confusing place to mention concurrent writers. They are a common source of user error and that's why locking was introduced in the first place.
So you understand "concurrent writers" as at least two writers? Because I wouldn't understood it as a writer that is concurrent to the (read-only) qemu-img.
Maybe rephrase it as "...allowing other processes to write to the image" then?
Quoted 4 lines
There should be a separate paragraph in docs/qemu-block-drivers.texi explaining that share-rw=on can be used safely with format=raw if the guests are configured to safely access a shared disk. It should also mention that share-rw=on is unsafe for image formats.
share-rw=on is a -device option and only about the guest, not about the backend. It is never unsafe if the guest can cope with external writers. It just doesn't prevent qemu from locking the image file for image formats.
Kevin
Quoted 10 lines · Kevin Wolf
Am 31.01.2018 um 15:12 hat Stefan Hajnoczi geschrieben:
Quoted 4 lines
There should be a separate paragraph in docs/qemu-block-drivers.texi explaining that share-rw=on can be used safely with format=raw if the guests are configured to safely access a shared disk. It should also mention that share-rw=on is unsafe for image formats.
share-rw=on is a -device option and only about the guest, not about the backend. It is never unsafe if the guest can cope with external writers. It just doesn't prevent qemu from locking the image file for image formats.
Thanks for the explanation. Documentation on share-rw=on|off would be nice.
Maybe something like:
By default the guest has exclusive write access to its disk image. This is enforced by QEMU via file locking. If the guest can safely share the disk image with other writers the -device ...,share-rw=on parameter can be used. This is only safe if the guest is running software, such as a cluster file system, that coordinates disk accesses to avoid corruption.
Note that share-rw=on only declares the guest's ability to share the disk. Some QEMU features, such as image file formats, require exclusive write access to the disk image and this is unaffected by the share-rw=on option.
For anyone else reading this, here is the code that protects qcow2 and other image formats:
void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
const BdrvChildRole *role,
BlockReopenQueue *reopen_queue,
uint64_t perm, uint64_t shared,
uint64_t *nperm, uint64_t *nshared)
{
...
/* bs->file always needs to be consistent because of the metadata. We
* can never allow other users to resize or write to it. */
if (!(flags & BDRV_O_NO_IO)) {
perm |= BLK_PERM_CONSISTENT_READ;
}
shared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);Stefan
Quoted 24 lines · Stefan Hajnoczi
Quoted 10 lines · Kevin Wolf
Am 31.01.2018 um 15:12 hat Stefan Hajnoczi geschrieben:
Quoted 4 lines
There should be a separate paragraph in docs/qemu-block-drivers.texi explaining that share-rw=on can be used safely with format=raw if the guests are configured to safely access a shared disk. It should also mention that share-rw=on is unsafe for image formats.
share-rw=on is a -device option and only about the guest, not about the backend. It is never unsafe if the guest can cope with external writers. It just doesn't prevent qemu from locking the image file for image formats.
Thanks for the explanation. Documentation on share-rw=on|off would be nice.
Maybe something like:
By default the guest has exclusive write access to its disk image. This is enforced by QEMU via file locking. If the guest can safely share the disk image with other writers the -device ...,share-rw=on parameter can be used. This is only safe if the guest is running software, such as a cluster file system, that coordinates disk accesses to avoid corruption.
Quoted 4 lines
Note that share-rw=on only declares the guest's ability to share the disk. Some QEMU features, such as image file formats, require exclusive write access to the disk image and this is unaffected by the share-rw=on option.
I will add these paragraphs to the "image locking" seciton in docs/qemu-block-drivers.texi.
Fam
Quoted 24 lines · Stefan Hajnoczi
Quoted 10 lines · Kevin Wolf
Am 31.01.2018 um 15:12 hat Stefan Hajnoczi geschrieben:
Quoted 4 lines
There should be a separate paragraph in docs/qemu-block-drivers.texi explaining that share-rw=on can be used safely with format=raw if the guests are configured to safely access a shared disk. It should also mention that share-rw=on is unsafe for image formats.
share-rw=on is a -device option and only about the guest, not about the backend. It is never unsafe if the guest can cope with external writers. It just doesn't prevent qemu from locking the image file for image formats.
Thanks for the explanation. Documentation on share-rw=on|off would be nice.
Maybe something like:
By default the guest has exclusive write access to its disk image. This is enforced by QEMU via file locking. If the guest can safely share the disk image with other writers the -device ...,share-rw=on parameter can be used. This is only safe if the guest is running software, such as a cluster file system, that coordinates disk accesses to avoid corruption.
Quoted 4 lines
Note that share-rw=on only declares the guest's ability to share the disk. Some QEMU features, such as image file formats, require exclusive write access to the disk image and this is unaffected by the share-rw=on option.
I will add these paragraphs to the "image locking" seciton in docs/qemu-block-drivers.texi.
Fam
Quoted 11 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>Signed-off-by Kevin Wolf <[email protected]>--- qemu-img.texi | 7 +++++++ 1 file changed, 7 insertions(+)qemu-img.texi +0
-0
qemu-img.texi exclusive with the @var{-O} parameters. It is currently required to also use · line 91
Quoted 6 lines
qemu-img.texi +3
-0@@ -86,6 +86,13 @@ exclusive with the @var{-O} parameters. It is currently required to also use the @var{-n} parameter to skip image creation. This restriction may be relaxed in a future release. +@item --force-share (-U) +If specified, @code{qemu-img} will open the image in shared mode, allowing +concurrent writers.
This wording confuses me. It makes me think of multiple processes writing to the image at the same time...
Quoted 1 line
This option is only allowed when opening images in read-only mode.
...but later it turns out "concurrent writers" means there can be at most 1 writing process and multiple reading processes.
How about merging the two statements?
"If specified, allows @code{qemu-img} to open the image in read-only mode even if another process already has it open for writing."