[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/29] qemu-storage-daemon: Add main loop
From: |
Kevin Wolf |
Subject: |
[PULL 18/29] qemu-storage-daemon: Add main loop |
Date: |
Fri, 6 Mar 2020 18:14:47 +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>
Message-Id: <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
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 bacbdb55bc..2554e331d5 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
- [PULL 02/29] iotests/026: Test EIO on preallocated zero cluster, (continued)
- [PULL 02/29] iotests/026: Test EIO on preallocated zero cluster, Kevin Wolf, 2020/03/06
- [PULL 05/29] block: Introduce 'bdrv_reopen_commit_post' step, Kevin Wolf, 2020/03/06
- [PULL 08/29] stubs: Add arch_type, Kevin Wolf, 2020/03/06
- [PULL 04/29] block: Fix leak in bdrv_create_file_fallback(), Kevin Wolf, 2020/03/06
- [PULL 07/29] qemu-storage-daemon: Add barebone tool, Kevin Wolf, 2020/03/06
- [PULL 15/29] qemu-storage-daemon: Add --nbd-server option, Kevin Wolf, 2020/03/06
- [PULL 13/29] qapi: Flatten object-add, Kevin Wolf, 2020/03/06
- [PULL 14/29] qemu-storage-daemon: Add --object option, Kevin Wolf, 2020/03/06
- [PULL 06/29] block/qcow2: Move bitmap reopen into bdrv_reopen_commit_post, Kevin Wolf, 2020/03/06
- [PULL 10/29] block: Move common QMP commands to block-core QAPI module, Kevin Wolf, 2020/03/06
- [PULL 18/29] qemu-storage-daemon: Add main loop,
Kevin Wolf <=
- [PULL 17/29] qemu-storage-daemon: Add --export option, Kevin Wolf, 2020/03/06
- [PULL 19/29] qemu-storage-daemon: Add --chardev option, Kevin Wolf, 2020/03/06
- [PULL 16/29] blockdev-nbd: Boxed argument type for nbd-server-add, Kevin Wolf, 2020/03/06
- [PULL 20/29] stubs: Update monitor stubs for qemu-storage-daemon, Kevin Wolf, 2020/03/06
- [PULL 21/29] qapi: Create 'pragma' module, Kevin Wolf, 2020/03/06
- [PULL 23/29] qmp: Fail gracefully if chardev is already in use, Kevin Wolf, 2020/03/06
- [PULL 25/29] monitor: Add allow_hmp parameter to monitor_init(), Kevin Wolf, 2020/03/06
- [PULL 11/29] block: Move sysemu QMP commands to QAPI block module, Kevin Wolf, 2020/03/06
- [PULL 12/29] qemu-storage-daemon: Add --blockdev option, Kevin Wolf, 2020/03/06
- [PULL 22/29] monitor: Create QAPIfied monitor_init(), Kevin Wolf, 2020/03/06