Skip to contentSkip to conversation

hmp: allow cpu index for "info lapic"

PATCH In review Yi Wang 6 participants 19 messages Jul 18, 2017 – Jul 20, 2017

lore
Share & tools
lore

Yi Wang

author
#0 lore raw

PATCH v2 1/1 hmp: allow cpu index for "info lapic"

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

---
 hmp-commands-info.hx  | 6 +++---
 target/i386/monitor.c | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
hmp-commands-info.hx +3 -3
index d9df238..c534b03 100644
@@ -115,9 +115,9 @@ ETEXI
 #if defined(TARGET_I386)
     {
         .name       = "lapic",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show local apic state",
+        .args_type  = "vcpu:i?",
+        .params     = "[vcpu]",
+        .help       = "show local apic state (vcpu: vCPU to read, default is 0)",
         .cmd        = hmp_info_local_apic,
     },
 #endif
target/i386/monitor.c +7 -1
index 77ead60..813005e 100644
@@ -632,8 +632,14 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-    CPUState *cs = mon_get_cpu();
+    CPUState *cs;
 
+    if (qdict_haskey(qdict, "vcpu")) {
+        int index = qdict_get_try_int(qdict, "vcpu", 0);
+        cs = qemu_get_cpu(index);
+    } else {
+        cs = mon_get_cpu();
+    }
     if (!cs) {
         monitor_printf(mon, "No CPU available\n");
         return;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · On Mon, 17 Jul 2017 21:49:37 -0400 Yi Wang <[email protected]> wrote:

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

we shouldn't expose cpu_index to users anymore,

I would suggest using to use real APIC ID here but we don't have monitor command that returns APIC IDs for present cpus.

"info hotpluggable-cpus" gives you a list of available CPUs it also gives you qom_path to cpu so potentially you could read apic-id property of cpu.

But we have only QMP variant of qom-get so monitor needs addition of qom-get command that will be a wrapper around QMP command.

It could be solved in 2 ways:
* use socket-id/core-id/thread-id to specify desired cpu /possible values in 'info hotpluggable-cpus'/

* use apic-id value to specify interrupt controller
- apic-id could be retrieved with new qom-get (qom-get would also be useful to read other properties)
- extend 'info registers' with apic id value

    for example instead of current:
    
     CPU#1
     EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000
     ....

    it would look like:

     CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d)
     ...
Quoted 45 lines
---
 hmp-commands-info.hx  | 6 +++---
 target/i386/monitor.c | 8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
hmp-commands-info.hx +3 -3
index d9df238..c534b03 100644
@@ -115,9 +115,9 @@ ETEXI
 #if defined(TARGET_I386)
     {
         .name       = "lapic",
-        .args_type  = "",
-        .params     = "",
-        .help       = "show local apic state",
+        .args_type  = "vcpu:i?",
+        .params     = "[vcpu]",
+        .help       = "show local apic state (vcpu: vCPU to read, default is 0)",
         .cmd        = hmp_info_local_apic,
     },
 #endif
