Skip to contentSkip to conversation

Move target- and device specific code from monitor

PATCH In review Denis V. Lunev 7 participants 17 messages Sep 10, 2015 – Sep 22, 2015 Kbuild

lore
Share & tools
lore
#0 lore raw

v4 cover Move target- and device specific code from monitor

The monivation of this set is simple. Recently we have proposed patch to monitor.c with specific x86 APIC HMP commands. The patchset was denied with the main motivation "No more arch specific code in monitor.c" This patchset is the first step to move arch specific code from monitor.c targets.

So, monitor.c already contains a lot of generic code, as well as the target specifics code and eventually monitor.c volume will only grow. This trend leads to a variety of fouling code ifdeffery(and combinations thereof), poor readability, and entanglement of architecture of the project. If someone wants to improve processing logic commands at the monitor, it isn't necessarily must differentiate amongst the implementation of some ARM or x86_64 specific commands, because the project already has separation of target specific code on directories.

The presented solution is not the best, but it is quite simple (PATCH doesn't add more code!) and decides the above mentioned issue. Subsequently it will not prevent the introduction of more advanced mechanism that can more effectively resolve the issue.

There is a issue with the placement of code for multiple architectures (isn't for everyone), but this code is very small. This patch is a step towards solving the issue associated with maintaining the purity of the code and structure of the project, which solves not all, but doing a little better than it is.

Changes from v3:
- removed weak symbol, because it does not work on all platforms
- qemu-monitor-info.texi moved to patch 4

Changes from v2:
- target_monitor_defs provides a target-specific array monitor_defs[] This call is added through stub to all archs as a weak symbol. It should be redefined on each specific architecture
- fix end of table info (information about the system state)
- ported to current HEAD (iothreads & skeys commands descriptions moved)

Changes from v1:
- ported to new head

Pavel Butsykin (4):
hmp-commands-info: move info_cmds content out of monitor.c
monitor: remove target-specific code from monitor.c hmp-commands.hx: fix end of table info
monitor: added generation of documentation for hmp-commands-info.hx

 .gitignore                       |    1 +
 Makefile                         |   10 +-
 Makefile.target                  |    5 +-
 hmp-commands-info.hx             |  749 +++++++++++++++++++++++
 hmp-commands.hx                  |  120 ----
 include/monitor/monitor-common.h |   45 ++
 include/qemu/typedefs.h          |    1 +
 monitor.c                        | 1249 +-------------------------------------
 qemu-doc.texi                    |    2 +
 stubs/Makefile.objs              |    1 +
 stubs/target-monitor-defs.c      |    9 +
 target-i386/Makefile.objs        |    2 +-
 target-i386/monitor.c            |  494 +++++++++++++++
 target-ppc/Makefile.objs         |    2 +-
 target-ppc/monitor.c             |  255 ++++++++
 target-sh4/Makefile.objs         |    1 +
 target-sh4/monitor.c             |   52 ++
 target-sparc/Makefile.objs       |    2 +-
 target-sparc/monitor.c           |  158 +++++
 target-xtensa/Makefile.objs      |    1 +
 target-xtensa/monitor.c          |   34 ++
 21 files changed, 1827 insertions(+), 1366 deletions(-)
 create mode 100644 hmp-commands-info.hx
 create mode 100644 include/monitor/monitor-common.h
 create mode 100644 stubs/target-monitor-defs.c
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sh4/monitor.c
 create mode 100644 target-sparc/monitor.c
 create mode 100644 target-xtensa/monitor.c
Signature · 1 line
2.1.4
#1 lore raw

PATCH v4 1/4 hmp-commands-info: move info_cmds content out of monitor.c

From: Pavel Butsykin <[email protected]>

For moving target- and device-specific code from monitor.c, to beginning we move info_cmds content to hmp-commands-info.hx

---
 Makefile.target      |   5 +-
 hmp-commands-info.hx | 741 +++++++++++++++++++++++++++++++++++++++++++++++++++
 monitor.c            | 389 +--------------------------
 3 files changed, 747 insertions(+), 388 deletions(-)
 create mode 100644 hmp-commands-info.hx
Makefile.target +4 -1
index 3e7aafd..93ae46d 100644
@@ -151,7 +151,7 @@ else
 obj-y += hw/$(TARGET_BASE_ARCH)/
 endif
 
-GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
+GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h
 
 endif # CONFIG_SOFTMMU
 
@@ -193,6 +193,9 @@ gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
+hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx
+	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
+
 qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
hmp-commands-info.hx new file +741 -0

741 lines not on this page · raw message

monitor.c +2 -387

395 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] hmp-commands-info: move info_cmds content out of monitor.c

Quoted 9 lines · Denis V. Lunev

From: Pavel Butsykin <[email protected]>

For moving target- and device-specific code from monitor.c, to beginning we move info_cmds content to hmp-commands-info.hx

For me, this commit drops "info pci".

Before:

    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio
    QEMU 2.4.50 monitor - type 'help' for more information
    (qemu) info pci
      Bus  0, device   0, function 0:
        Host bridge: PCI device 8086:1237
          id ""
      Bus  0, device   1, function 0:
        ISA bridge: PCI device 8086:7000
          id ""
      Bus  0, device   1, function 1:
        IDE controller: PCI device 8086:7010
          BAR4: I/O at 0xffffffffffffffff [0x000e].
          id ""
      Bus  0, device   1, function 3:
        Bridge: PCI device 8086:7113
          IRQ 0.
          id ""

After:

(qemu) info pci
unknown command: 'pci'

Please advise.

#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] hmp-commands-info: move info_cmds content out of monitor.c

Quoted 34 lines · Markus Armbruster
Quoted 9 lines · Denis V. Lunev

From: Pavel Butsykin <[email protected]>

For moving target- and device-specific code from monitor.c, to beginning we move info_cmds content to hmp-commands-info.hx

For me, this commit drops "info pci".

Before:

    $ qemu-system-x86_64 -nodefaults -S -display none -monitor stdio
    QEMU 2.4.50 monitor - type 'help' for more information
    (qemu) info pci
      Bus  0, device   0, function 0:
        Host bridge: PCI device 8086:1237
          id ""
      Bus  0, device   1, function 0:
        ISA bridge: PCI device 8086:7000
          id ""
      Bus  0, device   1, function 1:
        IDE controller: PCI device 8086:7010
          BAR4: I/O at 0xffffffffffffffff [0x000e].
          id ""
      Bus  0, device   1, function 3:
        Bridge: PCI device 8086:7113
          IRQ 0.
          id ""
Quoted 6 lines

After:

(qemu) info pci
unknown command: 'pci'

Please advise.

s/advise/fix/... patch sent. Let me know who shall send it to Peter.

(BTW, it's obvious that I don't scale to 100+ patches per month. Do you still have that script of yours looking for unmaintained areas?).

Paolo

#4 lore raw

Re: [Qemu-devel] [PATCH 1/4] hmp-commands-info: move info_cmds content out of monitor.c

Paolo Bonzini <[email protected]> writes:

[...]

Quoted 2 lines

(BTW, it's obvious that I don't scale to 100+ patches per month. Do you still have that script of yours looking for unmaintained areas?).

I'll follow up with up-to-date data.

#5 lore raw

PATCH 1/1 hmp-commands-info.hx: fix drops hmp "info pci"

In reply to Markus Armbruster

The hmp command "info pci" accidentally lost when moving from monitor.c

---
 hmp-commands-info.hx | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
hmp-commands-info.hx +14 -0
index 9f5a158..a311b46 100644
@@ -183,6 +183,20 @@ STEXI
 Show i8259 (PIC) state.
 ETEXI
 
+    {
+        .name       = "pci",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show PCI info",
+        .mhandler.cmd = hmp_info_pci,
+    },
+
+STEXI
+@item info pci
+@findex pci
+show emulated PCI device info
+ETEXI
+
 #if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) || \
     defined(TARGET_PPC) || defined(TARGET_XTENSA)
     {
Signature · 1 line
1.9.1
#6 lore raw

Re: [Qemu-devel] [PATCH] hmp-commands-info.hx: fix drops hmp "info pci"

Quoted 6 lines · Pavel Butsykin

The hmp command "info pci" accidentally lost when moving from monitor.c

---
 hmp-commands-info.hx | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Paolo's variant has a better commit message:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04893.html

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH] hmp-commands-info.hx: fix drops hmp "info pci"

Quoted 10 lines · Eric Blake
Quoted 6 lines · Pavel Butsykin

The hmp command "info pci" accidentally lost when moving from monitor.c

---
  hmp-commands-info.hx | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

Paolo's variant has a better commit message:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04893.html

Ok. I just had to respond to the situation)
(Because the notification about the patch didn't come to me..)

#8 lore raw

Re: [Qemu-devel] [PATCH] hmp-commands-info.hx: fix drops hmp "info pci"

Quoted 4 lines · Pavel Butsykin
Quoted 3 lines · Eric Blake
Quoted 2 lines · Pavel Butsykin

The hmp command "info pci" accidentally lost when moving from monitor.c

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
---
  hmp-commands-info.hx | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

Paolo's variant has a better commit message:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04893.html

Ok. I just had to respond to the situation)

