nixpkgs/pkgs/applications/virtualization/qemu/fix-qemu-ga.patch
Alyssa Ross 8ce7f9f78b qemu: 9.0.2 -> 9.1.0
The macOS deployment target has been set to 12.0, and the collection
of patches and reverts to keep older macOS versions working has been
dropped, as maintaining what is effectively a fork of QEMU solely for
the sake of versions no longer supported by Apple has become untenable.
It may or may not still work on older macOS versions, potentially with
reduced functionality. Upstream only officially supports the latest
two versions of macOS, so this is still extending support further back
than QEMU will support. To continue supporting back to macOS 10.12,
at least the following upstream commits would have to be reverted,
and possibly more:

* <2d27c91e2b>
* <e9c9d8dc3b>
* <7b60b971cc>

However, if you want to do that, you should be prepared to take up the
burden of maintaining the monotonically‐increasing set of patches
that will be required to keep this working in future.

Fixes: CVE-2024-7409
Co-authored-by: Emily <vcs@emily.moe>
2024-09-05 16:38:43 +02:00

46 lines
1.7 KiB
Diff

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index c2bd0b4316..47cee1c351 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -246,7 +246,7 @@ void qmp_guest_shutdown(const char *mode, Error **errp)
return;
}
- const char *argv[] = {"/sbin/shutdown",
+ const char *argv[] = {"/run/current-system/sw/bin/shutdown",
#ifdef CONFIG_SOLARIS
shutdown_flag, "-g0", "-y",
#elif defined(CONFIG_BSD)
@@ -257,6 +257,10 @@ void qmp_guest_shutdown(const char *mode, Error **errp)
"hypervisor initiated shutdown", (char *) NULL};
ga_run_command(argv, NULL, "shutdown", &local_err);
+ if (local_err) {
+ argv[0] = "/sbin/shutdown";
+ ga_run_command(argv, NULL, "shutdown", &local_err);
+ }
if (local_err) {
error_propagate(errp, local_err);
return;
@@ -270,7 +274,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
int ret;
Error *local_err = NULL;
struct timeval tv;
- const char *argv[] = {"/sbin/hwclock", has_time ? "-w" : "-s", NULL};
+ const char *argv[] = {"/run/current-system/sw/bin/hwclock", has_time ? "-w" : "-s", NULL};
/* If user has passed a time, validate and set it. */
if (has_time) {
@@ -303,6 +307,11 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
* hardware clock (RTC). */
ga_run_command(argv, NULL, "set hardware clock to system time",
&local_err);
+ if (local_err) {
+ argv[0] = "/sbin/hwclock";
+ ga_run_command(argv, NULL, "set hardware clock to system time",
+ &local_err);
+ }
if (local_err) {
error_propagate(errp, local_err);
return;