New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qemu-ga: fix working guest-shutdown #44836
Conversation
Version update is a duplicate of #44711. |
--replace '"/sbin/shutdown"' '"/run/current-system/sw/bin/shutdown"' \ | ||
--replace '"/sbin/hwclock"' '"/run/current-system/sw/bin/hwclock"' | ||
''; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain which bug you are trying to fix here and how to reproduce that bug.
Note that /run/current-system/sw/bin
only exists on NixOS systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If runnig command qm agent <vmid> shutdown
(host system Proxmox) an error -
{
"error" : {
"class" : "GenericError",
"desc" : "child process has failed to shutdown"
}
}
strace on on the guest system
socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/dev/log"}, 110) = 0
sendto(5, "<14>Aug 9 23:39:10 qemu-ga: inf"..., 70, MSG_NOSIGNAL, NULL, 0) = 70
clone(strace: Process 734 attached
child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fbc4b79b5d0) = 734
[pid 485] wait4(734, <unfinished ...>
[pid 734] set_robust_list(0x7fbc4b79b5e0, 24) = 0
[pid 734] setsid() = 734
[pid 734] openat(AT_FDCWD, "/dev/null", O_RDWR) = 6
[pid 734] dup2(6, 0) = 0
[pid 734] close(6) = 0
[pid 734] openat(AT_FDCWD, "/dev/null", O_RDWR) = 6
[pid 734] dup2(6, 1) = 1
[pid 734] close(6) = 0
[pid 734] openat(AT_FDCWD, "/dev/null", O_RDWR) = 6
[pid 734] dup2(6, 2) = 2
[pid 734] close(6) = 0
[pid 734] execve("/sbin/shutdown", ["shutdown", "-h", "-P", "+0", "hypervisor initiated shutdown"], 0x7ffeff9da0f8 /* 6 vars */) = -1 ENOENT (No such file or directory)
[pid 734] exit_group(1) = ?
[pid 734] +++ exited with 1 +++
<... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 734
By default running command /sbin/shutdown
- the result is an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a execle("/run/current-system/sw/bin/shutdown, ....);
right after: https://github.com/qemu/qemu/blob/master/qga/commands-posix.c#L106
This would then be executed when /sbin/shutdown
fails.
Updated commit. |
|
||
+ execle("/run/current-system/sw/bin/shutdown", "shutdown", "-h", shutdown_flag, "+0", | ||
+ "hypervisor initiated shutdown", (char*)NULL, environ); | ||
execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes it is running on NixOS, why would this be the case? Packages should also be able to run on other OSes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If error running command /run/current-system/sw/bin/shutdown, it will running /sbin/shutdown
@GrahamcOfBorg test simple |
Success on x86_64-linux (full log) Attempted: tests.simple Partial log (click to expand)
|
Thanks! |
Success on aarch64-linux (full log) Attempted: tests.simple Partial log (click to expand)
|
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)