From bba249a256c1f6924f336f136782f3a4927f3a35 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Sat, 1 Nov 2025 13:30:24 +0300 Subject: [PATCH 1/3] qga: use access(2) to check for command existance instead of questionable stat(2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code checks existance of a command (halt/poweroff/reboot) by using stat(2) and immediately checking for S_ISLNK() on the returned stat struct. This check will never be true, because stat(2) always follows symbolic links and hence will either return ENOENT (in case of dangling symlink) or the properties for the final target file. It is lstat(2) which might return information about the symlink itself. However, even there, we want to check the final file properties, not the first symlink. This check - S_ISLNK - is harmful but useless in this case. However, it is confusing and it helps the wrong usage of stat(2) to spread, so it is better to remove it. Additionally, the code would better to check for the executable bits of the final file, not check if it's a regular file - it's sort of dubious to have anything but regular files in /sbin/. But a POSIX system provides another command which suits the purpose perfectly: it is access(2). And it is so simple that it's not necessary to create a separate function when usin it. Replace stat(2) with access(X_OK) to check for file existance in qga/commands-posix.c Fixes: c5b4afd4d56e "qga: Support guest shutdown of BusyBox-based systems" Reviewed-by: Rodrigo Dias Correa Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Kostiantyn Kostiuk Signed-off-by: Michael Tokarev --- qga/commands-posix.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 66f3e6f673..837be51c40 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -216,12 +216,6 @@ 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" @@ -248,17 +242,17 @@ 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)) { + if (access(POWEROFF_CMD_PATH, X_OK) == 0) { shutdown_cmd = POWEROFF_CMD_PATH; } shutdown_flag = powerdown_flag; } else if (strcmp(mode, "halt") == 0) { - if (file_exists(HALT_CMD_PATH)) { + if (access(HALT_CMD_PATH, X_OK) == 0) { shutdown_cmd = HALT_CMD_PATH; } shutdown_flag = halt_flag; } else if (strcmp(mode, "reboot") == 0) { - if (file_exists(REBOOT_CMD_PATH)) { + if (access(REBOOT_CMD_PATH, X_OK) == 0) { shutdown_cmd = REBOOT_CMD_PATH; } shutdown_flag = reboot_flag; From 5fbcbf76a19a0d3500a4103fc8876c6cace2afcf Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Tue, 21 Oct 2025 07:33:09 +0200 Subject: [PATCH 2/3] qmp: Fix a typo for a USO feature There is a copy & paste error, USO6 should be there. Fixes: 58f81689789f ("qmp: update virtio feature maps, vhost-user-gpio introspection") Signed-off-by: Jack Wang Reviewed-by: Michael Tokarev Signed-off-by: Michael Tokarev --- hw/virtio/virtio-qmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index b338344c6c..968299fda0 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -299,7 +299,7 @@ static const qmp_virtio_feature_map_t virtio_net_feature_map[] = { FEATURE_ENTRY(VIRTIO_NET_F_GUEST_USO4, \ "VIRTIO_NET_F_GUEST_USO4: Driver can receive USOv4"), FEATURE_ENTRY(VIRTIO_NET_F_GUEST_USO6, \ - "VIRTIO_NET_F_GUEST_USO4: Driver can receive USOv6"), + "VIRTIO_NET_F_GUEST_USO6: Driver can receive USOv6"), FEATURE_ENTRY(VIRTIO_NET_F_HOST_USO, \ "VIRTIO_NET_F_HOST_USO: Device can receive USO"), FEATURE_ENTRY(VIRTIO_NET_F_HASH_REPORT, \ From 5f9ac963735598c1efbdce9c4a09f0a64e13d613 Mon Sep 17 00:00:00 2001 From: Yanghang Liu Date: Fri, 21 Nov 2025 17:43:41 +0800 Subject: [PATCH 3/3] Fix the typo of vfio-pci device's enable-migration option Signed-off-by: Yanghang Liu Reported-by: Mario Casquero Reviewed-by: Michael Tokarev Signed-off-by: Michael Tokarev --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8b8bc5a421..b46b1305a7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3871,7 +3871,7 @@ static void vfio_pci_class_init(ObjectClass *klass, const void *data) "(DEBUG)"); object_class_property_set_description(klass, /* 5.2, 8.0 non-experimetal */ "enable-migration", - "Enale device migration. Also requires a host VFIO PCI " + "Enable device migration. Also requires a host VFIO PCI " "variant or mdev driver with migration support enabled"); object_class_property_set_description(klass, /* 8.1 */ "vf-token",