Appreciated! It's much better to have two fixes for a regression quickly than one late :)

Quoted 1 line

(Because the notification about the patch didn't come to me..)

#9 lore raw

Re: [Qemu-devel] [PATCH] hmp-commands-info.hx: fix drops hmp "info pci"

Quoted 10 lines · Markus Armbruster
Quoted 8 lines · Pavel Butsykin
Quoted 7 lines · Eric Blake
Quoted 6 lines · Pavel Butsykin

The hmp command "info pci" accidentally lost when moving from monitor.c

---
  hmp-commands-info.hx | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Paolo's variant has a better commit message:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04893.html

Ok. I just had to respond to the situation)

Appreciated! It's much better to have two fixes for a regression quickly than one late :)

Are you pulling one of the two?

Paolo

#10 lore raw

Re: [Qemu-devel] [PATCH] hmp-commands-info.hx: fix drops hmp "info pci"

Quoted 14 lines · Paolo Bonzini
Quoted 13 lines · Markus Armbruster
Quoted 11 lines · Pavel Butsykin
Quoted 10 lines · Eric Blake
Quoted 6 lines · Pavel Butsykin

The hmp command "info pci" accidentally lost when moving from monitor.c

---
  hmp-commands-info.hx | 14 ++++++++++++++
  1 file changed, 14 insertions(+)

