introduce QMP-only binaries
Subsystems (2)
cover introduce QMP-only binaries
These three patches introduce a new system emulation binary qemu-qmp-* that does nothing but start a QMP monitor (via systemd activation protocol if possible, otherwise on stdio). The idea is that the creation of the machine would happen through new commands such as machine-set, accel-set, etc.
Patches 1 and 2 simply avoid that {'execute':'quit'} crashes; that's more or less the extent of my testing.
Paolo
Paolo Bonzini (3):
migration: allow calling migration_shutdown without a prior
initialization
net: initialize global variables early
introduce qemu-qmp-*
hw/net/xen_nic.c | 20 +++---
include/net/net.h | 1 +
meson.build | 16 +++--
migration/migration.c | 4 ++
net/net.c | 5 +-
softmmu/{vl.c => climain.c} | 2 +-
softmmu/meson.build | 1 -
softmmu/qmpmain.c | 120 ++++++++++++++++++++++++++++++++++++
softmmu/runstate.c | 1 +
9 files changed, 153 insertions(+), 17 deletions(-)
rename softmmu/{vl.c => climain.c} (99%)
create mode 100644 softmmu/qmpmain.cSignature · 1 line
2.31.1
RFC PATCH 1/3 migration: allow calling migration_shutdown without a prior initialization
This can happen with the qemu-qmp binaries.
--- migration/migration.c | 4 ++++ 1 file changed, 4 insertions(+)
migration/migration.c +4 -0
@@ -226,6 +226,10 @@ void migration_cancel(const Error *error)void migration_shutdown (void ) { +if (!current_migration) { +return ; + } +/* * When the QEMU main thread exit, the COLO thread * may wait a semaphore. So, we should wakeup the
Signature · 1 line
2.31.1
RFC PATCH 2/3 net: initialize global variables early
In reply to Paolo BonziniInitialize global variables separately from net_init_clients, so that calling net_cleanup does not crash miserably.
--- hw/net/xen_nic.c | 20 ++++++++++---------- include/net/net.h | 1 + net/net.c | 5 ++++- softmmu/runstate.c | 1 + 4 files changed, 16 insertions(+), 11 deletions(-)
hw/net/xen_nic.c +10 -10
@@ -275,7 +275,7 @@ static NetClientInfo net_xen_info = { .receive = net_rx_packet, }; -static int net_init (struct XenLegacyDevice *xendev) +static int xen_net_init (struct XenLegacyDevice *xendev) { struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
@@ -307,7 +307,7 @@ static int net_init(struct XenLegacyDevice *xendev)return 0 ; } -static int net_connect (struct XenLegacyDevice *xendev) +static int xen_net_connect (struct XenLegacyDevice *xendev) { struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);int rx_copy;
@@ -362,7 +362,7 @@ static int net_connect(struct XenLegacyDevice *xendev)return 0 ; } -static void net_disconnect (struct XenLegacyDevice *xendev) +static void xen_net_disconnect (struct XenLegacyDevice *xendev) { struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
@@ -378,14 +378,14 @@ static void net_disconnect(struct XenLegacyDevice *xendev) } } -static void net_event (struct XenLegacyDevice *xendev) +static void xen_net_event (struct XenLegacyDevice *xendev) { struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);net_tx_packets (netdev);qemu_flush_queued_packets (qemu_get_queue (netdev->nic)); } -static int net_free (struct XenLegacyDevice *xendev) +static int xen_net_free (struct XenLegacyDevice *xendev) { struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
@@ -403,9 +403,9 @@ static int net_free(struct XenLegacyDevice *xendev)struct XenDevOps xen_netdev_ops = { .size =sizeof (struct XenNetDev ), .flags =DEVOPS_FLAG_NEED_GNTDEV , - .init = net_init, - .initialise = net_connect, - .event = net_event, - .disconnect = net_disconnect, - .free = net_free, + .init = xen_net_init, + .initialise = xen_net_connect, + .event = xen_net_event, + .disconnect = xen_net_disconnect, + .free = xen_net_free, };
include/net/net.h +1 -0
@@ -216,6 +216,7 @@ extern const char *host_net_devices[];/* from net.c */ int net_client_parse (QemuOptsList *opts_list,const char *str);void show_netdevs (void ); +void net_init (void );int net_init_clients (Error **errp);void net_check_clients (void );void net_cleanup (void );
net/net.c +4 -1
@@ -1551,13 +1551,16 @@ out:return ret; } -int net_init_clients (Error **errp) +void net_init (void ) { net_change_state_entry =qemu_add_vm_change_state_handler (net_vm_change_state_handler,NULL );QTAILQ_INIT (&net_clients); +} +int net_init_clients (Error **errp) +{if (qemu_opts_foreach (qemu_find_opts ("netdev" ), net_init_netdev,NULL , errp)) {return -1 ;
softmmu/runstate.c +1 -0
@@ -776,6 +776,7 @@ void qemu_init_subsystems(void)bdrv_init_with_whitelist ();socket_init (); +net_init (); }
Signature · 1 line
2.31.1
Re: [RFC PATCH 2/3] net: initialize global variables early
Quoted 10 lines · Paolo Bonzini
Initialize global variables separately from
net_init_clients, so that callingnet_cleanupdoes not crash miserably.Signed-off-by Paolo Bonzini <[email protected]>--- hw/net/xen_nic.c | 20 ++++++++++---------- include/net/net.h | 1 + net/net.c | 5 ++++- softmmu/runstate.c | 1 + 4 files changed, 16 insertions(+), 11 deletions(-)
RFC PATCH 3/3 introduce qemu-qmp-*
In reply to Paolo Bonzini---
meson.build | 16 +++--
softmmu/{vl.c => climain.c} | 2 +-
softmmu/meson.build | 1 -
softmmu/qmpmain.c | 120 ++++++++++++++++++++++++++++++++++++
4 files changed, 133 insertions(+), 6 deletions(-)
rename softmmu/{vl.c => climain.c} (99%)
create mode 100644 softmmu/qmpmain.cmeson.build +12 -4
@@ -3003,14 +3003,21 @@ foreach target : target_dirs execs = [{ 'name': 'qemu-system-' + target_name, 'win_subsystem': 'console', - 'sources': files('softmmu/main.c'), + 'sources': [files('softmmu/climain.c', 'softmmu/main.c')], 'dependencies': [] }] - if targetos == 'windows' and (sdl.found() or gtk.found()) + if targetos != 'windows' + execs += [{ + 'name': 'qemu-qmp-' + target_name, + 'win_subsystem': 'console', + 'sources': [files('softmmu/qmpmain.c', 'softmmu/main.c')], + 'dependencies': [] + }] + elif sdl.found() or gtk.found() execs += [{ 'name': 'qemu-system-' + target_name + 'w', 'win_subsystem': 'windows', - 'sources': files('softmmu/main.c'), + 'sources': [files('softmmu/climain.c', 'softmmu/main.c')], 'dependencies': [] }] endif
@@ -3019,7 +3026,7 @@ foreach target : target_dirs execs += [{ 'name': 'qemu-fuzz-' + target_name, 'win_subsystem': 'console', - 'sources': specific_fuzz.sources(), + 'sources': [files('softmmu/climain.c'), specific_fuzz.sources()], 'dependencies': specific_fuzz.dependencies(), }] endif
@@ -3040,6 +3047,7 @@ foreach target : target_dirs emulator = executable(exe_name, exe['sources'], install: true, c_args: c_args, + include_directories: target_inc, dependencies: arch_deps + deps + exe['dependencies'], objects: lib.extract_all_objects(recursive: true), link_language: link_language,
softmmu/climain.c renamed from softmmu/vl.c +1 -1
@@ -1,5 +1,5 @@/* -* QEMU System Emulator +* QEMU System Emulator command-line interface * * Copyright (c) 2003-2008 Fabrice Bellard *
softmmu/meson.build +0 -1
@@ -12,7 +12,6 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'memory.c', 'memory_mapping.c', 'qtest.c', - 'vl.c', 'cpu-timers.c', 'runstate-action.c', )])
softmmu/qmpmain.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.31.1