Merge tag 'hw-misc-20260816' of https://github.com/philmd/qemu into staging

Misc HW and Monitor patch queue

- Bug fixes

 . Reinstate x86/pc 'xenfv' machine alias
 . Defend against malformed ELF headers to prevent underflows
 . Restore ROMD mode after migration for Intel PFlash (CFI01)
 . Fix VLAN tag handling on incoming packets on RTL8139 model

- Refactoring (Monitor, common CPU, NMI)

 . Add missing inclusions and remove unnecessary ones
 . Use qdev_is_realized() consistently (no direct field access)
 . Remove deprecated DEFINE_PROP_DMAADDR() macro
 . Renaming churn around cpu_{exec,common}* helpers
 . Simplify NMI API hanlding
 . Move QMP handlers (physmem, nmi) to appropriate subsystems
 . Replace container_of() casts with HMP typed accessors
 . Rename @mon to @hmp in MonitorHMP for clarity

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmqBzKAACgkQ4+MsLN6t
# wN79Og//Qt6s9wU8KyegqCi55+tMSxQfTE96O5qRjV9FcrTeYMrlDWTm5jXcdSXr
# DVjAfM/SDI98TDWkG0Uxk5r0Kr1C1V9u8CAClED1Us81mwloGBX6qar9AdcnNzXL
# Pi0C4jWk2NVZyXq+0cvPQZg8SW2xSsgbEWrkuGRxlDqrwHcljMhEivE6NvHZjrOr
# 2QvgB/31JcsqrtdosBnAw4xDsZ7Gf3Gqpoz4IdoVdxn2o9TaTm8+DlZgmHz2klmq
# 3diW9BItqQEYzURl/psfjl6WaQ2sls18sEIZs62M+2cTkDBBTFo8ErnFyEUqCRlD
# tPCt+b+DljifV9vKAt/+rMO2WdQxN3eTild+xmQ0DbZH6BCktkS0tR6nEVosC8qB
# 3fmqmibyn9T+qaGfAAKrBEbsPhS0yiZaw3/pSY/BBuDMTX9G4URfxsWY6Ka++ZqL
# KRPeypnMeGBYsfEOVmWAbVeMVO9O8aXoIcaXprRc2jvtRj47exHvVKYSCwFPNeTi
# hioNFbI6/EjzcIooWZd0yq3DLrJ5KaW9S/BoZH1B5A8uun9pdmybCbROgOFryr/q
# aZNuk6otVynNwd2sTHzgw34ru76pJv2NqyP1PV3MxmfsLrCpjr3xH0lXaqRiiaKk
# Z+uglV8hrkKsGY5krzbHLWtjRc/XthroFkW4g8VLQw4XLsIeR+s=
# =Dx4p
# -----END PGP SIGNATURE-----
# gpg: Signature made Sun 16 Aug 2026 07:43:44 AM PDT
# gpg:                using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD  6BB2 E3E3 2C2C DEAD C0DE

* tag 'hw-misc-20260816' of https://github.com/philmd/qemu: (56 commits)
  hw/core/machine: Move EHCI migration compat properties to 11.1
  hw/elf_ops: defend against weird elf headers
  monitor: Replace container_of(MonitorHMP, parent_obj) -> MONITOR_HMP()
  monitor: Better express monitor_read()'s opaque arg is of Monitor type
  monitor: Rename MonitorHMP @mon -> @hmp
  system: Move runstate-related code from cpus.c to runstate.c
  system: Extract QMP memsave/pmemsave commands to physmem-qmp-cmds.c
  system: Move qmp_inject_nmi() to hw/core/machine-qmp-cmds.c
  system/dirtylimit: Extract HMP code to dirtylimit-hmp-cmds.c
  system: Remove unnecessary 'monitor/monitor.h' header
  monitor: Remove unnecessary 'block/block.h' header
  monitor: Reduce inclusion of 'qapi/qapi-emit-events.h' header
  monitor: Include missing 'qemu/coroutine-core.h' header
  monitor: Include missing 'qemu/lockable.h' header
  monitor: Include missing 'qemu/aio-wait.h' header
  migration/hmp-cmds: Include 'block/block-global-state.h' header
  qapi/qmp-registry: Remove unnecessary 'monitor/monitor.h' header
  qapi/qmp-dispatch: Include 'qemu/aio-wait.h' and 'monitor/monitor.h'
  tests/unit: Include 'qemu/main-loop.h' header in test-util-sockets.c
  net/vhost-vdpa: Include missing 'qemu/iov.h' header
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson committed 2026-08-16 08:17:47 -07:00
commit 9696bf5dc5
94 files changed
+702 -595

No files matched your search

