]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/core/loader: Use qemu_open() instead of open() in get_image_size()
authorVishal Chourasia <vishalc@linux.ibm.com>
Fri, 24 Oct 2025 13:05:53 +0000 (18:35 +0530)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 28 Oct 2025 07:19:18 +0000 (08:19 +0100)
Replace open() with qemu_open() which provides better error handling
via the Error object, automatically sets O_CLOEXEC, and supports FD
passing with /dev/fdset.

Currently pass errp argument as NULL.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
Message-ID: <20251024130556.1942835-4-vishalc@linux.ibm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/core/loader.c

index 477661a0255c9677e0429acc21ccd8aff1155123..c9782d67e86bb5c7e99b9aa5b08ac1bf2fd5cb78 100644 (file)
@@ -74,7 +74,7 @@ int64_t get_image_size(const char *filename)
 {
     int fd;
     int64_t size;
-    fd = open(filename, O_RDONLY | O_BINARY);
+    fd = qemu_open(filename, O_RDONLY | O_BINARY, NULL);
     if (fd < 0)
         return -1;
     size = lseek(fd, 0, SEEK_END);