]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch_driver: Don't error out if CH_CMD was not found
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Jun 2021 12:55:04 +0000 (14:55 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Jun 2021 14:39:00 +0000 (16:39 +0200)
The CH driver needs "cloud-hypervisor" binary. And if none was
found then the initialization of the driver fails as
chStateInitialize() returns VIR_DRV_STATE_INIT_ERROR. This in
turn means that whole daemon fails to initialize. Let's return
VIR_DRV_STATE_INIT_SKIPPED in this particular case, which
disables the CH drvier but lets the daemon run.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/ch/ch_conf.c
src/ch/ch_driver.c

index dfebc8525a792b0adae49bcc8bb7affe9e92057d..b2812de7ad59e42a748bee5b0b343979fac11fd4 100644 (file)
@@ -199,8 +199,12 @@ chExtractVersion(virCHDriver *driver)
     char *help = NULL;
     char *tmp = NULL;
     g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
-    virCommand *cmd = virCommandNewArgList(ch_cmd, "--version", NULL);
+    virCommand *cmd = NULL;
 
+    if (!ch_cmd)
+        return -2;
+
+    cmd = virCommandNewArgList(ch_cmd, "--version", NULL);
     virCommandAddEnvString(cmd, "LC_ALL=C");
     virCommandSetOutputBuffer(cmd, &help);
 
index 7d1e97098aefc64f4e4f532443fbd3675852d084..8c458a20bd9256bd3898c0a0bd54b61a78009053 100644 (file)
@@ -836,6 +836,9 @@ static int chStateInitialize(bool privileged,
                              virStateInhibitCallback callback G_GNUC_UNUSED,
                              void *opaque G_GNUC_UNUSED)
 {
+    int ret = VIR_DRV_STATE_INIT_ERROR;
+    int rv;
+
     if (root != NULL) {
         virReportError(VIR_ERR_INVALID_ARG, "%s",
                        _("Driver does not support embedded mode"));
@@ -861,14 +864,18 @@ static int chStateInitialize(bool privileged,
     if (!(ch_driver->config = virCHDriverConfigNew(privileged)))
         goto cleanup;
 
-    if (chExtractVersion(ch_driver) < 0)
+    if ((rv = chExtractVersion(ch_driver)) < 0) {
+        if (rv == -2)
+            ret = VIR_DRV_STATE_INIT_SKIPPED;
         goto cleanup;
+    }
 
-    return VIR_DRV_STATE_INIT_COMPLETE;
+    ret = VIR_DRV_STATE_INIT_COMPLETE;
 
  cleanup:
-    chStateCleanup();
-    return VIR_DRV_STATE_INIT_ERROR;
+    if (ret != VIR_DRV_STATE_INIT_COMPLETE)
+        chStateCleanup();
+    return ret;
 }
 
 /* Function Tables */