Bug 1468447 - Executing HMP block_resize command via QMP ‘human-monitor-command’ gets unexpected result
Executing HMP block_resize command via QMP ‘human-monitor-command’ gets unex...
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
ppc64le Linux
unspecified Severity unspecified
: rc
: ---
Assigned To: Dr. David Alan Gilbert
Virtualization Bugs
Depends On:
  Show dependency treegraph
Reported: 2017-07-07 03:08 EDT by yilzhang
Modified: 2017-07-11 21:57 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-07-10 15:16:24 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description yilzhang 2017-07-07 03:08:57 EDT
Description of problem:
Boot up a guest with one qcow2 disk image(acts as one data disk), then using QMP ‘human-monitor-command’ to execute  HMP block_resize, which attempts to resize the block disk to a smaller size(e.g. 1G-->512M).
This is expected to fail, but QMP returns “success” and the block disk’s size is not correct after changing.

Version-Release number of selected component (if applicable):
Host:  kernel: 4.11.0-10.el7a.ppc64le
Guest: 4.11.0-10.el7a.ppc64le

How reproducible: 100%

Steps to Reproduce:
1. boot guest with QMP enabled, Qemu cli:
/usr/libexec/qemu-kvm \
-name yilzhang_vm \
-serial unix:/tmp/myserial.log,server,nowait \
-smp 8,sockets=2,cores=4,threads=1 -m 8192 \
-qmp tcp:0:9999,server,nowait \
-monitor stdio \
-nodefaults -enable-kvm \
-device virtio-scsi-pci,bus=pci.0,addr=0x3,id=scsi0 \
-drive file=/home/yilzhang/rhel7.4-alt-20170626.4.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop \
-device scsi-hd,bus=scsi0.0,drive=drive-system-disk,id=system-disk,bootindex=1 \
-drive file=/dev/sdb3,if=none,cache=none,id=data-disk1,format=qcow2 \
-device virtio-blk-pci,drive=data-disk1,bus=pci.0,id=blk-disk1 \
-netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup \
-device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=52:54:00:c3:e7:84,bus=pci.0,addr=0x4,ioeventfd=off \
2. from any box with telnet client run #telnet $HostIP 4444
   {"execute": "qmp_capabilities"}
3. execute block_resize command with QMP "human-monitor-command" to shrink a block disk with qcow2 format
 {"execute":"human-monitor-command","arguments":{"command-line":"block_resize  data-disk1 536870912" }}

Actual results:
1. step3 QMP success:
{"execute":"human-monitor-command","arguments":{"command-line":"block_resize  data-disk1 536870912" }}
{"return": ""}
2. the block disk's size is changed to 512T which is not correct:
{"execute": "query-block"}
{"return": [{"io-status": "ok", "device": "drive-system-disk", .......  ......}, {"io-status": "ok", "device": "data-disk1", "locked": false, "removable": false, "inserted": {"iops_rd": 0, "detect_zeroes": "off", "image": {"virtual-size": 562949953421312, "filename": "/dev/sdb3", "cluster-size": 65536, "format": "qcow2", "actual-size": 0, "format-specific": {"type": "qcow2"

[guest]#   fdisk -l  /dev/vda
Disk /dev/vda: 562950.0 GB, 562949953421312 bytes, 1099511627776 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[guest]#  lsblk -p| grep vda
/dev/vda                    252:0    0  512T  0 disk 

Expected results:
1. step3 QMP should prompt error, like:
{"error": {"class": "GenericError", "desc": "Failed to resize image: Operation not supported"}}
2. the block disk's size is NOT changed

Additional info:
If I use QMP block_resize to shrink the block image's size, QMP will prompt error message (this is expected since qcow2 image doesn't support shrink):

{ "execute": "block_resize", "arguments": { "device": "data-disk1", "size": 536870912 }}
{"error": {"class": "GenericError", "desc": "Failed to resize image: Operation not supported"}}
Comment 2 Karen Noel 2017-07-07 07:20:34 EDT
Does this reproduce on x86 or Power 8? Thanks.
Comment 3 Ademar Reis 2017-07-07 09:53:49 EDT
We don't support HMP in RHEL, so I suggest closing it as WONTFIX. David Gilbert is the upstream maintainer of HMP, so I'm reassigning it to him just in case it's a low hanging fruit worth fixing upstream.
Comment 7 Dr. David Alan Gilbert 2017-07-10 15:16:24 EDT
Sizes there are assumed to be in MiB; unless you add a prefix (I tried all the way back to 1.5.3 it hasn't changed).

You should find:
block_resize  data-disk1 536870912b
block_resize data-disks1 512

does what you expect.

HMP is for Humans, humans generally think of disks in MiB or larger by default, so that's fine.

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