From: Jeff Cody <jcody@redhat.com>
To: supriyak@linux.vnet.ibm.com
Cc: Kevin Wolf <kwolf@redhat.com>,
Shrinidhi Joshi <spjoshi31@gmail.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [Qemu-devel] [v2 Patch 8/9]block: Cmd "block_set_hostcache" for dynamic cache change
Date: Fri, 31 Aug 2012 15:32:00 -0400 [thread overview]
Message-ID: <50411130.3020707@redhat.com> (raw)
In-Reply-To: <5019791F.1000103@linux.vnet.ibm.com>
On 08/01/2012 02:44 PM, Supriya Kannery wrote:
> New command "block_set_hostcache" added for dynamically changing
> host pagecache setting of a block device.
>
> Usage:
> block_set_hostcache <device> <option>
> <device> = block device
> <option> = on/off
>
> Example:
> (qemu) block_set_hostcache ide0-hd0 off
>
> Signed-off-by: Supriya Kannery <supriyak@linux.vnet.ibm.com>
>
> ---
> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c
> +++ qemu/block.c
> @@ -970,6 +970,30 @@ void bdrv_close_all(void)
> }
> }
>
> +void bdrv_change_hostcache(BlockDriverState *bs, bool enable, Error **errp)
> +{
> + int bdrv_flags = bs->open_flags;
> +
> + /* set hostcache flags (without changing WCE/flush bits) */
> + if (enable) {
> + bdrv_flags &= ~BDRV_O_NOCACHE;
> + } else {
> + bdrv_flags |= BDRV_O_NOCACHE;
> + }
> +
> + /* If no change in flags, no need to reopen */
> + if (bdrv_flags != bs->open_flags) {
> + if (bdrv_is_inserted(bs)) {
> + /* Reopen file with changed set of flags */
> + bdrv_flags &= ~BDRV_O_CACHE_WB;
> + bdrv_reopen(bs, bdrv_flags, errp);
> + } else {
> + /* Save hostcache change for future use */
> + bs->open_flags = bdrv_flags;
> + }
> + }
> +}
> +
BDRV_O_CACHE_WB is cleared here, and it never gets set again. Is that
intentional?
> /*
> * Wait for pending requests to complete across all BlockDriverStates
> *
> Index: qemu/blockdev.c
> ===================================================================
> --- qemu.orig/blockdev.c
> +++ qemu/blockdev.c
> @@ -1191,3 +1191,22 @@ BlockJobInfoList *qmp_query_block_jobs(E
> bdrv_iterate(do_qmp_query_block_jobs_one, &prev);
> return dummy.next;
> }
> +
> +/*
> + * Change host page cache setting while guest is running.
> +*/
> +void qmp_block_set_hostcache(const char *device, bool enable,
> + Error **errp)
> +{
> + BlockDriverState *bs = NULL;
> +
> + /* Validate device */
> + bs = bdrv_find(device);
> + if (!bs) {
> + error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> + return;
> + }
> +
> + bdrv_change_hostcache(bs, enable, errp);
> + return;
> +}
> Index: qemu/hmp-commands.hx
> ===================================================================
> --- qemu.orig/hmp-commands.hx
> +++ qemu/hmp-commands.hx
> @@ -1344,6 +1344,21 @@ passed since 1970, i.e. unix epoch.
> ETEXI
>
> {
> + .name = "block_set_hostcache",
> + .args_type = "device:B,option:b",
> + .params = "device on|off",
> + .help = "Change setting of host pagecache",
> + .mhandler.cmd = hmp_block_set_hostcache,
> + },
> +
> +STEXI
> +@item block_set_hostcache @var{device} @var{option}
> +@findex block_set_hostcache
> +Change host pagecache setting of a block device while guest is running.
> +ETEXI
> +
> +
> + {
> .name = "info",
> .args_type = "item:s?",
> .params = "[subcommand]",
> Index: qemu/qmp-commands.hx
> ===================================================================
> --- qemu.orig/qmp-commands.hx
> +++ qemu/qmp-commands.hx
> @@ -987,6 +987,30 @@ Example:
> EQMP
>
> {
> + .name = "block_set_hostcache",
> + .args_type = "device:B,option:b",
> + .mhandler.cmd_new = qmp_marshal_input_block_set_hostcache,
> + },
> +
> +SQMP
> +block_set_hostcache
> +-------------------
> +
> +Change host pagecache setting of a block device
> +
> +Arguments:
> +
> +- "device": the device's ID, must be unique (json-string)
> +- "option": hostcache setting (json-bool)
> +
> +Example:
> +-> { +"execute": "block_set_hostcache", "arguments": { "device": "ide0-hd0", "option": false } }
> +<- { "return": {} }
> +
> +EQMP
> +
> +
> + {
> .name = "set_password",
> .args_type = "protocol:s,password:s,connected:s?",
> .mhandler.cmd_new = qmp_marshal_input_set_password,
> Index: qemu/qapi-schema.json
> ===================================================================
> --- qemu.orig/qapi-schema.json
> +++ qemu/qapi-schema.json
> @@ -1604,6 +1604,23 @@
> 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int' } }
>
> ##
> +# @block_set_hostcache:
> +#
> +# Change host pagecache setting of a block device
> +#
> +# @device: name of the block device
> +#
> +# @option: hostcache setting (true/false)
> +#
> +# Returns: Nothing on success
> +# If @device is not a valid block device, DeviceNotFound
> +#
> +# Since: 1.2
> +##
> +{ 'command': 'block_set_hostcache',
> + 'data': { 'device': 'str', 'option': 'bool' } }
> +
> +##
> # @block-stream:
> #
> # Copy data from a backing file into a block device.
> Index: qemu/hmp.c
> ===================================================================
> --- qemu.orig/hmp.c
> +++ qemu/hmp.c
> @@ -837,6 +837,15 @@ void hmp_block_set_io_throttle(Monitor *
> hmp_handle_error(mon, &err);
> }
>
> +void hmp_block_set_hostcache(Monitor *mon, const QDict *qdict)
> +{
> + Error *err = NULL;
> +
> + qmp_block_set_hostcache(qdict_get_str(qdict, "device"),
> + qdict_get_bool(qdict, "option"), &err);
> + hmp_handle_error(mon, &err);
> +}
> +
> void hmp_block_stream(Monitor *mon, const QDict *qdict)
> {
> Error *error = NULL;
> Index: qemu/hmp.h
> ===================================================================
> --- qemu.orig/hmp.h
> +++ qemu/hmp.h
> @@ -66,5 +66,6 @@ void hmp_netdev_add(Monitor *mon, const
> void hmp_netdev_del(Monitor *mon, const QDict *qdict);
> void hmp_getfd(Monitor *mon, const QDict *qdict);
> void hmp_closefd(Monitor *mon, const QDict *qdict);
> +void hmp_block_set_hostcache(Monitor *mon, const QDict *qdict);
>
> #endif
> Index: qemu/block.h
> ===================================================================
> --- qemu.orig/block.h
> +++ qemu/block.h
> @@ -187,6 +187,7 @@ int bdrv_commit_all(void);
> int bdrv_change_backing_file(BlockDriverState *bs,
> const char *backing_file, const char *backing_fmt);
> void bdrv_register(BlockDriver *bdrv);
> +void bdrv_change_hostcache(BlockDriverState *bs, bool enable, Error **errp);
>
>
> typedef struct BdrvCheckResult {
>
>
next prev parent reply other threads:[~2012-08-31 19:32 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 21:34 [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Supriya Kannery
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 1/9]block: Framework for reopening image files safely Supriya Kannery
2012-08-01 15:51 ` Stefan Hajnoczi
2012-08-02 20:19 ` Luiz Capitulino
2012-08-14 8:54 ` Supriya Kannery
2012-08-08 21:13 ` Jeff Cody
2012-08-14 9:21 ` Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-09 9:20 ` Kevin Wolf
2012-08-09 13:02 ` Jeff Cody
2012-08-14 10:24 ` Supriya Kannery
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 2/9]block: raw-posix image file reopen Supriya Kannery
2012-07-31 17:17 ` Eric Blake
2012-08-01 6:18 ` Kevin Wolf
2012-08-03 22:32 ` Jeff Cody
2012-08-14 10:53 ` Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-10 13:45 ` Corey Bryant
2012-08-14 11:13 ` Supriya Kannery
2012-08-14 11:35 ` Kevin Wolf
2012-07-30 21:34 ` [Qemu-devel] [v2 Patch 3/9]block: raw-win32 " Supriya Kannery
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 4/9]block: vmdk " Supriya Kannery
2012-07-31 17:43 ` Eric Blake
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 5/9]block: qcow2 " Supriya Kannery
2012-08-09 4:26 ` Jeff Cody
2012-08-09 9:37 ` Kevin Wolf
2012-07-30 21:35 ` [Qemu-devel] [v2 Patch 7/9]block: qed " Supriya Kannery
2012-07-30 21:36 ` [Qemu-devel] [v2 Patch 9/9]block: Enhance "info block" to display host cache setting Supriya Kannery
2012-07-31 17:47 ` Eric Blake
2012-07-31 20:33 ` [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Jeff Cody
2012-08-01 17:11 ` Supriya Kannery
2012-08-01 18:36 ` [Qemu-devel] [v2 Patch 6/9]block: qcow image file reopen Supriya Kannery
2012-08-01 18:44 ` [Qemu-devel] [v2 Patch 8/9]block: Cmd "block_set_hostcache" for dynamic cache change Supriya Kannery
2012-08-01 19:21 ` Eric Blake
2012-08-02 20:36 ` Luiz Capitulino
2012-08-31 19:32 ` Jeff Cody [this message]
2012-08-09 4:26 ` [Qemu-devel] [v2 Patch 0/9]block: Image file reopen and dynamic host pagecache change Jeff Cody
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50411130.3020707@redhat.com \
--to=jcody@redhat.com \
--cc=hch@lst.de \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=spjoshi31@gmail.com \
--cc=stefanha@gmail.com \
--cc=supriyak@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).