static void
hypervFreePrivate(hypervPrivate **priv)
{
- if (priv == NULL || *priv == NULL) {
+ if (priv == NULL || *priv == NULL)
return;
- }
if ((*priv)->client != NULL) {
/* FIXME: This leaks memory due to bugs in openwsman <= 2.2.6 */
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
/* Decline if the URI is NULL or the scheme is NULL */
- if (conn->uri == NULL || conn->uri->scheme == NULL) {
+ if (conn->uri == NULL || conn->uri->scheme == NULL)
return VIR_DRV_OPEN_DECLINED;
- }
/* Decline if the scheme is not hyperv */
plus = strchr(conn->uri->scheme, '+');
if (plus == NULL) {
- if (STRCASENEQ(conn->uri->scheme, "hyperv")) {
+ if (STRCASENEQ(conn->uri->scheme, "hyperv"))
return VIR_DRV_OPEN_DECLINED;
- }
} else {
if (plus - conn->uri->scheme != 6 ||
STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) {
if (VIR_ALLOC(priv) < 0)
goto cleanup;
- if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) {
+ if (hypervParseUri(&priv->parsedUri, conn->uri) < 0)
goto cleanup;
- }
/* Set the port dependent on the transport protocol if no port is
* specified. This allows us to rely on the port parameter being
virBufferAddLit(&query, "where ");
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_PHYSICAL);
- if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT);
- if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT);
/* Get Win32_ComputerSystem */
- if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"ResultClass = Win32_Processor",
computerSystem->data->Name);
- if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) {
+ if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0)
goto cleanup;
- }
if (processorList == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
Msvm_ComputerSystem *computerSystem = NULL;
int count = 0;
- if (maxids == 0) {
+ if (maxids == 0)
return 0;
- }
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT);
virBufferAddLit(&query, "where ");
computerSystem = computerSystem->next) {
ids[count++] = computerSystem->data->ProcessID;
- if (count >= maxids) {
+ if (count >= maxids)
break;
- }
}
success = true;
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
virBufferAsprintf(&query, "and ProcessID = %d", id);
- if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string);
- if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_NO_DOMAIN,
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
virBufferAsprintf(&query, "and ElementName = \"%s\"", name);
- if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) {
+ if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem == NULL) {
virReportError(VIR_ERR_NO_DOMAIN,
hypervPrivate *priv = domain->conn->privateData;
Msvm_ComputerSystem *computerSystem = NULL;
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem->data->EnabledState !=
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
hypervPrivate *priv = domain->conn->privateData;
Msvm_ComputerSystem *computerSystem = NULL;
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem->data->EnabledState !=
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) {
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
in_transition) {
virUUIDFormat(domain->uuid, uuid_string);
/* Get Msvm_ComputerSystem */
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
/* Get Msvm_VirtualSystemSettingData */
virBufferAsprintf(&query,
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
*state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem);
- if (reason != NULL) {
+ if (reason != NULL)
*reason = 0;
- }
result = 0;
virUUIDFormat(domain->uuid, uuid_string);
/* Get Msvm_ComputerSystem */
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
/* Get Msvm_VirtualSystemSettingData */
virBufferAsprintf(&query,
int count = 0;
size_t i;
- if (maxnames == 0) {
+ if (maxnames == 0)
return 0;
- }
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT);
virBufferAddLit(&query, "where ");
++count;
- if (count >= maxnames) {
+ if (count >= maxnames)
break;
- }
}
success = true;
cleanup:
if (!success) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
- }
count = -1;
}
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
hypervPrivate *priv = domain->conn->privateData;
Msvm_ComputerSystem *computerSystem = NULL;
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
result = hypervIsMsvmComputerSystemActive(computerSystem, NULL) ? 1 : 0;
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
in_transition) {
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
result = computerSystem->data->EnabledState ==
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0;
virCheckFlags(0, -1);
- if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) {
+ if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
goto cleanup;
- }
if (computerSystem->data->EnabledState !=
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) {
cleanup:
if (doms) {
- for (i = 0; i < count; ++i) {
+ for (i = 0; i < count; ++i)
virDomainFree(doms[i]);
- }
VIR_FREE(doms);
}
response = wsmc_action_enumerate(priv->client, root, options, filter);
- if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0) {
+ if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0)
goto cleanup;
- }
enumContext = wsmc_get_enum_context(response);
response = wsmc_action_pull(priv->client, resourceUri, options,
filter, enumContext);
- if (hyperyVerifyResponse(priv->client, response, "pull") < 0) {
+ if (hyperyVerifyResponse(priv->client, response, "pull") < 0)
goto cleanup;
- }
node = ws_xml_get_soap_body(response);
goto cleanup;
}
- if (ws_xml_get_child(node, 0, resourceUri, className) == NULL) {
+ if (ws_xml_get_child(node, 0, resourceUri, className) == NULL)
break;
- }
data = ws_deserialize(serializerContext, node, serializerInfo,
className, resourceUri, NULL, 0, 0);
result = 0;
cleanup:
- if (options != NULL) {
+ if (options != NULL)
wsmc_options_destroy(options);
- }
- if (filter != NULL) {
+ if (filter != NULL)
filter_destroy(filter);
- }
if (data != NULL) {
#if WS_SERIALIZER_FREE_MEM_WORKS
WsSerializerContextH serializerContext;
#endif
- if (object == NULL) {
+ if (object == NULL)
return;
- }
#if WS_SERIALIZER_FREE_MEM_WORKS
serializerContext = wsmc_get_serialization_context(priv->client);
response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_RESOURCE_URI,
options, "RequestStateChange", NULL);
- if (hyperyVerifyResponse(priv->client, response, "invocation") < 0) {
+ if (hyperyVerifyResponse(priv->client, response, "invocation") < 0)
goto cleanup;
- }
/* Check return value */
returnValue = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:ReturnValue");
virBufferAddLit(&query, MSVM_CONCRETEJOB_WQL_SELECT);
virBufferAsprintf(&query, "where InstanceID = \"%s\"", instanceID);
- if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0) {
+ if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0)
goto cleanup;
- }
if (concreteJob == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
result = 0;
cleanup:
- if (options != NULL) {
+ if (options != NULL)
wsmc_options_destroy(options);
- }
ws_xml_destroy_doc(response);
VIR_FREE(selector);
hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem,
bool *in_transition)
{
- if (in_transition != NULL) {
+ if (in_transition != NULL)
*in_transition = false;
- }
switch (computerSystem->data->EnabledState) {
case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN:
case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_STOPPING:
case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSING:
case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_RESUMING:
- if (in_transition != NULL) {
+ if (in_transition != NULL)
*in_transition = true;
- }
return true;
*domain = virGetDomain(conn, computerSystem->data->ElementName, uuid);
- if (*domain == NULL) {
+ if (*domain == NULL)
return -1;
- }
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) {
(*domain)->id = computerSystem->data->ProcessID;
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string);
- if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) {
+ if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0)
return -1;
- }
if (*computerSystem == NULL) {
virReportError(VIR_ERR_NO_DOMAIN,