From nobody Mon Feb 9 23:44:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1636648560; cv=none; d=zohomail.com; s=zohoarc; b=YOT3L/oY0kW7U2YSz0Bl26ZXfQfQxozWc3zTq2xDKUqZzbYpJEjUfYFsbGWm7dt/9FALnbcWppRXN8g6jKzERPmLLtfncWwwiH8Iv25cQ0fDLFIjWDzkHUhB3DpUDbuERpnTfVOkgi8cL27rwWyzP/o/dSmYpKngzVhn3yuqekM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636648560; 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=hcsOdbA1w+20IRG/hsHC9n9PObEUEAHfN+oYVHOb7Po=; b=kS1M+Evo2Cxj/yOIQSpC3+Y+OS4Z5q1WFV0WGmu2bXYQNLnwkKcMobplq8Scwgxpchx9qLSk9KdLYthDy5fWrcc1xL96E6iS7dH02OcH4VPpzxLIj3dvaDThcrKQaxEKUukUCE+6tZVpyhdDCIH2MQlbGJM/e0YUn0j4E53YWiY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636648560700665.618437356047; Thu, 11 Nov 2021 08:36:00 -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-457-Hp53dLTvOPmlTLoCrZzY_A-1; Thu, 11 Nov 2021 11:35:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37E90100B790; Thu, 11 Nov 2021 16:35:50 +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 18A075DF56; Thu, 11 Nov 2021 16:35:50 +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 DFA581832DD4; Thu, 11 Nov 2021 16:35:49 +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 1ABGZmIf013717 for ; Thu, 11 Nov 2021 11:35:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 19BA819D9D; Thu, 11 Nov 2021 16:35:48 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.194.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47FE419C59; Thu, 11 Nov 2021 16:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636648558; 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=hcsOdbA1w+20IRG/hsHC9n9PObEUEAHfN+oYVHOb7Po=; b=aCAuvyzxnPOQZPB+2EMLg4K0a0yTD2dYbRHvFSLIV753fD9w14WpxqZ08TTm32yN4m6caG +aacVf6zJu8pEzqK1iymRue3gNXFWRTPcL0+YdNE7NyG8WU1YZws8+sdjmxUXApVP2BSi5 0I78hlZw9HSOJt3QL6RUpryFwGZmbWs= X-MC-Unique: Hp53dLTvOPmlTLoCrZzY_A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] qemu: don't strip audio elements with user config present Date: Thu, 11 Nov 2021 16:35:43 +0000 Message-Id: <20211111163543.1652878-3-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.14 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: 1636648562712100003 To support backwards live migration we must strip the default added audio element, however, we are too aggressive in doing so. We are only comparing a couple of attributes for equality, so risk stripping config that was user customized. To improve this we need to a deep comparison of the audio config. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 72 +++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fb203bc830..ef0a08d405 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3507,17 +3507,15 @@ qemuDomainDefSuggestDefaultAudioBackend(virQEMUDriv= er *driver, } =20 static int -qemuDomainDefClearDefaultAudioBackend(virQEMUDriver *driver, - virDomainDef *def) +qemuDomainDefCreateDefaultAudioBackend(virQEMUDriver *driver, + virDomainDef *def, + virDomainAudioDef **audioout) { bool addAudio; int audioBackend; int audioSDLDriver; - virDomainAudioDef *audio; =20 - if (def->naudios !=3D 1) { - return 0; - } + *audioout =3D NULL; =20 if (qemuDomainDefSuggestDefaultAudioBackend(driver, def, @@ -3526,21 +3524,45 @@ qemuDomainDefClearDefaultAudioBackend(virQEMUDriver= *driver, &audioSDLDriver) < 0) return -1; =20 - if (!addAudio) - return 0; + if (addAudio) { + virDomainAudioDef *audio =3D g_new0(virDomainAudioDef, 1); + + audio->type =3D audioBackend; + audio->id =3D 1; =20 - audio =3D def->audios[0]; - if (audio->type !=3D audioBackend) + if (audioBackend =3D=3D VIR_DOMAIN_AUDIO_TYPE_SDL) + audio->backend.sdl.driver =3D audioSDLDriver; + + *audioout =3D audio; + } + + return 0; +} + + +static int +qemuDomainDefClearDefaultAudioBackend(virQEMUDriver *driver, + virDomainDef *def) +{ + virDomainAudioDef *audio =3D NULL; + + if (def->naudios !=3D 1) { return 0; + } =20 - if (audio->type =3D=3D VIR_DOMAIN_AUDIO_TYPE_SDL && - audio->backend.sdl.driver !=3D audioSDLDriver) + if (qemuDomainDefCreateDefaultAudioBackend(driver, def, &audio) < 0) + return -1; + + if (!audio) return 0; =20 + if (virDomainAudioIsEqual(def->audios[0], audio)) { + virDomainAudioDefFree(def->audios[0]); + g_free(def->audios); + def->naudios =3D 0; + def->audios =3D NULL; + } virDomainAudioDefFree(audio); - g_free(def->audios); - def->naudios =3D 0; - def->audios =3D NULL; =20 return 0; } @@ -3549,33 +3571,19 @@ static int qemuDomainDefAddDefaultAudioBackend(virQEMUDriver *driver, virDomainDef *def) { - bool addAudio; - int audioBackend; - int audioSDLDriver; + virDomainAudioDef *audio; =20 if (def->naudios > 0) { return 0; } =20 - if (qemuDomainDefSuggestDefaultAudioBackend(driver, - def, - &addAudio, - &audioBackend, - &audioSDLDriver) < 0) + if (qemuDomainDefCreateDefaultAudioBackend(driver, def, &audio) < 0) return -1; =20 - if (addAudio) { - virDomainAudioDef *audio =3D g_new0(virDomainAudioDef, 1); - - audio->type =3D audioBackend; - audio->id =3D 1; - + if (audio) { def->naudios =3D 1; def->audios =3D g_new0(virDomainAudioDef *, def->naudios); def->audios[0] =3D audio; - - if (audioBackend =3D=3D VIR_DOMAIN_AUDIO_TYPE_SDL) - audio->backend.sdl.driver =3D audioSDLDriver; } =20 return 0; --=20 2.31.1