kvm-87: qemu-img creates raw file with wrong size
Greetings,
Running qemu-img create -f raw file.raw 1000 creates a 512 byte file rather than the 1000K file the docs imply.
From the help message:
"
'size' is the disk image size in kilobytes. Optional suffixes 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are supported any 'k' or 'K' is ignored
"
Did the default change or is there bug with the create?
Signature · 3 lines
Randy Smith http://www.vuser.org/ http://perlstalker.blogspot.com/
Quoted 5 lines · Randy Smith
Greetings,
Running
qemu-img create -f raw file.raw 1000creates a 512 byte file rather than the 1000K file the docs imply.
Quoted 9 lines
From the help message:
"
'size' is the disk image size in kilobytes. Optional suffixes 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are supported any 'k' or 'K' is ignored
"Did the default change or is there bug with the create?
No suffix assumes bytes. It truncates to the nearest sector which is why you see a 512 byte file. If you did qemu-img create -f raw file.raw 1024 you would see a file of 1024 bytes.
Not sure if the docs is wrong or this behavior changed. Patch either way would be appreciated/accepted.
Regards,
Anthony Liguori
Quoted 17 lines · Anthony Liguori
Quoted 6 lines · Randy Smith
Greetings,
Running
qemu-img create -f raw file.raw 1000creates a 512 byte file rather than the 1000K file the docs imply.Quoted 9 lines
From the help message:
"
'size' is the disk image size in kilobytes. Optional suffixes 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are supported any 'k' or 'K' is ignored
"Did the default change or is there bug with the create?
Quoted 6 lines
No suffix assumes bytes. It truncates to the nearest sector which is why you see a 512 byte file. If you did
qemu-img create -f raw file.raw 1024you would see a file of 1024 bytes.Not sure if the docs is wrong or this behavior changed. Patch either way would be appreciated/accepted.
It looks like the behavior changed. The ubuntu-vm-builder depended on 'size' defaulting to kilobytes and the help message printed when qemu-img is run claims that it should default to kilobytes.
Here's a patch that updates the help message. It doesn't matter to me if the behavior changed here but as long as the docs match what's really happening.
qemu-img.c renamed from qemu-img.c.orig +0 -0
@@ -78,7 +78,7 @@ " content as the input's base image, however the path,
image format, etc may\n"
" differ\n"
" 'fmt' is the disk image format. It is guessed
automatically in most cases\n"
- " 'size' is the disk image size in kilobytes. Optional suffixes\n"
+ " 'size' is the disk image size in bytes. Optional suffixes\n"
" 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 *1024 * 1024) are\n"
" supported any 'k' or 'K' is ignored\n"
" 'output_filename' is the destination disk image filename\n"
Signature · 3 lines
Randy Smith http://www.vuser.org/ http://perlstalker.blogspot.com/
Quoted 45 lines · Randall Smith
Quoted 17 lines · Anthony Liguori
Quoted 6 lines · Randy Smith
Greetings,
Running
qemu-img create -f raw file.raw 1000creates a 512 byte file rather than the 1000K file the docs imply.Quoted 9 lines
From the help message:
"
'size' is the disk image size in kilobytes. Optional suffixes 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are supported any 'k' or 'K' is ignored
"Did the default change or is there bug with the create?
Quoted 6 lines
No suffix assumes bytes. It truncates to the nearest sector which is why you see a 512 byte file. If you did
qemu-img create -f raw file.raw 1024you would see a file of 1024 bytes.Not sure if the docs is wrong or this behavior changed. Patch either way would be appreciated/accepted.
It looks like the behavior changed. The ubuntu-vm-builder depended on 'size' defaulting to kilobytes and the help message printed when qemu-img is run claims that it should default to kilobytes.
Here's a patch that updates the help message. It doesn't matter to me if the behavior changed here but as long as the docs match what's really happening.
qemu-img.c renamed from qemu-img.c.orig +0
-0@@ -78,7 +78,7 @@ " content as the input's base image, however the path,image format, etc may\n"
" differ\n"
" 'fmt' is the disk image format. It is guessed
automatically in most cases\n"
- " 'size' is the disk image size in kilobytes. Optional
suffixes\n"
+ " 'size' is the disk image size in bytes. Optional
suffixes\n"
Quoted 5 lines
" 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 *1024 * 1024) are\n"
" supported any 'k' or 'K' is ignored\n"
" 'output_filename' is the destination disk image
filename\n"
The help message is still incorrect. The 'k' or 'K' suffix is supported also and not ignored like the message says.
Lynn Kerby