QMP design: Fixing query-block and friends
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:
Quoted 36 lines
{ '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' } }
Quoted 9 lines
{ '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
Quoted 7 lines · Kevin Wolf
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.
Quoted 4 lines
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.
Quoted 5 lines
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.
Quoted 8 lines
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.
Quoted 5 lines
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).
Quoted 3 lines
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).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 11 lines · Eric Blake
Quoted 7 lines · Kevin Wolf
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...]
Quoted 17 lines
Quoted 4 lines
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.
Quoted 5 lines
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.
Quoted 6 lines
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.
Quoted 2 lines
Quoted 2 lines
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.
Quoted 4 lines
Quoted 4 lines
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.
Quoted 2 lines
Quoted 2 lines
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?
Quoted 6 lines
Quoted 5 lines
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.
Quoted 6 lines
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.
Quoted 9 lines
Quoted 3 lines
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.
Am 28.06.2017 um 09:10 hat Markus Armbruster geschrieben:
Quoted 14 lines
Quoted 6 lines · Eric Blake
Quoted 4 lines · Kevin Wolf
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.
Quoted 6 lines
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.
Quoted 8 lines
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.
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
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.
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
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?
Quoted 13 lines
Quoted 6 lines
Quoted 5 lines
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.
Quoted 6 lines
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).
Quoted 4 lines
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.
Quoted 12 lines
Quoted 9 lines
Quoted 3 lines
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.
Quoted 8 lines
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
Quoted 21 lines · Kevin Wolf
Am 28.06.2017 um 09:10 hat Markus Armbruster geschrieben:
Quoted 20 lines
Quoted 6 lines · Eric Blake
Quoted 4 lines · Kevin Wolf
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.
Quoted 6 lines
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.
Quoted 7 lines
Quoted 2 lines
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?
Quoted 14 lines
But you have a good point with the necessary atomicity, so we'll return everything at once.
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 4 lines
Quoted 4 lines
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?
Quoted 7 lines
Quoted 2 lines
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.
Quoted 6 lines
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.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
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.
Quoted 8 lines
Quoted 2 lines
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.
Quoted 2 lines
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.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 5 lines
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).
Quoted 8 lines
Quoted 4 lines
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.
Quoted 21 lines
Quoted 12 lines
Quoted 9 lines
Quoted 3 lines
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.
Quoted 8 lines
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.
Quoted 3 lines
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" :)
Quoted 8 lines · Kevin Wolf
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...]
Quoted 7 lines
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.
Quoted 4 lines
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.
Quoted 5 lines
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.
Quoted 14 lines
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.
Quoted 4 lines
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.
Quoted 2 lines
Kevin
Quoted 32 lines · John Snow
Quoted 8 lines · Kevin Wolf
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...]
Quoted 7 lines
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.
Quoted 4 lines
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.
Quoted 6 lines
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.
[...]
Quoted 37 lines · Markus Armbruster
Quoted 35 lines · John Snow
Quoted 8 lines · Kevin Wolf
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...]
Quoted 7 lines
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.
Quoted 4 lines
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.
Quoted 9 lines
Quoted 3 lines
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
Quoted 52 lines · John Snow
Quoted 37 lines · Markus Armbruster
Quoted 35 lines · John Snow
Quoted 8 lines · Kevin Wolf
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...]
Quoted 7 lines
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.
Quoted 4 lines
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.
Quoted 9 lines
Quoted 3 lines
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.
Quoted 5 lines
"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.
Quoted 9 lines · John Snow
Quoted 5 lines · Kevin Wolf
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
Quoted 5 lines · Kevin Wolf
* 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
Am 30.06.2017 um 15:01 hat Alberto Garcia geschrieben:
Quoted 7 lines · Kevin Wolf
Quoted 5 lines
* 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.
Quoted 7 lines
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
Quoted 20 lines · Kevin Wolf
Am 30.06.2017 um 15:01 hat Alberto Garcia geschrieben:
Quoted 7 lines · Kevin Wolf
Quoted 5 lines
* 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.
Quoted 7 lines
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.
Quoted 6 lines
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