From nobody Sat May 11 20:04:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1693936341; cv=none; d=zohomail.com; s=zohoarc; b=c9t5YcNIpZfup4y9jANc9Eov37vo6+Ws/Lr3OwdIaUYkMAe0D8yMjlfsy2ezdffuGjnujJOzuogBR/yzaY2bZH5PJGn67uFIzctP9AFlyM90LAWx5aviN8eOi795ptUcFHtW8RU3NrRUVT5By5uwwNLV0/HMVZE3utglK/CHMUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693936341; 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=djmzBApjyGe2KBvXKUHxwQP9dX7qBfdOuWLa1Dv+ACw=; b=Gw3uGO9YADrz7Huqy8IRCQnHrxabSFgUZZnV63kpcNU9nC+KzmVUsaz01PCMxvz2JDv7YibgOEhNjJVK8BV9e2E9caXGjBaboel+edPeUcO/0z7qMFxGGURLH5ZBh9m+ZhiiAAbeH+vxI8aetfDErvoHGo0n/B/CIskpkTpxMD4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1693936341790565.2114291184164; Tue, 5 Sep 2023 10:52:21 -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-250-nPQ0YHC_MDKlb0NPhdHItw-1; Tue, 05 Sep 2023 13:52:14 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E31401040883; Tue, 5 Sep 2023 17:52:11 +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 0E01A47FC73; Tue, 5 Sep 2023 17:52:09 +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 8869E194658C; Tue, 5 Sep 2023 17:52:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E183F1946589 for ; Tue, 5 Sep 2023 17:52:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 99830493110; Tue, 5 Sep 2023 17:52:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92CDC493112 for ; Tue, 5 Sep 2023 17:52:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.120]) (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 E05F51040883 for ; Tue, 5 Sep 2023 17:52:07 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-175-7hNzHvjYNm-SUILq8Xzw_Q-1; Tue, 05 Sep 2023 13:52:05 -0400 Received: from home-fedora.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id 0F08F212B17B; Tue, 5 Sep 2023 10:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693936340; 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=djmzBApjyGe2KBvXKUHxwQP9dX7qBfdOuWLa1Dv+ACw=; b=hUatWFjBmurtrHmCTlm7STCMFFPjPa6OWlYSK+vBZJV91udltbyS2hAywzToT93Pg4zQpY elWImwxxdkABQJcFQMvvOhbf/urdpSHse/hC4h0HWM+iZ4ORn3UcFYdJUm09XWrX0feOhh cB2zlwosWjsafLdMlp7ZmdHSL4lCHCk= X-MC-Unique: nPQ0YHC_MDKlb0NPhdHItw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 7hNzHvjYNm-SUILq8Xzw_Q-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0F08F212B17B From: Praveen K Paladugu To: libvir-list@redhat.com, prapal@microsoft.com Subject: [libvirt PATCH v2] ch: Fix cloud-hypervisor version processing Date: Tue, 5 Sep 2023 12:44:25 -0500 Message-ID: <20230905174425.25171-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.9 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.9 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: 1693936343618100001 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 --- src/ch/ch_conf.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index a8565d9537..a0849bfbd6 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -172,6 +172,33 @@ virCHDriverConfigDispose(void *obj) =20 #define MIN_VERSION ((15 * 1000000) + (0 * 1000) + (0)) =20 +/** + * chPreProcessVersionString - crop branch, commit info and return just th= e version + */ +static char * +chPreProcessVersionString(char *version) +{ + g_autofree char *new_version =3D version; + char *tmp_version; + + if ((tmp_version =3D strrchr(version, '/')) !=3D NULL) { + new_version =3D tmp_version + 1; + } + + if (new_version[0] =3D=3D 'v') { + new_version =3D new_version + 1; + } + // Duplicate the string in both cases. This would allow the calling me= thod + // free the returned string in a consistent manner. + if ((tmp_version =3D strchr(new_version, '-')) !=3D NULL) { + new_version =3D g_strndup(new_version, tmp_version - new_version); + } else{ + new_version =3D g_strdup(new_version); + } + + return g_steal_pointer(&new_version); + +} int chExtractVersion(virCHDriver *driver) { @@ -193,19 +220,25 @@ 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 some 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); return -1; } - if (version < MIN_VERSION) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cloud-Hypervisor version is too old (v15.0 is th= e minimum supported version)")); --=20 2.41.0