Skip to contentSkip to conversation

qapi: Restrict machine (and migration) specific commands

PATCH Applied Philippe Mathieu-Daudé 3 participants 13 messages Oct 12, 2020 – Oct 20, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover qapi: Restrict machine (and migration) specific commands

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

Since v1:
- Added A-b tags
- Rebased

Philippe Mathieu-Daudé (5):
qapi: Restrict 'inject-nmi' command to machine code
qapi: Restrict 'system wakeup/reset/powerdown' commands to
machine.json
qapi: Restrict '(p)memsave' command to machine code
qapi: Restrict 'query-kvm' command to machine code
qapi: Restrict Xen migration commands to migration.json

 qapi/machine.json      | 168 +++++++++++++++++++++++++++++++++
 qapi/migration.json    |  41 ++++++++
 qapi/misc.json         | 209 -----------------------------------------
 accel/stubs/xen-stub.c |   2 +-
 hw/i386/xen/xen-hvm.c  |   2 +-
 migration/savevm.c     |   1 -
 softmmu/cpus.c         |   1 +
 ui/gtk.c               |   1 +
 ui/cocoa.m             |   1 +
 9 files changed, 214 insertions(+), 212 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/5 qapi: Restrict 'inject-nmi' command to machine code

Restricting 'inject-nmi' to machine.json pulls slightly less QAPI-generated code into user-mode and tools.

---
 qapi/machine.json | 20 ++++++++++++++++++++
 qapi/misc.json    | 20 --------------------
 softmmu/cpus.c    |  1 +
 3 files changed, 21 insertions(+), 20 deletions(-)
qapi/machine.json +20 -0
index 756dacb06fd..073b1c98b26 100644
@@ -484,6 +484,26 @@
 { 'enum': 'LostTickPolicy',
   'data': ['discard', 'delay', 'slew' ] }
 
+##
+# @inject-nmi:
+#
+# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or all CPUs (ppc64).
+# The command fails when the guest doesn't support injecting.
+#
+# Returns:  If successful, nothing
+#
+# Since:  0.14.0
+#
+# Note: prior to 2.1, this command was only supported for x86 and s390 VMs
+#
+# Example:
+#
+# -> { "execute": "inject-nmi" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'inject-nmi' }
+
 ##
 # @NumaOptionsType:
 #
qapi/misc.json +0 -20
index 7d1e2e9aaef..3fe9cc21b4b 100644
@@ -341,26 +341,6 @@
 ##
 { 'command': 'system_wakeup' }
 
-##
-# @inject-nmi:
-#
-# Injects a Non-Maskable Interrupt into the default CPU (x86/s390) or all CPUs (ppc64).
-# The command fails when the guest doesn't support injecting.
-#
-# Returns:  If successful, nothing
-#
-# Since:  0.14.0
-#
-# Note: prior to 2.1, this command was only supported for x86 and s390 VMs
-#
-# Example:
-#
-# -> { "execute": "inject-nmi" }
-# <- { "return": {} }
-#
-##
-{ 'command': 'inject-nmi' }
-
 ##
 # @human-monitor-command:
 #
softmmu/cpus.c +1 -0
index 47cceddd805..e46ac68ad09 100644
@@ -26,6 +26,7 @@
 #include "qemu-common.h"
 #include "monitor/monitor.h"
 #include "qapi/error.h"
+#include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qapi/qapi-events-run-state.h"
 #include "qapi/qmp/qerror.h"
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/5 qapi: Restrict 'system wakeup/reset/powerdown' commands to machine.json

In reply to Philippe Mathieu-Daudé

Restricting system_wakeup/system_reset/system_powerdown to machine.json pulls slightly less QAPI-generated code into user-mode and tools.

---
 qapi/machine.json | 57 +++++++++++++++++++++++++++++++++++++++++++++++
 qapi/misc.json    | 57 -----------------------------------------------
 ui/gtk.c          |  1 +
 ui/cocoa.m        |  1 +
 4 files changed, 59 insertions(+), 57 deletions(-)
