Bug 1698863 - 'qemu-img create -f raw -o ?' should list more options
Summary: 'qemu-img create -f raw -o ?' should list more options
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: qemu-kvm
Version: 8.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Hanna Czenczek
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-04-11 11:46 UTC by Tingting Mao
Modified: 2019-08-26 20:28 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-08 02:44:10 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Tingting Mao 2019-04-11 11:46:54 UTC
Description of problem:
'qemu-img create -f raw -o ?' should list more options, while there is only size=<size> option now.


Version-Release number of selected component (if applicable):
qemu-kvm-3.1.0-20.module+el8+2904+e658c755


How reproducible:
100%


Steps to Reproduce:

# qemu-img create -f raw -o ?
Supported options:
  size=<size>            - Virtual disk size


Actual results:
As above.


Expected results:
More supporting options, at least 'preallocation', for preallocation modes(off, falloc and full) are supported by 'qemu-img create -f raw -o'.

# qemu-img create -f raw test.img 2G -o preallocation=off
Formatting 'test.img', fmt=raw size=2147483648 preallocation=off

# qemu-img create -f raw test.img 2G -o preallocation=falloc
Formatting 'test.img', fmt=raw size=2147483648 preallocation=falloc

# qemu-img create -f raw test.img 2G -o preallocation=full
Formatting 'test.img', fmt=raw size=2147483648 preallocation=full


Additional info:

Comment 4 Hanna Czenczek 2019-04-13 14:35:52 UTC
Hi,

preallocation is a protocol-level option.  Without giving a filename, qemu-img create does not know which protocol to use, so it cannot list any such options.

If you give a filename, the output changes:

$ qemu-img create -f raw -o help foo.img
Supported options:
  nocow=<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
  preallocation=<str>    - Preallocation mode (allowed values: off, falloc, full)
  size=<size>            - Virtual disk size

I suppose we can print a note hinting at this fact if the user did not specify a filename.

Max

Comment 5 Tingting Mao 2019-04-15 02:11:57 UTC
(In reply to Max Reitz from comment #4)
> Hi,
> 
> preallocation is a protocol-level option.  Without giving a filename,
> qemu-img create does not know which protocol to use, so it cannot list any
> such options.
> 
At the beginning, I reported this bug is because it could list the supported options(includes preallocation) for qcow2 format. So could I know what is different between qcow2 and raw? Thanks.

# qemu-img create -f qcow2 -o ?
Supported options:
size             Virtual disk size
compat           Compatibility level (0.10 or 1.1)
backing_file     File name of a base image
backing_fmt      Image format of the base image
encryption       Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
encrypt.cipher-alg Name of encryption cipher algorithm
encrypt.cipher-mode Name of encryption cipher mode
encrypt.ivgen-alg Name of IV generator algorithm
encrypt.ivgen-hash-alg Name of IV generator hash algorithm
encrypt.hash-alg Name of encryption hash algorithm
encrypt.iter-time Time to spend in PBKDF in milliseconds
cluster_size     qcow2 cluster size
preallocation    Preallocation mode (allowed values: off, metadata, falloc, full)  ----- Preallocation Mode
lazy_refcounts   Postpone refcount updates
refcount_bits    Width of a reference count entry in bits

> If you give a filename, the output changes:
> 
> $ qemu-img create -f raw -o help foo.img
> Supported options:
>   nocow=<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
>   preallocation=<str>    - Preallocation mode (allowed values: off, falloc,
> full)
>   size=<size>            - Virtual disk size
> 
> I suppose we can print a note hinting at this fact if the user did not
> specify a filename.
> 
> Max

Comment 6 Hanna Czenczek 2019-04-15 14:32:26 UTC
The difference is that the raw format actually does not support preallocation, whereas the qcow2 format does.  However, the raw format itself does not need to preallocate anything, so it can just pass that option through to the protocol driver.

Thus, you cannot use raw preallocation over other protocols like ssh:

$ qemu-img create -f raw -o help /tmp/foo.img         
Supported options:
  nocow=<bool (on/off)>  - Turn off copy-on-write (valid only on btrfs)
  preallocation=<str>    - Preallocation mode (allowed values: off, falloc, full)
  size=<size>            - Virtual disk size

$ qemu-img create -f raw -o help ssh://localhost/tmp/foo.img   
Supported options:
  size=<size>            - Virtual disk size

$ qemu-img create -f raw -o preallocation=full ssh://localhost/tmp/foo.img 64M
qemu-img: ssh://localhost/tmp/foo.img: Invalid parameter 'preallocation'

Note that in practice you also cannot use preallocation=full and preallocation=falloc over these protocols with qcow2:

$ qemu-img create -f qcow2 -o preallocation=full ssh://localhost/tmp/foo.img 64M
Formatting 'ssh://localhost/tmp/foo.img', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=full lazy_refcounts=off refcount_bits=16
qemu-img: ssh://localhost/tmp/foo.img: Could not resize image: Failed to resize underlying file: Unsupported preallocation mode 'full'

But you can at least use metadata preallocation:

$ qemu-img create -f qcow2 -o preallocation=metadata ssh://localhost/tmp/foo.img 64M
Formatting 'ssh://localhost/tmp/foo.img', fmt=qcow2 size=67108864 cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16

$ echo $?
0

Max


Note You need to log in before you can comment on or make changes to this bug.