Re: [libvirt] [Qemu-devel] [PATCH v2] hmp: allow cpu index for "info lapic"

[adding libvirt] On 07/19/2017 07:41 AM, Eduardo Habkost wrote:
virsh qemu-monitor-command --domain rhel6.8 --hmp --cmd "cpu 1" virsh qemu-monitor-command --domain rhel6.8 --hmp --cmd "info lapic" dumping local APIC state for CPU 0
Right, the "cpu" command is useless inside a 'human-monitor-command' QMP command. The 'cpu-index' argument should be used instead. should make "cpu" print an error if ran inside 'human-monitor-command' instead of silently pretend it worked.
If virsh doesn't support the 'cpu-index' argument to 'human-monitor-command',
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
it's possible to work around that limitation by building your own QMP command. e.g.:
# virsh qemu-monitor-command f26test '{"execute":"human-monitor-command", "arguments":{"command-line":"info lapic", "cpu-index":1}}' | jq -r '.return'
Indeed, there's the use of QMP to work around the HMP deficiency. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org

On Wed, Jul 19, 2017 at 10:02:04AM -0500, Eric Blake wrote:
[adding libvirt]
On 07/19/2017 07:41 AM, Eduardo Habkost wrote:
virsh qemu-monitor-command --domain rhel6.8 --hmp --cmd "cpu 1" virsh qemu-monitor-command --domain rhel6.8 --hmp --cmd "info lapic" dumping local APIC state for CPU 0
Right, the "cpu" command is useless inside a 'human-monitor-command' QMP command. The 'cpu-index' argument should be used instead. should make "cpu" print an error if ran inside 'human-monitor-command' instead of silently pretend it worked.
If virsh doesn't support the 'cpu-index' argument to 'human-monitor-command',
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
Or special case the "cpu 1" command - ie notice that it is being requested and don't execute 'human-montor-command'. Instead just record the CPU index, and use that for future "human-monitor-command" invokations, so we get full compat with the (dubious) stateful HMP semantics that traditionally existed.
it's possible to work around that limitation by building your own QMP command. e.g.:
# virsh qemu-monitor-command f26test '{"execute":"human-monitor-command", "arguments":{"command-line":"info lapic", "cpu-index":1}}' | jq -r '.return'
Indeed, there's the use of QMP to work around the HMP deficiency.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On 07/19/2017 10:07 AM, Daniel P. Berrange wrote:
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
Or special case the "cpu 1" command - ie notice that it is being requested and don't execute 'human-montor-command'. Instead just record the CPU index, and use that for future "human-monitor-command" invokations, so we get full compat with the (dubious) stateful HMP semantics that traditionally existed.
Is 'cpu' (and the followup commands affected by it) the only stateful HMP command pairing? Is there a way to specify multiple HMP commands in a single human-monitor-command QMP call? Indeed, tweaking qemu's human-monitor-command call to track the state might be cleaner than having libvirt have to tweak API to work around this wart of HMP. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org

On Wed, Jul 19, 2017 at 10:17:36AM -0500, Eric Blake wrote:
On 07/19/2017 10:07 AM, Daniel P. Berrange wrote:
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
Or special case the "cpu 1" command - ie notice that it is being requested and don't execute 'human-montor-command'. Instead just record the CPU index, and use that for future "human-monitor-command" invokations, so we get full compat with the (dubious) stateful HMP semantics that traditionally existed.
Is 'cpu' (and the followup commands affected by it) the only stateful HMP command pairing? Is there a way to specify multiple HMP commands in a single human-monitor-command QMP call?
Indeed, tweaking qemu's human-monitor-command call to track the state might be cleaner than having libvirt have to tweak API to work around this wart of HMP.
The CPU index was the only state kept by the human monitor, and I think it's by design that it stopped being considered "monitor state" to be tracked, and became just an argument to human-monitor-command. It's true that it broke compatibility of "virsh qemu-monitor-command <domain> --hmp 'cpu <n>'", when we moved to QMP, but this happened years ago, and it looks like nobody was relying on it. I don't see the point of trying to emulate the previous stateful interface. -- Eduardo

