mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
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
This commit is contained in:
parent
f5272027c3
commit
f1f28611f1
@ -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 <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).</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
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user