| Summary: | qemu-img: can't parse negative value of qemu-img resize command. | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Hajime Taira <htaira> |
| Component: | qemu-kvm | Assignee: | Kevin Wolf <kwolf> |
| Status: | CLOSED WONTFIX | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 6.1 | CC: | areis, chayang, jbainbri, juzhang, mkenneth, nigil, sathnaga86, shuang, tburke, virt-maint, wgold |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-04-05 09:42:15 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
|
Description
Hajime Taira
2011-09-02 04:55:26 UTC
Fixed in upstream commit e80fec7f. Will backport to RHEL. Additional information. please see manpage of qemu-img in Fedora 15 or Upstream.
QEMU-IMG(1) QEMU-IMG(1)
NAME
qemu-img - QEMU disk image utility
SYNOPSIS
usage: qemu-img command [command options]
OPTIONS
The following commands are supported:
(snip)
resize filename [+ | -]size
Change the disk image as if it had been created with size.
Before using this command to shrink a disk image, you MUST use file
system and partitioning tools inside the VM to reduce allocated file
systems and partition sizes accordingly. Failure to do so will result
in data loss!
After using this command to grow a disk image, you must use file
system and partitioning tools inside the VM to actually begin using
the new space on the device.
Reproduced this issue with qemu-kvm-0.12.1.2-2.209.el6.x86_64. Got following output by: # qemu-img --help qemu-img version 0.12.1, Copyright (c) 2004-2008 Fabrice Bellard usage: qemu-img command [command options] QEMU disk image utility (snip) resize filename [+ | -]size Steps: 1. create a raw format image file: # qemu-img create -f raw test.raw 10G Formatting 'test.raw', fmt=raw size=10737418240 # qemu-img info test.raw image: test.raw file format: raw virtual size: 10G (10737418240 bytes) disk size: 0 2. resize this image file to 6G: # qemu-img resize test.raw 6G Image resized. # qemu-img info test.raw image: test.raw file format: raw virtual size: 6.0G (6442450944 bytes) disk size: 0 3. resize to 20G # qemu-img resize test.raw 20G Image resized. # qemu-img info test.raw image: test.raw file format: raw virtual size: 20G (21474836480 bytes) disk size: 0 4. increase it by +2G # qemu-img resize test.raw +2G Image resized. # qemu-img info test.raw image: test.raw file format: raw virtual size: 22G (23622320128 bytes) disk size: 0 5. decrease it by 2G # qemu-img resize test.raw -2G resize: invalid option -- '2' Marking qa_ack+ according to above info. Interestingly, you can work around this by specifying the negative value as an addition eg: to remove 2gb from image # qemu-img resize image.img "+-2G" Deferring to RHEL 6.5 because this is low priority and we're over capacity. This kind of behavior is quite common in getopt(3) applications. The workaround is to use -- before the option (or +-2G, as suggested by Jamie). Why discuss this about 1 year?
I propose new sub-commands "qemu-img extend" and "qemu-img reduce"
eg. To extend 2GB from image
# qemu-img extend 2GB image.img
eg. Do not give negative size parameter for "qemu-img resize",
To reduce 2GB from image
# qemu-img reduce 2GB image.img
Still broken in RHEL 6.3 Still broken in RHEL 6.4 |