Browse Source

qemu: add patch for qga guest-shutdown command

Ref: https://github.com/openwrt/packages/issues/14244
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
lilik-openwrt-22.03
Yousong Zhou 4 years ago
parent
commit
33bbeceaa7
2 changed files with 48 additions and 1 deletions
  1. +1
    -1
      utils/qemu/Makefile
  2. +47
    -0
      utils/qemu/patches/0007-qga-invoke-separate-applets-for-guest-shutdown-modes.patch

+ 1
- 1
utils/qemu/Makefile View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=qemu
PKG_VERSION:=5.0.0
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_HASH:=2f13a92a0fa5c8b69ff0796b59b86b080bbb92ebad5d301a7724dd06b5e78cb6
PKG_SOURCE_URL:=http://download.qemu.org/


+ 47
- 0
utils/qemu/patches/0007-qga-invoke-separate-applets-for-guest-shutdown-modes.patch View File

@ -0,0 +1,47 @@
From 80ec6872aceb18c68b1cf5b6f8acd6ad667cbd4f Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Thu, 17 Dec 2020 15:55:55 +0800
Subject: [PATCH] qga: invoke separate applets for guest-shutdown modes
/sbin/shutdown is not available on OpenWrt by default
Origin: "main/qemu: fix shutdown from guest agent"
https://gitlab.alpinelinux.org/alpine/aports/commit/76b81b486480fd9c3294cd420bcf2df01c27790d
---
qga/commands-posix.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index a52af0315f..623d856c64 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -84,6 +84,7 @@ static void ga_wait_child(pid_t pid, int *status, Error **errp)
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
{
const char *shutdown_flag;
+ const char *fallback_cmd = NULL;
Error *local_err = NULL;
pid_t pid;
int status;
@@ -91,10 +92,13 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
slog("guest-shutdown called, mode: %s", mode);
if (!has_mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag = "-P";
+ fallback_cmd = "/sbin/poweroff";
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag = "-H";
+ fallback_cmd = "/sbin/halt";
} else if (strcmp(mode, "reboot") == 0) {
shutdown_flag = "-r";
+ fallback_cmd = "/sbin/reboot";
} else {
error_setg(errp,
"mode is invalid (valid values are: halt|powerdown|reboot");
@@ -111,6 +115,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
"hypervisor initiated shutdown", (char*)NULL, environ);
+ execle(fallback_cmd, fallback_cmd, (char*)NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");

Loading…
Cancel
Save