Paolo's variant has a better commit message:
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04893.html

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Ok. I just had to respond to the situation)

Appreciated! It's much better to have two fixes for a regression quickly than one late :)

Are you pulling one of the two?

Can do. I'll reply to the one I apply to my monitor-next branch.

#11 lore raw

PATCH v4 2/4 monitor: remove target-specific code from monitor.c

In reply to Denis V. Lunev

From: Pavel Butsykin <[email protected]>

Move target-specific code out of /monitor.c to /target-*/monitor.c, this will avoid code cluttering and using random ifdeffery. The solution is quite simple, but solves the issue of the separation of target-specific code from monitor.

---
 include/monitor/monitor-common.h |  45 ++
 include/qemu/typedefs.h          |   1 +
 monitor.c                        | 860 +--------------------------------------
 stubs/Makefile.objs              |   1 +
 stubs/target-monitor-defs.c      |   9 +
 target-i386/Makefile.objs        |   2 +-
 target-i386/monitor.c            | 494 ++++++++++++++++++++++
 target-ppc/Makefile.objs         |   2 +-
 target-ppc/monitor.c             | 255 ++++++++++++
 target-sh4/Makefile.objs         |   1 +
 target-sh4/monitor.c             |  52 +++
 target-sparc/Makefile.objs       |   2 +-
 target-sparc/monitor.c           | 158 +++++++
 target-xtensa/Makefile.objs      |   1 +
 target-xtensa/monitor.c          |  34 ++
 15 files changed, 1062 insertions(+), 855 deletions(-)
 create mode 100644 include/monitor/monitor-common.h
 create mode 100644 stubs/target-monitor-defs.c
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sh4/monitor.c
 create mode 100644 target-sparc/monitor.c
 create mode 100644 target-xtensa/monitor.c
include/monitor/monitor-common.h new file +45 -0
new file mode 100644
index 0000000..7d1ec5a
@@ -0,0 +1,45 @@
+/*
+ * QEMU monitor
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef MONITOR_COMMON_H
+#define MONITOR_COMMON_H
+
+#define MD_TLONG 0
+#define MD_I32   1
+
+typedef struct MonitorDef {
+    const char *name;
+    int offset;
+    target_long (*get_value)(const struct MonitorDef *md, int val);
+    int type;
+} MonitorDef;
+
+const MonitorDef *target_monitor_defs(void);
+
+CPUArchState *mon_get_cpu_env(void);
+
+void hmp_info_mem(Monitor *mon, const QDict *qdict);
+void hmp_info_tlb(Monitor *mon, const QDict *qdict);
+void hmp_mce(Monitor *mon, const QDict *qdict);
+
+#endif /* MONITOR_COMMON */
include/qemu/typedefs.h +1 -0
index f8a9dd6..97ac727 100644
@@ -80,5 +80,6 @@ typedef struct SSIBus SSIBus;
 typedef struct uWireSlave uWireSlave;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct Visitor Visitor;