+3
View File
@@ -2093,6 +2093,7 @@ Machine core
M: Philippe Mathieu-Daudé <philmd@mailo.com>
R: Zhao Liu <zhao1.liu@intel.com>
S: Maintained
F: hw/core/cpu-internal.h
F: hw/core/cpu-common.c
F: hw/core/cpu-system.c
F: hw/core/machine-qmp-cmds.c
@@ -3435,6 +3436,7 @@ F: system/ioport.c
F: system/memory.c
F: system/memory_mapping.c
F: system/physmem.c
F: system/physmem-qmp-cmds.c
F: system/memory_ldst*
F: system/memory-internal.h
F: system/ram-block-attributes.c
@@ -3874,6 +3876,7 @@ Migration dirty limit and dirty page rate
M: Hyman Huang <infra.ai.cloud@bitdeer.com>
S: Maintained
F: system/dirtylimit.c
F: system/dirtylimit-hmp-cmds.c
F: include/system/dirtylimit.h
F: migration/dirtyrate.c
F: migration/dirtyrate.h
+4 -3
View File
@@ -865,12 +865,13 @@ ERST
.name = "nmi",
.args_type = "",
.params = "",
.help = "inject an NMI",
.help = "Inject an NMI, in a machine-specific way",
.cmd = hmp_nmi,
},
SRST
``nmi`` *cpu*
Inject an NMI on the default CPU (x86/s390) or all CPUs (ppc64).
``nmi``
Inject an NMI, in a machine-specific way.
Not all machines implement NMI handling.
ERST
{
+10
View File
@@ -1030,6 +1030,16 @@ static int pflash_post_load(void *opaque, int version_id)
{
PFlashCFI01 *pfl = opaque;
/*
* ROMD mode is not in the VMState; derive it from the migrated
* cmd and wcycle. Only (wcycle == 0, cmd == 0x00) is read-array.
*/
if (pfl->wcycle == 0 && pfl->cmd == 0x00) {
memory_region_rom_device_set_romd(&pfl->mem, true);
} else {
memory_region_rom_device_set_romd(&pfl->mem, false);
}
if (!pfl->ro) {
pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb,
pfl);
+7 -25
View File
@@ -23,6 +23,7 @@
#include "qapi/error.h"
#include "hw/core/cpu.h"
#include "system/hw_accel.h"
#include "qemu/accel.h"
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/lockcnt.h"
@@ -32,12 +33,12 @@
#include "exec/log.h"
#include "exec/gdbstub.h"
#include "system/tcg.h"
#include "hw/core/boards.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#ifdef CONFIG_PLUGIN
#include "qemu/plugin.h"
#endif
#include "cpu-internal.h"
CPUState *cpu_by_arch_id(int64_t id)
{
@@ -228,7 +229,7 @@ const char *parse_cpu_option(const char *cpu_option)
return cpu_type;
}
bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
bool cpu_common_realize(CPUState *cpu, Error **errp)
{
if (!accel_cpu_common_realize(cpu, errp)) {
return false;
@@ -246,26 +247,7 @@ bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
static void cpu_common_realizefn(DeviceState *dev, Error **errp)
{
CPUState *cpu = CPU(dev);
Object *machine = qdev_get_machine();
/* qdev_get_machine() can return something that's not TYPE_MACHINE
* if this is one of the user-only emulators; in that case there's
* no need to check the ignore_memory_transaction_failures board flag.
*/
if (object_dynamic_cast(machine, TYPE_MACHINE)) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
if (mc) {
cpu->ignore_memory_transaction_failures =
mc->ignore_memory_transaction_failures;
}
}
if (dev->hotplugged) {
cpu_synchronize_post_init(cpu);
cpu_resume(cpu);
}
cpu_exec_realize(CPU(dev), errp);
/* NOTE: latest generic point where the cpu is fully realized */
}
@@ -282,10 +264,10 @@ static void cpu_common_unrealizefn(DeviceState *dev)
#endif
/* NOTE: latest generic point before the cpu is fully unrealized */
cpu_exec_unrealizefn(cpu);
cpu_common_unrealize(cpu);
}
void cpu_exec_unrealizefn(CPUState *cpu)
void cpu_common_unrealize(CPUState *cpu)
{
cpu_vmstate_unregister(cpu);
@@ -325,7 +307,7 @@ static void cpu_common_initfn(Object *obj)
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
cpu_exec_initfn(cpu);
cpu_exec_init(cpu);
/*
* Plugin initialization must wait until the cpu start executing
+23
View File
@@ -0,0 +1,23 @@
/*
* QEMU private CPU interface between user / system modes)
*
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef HW_CORE_CPU_INTERNAL_H
#define HW_CORE_CPU_INTERNAL_H
#include "hw/core/qdev.h"
#include "hw/core/cpu.h"
void cpu_class_init_props(DeviceClass *dc);
void cpu_exec_class_post_init(CPUClass *cc);
void cpu_exec_init(CPUState *cpu);
void cpu_exec_realize(CPUState *cpu, Error **errp);
void cpu_vmstate_register(CPUState *cpu);
void cpu_vmstate_unregister(CPUState *cpu);
#endif
+29 -1
View File
@@ -25,11 +25,14 @@
#include "exec/target_page.h"
#include "system/memory.h"
#include "qemu/target-info.h"
#include "hw/core/boards.h"
#include "hw/core/qdev.h"
#include "hw/core/qdev-properties.h"
#include "hw/core/sysemu-cpu-ops.h"
#include "migration/vmstate.h"
#include "system/hw_accel.h"
#include "system/tcg.h"
#include "cpu-internal.h"
bool cpu_has_work(CPUState *cpu)
{
@@ -188,7 +191,7 @@ void cpu_exec_class_post_init(CPUClass *cc)
g_assert(cc->sysemu_ops->has_work);
}
void cpu_exec_initfn(CPUState *cpu)
void cpu_exec_init(CPUState *cpu)
{
cpu->memory = get_system_memory();
object_ref(OBJECT(cpu->memory));
@@ -220,6 +223,31 @@ static int cpu_common_pre_load(void *opaque)
return 0;
}
void cpu_exec_realize(CPUState *cpu, Error **errp)
{
Object *machine = qdev_get_machine();
/*
* qdev_get_machine() can return something that's not TYPE_MACHINE
* if this is one of the user-only emulators; in that case there's
* no need to check the ignore_memory_transaction_failures board flag.
*/
if (object_dynamic_cast(machine, TYPE_MACHINE)) {
MachineClass *mc = MACHINE_GET_CLASS(machine);
if (mc) {
cpu->ignore_memory_transaction_failures =
mc->ignore_memory_transaction_failures;
}
}
if (DEVICE(cpu)->hotplugged) {
cpu_synchronize_post_init(cpu);
cpu_resume(cpu);
}
}
static bool cpu_common_exception_index_needed(void *opaque)
{
CPUState *cpu = opaque;
+7 -1
View File
@@ -11,6 +11,7 @@
#include "hw/core/qdev-properties.h"
#include "hw/core/cpu.h"
#include "migration/vmstate.h"
#include "cpu-internal.h"
static const Property cpu_user_props[] = {
/*
@@ -32,7 +33,12 @@ void cpu_exec_class_post_init(CPUClass *cc)
/* nothing to do */
}
void cpu_exec_initfn(CPUState *cpu)
void cpu_exec_init(CPUState *cpu)
{
/* nothing to do */
}
void cpu_exec_realize(CPUState *cpu, Error **errp)
{
/* nothing to do */
}
+6
View File
@@ -10,6 +10,7 @@
#include "qemu/osdep.h"
#include "hw/acpi/vmgenid.h"
#include "hw/core/boards.h"
#include "hw/core/nmi.h"
#include "hw/intc/intc.h"
#include "hw/mem/memory-device.h"
#include "qapi/error.h"
@@ -448,3 +449,8 @@ void qmp_dump_skeys(const char *filename, Error **errp)
}
DUMP_SKEYS_INTERFACE_CLASS(oc)->qmp_dump_skeys(filename, errp);
}
void qmp_inject_nmi(Error **errp)
{
nmi_inject(errp);
}
+4 -3
View File
@@ -40,7 +40,10 @@
#include "qemu/audio.h"
#include "hw/arm/smmuv3.h"
GlobalProperty hw_compat_11_1[] = {};
GlobalProperty hw_compat_11_1[] = {
{ "sysbus-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
{ "pci-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
};
const size_t hw_compat_11_1_len = G_N_ELEMENTS(hw_compat_11_1);
GlobalProperty hw_compat_11_0[] = {
@@ -54,8 +57,6 @@ GlobalProperty hw_compat_11_0[] = {
{ TYPE_ARM_SMMUV3, "ssidsize", "0" },
{ TYPE_ARM_SMMUV3, "oas", "44" },
{ "migration", "switchover-ack-legacy", "on" },
{ "sysbus-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
{ "pci-ehci-usb", "x-migrate-fetch-addr-64bit", "off" },
};
const size_t hw_compat_11_0_len = G_N_ELEMENTS(hw_compat_11_0);
+14 -34
View File
@@ -22,55 +22,35 @@
#include "qemu/osdep.h"
#include "hw/core/nmi.h"
#include "qapi/error.h"
#include "qemu/module.h"
#include "monitor/monitor.h"
struct do_nmi_s {
int cpu_index;
Error *err;
bool handled;
};
static void nmi_children(Object *o, struct do_nmi_s *ns);
static int do_nmi(Object *o, void *opaque)
{
struct do_nmi_s *ns = opaque;
bool *handled = opaque;
NMIState *n = (NMIState *) object_dynamic_cast(o, TYPE_NMI);
if (n) {
NMIClass *nc = NMI_GET_CLASS(n);
ns->handled = true;
nc->nmi_monitor_handler(n, ns->cpu_index, &ns->err);
if (ns->err) {
return -1;
}
*handled = true;
NMI_GET_CLASS(n)->raise_nmi(n);
/*
* We expect only one object to implement TYPE_NMI, so once
* we've asked it to deliver the NMI we can stop looking.
*/
return 1;
}
nmi_children(o, ns);
return 0;
}
static void nmi_children(Object *o, struct do_nmi_s *ns)
bool nmi_inject(Error **errp)
{
object_child_foreach(o, do_nmi, ns);
}
bool handled = false;
void nmi_monitor_handle(int cpu_index, Error **errp)
{
struct do_nmi_s ns = {
.cpu_index = cpu_index,
.err = NULL,
.handled = false
};
nmi_children(object_get_root(), &ns);
if (ns.handled) {
error_propagate(errp, ns.err);
} else {
object_child_foreach_recursive(object_get_root(), do_nmi, &handled);
if (!handled) {
error_setg(errp, "machine does not provide NMIs");
return false;
}
return true;
}
static const TypeInfo nmi_info = {
+29 -22
View File
@@ -264,17 +264,43 @@ static void device_reset_child_foreach(Object *obj, ResettableChildCallback cb,
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
{
assert(!dev->realized && !dev->parent_bus);
static int unattached_count;
bool unattached_parent = false;
assert(!dev->parent_bus);
if (!OBJECT(dev)->parent) {
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
object_property_add_child(machine_get_container("unattached"),
name, OBJECT(dev));
unattached_parent = true;
g_free(name);
}
if (bus) {
if (!qdev_set_parent_bus(dev, bus, errp)) {
return false;
goto fail;
}
} else {
assert(!DEVICE_GET_CLASS(dev)->bus_type);
}
return object_property_set_bool(OBJECT(dev), "realized", true, errp);
if (object_property_set_bool(OBJECT(dev), "realized", true, errp)) {
return true;
}
fail:
if (unattached_parent) {
/*
* Beware, this doesn't just revert
* object_property_add_child(), it also runs bus_remove()!
*/
object_unparent(OBJECT(dev));
unattached_count--;
}
return false;
}
bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp)
@@ -479,8 +505,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
BusState *bus;
NamedClockList *ncl;
Error *local_err = NULL;
bool unattached_parent = false;
static int unattached_count;
if (dev->hotplugged && !dc->hotpluggable) {
error_setg(errp, "Device '%s' does not support hotplugging",
@@ -493,15 +517,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
goto fail;
}
if (!obj->parent) {
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
object_property_add_child(machine_get_container("unattached"),
name, obj);
unattached_parent = true;
g_free(name);
}
hotplug_ctrl = qdev_get_hotplug_handler(dev);
if (hotplug_ctrl) {
hotplug_handler_pre_plug(hotplug_ctrl, dev, &local_err);
@@ -627,14 +642,6 @@ post_realize_fail:
fail:
error_propagate(errp, local_err);
if (unattached_parent) {
/*
* Beware, this doesn't just revert
* object_property_add_child(), it also runs bus_remove()!
*/
object_unparent(OBJECT(dev));
unattached_count--;
}
}
static bool device_get_hotpluggable(Object *obj, Error **errp)
+2 -2
View File
@@ -829,7 +829,7 @@ static void hppa_machine_reset(MachineState *ms, ResetType type)
cpu[0]->env.cmdline_or_bootorder = 'c';
}
static void hppa_nmi(NMIState *n, int cpu_index, Error **errp)
static void hppa_nmi(NMIState *ns)
{
CPUState *cs;
@@ -851,7 +851,7 @@ static void hppa_machine_common_class_init(ObjectClass *oc, const void *data)
mc->default_ram_id = "hppa.ram";
mc->default_nic = "tulip";
nc->nmi_monitor_handler = hppa_nmi;
nc->raise_nmi = hppa_nmi;
}
static void HP_B160L_machine_init_class_init(ObjectClass *oc, const void *data)
+1 -1
View File
@@ -197,7 +197,7 @@ static int build_dimm_list(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
DeviceState *dev = DEVICE(obj);
if (dev->realized) { /* only realized DIMMs matter */
if (qdev_is_realized(dev)) { /* only realized DIMMs matter */
*list = g_slist_prepend(*list, dev);
}
}
+1
View File
@@ -667,6 +667,7 @@ static void xenfv_machine_4_2_options(MachineClass *m)
{
pc_i440fx_machine_4_2_options(m);
m->desc = "Xen Fully-virtualized PC";
m->alias = "xenfv";
m->max_cpus = HVM_MAX_VCPUS;
m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
}
+2 -2
View File
@@ -147,7 +147,7 @@ static const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
return ms->possible_cpus;
}
static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
static void x86_nmi(NMIState *ns)
{
/* cpu index isn't used */
CPUState *cs;
@@ -389,7 +389,7 @@ static void x86_machine_class_init(ObjectClass *oc, const void *data)
mc->get_default_cpu_node_id = x86_get_default_cpu_node_id;
mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
mc->kvm_type = x86_kvm_type;
nc->nmi_monitor_handler = x86_nmi;
nc->raise_nmi = x86_nmi;
object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto",
x86_machine_get_smm, x86_machine_set_smm,
+1 -1
View File
@@ -424,7 +424,7 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name,
DeviceState *dev = DEVICE(obj);
uint32_t value;
if (dev->realized) {
if (qdev_is_realized(dev)) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
+2 -2
View File
@@ -70,7 +70,7 @@ static void m68k_irqc_instance_init(Object *obj)
qdev_init_gpio_in(DEVICE(obj), m68k_set_irq, M68K_IRQC_LEVEL_NUM);
}
static void m68k_nmi(NMIState *n, int cpu_index, Error **errp)
static void m68k_nmi(NMIState *n)
{
m68k_set_irq(n, M68K_IRQC_LEVEL_7, 1);
}
@@ -97,7 +97,7 @@ static void m68k_irqc_class_init(ObjectClass *oc, const void *data)
InterruptStatsProviderClass *ic = INTERRUPT_STATS_PROVIDER_CLASS(oc);
device_class_set_props(dc, m68k_irqc_properties);
nc->nmi_monitor_handler = m68k_nmi;
nc->raise_nmi = m68k_nmi;
device_class_set_legacy_reset(dc, m68k_irqc_reset);
dc->vmsd = &vmstate_m68k_irqc;
ic->get_statistics = m68k_irqc_get_statistics;
+1 -2
View File
@@ -59,8 +59,7 @@ static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
if (checkonly) {
return 0;
}
/* We don't care what CPU we use. */
nmi_monitor_handle(0, NULL);
nmi_inject(NULL);
return 0;
case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
+2 -2
View File
@@ -159,7 +159,7 @@ static void glue_auxmode_set_irq(void *opaque, int irq, int level)
s->auxmode = level;
}
static void glue_nmi(NMIState *n, int cpu_index, Error **errp)
static void glue_nmi(NMIState *n)
{
GLUEState *s = GLUE(n);
@@ -237,7 +237,7 @@ static void glue_class_init(ObjectClass *klass, const void *data)
dc->vmsd = &vmstate_glue;
device_class_set_props(dc, glue_properties);
rc->phases.hold = glue_reset_hold;
nc->nmi_monitor_handler = glue_nmi;
nc->raise_nmi = glue_nmi;
}
static const TypeInfo glue_info_types[] = {
+2 -2
View File
@@ -59,7 +59,7 @@ static int memory_device_build_list(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_MEMORY_DEVICE)) {
DeviceState *dev = DEVICE(obj);
if (dev->realized) { /* only realized memory devices matter */
if (qdev_is_realized(dev)) {
*list = g_slist_insert_sorted(*list, dev, memory_device_addr_sort);
}
}
@@ -326,7 +326,7 @@ static int memory_device_plugged_size(Object *obj, void *opaque)
const MemoryDeviceState *md = MEMORY_DEVICE(obj);
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(obj);
if (dev->realized && !memory_device_is_empty(md)) {
if (qdev_is_realized(dev) && !memory_device_is_empty(md)) {
*size += mdc->get_plugged_size(md, &error_abort);
}
}
+1 -1
View File
@@ -99,7 +99,7 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
static void nvdimm_init(Object *obj)
{
object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "int",
object_property_add(obj, NVDIMM_LABEL_SIZE_PROP, "size",
nvdimm_get_label_size, nvdimm_set_label_size, NULL,
NULL);
+1 -1
View File
@@ -103,7 +103,7 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
DeviceState *dev = DEVICE(obj);
if (dev->realized) { /* count only realized DIMMs */
if (qdev_is_realized(dev)) { /* count only realized DIMMs */
PCDIMMDevice *d = PC_DIMM(obj);
set_bit(d->slot, bitmap);
}
+2 -2
View File
@@ -188,7 +188,7 @@ static void macio_gpio_reset(DeviceState *dev)
macio_set_gpio(s, 1, true);
}
static void macio_gpio_nmi(NMIState *n, int cpu_index, Error **errp)
static void macio_gpio_nmi(NMIState *n)
{
macio_set_gpio(MACIO_GPIO(n), 9, true);
macio_set_gpio(MACIO_GPIO(n), 9, false);
@@ -201,7 +201,7 @@ static void macio_gpio_class_init(ObjectClass *oc, const void *data)
device_class_set_legacy_reset(dc, macio_gpio_reset);
dc->vmsd = &vmstate_macio_gpio;
nc->nmi_monitor_handler = macio_gpio_nmi;
nc->raise_nmi = macio_gpio_nmi;
}
static const TypeInfo macio_gpio_init_info = {
+1 -5
View File
@@ -778,7 +778,6 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)
s->RxBufAddr += size;
}
#define MIN_BUF_SIZE 60
static inline dma_addr_t rtl8139_addr64(uint32_t low, uint32_t high)
{
return low | ((uint64_t)high << 32);
@@ -1007,10 +1006,6 @@ static ssize_t rtl8139_receive(NetClientState *nc,
lduw_be_p(&buf[ETH_ALEN * 2]) == ETH_P_VLAN) {
dot1q_buf = &buf[ETH_ALEN * 2];
size -= VLAN_HLEN;
/* if too small buffer, use the tailroom added duing expansion */
if (size < MIN_BUF_SIZE) {
size = MIN_BUF_SIZE;
}
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
/* BE + ~le_to_cpu()~ + cpu_to_le() = BE */
@@ -1770,6 +1765,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size,
buf2 = g_malloc(buf2_size);
iov_to_buf(iov, 3, 0, buf2, buf2_size);
buf = buf2;
size = buf2_size;
}
DPRINTF("+++ transmit loopback mode\n");
+1
View File
@@ -2,3 +2,4 @@ config NVME_PCI
bool
default y if PCI_DEVICES || PCIE_DEVICES
depends on PCI
select SPDM_SOCKET
+1 -1
View File
@@ -468,7 +468,7 @@ static void bbram_prop_set_drive(Object *obj, Visitor *v, const char *name,
qdev_prop_drive.set(obj, v, name, opaque, errp);
/* Fill initial data if backend is attached after realized */
if (dev->realized) {
if (qdev_is_realized(dev)) {
bbram_bdrv_read(XLNX_BBRAM(obj), errp);
}
}
+1 -1
View File
@@ -233,7 +233,7 @@ static void efuse_prop_set_drive(Object *obj, Visitor *v, const char *name,
qdev_prop_drive.set(obj, v, name, opaque, errp);
/* Fill initial data if backend is attached after realized */
if (dev->realized) {
if (qdev_is_realized(dev)) {
efuse_bdrv_read(XLNX_EFUSE(obj), errp);
}
}
+2 -2
View File
@@ -3552,7 +3552,7 @@ static void pnv_cpu_do_nmi(PnvChip *chip, PowerPCCPU *cpu, void *opaque)
async_run_on_cpu(CPU(cpu), pnv_cpu_do_nmi_on_cpu, RUN_ON_CPU_HOST_INT(0));
}
static void pnv_nmi(NMIState *n, int cpu_index, Error **errp)
static void pnv_nmi(NMIState *ns)
{
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
int i;
@@ -3583,7 +3583,7 @@ static void pnv_machine_class_init(ObjectClass *oc, const void *data)
mc->default_ram_size = 1 * GiB;
mc->default_ram_id = "pnv.ram";
ispc->print_info = pnv_pic_print_info;
nc->nmi_monitor_handler = pnv_nmi;
nc->raise_nmi = pnv_nmi;
object_class_property_add_bool(oc, "hb-mode",
pnv_machine_get_hb, pnv_machine_set_hb);
+1 -1
View File
@@ -253,7 +253,7 @@ static int xscom_dt_child(Object *child, void *opaque)
/*
* Only "realized" devices should be configured in the DT
*/
if (xc->dt_xscom && DEVICE(child)->realized) {
if (xc->dt_xscom && qdev_is_realized(DEVICE(child))) {
_FDT((xc->dt_xscom(xd, args->fdt, args->xscom_offset)));
}
}
+2 -2
View File
@@ -3550,7 +3550,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg)
}
}
static void spapr_nmi(NMIState *n, int cpu_index, Error **errp)
static void spapr_nmi(NMIState *ns)
{
CPUState *cs;
@@ -4652,7 +4652,7 @@ static void spapr_machine_class_init(ObjectClass *oc, const void *data)
mc->nvdimm_supported = true;
smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED;
fwc->get_dev_path = spapr_get_fw_dev_path;
nc->nmi_monitor_handler = spapr_nmi;
nc->raise_nmi = spapr_nmi;
vhc->cpu_in_nested = spapr_cpu_in_nested;
vhc->deliver_hv_excp = spapr_exit_nested;
vhc->hypercall = emulate_spapr_hypercall;
+3 -5
View File
@@ -725,11 +725,9 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
return NULL;
}
static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
static void s390_nmi(NMIState *ns)
{
CPUState *cs = qemu_get_cpu(cpu_index);
s390_cpu_restart(S390_CPU(cs));
s390_cpu_restart(S390_CPU(first_cpu));
}
static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
@@ -832,7 +830,7 @@ static void ccw_machine_class_init(ObjectClass *oc, const void *data)
hc->plug = s390_machine_device_plug;
hc->unplug_request = s390_machine_device_unplug_request;
hc->unplug = s390_machine_device_unplug;
nc->nmi_monitor_handler = s390_nmi;
nc->raise_nmi = s390_nmi;
mc->default_ram_id = "s390.ram";
mc->default_nic = "virtio-net-ccw";
dsi->qmp_dump_skeys = s390_qmp_dump_skeys;
-1
View File
@@ -25,7 +25,6 @@
#include "migration/vmstate.h"
#include "hw/pci/pci_device.h"
#include "hw/core/sysbus.h"
#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
+1 -2
View File
@@ -26,7 +26,6 @@
#include "hw/usb/usb.h"
#include "migration/vmstate.h"
#include "hw/core/sysbus.h"
#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
@@ -61,7 +60,7 @@ static const Property ohci_sysbus_properties[] = {
DEFINE_PROP_STRING("masterbus", OHCISysBusState, masterbus),
DEFINE_PROP_UINT32("num-ports", OHCISysBusState, num_ports, 3),
DEFINE_PROP_UINT32("firstport", OHCISysBusState, firstport, 0),
DEFINE_PROP_DMAADDR("dma-offset", OHCISysBusState, dma_offset, 0),
DEFINE_PROP_UINT64("dma-offset", OHCISysBusState, dma_offset, 0),
};
static void ohci_sysbus_class_init(ObjectClass *klass, const void *data)
-1
View File
@@ -34,7 +34,6 @@
#include "hw/usb/usb.h"
#include "migration/vmstate.h"
#include "hw/core/sysbus.h"
#include "hw/core/qdev-dma.h"
#include "hw/core/qdev-properties.h"
#include "trace.h"
#include "hcd-ohci.h"
+2 -2
View File
@@ -1075,7 +1075,7 @@ static int vfio_legacy_pci_hot_reset(VFIODevice *vbasedev, bool single)
/* Prep dependent devices for reset and clear our marker. */
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
if (!vbasedev_iter->dev->realized ||
if (!qdev_is_realized(vbasedev_iter->dev) ||
!vfio_pci_from_vfio_device(vbasedev_iter)) {
continue;
}
@@ -1160,7 +1160,7 @@ out:
}
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
if (!vbasedev_iter->dev->realized ||
if (!qdev_is_realized(vbasedev_iter->dev) ||
!vfio_pci_from_vfio_device(vbasedev_iter)) {
continue;
}
+2 -2
View File
@@ -59,13 +59,13 @@ void vfio_device_reset_handler(void *opaque)
trace_vfio_device_reset_handler();
QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) {
if (vbasedev->dev->realized) {
if (qdev_is_realized(vbasedev->dev)) {
vbasedev->ops->vfio_compute_needs_reset(vbasedev);
}
}
QLIST_FOREACH(vbasedev, &vfio_device_list, global_next) {
if (vbasedev->dev->realized && vbasedev->needs_reset) {
if (qdev_is_realized(vbasedev->dev) && vbasedev->needs_reset) {
vbasedev->ops->vfio_hot_reset_multi(vbasedev);
}
}
+1 -1
View File
@@ -829,7 +829,7 @@ iommufd_cdev_dep_get_realized_vpdev(struct vfio_pci_dependent_device *dep_dev,
vbasedev_tmp = iommufd_cdev_pci_find_by_devid(dep_dev->devid);
if (!vfio_pci_from_vfio_device(vbasedev_tmp) ||
!vbasedev_tmp->dev->realized) {
!qdev_is_realized(vbasedev_tmp->dev)) {
return NULL;
}
+2 -2
View File
@@ -1453,7 +1453,7 @@ static void virtio_mem_set_requested_size(Object *obj, Visitor *v,
* The block size and memory backend are not fixed until the device was
* realized. realize() will verify these properties then.
*/
if (DEVICE(obj)->realized) {
if (qdev_is_realized(DEVICE(obj))) {
if (!QEMU_IS_ALIGNED(value, vmem->block_size)) {
error_setg(errp, "'%s' has to be multiples of '%s' (0x%" PRIx64
")", name, VIRTIO_MEM_BLOCK_SIZE_PROP,
@@ -1507,7 +1507,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
VirtIOMEM *vmem = VIRTIO_MEM(obj);
uint64_t value;
if (DEVICE(obj)->realized) {
if (qdev_is_realized(DEVICE(obj))) {
error_setg(errp, "'%s' cannot be changed", name);
return;
}
+2 -2
View File
@@ -659,7 +659,7 @@ static int query_dev_child(Object *child, void *opaque)
{
VirtioInfoList **vdevs = opaque;
Object *dev = object_dynamic_cast(child, TYPE_VIRTIO_DEVICE);
if (dev != NULL && DEVICE(dev)->realized) {
if (dev != NULL && qdev_is_realized(DEVICE(dev))) {
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtioInfo *info = g_new(VirtioInfo, 1);
@@ -688,7 +688,7 @@ VirtIODevice *qmp_find_virtio_device(const char *path)
/* Verify the canonical path is a realized virtio device */
Object *dev = object_dynamic_cast(object_resolve_path(path, NULL),
TYPE_VIRTIO_DEVICE);
if (!dev || !DEVICE(dev)->realized) {
if (!dev || !qdev_is_realized(DEVICE(dev))) {
return NULL;
}
return VIRTIO_DEVICE(dev);
+1 -1
View File
@@ -81,7 +81,7 @@ void watchdog_perform_action(void)
case WATCHDOG_ACTION_INJECT_NMI:
qapi_event_send_watchdog(WATCHDOG_ACTION_INJECT_NMI);
nmi_monitor_handle(0, NULL);
nmi_inject(NULL);
break;
default:
+6 -9
View File
@@ -60,7 +60,7 @@ typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
* expensive given the eventual call to
* object_class_dynamic_cast_assert(). Because of this the CPUState
* has a cached value for the class in cs->cc which is set up in
* cpu_exec_realizefn() for use in hot code paths.
* cpu_common_initfn() for use in hot code paths.
*/
typedef struct CPUClass CPUClass;
DECLARE_CLASS_CHECKERS(CPUClass, CPU,
@@ -1178,14 +1178,11 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
*/
void qemu_process_cpu_events(CPUState *cpu);
/* $(top_srcdir)/cpu.c */
void cpu_class_init_props(DeviceClass *dc);
void cpu_exec_class_post_init(CPUClass *cc);
void cpu_exec_initfn(CPUState *cpu);
void cpu_vmstate_register(CPUState *cpu);
void cpu_vmstate_unregister(CPUState *cpu);
bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
void cpu_exec_unrealizefn(CPUState *cpu);
/** cpu_common_realize: CPU DeviceRealize common handler */
bool cpu_common_realize(CPUState *cpu, Error **errp);
/** cpu_common_realize: CPU DeviceUnrealize common handler */
void cpu_common_unrealize(CPUState *cpu);
void cpu_exec_reset_hold(CPUState *cpu);
extern const VMStateDescription vmstate_cpu_common;
+31 -2
View File
@@ -37,9 +37,38 @@ typedef struct NMIState NMIState;
struct NMIClass {
InterfaceClass parent_class;
void (*nmi_monitor_handler)(NMIState *n, int cpu_index, Error **errp);
/**
* raise_nmi: Callback to handle NMI notifications.
* @ns: Class #NMIState state
*
* Called by nmi_inject() to perform the machine-specific
* action when a NMI is requested.
*/
void (*raise_nmi)(NMIState *ns);
};
void nmi_monitor_handle(int cpu_index, Error **errp);
/**
* nmi_inject: Inject an NMI, in a machine-specific way
* @errp: pointer to error object
*
* This function injects an NMI, in a machine-specific way. The
* intention is that this should typically trigger a guest kernel
* dump or reboot, and might happen as a result of user request
* from the monitor, watchdog timeouts, and similar events.
* (For example on the x86 PC it triggers an NMI on all CPUs,
* and on s390 it triggers the RESTART interrupt on the first CPU.)
*
* The NMI is injected by looking for a QOM object which implements
* the TYPE_NMI interface, and calling its raise_nmi method. Usually
* it is the machine model class that implements this interface.
*
* Not all machines implement NMI handling; this function
* will return an error if used on a machine which does not
* implement NMIs.
*
* On success, return %true.
* On failure, store an error through @errp and return %false.
*/
bool nmi_inject(Error **errp);
#endif /* NMI_H */
-16
View File
@@ -1,16 +0,0 @@
/*
* Support for dma_addr_t typed properties
*
* Copyright (C) 2012 David Gibson, IBM Corporation.
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef HW_QDEV_DMA_H
#define HW_QDEV_DMA_H
#define DEFINE_PROP_DMAADDR(_n, _s, _f, _d) \
DEFINE_PROP_UINT64(_n, _s, _f, _d)
#endif
+1 -1
View File
@@ -437,7 +437,7 @@ DeviceState *qdev_try_new(const char *name);
* Context: May be called outside big qemu lock.
* Return: true if the device has been fully constructed, false otherwise.
*/
static inline bool qdev_is_realized(DeviceState *dev)
static inline bool qdev_is_realized(const DeviceState *dev)
{
return qatomic_load_acquire(&dev->realized);
}
+5
View File
@@ -427,6 +427,11 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
file_size = ph->p_filesz; /* Size of the allocated data */
data_offset = ph->p_offset; /* Offset where the data is located */
if (file_size > mem_size) {
ret = ELF_LOAD_TOO_BIG;
goto fail;
}
if (file_size > 0) {
if (g_mapped_file_get_length(mapped_file) <
file_size + data_offset) {
+1 -1
View File
@@ -12,7 +12,7 @@
#include "qom/object.h"
#include "exec/hwaddr.h"
#include "exec/mmu-access-type.h"
#include "monitor/monitor.h"
#define TYPE_HEXAGON_TLB "hexagon-tlb"
OBJECT_DECLARE_SIMPLE_TYPE(HexagonTLBState, HEXAGON_TLB)
+3 -4
View File
@@ -1,9 +1,8 @@
#ifndef MONITOR_H
#define MONITOR_H
#include "block/block.h"
#include "qapi/qapi-types-misc.h"
#include "qapi/qapi-emit-events.h"
#include "qemu/coroutine-core.h"
#include "qemu/readline.h"
#include "exec/hwaddr.h"
#include "qom/object.h"
@@ -56,8 +55,8 @@ void monitor_flush_locked(Monitor *mon);
void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
void monitor_read_command(MonitorHMP *mon, int show_prompt);
int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
void monitor_read_command(MonitorHMP *hmp, int show_prompt);
int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
void *opaque);
AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
-1
View File
@@ -14,7 +14,6 @@
#ifndef QAPI_QMP_DISPATCH_H
#define QAPI_QMP_DISPATCH_H
#include "monitor/monitor.h"
#include "qemu/queue.h"
typedef void (QmpCommandFunc)(QDict *, QObject **, Error **);
+1
View File
@@ -15,6 +15,7 @@
#include "qemu/osdep.h"
#include "block/qapi.h"
#include "block/block-global-state.h"
#include "migration/snapshot.h"
#include "monitor/hmp.h"
#include "monitor/hmp-completion.h"
+1
View File
@@ -29,6 +29,7 @@
#include "qapi/qmp/qerror.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/lockable.h"
#include "system/runstate.h"
/* file descriptors passed via SCM_RIGHTS */
+3 -3
View File
@@ -290,16 +290,16 @@ void hmp_info_sync_profile(Monitor *mon, const QDict *qdict)
void hmp_info_history(Monitor *mon, const QDict *qdict)
{
MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
MonitorHMP *hmp = MONITOR_HMP(mon);
int i;
const char *str;
if (!hmp_mon->rs) {
if (!hmp->rs) {
return;
}
i = 0;
for(;;) {
str = readline_get_history(hmp_mon->rs, i);
str = readline_get_history(hmp->rs, i);
if (!str) {
break;
}
+69 -67
View File
@@ -49,24 +49,24 @@ OBJECT_DEFINE_TYPE(MonitorHMP, monitor_hmp, MONITOR_HMP, MONITOR);
static void monitor_hmp_finalize(Object *obj)
{
MonitorHMP *mon = MONITOR_HMP(obj);
if (mon->rs) {
readline_free(mon->rs);
MonitorHMP *hmp = MONITOR_HMP(obj);
if (hmp->rs) {
readline_free(hmp->rs);
}
}
static bool monitor_hmp_get_readline(Object *obj, Error **errp)
{
MonitorHMP *mon = MONITOR_HMP(obj);
MonitorHMP *hmp = MONITOR_HMP(obj);
return mon->use_readline;
return hmp->use_readline;
}
static void monitor_hmp_set_readline(Object *obj, bool val, Error **errp)
{
MonitorHMP *mon = MONITOR_HMP(obj);
MonitorHMP *hmp = MONITOR_HMP(obj);
mon->use_readline = val;
hmp->use_readline = val;
}
int monitor_hmp_vprintf(Monitor *mon, const char *fmt, va_list ap)
@@ -128,34 +128,34 @@ static void monitor_hmp_accept_input(Monitor *mon)
static void monitor_command_cb(void *opaque, const char *cmdline,
void *readline_opaque)
{
MonitorHMP *mon = opaque;
MonitorHMP *hmp = opaque;
monitor_suspend(&mon->parent_obj);
handle_hmp_command(mon, cmdline);
monitor_resume(&mon->parent_obj);
monitor_suspend(&hmp->parent_obj);
handle_hmp_command(hmp, cmdline);
monitor_resume(&hmp->parent_obj);
}
void monitor_read_command(MonitorHMP *mon, int show_prompt)
void monitor_read_command(MonitorHMP *hmp, int show_prompt)
{
if (!mon->rs) {
if (!hmp->rs) {
return;
}
readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL);
readline_start(hmp->rs, "(qemu) ", 0, monitor_command_cb, NULL);
if (show_prompt) {
readline_show_prompt(mon->rs);
readline_show_prompt(hmp->rs);
}
}
int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
int monitor_read_password(MonitorHMP *hmp, ReadLineFunc *readline_func,
void *opaque)
{
if (mon->rs) {
readline_start(mon->rs, "Password: ", 1, readline_func, opaque);
if (hmp->rs) {
readline_start(hmp->rs, "Password: ", 1, readline_func, opaque);
/* prompt is printed on return from the command handler */
return 0;
} else {
monitor_printf(&mon->parent_obj,
monitor_printf(&hmp->parent_obj,
"terminal does not support password prompting\n");
return -ENOTTY;
}
@@ -772,12 +772,12 @@ static const HMPCommand *search_dispatch_table(const HMPCommand *disp_table,
* Do not assume the return value points into @table! It doesn't when
* the command is found in a sub-command table.
*/
static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
static const HMPCommand *monitor_parse_command(MonitorHMP *hmp,
const char *cmdp_start,
const char **cmdp,
HMPCommand *table)
{
Monitor *mon = &hmp_mon->parent_obj;
Monitor *mon = &hmp->parent_obj;
const char *p;
const HMPCommand *cmd;
char cmdname[256];
@@ -809,7 +809,7 @@ static const HMPCommand *monitor_parse_command(MonitorHMP *hmp_mon,
*cmdp = p;
/* search sub command */
if (cmd->sub_table != NULL && *p != '\0') {
return monitor_parse_command(hmp_mon, cmdp_start, cmdp, cmd->sub_table);
return monitor_parse_command(hmp, cmdp_start, cmdp, cmd->sub_table);
}
return cmd;
@@ -1254,15 +1254,15 @@ static void handle_hmp_command_co(void *opaque)
data->done = true;
}
void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
void handle_hmp_command(MonitorHMP *hmp, const char *cmdline)
{
QDict *qdict;
const HMPCommand *cmd;
const char *cmd_start = cmdline;
trace_handle_hmp_command(mon, cmdline);
trace_handle_hmp_command(hmp, cmdline);
cmd = monitor_parse_command(mon, cmdline, &cmdline,
cmd = monitor_parse_command(hmp, cmdline, &cmdline,
hmp_cmds_for_target(false));
if (!cmd) {
return;
@@ -1270,17 +1270,17 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
if (!cmd->cmd && !cmd->cmd_info_hrt) {
/* FIXME: is it useful to try autoload modules here ??? */
monitor_printf(&mon->parent_obj, "Command \"%.*s\" is not available.\n",
monitor_printf(&hmp->parent_obj, "Command \"%.*s\" is not available.\n",
(int)(cmdline - cmd_start), cmd_start);
return;
}
qdict = monitor_parse_arguments(&mon->parent_obj, &cmdline, cmd);
qdict = monitor_parse_arguments(&hmp->parent_obj, &cmdline, cmd);
if (!qdict) {
while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) {
cmdline--;
}
monitor_printf(&mon->parent_obj,
monitor_printf(&hmp->parent_obj,
"Try \"help %.*s\" for more information\n",
(int)(cmdline - cmd_start), cmd_start);
return;
@@ -1289,18 +1289,18 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
if (!cmd->coroutine) {
/* old_mon is non-NULL when called from qmp_human_monitor_command() */
Monitor *old_mon = monitor_set_cur(qemu_coroutine_self(),
&mon->parent_obj);
handle_hmp_command_exec(&mon->parent_obj, cmd, qdict);
&hmp->parent_obj);
handle_hmp_command_exec(&hmp->parent_obj, cmd, qdict);
monitor_set_cur(qemu_coroutine_self(), old_mon);
} else {
HandleHmpCommandCo data = {
.mon = &mon->parent_obj,
.mon = &hmp->parent_obj,
.cmd = cmd,
.qdict = qdict,
.done = false,
};
Coroutine *co = qemu_coroutine_create(handle_hmp_command_co, &data);
monitor_set_cur(co, &mon->parent_obj);
monitor_set_cur(co, &hmp->parent_obj);
aio_co_enter(qemu_get_aio_context(), co);
AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done);
}
@@ -1308,7 +1308,8 @@ void handle_hmp_command(MonitorHMP *mon, const char *cmdline)
qobject_unref(qdict);
}
static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
static void cmd_completion(MonitorHMP *hmp,
const char *name, const char *list)
{
const char *p, *pstart;
char cmd[128];
@@ -1324,7 +1325,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
memcpy(cmd, pstart, len);
cmd[len] = '\0';
readline_add_completion_of(mon->rs, name, cmd);
readline_add_completion_of(hmp->rs, name, cmd);
if (*p == '\0') {
break;
}
@@ -1332,7 +1333,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
}
static void file_completion(MonitorHMP *mon, const char *input)
static void file_completion(MonitorHMP *hmp, const char *input)
{
DIR *ffs;
struct dirent *d;
@@ -1384,7 +1385,7 @@ static void file_completion(MonitorHMP *mon, const char *input)
if (stat(file, &sb) == 0 && S_ISDIR(sb.st_mode)) {
pstrcat(file, sizeof(file), "/");
}
readline_add_completion(mon->rs, file);
readline_add_completion(hmp->rs, file);
}
}
closedir(ffs);
@@ -1396,7 +1397,7 @@ static const char *next_arg_type(const char *typestr)
return (p != NULL ? ++p : typestr);
}
static void monitor_find_completion_by_table(MonitorHMP *mon,
static void monitor_find_completion_by_table(MonitorHMP *hmp,
const HMPCommand *cmd_table,
char **args,
int nb_args)
@@ -1414,10 +1415,10 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
} else {
cmdname = args[0];
}
readline_set_completion_index(mon->rs, strlen(cmdname));
readline_set_completion_index(hmp->rs, strlen(cmdname));
for (cmd = cmd_table; cmd->name != NULL; cmd++) {
if (cmd_available(cmd)) {
cmd_completion(mon, cmdname, cmd->name);
cmd_completion(hmp, cmdname, cmd->name);
}
}
} else {
@@ -1434,12 +1435,12 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
if (cmd->sub_table) {
/* do the job again */
monitor_find_completion_by_table(mon, cmd->sub_table,
monitor_find_completion_by_table(hmp, cmd->sub_table,
&args[1], nb_args - 1);
return;
}
if (cmd->command_completion) {
cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
cmd->command_completion(hmp->rs, nb_args, args[nb_args - 1]);
return;
}
@@ -1461,20 +1462,20 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
switch (*ptype) {
case 'F':
/* file completion */
readline_set_completion_index(mon->rs, strlen(str));
file_completion(mon, str);
readline_set_completion_index(hmp->rs, strlen(str));
file_completion(hmp, str);
break;
case 'B':
/* block device name completion */
readline_set_completion_index(mon->rs, strlen(str));
readline_set_completion_index(hmp->rs, strlen(str));
while ((blk = blk_next(blk)) != NULL) {
readline_add_completion_of(mon->rs, str, blk_name(blk));
readline_add_completion_of(hmp->rs, str, blk_name(blk));
}
break;
case 's':
case 'S':
if (!strcmp(cmd->name, "help|?")) {
monitor_find_completion_by_table(mon, cmd_table,
monitor_find_completion_by_table(hmp, cmd_table,
&args[1], nb_args - 1);
}
break;
@@ -1487,7 +1488,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
static void monitor_find_completion(void *opaque,
const char *cmdline)
{
MonitorHMP *mon = opaque;
MonitorHMP *hmp = opaque;
char *args[MAX_ARGS];
int nb_args, len;
@@ -1509,7 +1510,7 @@ static void monitor_find_completion(void *opaque,
}
/* 2. auto complete according to args */
monitor_find_completion_by_table(mon, hmp_cmds_for_target(false),
monitor_find_completion_by_table(hmp, hmp_cmds_for_target(false),
args, nb_args);
cleanup:
@@ -1518,18 +1519,19 @@ cleanup:
static void monitor_read(void *opaque, const uint8_t *buf, int size)
{
MonitorHMP *mon = container_of(opaque, MonitorHMP, parent_obj);
Monitor *mon = opaque;
MonitorHMP *hmp = MONITOR_HMP(mon);
int i;
if (mon->rs) {
if (hmp->rs) {
for (i = 0; i < size; i++) {
readline_handle_byte(mon->rs, buf[i]);
readline_handle_byte(hmp->rs, buf[i]);
}
} else {
if (size == 0 || buf[size - 1] != 0) {
monitor_printf(&mon->parent_obj, "corrupted command\n");
monitor_printf(&hmp->parent_obj, "corrupted command\n");
} else {
handle_hmp_command(mon, (char *)buf);
handle_hmp_command(hmp, (char *)buf);
}
}
}
@@ -1598,17 +1600,17 @@ static void monitor_event(void *opaque, QEMUChrEvent event)
static void G_GNUC_PRINTF(2, 3) monitor_readline_printf(void *opaque,
const char *fmt, ...)
{
MonitorHMP *mon = opaque;
MonitorHMP *hmp = opaque;
va_list ap;
va_start(ap, fmt);
monitor_vprintf(&mon->parent_obj, fmt, ap);
monitor_vprintf(&hmp->parent_obj, fmt, ap);
va_end(ap);
}
static void monitor_readline_flush(void *opaque)
{
MonitorHMP *mon = opaque;
monitor_flush(&mon->parent_obj);
MonitorHMP *hmp = opaque;
monitor_flush(&hmp->parent_obj);
}
void monitor_new_hmp(const char *id, const char *chardev_id,
@@ -1626,11 +1628,11 @@ void monitor_new_hmp(const char *id, const char *chardev_id,
static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
{
MonitorHMP *mon = MONITOR_HMP(uc);
MonitorHMP *hmp = MONITOR_HMP(uc);
UserCreatableClass *ucc_parent =
USER_CREATABLE_CLASS(
object_class_get_parent(
OBJECT_CLASS(MONITOR_HMP_GET_CLASS(mon))));
OBJECT_CLASS(MONITOR_HMP_GET_CLASS(hmp))));
ERRP_GUARD();
ucc_parent->complete(uc, errp);
@@ -1638,21 +1640,21 @@ static void monitor_hmp_complete(UserCreatable *uc, Error **errp)
return;
}
if (mon->parent_obj.chardev_id) {
if (mon->use_readline) {
mon->rs = readline_init(monitor_readline_printf,
if (hmp->parent_obj.chardev_id) {
if (hmp->use_readline) {
hmp->rs = readline_init(monitor_readline_printf,
monitor_readline_flush,
mon,
hmp,
monitor_find_completion);
monitor_read_command(mon, 0);
monitor_read_command(hmp, 0);
}
qemu_chr_fe_set_handlers(&mon->parent_obj.chr,
qemu_chr_fe_set_handlers(&hmp->parent_obj.chr,
monitor_can_read,
monitor_read,
monitor_event, NULL,
&mon->parent_obj, NULL, true);
monitor_list_append(&mon->parent_obj);
&hmp->parent_obj, NULL, true);
monitor_list_append(&hmp->parent_obj);
}
}
+2 -1
View File
@@ -27,6 +27,7 @@
#include "chardev/char-fe.h"
#include "monitor/monitor.h"
#include "qapi/qapi-emit-events.h"
#include "qapi/qapi-types-control.h"
#include "qapi/qapi-types-qom.h"
#include "qapi/qmp-registry.h"
@@ -220,7 +221,7 @@ void monitor_data_destroy_qmp(MonitorQMP *mon);
void coroutine_fn monitor_qmp_dispatcher_co(void *data);
void qmp_dispatcher_co_wake(void);
void handle_hmp_command(MonitorHMP *mon, const char *cmdline);
void handle_hmp_command(MonitorHMP *hmp, const char *cmdline);
int hmp_compare_cmd(const char *name, const char *list);
/*
+2
View File
@@ -30,7 +30,9 @@
#include "qapi/qapi-visit-control.h"
#include "qobject/qdict.h"
#include "qom/object_interfaces.h"
#include "qemu/aio-wait.h"
#include "qemu/error-report.h"
#include "qemu/lockable.h"
#include "qemu/option.h"
#include "system/qtest.h"
#include "trace.h"
+2 -1
View File
@@ -23,7 +23,8 @@
*/
#include "qemu/osdep.h"
#include "qemu/aio-wait.h"
#include "qemu/lockable.h"
#include "chardev/char-io.h"
#include "monitor-internal.h"
#include "qapi/error.h"
+1
View File
@@ -17,6 +17,7 @@
#include "hw/virtio/vhost-vdpa.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "qemu/iov.h"
#include "qemu/log.h"
#include "qemu/memalign.h"
#include "qemu/option.h"
+4 -3
View File
@@ -432,9 +432,10 @@
##
# @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.
# Injects a Non-Maskable Interrupt (machine specific: for example on
# s390x CCW only the first vCPU receives the NMI, but on x86 machines
# all vCPUs receive it). The command fails when the guest doesn't
# support injecting.
#
# Since: 0.14
#
+2
View File
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include "qemu/aio.h"
#include "qemu/aio-wait.h"
#include "qapi/compat-policy.h"
#include "qapi/error.h"
#include "qapi/qmp-registry.h"
@@ -24,6 +25,7 @@
#include "qobject/qbool.h"
#include "qemu/coroutine.h"
#include "qemu/main-loop.h"
#include "monitor/monitor.h"
Visitor *qobject_input_visitor_new_qmp(QObject *obj)
{
+4 -2
View File
@@ -317,8 +317,10 @@
#
# @none: nothing is done
#
# @inject-nmi: a non-maskable interrupt is injected into the first
# VCPU (all VCPUS on x86) (since 2.4)
# @inject-nmi: a non-maskable interrupt is injected (machine
# specific: for example on s390x CCW only the first vCPU
# receives the NMI, but on x86 machines all vCPUs receive
# it). (since 2.4)
#
# Since: 2.1
##
-248
View File
@@ -23,13 +23,8 @@
*/
#include "qemu/osdep.h"
#include "monitor/monitor.h"
#include "qemu/coroutine-tls.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"
#include "exec/gdbstub.h"
#include "accel/accel-cpu-ops.h"
#include "system/hw_accel.h"
@@ -39,11 +34,9 @@
#include "qemu/plugin.h"
#include "system/cpus.h"
#include "qemu/guest-random.h"
#include "hw/core/nmi.h"
#include "system/physmem.h"
#include "system/replay.h"
#include "system/runstate.h"
#include "migration/misc.h"
#include "system/cpu-timers.h"
#include "system/whpx.h"
#include "hw/core/boards.h"
@@ -278,58 +271,6 @@ void cpu_interrupt(CPUState *cpu, int mask)
cpus_accel->handle_interrupt(cpu, mask);
}
/*
* True if the vm was previously suspended, and has not been woken or reset.
*/
static int vm_was_suspended;
void vm_set_suspended(bool suspended)
{
vm_was_suspended = suspended;
}
bool vm_get_suspended(void)
{
return vm_was_suspended;
}
static int do_vm_stop(RunState state, bool send_stop)
{
int ret = 0;
RunState oldstate = runstate_get();
if (runstate_is_live(oldstate)) {
vm_was_suspended = (oldstate == RUN_STATE_SUSPENDED);
runstate_set(state);
cpu_disable_ticks();
if (oldstate == RUN_STATE_RUNNING) {
pause_all_vcpus();
}
ret = vm_state_notify(0, state);
if (send_stop) {
qapi_event_send_stop();
}
}
bdrv_drain_all();
/*
* Even if vm_state_notify() return failure,
* it would be better to flush as before.
*/
ret |= bdrv_flush_all();
trace_vm_stop_flush_all(ret);
return ret;
}
/* Special vm_stop() variant for terminating the process. Historically clients
* did not expect a QMP STOP event and so we need to retain compatibility.
*/
int vm_shutdown(void)
{
return do_vm_stop(RUN_STATE_SHUTDOWN, false);
}
bool cpu_can_run(CPUState *cpu)
{
if (cpu->stop) {
@@ -740,192 +681,3 @@ void cpu_stop_current(void)
cpu_exit(current_cpu);
}
}
int vm_stop(RunState state)
{
if (qemu_in_vcpu_thread()) {
qemu_system_vmstop_request_prepare();
qemu_system_vmstop_request(state);
/*
* FIXME: should not return to device code in case
* vm_stop() has been requested.
*/
cpu_stop_current();
return 0;
}
return do_vm_stop(state, true);
}
/**
* Prepare for (re)starting the VM.
* Returns 0 if the vCPUs should be restarted, -1 on an error condition,
* and 1 otherwise.
*/
int vm_prepare_start(bool step_pending)
{
int ret = vm_was_suspended ? 1 : 0;
RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
RunState requested;
qemu_vmstop_requested(&requested);
if (runstate_is_running() && requested == RUN_STATE__MAX) {
return -1;
}
/* Ensure that a STOP/RESUME pair of events is emitted if a
* vmstop request was pending. The BLOCK_IO_ERROR event, for
* example, according to documentation is always followed by
* the STOP event.
*/
if (runstate_is_running()) {
qapi_event_send_stop();
qapi_event_send_resume();
return -1;
}
/*
* WHPX accelerator needs to know whether we are going to step
* any CPUs, before starting the first one.
*/
accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
/* We are sending this now, but the CPUs will be resumed shortly later */
qapi_event_send_resume();
cpu_enable_ticks();
runstate_set(state);
vm_state_notify(1, state);
vm_was_suspended = false;
return ret;
}
void vm_start(void)
{
if (!vm_prepare_start(false)) {
resume_all_vcpus();
}
}
void vm_resume(RunState state)
{
if (runstate_is_live(state)) {
vm_start();
} else {
runstate_set(state);
}
}
/* does a state transition even if the VM is already stopped,
current state is forgotten forever */
int vm_stop_force_state(RunState state)
{
if (runstate_is_live(runstate_get())) {
return vm_stop(state);
} else {
int ret;
runstate_set(state);
bdrv_drain_all();
/* Make sure to return an error if the flush in a previous vm_stop()
* failed. */
ret = bdrv_flush_all();
trace_vm_stop_flush_all(ret);
return ret;
}
}
void qmp_memsave(uint64_t addr, uint64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{
FILE *f;
uint64_t l;
CPUState *cpu;
uint8_t buf[1024];
uint64_t orig_addr = addr, orig_size = size;
if (migration_guest_ram_loading()) {
error_setg(errp, "Guest memory access not allowed during migration");
return;
}
if (!has_cpu) {
cpu_index = 0;
}
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRIu64
" specified", orig_addr, orig_size);
goto exit;
}
if (fwrite(buf, 1, l, f) != l) {
error_setg(errp, "writing memory to '%s' failed",
filename);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
Error **errp)
{
FILE *f;
uint64_t l;
uint8_t buf[1024];
if (migration_guest_ram_loading()) {
error_setg(errp, "Guest memory access not allowed during migration");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size)
l = size;
physical_memory_read(addr, buf, l);
if (fwrite(buf, 1, l, f) != l) {
error_setg(errp, "writing memory to '%s' failed",
filename);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
void qmp_inject_nmi(Error **errp)
{
nmi_monitor_handle(monitor_get_cpu_index(monitor_cur()), errp);
}
-1
View File
@@ -29,7 +29,6 @@
#include "qemu/config-file.h"
#include "qapi/qapi-commands-machine.h"
#include "qobject/qdict.h"
#include "monitor/hmp.h"
#include <libfdt.h>
+74
View File
@@ -0,0 +1,74 @@
/*
* HMP commands related to migration dirty page rate limit
*
* Copyright (c) 2022 CHINA TELECOM CO.,LTD.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
#include "qobject/qdict.h"
#include "monitor/hmp.h"
#include "monitor/monitor.h"
#include "system/dirtylimit.h"
void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
Error *err = NULL;
qmp_cancel_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, &err);
if (err) {
hmp_handle_error(mon, err);
return;
}
monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
"dirty limit for virtual CPU]\n");
}
void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
Error *err = NULL;
if (dirty_rate < 0) {
error_setg(&err, "invalid dirty page limit %" PRId64, dirty_rate);
goto out;
}
qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);
out:
hmp_handle_error(mon, err);
}
void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
DirtyLimitInfoList *info;
g_autoptr(DirtyLimitInfoList) head = NULL;
Error *err = NULL;
if (!dirtylimit_in_service()) {
monitor_printf(mon, "Dirty page limit not enabled!\n");
return;
}
head = qmp_query_vcpu_dirty_limit(&err);
if (err) {
hmp_handle_error(mon, err);
return;
}
for (info = head; info != NULL; info = info->next) {
monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
" current rate %"PRIi64 " (MB/s)\n",
info->value->cpu_index,
info->value->limit_rate,
info->value->current_rate);
}
}
-60
View File
@@ -17,8 +17,6 @@
#include "qapi/error.h"
#include "system/dirtyrate.h"
#include "system/dirtylimit.h"
#include "monitor/hmp.h"
#include "monitor/monitor.h"
#include "system/memory.h"
#include "exec/target_page.h"
#include "hw/core/boards.h"
@@ -491,21 +489,6 @@ void qmp_cancel_vcpu_dirty_limit(bool has_cpu_index,
dirtylimit_state_unlock();
}
void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
Error *err = NULL;
qmp_cancel_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, &err);
if (err) {
hmp_handle_error(mon, err);
return;
}
monitor_printf(mon, "[Please use 'info vcpu_dirty_limit' to query "
"dirty limit for virtual CPU]\n");
}
void qmp_set_vcpu_dirty_limit(bool has_cpu_index,
int64_t cpu_index,
uint64_t dirty_rate,
@@ -548,23 +531,6 @@ void qmp_set_vcpu_dirty_limit(bool has_cpu_index,
dirtylimit_state_unlock();
}
void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
int64_t dirty_rate = qdict_get_int(qdict, "dirty_rate");
int64_t cpu_index = qdict_get_try_int(qdict, "cpu_index", -1);
Error *err = NULL;
if (dirty_rate < 0) {
error_setg(&err, "invalid dirty page limit %" PRId64, dirty_rate);
goto out;
}
qmp_set_vcpu_dirty_limit(!!(cpu_index != -1), cpu_index, dirty_rate, &err);
out:
hmp_handle_error(mon, err);
}
/* Return the max throttle time of each virtual CPU */
uint64_t dirtylimit_throttle_time_per_round(void)
{
@@ -646,29 +612,3 @@ struct DirtyLimitInfoList *qmp_query_vcpu_dirty_limit(Error **errp)
{
return dirtylimit_query_all();
}
void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict)
{
DirtyLimitInfoList *info;
g_autoptr(DirtyLimitInfoList) head = NULL;
Error *err = NULL;
if (!dirtylimit_in_service()) {
monitor_printf(mon, "Dirty page limit not enabled!\n");
return;
}
head = qmp_query_vcpu_dirty_limit(&err);
if (err) {
hmp_handle_error(mon, err);
return;
}
for (info = head; info != NULL; info = info->next) {
monitor_printf(mon, "vcpu[%"PRIi64"], limit rate %"PRIi64 " (MB/s),"
" current rate %"PRIi64 " (MB/s)\n",
info->value->cpu_index,
info->value->limit_rate,
info->value->current_rate);
}
}
+2
View File
@@ -9,6 +9,7 @@ system_ss.add(files(
'cpus.c',
'cpu-timers.c',
'dirtylimit.c',
'dirtylimit-hmp-cmds.c',
'dma-helpers.c',
'exit-with-parent.c',
'globals.c',
@@ -18,6 +19,7 @@ system_ss.add(files(
'memory_mapping.c',
'memory.c',
'physmem.c',
'physmem-qmp-cmds.c',
'qdev-monitor.c',
'qtest.c',
'rtc.c',
+107
View File
@@ -0,0 +1,107 @@
/*
* QMP commands to dump physical memory
*
* Copyright (c) 2003-2008 Fabrice Bellard
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-machine.h"
#include "qapi/qmp/qerror.h"
#include "hw/core/cpu.h"
#include "system/physmem.h"
#include "migration/misc.h"
void qmp_memsave(uint64_t addr, uint64_t size, const char *filename,
bool has_cpu, int64_t cpu_index, Error **errp)
{
FILE *f;
uint64_t l;
CPUState *cpu;
uint8_t buf[1024];
uint64_t orig_addr = addr, orig_size = size;
if (migration_guest_ram_loading()) {
error_setg(errp, "Guest memory access not allowed during migration");
return;
}
if (!has_cpu) {
cpu_index = 0;
}
cpu = qemu_get_cpu(cpu_index);
if (cpu == NULL) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
"a CPU number");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size) {
l = size;
}
if (cpu_memory_rw_debug(cpu, addr, buf, l, 0) != 0) {
error_setg(errp, "Invalid addr 0x%016" PRIx64 "/size %" PRIu64
" specified", orig_addr, orig_size);
goto exit;
}
if (fwrite(buf, 1, l, f) != l) {
error_setg(errp, "writing memory to '%s' failed",
filename);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
Error **errp)
{
FILE *f;
uint64_t l;
uint8_t buf[1024];
if (migration_guest_ram_loading()) {
error_setg(errp, "Guest memory access not allowed during migration");
return;
}
f = fopen(filename, "wb");
if (!f) {
error_setg_file_open(errp, errno, filename);
return;
}
while (size != 0) {
l = sizeof(buf);
if (l > size) {
l = size;
}
physical_memory_read(addr, buf, l);
if (fwrite(buf, 1, l, f) != l) {
error_setg(errp, "writing memory to '%s' failed",
filename);
goto exit;
}
addr += l;
size -= l;
}
exit:
fclose(f);
}
-2
View File
@@ -84,8 +84,6 @@
#include "qemu/mmap-alloc.h"
#endif
#include "monitor/monitor.h"
#ifdef CONFIG_LIBDAXCTL
#include <daxctl/libdaxctl.h>
#endif
+154
View File
@@ -52,6 +52,7 @@
#include "qemu/thread.h"
#include "qom/object.h"
#include "qom/object_interfaces.h"
#include "system/cpu-timers.h"
#include "system/cpus.h"
#include "system/qtest.h"
#include "system/replay.h"
@@ -408,6 +409,159 @@ int vm_state_notify(bool running, RunState state)
return ret;
}
/*
* True if the vm was previously suspended, and has not been woken or reset.
*/
static int vm_was_suspended;
void vm_set_suspended(bool suspended)
{
vm_was_suspended = suspended;
}
bool vm_get_suspended(void)
{
return vm_was_suspended;
}
static int do_vm_stop(RunState state, bool send_stop)
{
int ret = 0;
RunState oldstate = runstate_get();
if (runstate_is_live(oldstate)) {
vm_was_suspended = (oldstate == RUN_STATE_SUSPENDED);
runstate_set(state);
cpu_disable_ticks();
if (oldstate == RUN_STATE_RUNNING) {
pause_all_vcpus();
}
ret = vm_state_notify(0, state);
if (send_stop) {
qapi_event_send_stop();
}
}
bdrv_drain_all();
/*
* Even if vm_state_notify() return failure,
* it would be better to flush as before.
*/
ret |= bdrv_flush_all();
trace_vm_stop_flush_all(ret);
return ret;
}
/*
* Special vm_stop() variant for terminating the process. Historically clients
* did not expect a QMP STOP event and so we need to retain compatibility.
*/
int vm_shutdown(void)
{
return do_vm_stop(RUN_STATE_SHUTDOWN, false);
}
int vm_stop(RunState state)
{
if (qemu_in_vcpu_thread()) {
qemu_system_vmstop_request_prepare();
qemu_system_vmstop_request(state);
/*
* FIXME: should not return to device code in case
* vm_stop() has been requested.
*/
cpu_stop_current();
return 0;
}
return do_vm_stop(state, true);
}
/**
* Prepare for (re)starting the VM.
* Returns 0 if the vCPUs should be restarted, -1 on an error condition,
* and 1 otherwise.
*/
int vm_prepare_start(bool step_pending)
{
int ret = vm_was_suspended ? 1 : 0;
RunState state = vm_was_suspended ? RUN_STATE_SUSPENDED : RUN_STATE_RUNNING;
RunState requested;
qemu_vmstop_requested(&requested);
if (runstate_is_running() && requested == RUN_STATE__MAX) {
return -1;
}
/*
* Ensure that a STOP/RESUME pair of events is emitted if a
* vmstop request was pending. The BLOCK_IO_ERROR event, for
* example, according to documentation is always followed by
* the STOP event.
*/
if (runstate_is_running()) {
qapi_event_send_stop();
qapi_event_send_resume();
return -1;
}
/*
* WHPX accelerator needs to know whether we are going to step
* any CPUs, before starting the first one.
*/
accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
/* We are sending this now, but the CPUs will be resumed shortly later */
qapi_event_send_resume();
cpu_enable_ticks();
runstate_set(state);
vm_state_notify(1, state);
vm_was_suspended = false;
return ret;
}
void vm_start(void)
{
if (!vm_prepare_start(false)) {
resume_all_vcpus();
}
}
void vm_resume(RunState state)
{
if (runstate_is_live(state)) {
vm_start();
} else {
runstate_set(state);
}
}
/*
* does a state transition even if the VM is already stopped,
* current state is forgotten forever
*/
int vm_stop_force_state(RunState state)
{
if (runstate_is_live(runstate_get())) {
return vm_stop(state);
} else {
int ret;
runstate_set(state);
bdrv_drain_all();
/*
* Make sure to return an error if the flush in a previous vm_stop()
* failed.
*/
ret = bdrv_flush_all();
trace_vm_stop_flush_all(ret);
return ret;
}
}
static ShutdownCause reset_requested;
static ShutdownCause shutdown_requested;
static int shutdown_exit_code = EXIT_SUCCESS;
+1 -1
View File
@@ -117,7 +117,7 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
cs->tcg_cflags |= CF_PCREL;
#endif
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -1891,7 +1891,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
}
#endif
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -131,7 +131,7 @@ static void avr_cpu_realizefn(DeviceState *dev, Error **errp)
AVRCPUClass *mcc = AVR_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -457,7 +457,7 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+2 -1
View File
@@ -7,8 +7,9 @@
#ifndef HEXAGON_MMU_H
#define HEXAGON_MMU_H
#include "exec/hwaddr.h"
#include "exec/mmu-access-type.h"
#include "cpu.h"
#include "monitor/monitor.h"
extern void hex_tlbw(CPUHexagonState *env, uint32_t index, uint64_t value);
extern uint32_t hex_tlb_lookup(CPUHexagonState *env, uint32_t ssr, uint32_t VA);
+1 -1
View File
@@ -181,7 +181,7 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp)
HPPACPUClass *acc = HPPA_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+6 -6
View File
@@ -10164,7 +10164,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* These may be set by the accel-specific code,
* and the results are subsequently checked / assumed in this function.
*/
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
@@ -10179,7 +10179,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
if (cpu->guest_phys_bits == -1) {
/*
* If it was not set by the user, or by the accelerator via
* cpu_exec_realizefn, clear.
* cpu_common_realize, clear.
*/
cpu->guest_phys_bits = 0;
}
@@ -10188,7 +10188,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
/*
* The default is the same as KVM's. Note that this check
* needs to happen after the evenual setting of ucode_rev in
* accel-specific code in cpu_exec_realizefn.
* accel-specific code in cpu_common_realize.
*/
if (IS_AMD_CPU(env)) {
cpu->ucode_rev = 0x01000065;
@@ -10201,7 +10201,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* mwait extended info: needed for Core compatibility
* We always wake on interrupt even if host does not have the capability.
*
* requires the accel-specific code in cpu_exec_realizefn to
* requires the accel-specific code in cpu_common_realize to
* have already acquired the CPUID data into cpu->mwait.
*/
cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
@@ -10230,7 +10230,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
* Note that this code assumes features expansion has already been done
* (as it checks for CPUID_EXT2_LM), and also assumes that potential
* phys_bits adjustments to match the host have been already done in
* accel-specific code in cpu_exec_realizefn.
* accel-specific code in cpu_common_realize.
*/
if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {
if (cpu->phys_bits && cpu->phys_bits < 32) {
@@ -10387,7 +10387,7 @@ static void x86_cpu_set_bit_prop(Object *obj, Visitor *v, const char *name,
BitProperty *fp = opaque;
bool value;
if (dev->realized) {
if (qdev_is_realized(dev)) {
qdev_prop_set_after_realize(dev, name, errp);
return;
}
+2 -2
View File
@@ -57,13 +57,13 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp)
*
* x86_cpu_realizefn():
* x86_cpu_expand_features()
* cpu_exec_realizefn():
* cpu_common_realize():
* accel_cpu_common_realize()
* kvm_cpu_realizefn()
* host_cpu_realizefn()
* kvm_set_guest_phys_bits()
* check/update ucode_rev, phys_bits, guest_phys_bits, mwait
* cpu_common_realizefn() (via xcc->parent_realize)
* cpu_exec_realize() (via xcc->parent_realize)
*/
if (xcc->max_features) {
if (enable_cpu_pm) {
+1 -1
View File
@@ -704,7 +704,7 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -389,7 +389,7 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
register_m68k_insns(&cpu->env);
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -251,7 +251,7 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
int i = 0;
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -544,7 +544,7 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp)
}
mips_cp0_period_set(cpu);
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -170,7 +170,7 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+2 -2
View File
@@ -6921,7 +6921,7 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
@@ -6956,7 +6956,7 @@ static void ppc_cpu_realize(DeviceState *dev, Error **errp)
return;
unrealize:
cpu_exec_unrealizefn(cs);
cpu_common_unrealize(cs);
}
static void ppc_cpu_unrealize(DeviceState *dev)
+1 -1
View File
@@ -1226,7 +1226,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -2006,7 +2006,7 @@ static void kvm_cpu_instance_init(CPUState *cs)
* We'll get here via the following path:
*
* riscv_cpu_realize()
* -> cpu_exec_realizefn()
* -> cpu_common_realize()
* -> kvm_cpu_realize() (via accel_cpu_common_realize())
*/
static bool kvm_cpu_realize(CPUState *cs, Error **errp)
+1 -1
View File
@@ -1304,7 +1304,7 @@ static void riscv_cpu_set_profile(RISCVCPU *cpu,
* We'll get here via the following path:
*
* riscv_cpu_realize()
* -> cpu_exec_realizefn()
* -> cpu_common_realize()
* -> tcg_cpu_realize() (via accel_cpu_common_realize())
*/
static bool riscv_tcg_cpu_realize(CPUState *cs, Error **errp)
+1 -1
View File
@@ -147,7 +147,7 @@ static void rx_cpu_realize(DeviceState *dev, Error **errp)
RXCPUClass *rcc = RX_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -249,7 +249,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
}
#endif
cpu_exec_realizefn(cs, &err);
cpu_common_realize(cs, &err);
if (err != NULL) {
goto out;
}
+2 -2
View File
@@ -714,7 +714,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name,
S390CPU *cpu = S390_CPU(obj);
bool value;
if (dev->realized) {
if (qdev_is_realized(dev)) {
error_setg(errp, "Attempt to set property '%s' on '%s' after "
"it was realized", name, object_get_typename(obj));
return;
@@ -770,7 +770,7 @@ static void set_feature_group(Object *obj, Visitor *v, const char *name,
S390CPU *cpu = S390_CPU(obj);
bool value;
if (dev->realized) {
if (qdev_is_realized(dev)) {
error_setg(errp, "Attempt to set property '%s' on '%s' after "
"it was realized", name, object_get_typename(obj));
return;
+1 -1
View File
@@ -250,7 +250,7 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev);
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -892,7 +892,7 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
/* Default NaN value: sign bit clear, all frac bits set */
set_float_default_nan_pattern(0b01111111, &env->fp_status);
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -99,7 +99,7 @@ static void tricore_cpu_realizefn(DeviceState *dev, Error **errp)
CPUTriCoreState *env = &cpu->env;
Error *local_err = NULL;
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+1 -1
View File
@@ -257,7 +257,7 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
xtensa_irq_init(&XTENSA_CPU(dev)->env);
#endif
cpu_exec_realizefn(cs, &local_err);
cpu_common_realize(cs, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
+13
View File
@@ -78,6 +78,16 @@ static void test_qdev_free_properties(void)
object_unref(mt);
}
static void test_qdev_double_realization(void)
{
MyDev *mt = STATIC_TYPE(object_new(TYPE_MY_DEV));
qdev_realize(DEVICE(mt), NULL, &error_fatal);
qdev_realize(DEVICE(mt), NULL, &error_fatal);
object_unparent(OBJECT(mt));
object_unref(OBJECT(mt));
}
int main(int argc, char **argv)
{
@@ -90,6 +100,9 @@ int main(int argc, char **argv)
g_test_add_func("/qdev/free-properties",
test_qdev_free_properties);
g_test_add_func("/qdev/double-realization",
test_qdev_double_realization);
g_test_run();
return 0;
+1
View File
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
#include "qemu/sockets.h"
#include "qapi/error.h"
#include "socket-helpers.h"
+3 -3
View File
@@ -19,7 +19,7 @@
#endif
#include "monitor/hmp.h"
#include "monitor/hmp-completion.h"
#include "monitor/monitor-internal.h"
#include "monitor/monitor.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-ui.h"
#include "qobject/qdict.h"
@@ -343,8 +343,8 @@ void hmp_change_vnc(Monitor *mon, const char *device, const char *target,
return;
}
if (!arg) {
MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, parent_obj);
monitor_read_password(hmp_mon, hmp_change_read_arg, NULL);
MonitorHMP *hmp = MONITOR_HMP(mon);
monitor_read_password(hmp, hmp_change_read_arg, NULL);
} else {
qmp_change_vnc_password(arg, errp);
}