mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Replace use of HYPERV_ERROR with virReportError
Update the Hyper-V driver to use virReportError instead of the HYPERV_ERROR custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
cf8cff035c
commit
d9de122052
1
cfg.mk
1
cfg.mk
@ -506,7 +506,6 @@ sc_avoid_attribute_unused_in_header:
|
|||||||
# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
|
# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
|
||||||
|
|
||||||
msg_gen_function =
|
msg_gen_function =
|
||||||
msg_gen_function += HYPERV_ERROR
|
|
||||||
msg_gen_function += PHYP_ERROR
|
msg_gen_function += PHYP_ERROR
|
||||||
msg_gen_function += VIR_ERROR
|
msg_gen_function += VIR_ERROR
|
||||||
msg_gen_function += VMX_ERROR
|
msg_gen_function += VMX_ERROR
|
||||||
|
@ -96,7 +96,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
return VIR_DRV_OPEN_DECLINED;
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
HYPERV_ERROR(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("Transport '%s' in URI scheme is not supported, try again "
|
_("Transport '%s' in URI scheme is not supported, try again "
|
||||||
"without the transport part"), plus + 1);
|
"without the transport part"), plus + 1);
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
@ -104,14 +104,14 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
|
|
||||||
/* Require server part */
|
/* Require server part */
|
||||||
if (conn->uri->server == NULL) {
|
if (conn->uri->server == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("URI is missing the server part"));
|
_("URI is missing the server part"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Require auth */
|
/* Require auth */
|
||||||
if (auth == NULL || auth->cb == NULL) {
|
if (auth == NULL || auth->cb == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("Missing or invalid auth pointer"));
|
_("Missing or invalid auth pointer"));
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
username = virAuthGetUsername(conn, auth, "hyperv", "administrator", conn->uri->server);
|
username = virAuthGetUsername(conn, auth, "hyperv", "administrator", conn->uri->server);
|
||||||
|
|
||||||
if (username == NULL) {
|
if (username == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
|
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
password = virAuthGetPassword(conn, auth, "hyperv", username, conn->uri->server);
|
password = virAuthGetPassword(conn, auth, "hyperv", username, conn->uri->server);
|
||||||
|
|
||||||
if (password == NULL) {
|
if (password == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
|
virReportError(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +167,13 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
priv->parsedUri->transport, username, password);
|
priv->parsedUri->transport, username, password);
|
||||||
|
|
||||||
if (priv->client == NULL) {
|
if (priv->client == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not create openwsman client"));
|
_("Could not create openwsman client"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wsmc_transport_init(priv->client, NULL) != 0) {
|
if (wsmc_transport_init(priv->client, NULL) != 0) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not initialize openwsman transport"));
|
_("Could not initialize openwsman transport"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ hypervOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("%s is not a Hyper-V server"), conn->uri->server);
|
_("%s is not a Hyper-V server"), conn->uri->server);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -254,7 +254,7 @@ hypervGetHostname(virConnectPtr conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s"),
|
_("Could not lookup %s"),
|
||||||
"Win32_ComputerSystem");
|
"Win32_ComputerSystem");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -296,7 +296,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s"),
|
_("Could not lookup %s"),
|
||||||
"Win32_ComputerSystem");
|
"Win32_ComputerSystem");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -315,7 +315,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processorList == NULL) {
|
if (processorList == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s"),
|
_("Could not lookup %s"),
|
||||||
"Win32_Processor");
|
"Win32_Processor");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -342,7 +342,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
|
|||||||
/* Fill struct */
|
/* Fill struct */
|
||||||
if (virStrncpy(info->model, processorList->data->Name,
|
if (virStrncpy(info->model, processorList->data->Name,
|
||||||
sizeof(info->model) - 1, sizeof(info->model)) == NULL) {
|
sizeof(info->model) - 1, sizeof(info->model)) == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("CPU model %s too long for destination"),
|
_("CPU model %s too long for destination"),
|
||||||
processorList->data->Name);
|
processorList->data->Name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -471,7 +471,7 @@ hypervDomainLookupByID(virConnectPtr conn, int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
|
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ hypervDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
_("No domain with UUID %s"), uuid_string);
|
_("No domain with UUID %s"), uuid_string);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -539,7 +539,7 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computerSystem == NULL) {
|
if (computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
_("No domain with name %s"), name);
|
_("No domain with name %s"), name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ hypervDomainSuspend(virDomainPtr domain)
|
|||||||
|
|
||||||
if (computerSystem->data->EnabledState !=
|
if (computerSystem->data->EnabledState !=
|
||||||
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not active"));
|
_("Domain is not active"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -596,7 +596,7 @@ hypervDomainResume(virDomainPtr domain)
|
|||||||
|
|
||||||
if (computerSystem->data->EnabledState !=
|
if (computerSystem->data->EnabledState !=
|
||||||
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) {
|
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not paused"));
|
_("Domain is not paused"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -628,7 +628,7 @@ hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
|
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
|
||||||
in_transition) {
|
in_transition) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not active or is in state transition"));
|
_("Domain is not active or is in state transition"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virtualSystemSettingData == NULL) {
|
if (virtualSystemSettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_VirtualSystemSettingData",
|
"Msvm_VirtualSystemSettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -724,7 +724,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processorSettingData == NULL) {
|
if (processorSettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_ProcessorSettingData",
|
"Msvm_ProcessorSettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -746,7 +746,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
|
|||||||
|
|
||||||
|
|
||||||
if (memorySettingData == NULL) {
|
if (memorySettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_MemorySettingData",
|
"Msvm_MemorySettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -845,7 +845,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virtualSystemSettingData == NULL) {
|
if (virtualSystemSettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_VirtualSystemSettingData",
|
"Msvm_VirtualSystemSettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -866,7 +866,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (processorSettingData == NULL) {
|
if (processorSettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_ProcessorSettingData",
|
"Msvm_ProcessorSettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -888,7 +888,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
|
|
||||||
if (memorySettingData == NULL) {
|
if (memorySettingData == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for domain %s"),
|
_("Could not lookup %s for domain %s"),
|
||||||
"Msvm_MemorySettingData",
|
"Msvm_MemorySettingData",
|
||||||
computerSystem->data->ElementName);
|
computerSystem->data->ElementName);
|
||||||
@ -905,7 +905,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virUUIDParse(computerSystem->data->Name, def->uuid) < 0) {
|
if (virUUIDParse(computerSystem->data->Name, def->uuid) < 0) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse UUID from string '%s'"),
|
_("Could not parse UUID from string '%s'"),
|
||||||
computerSystem->data->Name);
|
computerSystem->data->Name);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1066,7 +1066,7 @@ hypervDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) {
|
if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is already active or is in state transition"));
|
_("Domain is already active or is in state transition"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1189,7 +1189,7 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
|
if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
|
||||||
in_transition) {
|
in_transition) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain is not active or is in state transition"));
|
_("Domain is not active or is in state transition"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1244,7 +1244,7 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
|
|||||||
|
|
||||||
if (computerSystem->data->EnabledState !=
|
if (computerSystem->data->EnabledState !=
|
||||||
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) {
|
MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) {
|
||||||
HYPERV_ERROR(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("Domain has no managed save image"));
|
_("Domain has no managed save image"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
# include "hyperv_util.h"
|
# include "hyperv_util.h"
|
||||||
# include "openwsman.h"
|
# include "openwsman.h"
|
||||||
|
|
||||||
# define HYPERV_ERROR(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_HYPERV, code, __FILE__, __FUNCTION__, \
|
|
||||||
__LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
typedef struct _hypervPrivate hypervPrivate;
|
typedef struct _hypervPrivate hypervPrivate;
|
||||||
|
|
||||||
struct _hypervPrivate {
|
struct _hypervPrivate {
|
||||||
|
@ -42,7 +42,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (parsedUri == NULL || *parsedUri != NULL) {
|
if (parsedUri == NULL || *parsedUri != NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
|
|||||||
|
|
||||||
if (STRNEQ((*parsedUri)->transport, "http") &&
|
if (STRNEQ((*parsedUri)->transport, "http") &&
|
||||||
STRNEQ((*parsedUri)->transport, "https")) {
|
STRNEQ((*parsedUri)->transport, "https")) {
|
||||||
HYPERV_ERROR(VIR_ERR_INVALID_ARG,
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("Query parameter 'transport' has unexpected value "
|
_("Query parameter 'transport' has unexpected value "
|
||||||
"'%s' (should be http|https)"),
|
"'%s' (should be http|https)"),
|
||||||
(*parsedUri)->transport);
|
(*parsedUri)->transport);
|
||||||
|
@ -56,7 +56,7 @@ hyperyVerifyResponse(WsManClient *client, WsXmlDocH response,
|
|||||||
WsManFault *fault;
|
WsManFault *fault;
|
||||||
|
|
||||||
if (lastError != WS_LASTERR_OK) {
|
if (lastError != WS_LASTERR_OK) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Transport error during %s: %s (%d)"),
|
_("Transport error during %s: %s (%d)"),
|
||||||
detail, wsman_transport_get_last_error_string(lastError),
|
detail, wsman_transport_get_last_error_string(lastError),
|
||||||
lastError);
|
lastError);
|
||||||
@ -66,14 +66,14 @@ hyperyVerifyResponse(WsManClient *client, WsXmlDocH response,
|
|||||||
/* Check the HTTP response code and report an error if it's not 200 (OK),
|
/* Check the HTTP response code and report an error if it's not 200 (OK),
|
||||||
* 400 (Bad Request) or 500 (Internal Server Error) */
|
* 400 (Bad Request) or 500 (Internal Server Error) */
|
||||||
if (responseCode != 200 && responseCode != 400 && responseCode != 500) {
|
if (responseCode != 200 && responseCode != 400 && responseCode != 500) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unexpected HTTP response during %s: %d"),
|
_("Unexpected HTTP response during %s: %d"),
|
||||||
detail, responseCode);
|
detail, responseCode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == NULL) {
|
if (response == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Empty response during %s"), detail);
|
_("Empty response during %s"), detail);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ hyperyVerifyResponse(WsManClient *client, WsXmlDocH response,
|
|||||||
|
|
||||||
wsmc_get_fault_data(response, fault);
|
wsmc_get_fault_data(response, fault);
|
||||||
|
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("SOAP fault during %s: code '%s', subcode '%s', "
|
_("SOAP fault during %s: code '%s', subcode '%s', "
|
||||||
"reason '%s', detail '%s'"),
|
"reason '%s', detail '%s'"),
|
||||||
detail, NULLSTR(fault->code), NULLSTR(fault->subcode),
|
detail, NULLSTR(fault->code), NULLSTR(fault->subcode),
|
||||||
@ -126,7 +126,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
hypervObject *object;
|
hypervObject *object;
|
||||||
|
|
||||||
if (list == NULL || *list != NULL) {
|
if (list == NULL || *list != NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
options = wsmc_options_init();
|
options = wsmc_options_init();
|
||||||
|
|
||||||
if (options == NULL) {
|
if (options == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not initialize options"));
|
_("Could not initialize options"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
filter = filter_create_simple(WSM_WQL_FILTER_DIALECT, query_string);
|
filter = filter_create_simple(WSM_WQL_FILTER_DIALECT, query_string);
|
||||||
|
|
||||||
if (filter == NULL) {
|
if (filter == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not create filter"));
|
_("Could not create filter"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
node = ws_xml_get_soap_body(response);
|
node = ws_xml_get_soap_body(response);
|
||||||
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not lookup SOAP body"));
|
_("Could not lookup SOAP body"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP);
|
node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_PULL_RESP);
|
||||||
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not lookup pull response"));
|
_("Could not lookup pull response"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_ITEMS);
|
node = ws_xml_get_child(node, 0, XML_NS_ENUMERATION, WSENUM_ITEMS);
|
||||||
|
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not lookup pull response items"));
|
_("Could not lookup pull response items"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
|
|||||||
className, resourceUri, NULL, 0, 0);
|
className, resourceUri, NULL, 0, 0);
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not deserialize pull response item"));
|
_("Could not deserialize pull response item"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -422,7 +422,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
|
|||||||
options = wsmc_options_init();
|
options = wsmc_options_init();
|
||||||
|
|
||||||
if (options == NULL) {
|
if (options == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not initialize options"));
|
_("Could not initialize options"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -442,14 +442,14 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
|
|||||||
returnValue = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:ReturnValue");
|
returnValue = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:ReturnValue");
|
||||||
|
|
||||||
if (returnValue == NULL) {
|
if (returnValue == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for %s invocation"),
|
_("Could not lookup %s for %s invocation"),
|
||||||
"ReturnValue", "RequestStateChange");
|
"ReturnValue", "RequestStateChange");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStrToLong_i(returnValue, NULL, 10, &returnCode) < 0) {
|
if (virStrToLong_i(returnValue, NULL, 10, &returnCode) < 0) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse return code from '%s'"), returnValue);
|
_("Could not parse return code from '%s'"), returnValue);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -459,7 +459,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
|
|||||||
instanceID = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:Job/a:ReferenceParameters/w:SelectorSet/w:Selector[@Name='InstanceID']");
|
instanceID = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:Job/a:ReferenceParameters/w:SelectorSet/w:Selector[@Name='InstanceID']");
|
||||||
|
|
||||||
if (instanceID == NULL) {
|
if (instanceID == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for %s invocation"),
|
_("Could not lookup %s for %s invocation"),
|
||||||
"InstanceID", "RequestStateChange");
|
"InstanceID", "RequestStateChange");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -476,7 +476,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (concreteJob == NULL) {
|
if (concreteJob == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not lookup %s for %s invocation"),
|
_("Could not lookup %s for %s invocation"),
|
||||||
"Msvm_ConcreteJob", "RequestStateChange");
|
"Msvm_ConcreteJob", "RequestStateChange");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -501,20 +501,20 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
|
|||||||
case MSVM_CONCRETEJOB_JOBSTATE_KILLED:
|
case MSVM_CONCRETEJOB_JOBSTATE_KILLED:
|
||||||
case MSVM_CONCRETEJOB_JOBSTATE_EXCEPTION:
|
case MSVM_CONCRETEJOB_JOBSTATE_EXCEPTION:
|
||||||
case MSVM_CONCRETEJOB_JOBSTATE_SERVICE:
|
case MSVM_CONCRETEJOB_JOBSTATE_SERVICE:
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Concrete job for %s invocation is in error state"),
|
_("Concrete job for %s invocation is in error state"),
|
||||||
"RequestStateChange");
|
"RequestStateChange");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Concrete job for %s invocation is in unknown state"),
|
_("Concrete job for %s invocation is in unknown state"),
|
||||||
"RequestStateChange");
|
"RequestStateChange");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (returnCode != CIM_RETURNCODE_COMPLETED_WITH_NO_ERROR) {
|
} else if (returnCode != CIM_RETURNCODE_COMPLETED_WITH_NO_ERROR) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invocation of %s returned an error: %s (%d)"),
|
_("Invocation of %s returned an error: %s (%d)"),
|
||||||
"RequestStateChange", hypervReturnCodeToString(returnCode),
|
"RequestStateChange", hypervReturnCodeToString(returnCode),
|
||||||
returnCode);
|
returnCode);
|
||||||
@ -624,12 +624,12 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn,
|
|||||||
unsigned char uuid[VIR_UUID_BUFLEN];
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
||||||
|
|
||||||
if (domain == NULL || *domain != NULL) {
|
if (domain == NULL || *domain != NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virUUIDParse(computerSystem->data->Name, uuid) < 0) {
|
if (virUUIDParse(computerSystem->data->Name, uuid) < 0) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not parse UUID from string '%s'"),
|
_("Could not parse UUID from string '%s'"),
|
||||||
computerSystem->data->Name);
|
computerSystem->data->Name);
|
||||||
return -1;
|
return -1;
|
||||||
@ -659,7 +659,7 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain,
|
|||||||
virBuffer query = VIR_BUFFER_INITIALIZER;
|
virBuffer query = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (computerSystem == NULL || *computerSystem != NULL) {
|
if (computerSystem == NULL || *computerSystem != NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*computerSystem == NULL) {
|
if (*computerSystem == NULL) {
|
||||||
HYPERV_ERROR(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
_("No domain with UUID %s"), uuid_string);
|
_("No domain with UUID %s"), uuid_string);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user