From nobody Sun May 12 08:29:24 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=1694015458; cv=none; d=zohomail.com; s=zohoarc; b=ePNxonprfEKtgKmzo2W8blX5OFQpkJqjkaRgGhkfaxlx6iZKwv1qTwo4sSr/4K1zyzK40mkEhhEFbAUHhLyR7elPmBRT2Wdua4T/eBJHpBhnYapTSjgpvWPZLPKPanIZr+shpe2Mx10LZwhQp6WQ6zetQPg2rt0aTWr+kTMEJaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694015458; 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=ALdp8Y+ZD7O4CrD3fu5CcQYunvEfqYQi6RgJnjtMTCQ=; b=B+47+KX3Loy/O6LvQA3WSzjHyJluiOphwRm+3brx1RCgW+CBxfQPuvI4RqW8sCyczVh9XsiY457qP+GIh7bPJv4A6VtzjOKt1bqvknZCW+7WCbVs0W7KMDReM4Ut9FpgwcyYe7LFFW+jreSuNZgyhVpZQFKlcyhvOsAAJK59QrY= 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 1694015458000365.9674977755876; Wed, 6 Sep 2023 08:50:58 -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-187-zsow6ecYPD69J0hmJxAtYA-1; Wed, 06 Sep 2023 11:50:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3DBE101F5A1; Wed, 6 Sep 2023 15:50:44 +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 2D9FB20BAE72; Wed, 6 Sep 2023 15:50:44 +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 D3E14194658D; Wed, 6 Sep 2023 15:50:43 +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 0CD68194658C for ; Wed, 6 Sep 2023 15:50:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E742F40ED77B; Wed, 6 Sep 2023 15:50:42 +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 E00D740C105A for ; Wed, 6 Sep 2023 15:50:42 +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 BEC818AA801 for ; Wed, 6 Sep 2023 15:50:42 +0000 (UTC) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by relay.mimecast.com with ESMTP id us-mta-369-Xv7BDLh3PkGsj8zhV_PLdQ-1; Wed, 06 Sep 2023 11:50:40 -0400 Received: from home-fedora.. (072-191-074-189.res.spectrum.com [72.191.74.189]) by linux.microsoft.com (Postfix) with ESMTPSA id 9CEBA212B195 for ; Wed, 6 Sep 2023 08:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694015457; 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=ALdp8Y+ZD7O4CrD3fu5CcQYunvEfqYQi6RgJnjtMTCQ=; b=JEWkiIyZRA/LGkTLbI40Pt/oQRTgLKj/lTv2Rz47nk48uVzsVlYn9KrRKghKemUN3kgwYT 7cnhr06IEfJFvtDt3TlyZiE0v16BhKiam20IHIh+3C+DfK84b9k76G6LBs1T/gXOvGgwCF KquvAtfsaoQwXOJ+VBqvKfVSXZ1ahS4= X-MC-Unique: zsow6ecYPD69J0hmJxAtYA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Xv7BDLh3PkGsj8zhV_PLdQ-1 DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9CEBA212B195 From: Praveen K Paladugu To: libvir-list@redhat.com Subject: [libvirt PATCH v3] ch: Fix cloud-hypervisor version processing Date: Wed, 6 Sep 2023 10:50:30 -0500 Message-ID: <20230906155030.21298-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.6 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: 1694015459038100001 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 | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index a8565d9537..5573119b23 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -172,6 +172,37 @@ 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_version =3D version; + g_autofree char *ret_version =3D NULL; + char *sub_string; + + if ((sub_string =3D strrchr(version, '/')) !=3D NULL) { + tmp_version =3D sub_string + 1; + } + + if (tmp_version[0] =3D=3D 'v') { + tmp_version =3D tmp_version + 1; + } + + // Duplicate the string in both cases. This would allow the calling me= thod + // free the returned string in a consistent manner. + if ((sub_string =3D strchr(tmp_version, '-')) !=3D NULL) { + ret_version =3D g_strndup(tmp_version, sub_string - tmp_version); + } else{ + ret_version =3D g_strdup(tmp_version); + } + + return g_steal_pointer(&ret_version); + +} int chExtractVersion(virCHDriver *driver) { @@ -193,13 +224,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 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); --=20 2.41.0