qapi: Restrict device memory commands to machine code
Only qemu-system-FOO and qemu-storage-daemon provide QMP monitors, therefore such declarations and definitions are irrelevant for user-mode emulation. Restricting the memory commands to machine.json pulls less QAPI-generated code into user-mode. Acked-by: Igor Mammedov <imammedo@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20200913195348.1064154-7-philmd@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
f68c01470b
commit
b495ec6c5e
@ -7,6 +7,7 @@
|
||||
#include "migration/vmstate.h"
|
||||
#include "trace.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-events-machine.h"
|
||||
#include "qapi/qapi-events-misc.h"
|
||||
|
||||
#define MEMORY_SLOTS_NUMBER "MDNR"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "virtio-mem-pci.h"
|
||||
#include "hw/mem/memory-device.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-events-machine.h"
|
||||
#include "qapi/qapi-events-misc.h"
|
||||
|
||||
static void virtio_mem_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define MEMORY_DEVICE_H
|
||||
|
||||
#include "hw/qdev-core.h"
|
||||
#include "qapi/qapi-types-misc.h"
|
||||
#include "qapi/qapi-types-machine.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_MEMORY_DEVICE "memory-device"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#define HW_VIRTIO_PMEM_H
|
||||
|
||||
#include "hw/virtio/virtio.h"
|
||||
#include "qapi/qapi-types-misc.h"
|
||||
#include "qapi/qapi-types-machine.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_VIRTIO_PMEM "virtio-pmem"
|
||||
|
@ -1085,3 +1085,219 @@
|
||||
##
|
||||
{ 'event': 'BALLOON_CHANGE',
|
||||
'data': { 'actual': 'int' } }
|
||||
|
||||
##
|
||||
# @MemoryInfo:
|
||||
#
|
||||
# Actual memory information in bytes.
|
||||
#
|
||||
# @base-memory: size of "base" memory specified with command line
|
||||
# option -m.
|
||||
#
|
||||
# @plugged-memory: size of memory that can be hot-unplugged. This field
|
||||
# is omitted if target doesn't support memory hotplug
|
||||
# (i.e. CONFIG_MEM_DEVICE not defined at build time).
|
||||
#
|
||||
# Since: 2.11.0
|
||||
##
|
||||
{ 'struct': 'MemoryInfo',
|
||||
'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } }
|
||||
|
||||
##
|
||||
# @query-memory-size-summary:
|
||||
#
|
||||
# Return the amount of initially allocated and present hotpluggable (if
|
||||
# enabled) memory in bytes.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "query-memory-size-summary" }
|
||||
# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
|
||||
#
|
||||
# Since: 2.11.0
|
||||
##
|
||||
{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
|
||||
|
||||
##
|
||||
# @PCDIMMDeviceInfo:
|
||||
#
|
||||
# PCDIMMDevice state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @addr: physical address, where device is mapped
|
||||
#
|
||||
# @size: size of memory that the device provides
|
||||
#
|
||||
# @slot: slot number at which device is plugged in
|
||||
#
|
||||
# @node: NUMA node number where device is plugged in
|
||||
#
|
||||
# @memdev: memory backend linked with device
|
||||
#
|
||||
# @hotplugged: true if device was hotplugged
|
||||
#
|
||||
# @hotpluggable: true if device if could be added/removed while machine is running
|
||||
#
|
||||
# Since: 2.1
|
||||
##
|
||||
{ 'struct': 'PCDIMMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'addr': 'int',
|
||||
'size': 'int',
|
||||
'slot': 'int',
|
||||
'node': 'int',
|
||||
'memdev': 'str',
|
||||
'hotplugged': 'bool',
|
||||
'hotpluggable': 'bool'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @VirtioPMEMDeviceInfo:
|
||||
#
|
||||
# VirtioPMEM state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @memaddr: physical address in memory, where device is mapped
|
||||
#
|
||||
# @size: size of memory that the device provides
|
||||
#
|
||||
# @memdev: memory backend linked with device
|
||||
#
|
||||
# Since: 4.1
|
||||
##
|
||||
{ 'struct': 'VirtioPMEMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'memaddr': 'size',
|
||||
'size': 'size',
|
||||
'memdev': 'str'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @VirtioMEMDeviceInfo:
|
||||
#
|
||||
# VirtioMEMDevice state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @memaddr: physical address in memory, where device is mapped
|
||||
#
|
||||
# @requested-size: the user requested size of the device
|
||||
#
|
||||
# @size: the (current) size of memory that the device provides
|
||||
#
|
||||
# @max-size: the maximum size of memory that the device can provide
|
||||
#
|
||||
# @block-size: the block size of memory that the device provides
|
||||
#
|
||||
# @node: NUMA node number where device is assigned to
|
||||
#
|
||||
# @memdev: memory backend linked with the region
|
||||
#
|
||||
# Since: 5.1
|
||||
##
|
||||
{ 'struct': 'VirtioMEMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'memaddr': 'size',
|
||||
'requested-size': 'size',
|
||||
'size': 'size',
|
||||
'max-size': 'size',
|
||||
'block-size': 'size',
|
||||
'node': 'int',
|
||||
'memdev': 'str'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @MemoryDeviceInfo:
|
||||
#
|
||||
# Union containing information about a memory device
|
||||
#
|
||||
# nvdimm is included since 2.12. virtio-pmem is included since 4.1.
|
||||
# virtio-mem is included since 5.1.
|
||||
#
|
||||
# Since: 2.1
|
||||
##
|
||||
{ 'union': 'MemoryDeviceInfo',
|
||||
'data': { 'dimm': 'PCDIMMDeviceInfo',
|
||||
'nvdimm': 'PCDIMMDeviceInfo',
|
||||
'virtio-pmem': 'VirtioPMEMDeviceInfo',
|
||||
'virtio-mem': 'VirtioMEMDeviceInfo'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @query-memory-devices:
|
||||
#
|
||||
# Lists available memory devices and their state
|
||||
#
|
||||
# Since: 2.1
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "query-memory-devices" }
|
||||
# <- { "return": [ { "data":
|
||||
# { "addr": 5368709120,
|
||||
# "hotpluggable": true,
|
||||
# "hotplugged": true,
|
||||
# "id": "d1",
|
||||
# "memdev": "/objects/memX",
|
||||
# "node": 0,
|
||||
# "size": 1073741824,
|
||||
# "slot": 0},
|
||||
# "type": "dimm"
|
||||
# } ] }
|
||||
#
|
||||
##
|
||||
{ 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
|
||||
|
||||
##
|
||||
# @MEMORY_DEVICE_SIZE_CHANGE:
|
||||
#
|
||||
# Emitted when the size of a memory device changes. Only emitted for memory
|
||||
# devices that can actually change the size (e.g., virtio-mem due to guest
|
||||
# action).
|
||||
#
|
||||
# @id: device's ID
|
||||
# @size: the new size of memory that the device provides
|
||||
#
|
||||
# Note: this event is rate-limited.
|
||||
#
|
||||
# Since: 5.1
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "MEMORY_DEVICE_SIZE_CHANGE",
|
||||
# "data": { "id": "vm0", "size": 1073741824},
|
||||
# "timestamp": { "seconds": 1588168529, "microseconds": 201316 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'MEMORY_DEVICE_SIZE_CHANGE',
|
||||
'data': { '*id': 'str', 'size': 'size' } }
|
||||
|
||||
|
||||
##
|
||||
# @MEM_UNPLUG_ERROR:
|
||||
#
|
||||
# Emitted when memory hot unplug error occurs.
|
||||
#
|
||||
# @device: device name
|
||||
#
|
||||
# @msg: Informative message
|
||||
#
|
||||
# Since: 2.4
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "MEM_UNPLUG_ERROR"
|
||||
# "data": { "device": "dimm1",
|
||||
# "msg": "acpi: device unplug for unsupported device"
|
||||
# },
|
||||
# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'MEM_UNPLUG_ERROR',
|
||||
'data': { 'device': 'str', 'msg': 'str' } }
|
||||
|
217
qapi/misc.json
217
qapi/misc.json
@ -826,39 +826,6 @@
|
||||
##
|
||||
{ 'command': 'closefd', 'data': {'fdname': 'str'} }
|
||||
|
||||
##
|
||||
# @MemoryInfo:
|
||||
#
|
||||
# Actual memory information in bytes.
|
||||
#
|
||||
# @base-memory: size of "base" memory specified with command line
|
||||
# option -m.
|
||||
#
|
||||
# @plugged-memory: size of memory that can be hot-unplugged. This field
|
||||
# is omitted if target doesn't support memory hotplug
|
||||
# (i.e. CONFIG_MEM_DEVICE not defined at build time).
|
||||
#
|
||||
# Since: 2.11.0
|
||||
##
|
||||
{ 'struct': 'MemoryInfo',
|
||||
'data' : { 'base-memory': 'size', '*plugged-memory': 'size' } }
|
||||
|
||||
##
|
||||
# @query-memory-size-summary:
|
||||
#
|
||||
# Return the amount of initially allocated and present hotpluggable (if
|
||||
# enabled) memory in bytes.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "query-memory-size-summary" }
|
||||
# <- { "return": { "base-memory": 4294967296, "plugged-memory": 0 } }
|
||||
#
|
||||
# Since: 2.11.0
|
||||
##
|
||||
{ 'command': 'query-memory-size-summary', 'returns': 'MemoryInfo' }
|
||||
|
||||
|
||||
##
|
||||
# @AddfdInfo:
|
||||
#
|
||||
@ -1154,190 +1121,6 @@
|
||||
'returns': ['CommandLineOptionInfo'],
|
||||
'allow-preconfig': true }
|
||||
|
||||
##
|
||||
# @PCDIMMDeviceInfo:
|
||||
#
|
||||
# PCDIMMDevice state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @addr: physical address, where device is mapped
|
||||
#
|
||||
# @size: size of memory that the device provides
|
||||
#
|
||||
# @slot: slot number at which device is plugged in
|
||||
#
|
||||
# @node: NUMA node number where device is plugged in
|
||||
#
|
||||
# @memdev: memory backend linked with device
|
||||
#
|
||||
# @hotplugged: true if device was hotplugged
|
||||
#
|
||||
# @hotpluggable: true if device if could be added/removed while machine is running
|
||||
#
|
||||
# Since: 2.1
|
||||
##
|
||||
{ 'struct': 'PCDIMMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'addr': 'int',
|
||||
'size': 'int',
|
||||
'slot': 'int',
|
||||
'node': 'int',
|
||||
'memdev': 'str',
|
||||
'hotplugged': 'bool',
|
||||
'hotpluggable': 'bool'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @VirtioPMEMDeviceInfo:
|
||||
#
|
||||
# VirtioPMEM state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @memaddr: physical address in memory, where device is mapped
|
||||
#
|
||||
# @size: size of memory that the device provides
|
||||
#
|
||||
# @memdev: memory backend linked with device
|
||||
#
|
||||
# Since: 4.1
|
||||
##
|
||||
{ 'struct': 'VirtioPMEMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'memaddr': 'size',
|
||||
'size': 'size',
|
||||
'memdev': 'str'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @VirtioMEMDeviceInfo:
|
||||
#
|
||||
# VirtioMEMDevice state information
|
||||
#
|
||||
# @id: device's ID
|
||||
#
|
||||
# @memaddr: physical address in memory, where device is mapped
|
||||
#
|
||||
# @requested-size: the user requested size of the device
|
||||
#
|
||||
# @size: the (current) size of memory that the device provides
|
||||
#
|
||||
# @max-size: the maximum size of memory that the device can provide
|
||||
#
|
||||
# @block-size: the block size of memory that the device provides
|
||||
#
|
||||
# @node: NUMA node number where device is assigned to
|
||||
#
|
||||
# @memdev: memory backend linked with the region
|
||||
#
|
||||
# Since: 5.1
|
||||
##
|
||||
{ 'struct': 'VirtioMEMDeviceInfo',
|
||||
'data': { '*id': 'str',
|
||||
'memaddr': 'size',
|
||||
'requested-size': 'size',
|
||||
'size': 'size',
|
||||
'max-size': 'size',
|
||||
'block-size': 'size',
|
||||
'node': 'int',
|
||||
'memdev': 'str'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @MemoryDeviceInfo:
|
||||
#
|
||||
# Union containing information about a memory device
|
||||
#
|
||||
# nvdimm is included since 2.12. virtio-pmem is included since 4.1.
|
||||
# virtio-mem is included since 5.1.
|
||||
#
|
||||
# Since: 2.1
|
||||
##
|
||||
{ 'union': 'MemoryDeviceInfo',
|
||||
'data': { 'dimm': 'PCDIMMDeviceInfo',
|
||||
'nvdimm': 'PCDIMMDeviceInfo',
|
||||
'virtio-pmem': 'VirtioPMEMDeviceInfo',
|
||||
'virtio-mem': 'VirtioMEMDeviceInfo'
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @query-memory-devices:
|
||||
#
|
||||
# Lists available memory devices and their state
|
||||
#
|
||||
# Since: 2.1
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# -> { "execute": "query-memory-devices" }
|
||||
# <- { "return": [ { "data":
|
||||
# { "addr": 5368709120,
|
||||
# "hotpluggable": true,
|
||||
# "hotplugged": true,
|
||||
# "id": "d1",
|
||||
# "memdev": "/objects/memX",
|
||||
# "node": 0,
|
||||
# "size": 1073741824,
|
||||
# "slot": 0},
|
||||
# "type": "dimm"
|
||||
# } ] }
|
||||
#
|
||||
##
|
||||
{ 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
|
||||
|
||||
##
|
||||
# @MEMORY_DEVICE_SIZE_CHANGE:
|
||||
#
|
||||
# Emitted when the size of a memory device changes. Only emitted for memory
|
||||
# devices that can actually change the size (e.g., virtio-mem due to guest
|
||||
# action).
|
||||
#
|
||||
# @id: device's ID
|
||||
# @size: the new size of memory that the device provides
|
||||
#
|
||||
# Note: this event is rate-limited.
|
||||
#
|
||||
# Since: 5.1
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "MEMORY_DEVICE_SIZE_CHANGE",
|
||||
# "data": { "id": "vm0", "size": 1073741824},
|
||||
# "timestamp": { "seconds": 1588168529, "microseconds": 201316 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'MEMORY_DEVICE_SIZE_CHANGE',
|
||||
'data': { '*id': 'str', 'size': 'size' } }
|
||||
|
||||
|
||||
##
|
||||
# @MEM_UNPLUG_ERROR:
|
||||
#
|
||||
# Emitted when memory hot unplug error occurs.
|
||||
#
|
||||
# @device: device name
|
||||
#
|
||||
# @msg: Informative message
|
||||
#
|
||||
# Since: 2.4
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# <- { "event": "MEM_UNPLUG_ERROR"
|
||||
# "data": { "device": "dimm1",
|
||||
# "msg": "acpi: device unplug for unsupported device"
|
||||
# },
|
||||
# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
|
||||
#
|
||||
##
|
||||
{ 'event': 'MEM_UNPLUG_ERROR',
|
||||
'data': { 'device': 'str', 'msg': 'str' } }
|
||||
|
||||
##
|
||||
# @ACPISlotType:
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user