From: yvinter <yves.vinter(a)bull.net>
---
src/hyperv/hyperv_driver.c | 13 +++++++++++++
src/hyperv/hyperv_wmi.c | 15 +++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index aed9307..372ff39 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -201,6 +201,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned
int flags
VIR_FREE(username);
VIR_FREE(password);
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ virBufferFreeAndReset(&query);
return result;
}
@@ -254,6 +255,7 @@ hypervConnectGetHostname(virConnectPtr conn)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ virBufferFreeAndReset(&query);
return hostname;
}
@@ -352,6 +354,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystem);
hypervFreeObject(priv, (hypervObject *)processorList);
+ virBufferFreeAndReset(&query);
return result;
}
@@ -396,6 +399,7 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+ virBufferFreeAndReset(&query);
return success ? count : -1;
}
@@ -432,6 +436,7 @@ hypervConnectNumOfDomains(virConnectPtr conn)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+ virBufferFreeAndReset(&query);
return success ? count : -1;
}
@@ -464,6 +469,7 @@ hypervDomainLookupByID(virConnectPtr conn, int id)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ virBufferFreeAndReset(&query);
return domain;
}
@@ -500,6 +506,7 @@ hypervDomainLookupByUUID(virConnectPtr conn, const unsigned char
*uuid)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ virBufferFreeAndReset(&query);
return domain;
}
@@ -533,6 +540,7 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystem);
+ virBufferFreeAndReset(&query);
return domain;
}
@@ -748,6 +756,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
hypervFreeObject(priv, (hypervObject *)virtualSystemSettingData);
hypervFreeObject(priv, (hypervObject *)processorSettingData);
hypervFreeObject(priv, (hypervObject *)memorySettingData);
+ virBufferFreeAndReset(&query);
return result;
}
@@ -915,6 +924,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
hypervFreeObject(priv, (hypervObject *)virtualSystemSettingData);
hypervFreeObject(priv, (hypervObject *)processorSettingData);
hypervFreeObject(priv, (hypervObject *)memorySettingData);
+ virBufferFreeAndReset(&query);
return xml;
}
@@ -971,6 +981,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const
names, int maxn
}
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+ virBufferFreeAndReset(&query);
return count;
}
@@ -1007,6 +1018,7 @@ hypervConnectNumOfDefinedDomains(virConnectPtr conn)
cleanup:
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+ virBufferFreeAndReset(&query);
return success ? count : -1;
}
@@ -1346,6 +1358,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
}
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+ virBufferFreeAndReset(&query);
return ret;
}
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index acb705c..d93abd9 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -526,6 +526,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
VIR_FREE(returnValue);
VIR_FREE(instanceID);
hypervFreeObject(priv, (hypervObject *)concreteJob);
+ virBufferFreeAndReset(&query);
return result;
}
@@ -646,13 +647,14 @@ int
hypervMsvmComputerSystemFromDomain(virDomainPtr domain,
Msvm_ComputerSystem **computerSystem)
{
+ int result = -1;
hypervPrivate *priv = domain->conn->privateData;
char uuid_string[VIR_UUID_STRING_BUFLEN];
virBuffer query = VIR_BUFFER_INITIALIZER;
if (computerSystem == NULL || *computerSystem != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
- return -1;
+ goto cleanup;
}
virUUIDFormat(domain->uuid, uuid_string);
@@ -663,16 +665,21 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain,
virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string);
if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) {
- return -1;
+ goto cleanup;
}
if (*computerSystem == NULL) {
virReportError(VIR_ERR_NO_DOMAIN,
_("No domain with UUID %s"), uuid_string);
- return -1;
+ goto cleanup;
}
- return 0;
+ result = 0;
+
+ cleanup:
+ virBufferFreeAndReset(&query);
+
+ return result;
}
--
1.9.1