[PATCH 2/2] qemu: Return -EINVAL to keep qemuDomainOpenFile() consistent

Kristina Hanicova khanicov at redhat.com
Fri May 21 11:41:30 UTC 2021


The description of the function says that the return value is a
file descriptor on success and negative errno on failure which is
not true. If the 'if' case with check on security labels fails,
the return value is -1 not -errno. The solution is to return
'-EINVAL' instead.

Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
---
 src/qemu/qemu_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 10641846b3..5254552551 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11509,7 +11509,7 @@ qemuDomainOpenFile(virQEMUDriver *driver,
         (seclabel = virDomainDefGetSecurityLabelDef(vm->def, "dac")) != NULL &&
         seclabel->label != NULL &&
         (virParseOwnershipIds(seclabel->label, &user, &group) < 0))
-        return -1;
+        return -EINVAL;
 
     return virQEMUFileOpenAs(user, group, dynamicOwnership,
                              path, oflags, needUnlink);
-- 
2.31.1




More information about the libvir-list mailing list