From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdiH6-0001qm-Cd for qemu-devel@nongnu.org; Mon, 04 Jul 2011 08:29:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdiH4-0006SK-Jo for qemu-devel@nongnu.org; Mon, 04 Jul 2011 08:29:16 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:56912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdiH4-0006SC-6f for qemu-devel@nongnu.org; Mon, 04 Jul 2011 08:29:14 -0400 Received: by gyf2 with SMTP id 2so221609gyf.4 for ; Mon, 04 Jul 2011 05:29:13 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20110704104320.28170.29248.sendpatchset@skannery> References: <20110704104237.28170.97021.sendpatchset@skannery> <20110704104320.28170.29248.sendpatchset@skannery> Date: Mon, 4 Jul 2011 13:29:13 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [V4 Patch 3/4]Qemu: Command "block_set" for dynamic block params change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Supriya Kannery Cc: Kevin Wolf , qemu-devel@nongnu.org, Christoph Hellwig On Mon, Jul 4, 2011 at 11:43 AM, Supriya Kannery wrote: > +/* > + * Handle changes to block device settings, like hostcache, > + * while guest is running. > +*/ > +int do_block_set(Monitor *mon, const QDict *qdict, QObject **ret_data) > +{ > + =A0 =A0const char *device =3D qdict_get_str(qdict, "device"); > + =A0 =A0const char *name =3D qdict_get_str(qdict, "name"); > + =A0 =A0int enable =3D qdict_get_bool(qdict, "enable"); > + =A0 =A0BlockDriverState *bs; > + > + =A0 =A0bs =3D bdrv_find(device); > + =A0 =A0if (!bs) { > + =A0 =A0 =A0 =A0qerror_report(QERR_DEVICE_NOT_FOUND, device); > + =A0 =A0 =A0 =A0return -1; > + =A0 =A0} > + > + =A0 =A0if (!strcmp(name, "hostcache")) { > + =A0 =A0 =A0 =A0return bdrv_change_hostcache(bs, enable); > + =A0 =A0} > + > + =A0 =A0return 0; No error for unknown "name" argument? > =A0#endif > Index: qemu/hmp-commands.hx > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu.orig/hmp-commands.hx > +++ qemu/hmp-commands.hx > @@ -70,6 +70,21 @@ but should be used with extreme caution. > =A0resizes image files, it can not resize block devices like LVM volumes. > =A0ETEXI > > + =A0 =A0{ > + =A0 =A0 =A0 =A0.name =A0 =A0 =A0 =3D "block_set", > + =A0 =A0 =A0 =A0.args_type =A0=3D "device:B,name:s,enable:b", > + =A0 =A0 =A0 =A0.params =A0 =A0 =3D "device name enable", > + =A0 =A0 =A0 =A0.help =A0 =A0 =A0 =3D "On/Off block device parameters li= ke hostcache", > + =A0 =A0 =A0 =A0.user_print =3D monitor_user_noop, > + =A0 =A0 =A0 =A0.mhandler.cmd_new =3D do_block_set, > + =A0 =A0}, > + > +STEXI > +@item block_set > +@findex block_set > +Change block device params (eg:"hostcache"=3Don/off) while guest is runn= ing. > +ETEXI See QMP comments below. > + > > =A0 =A0 { > =A0 =A0 =A0 =A0 .name =A0 =A0 =A0 =3D "eject", > Index: qemu/qmp-commands.hx > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu.orig/qmp-commands.hx > +++ qemu/qmp-commands.hx > @@ -694,6 +694,34 @@ Example: > =A0EQMP > > =A0 =A0 { > + =A0 =A0 =A0 =A0.name =A0 =A0 =A0 =3D "block_set", > + =A0 =A0 =A0 =A0.args_type =A0=3D "device:B,name:s,enable:b", > + =A0 =A0 =A0 =A0.params =A0 =A0 =3D "device name enable", Perhaps: .args_type =A0=3D "device:B,name:s,enable:b?", .params =A0 =A0 =3D "device name [enable]", But I am not sure what the best way to express this is. > + =A0 =A0 =A0 =A0.help =A0 =A0 =A0 =3D "Enable/Disable block device param= s like hostcache", Arguments (like "enable") should depend on the block parameter that is being set: .help =3D "Set block device parameter" If there is no good way to support different optional arguments and types then a json-string "value" argument would be best. > + =A0 =A0 =A0 =A0.user_print =3D monitor_user_noop, > + =A0 =A0 =A0 =A0.mhandler.cmd_new =3D do_block_set, > + =A0 =A0}, > + > +SQMP > +block_set > +--------- > + > +Change various block device parameters like hostcache. > + > +Arguments: > + > +- "device": the device's ID, must be unique (json-string) > +- "name": name of the parameter to be changed" (json-string) Trailing '"'. > +- "enable": value to be set for the parameter, 'true' or 'false' (json-b= ool) The relevant arguments depend on which block parameter you are changing. I think "enable" should be documented specifically for "hostcache": Block parameters: - "hostcache": Enable/disable host buffer cache - "enable": 'true' or 'false' (json-bool) Stefan