From: Michal Privoznik Date: Fri, 4 Jun 2021 12:18:50 +0000 (+0200) Subject: ch_conf: Move error reporting into chExtractVersionInfo() X-Git-Tag: v7.5.0-rc1~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fcbedad406921e36b2c503049f1e76fbf048dea;p=thirdparty%2Flibvirt.git ch_conf: Move error reporting into chExtractVersionInfo() 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 Reviewed-by: Daniel P. Berrangé --- 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.. */ - 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; }