target/i386/monitor.c +7 -1
index 77ead60..813005e 100644
@@ -632,8 +632,14 @@ const MonitorDef *target_monitor_defs(void)
 
 void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 {
-    CPUState *cs = mon_get_cpu();
+    CPUState *cs;
 
+    if (qdict_haskey(qdict, "vcpu")) {
+        int index = qdict_get_try_int(qdict, "vcpu", 0);
+        cs = qemu_get_cpu(index);
+    } else {
+        cs = mon_get_cpu();
+    }
     if (!cs) {
         monitor_printf(mon, "No CPU available\n");
         return;
#2 lore raw
Quoted 27 lines · Igor Mammedov
Quoted 3 lines · On Mon, 17 Jul 2017 21:49:37 -0400 Yi Wang <[email protected]> wrote:

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

we shouldn't expose cpu_index to users anymore,

I would suggest using to use real APIC ID here but we don't have monitor command that returns APIC IDs for present cpus.

"info hotpluggable-cpus" gives you a list of available CPUs it also gives you qom_path to cpu so potentially you could read apic-id property of cpu.

But we have only QMP variant of qom-get so monitor needs addition of qom-get command that will be a wrapper around QMP command.

It could be solved in 2 ways:
* use socket-id/core-id/thread-id to specify desired cpu /possible values in 'info hotpluggable-cpus'/

* use apic-id value to specify interrupt controller
- apic-id could be retrieved with new qom-get (qom-get would also be useful to read other properties)
- extend 'info registers' with apic id value

Quoted 10 lines
    for example instead of current:
    
     CPU#1
     EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000
     ....

    it would look like:

     CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d)
     ...

We already print "CPU #<n>" on "info cpus", so <n> is already a perfectly good identifier for a human interface. I think HMP should not require any identifier that isn't a simple number that is shown very prominently on "info cpus".

If we don't want to use cpu_index as an identifier anymore, we can start printing arch ID instead of cpu_index on commands that print "CPU #<n>", and change mon_get_cpu() and monitor_set_cpu() accordingly.

Signature · 1 line
Eduardo
#3 lore raw
Quoted 44 lines · On Tue, 18 Jul 2017 20:26:50 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 27 lines · Igor Mammedov
Quoted 3 lines · On Mon, 17 Jul 2017 21:49:37 -0400 Yi Wang <[email protected]> wrote:

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

we shouldn't expose cpu_index to users anymore,

I would suggest using to use real APIC ID here but we don't have monitor command that returns APIC IDs for present cpus.

"info hotpluggable-cpus" gives you a list of available CPUs it also gives you qom_path to cpu so potentially you could read apic-id property of cpu.

But we have only QMP variant of qom-get so monitor needs addition of qom-get command that will be a wrapper around QMP command.

It could be solved in 2 ways:
* use socket-id/core-id/thread-id to specify desired cpu /possible values in 'info hotpluggable-cpus'/

* use apic-id value to specify interrupt controller
- apic-id could be retrieved with new qom-get (qom-get would also be useful to read other properties)
- extend 'info registers' with apic id value

Quoted 10 lines
    for example instead of current:
    
     CPU#1
     EAX=00000c06 EBX=00000000 ECX=000002ff EDX=00000000
     ....

    it would look like:

     CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d)
     ...

We already print "CPU #<n>" on "info cpus", so <n> is already a perfectly good identifier for a human interface. I think HMP should not require any identifier that isn't a simple number that is shown very prominently on "info cpus".

Quoted 4 lines

If we don't want to use cpu_index as an identifier anymore, we can start printing arch ID instead of cpu_index on commands that print "CPU #<n>", and change mon_get_cpu() and monitor_set_cpu() accordingly.

Looks like a good plan, but it probably should touch all commands that use cpu_index, also I'd leave cpu_index in 'info cpus' where it is till we faze it out from CLI.

#4 lore raw
In reply to Igor Mammedov
Quoted 12 lines

On Mon, 17 Jul 2017 21:49:37 -0400

Quoted 5 lines · Yi Wang

Add [vcpu] index support for hmp command "info lapic", which is

useful when debugging ipi and so on. Current behavior is not

changed when the parameter isn't specified.

Quoted 7 lines

we shouldn't expose cpu_index to users anymore,

I would suggest using to use real APIC ID here but we don't

have monitor command that returns APIC IDs for present cpus.

Would you like to explain the reason we shouldn't use cpu_index any

more, which is more straightforward than socket-id/core-id/thread-id?

As Eduardo wrote in the next reply, "CPU #<n>" is already a perfectly

good identifier for a human interface :-)

Many thanks.

---

Best wishes

Yi Wang

#5 lore raw
Quoted 23 lines · On Wed, 19 Jul 2017 12:25:53 +0800 (CST) <[email protected]> wrote:
Quoted 12 lines

On Mon, 17 Jul 2017 21:49:37 -0400

Quoted 5 lines · Yi Wang

Add [vcpu] index support for hmp command "info lapic", which is

useful when debugging ipi and so on. Current behavior is not

changed when the parameter isn't specified.

Quoted 7 lines

we shouldn't expose cpu_index to users anymore,

I would suggest using to use real APIC ID here but we don't

have monitor command that returns APIC IDs for present cpus.

Quoted 7 lines

Would you like to explain the reason we shouldn't use cpu_index any

more, which is more straightforward than socket-id/core-id/thread-id?

As Eduardo wrote in the next reply, "CPU #<n>" is already a perfectly

good identifier for a human interface :-)

We are working on hiding cpu_index from user interface,
it's still work in progress but and having old commands, that use cpu_index and haven't been fixed yet, doesn't mean that we should add more.

Anyways as Eduardo pointed out combo of cpu/info lapic should be sufficient for your task and this patch seems unnecessary.

