]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Report system error on failed open()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 16 Jul 2025 13:28:08 +0000 (15:28 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Jul 2025 06:27:36 +0000 (08:27 +0200)
With a help from coccinelle three places were identified that
call virReportError() after failed open() (in
qemuDomainWriteMasterKeyFile(), qemuDomainMasterKeyReadFile() and
qemuProcessOpenVhostVsock()). The open() syscall does set errno
on failure so switch them to virReportSystemError() which may
shed more light into the reasons for failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_process.c

index 4420940745948f11d6224dcc14fd0014e2709ca1..963dbd3973e8fa251347c8b59446a30872544212 100644 (file)
@@ -515,8 +515,8 @@ qemuDomainWriteMasterKeyFile(virQEMUDriver *driver,
         return -1;
 
     if ((fd = open(path, O_WRONLY|O_TRUNC|O_CREAT, 0600)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("failed to open domain master key file for write"));
+        virReportSystemError(errno, "%s",
+                             _("failed to open domain master key file for write"));
         return -1;
     }
 
@@ -580,8 +580,8 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivate *priv)
     }
 
     if ((fd = open(path, O_RDONLY)) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("failed to open domain master key file for read"));
+        virReportSystemError(errno, "%s",
+                             _("failed to open domain master key file for read"));
         goto error;
     }
 
index 82cab3f76eec32672c3abf1bed9ce9dc4c096b21..a2872602e879e6748267ca4d9865b8cc103efa6b 100644 (file)
@@ -7137,8 +7137,8 @@ qemuProcessOpenVhostVsock(virDomainVsockDef *vsock)
     int fd;
 
     if ((fd = open(vsock_path, O_RDWR)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       "%s", _("unable to open vhost-vsock device"));
+        virReportSystemError(errno, "%s",
+                             _("unable to open vhost-vsock device"));
         return -1;
     }