+typedef struct MonitorDef MonitorDef;
 
 #endif /* QEMU_TYPEDEFS_H */
monitor.c +8 -852

898 lines not on this page · raw message

stubs/Makefile.objs +1 -0
index 9937a12..85e4e81 100644
@@ -38,3 +38,4 @@ stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
 stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += target-monitor-defs.o
stubs/target-monitor-defs.c new file +9 -0
new file mode 100644
index 0000000..7d8d182
@@ -0,0 +1,9 @@
+#include "stddef.h"
+#include "qemu/typedefs.h"
+
+const MonitorDef *target_monitor_defs(void);
+
+const MonitorDef *target_monitor_defs(void)
+{
+    return NULL;
+}
target-i386/Makefile.objs +1 -1
index 7a1df2c..3da413e 100644
@@ -2,6 +2,6 @@ obj-y += translate.o helper.o cpu.o
 obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
 obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
 obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
+obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
target-i386/monitor.c new file +494 -0

494 lines not on this page · raw message

target-ppc/Makefile.objs +1 -1
index a7ae392..47a3e98 100644
@@ -1,7 +1,7 @@
 obj-y += cpu-models.o
 obj-y += translate.o
 ifeq ($(CONFIG_SOFTMMU),y)
-obj-y += machine.o mmu_helper.o mmu-hash32.o
+obj-y += machine.o mmu_helper.o mmu-hash32.o monitor.o
 obj-$(TARGET_PPC64) += mmu-hash64.o arch_dump.o
 endif
 obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
target-ppc/monitor.c new file +255 -0

255 lines not on this page · raw message

target-sh4/Makefile.objs +1 -0
index a285358..2c25d96 100644
@@ -1,2 +1,3 @@
 obj-y += translate.o op_helper.o helper.o cpu.o
+obj-$(CONFIG_SOFTMMU) += monitor.o
 obj-y += gdbstub.o
target-sh4/monitor.c new file +52 -0

52 lines not on this page · raw message

target-sparc/Makefile.objs +1 -1
index 1cd81cc..ec90569 100644
@@ -1,4 +1,4 @@
-obj-$(CONFIG_SOFTMMU) += machine.o
+obj-$(CONFIG_SOFTMMU) += machine.o monitor.o
 obj-y += translate.o helper.o cpu.o
 obj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
 obj-$(TARGET_SPARC) += int32_helper.o
target-sparc/monitor.c new file +158 -0

158 lines not on this page · raw message

target-xtensa/Makefile.objs +1 -0
index 5c150a8..481de91 100644
@@ -2,5 +2,6 @@ obj-y += xtensa-semi.o
 obj-y += core-dc232b.o
 obj-y += core-dc233c.o
 obj-y += core-fsf.o
