Bug 890024 - Guest should failed to be booted if specifying iops,bps as negative value
Guest should failed to be booted if specifying iops,bps as negative value
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
7.0
Unspecified Unspecified
low Severity low
: rc
: ---
Assigned To: Stefan Hajnoczi
Virtualization Bugs
: FutureFeature
Depends On:
Blocks: 987725
  Show dependency treegraph
 
Reported: 2012-12-24 07:00 EST by juzhang
Modified: 2014-06-17 23:19 EDT (History)
8 users (show)

See Also:
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 07:46:13 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description juzhang 2012-12-24 07:00:58 EST
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 04:32:13 EST
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 11:12:28 EST
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 10:41:30 EDT
Fixed upstream, will be available in QEMU 1.5.

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

    block: refuse negative iops and bps values
Comment 4 Sibiao Luo 2013-05-23 21:59:00 EDT
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 07:46:13 EDT
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.

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