mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
phyp: Make generic domain listing functions return -1 in case of error
phypNumDomainsGeneric() and phypListDomainsGeneric() return 0 in case of an error. This makes it impossible to distinguish between an actual error and no domains being defined on the hypervisor. It also turn the no domains situation into an error. Return -1 in case of an error to fix this problem.
This commit is contained in:
parent
8d6a1b2c88
commit
4c9afe08e4
@ -980,7 +980,7 @@ phypNumDomainsGeneric(virConnectPtr conn, unsigned int type)
|
||||
err:
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(ret);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1065,7 +1065,7 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
|
||||
err:
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(ret);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1130,7 +1130,7 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
|
||||
VIR_FREE(names[i]);
|
||||
VIR_FREE(cmd);
|
||||
VIR_FREE(ret);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static virDomainPtr
|
||||
@ -1843,17 +1843,34 @@ phypUUIDTable_Init(virConnectPtr conn)
|
||||
int *ids = NULL;
|
||||
unsigned int i = 0;
|
||||
|
||||
if ((nids = phypNumDomainsGeneric(conn, 2)) == 0)
|
||||
if ((nids = phypNumDomainsGeneric(conn, 2)) < 0)
|
||||
goto err;
|
||||
|
||||
/* exit early if there are no domains */
|
||||
if (nids == 0)
|
||||
return 0;
|
||||
|
||||
if (VIR_ALLOC_N(ids, nids) < 0) {
|
||||
virReportOOMError(conn);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (phypListDomainsGeneric(conn, ids, nids, 1) == 0)
|
||||
if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0)
|
||||
goto err;
|
||||
|
||||
/* exit early if there are no domains */
|
||||
/* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric()
|
||||
* returned 0. indicates this an error condition?
|
||||
* an even stricter check would be to treat
|
||||
*
|
||||
* phypNumDomainsGeneric() != phypListDomainsGeneric()
|
||||
*
|
||||
* as an error */
|
||||
if (nids == 0) {
|
||||
VIR_FREE(ids);
|
||||
return 0;
|
||||
}
|
||||
|
||||
phyp_driver = conn->privateData;
|
||||
uuid_table = phyp_driver->uuid_table;
|
||||
uuid_table->nlpars = nids;
|
||||
|
Loading…
x
Reference in New Issue
Block a user