From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqmKo-00024o-Vj for qemu-devel@nongnu.org; Tue, 09 Aug 2011 09:27:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqmKd-0003os-Sr for qemu-devel@nongnu.org; Tue, 09 Aug 2011 09:27:05 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:35649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqmKd-0003dC-9S for qemu-devel@nongnu.org; Tue, 09 Aug 2011 09:26:55 -0400 Received: by gwb19 with SMTP id 19so2312969gwb.4 for ; Tue, 09 Aug 2011 06:26:31 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1312863472-6901-2-git-send-email-wuzhy@linux.vnet.ibm.com> References: <1312863472-6901-1-git-send-email-wuzhy@linux.vnet.ibm.com> <1312863472-6901-2-git-send-email-wuzhy@linux.vnet.ibm.com> Date: Tue, 9 Aug 2011 13:25:24 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 1/4] block: add the command line support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zhi Yong Wu Cc: kwolf@redhat.com, pair@us.ibm.com, stefanha@linux.vnet.ibm.com, kvm@vger.kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, zwu.kernel@gmail.com, ryanh@us.ibm.com, luowenj@cn.ibm.com On Tue, Aug 9, 2011 at 5:17 AM, Zhi Yong Wu wrot= e: > Signed-off-by: Zhi Yong Wu > --- > =A0Makefile.objs =A0 | =A0 =A02 +- > =A0blockdev.c =A0 =A0 =A0| =A0 39 +++++++++++++++++++++++++++++++++++++++ > =A0qemu-config.c =A0 | =A0 24 ++++++++++++++++++++++++ > =A0qemu-option.c =A0 | =A0 17 +++++++++++++++++ > =A0qemu-option.h =A0 | =A0 =A01 + > =A0qemu-options.hx | =A0 =A01 + > =A06 files changed, 83 insertions(+), 1 deletions(-) > > diff --git a/Makefile.objs b/Makefile.objs > index 9f99ed4..06f2033 100644 > --- a/Makefile.objs > +++ b/Makefile.objs > @@ -23,7 +23,7 @@ block-nested-y +=3D raw.o cow.o qcow.o vdi.o vmdk.o clo= op.o dmg.o bochs.o vpc.o vv > =A0block-nested-y +=3D qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-sna= pshot.o qcow2-cache.o > =A0block-nested-y +=3D qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-c= luster.o > =A0block-nested-y +=3D qed-check.o > -block-nested-y +=3D parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o > +block-nested-y +=3D parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o = blk-queue.o This does not build: LINK qemu-ga gcc: error: block/blk-queue.o: No such file or directory This Makefile.objs change should be in the commit that adds blk-queue.c. Each patch in a series should compile cleanly and can only depend on previous patches. This is important so that git-bisect(1) can be used, it only works if every commit builds a working program. It also makes patch review easier when the patch series builds up logically. > =A0block-nested-$(CONFIG_WIN32) +=3D raw-win32.o > =A0block-nested-$(CONFIG_POSIX) +=3D raw-posix.o > =A0block-nested-$(CONFIG_CURL) +=3D curl.o > diff --git a/blockdev.c b/blockdev.c > index c263663..9c78548 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -238,6 +238,10 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to= _scsi) > =A0 =A0 int on_read_error, on_write_error; > =A0 =A0 const char *devaddr; > =A0 =A0 DriveInfo *dinfo; > + =A0 =A0BlockIOLimit io_limits; This structure is not undefined at this point in the patch series. > + =A0 =A0bool iol_flag =3D false; > + =A0 =A0const char *iol_opts[7] =3D {"bps", "bps_rd", "bps_wr", > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"iops", = "iops_rd", "iops_wr"}; > =A0 =A0 int is_extboot =3D 0; > =A0 =A0 int snapshot =3D 0; > =A0 =A0 int ret; > @@ -372,6 +376,36 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to= _scsi) > =A0 =A0 =A0 =A0 return NULL; > =A0 =A0 } > > + =A0 =A0/* disk io throttling */ > + =A0 =A0iol_flag =3D qemu_opt_io_limits_enable_flag(opts, iol_opts); > + =A0 =A0if (iol_flag) { > + =A0 =A0 =A0 =A0memset(&io_limits, 0, sizeof(BlockIOLimit)); > + > + =A0 =A0 =A0 =A0io_limits.bps[BLOCK_IO_LIMIT_TOTAL] =A0=3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "bps", 0); > + =A0 =A0 =A0 =A0io_limits.bps[BLOCK_IO_LIMIT_READ] =A0 =3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "bps_rd", 0); > + =A0 =A0 =A0 =A0io_limits.bps[BLOCK_IO_LIMIT_WRITE] =A0=3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "bps_wr", 0); > + =A0 =A0 =A0 =A0io_limits.iops[BLOCK_IO_LIMIT_TOTAL] =3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "iops", 0); > + =A0 =A0 =A0 =A0io_limits.iops[BLOCK_IO_LIMIT_READ] =A0=3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "iops_rd", 0); > + =A0 =A0 =A0 =A0io_limits.iops[BLOCK_IO_LIMIT_WRITE] =3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 qemu_opt_get_number= (opts, "iops_wr", 0); > + > + =A0 =A0 =A0 =A0if (((io_limits.bps[BLOCK_IO_LIMIT_TOTAL] !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0&& ((io_limits.bps[BLOCK_IO_LIMIT_READ] !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0|| (io_limits.bps[BLOCK_IO_LIMIT_WRITE] !=3D 0))= ) > + =A0 =A0 =A0 =A0 =A0 =A0|| ((io_limits.iops[BLOCK_IO_LIMIT_TOTAL] !=3D 0= ) > + =A0 =A0 =A0 =A0 =A0 =A0&& ((io_limits.iops[BLOCK_IO_LIMIT_READ] !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0|| (io_limits.iops[BLOCK_IO_LIMIT_WRITE] !=3D 0)= ))) { > + =A0 =A0 =A0 =A0 =A0 =A0error_report("bps(iops) and bps_rd/bps_wr(iops_r= d/iops_wr) \ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0cannot be used at the same time"); > + =A0 =A0 =A0 =A0 =A0 =A0return NULL; > + =A0 =A0 =A0 =A0} > + =A0 =A0} > + > =A0 =A0 on_write_error =3D BLOCK_ERR_STOP_ENOSPC; > =A0 =A0 if ((buf =3D qemu_opt_get(opts, "werror")) !=3D NULL) { > =A0 =A0 =A0 =A0 if (type !=3D IF_IDE && type !=3D IF_SCSI && type !=3D IF= _VIRTIO && type !=3D IF_NONE) { > @@ -483,6 +517,11 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to= _scsi) > > =A0 =A0 bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); > > + =A0 =A0/* disk I/O throttling */ > + =A0 =A0if (iol_flag) { > + =A0 =A0 =A0 =A0bdrv_set_io_limits(dinfo->bdrv, &io_limits); > + =A0 =A0} iol_flag and qemu_opt_io_limits_enable_flag() are not necessary. If no limits were set then all fields will be 0 (unlimited). Stefan