[PATCH] Added error message for qemu-user fake_open which clears up misleading open() errors which are caused by QEMU interception of open() rather than the linux-user's open()

Brandon Falk posted 1 patch 1 year, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/CAK9+cJVrgAew._5FDjQaEg56ywJAt4bLGgzyZsJqHg3SZVngmq81A@mail.gmail.com
linux-user/syscall.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] Added error message for qemu-user fake_open which clears up misleading open() errors which are caused by QEMU interception of open() rather than the linux-user's open()
Posted by Brandon Falk 1 year, 10 months ago
Add error message for fake open calls when failing to create a temporary
file. I spent some time debugging an issue where for some reason I thought
/proc was misbehaving in the linux-user chroot environment, but it was
rather QEMU silently failing (and passing through an error) to the guest
application, even though it was a QEMU issue related to creating a
temporary file in the chrooted environment.
From 8f35a893176b61cd9de82bf80c60049c05597e7a Mon Sep 17 00:00:00 2001
From: Brandon Falk <bfalk@gamozolabs.com>
Date: Tue, 21 Jun 2022 18:47:24 -0700
Subject: [PATCH] Added error message for qemu-user fake_open which clears up
 misleading open() errors which are caused by QEMU interception of open()
 rather than the linux-user's open()

Signed-off-by: Brandon Falk <bfalk@gamozolabs.com>
---
 linux-user/syscall.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f55cdebee5..acd7b2063e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8263,6 +8263,10 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int
         snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir);
         fd = mkstemp(filename);
         if (fd < 0) {
+            fprintf(stderr,
+                    "qemu-user: Could not create temporary file for "
+                    "fake_open, set $TMPDIR to a valid path or create /tmp. "
+                    "Returning error for open() of %s\n", pathname);
             return fd;
         }
         unlink(filename);
-- 
2.35.1