[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/50] os-posix: Add os_set_daemonize()
From: |
Kevin Wolf |
Subject: |
[PULL 10/50] os-posix: Add os_set_daemonize() |
Date: |
Fri, 4 Mar 2022 17:46:31 +0100 |
From: Hanna Reitz <hreitz@redhat.com>
The daemonizing functions in os-posix (os_daemonize() and
os_setup_post()) only daemonize the process if the static `daemonize`
variable is set. Right now, it can only be set by os_parse_cmd_args().
In order to use os_daemonize() and os_setup_post() from the storage
daemon to have it be daemonized, we need some other way to set this
`daemonize` variable, because I would rather not tap into the system
emulator's arg-parsing code. Therefore, this patch adds an
os_set_daemonize() function, which will return an error on os-win32
(because daemonizing is not supported there).
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220303164814.284974-2-hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/sysemu/os-posix.h | 1 +
include/sysemu/os-win32.h | 8 ++++++++
os-posix.c | 6 ++++++
3 files changed, 15 insertions(+)
diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h
index 2edf33658a..dd64fb401d 100644
--- a/include/sysemu/os-posix.h
+++ b/include/sysemu/os-posix.h
@@ -55,6 +55,7 @@ int os_mlock(void);
typedef struct timeval qemu_timeval;
#define qemu_gettimeofday(tp) gettimeofday(tp, NULL)
+int os_set_daemonize(bool d);
bool is_daemonized(void);
/**
diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index 43f569b5c2..770752222a 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -77,6 +77,14 @@ typedef struct {
} qemu_timeval;
int qemu_gettimeofday(qemu_timeval *tp);
+static inline int os_set_daemonize(bool d)
+{
+ if (d) {
+ return -ENOTSUP;
+ }
+ return 0;
+}
+
static inline bool is_daemonized(void)
{
return false;
diff --git a/os-posix.c b/os-posix.c
index ae6c9f2a5e..24692c8593 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -317,6 +317,12 @@ bool is_daemonized(void)
return daemonize;
}
+int os_set_daemonize(bool d)
+{
+ daemonize = d;
+ return 0;
+}
+
int os_mlock(void)
{
#ifdef HAVE_MLOCKALL
--
2.35.1
- [PULL 00/50] Block layer patches, Kevin Wolf, 2022/03/04
- [PULL 01/50] crypto: perform permission checks under BQL, Kevin Wolf, 2022/03/04
- [PULL 04/50] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache, Kevin Wolf, 2022/03/04
- [PULL 05/50] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate, Kevin Wolf, 2022/03/04
- [PULL 06/50] tls: add macros for coroutine-safe TLS variables, Kevin Wolf, 2022/03/04
- [PULL 08/50] rcu: use coroutine TLS macros, Kevin Wolf, 2022/03/04
- [PULL 09/50] cpus: use coroutine TLS macros for iothread_locked, Kevin Wolf, 2022/03/04
- [PULL 10/50] os-posix: Add os_set_daemonize(),
Kevin Wolf <=
- [PULL 12/50] qsd: Add --daemonize, Kevin Wolf, 2022/03/04
- [PULL 11/50] qsd: Add pre-init argument parsing pass, Kevin Wolf, 2022/03/04
- [PULL 07/50] util/async: replace __thread with QEMU TLS macros, Kevin Wolf, 2022/03/04
- [PULL 16/50] include/block/block: split header into I/O and global state API, Kevin Wolf, 2022/03/04
- [PULL 13/50] iotests/185: Add post-READY quit tests, Kevin Wolf, 2022/03/04
- [PULL 14/50] main-loop.h: introduce qemu_in_main_thread(), Kevin Wolf, 2022/03/04
- [PULL 15/50] main loop: macros to mark GS and I/O functions, Kevin Wolf, 2022/03/04
- [PULL 03/50] block: introduce bdrv_activate, Kevin Wolf, 2022/03/04
- [PULL 17/50] assertions for block global state API, Kevin Wolf, 2022/03/04
- [PULL 02/50] crypto: distinguish between main loop and I/O in block_crypto_amend_options_generic_luks, Kevin Wolf, 2022/03/04