From f1f28611f1fb7370e2780edf958e4918e88fc36f Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange"
Date: Tue, 29 Nov 2011 14:50:04 +0000
Subject: [PATCH] Remove powerMgmt_valid field from capabilities struct
If we ensure that virNodeSuspendGetTargetMask always resets
*bitmask to zero upon failure, there is no need for the
powerMgmt_valid field.
* src/util/virnodesuspend.c: Ensure *bitmask is zero upon
failure
* src/conf/capabilities.c, src/conf/capabilities.h: Remove
powerMgmt_valid field
* src/qemu/qemu_capabilities.c: Remove powerMgmt_valid
---
docs/formatcaps.html.in | 7 ++-----
src/conf/capabilities.c | 30 ++++++++++++++----------------
src/conf/capabilities.h | 1 -
src/qemu/qemu_capabilities.c | 5 +----
src/util/virnodesuspend.c | 10 +++++++---
5 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index dc9693eb37..9d42426b23 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -74,12 +74,9 @@ BIOS you will see
description). Further, the power management features
supported by the host are shown, such as Suspend-to-RAM (S3),
Suspend-to-Disk (S4) and Hybrid-Suspend (a combination of S3
- and S4). In case the query for power
- management features succeeded but the host does not support
+ and S4). In case the host does not support
any such feature, then an empty <power_management/>
- tag will be shown. Otherwise, if the query itself failed, no
- such tag will be displayed (i.e., there will not be any
- power_management block or empty tag in the XML).
+ tag will be shown.
The second block (in blue) indicates the paravirtualization
support of the Xen support, you will see the os_type of xen
to indicate a paravirtual kernel, then architecture
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index df5ff23160..ac050df2d3 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -696,23 +696,21 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " \n");
- if (caps->host.powerMgmt_valid) {
- /* The PM query was successful. */
- if (caps->host.powerMgmt) {
- /* The host supports some PM features. */
- unsigned int pm = caps->host.powerMgmt;
- virBufferAddLit(&xml, " \n");
- while (pm) {
- int bit = ffs(pm) - 1;
- virBufferAsprintf(&xml, " <%s/>\n",
- virCapsHostPMTargetTypeToString(bit));
- pm &= ~(1U << bit);
- }
- virBufferAddLit(&xml, " \n");
- } else {
- /* The host does not support any PM feature. */
- virBufferAddLit(&xml, " \n");
+ /* The PM query was successful. */
+ if (caps->host.powerMgmt) {
+ /* The host supports some PM features. */
+ unsigned int pm = caps->host.powerMgmt;
+ virBufferAddLit(&xml, " \n");
+ while (pm) {
+ int bit = ffs(pm) - 1;
+ virBufferAsprintf(&xml, " <%s/>\n",
+ virCapsHostPMTargetTypeToString(bit));
+ pm &= ~(1U << bit);
}
+ virBufferAddLit(&xml, " \n");
+ } else {
+ /* The host does not support any PM feature. */
+ virBufferAddLit(&xml, " \n");
}
if (caps->host.offlineMigrate) {
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 148c7cc939..7f35c17e3b 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -105,7 +105,6 @@ struct _virCapsHost {
size_t nfeatures;
size_t nfeatures_max;
char **features;
- bool powerMgmt_valid;
unsigned int powerMgmt; /* Bitmask of the PM capabilities.
* See enum virHostPMCapability.
*/
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 64ab8a8652..deef0eafb9 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -851,11 +851,8 @@ virCapsPtr qemuCapsInit(virCapsPtr old_caps)
/* Add the power management features of the host */
- if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) {
+ if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0)
VIR_WARN("Failed to get host power management capabilities");
- caps->host.powerMgmt_valid = false;
- } else
- caps->host.powerMgmt_valid = true; /* The PM query succeeded. */
virCapabilitiesAddHostMigrateTransport(caps,
"tcp");
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index e070cb1805..29b7f871c0 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -346,23 +346,27 @@ virNodeSuspendGetTargetMask(unsigned int *bitmask)
/* Check support for Suspend-to-RAM (S3) */
ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_MEM, &supported);
if (ret < 0)
- return -1;
+ goto error;
if (supported)
*bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_MEM);
/* Check support for Suspend-to-Disk (S4) */
ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_DISK, &supported);
if (ret < 0)
- return -1;
+ goto error;
if (supported)
*bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_DISK);
/* Check support for Hybrid-Suspend */
ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_HYBRID, &supported);
if (ret < 0)
- return -1;
+ goto error;
if (supported)
*bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_HYBRID);
return 0;
+
+error:
+ *bitmask = 0;
+ return -1;
}