From nobody Mon Feb 9 12:27:01 2026 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633950172; cv=none; d=zohomail.com; s=zohoarc; b=HmRU3e6yrHvr4mc2/lprekJl46+aNouEAn9SLJe9eOQniE3QIXW30r+9rClqPPfedxLNAB/fQChaH5jtupP49NE270LaV9ExrGJxnacTN2kXxswY14y7xiVbzZKbInwFvWFza3kdOBvCRMoSIrHiqWlxsSWA4D/x2Z9apztZW0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633950172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z5ESqERTUKvOD2D04N/qkVXct7XrAo3iBXW5/G6FUlU=; b=V8E0aIiwbjElyXQ542CuiAUYABz3zsbZHI0vgxWp+nc/zrCpraGyW27ymNJpwq/afdap8Qr2sG/2tFWBl25x9BVcdgHyB8yFtsI1tKUgzMw82zKKnHIdmJa6wWLRoEwQrEmPP71gg3TIsrwLX0DWkpZ2TvfV6H03ytZg8q3cKyc= 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=pass 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 1633950172592907.1474798425636; Mon, 11 Oct 2021 04:02:52 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-NVN1O2AePYufnA9tKDrT6A-1; Mon, 11 Oct 2021 07:02:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 580BD10A8E04; Mon, 11 Oct 2021 11:02:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37DE95C23A; Mon, 11 Oct 2021 11:02:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D3B724EA37; Mon, 11 Oct 2021 11:02:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19BB2flO012795 for ; Mon, 11 Oct 2021 07:02:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D31360C82; Mon, 11 Oct 2021 11:02:41 +0000 (UTC) Received: from work.redhat.com (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FE2960BF4; Mon, 11 Oct 2021 11:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633950171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Z5ESqERTUKvOD2D04N/qkVXct7XrAo3iBXW5/G6FUlU=; b=Ww0K4XtwomvOjBEFohHgIKZnxoSofAts1eONFcZJKxzzX2I+5dLVes/4oxUagpupGy/09Z vXGOXjQaSxJEDRI2AHq1vqStZMiuXJcnRAsu2rGNUNastbQtSRwzpAM98kAGwP9hgWR6fC QRWNIAH+Fu9q0m4aBxLo1MhKaC6b8Ws= X-MC-Unique: NVN1O2AePYufnA9tKDrT6A-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 2/5] cpu: Add virCPUDataIsIdentical Date: Mon, 11 Oct 2021 13:02:25 +0200 Message-Id: <20211011110228.46312-3-twiederh@redhat.com> In-Reply-To: <20211011110228.46312-1-twiederh@redhat.com> References: <20211011110228.46312-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633950174685100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- src/cpu/cpu.c | 29 +++++++++++++++++++++++++++++ src/cpu/cpu.h | 9 +++++++++ src/libvirt_private.syms | 1 + 3 files changed, 39 insertions(+) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index b4965f3ee0..a3531dd665 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -1128,6 +1128,35 @@ virCPUDataAddFeature(virCPUData *cpuData, } =20 =20 +/** + * virCPUDataIsIdentical: + * + * Returns VIR_CPU_COMPARE_IDENTICAL if @a and @b are identical, + * VIR_CPU_COMPARE_INCOMPATIBLE if @a and @b are not identical, or + * VIR_CPU_COMPARE_ERROR on error. + */ +virCPUCompareResult +virCPUDataIsIdentical(const virCPUData *a, + const virCPUData *b) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("a=3D%p, b=3D%p", a, b); + + if (!a || !b) + return VIR_CPU_COMPARE_ERROR; + + if (!(driver =3D cpuGetSubDriver(a->arch))) + return VIR_CPU_COMPARE_ERROR; + + if (!driver->dataIsIdentical) { + return VIR_CPU_COMPARE_ERROR; + } + + return driver->dataIsIdentical(a, b); +} + + /** * virCPUArchIsSupported: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index d11d2641fc..e752126813 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -123,6 +123,10 @@ typedef int (*virCPUArchDataAddFeature)(virCPUData *cpuData, const char *name); =20 +typedef virCPUCompareResult +(*virCPUArchDataIsIdentical)(const virCPUData *a, + const virCPUData *b); + struct cpuArchDriver { const char *name; const virArch *arch; @@ -146,6 +150,7 @@ struct cpuArchDriver { virCPUArchCopyMigratable copyMigratable; virCPUArchValidateFeatures validateFeatures; virCPUArchDataAddFeature dataAddFeature; + virCPUArchDataIsIdentical dataIsIdentical; }; =20 =20 @@ -275,6 +280,10 @@ int virCPUDataAddFeature(virCPUData *cpuData, const char *name); =20 +virCPUCompareResult +virCPUDataIsIdentical(const virCPUData *a, + const virCPUData *b); + bool virCPUArchIsSupported(virArch arch); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fd0eea0777..b63165f354 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1459,6 +1459,7 @@ virCPUDataAddFeature; virCPUDataCheckFeature; virCPUDataFormat; virCPUDataFree; +virCPUDataIsIdentical; virCPUDataNew; virCPUDataParse; virCPUExpandFeatures; --=20 2.31.1