Bug 890024

Summary: Guest should failed to be booted if specifying iops,bps as negative value
Product: Red Hat Enterprise Linux 7 Reporter: juzhang <juzhang>
Component: qemu-kvmAssignee: Stefan Hajnoczi <stefanha>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: armbru, hhuang, juzhang, knoel, michen, qzhang, sluo, virt-maint
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 1.5 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 987725 (view as bug list) Environment:
Last Closed: 2014-06-13 11:46:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 987725    

Description juzhang 2012-12-24 12:00:58 UTC
Description of problem:
Guest should be failed to boot if specifying iops,bps as negative value.

Version-Release number of selected component (if applicable):
Host Kernel
#uname -r
3.6.0-0.29.el7.x86_64
qemu-kvm version
qemu-kvm-1.2.0-20.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Boot guest with specifying bps=-1024000,iops=-100
#-drive file=/root/zhangjunyi/hotadd_15G.qcow2,if=none,id=drive-scsi-disk_test,format=qcow2,cache=none,werror=stop,rerror=stop,bps=-1024000,iops=-100 -device scsi-disk,drive=drive-scsi-disk_test,bus=scsi0.0,scsi-id=0,lun=1,id=scsi-disk_test
2.
3.
  
Actual results:
Guest can booted without promoting any messages.
(qemu)info block
.....
drive-scsi-disk_test: removable=0 io-status=ok file=/root/zhangjunyi/hotadd_15G.qcow2 ro=0 drv=qcow2 encrypted=0 bps=-1024000 bps_rd=0 bps_wr=0 iops=-100 iops_rd=0 iops_wr=0

Expected results:
Guest should failed to be booted and promote friendly message like
"Parameter 'iops' expects a positive number"

Additional info:
1. I tried latest upstream(qemu1.3), hit the same issue.
2. I checked the code #vi block_int.h
typedef struct BlockIOLimit {
    int64_t bps[3];
    int64_t iops[3];
} BlockIOLimit;

Why do not set uint64_t bps[3] instead of int64_t bps[3]?
3. File bug first, will check more io throttling codes.

Comment 1 juzhang 2012-12-25 09:32:13 UTC
Additional info:
Can we add a similar function for checking iops/iops_wr/iops_rd/bsp_wr/bps_rd/bps value  like bool do_check_io_limits?
snip code of source
#vi blockdev.c
static bool do_check_io_limits(BlockIOLimit *io_limits)
{
    bool bps_flag;
    bool iops_flag;

    assert(io_limits);

    bps_flag  = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0)
                 && ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0)
                 || (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0));
    iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0)
                 && ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0)
                 || (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0));
    if (bps_flag || iops_flag) {
        return false;
    }

    return true;
}

if (!do_check_io_limits(&io_limits)) {
        error_report("bps(iops) and bps_rd/bps_wr(iops_rd/iops_wr) "
                     "cannot be used at the same time");
        return NULL;
    }

Comment 2 Stefan Hajnoczi 2013-02-13 16:12:28 UTC
Thanks for reporting this bug and your suggestions.

I have posted a patch series upstream:
http://thread.gmane.org/gmane.comp.emulators.qemu/194315

Once it has been merged I will backport for RHEL 7, if necessary.

Comment 3 Stefan Hajnoczi 2013-03-13 14:41:30 UTC
Fixed upstream, will be available in QEMU 1.5.

commit 7d81c1413c9c9bdcc966453636e4ca7776b59861
Author: Stefan Hajnoczi <stefanha>
Date:   Wed Feb 13 16:53:43 2013 +0100

    block: refuse negative iops and bps values

Comment 4 Sibiao Luo 2013-05-24 01:59:00 UTC
Reproduce this issue on qemu-kvm-1.4.0-4.el7, it can boot guest with specifying iops,bps as negative value.
host info:
kernel-3.9.0-0.55.el7.x86_64
qemu-kvm-1.4.0-4.el7

Steps:
e.g:...-drive file=/mnt/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,readonly=on,cache=none,aio=native,werror=stop,rerror=stop,bps=-102400000,iops=-100000 -device virtio-blk-pci,bus=pcie.0,addr=0x7,drive=drive-data-disk,id=data-disk

Results:
it can boot guest with specifying iops,bps as negative value.
(qemu) info block
drive-system-disk: removable=0 io-status=ok file=/mnt/RHEL-7.0-20130403.0_x86_64.qcow3bk ro=0 drv=qcow2 encrypted=0 bps=0 bps_rd=0 bps_wr=0 iops=0 iops_rd=0 iops_wr=0
drive-data-disk: removable=0 io-status=ok file=/mnt/my-data-disk.qcow2 ro=1 drv=qcow2 encrypted=0 bps=-102400000 bps_rd=0 bps_wr=0 iops=-100000 iops_rd=0 iops_wr=0

Verify this issue on qemu-kvm-1.5.0-1.el7.x86_64.
hot info:
kernel-3.9.0-0.55.el7.x86_64
qemu-kvm-1.5.0-1.el7.x86_64
guest info:
kernel-3.9.0-0.55.el7.x86_64
Result:
It fail to boot guest with specifying iops,bps as negative value, and qemu give a friendly reminds.
qemu-kvm: -drive file=/mnt/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,readonly=on,cache=none,aio=native,werror=stop,rerror=stop,bps=-102400000,iops=-100000: bps and iops values must be 0 or greater

Base on above, this issue has been fixed successfully.

Comment 7 Ludek Smid 2014-06-13 11:46:13 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.