Merge tag 'qga-pull-2025-10-30' of https://github.com/kostyanf14/qemu into staging

qga-pull-2025-10-30

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEwsLBCepDxjwUI+uE711egWG6hOcFAmkDYhwACgkQ711egWG6
# hOcMLQ//X/xmrP+PMFbEkPVHCYV0OB5CqvWXw01NOUTRfzMr/xoW+Bws9gC3ok8b
# j1OfsQp48l7e347ZzOYTCaU05lKz7uxgniciwV76tqZM0hPF8ftjRFh4Sia4gGDD
# yqAo9utZ9gE3fW2KEDgjjHtzujj7O0jkV2tqwhjkFr74LH99b422HCgM21GUC03W
# hOLXuNkUVZZVR3JSMweVjSUf+/3NX17lU6EBTdZJ9fF7OF4tpQeLIrgQfI03Tkee
# ZXiVbUbpbRC8LUJhA6sfm0+YCK4x5kRhveSk9nJx5qcARLG0V4RS/DEyZatr2R7/
# KsBR7VSKPWwHhS+MbHako0nMbO76UCZ5Tqx+9i0evHe6KIiMq6O8QhENGtrCwpV0
# wcycFqgtmEyMqoqoHIDAIFrOblo9DzgsxE3QchBOl+EDc/zfKNE4nho+KVT9H2J5
# IjcljLkQUSFcw5pcW+QRsg/HL+rgoSrb8FXuUDZKXeD8jnyM/ISHA8EX0CxJWhUi
# FbkHvhWk7S/SarENr2WnQzuAoPa/eFTd3HKOizZNNkhwyOjox349QwudIEpjdusE
# GCiBrEh3q3fSwgy85KaZH5NYTvgCRa9Ol8CAeIDJxiEb3ywpZJTgnOf21m8Lj5J1
# FITBVpZ+z8fu0PUXScHQ3KZmHh3OoDs++sa7iOqghpDYvJVeUM0=
# =OGKA
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 30 Oct 2025 02:03:24 PM CET
# gpg:                using RSA key C2C2C109EA43C63C1423EB84EF5D5E8161BA84E7
# gpg: Good signature from "Kostiantyn Kostiuk (Upstream PR sign) <kkostiuk@redhat.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: C2C2 C109 EA43 C63C 1423  EB84 EF5D 5E81 61BA 84E7

* tag 'qga-pull-2025-10-30' of https://github.com/kostyanf14/qemu:
  qga: Support guest shutdown of BusyBox-based systems
  qga: Improve Windows filesystem space info retrieval logic
  scripts/qemu-guest-agent/fsfreeze-hook: improve script description

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson
2025-11-01 09:46:17 +01:00
3 changed files with 45 additions and 15 deletions
+29
View File
@@ -213,9 +213,20 @@ out:
return retcode;
}
static bool file_exists(const char *path)
{
struct stat st;
return stat(path, &st) == 0 && (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode));
}
#define POWEROFF_CMD_PATH "/sbin/poweroff"
#define HALT_CMD_PATH "/sbin/halt"
#define REBOOT_CMD_PATH "/sbin/reboot"
void qmp_guest_shutdown(const char *mode, Error **errp)
{
const char *shutdown_flag;
const char *shutdown_cmd = NULL;
Error *local_err = NULL;
#ifdef CONFIG_SOLARIS
@@ -234,10 +245,19 @@ void qmp_guest_shutdown(const char *mode, Error **errp)
slog("guest-shutdown called, mode: %s", mode);
if (!mode || strcmp(mode, "powerdown") == 0) {
if (file_exists(POWEROFF_CMD_PATH)) {
shutdown_cmd = POWEROFF_CMD_PATH;
}
shutdown_flag = powerdown_flag;
} else if (strcmp(mode, "halt") == 0) {
if (file_exists(HALT_CMD_PATH)) {
shutdown_cmd = HALT_CMD_PATH;
}
shutdown_flag = halt_flag;
} else if (strcmp(mode, "reboot") == 0) {
if (file_exists(REBOOT_CMD_PATH)) {
shutdown_cmd = REBOOT_CMD_PATH;
}
shutdown_flag = reboot_flag;
} else {
error_setg(errp,
@@ -255,6 +275,15 @@ void qmp_guest_shutdown(const char *mode, Error **errp)
#endif
"hypervisor initiated shutdown", (char *) NULL};
/*
* If the specific command exists (poweroff, halt or reboot), use it instead
* of /sbin/shutdown.
*/
if (shutdown_cmd != NULL) {
argv[0] = shutdown_cmd;
argv[1] = NULL;
}
ga_run_command(argv, NULL, "shutdown", &local_err);
if (local_err) {
error_propagate(errp, local_err);
+9 -9
View File
@@ -1164,15 +1164,15 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
fs->mountpoint = g_strdup("System Reserved");
} else {
fs->mountpoint = g_strndup(mnt_point, len);
if (GetDiskFreeSpaceEx(fs->mountpoint,
(PULARGE_INTEGER) & i64FreeBytesToCaller,
(PULARGE_INTEGER) & i64TotalBytes,
(PULARGE_INTEGER) & i64FreeBytes)) {
fs->used_bytes = i64TotalBytes - i64FreeBytes;
fs->total_bytes = i64TotalBytes;
fs->has_total_bytes = true;
fs->has_used_bytes = true;
}
}
if (GetDiskFreeSpaceEx(fs->name,
(PULARGE_INTEGER) & i64FreeBytesToCaller,
(PULARGE_INTEGER) & i64TotalBytes,
(PULARGE_INTEGER) & i64FreeBytes)) {
fs->used_bytes = i64TotalBytes - i64FreeBytes;
fs->total_bytes = i64TotalBytes;
fs->has_total_bytes = true;
fs->has_used_bytes = true;
}
wcstombs(fs_name, wfs_name, sizeof(wfs_name));
fs->type = g_strdup(fs_name);
+7 -6
View File
@@ -1,11 +1,12 @@
#!/bin/sh
# This script is executed when a guest agent receives fsfreeze-freeze and
# fsfreeze-thaw command, if it is specified in --fsfreeze-hook (-F)
# option of qemu-ga or placed in default path (/etc/qemu/fsfreeze-hook).
# When the agent receives fsfreeze-freeze request, this script is issued with
# "freeze" argument before the filesystem is frozen. And for fsfreeze-thaw
# request, it is issued with "thaw" argument after filesystem is thawed.
# This script is executed when the guest agent receives fsfreeze-freeze and
# fsfreeze-thaw commands, provided that the --fsfreeze-hook (-F) option of
# qemu-ga is specified and the script is placed in /etc/qemu/fsfreeze-hook or in
# the path specified together with -F. When the agent receives fsfreeze-freeze
# requests, this script is called with "freeze" as its argument before the
# filesystem is frozen. And for fsfreeze-thaw requests, it is called with "thaw"
# as its argument after the filesystem is thawed.
LOGFILE=/var/log/qga-fsfreeze-hook.log
FSFREEZE_D=$(dirname -- "$0")/fsfreeze-hook.d