mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-31 14:07:16 +00:00
hyperv: Fix and improve hypervListAllDomains
Use MATCH for all flags checks. hypervMsvmComputerSystemToDomain expects the domain pointer to the initialized to NULL. All items in doms up to the count-th one are valid, no need to double check before freeing them.
This commit is contained in:
parent
5fc663d8be
commit
9e9ea3ead9
@ -1302,13 +1302,14 @@ hypervListAllDomains(virConnectPtr conn,
|
|||||||
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
|
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
|
||||||
|
|
||||||
/* construct query with filter depending on flags */
|
/* construct query with filter depending on flags */
|
||||||
if (!(flags & VIR_CONNECT_LIST_DOMAINS_ACTIVE &&
|
if (!(MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE) &&
|
||||||
flags & VIR_CONNECT_LIST_DOMAINS_INACTIVE)) {
|
MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE))) {
|
||||||
if (flags & VIR_CONNECT_LIST_DOMAINS_ACTIVE) {
|
if (MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE)) {
|
||||||
virBufferAddLit(&query, "and ");
|
virBufferAddLit(&query, "and ");
|
||||||
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_ACTIVE);
|
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_ACTIVE);
|
||||||
}
|
}
|
||||||
if (flags & VIR_CONNECT_LIST_DOMAINS_INACTIVE) {
|
|
||||||
|
if (MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE)) {
|
||||||
virBufferAddLit(&query, "and ");
|
virBufferAddLit(&query, "and ");
|
||||||
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_INACTIVE);
|
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_INACTIVE);
|
||||||
}
|
}
|
||||||
@ -1358,14 +1359,16 @@ hypervListAllDomains(virConnectPtr conn,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
|
if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
|
domain = NULL;
|
||||||
|
|
||||||
if (hypervMsvmComputerSystemToDomain(conn, computerSystem,
|
if (hypervMsvmComputerSystemToDomain(conn, computerSystem,
|
||||||
&domain) < 0)
|
&domain) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
doms[count++] = domain;
|
doms[count++] = domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doms)
|
if (doms)
|
||||||
@ -1376,13 +1379,14 @@ hypervListAllDomains(virConnectPtr conn,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (doms) {
|
if (doms) {
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
if (doms[i])
|
virDomainFree(doms[i]);
|
||||||
virDomainFree(doms[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VIR_FREE(doms);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(doms);
|
|
||||||
hypervFreeObject(priv, (hypervObject *)computerSystemList);
|
hypervFreeObject(priv, (hypervObject *)computerSystemList);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
no_memory:
|
no_memory:
|
||||||
|
Loading…
Reference in New Issue
Block a user