mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
hyperv: avoid overwriting errors from hypervGetWmiClass()
Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5140f97bcc
commit
26f5609e70
@ -73,8 +73,10 @@ hypervGetProcessorsByName(hypervPrivate *priv, const char *name,
|
|||||||
"ResultClass = Win32_Processor",
|
"ResultClass = Win32_Processor",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Win32_Processor, processorList) < 0 ||
|
if (hypervGetWmiClass(Win32_Processor, processorList) < 0)
|
||||||
!processorList) {
|
return -1;
|
||||||
|
|
||||||
|
if (!processorList) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not look up processor(s) on '%s'"),
|
_("Could not look up processor(s) on '%s'"),
|
||||||
name);
|
name);
|
||||||
@ -92,8 +94,10 @@ hypervGetActiveVirtualSystemList(hypervPrivate *priv,
|
|||||||
"WHERE " MSVM_COMPUTERSYSTEM_WQL_VIRTUAL
|
"WHERE " MSVM_COMPUTERSYSTEM_WQL_VIRTUAL
|
||||||
"AND " MSVM_COMPUTERSYSTEM_WQL_ACTIVE), 0 };
|
"AND " MSVM_COMPUTERSYSTEM_WQL_ACTIVE), 0 };
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0 ||
|
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0)
|
||||||
!*computerSystemList) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*computerSystemList) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not look up active virtual machines"));
|
_("Could not look up active virtual machines"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -111,8 +115,10 @@ hypervGetInactiveVirtualSystemList(hypervPrivate *priv,
|
|||||||
"WHERE " MSVM_COMPUTERSYSTEM_WQL_VIRTUAL
|
"WHERE " MSVM_COMPUTERSYSTEM_WQL_VIRTUAL
|
||||||
"AND " MSVM_COMPUTERSYSTEM_WQL_INACTIVE), 0 };
|
"AND " MSVM_COMPUTERSYSTEM_WQL_INACTIVE), 0 };
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0 ||
|
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0)
|
||||||
!*computerSystemList) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*computerSystemList) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not look up inactive virtual machines"));
|
_("Could not look up inactive virtual machines"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -127,8 +133,10 @@ hypervGetPhysicalSystemList(hypervPrivate *priv,
|
|||||||
{
|
{
|
||||||
g_auto(virBuffer) query = { g_string_new(WIN32_COMPUTERSYSTEM_WQL_SELECT), 0 };
|
g_auto(virBuffer) query = { g_string_new(WIN32_COMPUTERSYSTEM_WQL_SELECT), 0 };
|
||||||
|
|
||||||
if (hypervGetWmiClass(Win32_ComputerSystem, computerSystemList) < 0 ||
|
if (hypervGetWmiClass(Win32_ComputerSystem, computerSystemList) < 0)
|
||||||
!*computerSystemList) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*computerSystemList) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not look up Win32_ComputerSystem"));
|
_("Could not look up Win32_ComputerSystem"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -148,11 +156,8 @@ hypervGetVirtualSystemByID(hypervPrivate *priv, int id,
|
|||||||
"AND ProcessID = %d",
|
"AND ProcessID = %d",
|
||||||
id);
|
id);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0) {
|
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("Could not look up virtual system with ID %d"), id);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (*computerSystemList == NULL) {
|
if (*computerSystemList == NULL) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
|
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id);
|
||||||
@ -173,12 +178,8 @@ hypervGetVirtualSystemByUUID(hypervPrivate *priv, const char *uuid,
|
|||||||
"AND Name = \"%s\"",
|
"AND Name = \"%s\"",
|
||||||
uuid);
|
uuid);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0) {
|
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("Could not look up virtual system with UUID '%s'"),
|
|
||||||
uuid);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (*computerSystemList == NULL) {
|
if (*computerSystemList == NULL) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
@ -201,11 +202,8 @@ hypervGetVirtualSystemByName(hypervPrivate *priv, const char *name,
|
|||||||
"AND ElementName = \"%s\"",
|
"AND ElementName = \"%s\"",
|
||||||
name);
|
name);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0) {
|
if (hypervGetWmiClass(Msvm_ComputerSystem, computerSystemList) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
_("Could not look up virtual system named '%s'"), name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (*computerSystemList == NULL) {
|
if (*computerSystemList == NULL) {
|
||||||
virReportError(VIR_ERR_NO_DOMAIN,
|
virReportError(VIR_ERR_NO_DOMAIN,
|
||||||
@ -227,8 +225,10 @@ hypervGetVSSDFromUUID(hypervPrivate *priv, const char *uuid,
|
|||||||
"ResultClass = Msvm_VirtualSystemSettingData",
|
"ResultClass = Msvm_VirtualSystemSettingData",
|
||||||
uuid);
|
uuid);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_VirtualSystemSettingData, data) < 0 ||
|
if (hypervGetWmiClass(Msvm_VirtualSystemSettingData, data) < 0)
|
||||||
!*data) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*data) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not look up virtual system setting data with UUID '%s'"),
|
_("Could not look up virtual system setting data with UUID '%s'"),
|
||||||
uuid);
|
uuid);
|
||||||
@ -249,8 +249,10 @@ hypervGetProcSDByVSSDInstanceId(hypervPrivate *priv, const char *id,
|
|||||||
"ResultClass = Msvm_ProcessorSettingData",
|
"ResultClass = Msvm_ProcessorSettingData",
|
||||||
id);
|
id);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_ProcessorSettingData, data) < 0 ||
|
if (hypervGetWmiClass(Msvm_ProcessorSettingData, data) < 0)
|
||||||
!*data) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*data) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not look up processor setting data with virtual system instance ID '%s'"),
|
_("Could not look up processor setting data with virtual system instance ID '%s'"),
|
||||||
id);
|
id);
|
||||||
@ -271,8 +273,10 @@ hypervGetMemSDByVSSDInstanceId(hypervPrivate *priv, const char *id,
|
|||||||
"ResultClass = Msvm_MemorySettingData",
|
"ResultClass = Msvm_MemorySettingData",
|
||||||
id);
|
id);
|
||||||
|
|
||||||
if (hypervGetWmiClass(Msvm_MemorySettingData, data) < 0 ||
|
if (hypervGetWmiClass(Msvm_MemorySettingData, data) < 0)
|
||||||
!*data) {
|
return -1;
|
||||||
|
|
||||||
|
if (!*data) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not look up memory setting data with virtual system instance ID '%s'"),
|
_("Could not look up memory setting data with virtual system instance ID '%s'"),
|
||||||
id);
|
id);
|
||||||
@ -548,8 +552,10 @@ hypervConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
|||||||
g_auto(virBuffer) query = { g_string_new(WIN32_OPERATINGSYSTEM_WQL_SELECT), 0 };
|
g_auto(virBuffer) query = { g_string_new(WIN32_OPERATINGSYSTEM_WQL_SELECT), 0 };
|
||||||
unsigned int major, minor, micro;
|
unsigned int major, minor, micro;
|
||||||
|
|
||||||
if (hypervGetWmiClass(Win32_OperatingSystem, &os) < 0 ||
|
if (hypervGetWmiClass(Win32_OperatingSystem, &os) < 0)
|
||||||
!os) {
|
goto cleanup;
|
||||||
|
|
||||||
|
if (!os) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not get version information for host %s"),
|
_("Could not get version information for host %s"),
|
||||||
conn->uri->server);
|
conn->uri->server);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user