If chExtractVersionInfo() fails, in some cases it reports error and in some it doesn't. Fix those places and drop reporting error from chExtractVersion() which would just overwrite more specific error. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/ch/ch_conf.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 2dd104b8a8..d900ebc7dd 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -213,11 +213,17 @@ chExtractVersionInfo(int *retversion) tmp = help; /* expected format: cloud-hypervisor v<major>.<minor>.<micro> */ - if ((tmp = STRSKIP(tmp, "cloud-hypervisor v")) == NULL) + if ((tmp = STRSKIP(tmp, "cloud-hypervisor v")) == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unexpected output of cloud-hypervisor binary")); goto cleanup; + } - if (virParseVersionString(tmp, &version, true) < 0) + if (virParseVersionString(tmp, &version, true) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse cloud-hypervisor version: %s"), tmp); goto cleanup; + } if (version < MIN_VERSION) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -241,11 +247,8 @@ int chExtractVersion(virCHDriver *driver) if (driver->version > 0) return 0; - if (chExtractVersionInfo(&driver->version) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not extract Cloud-Hypervisor version")); + if (chExtractVersionInfo(&driver->version) < 0) return -1; - } return 0; } -- 2.31.1