qapi/machine.json +57 -0
index 073b1c98b26..55328d4f3ca 100644
@@ -452,6 +452,63 @@
 ##
 { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
 
+##
+# @system_reset:
+#
+# Performs a hard reset of a guest.
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "system_reset" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_reset' }
+
+##
+# @system_powerdown:
+#
+# Requests that a guest perform a powerdown operation.
+#
+# Since: 0.14.0
+#
+# Notes: A guest may or may not respond to this command.  This command
+#        returning does not indicate that a guest has accepted the request or
+#        that it has shut down.  Many guests will respond to this command by
+#        prompting the user in some way.
+# Example:
+#
+# -> { "execute": "system_powerdown" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_powerdown' }
+
+##
+# @system_wakeup:
+#
+# Wake up guest from suspend. If the guest has wake-up from suspend
+# support enabled (wakeup-suspend-support flag from
+# query-current-machine), wake-up guest from suspend if the guest is
+# in SUSPENDED state. Return an error otherwise.
+#
+# Since:  1.1
+#
+# Returns:  nothing.
+#
+# Note: prior to 4.0, this command does nothing in case the guest
+#       isn't suspended.
+#
+# Example:
+#
+# -> { "execute": "system_wakeup" }
+# <- { "return": {} }
+#
+##
+{ 'command': 'system_wakeup' }
+
 ##
 # @LostTickPolicy:
 #
qapi/misc.json +0 -57

69 lines not on this page · raw message

ui/gtk.c +1 -0
index b11594d817a..a752aa22be0 100644
@@ -33,6 +33,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-control.h"
+#include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qemu/cutils.h"
 
ui/cocoa.m +1 -0
index 0910b4a7166..f32adc3074f 100644
@@ -35,6 +35,7 @@
 #include "sysemu/cpu-throttle.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-block.h"
+#include "qapi/qapi-commands-machine.h"
 #include "qapi/qapi-commands-misc.h"
 #include "sysemu/blockdev.h"
 #include "qemu-version.h"
Signature · 1 line
2.26.2
#3 lore raw

PATCH v2 3/5 qapi: Restrict '(p)memsave' command to machine code

In reply to Philippe Mathieu-Daudé

Restricting memsave/pmemsave to machine.json pulls slightly less QAPI-generated code into user-mode and tools.

---
 qapi/machine.json | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 qapi/misc.json    | 61 -----------------------------------------------
 2 files changed, 61 insertions(+), 61 deletions(-)
qapi/machine.json +61 -0
index 55328d4f3ca..5a3bbcae01b 100644
@@ -887,6 +887,67 @@
 { 'enum': 'HostMemPolicy',
   'data': [ 'default', 'preferred', 'bind', 'interleave' ] }
 
+##
+# @memsave:
+#
+# Save a portion of guest memory to a file.
+#
+# @val: the virtual address of the guest to start from
+#
+# @size: the size of memory region to save
+#
+# @filename: the file to save the memory to as binary data
+#
+# @cpu-index: the index of the virtual CPU to use for translating the
+#             virtual address (defaults to CPU 0)
+#
+# Returns: Nothing on success
+#
+# Since: 0.14.0
+#
+# Notes: Errors were not reliably returned until 1.1
+#
+# Example:
+#
+# -> { "execute": "memsave",
+#      "arguments": { "val": 10,
+#                     "size": 100,
+#                     "filename": "/tmp/virtual-mem-dump" } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'memsave',
+  'data': {'val': 'int', 'size': 'int', 'filename': 'str', '*cpu-index': 'int'} }
+
+##
+# @pmemsave:
+#
+# Save a portion of guest physical memory to a file.
+#
+# @val: the physical address of the guest to start from
+#
+# @size: the size of memory region to save
+#
+# @filename: the file to save the memory to as binary data
+#
+# Returns: Nothing on success
+#
+# Since: 0.14.0
+#
+# Notes: Errors were not reliably returned until 1.1
+#
+# Example:
+#
+# -> { "execute": "pmemsave",
+#      "arguments": { "val": 10,
+#                     "size": 100,
+#                     "filename": "/tmp/physical-mem-dump" } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'pmemsave',
+  'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
+
 ##
 # @Memdev:
 #
qapi/misc.json +0 -61

67 lines not on this page · raw message

Signature · 1 line
2.26.2
#4 lore raw

PATCH v2 4/5 qapi: Restrict 'query-kvm' command to machine code

In reply to Philippe Mathieu-Daudé

Restricting query-kvm to machine.json pulls slightly less QAPI-generated code into user-mode and tools.

---
 qapi/machine.json | 30 ++++++++++++++++++++++++++++++
 qapi/misc.json    | 30 ------------------------------
 2 files changed, 30 insertions(+), 30 deletions(-)
qapi/machine.json +30 -0
index 5a3bbcae01b..7c9a263778d 100644
@@ -561,6 +561,36 @@
 ##
 { 'command': 'inject-nmi' }
 
