[pve-devel] [PATCH kvm 2/2] add -foreground option for our systemd-run workaround

Wolfgang Bumiller w.bumiller at proxmox.com
Tue May 31 16:33:33 CEST 2016


---
 ...oreground-option-to-fix-systemd-run-issue.patch | 90 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 91 insertions(+)
 create mode 100644 debian/patches/pve/0046-add-foreground-option-to-fix-systemd-run-issue.patch

diff --git a/debian/patches/pve/0046-add-foreground-option-to-fix-systemd-run-issue.patch b/debian/patches/pve/0046-add-foreground-option-to-fix-systemd-run-issue.patch
new file mode 100644
index 0000000..ddbcf95
--- /dev/null
+++ b/debian/patches/pve/0046-add-foreground-option-to-fix-systemd-run-issue.patch
@@ -0,0 +1,90 @@
+From fc5e53a35d1ef8b1a90c423c3c3d5002b60d2c9c Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller at proxmox.com>
+Date: Tue, 31 May 2016 15:58:39 +0200
+Subject: [PATCH 9/9] add --foreground option to fix systemd-run issue
+
+---
+ os-posix.c      | 16 +++++++++++++++-
+ qemu-options.hx |  2 ++
+ 2 files changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/os-posix.c b/os-posix.c
+index e4da406..f91c2ef 100644
+--- a/os-posix.c
++++ b/os-posix.c
+@@ -48,6 +48,7 @@
+ static struct passwd *user_pwd;
+ static const char *chroot_dir;
+ static int daemonize;
++static int foreground;
+ static int daemon_pipe;
+ 
+ void os_setup_early_signal_handling(void)
+@@ -156,6 +157,9 @@ void os_parse_cmd_args(int index, const char *optarg)
+     case QEMU_OPTION_daemonize:
+         daemonize = 1;
+         break;
++    case QEMU_OPTION_foreground:
++        foreground = 1;
++        break;
+ #if defined(CONFIG_LINUX)
+     case QEMU_OPTION_enablefips:
+         fips_set_state(true);
+@@ -204,6 +208,9 @@ static void change_root(void)
+ 
+ void os_daemonize(void)
+ {
++    if (foreground) {
++        return;
++    }
+     if (daemonize) {
+         pid_t pid;
+         int fds[2];
+@@ -254,8 +261,13 @@ void os_daemonize(void)
+ 
+ void os_setup_post(void)
+ {
++    uint8_t status = 0;
+     int fd = 0;
+ 
++    if (foreground) {
++        kill(getppid(), SIGUSR2);
++    }
++
+     if (daemonize) {
+         if (chdir("/")) {
+             perror("not able to chdir to /");
+@@ -271,7 +283,6 @@ void os_setup_post(void)
+     change_process_uid();
+ 
+     if (daemonize) {
+-        uint8_t status = 0;
+         ssize_t len;
+ 
+         dup2(fd, 0);
+@@ -280,6 +291,9 @@ void os_setup_post(void)
+ 
+         close(fd);
+ 
++        if (foreground) {
++            return;
++        }
+         do {        
+             len = write(daemon_pipe, &status, 1);
+         } while (len < 0 && errno == EINTR);
+diff --git a/qemu-options.hx b/qemu-options.hx
+index a9ecd76..03a33bc 100644
+--- a/qemu-options.hx
++++ b/qemu-options.hx
+@@ -3119,6 +3119,8 @@ ETEXI
+ #ifndef _WIN32
+ DEF("daemonize", 0, QEMU_OPTION_daemonize, \
+     "-daemonize      daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
++DEF("foreground", 0, QEMU_OPTION_foreground, \
++    "-foreground     stay in foreground even as daemon\n", QEMU_ARCH_ALL)
+ #endif
+ STEXI
+ @item -daemonize
+-- 
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 10e5d46..7559ba9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -43,6 +43,7 @@ pve/0042-vma-writer-don-t-bail-out-on-zero-length-files.patch
 pve/0043-vma-better-driver-guessing-for-bdrv_open.patch
 pve/0044-block-add-zeroinit.patch
 pve/0045-vma-add-format-option-to-device-mapping.patch
+pve/0046-add-foreground-option-to-fix-systemd-run-issue.patch
 extra/0001-vnc-clear-vs-tlscreds-after-unparenting-it.patch
 extra/CVE-2016-2198-ehci-null-pointer.patch
 extra/CVE-2016-2391-usb-ohci-avoid-multiple-eof-timers.patch
-- 
2.1.4





More information about the pve-devel mailing list