* Eduardo Habkost (ehabkost@redhat.com) wrote:
On Wed, Jul 19, 2017 at 10:17:36AM -0500, Eric Blake wrote:
On 07/19/2017 10:07 AM, Daniel P. Berrange wrote:
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
Or special case the "cpu 1" command - ie notice that it is being requested and don't execute 'human-montor-command'. Instead just record the CPU index, and use that for future "human-monitor-command" invokations, so we get full compat with the (dubious) stateful HMP semantics that traditionally existed.
Is 'cpu' (and the followup commands affected by it) the only stateful HMP command pairing? Is there a way to specify multiple HMP commands in a single human-monitor-command QMP call?
Indeed, tweaking qemu's human-monitor-command call to track the state might be cleaner than having libvirt have to tweak API to work around this wart of HMP.
The CPU index was the only state kept by the human monitor, and I think it's by design that it stopped being considered "monitor state" to be tracked, and became just an argument to human-monitor-command.
It's true that it broke compatibility of "virsh qemu-monitor-command <domain> --hmp 'cpu <n>'", when we moved to QMP, but this happened years ago, and it looks like nobody was relying on it. I don't see the point of trying to emulate the previous stateful interface.
IMHO Yi's fix (once reworked) is the right fix - it removes the use of that piece of state, when the optional parameter is used. (OK, so it needs rework not to change that state and to come to some agreement as to what to use instead of cpu index number etc). Dave
-- Eduardo -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

On Wed, Jul 19, 2017 at 08:17:49PM +0100, Dr. David Alan Gilbert wrote:
* Eduardo Habkost (ehabkost@redhat.com) wrote:
On Wed, Jul 19, 2017 at 10:17:36AM -0500, Eric Blake wrote:
On 07/19/2017 10:07 AM, Daniel P. Berrange wrote:
It doesn't. Perhaps we should add that as a future libvirt-qemu.so API addition, although it's probably easier to just use QMP than HMP when using 'virsh qemu-monitor-command' if HMP doesn't do what you want.
Or special case the "cpu 1" command - ie notice that it is being requested and don't execute 'human-montor-command'. Instead just record the CPU index, and use that for future "human-monitor-command" invokations, so we get full compat with the (dubious) stateful HMP semantics that traditionally existed.
Is 'cpu' (and the followup commands affected by it) the only stateful HMP command pairing? Is there a way to specify multiple HMP commands in a single human-monitor-command QMP call?
Indeed, tweaking qemu's human-monitor-command call to track the state might be cleaner than having libvirt have to tweak API to work around this wart of HMP.
The CPU index was the only state kept by the human monitor, and I think it's by design that it stopped being considered "monitor state" to be tracked, and became just an argument to human-monitor-command.
It's true that it broke compatibility of "virsh qemu-monitor-command <domain> --hmp 'cpu <n>'", when we moved to QMP, but this happened years ago, and it looks like nobody was relying on it. I don't see the point of trying to emulate the previous stateful interface.
IMHO Yi's fix (once reworked) is the right fix - it removes the use of that piece of state, when the optional parameter is used. (OK, so it needs rework not to change that state and to come to some agreement as to what to use instead of cpu index number etc).
Agreed, as it helps us to keep the "virsh qemu-monitor-command" interface simpler. But we have 8 commands that use mon_get_cpu(), we shouldn't fix only "info lapic". -- Eduardo

Pk9uIFdlZCwgSnVsIDE5LCAyMDE3IGF0IDA4OjE3OjQ5UE0gKzAxMDAsIERyLiBEYXZpZCBBbGFu IEdpbGJlcnQgd3JvdGU6DQoNCj4+ICogRWR1YXJkbyBIYWJrb3N0IChhZGRyZXNzQGhpZGRlbikg d3JvdGU6DQoNCj4+ID4gT24gV2VkLCBKdWwgMTksIDIwMTcgYXQgMTA6MTc6MzZBTSAtMDUwMCwg RXJpYyBCbGFrZSB3cm90ZToNCg0KPj4gPiA+IE9uIDA3LzE5LzIwMTcgMTA6MDcgQU0sIERhbmll bCBQLiBCZXJyYW5nZSB3cm90ZToNCg0KPj4gPiA+ID4+IEl0IGRvZXNuJ3QuICBQZXJoYXBzIHdl IHNob3VsZCBhZGQgdGhhdCBhcyBhIGZ1dHVyZSBsaWJ2aXJ0LXFlbXUuc28gQVBJDQoNCj4+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