From: Michal Privoznik Date: Wed, 16 Jul 2025 13:28:08 +0000 (+0200) Subject: qemu: Report system error on failed open() X-Git-Tag: v11.6.0-rc1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12d0fc3cf7ff5e4d0778534a0b2b809761de35a6;p=thirdparty%2Flibvirt.git qemu: Report system error on failed open() 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 Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4420940745..963dbd3973 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 82cab3f76e..a2872602e8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -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; }