Quoted 12 lines

Many thanks.

---

Best wishes

Yi Wang

#6 lore raw
In reply to Yi Wang
Quoted 6 lines · Yi Wang

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special?

* info cpustats
* info lapic
* info mem
* info registers
* info tlb
* x
* memsave
* inject-nmi (QMP)

Signature · 1 line
Eduardo
#7 lore raw

Hi Eduardo,

Thank you for your reply!

Quoted 16 lines · Yi Wang
Quoted 5 lines

Add [vcpu] index support for hmp command "info lapic", which is

useful when debugging ipi and so on. Current behavior is not

Quoted 7 lines

changed when the parameter isn't specified.

Quoted 5 lines

We have 8 monitor commands (see below) that use the CPU set by

the "cpu" command (mon_get_cpu()) as input. Why is "info lapic"

special?

When we debugging a problem of ipi, we wanted to verify lapic info

on each vCPU, but we found that we could only get vCPU 0's lapic

through "info lapic", so we supposed this patch could help those

who have the same problem as us.

Quoted 10 lines

* info cpustats

* info lapic

* info mem

* info registers

Quoted 7 lines

* info tlb

* x

* memsave

* inject-nmi (QMP)

Monitor command "info registers" already have "-a" parameter to

show all vCPU's info. -)

May I send some new patches for the other monitor commands, which may

be helpful for analyzing multiple cpu problems?

---

Best wishes

Yi Wang

#8 lore raw
Quoted 20 lines · * [email protected] ([email protected]) wrote:

Hi Eduardo,

Thank you for your reply!

Quoted 15 lines · Yi Wang
Quoted 12 lines

Add [vcpu] index support for hmp command "info lapic", which is

useful when debugging ipi and so on. Current behavior is not

changed when the parameter isn't specified.

Quoted 8 lines
Quoted 3 lines

We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special?

When we debugging a problem of ipi, we wanted to verify lapic info on each vCPU, but we found that we could only get vCPU 0's lapic through "info lapic", so we supposed this patch could help those who have the same problem as us.

I think Eduardo's point is that you can already do:
cpu 0
info lapic
cpu 1
info lapic

Dave

Quoted 34 lines
Quoted 14 lines

* info cpustats

* info lapic

* info mem

* info registers

Quoted 7 lines

* info tlb

* x

* memsave

* inject-nmi (QMP)

Monitor command "info registers" already have "-a" parameter to

show all vCPU's info. -)

May I send some new patches for the other monitor commands, which may

be helpful for analyzing multiple cpu problems?

Quoted 5 lines

---

Best wishes

Yi Wang

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#9 lore raw
In reply to [email protected]
Quoted 13 lines · On Wed, Jul 19, 2017 at 12:47:53PM +0800, [email protected] wrote:

Hi Eduardo,

Thank you for your reply!

Quoted 8 lines · Yi Wang
Quoted 6 lines

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

Quoted 8 lines
Quoted 3 lines

We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special?

When we debugging a problem of ipi, we wanted to verify lapic info on each vCPU, but we found that we could only get vCPU 0's lapic through "info lapic", so we supposed this patch could help those who have the same problem as us.

The "cpu" command is supposed to allow you to select the CPU for those commands. Doesn't it work?

Signature · 1 line
Eduardo
#10 lore raw
Quoted 18 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 17 lines · On Wed, Jul 19, 2017 at 12:47:53PM +0800, [email protected] wrote:

Hi Eduardo,

Thank you for your reply!

Quoted 12 lines · Yi Wang
Quoted 6 lines

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special?

Quoted 7 lines
Quoted 4 lines

When we debugging a problem of ipi, we wanted to verify lapic info on each vCPU, but we found that we could only get vCPU 0's lapic through "info lapic", so we supposed this patch could help those who have the same problem as us.

The "cpu" command is supposed to allow you to select the CPU for those commands. Doesn't it work?

In the other arm to the thread Yi explained that they were driving it via virsh qemu-monitor-command, and I've just tried and it doesn't seem to work; doing:

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

Dave

Quoted 2 lines
Signature · 1 line
Eduardo

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#11 lore raw
Quoted 27 lines · Dr. David Alan Gilbert
Quoted 18 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 17 lines · On Wed, Jul 19, 2017 at 12:47:53PM +0800, [email protected] wrote:

