From nobody Mon Feb 9 11:05:05 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; 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=gmail.com 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 1629463583895911.3883785218758; Fri, 20 Aug 2021 05:46:23 -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-478-yeZpoO1ZPuegwJ7FptC3SQ-1; Fri, 20 Aug 2021 08:46:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 165051B2C984; Fri, 20 Aug 2021 12:46:16 +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 E02231ABD8; Fri, 20 Aug 2021 12:46:15 +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 9D7984BB7C; Fri, 20 Aug 2021 12:46:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KCj6BQ013638 for ; Fri, 20 Aug 2021 08:45:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id A5A4D105458D; Fri, 20 Aug 2021 12:45:06 +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 9755A1050199 for ; Fri, 20 Aug 2021 12:45:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 13D5410666A3 for ; Fri, 20 Aug 2021 12:45:06 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-Prdu6E5jOaGX-1PAXlcrWg-1; Fri, 20 Aug 2021 08:45:04 -0400 Received: by mail-pf1-f173.google.com with SMTP id j187so8487339pfg.4 for ; Fri, 20 Aug 2021 05:45:03 -0700 (PDT) Received: from localhost ([38.94.109.214]) by smtp.gmail.com with ESMTPSA id nv11sm11533572pjb.48.2021.08.20.05.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 05:45:02 -0700 (PDT) X-MC-Unique: yeZpoO1ZPuegwJ7FptC3SQ-1 X-MC-Unique: Prdu6E5jOaGX-1PAXlcrWg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iNhtx1xv+yrIbyanbn6l8y1/Y3Q+UPSQrlToEom0SKs=; b=XgSHWHUB6nMRUPauLCrht24ZCAK+q70g6tEaT6V76L832S1WWVd0h6uZD+oViPAesB jO5/AKMOOp2+EeODE5rNzSVnSOv5F6KfPkJLRM1Zo7rqPJBD5ufqYLI3xcJW6Tt2n0bY 9ej9PJ+WknhHmytyPb7BUayNLvqQpwUblv+xFg+S42Q3+5S/m5C98S72ks7nT1dLRUVl mU0vx5mBNHT4y+W0qnIzdSKg1wvZl0+ZZcLl1KOPfzYc+E4goMkYLjOsgQlTsh7NLM39 Pf5tbrAohC4diJjfGaWZ20U0qj/e4xxqMMGk/zfQvRzs0q4/emYUcFk+N2Z2UGftC4y0 hLRA== X-Gm-Message-State: AOAM530Tfg+MGpFd4v9aGMcUZj54c3fgVsf8FKxHNt8EaFjEpUwR012D 0+kY8p90K/MuErKBNP8xAlUb3pu2OBsWvlaQkg4= X-Google-Smtp-Source: ABdhPJzS6agkzG87+vHeGX14V6Ef01HGMgjFttTVYloBPm+HLWYcUZLNHXdqIcs5WKubOK5z9Fon+A== X-Received: by 2002:a63:134e:: with SMTP id 14mr18243122pgt.312.1629463502612; Fri, 20 Aug 2021 05:45:02 -0700 (PDT) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v2 06/12] conf: Add tpm helpers for future use Date: Fri, 20 Aug 2021 20:44:33 +0800 Message-Id: <20210820124439.535276-7-lukedyue@gmail.com> In-Reply-To: <20210820124439.535276-1-lukedyue@gmail.com> References: <20210820124439.535276-1-lukedyue@gmail.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 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com 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.15 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-ZM-MESSAGEID: 1629463585251100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- src/conf/domain_conf.c | 67 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 6 ++++ src/libvirt_private.syms | 2 ++ 3 files changed, 75 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6667426b9a..7f3d207a3e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16790,6 +16790,73 @@ virDomainVsockDefEquals(const virDomainVsockDef *a, } =20 =20 +static bool +virDomainTPMDefEquals(const virDomainTPMDef *a, + const virDomainTPMDef *b) +{ + if (a->type !=3D b->type) + return false; + + if (a->model !=3D b->model) + return false; + + if (a->version !=3D b->version) + return false; + + if (a->type =3D=3D VIR_DOMAIN_TPM_TYPE_PASSTHROUGH) { + if (STRNEQ_NULLABLE(a->data.passthrough.source.data.file.path, + b->data.passthrough.source.data.file.path)) + return false; + } else { + if (a->data.emulator.hassecretuuid !=3D b->data.emulator.hassecret= uuid) + return false; + + if (a->data.emulator.hassecretuuid =3D=3D true && + memcmp(a->data.emulator.secretuuid, + b->data.emulator.secretuuid, + VIR_UUID_BUFLEN)) + return false; + + if (a->data.emulator.persistent_state !=3D + b->data.emulator.persistent_state) + return false; + } + + if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info)) + return false; + + return true; +} + + +ssize_t +virDomainTPMDefFind(const virDomainDef *def, + const virDomainTPMDef *tpm) +{ + size_t i; + + for (i =3D 0; i < def->ntpms; i++) { + if (virDomainTPMDefEquals(tpm, def->tpms[i])) + return i; + } + + return -1; +} + + +virDomainTPMDef * +virDomainTPMDefRemove(virDomainDef *def, + size_t idx) +{ + virDomainTPMDef *ret =3D def->tpms[idx]; + + VIR_DELETE_ELEMENT(def->tpms, idx, def->ntpms); + + return ret; +} + + char * virDomainDefGetDefaultEmulator(virDomainDef *def, virCaps *caps) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3e4701176d..b8a1e1d2d2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3821,6 +3821,12 @@ bool virDomainVsockDefEquals(const virDomainVsockDef= *a, const virDomainVsockDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; =20 +ssize_t virDomainTPMDefFind(const virDomainDef *def, + const virDomainTPMDef *tpm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; +virDomainTPMDef *virDomainTPMDefRemove(virDomainDef *def, size_t idx) + ATTRIBUTE_NONNULL(1); + VIR_ENUM_DECL(virDomainTaint); VIR_ENUM_DECL(virDomainTaintMessage); VIR_ENUM_DECL(virDomainVirt); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9cf12779bf..f7f3726443 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -661,7 +661,9 @@ virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainTPMBackendTypeFromString; virDomainTPMBackendTypeToString; +virDomainTPMDefFind; virDomainTPMDefFree; +virDomainTPMDefRemove; virDomainTPMModelTypeFromString; virDomainTPMModelTypeToString; virDomainUSBDeviceDefForeach; --=20 2.33.0