mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
ch_driver: Don't error out if CH_CMD was not found
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>
This commit is contained in:
parent
da91bdf836
commit
7a90431d7d
@ -199,8 +199,12 @@ chExtractVersion(virCHDriver *driver)
|
|||||||
char *help = NULL;
|
char *help = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
|
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");
|
virCommandAddEnvString(cmd, "LC_ALL=C");
|
||||||
virCommandSetOutputBuffer(cmd, &help);
|
virCommandSetOutputBuffer(cmd, &help);
|
||||||
|
|
||||||
|
@ -836,6 +836,9 @@ static int chStateInitialize(bool privileged,
|
|||||||
virStateInhibitCallback callback G_GNUC_UNUSED,
|
virStateInhibitCallback callback G_GNUC_UNUSED,
|
||||||
void *opaque G_GNUC_UNUSED)
|
void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
|
int ret = VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
int rv;
|
||||||
|
|
||||||
if (root != NULL) {
|
if (root != NULL) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("Driver does not support embedded mode"));
|
_("Driver does not support embedded mode"));
|
||||||
@ -861,14 +864,18 @@ static int chStateInitialize(bool privileged,
|
|||||||
if (!(ch_driver->config = virCHDriverConfigNew(privileged)))
|
if (!(ch_driver->config = virCHDriverConfigNew(privileged)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (chExtractVersion(ch_driver) < 0)
|
if ((rv = chExtractVersion(ch_driver)) < 0) {
|
||||||
|
if (rv == -2)
|
||||||
|
ret = VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
return VIR_DRV_STATE_INIT_COMPLETE;
|
ret = VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
chStateCleanup();
|
if (ret != VIR_DRV_STATE_INIT_COMPLETE)
|
||||||
return VIR_DRV_STATE_INIT_ERROR;
|
chStateCleanup();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function Tables */
|
/* Function Tables */
|
||||||
|
Loading…
Reference in New Issue
Block a user