[libvirt] [PATCH] nodesuspend: report unsupported if systemd & pm-utils aren't available

Daniel P. Berrangé posted 1 patch 4 years, 11 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190523155928.13781-1-berrange@redhat.com
src/util/virnodesuspend.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
[libvirt] [PATCH] nodesuspend: report unsupported if systemd & pm-utils aren't available
Posted by Daniel P. Berrangé 4 years, 11 months ago
When libvirtd is run inside a container it is normal that neither
systemd nor pm-utils will be available. In this case there is no way to
suspend the host, so libvirt should just report the feature unsupported
instead of raising an error.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/util/virnodesuspend.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 0af0908e4a..3fc5b93ac7 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -330,11 +330,10 @@ virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
     if (ret == -2)
         ret = virNodeSuspendSupportsTargetPMUtils(target, supported);
 
-    /* If still unavailable, then report error */
+    /* If still unavailable, then report unsupported */
     if (ret == -2) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Cannot probe for supported suspend types"));
-        ret = -1;
+        *supported = false;
+        ret = 0;
     }
 
     return ret;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nodesuspend: report unsupported if systemd & pm-utils aren't available
Posted by Michal Privoznik 4 years, 11 months ago
On 5/23/19 5:59 PM, Daniel P. Berrangé wrote:
> When libvirtd is run inside a container it is normal that neither
> systemd nor pm-utils will be available. In this case there is no way to
> suspend the host, so libvirt should just report the feature unsupported
> instead of raising an error.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   src/util/virnodesuspend.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)

ACK

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list