On Mon, Jul 4, 2011 at 11:43 AM, Supriya Kannery <supri...@linux.vnet.ibm.com> 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) > +{ > + const char *device = qdict_get_str(qdict, "device"); > + const char *name = qdict_get_str(qdict, "name"); > + int enable = qdict_get_bool(qdict, "enable"); > + BlockDriverState *bs; > + > + bs = bdrv_find(device); > + if (!bs) { > + qerror_report(QERR_DEVICE_NOT_FOUND, device); > + return -1; > + } > + > + if (!strcmp(name, "hostcache")) { > + return bdrv_change_hostcache(bs, enable); > + } > + > + return 0;
No error for unknown "name" argument? > #endif > Index: qemu/hmp-commands.hx > =================================================================== > --- qemu.orig/hmp-commands.hx > +++ qemu/hmp-commands.hx > @@ -70,6 +70,21 @@ but should be used with extreme caution. > resizes image files, it can not resize block devices like LVM volumes. > ETEXI > > + { > + .name = "block_set", > + .args_type = "device:B,name:s,enable:b", > + .params = "device name enable", > + .help = "On/Off block device parameters like hostcache", > + .user_print = monitor_user_noop, > + .mhandler.cmd_new = do_block_set, > + }, > + > +STEXI > +@item block_set > +@findex block_set > +Change block device params (eg:"hostcache"=on/off) while guest is running. > +ETEXI See QMP comments below. > + > > { > .name = "eject", > Index: qemu/qmp-commands.hx > =================================================================== > --- qemu.orig/qmp-commands.hx > +++ qemu/qmp-commands.hx > @@ -694,6 +694,34 @@ Example: > EQMP > > { > + .name = "block_set", > + .args_type = "device:B,name:s,enable:b", > + .params = "device name enable", Perhaps: .args_type = "device:B,name:s,enable:b?", .params = "device name [enable]", But I am not sure what the best way to express this is. > + .help = "Enable/Disable block device params like hostcache", Arguments (like "enable") should depend on the block parameter that is being set: .help = "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. > + .user_print = monitor_user_noop, > + .mhandler.cmd_new = do_block_set, > + }, > + > +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-bool) 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