+obj-$(CONFIG_SOFTMMU) += monitor.o
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-y += gdbstub.o
target-xtensa/monitor.c new file +34 -0
new file mode 100644
index 0000000..412379b
@@ -0,0 +1,34 @@
+/*
+ * QEMU monitor
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "cpu.h"
+#include "monitor/monitor.h"
+#include "monitor/monitor-common.h"
+#include "hmp.h"
+
+void hmp_info_tlb(Monitor *mon, const QDict *qdict)
+{
+    CPUArchState *env1 = mon_get_cpu_env();
+
+    dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1);
+}
Signature · 1 line
2.1.4
#12 lore raw

PATCH v4 3/4 hmp-commands.hx: fix end of table info

In reply to Denis V. Lunev

From: Pavel Butsykin <[email protected]>

The table info(information about the system state) closes earlier and some of its elements are outside(trace-events, rocker, etc). This can be confusing and lead to additional bugs.

---
 hmp-commands.hx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hmp-commands.hx +4 -1
index 286dcc7..89fc09f 100644
@@ -1811,7 +1811,6 @@ show the memory devices
 Display the value of a storage key (s390 only)
 @item info iothreads
 show iothreads
-@end table
 ETEXI
 
 STEXI
@@ -1846,3 +1845,7 @@ ETEXI
 STEXI
 @end table
 ETEXI
+
+STEXI
+@end table
+ETEXI
Signature · 1 line
2.1.4
#13 lore raw

PATCH v4 4/4 monitor: added generation of documentation for hmp-commands-info.hx

In reply to Denis V. Lunev

From: Pavel Butsykin <[email protected]>

It will be easier if you need to add info-commands to edit only hmp-commands-info.hx, before this had to edit monitor.c and hmp-commands.hx.

Quoted 1 line

From the build point of view all documentation is saved into

qemu-monitor-info.texi which from now on is used for all user documentation building.

---
 .gitignore           |   1 +
 Makefile             |  10 +++--
 hmp-commands-info.hx |   8 ++++
 hmp-commands.hx      | 123 ---------------------------------------------------
 qemu-doc.texi        |   2 +
 5 files changed, 18 insertions(+), 126 deletions(-)
.gitignore +1 -0
index cb4b8ec..367bc70 100644
@@ -49,6 +49,7 @@
 /qemu-ga
 /qemu-bridge-helper
 /qemu-monitor.texi
+/qemu-monitor-info.texi
 /qmp-commands.txt
 /vscclient
 /fsdev/virtfs-proxy-helper
Makefile +7 -3
index 9ce3972..c540442 100644
@@ -344,7 +344,7 @@ qemu-%.tar.bz2:
 	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
 
 distclean: clean
-	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi
+	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
 	rm -f config-all-devices.mak config-all-disas.mak config.status
 	rm -f po/*.mo tests/qemu-iotests/common.env
 	rm -f roms/seabios/config.mak roms/vgabios/config.mak
@@ -511,13 +511,16 @@ qemu-options.texi: $(SRC_PATH)/qemu-options.hx
 qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
+qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx
+	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
+
 qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
 
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
-qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
+qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
 	$(call quiet-command, \
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
 	  $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
@@ -560,7 +563,8 @@ pdf: qemu-doc.pdf qemu-tech.pdf
 
 qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
 	qemu-img.texi qemu-nbd.texi qemu-options.texi \
-	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi
+	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
+	qemu-monitor-info.texi
 
 ifdef CONFIG_WIN32
 
hmp-commands-info.hx +8 -0
index 1d0906a..9f5a158 100644
@@ -7,6 +7,10 @@ HXCOMM HXCOMM can be used for comments, discarded from both texi and C
 
 STEXI
 @table @option
+@item info @var{subcommand}
+@findex info
+Show various information about the system state.
+@table @option
 ETEXI
 
     {
@@ -739,3 +743,7 @@ ETEXI
 STEXI
 @end table
 ETEXI
+
+STEXI
+@end table
+ETEXI
hmp-commands.hx +0 -123

128 lines not on this page · raw message

qemu-doc.texi +2 -0
index ea9b3fb..b949147 100644
@@ -391,6 +391,8 @@ The following commands are available:
 
 @include qemu-monitor.texi
 
+@include qemu-monitor-info.texi
+
 @subsection Integer expressions
 
 The monitor understands integers expressions for every integer
Signature · 1 line
2.1.4
#14 lore raw
In reply to Denis V. Lunev
Quoted 37 lines · Denis V. Lunev

The monivation of this set is simple. Recently we have proposed patch to monitor.c with specific x86 APIC HMP commands. The patchset was denied with the main motivation "No more arch specific code in monitor.c" This patchset is the first step to move arch specific code from monitor.c targets.

So, monitor.c already contains a lot of generic code, as well as the target specifics code and eventually monitor.c volume will only grow. This trend leads to a variety of fouling code ifdeffery(and combinations thereof), poor readability, and entanglement of architecture of the project. If someone wants to improve processing logic commands at the monitor, it isn't necessarily must differentiate amongst the implementation of some ARM or x86_64 specific commands, because the project already has separation of target specific code on directories.

The presented solution is not the best, but it is quite simple (PATCH doesn't add more code!) and decides the above mentioned issue. Subsequently it will not prevent the introduction of more advanced mechanism that can more effectively resolve the issue.

There is a issue with the placement of code for multiple architectures (isn't for everyone), but this code is very small. This patch is a step towards solving the issue associated with maintaining the purity of the code and structure of the project, which solves not all, but doing a little better than it is.

Changes from v3:
- removed weak symbol, because it does not work on all platforms
- qemu-monitor-info.texi moved to patch 4

Changes from v2:
- target_monitor_defs provides a target-specific array monitor_defs[] This call is added through stub to all archs as a weak symbol. It should be redefined on each specific architecture
- fix end of table info (information about the system state)
- ported to current HEAD (iothreads & skeys commands descriptions moved)

Quoted 8 lines

Changes from v1:
- ported to new head

I need this!

This is a piece of the puzzle for multi arch. I'll add it to my review queue, but can I take a CC on this in future incase it spins again before I get a chance?

Regards,
Peter

Quoted 41 lines

Pavel Butsykin (4):
hmp-commands-info: move info_cmds content out of monitor.c
monitor: remove target-specific code from monitor.c hmp-commands.hx: fix end of table info
monitor: added generation of documentation for hmp-commands-info.hx

 .gitignore                       |    1 +
 Makefile                         |   10 +-
 Makefile.target                  |    5 +-
 hmp-commands-info.hx             |  749 +++++++++++++++++++++++
 hmp-commands.hx                  |  120 ----
 include/monitor/monitor-common.h |   45 ++
 include/qemu/typedefs.h          |    1 +
 monitor.c                        | 1249 +-------------------------------------
 qemu-doc.texi                    |    2 +
 stubs/Makefile.objs              |    1 +
 stubs/target-monitor-defs.c      |    9 +
 target-i386/Makefile.objs        |    2 +-
 target-i386/monitor.c            |  494 +++++++++++++++
 target-ppc/Makefile.objs         |    2 +-
 target-ppc/monitor.c             |  255 ++++++++
 target-sh4/Makefile.objs         |    1 +
 target-sh4/monitor.c             |   52 ++
 target-sparc/Makefile.objs       |    2 +-
 target-sparc/monitor.c           |  158 +++++
 target-xtensa/Makefile.objs      |    1 +
 target-xtensa/monitor.c          |   34 ++
 21 files changed, 1827 insertions(+), 1366 deletions(-)
 create mode 100644 hmp-commands-info.hx
 create mode 100644 include/monitor/monitor-common.h
 create mode 100644 stubs/target-monitor-defs.c
 create mode 100644 target-i386/monitor.c
 create mode 100644 target-ppc/monitor.c
 create mode 100644 target-sh4/monitor.c
 create mode 100644 target-sparc/monitor.c
 create mode 100644 target-xtensa/monitor.c

--
2.1.4

#15 lore raw
Quoted 10 lines · Peter Crosthwaite
Quoted 5 lines
Quoted 5 lines

I need this!

This is a piece of the puzzle for multi arch. I'll add it to my review queue, but can I take a CC on this in future incase it spins again before I get a chance?

Actually it's ready. :) I've just applied and haven't even compiled it, but I've already pushed it for you to a branch for-upstream-next on my github repo.

Paolo

#16 lore raw
In reply to Peter Crosthwaite
Quoted 46 lines · Peter Crosthwaite
Quoted 37 lines · Denis V. Lunev

The monivation of this set is simple. Recently we have proposed patch to monitor.c with specific x86 APIC HMP commands. The patchset was denied with the main motivation "No more arch specific code in monitor.c" This patchset is the first step to move arch specific code from monitor.c targets.

So, monitor.c already contains a lot of generic code, as well as the target specifics code and eventually monitor.c volume will only grow. This trend leads to a variety of fouling code ifdeffery(and combinations thereof), poor readability, and entanglement of architecture of the project. If someone wants to improve processing logic commands at the monitor, it isn't necessarily must differentiate amongst the implementation of some ARM or x86_64 specific commands, because the project already has separation of target specific code on directories.

The presented solution is not the best, but it is quite simple (PATCH doesn't add more code!) and decides the above mentioned issue. Subsequently it will not prevent the introduction of more advanced mechanism that can more effectively resolve the issue.

There is a issue with the placement of code for multiple architectures (isn't for everyone), but this code is very small. This patch is a step towards solving the issue associated with maintaining the purity of the code and structure of the project, which solves not all, but doing a little better than it is.

Changes from v3:
- removed weak symbol, because it does not work on all platforms
- qemu-monitor-info.texi moved to patch 4

Changes from v2:
- target_monitor_defs provides a target-specific array monitor_defs[] This call is added through stub to all archs as a weak symbol. It should be redefined on each specific architecture
- fix end of table info (information about the system state)
- ported to current HEAD (iothreads & skeys commands descriptions moved)

Quoted 8 lines

Changes from v1:
- ported to new head

Quoted 8 lines

I need this!

This is a piece of the puzzle for multi arch. I'll add it to my review queue, but can I take a CC on this in future incase it spins again before I get a chance?

Regards,
Peter

Sure! though I hope that this is a last re-spin...

Den