Commit 578988e684 for qemu.org
commit 578988e68458ebb77f4263dca12100f8803ed30c
Author: Markus Armbruster <armbru@redhat.com>
Date: Fri Nov 21 13:14:28 2025 +0100
qga: Use error_setg_file_open() for better error messages
Error messages change from
open("FNAME"): REASON
to
Could not open 'FNAME': REASON
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Message-ID: <20251121121438.1249498-6-armbru@redhat.com>
diff --git a/qga/commands-linux.c b/qga/commands-linux.c
index c639a60a94..ae2c4d442a 100644
--- a/qga/commands-linux.c
+++ b/qga/commands-linux.c
@@ -1503,14 +1503,15 @@ static void transfer_vcpu(GuestLogicalProcessor *vcpu, bool sys2vcpu,
dirfd = open(dirpath, O_RDONLY | O_DIRECTORY);
if (dirfd == -1) {
- error_setg_errno(errp, errno, "open(\"%s\")", dirpath);
+ error_setg_file_open(errp, errno, dirpath);
return;
}
fd = openat(dirfd, fn, sys2vcpu ? O_RDONLY : O_RDWR);
if (fd == -1) {
if (errno != ENOENT) {
- error_setg_errno(errp, errno, "open(\"%s/%s\")", dirpath, fn);
+ error_setg_errno(errp, errno, "could not open %s/%s",
+ dirpath, fn);
} else if (sys2vcpu) {
vcpu->online = true;
vcpu->can_offline = false;
@@ -1712,7 +1713,7 @@ static void transfer_memory_block(GuestMemoryBlock *mem_blk, bool sys2memblk,
dirfd = open(dirpath, O_RDONLY | O_DIRECTORY);
if (dirfd == -1) {
if (sys2memblk) {
- error_setg_errno(errp, errno, "open(\"%s\")", dirpath);
+ error_setg_file_open(errp, errno, dirpath);
} else {
if (errno == ENOENT) {
result->response = GUEST_MEMORY_BLOCK_RESPONSE_TYPE_NOT_FOUND;
@@ -1937,7 +1938,7 @@ static GuestDiskStatsInfoList *guest_get_diskstats(Error **errp)
fp = fopen(diskstats, "r");
if (fp == NULL) {
- error_setg_errno(errp, errno, "open(\"%s\")", diskstats);
+ error_setg_file_open(errp, errno, diskstats);
return NULL;
}
@@ -2048,7 +2049,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp)
fp = fopen(cpustats, "r");
if (fp == NULL) {
- error_setg_errno(errp, errno, "open(\"%s\")", cpustats);
+ error_setg_file_open(errp, errno, cpustats);
return NULL;
}