]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
os-posix: Add os_set_daemonize()
authorHanna Reitz <hreitz@redhat.com>
Thu, 3 Mar 2022 16:48:11 +0000 (17:48 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 4 Mar 2022 17:14:40 +0000 (18:14 +0100)
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
include/sysemu/os-win32.h
os-posix.c

index 2edf33658a44f9093a5f02d19b44e4c80e546644..dd64fb401dfb8b7ffcaf6013ef3316a74b4d3c0d 100644 (file)
@@ -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);
 
 /**
index 43f569b5c216c7d643a92d32dc98aceda0f5ab59..770752222ae39f7ec205a4f877a581f37a32daa3 100644 (file)
@@ -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;
index ae6c9f2a5e983772745067ea9db74ac44b93f9ac..24692c8593f31e5c650a85837b6dd0073cee5862 100644 (file)
@@ -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