From nobody Sun May 12 22:47:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1694212169; cv=none; d=zohomail.com; s=zohoarc; b=Wsqic6jYdU5FcqeML2or+Bc9pbwkzhCmD0NnbXijlAac5ovsujMf1UeLrLDFBdexbu+hLkyOyKouKkti5Fu8aZgTZA/xCRCiTmpkpUdGz2GCgNvBPvXsqTaRZQUCoLCPG6irLVgRaOwisziVcoWScPf4lq240RJCgibK0RJcj0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694212169; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=haELv47sIoVgcMNO6cU8pFSC9JgMkobUnqon/kgjzfM=; b=LvLiyQuB4mmmchfz2tLKuzhIgCkl+hHGCxb+NWkHQfrTWIuEctRq2iTjqt3WScBoqg46V1jaLsgXHEVk6ewEjHNDRBgzQh0cH2DIgHAd9FZEu/w4D2zicxtcrKBE9OYo5vzKbdKyZtVpDs9G+hkRn+35YLIA29c4loc8bqptRFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1694212169723830.7798825844491; Fri, 8 Sep 2023 15:29:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-477-U-PVepiFMlCe1QW8palWeg-1; Fri, 08 Sep 2023 18:29:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2136811726; Fri, 8 Sep 2023 22:29:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0735405221C; Fri, 8 Sep 2023 22:29:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7357F194658C; Fri, 8 Sep 2023 22:29:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C5AC71946586 for ; Fri, 8 Sep 2023 22:29:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9698840ED414; Fri, 8 Sep 2023 22:29:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F53040C6CCC for ; Fri, 8 Sep 2023 22:29:18 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 723B1800C78 for ; Fri, 8 Sep 2023 22:29:18 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-54-YSvjNxcINEeSo5FdOwi2Pw-1; Fri, 08 Sep 2023 18:29:16 -0400 Received: from home-fedora.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id B0AEB212B5CA for ; Fri, 8 Sep 2023 15:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694212168; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=haELv47sIoVgcMNO6cU8pFSC9JgMkobUnqon/kgjzfM=; b=avSCckfg67TwCwot+VY5a1/yYnKU+cwQmuWF0oxz7TrEjUZ6AhI/cbJZLWYdERC7geKJW+ 3FiB0TkpWhEHA5Ct5AnH+AP+sqzwu6Q3bXYXeWBOoDtYnGiIO/ss4RBFEOd1MwRZqPL9l0 DxDuFA6au/riCux7zwvjDFyKAMtExzs= X-MC-Unique: U-PVepiFMlCe1QW8palWeg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: YSvjNxcINEeSo5FdOwi2Pw-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B0AEB212B5CA From: Praveen K Paladugu To: libvir-list@redhat.com Subject: [libvirt PATCH v4] ch: Fix cloud-hypervisor version processing Date: Fri, 8 Sep 2023 17:29:08 -0500 Message-ID: <20230908222908.43777-1-prapal@linux.microsoft.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: linux.microsoft.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694212171274100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Refactor the version processing logic in ch driver to support versions from non-release cloud-hypervisor binaries. This version also supports versions with branch prefixes in them. Signed-off-by: Praveen K Paladugu Reviewed-by: Martin Kletzander --- src/ch/ch_conf.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index a8565d9537..f421af5121 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -172,6 +172,29 @@ virCHDriverConfigDispose(void *obj) =20 #define MIN_VERSION ((15 * 1000000) + (0 * 1000) + (0)) =20 +/** + * chPreProcessVersionString: + * + * Returns: a pointer to numerical version without branch/commit info + */ +static char * +chPreProcessVersionString(char *version) +{ + char *tmp =3D strrchr(version, '/'); + + if (tmp) + version =3D tmp + 1; + + if (version[0] =3D=3D 'v') + version++; + + tmp =3D strchr(version, '-'); + if (tmp) + *tmp =3D '\0'; + + return version; +} + int chExtractVersion(virCHDriver *driver) { @@ -193,13 +216,20 @@ chExtractVersion(virCHDriver *driver) =20 tmp =3D help; =20 - /* expected format: cloud-hypervisor v.. */ - if ((tmp =3D STRSKIP(tmp, "cloud-hypervisor v")) =3D=3D NULL) { + /* Below are example version formats and expected outputs: + * cloud-hypervisor v32.0.0 (expected: 32.0.0) + * cloud-hypervisor v33.0-104-ge0e3779e-dirty (expected: 33.0) + * cloud-hypervisor testing/v32.0.131-1-ga5d6db5c-dirty (expected: 32= .0.131) + */ + if ((tmp =3D STRSKIP(tmp, "cloud-hypervisor ")) =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unexpected output of cloud-hypervisor binary")); return -1; } =20 + tmp =3D chPreProcessVersionString(tmp); + VIR_DEBUG("Cloud-Hypervisor version detected: %s", tmp); + if (virStringParseVersion(&version, tmp, true) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse cloud-hypervisor version: %1$s")= , tmp); --=20 2.41.0