[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/20] qemu-storage-daemon: Add main loop
From: |
Kevin Wolf |
Subject: |
[PATCH v2 12/20] qemu-storage-daemon: Add main loop |
Date: |
Mon, 24 Feb 2020 15:30:00 +0100 |
Instead of exiting after processing all command line options, start a
main loop and keep processing events until exit is requested with a
signal (e.g. SIGINT).
Now qemu-storage-daemon can be used as an alternative for qemu-nbd that
provides a few features that were previously only available from QMP,
such as access to options only available with -blockdev and the socket
types 'vsock' and 'fd'.
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-storage-daemon.c | 13 +++++++++++++
Makefile.objs | 2 ++
2 files changed, 15 insertions(+)
diff --git a/qemu-storage-daemon.c b/qemu-storage-daemon.c
index 5904d3c5b4..14093ac3a0 100644
--- a/qemu-storage-daemon.c
+++ b/qemu-storage-daemon.c
@@ -50,8 +50,16 @@
#include "qemu/option.h"
#include "qom/object_interfaces.h"
+#include "sysemu/runstate.h"
#include "trace/control.h"
+static volatile bool exit_requested = false;
+
+void qemu_system_killed(int signal, pid_t pid)
+{
+ exit_requested = true;
+}
+
static void help(void)
{
printf(
@@ -241,6 +249,7 @@ int main(int argc, char *argv[])
error_init(argv[0]);
qemu_init_exec_dir(argv[0]);
+ os_setup_signal_handling();
module_call_init(MODULE_INIT_QOM);
module_call_init(MODULE_INIT_TRACE);
@@ -256,5 +265,9 @@ int main(int argc, char *argv[])
qemu_init_main_loop(&error_fatal);
process_options(argc, argv);
+ while (!exit_requested) {
+ main_loop_wait(false);
+ }
+
return EXIT_SUCCESS;
}
diff --git a/Makefile.objs b/Makefile.objs
index 25ab313690..5b30537fd9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -33,6 +33,8 @@ endif # CONFIG_SOFTMMU or CONFIG_TOOLS
storage-daemon-obj-y = block/ qom/
storage-daemon-obj-y += blockdev.o blockdev-nbd.o iothread.o
+storage-daemon-obj-$(CONFIG_WIN32) += os-win32.o
+storage-daemon-obj-$(CONFIG_POSIX) += os-posix.o
######################################################################
# Target independent part of system emulation. The long term path is to
--
2.20.1
- [PATCH v2 02/20] stubs: Add arch_type, (continued)
- [PATCH v2 02/20] stubs: Add arch_type, Kevin Wolf, 2020/02/24
- [PATCH v2 01/20] qemu-storage-daemon: Add barebone tool, Kevin Wolf, 2020/02/24
- [PATCH v2 04/20] block: Move common QMP commands to block-core QAPI module, Kevin Wolf, 2020/02/24
- [PATCH v2 03/20] block: Move system emulator QMP commands to block/qapi-sysemu.c, Kevin Wolf, 2020/02/24
- [PATCH v2 05/20] block: Move sysemu QMP commands to QAPI block module, Kevin Wolf, 2020/02/24
- [PATCH v2 08/20] qemu-storage-daemon: Add --object option, Kevin Wolf, 2020/02/24
- [PATCH v2 06/20] qemu-storage-daemon: Add --blockdev option, Kevin Wolf, 2020/02/24
- [PATCH v2 07/20] qapi: Flatten object-add, Kevin Wolf, 2020/02/24
- [PATCH v2 09/20] qemu-storage-daemon: Add --nbd-server option, Kevin Wolf, 2020/02/24
- [PATCH v2 10/20] blockdev-nbd: Boxed argument type for nbd-server-add, Kevin Wolf, 2020/02/24
- [PATCH v2 12/20] qemu-storage-daemon: Add main loop,
Kevin Wolf <=
- [PATCH v2 11/20] qemu-storage-daemon: Add --export option, Kevin Wolf, 2020/02/24
- [PATCH v2 13/20] qemu-storage-daemon: Add --chardev option, Kevin Wolf, 2020/02/24
- [PATCH v2 14/20] stubs: Update monitor stubs for qemu-storage-daemon, Kevin Wolf, 2020/02/24
- [PATCH v2 16/20] monitor: Create QAPIfied monitor_init(), Kevin Wolf, 2020/02/24
- [PATCH v2 15/20] qapi: Create 'pragma' module, Kevin Wolf, 2020/02/24
- [PATCH v2 17/20] qmp: Fail gracefully if chardev is already in use, Kevin Wolf, 2020/02/24
- [PATCH v2 18/20] hmp: Fail gracefully if chardev is already in use, Kevin Wolf, 2020/02/24
- [PATCH v2 19/20] monitor: Add allow_hmp parameter to monitor_init(), Kevin Wolf, 2020/02/24
- [PATCH v2 20/20] qemu-storage-daemon: Add --monitor option, Kevin Wolf, 2020/02/24
- Re: [PATCH v2 00/20] Add qemu-storage-daemon, no-reply, 2020/02/24