All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] QMP design: Fixing query-block and friends
@ 2017-06-27 16:31 Kevin Wolf
  2017-06-27 16:46 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Kevin Wolf @ 2017-06-27 16:31 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, mreitz, armbru, stefanha, eblake

Hi,

I haven't really liked query-block for a long time, but now that
blockdev-add and -blockdev have settled, it might finally be the time to
actually do something about it. In fact, if used together with these
modern interfaces, our query commands are simply broken, so we have to
fix something.

Just for reference, I'll start with a copy of the most important part of
the schema of our current QMP commands here:

> { 'command': 'query-block', 'returns': ['BlockInfo'] }
> 
> { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] }
> 
> { 'struct': 'BlockInfo',
>   'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
>            'locked': 'bool', '*inserted': 'BlockDeviceInfo',
>            '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
>            '*dirty-bitmaps': ['BlockDirtyInfo'] } }
> 
> { 'struct': 'BlockDeviceInfo',
>   'data': { 'file': 'str', '*node-name': 'str', 'ro': 'bool', 'drv': 'str',
>             '*backing_file': 'str', 'backing_file_depth': 'int',
>             'encrypted': 'bool', 'encryption_key_missing': 'bool',
>             'detect_zeroes': 'BlockdevDetectZeroesOptions',
>             'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
>             'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
>             'image': 'ImageInfo',
>             '*bps_max': 'int', '*bps_rd_max': 'int',
>             '*bps_wr_max': 'int', '*iops_max': 'int',
>             '*iops_rd_max': 'int', '*iops_wr_max': 'int',
>             '*bps_max_length': 'int', '*bps_rd_max_length': 'int',
>             '*bps_wr_max_length': 'int', '*iops_max_length': 'int',
>             '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',
>             '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
>             'write_threshold': 'int' } }
> 
> { 'struct': 'ImageInfo',
>   'data': {'filename': 'str', 'format': 'str', '*dirty-flag': 'bool',
>            '*actual-size': 'int', 'virtual-size': 'int',
>            '*cluster-size': 'int', '*encrypted': 'bool', '*compressed': 'bool',
>            '*backing-filename': 'str', '*full-backing-filename': 'str',
>            '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
>            '*backing-image': 'ImageInfo',
>            '*format-specific': 'ImageInfoSpecific' } }
> 
> { 'union': 'ImageInfoSpecific',
>   'data': {
>       'qcow2': 'ImageInfoSpecificQCow2',
>       'vmdk': 'ImageInfoSpecificVmdk',
>       # If we need to add block driver specific parameters for
>       # LUKS in future, then we'll subclass QCryptoBlockInfoLUKS
>       # to define a ImageInfoSpecificLUKS
>       'luks': 'QCryptoBlockInfoLUKS'
>   } }

So what's wrong with this? Quite a few things, let's do a quick review
of the commands:

* query-block only returns BlockBackends that are owned by the monitor
  (i.e. they have a name). This used to be true for all BlockBackends
  that were attached to a guest device, but it's not the case any more:
  We want to use -blockdev/-device only with node names, which means
  that the devices create the BB internally - and they aren't visible in
  query-block any more.

* Even if we included those BBs in query-block, they would be missing
  the connection to their qdev device. The BB should really be
  considered part of the device, and if we had a way to query the state
  of a device, query-block would ideally be included there.

