From nobody Mon Feb 9 23:38:10 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; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636648633; cv=none; d=zohomail.com; s=zohoarc; b=PLYshKM5ElPBEBDNcUHkRhJ3f++uThmN2Q0Sst2v1O1GTYyKq4LxMlMqe8vR9UtOdWIBgVPwPDMwVkKqE9iMXZI6uNm2O3tRJsvyU5k6kL3mHZL9YifIX/ytzcrT+MD5PTAouOO02GHP0UDPNgommrmAvxLzoyxOgn5vQc1L55Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636648633; h=Content-Type:Content-Transfer-Encoding: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=tlIzh7r+Xtxep82UAZTGho3w1hzlqKJH0FXUtkdM6Vs=; b=lq6+QuaI0IBNabSzkPU3dfFx10R5OB4OBkH+6spEFiZsleD/f/vlxO8hRF1WBU3FpfYDxh5TwAwfU+lCbs24Vw2GUMKxCgBILYmv7poA8Jaz36//IlmIiP/JqDsOK4Vz9+DlOpIYwSWoS7Va5yGJNn9QB7BTVuCWVaFd3JA6QrE= 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=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.129.124]) by mx.zohomail.com with SMTPS id 1636648633074390.5823360366628; Thu, 11 Nov 2021 08:37:13 -0800 (PST) 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-162-OjsnuKkXNV-yqXUQqqCHXw-1; Thu, 11 Nov 2021 11:35:57 -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 EB3B487D541; Thu, 11 Nov 2021 16:35:49 +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 BD5F45D6D7; Thu, 11 Nov 2021 16:35:49 +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 550851819AC1; Thu, 11 Nov 2021 16:35:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ABGZkOk013707 for ; Thu, 11 Nov 2021 11:35:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id EB9E119D9D; Thu, 11 Nov 2021 16:35:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.194.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FE8A19C59; Thu, 11 Nov 2021 16:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636648632; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tlIzh7r+Xtxep82UAZTGho3w1hzlqKJH0FXUtkdM6Vs=; b=ZcW/7LysfXoKC7E+U7Pq4dy45f4B1EtmYLJ5xHJixU2DwK3xEKdQzNW7BuBunFtFWJ3v8I byJ4aT0ouc18uvRDcynQKPr+OQll2XOuTRYQ9Xa5DCg3kYqm9IvZ9Fs/qUZYvGa31XhEO7 k3wpCu28By0CVSYV9PK0zDsBEW8brE4= X-MC-Unique: OjsnuKkXNV-yqXUQqqCHXw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] conf: add helper for comparing virDomainAudioDef objects Date: Thu, 11 Nov 2021 16:35:42 +0000 Message-Id: <20211111163543.1652878-2-berrange@redhat.com> In-Reply-To: <20211111163543.1652878-1-berrange@redhat.com> References: <20211111163543.1652878-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636648634866100001 It is useful to be able to deeply check them for equality. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/conf/domain_conf.c | 144 +++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 + src/libvirt_private.syms | 1 + 3 files changed, 148 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index da0c64b460..f919d3f7a0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29842,6 +29842,150 @@ virDomainAudioIOCommonIsSet(virDomainAudioIOCommo= n *common) common->bufferLength; } =20 + +static bool +virDomainAudioIOCommonIsEqual(virDomainAudioIOCommon *this, + virDomainAudioIOCommon *that) +{ + return this->mixingEngine =3D=3D that->mixingEngine && + this->fixedSettings =3D=3D that->fixedSettings && + this->frequency =3D=3D that->frequency && + this->channels =3D=3D that->channels && + this->voices =3D=3D that->voices && + this->format =3D=3D that->format && + this->bufferLength =3D=3D that->bufferLength; +} + +static bool +virDomainAudioIOALSAIsEqual(virDomainAudioIOALSA *this, + virDomainAudioIOALSA *that) +{ + return STREQ_NULLABLE(this->dev, that->dev); +} + +static bool +virDomainAudioIOCoreAudioIsEqual(virDomainAudioIOCoreAudio *this, + virDomainAudioIOCoreAudio *that) +{ + return this->bufferCount =3D=3D that->bufferCount; +} + +static bool +virDomainAudioIOJackIsEqual(virDomainAudioIOJack *this, + virDomainAudioIOJack *that) +{ + return STREQ_NULLABLE(this->serverName, that->serverName) && + STREQ_NULLABLE(this->clientName, that->clientName) && + STREQ_NULLABLE(this->connectPorts, that->connectPorts) && + this->exactName =3D=3D that->exactName; +} + +static bool +virDomainAudioIOOSSIsEqual(virDomainAudioIOOSS *this, + virDomainAudioIOOSS *that) +{ + return STREQ_NULLABLE(this->dev, that->dev) && + this->bufferCount =3D=3D that->bufferCount && + this->tryPoll =3D=3D that->tryPoll; +} + +static bool +virDomainAudioIOPulseAudioIsEqual(virDomainAudioIOPulseAudio *this, + virDomainAudioIOPulseAudio *that) +{ + return STREQ_NULLABLE(this->name, that->name) && + STREQ_NULLABLE(this->streamName, that->streamName) && + this->latency =3D=3D that->latency; +} + +static bool +virDomainAudioIOSDLIsEqual(virDomainAudioIOSDL *this, + virDomainAudioIOSDL *that) +{ + return this->bufferCount =3D=3D that->bufferCount; +} + + +static bool +virDomainAudioBackendIsEqual(virDomainAudioDef *this, + virDomainAudioDef *that) +{ + if (this->type !=3D that->type) + return false; + + switch (this->type) { + case VIR_DOMAIN_AUDIO_TYPE_NONE: + return true; + + case VIR_DOMAIN_AUDIO_TYPE_ALSA: + return virDomainAudioIOALSAIsEqual(&this->backend.alsa.input, + &that->backend.alsa.input) && + virDomainAudioIOALSAIsEqual(&this->backend.alsa.output, + &that->backend.alsa.output); + + case VIR_DOMAIN_AUDIO_TYPE_COREAUDIO: + return virDomainAudioIOCoreAudioIsEqual(&this->backend.coreaudio.i= nput, + &that->backend.coreaudio.i= nput) && + virDomainAudioIOCoreAudioIsEqual(&this->backend.coreaudio.outp= ut, + &that->backend.coreaudio.outp= ut); + + case VIR_DOMAIN_AUDIO_TYPE_JACK: + return virDomainAudioIOJackIsEqual(&this->backend.jack.input, + &that->backend.jack.input) && + virDomainAudioIOJackIsEqual(&this->backend.jack.output, + &that->backend.jack.output); + + case VIR_DOMAIN_AUDIO_TYPE_OSS: + return virDomainAudioIOOSSIsEqual(&this->backend.oss.input, + &that->backend.oss.input) && + virDomainAudioIOOSSIsEqual(&this->backend.oss.output, + &that->backend.oss.output) && + this->backend.oss.tryMMap =3D=3D that->backend.oss.tryMMap && + this->backend.oss.exclusive =3D=3D that->backend.oss.exclusive= && + this->backend.oss.dspPolicySet =3D=3D that->backend.oss.dspPol= icySet && + this->backend.oss.dspPolicy =3D=3D that->backend.oss.dspPolicy; + + case VIR_DOMAIN_AUDIO_TYPE_PULSEAUDIO: + return virDomainAudioIOPulseAudioIsEqual(&this->backend.pulseaudio= .input, + &that->backend.pulseaudio= .input) && + virDomainAudioIOPulseAudioIsEqual(&this->backend.pulseaudio.ou= tput, + &that->backend.pulseaudio.ou= tput) && + STREQ_NULLABLE(this->backend.pulseaudio.serverName, + that->backend.pulseaudio.serverName); + + case VIR_DOMAIN_AUDIO_TYPE_SDL: + return virDomainAudioIOSDLIsEqual(&this->backend.sdl.input, + &that->backend.sdl.input) && + virDomainAudioIOSDLIsEqual(&this->backend.sdl.output, + &that->backend.sdl.output) && + this->backend.sdl.driver =3D=3D that->backend.sdl.driver; + + case VIR_DOMAIN_AUDIO_TYPE_SPICE: + return true; + + case VIR_DOMAIN_AUDIO_TYPE_FILE: + return STREQ_NULLABLE(this->backend.file.path, that->backend.file.= path); + + case VIR_DOMAIN_AUDIO_TYPE_LAST: + default: + return false; + } +} + + +bool +virDomainAudioIsEqual(virDomainAudioDef *this, + virDomainAudioDef *that) +{ + return this->type =3D=3D that->type && + this->id =3D=3D that->id && + this->timerPeriod =3D=3D that->timerPeriod && + virDomainAudioIOCommonIsEqual(&this->input, &that->input) && + virDomainAudioIOCommonIsEqual(&this->output, &that->output) && + virDomainAudioBackendIsEqual(this, that); +} + + char * virDomainObjGetMetadata(virDomainObj *vm, int type, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ab9a7d66f8..cf880ccb3c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4015,6 +4015,9 @@ bool virDomainSoundModelSupportsCodecs(virDomainSoundDef *def); bool virDomainAudioIOCommonIsSet(virDomainAudioIOCommon *common); +bool +virDomainAudioIsEqual(virDomainAudioDef *this, + virDomainAudioDef *that); =20 const char *virDomainChrSourceDefGetPath(virDomainChrSourceDef *chr); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9ee8fda25f..a369d9c113 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -231,6 +231,7 @@ virDomainAudioDefFree; virDomainAudioFormatTypeFromString; virDomainAudioFormatTypeToString; virDomainAudioIOCommonIsSet; +virDomainAudioIsEqual; virDomainAudioSDLDriverTypeFromString; virDomainAudioSDLDriverTypeToString; virDomainAudioTypeTypeFromString; --=20 2.31.1