+##
+# @KvmInfo:
+#
+# Information about support for KVM acceleration
+#
+# @enabled: true if KVM acceleration is active
+#
+# @present: true if KVM acceleration is built into this executable
+#
+# Since: 0.14.0
+##
+{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
+
+##
+# @query-kvm:
+#
+# Returns information about KVM acceleration
+#
+# Returns: @KvmInfo
+#
+# Since: 0.14.0
+#
+# Example:
+#
+# -> { "execute": "query-kvm" }
+# <- { "return": { "enabled": true, "present": true } }
+#
+##
+{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
+
 ##
 # @NumaOptionsType:
 #
qapi/misc.json +0 -30
index 9fa702b0f66..363115c1edb 100644
@@ -68,36 +68,6 @@
 ##
 { 'command': 'query-name', 'returns': 'NameInfo', 'allow-preconfig': true }
 
-##
-# @KvmInfo:
-#
-# Information about support for KVM acceleration
-#
-# @enabled: true if KVM acceleration is active
-#
-# @present: true if KVM acceleration is built into this executable
-#
-# Since: 0.14.0
-##
-{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
-
-##
-# @query-kvm:
-#
-# Returns information about KVM acceleration
-#
-# Returns: @KvmInfo
-#
-# Since: 0.14.0
-#
-# Example:
-#
-# -> { "execute": "query-kvm" }
-# <- { "return": { "enabled": true, "present": true } }
-#
-##
-{ 'command': 'query-kvm', 'returns': 'KvmInfo' }
-
 ##
 # @IOThreadInfo:
 #
Signature · 1 line
2.26.2
#5 lore raw

PATCH v2 5/5 qapi: Restrict Xen migration commands to migration.json

In reply to Philippe Mathieu-Daudé

Restricting xen-set-global-dirty-log and xen-load-devices-state commands migration.json pulls slightly less QAPI-generated code into user-mode and tools.

---
 qapi/migration.json    | 41 +++++++++++++++++++++++++++++++++++++++++
 qapi/misc.json         | 41 -----------------------------------------
 accel/stubs/xen-stub.c |  2 +-
 hw/i386/xen/xen-hvm.c  |  2 +-
 migration/savevm.c     |  1 -
 5 files changed, 43 insertions(+), 44 deletions(-)
qapi/migration.json +41 -0
index 7f5e6fd681a..cb30f4c729b 100644
@@ -1551,6 +1551,47 @@
 { 'command': 'xen-save-devices-state',
   'data': {'filename': 'str', '*live':'bool' } }
 
+##
+# @xen-set-global-dirty-log:
+#
+# Enable or disable the global dirty log mode.
+#
+# @enable: true to enable, false to disable.
+#
+# Returns: nothing
+#
+# Since: 1.3
+#
+# Example:
+#
+# -> { "execute": "xen-set-global-dirty-log",
+#      "arguments": { "enable": true } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
+
+##
+# @xen-load-devices-state:
+#
+# Load the state of all devices from file. The RAM and the block devices
+# of the VM are not loaded by this command.
+#
+# @filename: the file to load the state of the devices from as binary
+#            data. See xen-save-devices-state.txt for a description of the binary
+#            format.
+#
+# Since: 2.7
+#
+# Example:
+#
+# -> { "execute": "xen-load-devices-state",
+#      "arguments": { "filename": "/tmp/resume" } }
+# <- { "return": {} }
+#
+##
+{ 'command': 'xen-load-devices-state', 'data': {'filename': 'str'} }
+
 ##
 # @xen-set-replication:
 #
qapi/misc.json +0 -41

50 lines not on this page · raw message

accel/stubs/xen-stub.c +1 -1
index 7ba0b697f49..7054965c480 100644
@@ -7,7 +7,7 @@
 
 #include "qemu/osdep.h"
 #include "sysemu/xen.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-migration.h"
 
 bool xen_allowed;
 
hw/i386/xen/xen-hvm.c +1 -1
index f3ababf33b6..9519c33c098 100644
@@ -24,7 +24,7 @@
 #include "hw/xen/xen-bus.h"
 #include "hw/xen/xen-x86.h"
 #include "qapi/error.h"
-#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-migration.h"
 #include "qemu/error-report.h"
 #include "qemu/main-loop.h"
 #include "qemu/range.h"
migration/savevm.c +0 -1
index d2e141f7b1d..ff33e210eb0 100644
@@ -42,7 +42,6 @@
 #include "postcopy-ram.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-migration.h"
-#include "qapi/qapi-commands-misc.h"
 #include "qapi/qmp/qerror.h"
 #include "qemu/error-report.h"
 #include "sysemu/cpus.h"
Signature · 1 line
2.26.2
Reviewed-by on the v2 series
#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

Quoted 28 lines

Since v1:
- Added A-b tags
- Rebased

Philippe Mathieu-Daudé (5):
qapi: Restrict 'inject-nmi' command to machine code
qapi: Restrict 'system wakeup/reset/powerdown' commands to
machine.json
qapi: Restrict '(p)memsave' command to machine code
qapi: Restrict 'query-kvm' command to machine code
qapi: Restrict Xen migration commands to migration.json

 qapi/machine.json      | 168 +++++++++++++++++++++++++++++++++
 qapi/migration.json    |  41 ++++++++
 qapi/misc.json         | 209 -----------------------------------------
 accel/stubs/xen-stub.c |   2 +-
 hw/i386/xen/xen-hvm.c  |   2 +-
 migration/savevm.c     |   1 -
 softmmu/cpus.c         |   1 +
 ui/gtk.c               |   1 +
 ui/cocoa.m             |   1 +
 9 files changed, 214 insertions(+), 212 deletions(-)
Signature · 1 line
2.26.2
Signature · 1 line
Eduardo
#7 lore raw
Quoted 10 lines · Eduardo Habkost
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

I take this as "I agree the things moved to machine.json belong there". Holler if I'm mistaken.

#8 lore raw
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Eduardo Habkost
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

Quoted 7 lines
Quoted 4 lines

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

I take this as "I agree the things moved to machine.json belong there". Holler if I'm mistaken.

I agree machine.json is better than misc.json for them, yes.

I miss short descriptions of the purpose of each file, though. It would help us decide what's appropriate in the future.

Signature · 1 line
Eduardo
#9 lore raw
Quoted 14 lines · Eduardo Habkost
Quoted 13 lines · Markus Armbruster
Quoted 10 lines · Eduardo Habkost
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

Quoted 7 lines
Quoted 2 lines

I take this as "I agree the things moved to machine.json belong there". Holler if I'm mistaken.

I agree machine.json is better than misc.json for them, yes.

I miss short descriptions of the purpose of each file, though. It would help us decide what's appropriate in the future.

The QAPI modules are commonly aligned with sub-systems defined in MAINTAINERS.

Regardless, file comments would be nice.

#10 lore raw
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Eduardo Habkost
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Eduardo Habkost
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

Quoted 7 lines
Quoted 4 lines

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

I take this as "I agree the things moved to machine.json belong there". Holler if I'm mistaken.

I agree machine.json is better than misc.json for them, yes.

Quoted 7 lines
Quoted 2 lines

I miss short descriptions of the purpose of each file, though. It would help us decide what's appropriate in the future.

The QAPI modules are commonly aligned with sub-systems defined in MAINTAINERS.

Regardless, file comments would be nice.

I don't understand what you mean/expect by "file comments". Example?

W.r.t. MAINTAINERS, I can move Xen code to qapi/migration-xen.json;

'query-kvm' is used when no KVM built it, so I'll let it in machine.json; the others seem to belong in machine.json too, with no particular justification.

#11 lore raw
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · Markus Armbruster
Quoted 21 lines · Eduardo Habkost
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Eduardo Habkost
Quoted 4 lines · Philippe Mathieu-Daudé

Reduce the machine code pulled into qemu-storage-daemon.

The series is fully Acked, but Markus wants it reviewed by the Machine core maintainers.

Quoted 7 lines
Quoted 4 lines

I've confirmed that all patches move QAPI schema code without introducing any additional changes.

I take this as "I agree the things moved to machine.json belong there". Holler if I'm mistaken.

I agree machine.json is better than misc.json for them, yes.

I miss short descriptions of the purpose of each file, though. It would help us decide what's appropriate in the future.

Quoted 7 lines
Quoted 4 lines

The QAPI modules are commonly aligned with sub-systems defined in MAINTAINERS.

Regardless, file comments would be nice.

I don't understand what you mean/expect by "file comments". Example?

A comment explaining the file, at the beginning of the file.

Quoted 1 line

W.r.t. MAINTAINERS, I can move Xen code to qapi/migration-xen.json;

How much could be moved, and from where?

Sub-modules don't need to mirror MAINTAINERS slavishly. We want reasonably-sized modules, and we want useful get_maintainer.pl output.

Quoted 3 lines

'query-kvm' is used when no KVM built it, so I'll let it in machine.json; the others seem to belong in machine.json too, with no particular justification.