* query-named-block-nodes is a bad name. All block nodes are named these
  days. Which also means that it returns all block nodes, so its output
  becomes rather large and includes a lot of redundant information (as
  you'll see below).

* The good news: BlockInfo contains only fields that actually belong to
  BlockBackends, apart from a @type attribute that always contains the
  string "unknown".

  The bad news: A BlockBackend has a lot more information attached, this
  is by far not a full query command for BlockBackends.

* What is BlockDeviceInfo supposed to be? query-named-block-nodes
  returns it, so you would expect that it's a description of a
  BlockDriverState. But it's not. It's a mix of BB and BDS descriptions.
  The BB part just stays zeroed in query-named-block-nodes.

  In other words, if you do query-block, you'll see I/O limits and
  whether a writeback mode is used. But do query-named-block-nodes and
  look at the root node of the same device and it will always tell you
  that the limits are 0 and writeback is on.

  So BlockDeviceInfo contains many things that should really be in
  BlockInfo. Both together appear to be relatively complete for BBs.

* BlockDeviceInfo doesn't really describe the graph. It gives you the
  backing file name as a special case, but it won't tell you anything
  about other child nodes, and even for backing files it doesn't tell
  you which node is actually used.

  Instead, we should have a description of all attached children with
  the link name, the child node name and probably also the permissions
  attached to it (in other words, a description of BdrvChild).

* BlockDeviceInfo misses important information about nodes. For example,
  I often see a query-block output in bug reports and can't decide from
  it if we were using Linux AIO.

  Ideally it should include the currently active set of options
  (BlockdevOptions) that would result in the same block node. References
  would always be by name, so that this doesn't become recursive.

* Speaking of recursion: ImageInfo recursively includes information
  about all images in the backing chain. This is what makes the output
  of query-named-block-nodes so redundant. It is also inconsistent
  because the runtime information (BlockInfo/BlockDeviceInfo) isn't
  recursive.

* I'm also not quite sure if getting ImageInfo for an image shouldn't be
  a separate operation. It doesn't really seem related to getting the
  runtime state of a block device.

* ImageInfoSpecific exists only for a few drivers and doesn't contain
  all the information it could contain. Similar to what I said about
  BlockDeviceInfo, I think it should contain all the create options that
  you need to create the same image, apart from the data stored in it.

  'qemu-img create' still needs to improve its option handling, too, but
  I imagine that in the end it could be using the same QAPI struct that
  ImageInfo should contain.


So how do we go forward from here?

I guess we could add a few hacks o fix the really urgent things, and
just adding more information is always possible (at the cost of even
more duplication).

However, it appears to me that I dislike so many thing about our current
query commands that I'm tempted to say: Throw it all away and start
over.

If that's what we're going to do, I think I can figure out something
nice for block nodes. That shouldn't be too hard. The only question
would be whether we want a command to query one node or whether we would
keep returning all of them.

I am, however, a bit less confident about BBs. As I said above, I
consider them part of the qdev devices. As far as I know, there is no
high-level infrastructure to query runtime state of devices and qdev
properties are supposed to be read-only. Maybe non-qdev QOM properties
can be used somehow? But QOM isn't really nice to use as you need to
query each property individually.

Another option would be to have a QMP command that takes a qdev ID of a
block device and queries its BB. Or maybe it should stay like
query-block and return an array of all of them, but include the qdev
device name. Actually, maybe query-block can stay as it contains only
two fields that are useless in the new world.


I think this has become long enough now, so any opinions? On anything I
said above, but preferably also about what a new interface should look
like?

Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 16:31 [Qemu-devel] [RFC] QMP design: Fixing query-block and friends Kevin Wolf
@ 2017-06-27 16:46 ` Eric Blake
  2017-06-28  7:10   ` Markus Armbruster
  2017-06-27 18:24 ` [Qemu-devel] [Qemu-block] " John Snow
  2017-06-30 13:01 ` Alberto Garcia
  2 siblings, 1 reply; 13+ messages in thread
From: Eric Blake @ 2017-06-27 16:46 UTC (permalink / raw)
  To: Kevin Wolf, qemu-block; +Cc: qemu-devel, mreitz, armbru, stefanha

[-- Attachment #1: Type: text/plain, Size: 3293 bytes --]

On 06/27/2017 11:31 AM, Kevin Wolf wrote:
> Hi,
> 
> I haven't really liked query-block for a long time, but now that
> blockdev-add and -blockdev have settled, it might finally be the time to
> actually do something about it. In fact, if used together with these
> modern interfaces, our query commands are simply broken, so we have to
> fix something.

Agreed.

> 
> However, it appears to me that I dislike so many thing about our current
> query commands that I'm tempted to say: Throw it all away and start
> over.

I'm somewhat leaning this direction as well. We have to keep the old
commands for a while longer (if we don't want to break existing
clients), but libvirt has definitely felt some of the pain of how many
commands and parsing are required in tandem to reconstruct which BDS
node name to use for setting threshold events.

> 
> If that's what we're going to do, I think I can figure out something
> nice for block nodes. That shouldn't be too hard. The only question
> would be whether we want a command to query one node or whether we would
> keep returning all of them.

The age-old filtering question. It's also plausible to have a single
command, with an optional argument, and which always returns an array:
the full array if the argument was omitted, or an array of one matching
the argument when one was provided.  Adding filtering is an easy patch
on top once it is proven to make life easier for a client, and I'm okay
with a first approach that does not filter.

> 
> I am, however, a bit less confident about BBs. As I said above, I
> consider them part of the qdev devices. As far as I know, there is no
> high-level infrastructure to query runtime state of devices and qdev
> properties are supposed to be read-only. Maybe non-qdev QOM properties
> can be used somehow? But QOM isn't really nice to use as you need to
> query each property individually.
> 
> Another option would be to have a QMP command that takes a qdev ID of a
> block device and queries its BB. Or maybe it should stay like
> query-block and return an array of all of them, but include the qdev
> device name. Actually, maybe query-block can stay as it contains only
> two fields that are useless in the new world.

Being able to query all the devices (with their BB's, and only a name
reference to the top-level BDS in use by the BB), separately from being
able to query all BDS, seems like a reasonable thing.  After all,
sometimes you care about what the guest sees (what devices have a BB),
and sometimes you care about what the host is exposing (what BDS are in
use).

> I think this has become long enough now, so any opinions? On anything I
> said above, but preferably also about what a new interface should look
> like?

Our existing interface is definitely awkward, with lots of redundancy in
some places and missing information in others, and a new interface does
seem like we can do better at designing it right up front rather than
bolting on yet more information to the existing queries (which results
in that much more noise to churn through to get to the desired information).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 16:31 [Qemu-devel] [RFC] QMP design: Fixing query-block and friends Kevin Wolf
  2017-06-27 16:46 ` Eric Blake
@ 2017-06-27 18:24 ` John Snow
  2017-06-28  7:15   ` Markus Armbruster
  2017-07-05 14:53   ` Stefan Hajnoczi
  2017-06-30 13:01 ` Alberto Garcia
  2 siblings, 2 replies; 13+ messages in thread
From: John Snow @ 2017-06-27 18:24 UTC (permalink / raw)
  To: Kevin Wolf, qemu-block; +Cc: armbru, qemu-devel, stefanha, mreitz



On 06/27/2017 12:31 PM, Kevin Wolf wrote:
> Hi,
> 
> I haven't really liked query-block for a long time, but now that
> blockdev-add and -blockdev have settled, it might finally be the time to
> actually do something about it. In fact, if used together with these
> modern interfaces, our query commands are simply broken, so we have to
> fix something.
> 

[...words...]

> 
> So how do we go forward from here?
> 
> I guess we could add a few hacks o fix the really urgent things, and
> just adding more information is always possible (at the cost of even
> more duplication).
> 

I think you've included this suggestion so that you can summarily
dismiss it as foolish.

> However, it appears to me that I dislike so many thing about our current
> query commands that I'm tempted to say: Throw it all away and start
> over.
> 

Inclined to agree. The structure of the block layer has changed so much
in the past few years and this is easily seen by the gap you've outlined
here.

We have to keep the old query commands around for a while as Eric says,
but I worry that they are so wrong and misleading as to be actively harmful.

Maybe there's some hair trigger somewhere that if $NEW_FEATURE_X is used
to configure QEMU in some way, that the old commands can be deprecated
at runtime, such that we can more aggressively force their retirement.

> If that's what we're going to do, I think I can figure out something
> nice for block nodes. That shouldn't be too hard. The only question
> would be whether we want a command to query one node or whether we would
> keep returning all of them.
> 

Personally in favor of allowing filtering, as an option. I don't see why
we couldn't, or why it would be a problem, or worse in any way.

> I am, however, a bit less confident about BBs. As I said above, I
> consider them part of the qdev devices. As far as I know, there is no
> high-level infrastructure to query runtime state of devices and qdev
> properties are supposed to be read-only. Maybe non-qdev QOM properties
> can be used somehow? But QOM isn't really nice to use as you need to
> query each property individually.
> 
> Another option would be to have a QMP command that takes a qdev ID of a
> block device and queries its BB. Or maybe it should stay like
> query-block and return an array of all of them, but include the qdev
> device name. Actually, maybe query-block can stay as it contains only
> two fields that are useless in the new world.
> 
> 
> I think this has become long enough now, so any opinions? On anything I
> said above, but preferably also about what a new interface should look
> like?
> 

Sadly (for you, if you want advice) you're probably in the best shape to
decide such a thing. I like the idea of being able to query parts of the
tree on a per-device basis, as I think this likely reflects real world
usage the most.

"I want to do a thing to /dev/sda... what are the backends I am dealing
with for that?"

I think that's probably most along the "QMP command that takes a qdev
ID" option that you proposed.

> Kevin
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 16:46 ` Eric Blake
@ 2017-06-28  7:10   ` Markus Armbruster
  2017-06-28 10:06     ` Kevin Wolf
  0 siblings, 1 reply; 13+ messages in thread
From: Markus Armbruster @ 2017-06-28  7:10 UTC (permalink / raw)
  To: Eric Blake; +Cc: Kevin Wolf, qemu-block, qemu-devel, stefanha, mreitz

Eric Blake <eblake@redhat.com> writes:

> On 06/27/2017 11:31 AM, Kevin Wolf wrote:
>> Hi,
>> 
>> I haven't really liked query-block for a long time, but now that
>> blockdev-add and -blockdev have settled, it might finally be the time to
>> actually do something about it. In fact, if used together with these
>> modern interfaces, our query commands are simply broken, so we have to
>> fix something.
>
> Agreed.
>
[Analysis of what we have; it's a sad mess...]
>> 
>> However, it appears to me that I dislike so many thing about our current
>> query commands that I'm tempted to say: Throw it all away and start
>> over.
>
> I'm somewhat leaning this direction as well. We have to keep the old
> commands for a while longer (if we don't want to break existing
> clients), but libvirt has definitely felt some of the pain of how many
> commands and parsing are required in tandem to reconstruct which BDS
> node name to use for setting threshold events.
>
>> 
>> If that's what we're going to do, I think I can figure out something
>> nice for block nodes. That shouldn't be too hard. The only question
>> would be whether we want a command to query one node or whether we would
>> keep returning all of them.
>
> The age-old filtering question. It's also plausible to have a single
> command, with an optional argument, and which always returns an array:
> the full array if the argument was omitted, or an array of one matching
> the argument when one was provided.  Adding filtering is an easy patch
> on top once it is proven to make life easier for a client, and I'm okay
> with a first approach that does not filter.

The graph may change.  Querying node by node would have to cope with
changes somehow, which I'd expect to be complex and fragile.  I think we
really need a way to get a complete, consistent graph.  So let's
implement that first.  If we still want server-side filtering once
that's done, we can add some on top.

As usual, I doubt we really need server-side filtering, and I dislike
the interface complexity it brings.

>> I am, however, a bit less confident about BBs. As I said above, I
>> consider them part of the qdev devices.

They weren't meant to be when I created them, but I guess it's what they
evolved to be.

>>                                         As far as I know, there is no
>> high-level infrastructure to query runtime state of devices and qdev
>> properties are supposed to be read-only. Maybe non-qdev QOM properties
>> can be used somehow?

Since qdev properties are implemented as QOM property, there are no
non-qdev QOM properties.

>>                      But QOM isn't really nice to use as you need to
>> query each property individually.

qom-get returns 'any'.  A read-only property with a complex value is
already possible.  But it's awkward when you also want to get or set
parts of the complex value.

Perhaps we could provide a way to get whole containers in addition to
single properties.  Would that do?

>> Another option would be to have a QMP command that takes a qdev ID of a
>> block device and queries its BB. Or maybe it should stay like
>> query-block and return an array of all of them, but include the qdev
>> device name. Actually, maybe query-block can stay as it contains only
>> two fields that are useless in the new world.
>
> Being able to query all the devices (with their BB's, and only a name
> reference to the top-level BDS in use by the BB), separately from being
> able to query all BDS, seems like a reasonable thing.  After all,
> sometimes you care about what the guest sees (what devices have a BB),
> and sometimes you care about what the host is exposing (what BDS are in
> use).

No argument.  But let's not focus narrowly on block devices, or even
devices.  If QOM "isn't really nice" for block devices, it probably
isn't nice for lots of other things.  If we can address that at the QOM
level, we should.

>> I think this has become long enough now, so any opinions? On anything I
>> said above, but preferably also about what a new interface should look
>> like?
>
> Our existing interface is definitely awkward, with lots of redundancy in
> some places and missing information in others, and a new interface does
> seem like we can do better at designing it right up front rather than
> bolting on yet more information to the existing queries (which results
> in that much more noise to churn through to get to the desired information).

Replacing an interface that could be evolved to serve is a mistake.

Not replacing an interface when it has reached its design limits is also
a mistake.

I normally advise against the first mistake.  But in this case, I think
we have to avoid the second.  The interface has evolved into a confusing
mess.  The gap between how the interface presents the block layer and
how it actually works has become too large.  Sufficiently sophisticated
clients have to bridge the gap somehow, and that's painful.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 18:24 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2017-06-28  7:15   ` Markus Armbruster
  2017-06-28 16:00     ` John Snow
  2017-07-05 14:53   ` Stefan Hajnoczi
  1 sibling, 1 reply; 13+ messages in thread
From: Markus Armbruster @ 2017-06-28  7:15 UTC (permalink / raw)
  To: John Snow; +Cc: Kevin Wolf, qemu-block, mreitz, stefanha, qemu-devel

John Snow <jsnow@redhat.com> writes:

> On 06/27/2017 12:31 PM, Kevin Wolf wrote:
>> Hi,
>> 
>> I haven't really liked query-block for a long time, but now that
>> blockdev-add and -blockdev have settled, it might finally be the time to
>> actually do something about it. In fact, if used together with these
>> modern interfaces, our query commands are simply broken, so we have to
>> fix something.
>> 
>
> [...words...]
>
>> 
>> So how do we go forward from here?
>> 
>> I guess we could add a few hacks o fix the really urgent things, and
>> just adding more information is always possible (at the cost of even
>> more duplication).
>> 
>
> I think you've included this suggestion so that you can summarily
> dismiss it as foolish.
>
>> However, it appears to me that I dislike so many thing about our current
>> query commands that I'm tempted to say: Throw it all away and start
>> over.
>> 
>
> Inclined to agree. The structure of the block layer has changed so much
> in the past few years and this is easily seen by the gap you've outlined
> here.
>
> We have to keep the old query commands around for a while as Eric says,
> but I worry that they are so wrong and misleading as to be actively harmful.
>
> Maybe there's some hair trigger somewhere that if $NEW_FEATURE_X is used
> to configure QEMU in some way, that the old commands can be deprecated
> at runtime, such that we can more aggressively force their retirement.

We warn on use of deprecated command line and HMP features.  I think we
want the same for QMP, within QMP.

[...]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [RFC] QMP design: Fixing query-block and friends
  2017-06-28  7:10   ` Markus Armbruster
@ 2017-06-28 10:06     ` Kevin Wolf
  2017-06-28 11:59       ` Markus Armbruster
  0 siblings, 1 reply; 13+ messages in thread
From: Kevin Wolf @ 2017-06-28 10:06 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Eric Blake, qemu-block, qemu-devel, stefanha, mreitz

Am 28.06.2017 um 09:10 hat Markus Armbruster geschrieben:
> Eric Blake <eblake@redhat.com> writes:
> > On 06/27/2017 11:31 AM, Kevin Wolf wrote:
> >> If that's what we're going to do, I think I can figure out something
> >> nice for block nodes. That shouldn't be too hard. The only question
> >> would be whether we want a command to query one node or whether we would
> >> keep returning all of them.
> >
> > The age-old filtering question. It's also plausible to have a single
> > command, with an optional argument, and which always returns an array:
> > the full array if the argument was omitted, or an array of one matching
> > the argument when one was provided.  Adding filtering is an easy patch
> > on top once it is proven to make life easier for a client, and I'm okay
> > with a first approach that does not filter.
> 
> The graph may change.  Querying node by node would have to cope with
> changes somehow, which I'd expect to be complex and fragile.  I think we
> really need a way to get a complete, consistent graph.  So let's
> implement that first.  If we still want server-side filtering once
> that's done, we can add some on top.
> 
> As usual, I doubt we really need server-side filtering, and I dislike
> the interface complexity it brings.

I didn't really think of it as filtering. Every other operation is done
on a single object, so querying a single object would be the natural
extension. I mean, we also don't consider it "filtering" that we have
many separate query commands instead of a 'query-qemu-state'.

But you have a good point with the necessary atomicity, so we'll return
everything at once.

> >> I am, however, a bit less confident about BBs. As I said above, I
> >> consider them part of the qdev devices.
> 
> They weren't meant to be when I created them, but I guess it's what they
> evolved to be.
> 
> >>                                         As far as I know, there is no
> >> high-level infrastructure to query runtime state of devices and qdev
> >> properties are supposed to be read-only. Maybe non-qdev QOM properties
> >> can be used somehow?
> 
> Since qdev properties are implemented as QOM property, there are no
> non-qdev QOM properties.

You got the logic wrong here: "All qdev properties are QOM properties"
doesn't imply "All QOM properties are qdev properties". Now I don't say
that it's not true anyway, I don't know enough about QOM and qdev to say
much about it.

I always had the impression that qdev provided some wrappers around QOM
that add magic that makes properties configurable in -device and things
like that, which you wouldn't want for these properties. I also know
that devices aren't supposed to change qdev properties at runtime
(whereas I remember QOM not to have trouble with that), but I'm not sure
if there is a technical reason for this.

> >>                      But QOM isn't really nice to use as you need to
> >> query each property individually.
> 
> qom-get returns 'any'.  A read-only property with a complex value is
> already possible.  But it's awkward when you also want to get or set
> parts of the complex value.
> 
> Perhaps we could provide a way to get whole containers in addition to
> single properties.  Would that do?

You could query a device with a single command then, sounds much nicer.
Actually, your argument from above applies here, too: You want the
returned data to be consistent, so querying needs to be atomic. This
means that getting whole containers isn't only more convenient, but
actually more correct.

Another thought I have when comparing this with querying block nodes:
Wouldn't you still consider querying just a single device filtering?

> >> Another option would be to have a QMP command that takes a qdev ID of a
> >> block device and queries its BB. Or maybe it should stay like
> >> query-block and return an array of all of them, but include the qdev
> >> device name. Actually, maybe query-block can stay as it contains only
> >> two fields that are useless in the new world.
> >
> > Being able to query all the devices (with their BB's, and only a name
> > reference to the top-level BDS in use by the BB), separately from being
> > able to query all BDS, seems like a reasonable thing.  After all,
> > sometimes you care about what the guest sees (what devices have a BB),
> > and sometimes you care about what the host is exposing (what BDS are in
> > use).
> 
> No argument.  But let's not focus narrowly on block devices, or even
> devices.  If QOM "isn't really nice" for block devices, it probably
> isn't nice for lots of other things.  If we can address that at the QOM
> level, we should.

That's exactly what I think. Unfortunately, my knowledge about QOM is
seriously lacking. Even more unfortunately, everyone else seems to have
the same problem.

> >> I think this has become long enough now, so any opinions? On anything I
> >> said above, but preferably also about what a new interface should look
> >> like?
> >
> > Our existing interface is definitely awkward, with lots of redundancy in
> > some places and missing information in others, and a new interface does
> > seem like we can do better at designing it right up front rather than
> > bolting on yet more information to the existing queries (which results
> > in that much more noise to churn through to get to the desired information).
> 
> Replacing an interface that could be evolved to serve is a mistake.
> 
> Not replacing an interface when it has reached its design limits is also
> a mistake.
> 
> I normally advise against the first mistake.  But in this case, I think
> we have to avoid the second.  The interface has evolved into a confusing
> mess.  The gap between how the interface presents the block layer and
> how it actually works has become too large.  Sufficiently sophisticated
> clients have to bridge the gap somehow, and that's painful.

Thanks, the feedback so far is already very helpful in that everyone
agreed that we need something completely new. Now we just need to figure
out what it should look like. :-)

Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [RFC] QMP design: Fixing query-block and friends
  2017-06-28 10:06     ` Kevin Wolf
@ 2017-06-28 11:59       ` Markus Armbruster
  0 siblings, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2017-06-28 11:59 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: stefanha, qemu-devel, qemu-block, mreitz

Kevin Wolf <kwolf@redhat.com> writes:

> Am 28.06.2017 um 09:10 hat Markus Armbruster geschrieben:
>> Eric Blake <eblake@redhat.com> writes:
>> > On 06/27/2017 11:31 AM, Kevin Wolf wrote:
>> >> If that's what we're going to do, I think I can figure out something
>> >> nice for block nodes. That shouldn't be too hard. The only question
>> >> would be whether we want a command to query one node or whether we would
>> >> keep returning all of them.
>> >
>> > The age-old filtering question. It's also plausible to have a single
>> > command, with an optional argument, and which always returns an array:
>> > the full array if the argument was omitted, or an array of one matching
>> > the argument when one was provided.  Adding filtering is an easy patch
>> > on top once it is proven to make life easier for a client, and I'm okay
>> > with a first approach that does not filter.
>> 
>> The graph may change.  Querying node by node would have to cope with
>> changes somehow, which I'd expect to be complex and fragile.  I think we
>> really need a way to get a complete, consistent graph.  So let's
>> implement that first.  If we still want server-side filtering once
>> that's done, we can add some on top.
>> 
>> As usual, I doubt we really need server-side filtering, and I dislike
>> the interface complexity it brings.
>
> I didn't really think of it as filtering. Every other operation is done
> on a single object, so querying a single object would be the natural
> extension. I mean, we also don't consider it "filtering" that we have
> many separate query commands instead of a 'query-qemu-state'.

Let me try to be more precise.

Once you have a command to return "full" data, I doubt the need to add
filtering to it so it can optionally return partial data.

I put "full" in quotes, because it's a design decision.  If you design a
command to query information about a node, then "full" is information
about just that node.  If you design one for the entire node graph, then
"full" is about all nodes that exist.  If you design one for the
sub-graph rooted at a certain node, then "full" is about all the nodes
in that sub-graph.

The design will depend on considerations like the desire let clients
gain a consistent view more easily.  That's not what I meant by
"filtering".

If the chosen design returns information on multiple nodes, then adding
optional parameters to make it return less is "filtering".  This kind of
filtering can easily be done in the client.  Doing it in the server
increases interface complexity, and that needs justification.

Here's a justification I could accept: we can show certain clients need
partial information frequently enough to make saving bandwidth
worthwhile.

Here's a justification I refuse to accept: because we can.

Is my stance clearer now?

> But you have a good point with the necessary atomicity, so we'll return
> everything at once.
>
>> >> I am, however, a bit less confident about BBs. As I said above, I
>> >> consider them part of the qdev devices.
>> 
>> They weren't meant to be when I created them, but I guess it's what they
>> evolved to be.
>> 
>> >>                                         As far as I know, there is no
>> >> high-level infrastructure to query runtime state of devices and qdev
>> >> properties are supposed to be read-only. Maybe non-qdev QOM properties
>> >> can be used somehow?
>> 
>> Since qdev properties are implemented as QOM property, there are no
>> non-qdev QOM properties.
>
> You got the logic wrong here: "All qdev properties are QOM properties"
> doesn't imply "All QOM properties are qdev properties". Now I don't say
> that it's not true anyway, I don't know enough about QOM and qdev to say
> much about it.

I got it backwards.  There are no non-QOM qdev properties.  Sorry for
the confusion.

QOM isn't the only way to interact with QEMU objects (objects in the
widest possible sense).  But it's a generic way that already exists.
Let's consider whether we can use it before we invent new ways.

Read/write QOM properties is how we configure and control QOM objects,
including devices.  Read-only QOM properties is how we inspect them.

> I always had the impression that qdev provided some wrappers around QOM
> that add magic that makes properties configurable in -device and things
> like that, which you wouldn't want for these properties. I also know
> that devices aren't supposed to change qdev properties at runtime
> (whereas I remember QOM not to have trouble with that), but I'm not sure
> if there is a technical reason for this.

Historically, qdev properties are for configuring devices.  But nothing
stops you from using (abusing?) qdev properties for something else.  You
could, for instance, ignore a property's initial value (making it *not*
configuration), then have its value track some interesting bit of device
state, so the user can inspect it with info qtree.

However, arguing about this has become rather pointless, because qdev is
less and less separate from QOM.  We've acquired non-qdev QOM properties
for configuring devices.  We may generalize features qdev now provides
over QOM, because they're useful for non-devices as well, such as
defining properties in data rather than code, or the machinery for
machine-type-specific defaults.

My point is: don't get sidetracked into qdev.

>> >>                      But QOM isn't really nice to use as you need to
>> >> query each property individually.
>> 
>> qom-get returns 'any'.  A read-only property with a complex value is
>> already possible.  But it's awkward when you also want to get or set
>> parts of the complex value.
>> 
>> Perhaps we could provide a way to get whole containers in addition to
>> single properties.  Would that do?
>
> You could query a device with a single command then, sounds much nicer.
> Actually, your argument from above applies here, too: You want the
> returned data to be consistent, so querying needs to be atomic. This
> means that getting whole containers isn't only more convenient, but
> actually more correct.

Point.

Related: transaction to set multiple properties.  Different topic,
though.

> Another thought I have when comparing this with querying block nodes:
> Wouldn't you still consider querying just a single device filtering?

I hope I answered this above.

>> >> Another option would be to have a QMP command that takes a qdev ID of a
>> >> block device and queries its BB. Or maybe it should stay like
>> >> query-block and return an array of all of them, but include the qdev
>> >> device name. Actually, maybe query-block can stay as it contains only
>> >> two fields that are useless in the new world.
>> >
>> > Being able to query all the devices (with their BB's, and only a name
>> > reference to the top-level BDS in use by the BB), separately from being
>> > able to query all BDS, seems like a reasonable thing.  After all,
>> > sometimes you care about what the guest sees (what devices have a BB),
>> > and sometimes you care about what the host is exposing (what BDS are in
>> > use).
>> 
>> No argument.  But let's not focus narrowly on block devices, or even
>> devices.  If QOM "isn't really nice" for block devices, it probably
>> isn't nice for lots of other things.  If we can address that at the QOM
>> level, we should.
>
> That's exactly what I think. Unfortunately, my knowledge about QOM is
> seriously lacking. Even more unfortunately, everyone else seems to have
> the same problem.

QOM is documented, but the documentation is seriously lacking on the
*why*.  It's obvious to me that a lot of thought and love has been
poured into QOM.  Sadly, the people how used to drive QOM aren't as
active as they used to be, or have since moved on to other adventures
entirely.  This leaves us with a complex, ambitious piece of
infrastructure we don't quite know how to put to use.

>> >> I think this has become long enough now, so any opinions? On anything I
>> >> said above, but preferably also about what a new interface should look
>> >> like?
>> >
>> > Our existing interface is definitely awkward, with lots of redundancy in
>> > some places and missing information in others, and a new interface does
>> > seem like we can do better at designing it right up front rather than
>> > bolting on yet more information to the existing queries (which results
>> > in that much more noise to churn through to get to the desired information).
>> 
>> Replacing an interface that could be evolved to serve is a mistake.
>> 
>> Not replacing an interface when it has reached its design limits is also
>> a mistake.
>> 
>> I normally advise against the first mistake.  But in this case, I think
>> we have to avoid the second.  The interface has evolved into a confusing
>> mess.  The gap between how the interface presents the block layer and
>> how it actually works has become too large.  Sufficiently sophisticated
>> clients have to bridge the gap somehow, and that's painful.
>
> Thanks, the feedback so far is already very helpful in that everyone
> agreed that we need something completely new. Now we just need to figure
> out what it should look like. :-)

"just" :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-28  7:15   ` Markus Armbruster
@ 2017-06-28 16:00     ` John Snow
  2017-06-29  7:23       ` Markus Armbruster
  0 siblings, 1 reply; 13+ messages in thread
From: John Snow @ 2017-06-28 16:00 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Kevin Wolf, qemu-block, mreitz, stefanha, qemu-devel



On 06/28/2017 03:15 AM, Markus Armbruster wrote:
> John Snow <jsnow@redhat.com> writes:
> 
>> On 06/27/2017 12:31 PM, Kevin Wolf wrote:
>>> Hi,
>>>
>>> I haven't really liked query-block for a long time, but now that
>>> blockdev-add and -blockdev have settled, it might finally be the time to
>>> actually do something about it. In fact, if used together with these
>>> modern interfaces, our query commands are simply broken, so we have to
>>> fix something.
>>>
>>
>> [...words...]
>>
>>>
>>> So how do we go forward from here?
>>>
>>> I guess we could add a few hacks o fix the really urgent things, and
>>> just adding more information is always possible (at the cost of even
>>> more duplication).
>>>
>>
>> I think you've included this suggestion so that you can summarily
>> dismiss it as foolish.
>>
>>> However, it appears to me that I dislike so many thing about our current
>>> query commands that I'm tempted to say: Throw it all away and start
>>> over.
>>>
>>
>> Inclined to agree. The structure of the block layer has changed so much
>> in the past few years and this is easily seen by the gap you've outlined
>> here.
>>
>> We have to keep the old query commands around for a while as Eric says,
>> but I worry that they are so wrong and misleading as to be actively harmful.
>>
>> Maybe there's some hair trigger somewhere that if $NEW_FEATURE_X is used
>> to configure QEMU in some way, that the old commands can be deprecated
>> at runtime, such that we can more aggressively force their retirement.
> 
> We warn on use of deprecated command line and HMP features.  I think we
> want the same for QMP, within QMP.
> 
> [...]
> 

I was thinking of something even stronger than a warning in this case.
Warn if you use it anyway, but if you use $SOME_2.10_FEATURE, it
actually disables it.

"Hi, I know that you have seen the 2.10 API. I'm removing access to this
feature, because you REALLY ought not use it."

Could be as simple as actually disabling the old query command if the
new query command is utilized.

--js

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-28 16:00     ` John Snow
@ 2017-06-29  7:23       ` Markus Armbruster
  0 siblings, 0 replies; 13+ messages in thread
From: Markus Armbruster @ 2017-06-29  7:23 UTC (permalink / raw)
  To: John Snow; +Cc: Kevin Wolf, qemu-devel, stefanha, qemu-block, mreitz

John Snow <jsnow@redhat.com> writes:

> On 06/28/2017 03:15 AM, Markus Armbruster wrote:
>> John Snow <jsnow@redhat.com> writes:
>> 
>>> On 06/27/2017 12:31 PM, Kevin Wolf wrote:
>>>> Hi,
>>>>
>>>> I haven't really liked query-block for a long time, but now that
>>>> blockdev-add and -blockdev have settled, it might finally be the time to
>>>> actually do something about it. In fact, if used together with these
>>>> modern interfaces, our query commands are simply broken, so we have to
>>>> fix something.
>>>>
>>>
>>> [...words...]
>>>
>>>>
>>>> So how do we go forward from here?
>>>>
>>>> I guess we could add a few hacks o fix the really urgent things, and
>>>> just adding more information is always possible (at the cost of even
>>>> more duplication).
>>>>
>>>
>>> I think you've included this suggestion so that you can summarily
>>> dismiss it as foolish.
>>>
>>>> However, it appears to me that I dislike so many thing about our current
>>>> query commands that I'm tempted to say: Throw it all away and start
>>>> over.
>>>>
>>>
>>> Inclined to agree. The structure of the block layer has changed so much
>>> in the past few years and this is easily seen by the gap you've outlined
>>> here.
>>>
>>> We have to keep the old query commands around for a while as Eric says,
>>> but I worry that they are so wrong and misleading as to be actively harmful.
>>>
>>> Maybe there's some hair trigger somewhere that if $NEW_FEATURE_X is used
>>> to configure QEMU in some way, that the old commands can be deprecated
>>> at runtime, such that we can more aggressively force their retirement.
>> 
>> We warn on use of deprecated command line and HMP features.  I think we
>> want the same for QMP, within QMP.
>> 
>> [...]
>> 
>
> I was thinking of something even stronger than a warning in this case.
> Warn if you use it anyway, but if you use $SOME_2.10_FEATURE, it
> actually disables it.
>
> "Hi, I know that you have seen the 2.10 API. I'm removing access to this
> feature, because you REALLY ought not use it."
>
> Could be as simple as actually disabling the old query command if the
> new query command is utilized.

Such spontaneous API change is bad magic, I'm afraid.  It also sabotages
the value of query-qmp-schema.

What we could do is enrich query-qmp-schema with deprecation
information, and let clients request a compatibility level.  Requesting
a level we no longer provide fails.  Default is the oldest level we
provide.  Clients relying on a stable interface would be well adviced to
request the one they need.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 16:31 [Qemu-devel] [RFC] QMP design: Fixing query-block and friends Kevin Wolf
  2017-06-27 16:46 ` Eric Blake
  2017-06-27 18:24 ` [Qemu-devel] [Qemu-block] " John Snow
@ 2017-06-30 13:01 ` Alberto Garcia
  2017-06-30 14:22   ` Kevin Wolf
  2 siblings, 1 reply; 13+ messages in thread
From: Alberto Garcia @ 2017-06-30 13:01 UTC (permalink / raw)
  To: Kevin Wolf, qemu-block; +Cc: armbru, qemu-devel, stefanha, mreitz

On Tue 27 Jun 2017 06:31:45 PM CEST, Kevin Wolf wrote:
> * Speaking of recursion: ImageInfo recursively includes information
>   about all images in the backing chain. This is what makes the output
>   of query-named-block-nodes so redundant. It is also inconsistent
>   because the runtime information (BlockInfo/BlockDeviceInfo) isn't
>   recursive.

I've also been told of cases where a query-block command on a VM with a
very large amount of images in all backing chains would slow down the
guest because of this recursion.

I haven't been able to reproduce this problem myself, but being able to
see only the devices seen by the guest (as opposed to the complete
graph) seems like a good idea.

Berto

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-30 13:01 ` Alberto Garcia
@ 2017-06-30 14:22   ` Kevin Wolf
  2017-06-30 14:30     ` Alberto Garcia
  0 siblings, 1 reply; 13+ messages in thread
From: Kevin Wolf @ 2017-06-30 14:22 UTC (permalink / raw)
  To: Alberto Garcia; +Cc: qemu-block, armbru, qemu-devel, stefanha, mreitz

Am 30.06.2017 um 15:01 hat Alberto Garcia geschrieben:
> On Tue 27 Jun 2017 06:31:45 PM CEST, Kevin Wolf wrote:
> > * Speaking of recursion: ImageInfo recursively includes information
> >   about all images in the backing chain. This is what makes the output
> >   of query-named-block-nodes so redundant. It is also inconsistent
> >   because the runtime information (BlockInfo/BlockDeviceInfo) isn't
> >   recursive.
> 
> I've also been told of cases where a query-block command on a VM with a
> very large amount of images in all backing chains would slow down the
> guest because of this recursion.
> 
> I haven't been able to reproduce this problem myself, but being able to
> see only the devices seen by the guest (as opposed to the complete
> graph) seems like a good idea.

I think the information only really becomes redundant if you use
query-named-block-nodes because then you list every backing file node
and each of them contains the recursive information.

With query-block, you start at the top and include the information for
each image in the backing file chain only once. If we did indeed have a
problem there, that might mean that we do in fact need filtering to
reduce the overhead. But I don't think any of the information involves
any I/O to get, so it seems unlikely to me that this would make a big
difference.

Kevin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-30 14:22   ` Kevin Wolf
@ 2017-06-30 14:30     ` Alberto Garcia
  0 siblings, 0 replies; 13+ messages in thread
From: Alberto Garcia @ 2017-06-30 14:30 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-block, armbru, qemu-devel, stefanha, mreitz

On Fri 30 Jun 2017 04:22:11 PM CEST, Kevin Wolf wrote:
> Am 30.06.2017 um 15:01 hat Alberto Garcia geschrieben:
>> On Tue 27 Jun 2017 06:31:45 PM CEST, Kevin Wolf wrote:
>> > * Speaking of recursion: ImageInfo recursively includes information
>> >   about all images in the backing chain. This is what makes the output
>> >   of query-named-block-nodes so redundant. It is also inconsistent
>> >   because the runtime information (BlockInfo/BlockDeviceInfo) isn't
>> >   recursive.
>> 
>> I've also been told of cases where a query-block command on a VM with a
>> very large amount of images in all backing chains would slow down the
>> guest because of this recursion.
>> 
>> I haven't been able to reproduce this problem myself, but being able to
>> see only the devices seen by the guest (as opposed to the complete
>> graph) seems like a good idea.
>
> I think the information only really becomes redundant if you use
> query-named-block-nodes because then you list every backing file node
> and each of them contains the recursive information.
>
> With query-block, you start at the top and include the information for
> each image in the backing file chain only once. If we did indeed have
> a problem there, that might mean that we do in fact need filtering to
> reduce the overhead. But I don't think any of the information involves
> any I/O to get, so it seems unlikely to me that this would make a big
> difference.

Yes, that was also what I thought, but I haven't been able to reproduce
the problem so I don't know yet. In my own tests with thousands of
backing files I haven't noticed any slowdown caused by query-block.

Berto

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [RFC] QMP design: Fixing query-block and friends
  2017-06-27 18:24 ` [Qemu-devel] [Qemu-block] " John Snow
  2017-06-28  7:15   ` Markus Armbruster
@ 2017-07-05 14:53   ` Stefan Hajnoczi
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Hajnoczi @ 2017-07-05 14:53 UTC (permalink / raw)
  To: John Snow; +Cc: Kevin Wolf, qemu-block, armbru, qemu-devel, mreitz

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]

On Tue, Jun 27, 2017 at 02:24:12PM -0400, John Snow wrote:
> On 06/27/2017 12:31 PM, Kevin Wolf wrote:
> > If that's what we're going to do, I think I can figure out something
> > nice for block nodes. That shouldn't be too hard. The only question
> > would be whether we want a command to query one node or whether we would
> > keep returning all of them.
> > 
> 
> Personally in favor of allowing filtering, as an option. I don't see why
> we couldn't, or why it would be a problem, or worse in any way.

Yes.  Filtering is important for performance with large numbers of
drives.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-07-05 14:53 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 16:31 [Qemu-devel] [RFC] QMP design: Fixing query-block and friends Kevin Wolf
2017-06-27 16:46 ` Eric Blake
2017-06-28  7:10   ` Markus Armbruster
2017-06-28 10:06     ` Kevin Wolf
2017-06-28 11:59       ` Markus Armbruster
2017-06-27 18:24 ` [Qemu-devel] [Qemu-block] " John Snow
2017-06-28  7:15   ` Markus Armbruster
2017-06-28 16:00     ` John Snow
2017-06-29  7:23       ` Markus Armbruster
2017-07-05 14:53   ` Stefan Hajnoczi
2017-06-30 13:01 ` Alberto Garcia
2017-06-30 14:22   ` Kevin Wolf
2017-06-30 14:30     ` Alberto Garcia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.