qemu: fix success return from qemuDomainGetHostnameLease

The current qemuDomainGetHostnameLease() implementation
jumps to the "endjob" label when it finds hostname.
As the label is defined after "ret = 0",
qemuDomainGetHostnameLease() returns -1 in this case.

That works because in qemuDomainGetHostname() it is used like that:

...
       if (qemuDomainGetHostnameLease(vm, &hostname) < 0)
           goto cleanup;

...

   cleanup:
      virDomainObjEndAPI(&vm);
      return hostname;
  }

So it works, but it looks confusing. To make more consistent,
use 'break' in qemuDomainGetHostnameLease() when the hostname
is found, so it returns 0 in this case.

Fixes: a4a5827c9f
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Roman Bogorodskiy
2026-04-14 19:09:06 +02:00
parent 47e9e16100
commit 80fb188790
+3 -1
View File
@@ -16434,6 +16434,8 @@ qemuDomainGetHostnameLease(virDomainObj *vm,
size_t i, j;
int ret = -1;
*hostname = NULL;
if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0)
return -1;
@@ -16471,7 +16473,7 @@ qemuDomainGetHostnameLease(virDomainObj *vm,
VIR_FREE(leases);
if (*hostname)
goto endjob;
break;
}
ret = 0;