From nobody Sun Feb 8 23:03:50 2026 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; 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=gmail.com 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 1644219568725348.38922777927075; Sun, 6 Feb 2022 23:39:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-ai876ECCNP-4ED9E5UMCDA-1; Mon, 07 Feb 2022 02:39:26 -0500 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 CAA34874983; Mon, 7 Feb 2022 07:39:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3F644F84C; Mon, 7 Feb 2022 07:39:21 +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 70DB8180B654; Mon, 7 Feb 2022 07:39:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2177cdcV012102 for ; Mon, 7 Feb 2022 02:38:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id A2593C159B3; Mon, 7 Feb 2022 07:38:39 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E16CC08090 for ; Mon, 7 Feb 2022 07:38:39 +0000 (UTC) Received: from us-smtp-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 85B5E802319 for ; Mon, 7 Feb 2022 07:38:39 +0000 (UTC) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-45OOMyZWMaWT-lku8vWcEQ-1; Mon, 07 Feb 2022 02:38:37 -0500 Received: by mail-pj1-f54.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso5610555pjt.4 for ; Sun, 06 Feb 2022 23:38:37 -0800 (PST) Received: from localhost ([38.94.108.206]) by smtp.gmail.com with ESMTPSA id c18sm10571201pfp.181.2022.02.06.23.38.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 23:38:35 -0800 (PST) X-MC-Unique: ai876ECCNP-4ED9E5UMCDA-1 X-MC-Unique: 45OOMyZWMaWT-lku8vWcEQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lFjqcEXKJhZUun0BGCtBvTOlrqKqPz9rS1sLCpVTMP4=; b=48Gdopo0EeODOUX1eiOFwTBmPuAlxUPAPc9ZvYuq+dbO3Y509NGZoYftqQRS84YY4i toGUDOCE7HoZzh7qIPayJvfIWFZX8tqjQWZm1ZWYQnAZZoFkY/tvrU1COdK6RVMZ+wkh HMBoGqGfBt+z804Gsfztva+/m2M/vfatug+rxEFVwZNOZ+po8qrkHvQtIBx021qqqK9L fK38V08Al9ZJ9dmFAjTXkxVP8zKQSRcfZoBJXbednF+sRZv6YLBimPEf9l517zStDHUl f5bNQlCSI5DO5T2rGHh5y/Jo0TdN5nV2++N35fl9PuIy+b7eBzH4Ajxhip4BXOQDBQt5 LLdA== X-Gm-Message-State: AOAM530ZtBai2AL4lPZchKF+ySMz5RfgNX+h3Xs3S9uW/qSphVvdlSx9 p0HlvUtidhV7V8CIIGsyvuIlA0H7jYsxXJDCPbM= X-Google-Smtp-Source: ABdhPJwWvobUXh/hY12oZjklWAHmD9DErArwCvv5LbX+toeUtf0btuH7/k31QiYOwdMYUPS94JhIMQ== X-Received: by 2002:a17:90b:3146:: with SMTP id ip6mr17257582pjb.208.1644219516106; Sun, 06 Feb 2022 23:38:36 -0800 (PST) From: Luke Yue To: libvir-list@redhat.com Subject: [PATCH v5 4/8] conf: Add tpm helpers for future use Date: Mon, 7 Feb 2022 15:38:14 +0800 Message-Id: <20220207073818.356659-5-lukedyue@gmail.com> In-Reply-To: <20220207073818.356659-1-lukedyue@gmail.com> References: <20220207073818.356659-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.85 on 10.11.54.8 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: 1644219579667100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Luke Yue --- As persistent_state and is bool type and its default value is false, so I guess it's fine that it's not explicitly assigned with false. link to context: https://listman.redhat.com/archives/libvir-list/2021-Novem= ber/msg00874.html --- 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 e19e3deb17..27643cab16 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16768,6 +16768,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 && a->model !=3D VIR_DOMAIN_TPM_MODEL_DEFAU= LT) + return false; + + if (a->version !=3D b->version && a->version !=3D VIR_DOMAIN_TPM_MODEL= _DEFAULT) + 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 3bb1092b60..89031639cb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3941,6 +3941,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 abdc8eaef7..b6b8606063 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -667,7 +667,9 @@ virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeToString; virDomainTPMBackendTypeFromString; virDomainTPMBackendTypeToString; +virDomainTPMDefFind; virDomainTPMDefFree; +virDomainTPMDefRemove; virDomainTPMModelTypeFromString; virDomainTPMModelTypeToString; virDomainTPMPcrBankTypeFromString; --=20 2.35.1