[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v2 3/6] qapi: add nbd-server-remove

From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-block] [PATCH v2 3/6] qapi: add nbd-server-remove
Date: Tue, 6 Feb 2018 20:54:54 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

06.02.2018 19:06, Eric Blake wrote:
On 02/06/2018 09:29 AM, Vladimir Sementsov-Ogievskiy wrote:

most of commands, ported to hmp are done in same style: they just call
corresponding qmp command.
Isn't it better to provide common interface for calling qmp commands through
HMP monitor, to never
create hmp versions of new commands? they will be available automatically.
It would be nice to do that, but they're not that consistent in how they
convert parameters and options, but I occasionally wonder if we could
automate more of it.

What about allowing some new syntax in hmp, directly mapped to qmp?

something like

 >>> blockdev-add id disk driver qcow2 cache {writeback true direct true} aio native discard unmap file {driver file filename /tmp/somedisk}

Personally, if I'm testing blockdev-add, I'll use QMP directly (or even scripts/qmp/qmp-shell or virsh qemu-monitor-command), not an HMP wrapper where I have to learn a new syntax of how to write something that will convert to QMP.  We already have enough different ways to write things that I don't need to learn yet another syntax wrapper.  Or maybe what I'm saying is that instead of inventing a new syntax, that if you DO add an HMP command that forwards to QMP, please reuse an existing syntax (whether direct JSON as used by QMP, or the syntax used by qmp-shell).

I'm afraid, that JSON is too hard to use in human monitor. And this will make the whole feature useless.

If you think writing a new HMP command is worth it, I won't stop you from writing it.  But at this point, our current approach of writing a manual wrapper per command as we have interest, rather than a generic wrap-anything, has worked for the cases that HMP users have cared about.  Remember, QMP is the interface that MUST work, while HMP is only for convenience, and if it is not trivial to make HMP do everything that QMP can do, it is no real loss.

But we create hmp wrappers on demand, and for each case, we actually invent new syntax. I just search for the way to avoid creating new and new hmp wrappers, by introducing new syntax only once.
And, here is almost nothing to learn:

command := command-name parameters
parameters = [key value ]...
value = simple-value | array | map
map = '{' parameters '}'
array = '[' [value ]... ']'

another variant is to use yaml - like json, but we do not need put all keys into quotes.

On the other hand, implementing new parser in qemu is not trivial task (hmm, I don't want do it=), it should be simpler to create direct JSON wrapper in HMP monitor, and use some python wrapper around the monitor. And this looks useless, as with same result I can use wrapper around QMP monitor. So, may be the most interesting solution would be to make some easy-to-use python-based wrapper, which will give a simple way to use both qmp and hmp commands.. I'll think about it. However it doesn't solve initial problem of creating new and new hmp wrappers by hand.


Or it may be realized as a separate hmp command "qmp" (looks more safe as a first step, however, I think previous variant (direct call) is better):

 >>> qmp blockdev-add id disk driver qcow2 cache {writeback true direct true} aio native discard unmap file {driver file filename /tmp/somedisk}

what do think? This looks simple to implement and should be useful.

Up to you if you want to tackle anything like that, but it would be a new thread (a generic way to invoke QMP from HMP is independent of nbd-server-remove).

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]