Hi Eduardo,

Thank you for your reply!

Quoted 12 lines · Yi Wang
Quoted 6 lines

Add [vcpu] index support for hmp command "info lapic", which is useful when debugging ipi and so on. Current behavior is not changed when the parameter isn't specified.

We have 8 monitor commands (see below) that use the CPU set by the "cpu" command (mon_get_cpu()) as input. Why is "info lapic" special?

Quoted 7 lines
Quoted 4 lines

When we debugging a problem of ipi, we wanted to verify lapic info on each vCPU, but we found that we could only get vCPU 0's lapic through "info lapic", so we supposed this patch could help those who have the same problem as us.

The "cpu" command is supposed to allow you to select the CPU for those commands. Doesn't it work?

Quoted 7 lines

In the other arm to the thread Yi explained that they were driving it via virsh qemu-monitor-command, and I've just tried and it doesn't seem to work; doing:

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'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'
  dumping local APIC state for CPU 1 
  LVT0     0x00010000 active-hi edge  masked                      Fixed  (vec 0)
  LVT1     0x00010000 active-hi edge  masked                      Fixed  (vec 0)
  LVTPC    0x00010000 active-hi edge  masked                      Fixed  (vec 0)
  LVTERR   0x00010000 active-hi edge  masked                      Fixed  (vec 0)
  LVTTHMR  0x00010000 active-hi edge  masked                      Fixed  (vec 0)
  LVTT     0x00010000 active-hi edge  masked         one-shot     Fixed  (vec 0)
  Timer    DCR=0x0 (divide by 2) initial_count = 0
  SPIV     0x000000ff APIC disabled, focus=off, spurious vec 255
  ICR      0x000000fd physical edge de-assert no-shorthand
  ICR2     0x00000000 cpu 0 (X2APIC ID)
  ESR      0x00000000
  ISR      (none)
  IRR      (none)

APR 0x00 TPR 0x00 DFR 0x0f LDR 0x00 PPR 0x00

Signature · 1 line
Eduardo
#12 lore raw

[adding libvirt]

Quoted 4 lines · Eduardo Habkost
Quoted 3 lines

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

Quoted 8 lines

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.

Quoted 4 lines

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.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#13 lore raw
Quoted 14 lines · Eric Blake

[adding libvirt]

Quoted 10 lines · Eduardo Habkost
Quoted 3 lines

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 13 lines
Quoted 5 lines

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.

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

Regards,
Daniel

Signature · 3 lines
|: 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 :|
#14 lore raw
Quoted 9 lines · Daniel P. Berrange
Quoted 3 lines

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.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#15 lore raw
Quoted 11 lines · Eric Blake
Quoted 9 lines · Daniel P. Berrange
Quoted 3 lines

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.

Quoted 7 lines

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.

Signature · 1 line
Eduardo
#16 lore raw
Quoted 25 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 11 lines · Eric Blake
Quoted 9 lines · Daniel P. Berrange
Quoted 3 lines

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.

Quoted 7 lines

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.

Quoted 5 lines

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

Quoted 2 lines
Signature · 1 line
Eduardo

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#17 lore raw
Quoted 32 lines · Dr. David Alan Gilbert
Quoted 25 lines · * Eduardo Habkost ([email protected]) wrote:
Quoted 11 lines · Eric Blake
Quoted 9 lines · Daniel P. Berrange
Quoted 3 lines

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.

Quoted 7 lines

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.

Quoted 5 lines

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.

Quoted 5 lines

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".

Signature · 1 line
Eduardo
#18 lore raw
Quoted 78 lines · Dr. David Alan Gilbert
Quoted 67 lines · * Eduardo Habkost (address@hidden) wrote:
Quoted 53 lines · Eric Blake
Quoted 31 lines · Daniel P. Berrange
Quoted 11 lines
Quoted 6 lines

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

Quoted 7 lines

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?

Quoted 5 lines

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

Quoted 7 lines

"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

Quoted 7 lines

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).

Quoted 5 lines

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".

Thank you all!

I will rework this patch in this way:

- extend 'info registers' with apic id value instead of current, like this:

      CPU#1 (socket-id: a, core-id: b, thread-id: c, apic-id: d)

- add parameter 'apic id' for 'info lapic'

As to other commands, I want to send some other patches 'cause in my opinion not

all commands need 'apic-id' as index.

---

Best wishes

Yi Wang