]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Remove powerMgmt_valid field from capabilities struct
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 29 Nov 2011 14:50:04 +0000 (14:50 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 30 Nov 2011 10:12:30 +0000 (10:12 +0000)
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
src/conf/capabilities.c
src/conf/capabilities.h
src/qemu/qemu_capabilities.c
src/util/virnodesuspend.c

index dc9693eb37468dc313c799a343a5ae362cedcdae..9d42426b235d7f2f6ff5b6b86325cdd87789427e 100644 (file)
@@ -74,12 +74,9 @@ BIOS you will see</p>
           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 &lt;power_management/&gt;
-          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).</p>
+          tag will be shown. </p>
         <p>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
index df5ff2316081cbf012ac72316cd8726633b55aae..ac050df2d3e2c9deddf25733c1877b73b3ec2768 100644 (file)
@@ -696,23 +696,21 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 
     virBufferAddLit(&xml, "    </cpu>\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, "    <power_management>\n");
-            while (pm) {
-                int bit = ffs(pm) - 1;
-                virBufferAsprintf(&xml, "      <%s/>\n",
-                    virCapsHostPMTargetTypeToString(bit));
-                pm &= ~(1U << bit);
-            }
-            virBufferAddLit(&xml, "    </power_management>\n");
-        } else {
-            /* The host does not support any PM feature. */
-            virBufferAddLit(&xml, "    <power_management/>\n");
+    /* The PM query was successful. */
+    if (caps->host.powerMgmt) {
+        /* The host supports some PM features. */
+        unsigned int pm = caps->host.powerMgmt;
+        virBufferAddLit(&xml, "    <power_management>\n");
+        while (pm) {
+            int bit = ffs(pm) - 1;
+            virBufferAsprintf(&xml, "      <%s/>\n",
+                              virCapsHostPMTargetTypeToString(bit));
+            pm &= ~(1U << bit);
         }
+        virBufferAddLit(&xml, "    </power_management>\n");
+    } else {
+        /* The host does not support any PM feature. */
+        virBufferAddLit(&xml, "    <power_management/>\n");
     }
 
     if (caps->host.offlineMigrate) {
index 148c7cc939f6b3906493c510d1207fd9326fa99c..7f35c17e3bd2f1a218c5a6ffe280242712a2a025 100644 (file)
@@ -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.
                                 */
index 64ab8a8652ee710c417501b216f3b2486bb161b4..deef0eafb94170f3735237562542f4e5e489e8c1 100644 (file)
@@ -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");
index e070cb1805f649e07a560aed269d29de25c96f3e..29b7f871c0810a9feab169a76462d5de22915aff 100644 (file)
@@ -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;
 }