On 10/30/25 16:12, Kostiantyn Kostiuk wrote:
From: Rodrigo Dias Correa <[email protected]>
On POSIX systems, the QEMU Guest Agent uses /sbin/shutdown to implement
the command guest-shutdown. Systems based on BusyBox, such as Alpine
Linux, don't have /sbin/shutdown. They have instead three separate
commands: poweroff, reboot, and halt.
Change the QEMU Guest Agent to, depending on the mode argument, use
/sbin/{poweroff,halt,reboot} when they exist, falling back to
/sbin/shutdown when they don't.
FWIW, I think sbin/poweroff is universal. But this will do it too.
+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));
+}
stat(2) will never return info about a symlink, so S_ISLINK here is
always 0. It is lstat(2) wihch might return symlink info.
Not that this is a bug, just a confusing expression which will be
copy-pasted by other new users and the confusion will spread ;)
I think I'll send a fix for this, since this patch is landed in
master.
Thanks,
/mjt