qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Supriya Kannery <supriyak@in.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Christoph Hellwig <hch@lst.de>,
	Supriya Kannery <supriyak@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic block params change
Date: Thu, 28 Jul 2011 07:48:38 -0500	[thread overview]
Message-ID: <4E315AA6.4070803@codemonkey.ws> (raw)
In-Reply-To: <4E31365F.2000904@in.ibm.com>

On 07/28/2011 05:13 AM, Supriya Kannery wrote:
> On 07/27/2011 09:32 PM, Anthony Liguori wrote:
>> On 07/27/2011 09:31 AM, Stefan Hajnoczi wrote:
>>> On Wed, Jul 27, 2011 at 1:58 PM, Anthony
>>> Liguori<anthony@codemonkey.ws> wrote:
>>>>> Index: qemu/hmp-commands.hx
>>>>> ===================================================================
>>>>> --- qemu.orig/hmp-commands.hx
>>>>> +++ qemu/hmp-commands.hx
>>>>> @@ -70,6 +70,20 @@ 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,device:O",
>>>>> + .params = "device [prop=value][,...]",
>>>>> + .help = "Change block device parameters
>>>>> [hostcache=on/off]",
>>>>> + .user_print = monitor_user_noop,
>>>>> + .mhandler.cmd_new = do_block_set,
>>>>> + },
>>>>> +STEXI
>>>>> +@item block_set @var{config}
>>>>> +@findex block_set
>>>>> +Change block device parameters (eg: hostcache=on/off) while guest is
>>>>> running.
>>>>> +ETEXI
>>>>> +
>>>>
>>>> block_set_hostcache() please.
>>>>
>>>> Multiplexing commands is generally a bad idea. It weakens typing. In
>>>> the
>>>> absence of a generic way to set block device properties, implementing
>>>> properties as generic in the QMP layer seems like a bad idea to me.
>>>
>>> The idea behind block_set was to have a unified interface for changing
>>> block device parameters at runtime. This prevents us from reinventing
>>> new commands from scratch. For example, block I/O throttling is
>>> already queued up to add run-time parameters.
>>>
>>> Without a unified command we have a bulkier QMP/HMP interface,
>>> duplicated code, and possibly inconsistencies in syntax between the
>>> commands. Isn't the best way to avoid these problems a unified
>>> interface?
>>>
>>> I understand the lack of type safety concern but in this case we
>>> already have to manually pull parsed arguments (i.e. cast to specific
>>> types and deal with invalid input). To me this is a reason *for*
>>> using a unified interface like block_set.
>>
>> Think about it from a client perspective. How do I determine which
>> properties are supported by this version of QEMU? I have no way to
>> identify programmatically what arguments are valid for block_set.
>>
>
> User can programmatically find out valid parameters for
> block_set. Internally, validation of prop=value is done against -drive
> parameter list and then, only the valid/implemented commands (for now,
> hostcache) are accepted from that list. Please find execution output
> attached:
> ========================================================================
> (qemu) info block
> ide0-hd0: removable=0 hostcache=1 file=../rhel6-32.qcow2 ro=0 drv=qcow2
> encrypted=0
> floppy0: removable=1 locked=0 hostcache=0 file=test.img ro=0 drv=raw
> encrypted=0
> ide1-cd0: removable=1 locked=0 hostcache=1 [not inserted]
> sd0: removable=1 locked=0 hostcache=1 [not inserted]
> (qemu) block
> block_resize block_set block_passwd
> (qemu) block_set

That's HMP btw, not QMP.

> block_set: block device name expected
> (qemu) block
> block_resize block_set block_passwd
> (qemu) help block_set
> block_set device [prop=value][,...] -- Change block device parameters
> [hostcache=on/off]

Parsing help text is not introspection!

Regards,

Anthony Liguori

> (qemu) block_set ide
> Device 'ide' not found
> (qemu) block_set ide0-hd0
> Usage: block_set device [prop=value][,...]
> (qemu) block_set ide0-hd0 cache
> Invalid parameter 'cache'
> (qemu) block_set ide0-hd0 cache=on
> Parameter 'hostcache' expects on/off
> (qemu) block_set ide0-hd0 hostcache=on
> (qemu) block_set ide0-hd0 hostcache=off
> (qemu) info block
> ide0-hd0: removable=0 hostcache=0 file=../rhel6-32.qcow2 ro=0 drv=qcow2
> encrypted=0
> floppy0: removable=1 locked=0 hostcache=0 file=test.img ro=0 drv=raw
> encrypted=0
> ide1-cd0: removable=1 locked=0 hostcache=1 [not inserted]
> sd0: removable=1 locked=0 hostcache=1 [not inserted]
> ========================================================================
>
> When we add further parameters, "usage" string can be enhanced to
> include those parameters for informing user.
>
> - Thanks, Supriya
>
>> OTOH, if you have strong types like block_set_hostcache, query-commands
>> tells me exactly what's supported.
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>>
>>> Stefan
>>>
>>
>>
>
>

  reply	other threads:[~2011-07-28 12:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27 11:30 [Qemu-devel] [V5 Patch 0/4]Qemu: Set host cache from cmdline and monitor Supriya Kannery
2011-07-27 11:30 ` [Qemu-devel] [V5 Patch 1/4]Qemu: Enhance "info block" to display host cache setting Supriya Kannery
2011-07-27 14:19   ` Stefan Hajnoczi
2011-07-28 10:39     ` Supriya Kannery
2011-07-27 11:30 ` [Qemu-devel] [V5 Patch 2/4]Qemu: qerrors for file reopen, data sync and cmd syntax Supriya Kannery
2011-07-27 11:30 ` [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic block params change Supriya Kannery
2011-07-27 12:58   ` Anthony Liguori
2011-07-27 14:31     ` Stefan Hajnoczi
2011-07-27 16:02       ` Anthony Liguori
2011-07-28  9:29         ` Stefan Hajnoczi
2011-08-01 15:22           ` Stefan Hajnoczi
2011-08-01 15:28             ` Anthony Liguori
2011-08-01 15:34               ` Stefan Hajnoczi
2011-08-01 15:44               ` Kevin Wolf
2011-08-01 15:44                 ` Anthony Liguori
2011-08-04  8:32                   ` Supriya Kannery
2011-08-04  8:31                     ` Stefan Hajnoczi
2011-08-04  9:33                       ` Supriya Kannery
2011-08-04  9:17                     ` Supriya Kannery
2011-08-01 15:44                 ` Stefan Hajnoczi
2011-08-01 15:46                   ` Anthony Liguori
2011-07-28 10:13         ` Supriya Kannery
2011-07-28 12:48           ` Anthony Liguori [this message]
2011-07-27 13:43   ` Michael Tokarev
2011-07-27 13:52     ` Anthony Liguori
2011-07-27 14:51     ` Stefan Hajnoczi
2011-07-28 10:23       ` Kevin Wolf
2011-07-28 13:10         ` Stefan Hajnoczi
2011-07-28 13:23           ` Kevin Wolf
2011-07-27 11:31 ` [Qemu-devel] [V5 Patch 4/4]Qemu: Add commandline -drive option 'hostcache' Supriya Kannery

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=4E315AA6.4070803@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=hch@lst.de \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=supriyak@in.ibm.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).