From nobody Tue Dec 16 07:33:18 2025 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=1650874951; cv=none; d=zohomail.com; s=zohoarc; b=JR7a4KEWGx3XhQsDOuEZqAbpGAWql6QVxT3EvmmIRXSMn/F0lYGz7iVTBnmW/cCNhb+fj/d4MZgDAfVqhklkYMIHzJbmtM7KRTvdcvYooSWUUGipmGa81sISqtn57Ykg+YAmQ93Ufh2yg63ELfeG5khnfTu7TKc9XYj6LuolT58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650874951; 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=FhQkwseUjLTHOIhK75umw1DiZK4WT0Kj4VwxUvLlvB0=; b=Y1+Tfth8+K7c7kSIvxS0m5UiqQaEgKTT7tRc6/VVZOKvn+r5HpLo/TjBPMmigaCM992TGdzEVNOX8UVe24DMaUPaxY8ZZlWfc5uJooPbs80IryZtQ2dMiTrThqUlIh6cvzpG/Ixlk7Po7s2IVSD6UzHopnqk888H579wBhF/vss= 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 1650874951705366.0636124021943; Mon, 25 Apr 2022 01:22:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-ZCzrO6ZCM7CPJj1rxCfM_Q-1; Mon, 25 Apr 2022 04:22:24 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87E751014A99; Mon, 25 Apr 2022 08:22:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 712D5416148; Mon, 25 Apr 2022 08:22:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 45F29193F6EE; Mon, 25 Apr 2022 08:22:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6EB131947BBE for ; Mon, 25 Apr 2022 08:22:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4F8BE1468F22; Mon, 25 Apr 2022 08:22:11 +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 4B55B1468F35 for ; Mon, 25 Apr 2022 08:22:11 +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 295D2803D65 for ; Mon, 25 Apr 2022 08:22:11 +0000 (UTC) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-5k2DCatlOZCNww2qXRpYsg-1; Mon, 25 Apr 2022 04:22:07 -0400 Received: by mail-wm1-f69.google.com with SMTP id k66-20020a1ca145000000b003928959f8efso5510011wme.1 for ; Mon, 25 Apr 2022 01:22:07 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id i6-20020a0560001ac600b0020a93f75030sm8609662wry.48.2022.04.25.01.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 01:22:05 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 84EB767B1B64; Mon, 25 Apr 2022 10:22:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650874950; 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=FhQkwseUjLTHOIhK75umw1DiZK4WT0Kj4VwxUvLlvB0=; b=LVmC2cYlK8vVN6DK6qPWjoXm0Mwzuzru3i/8zcumCROVIJl9FHV6t1wDsJ5LC34FlZpTBu D2jPJCQL6inR/2LzN02zIqYNc0l5lzBHMgjBPnfUQ0wk5wQd1mt0hevYJ8A7EJPxOfzFi3 syqFdCNILnwlgbsgcxRhUHRBveFfP3s= X-MC-Unique: ZCzrO6ZCM7CPJj1rxCfM_Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 5k2DCatlOZCNww2qXRpYsg-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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FhQkwseUjLTHOIhK75umw1DiZK4WT0Kj4VwxUvLlvB0=; b=jhM9izCsuErwEkeJZA2jT04N/h7G1pSUTB/sc5kti28TP011f/rk6DztoNW2uVO1ur lysus8KW3AHkxMXOv27tGFBlnvitlzk/8FBKfDjTx8vsB0NJv5n6c0pF9QypQ71PymXV 77cC2UMzur4W8pGoOUVHlmX/Yliw75kS5M4PVn4Kv0JJdN4b6mI0WDnSF2DAC2Sk37nY k0FxckXhuJscXUF6psTWkTWRl0KJy/cl6KHUCM9RewshMWEqvHLmHGMhoZcS6PN9oFUm Nuic4WlrB0o5BIpTVZn34oRIz8LeaDgU9yj929Axtypnh0QNhMDf1r/02iXFvaWp0KsT FZqQ== X-Gm-Message-State: AOAM533TDj85w7N/RL6c3NY41Tdh3ixWFMRX+WJgvoG0bRvlJeygq+o2 wRlyY8cfqCoy0H4QmjxTQqnZy5dwul4yZKEM7llDe04lWwbYB1uacfZhSO2sHr9OQ3Qm9kN0w1K QVU49q8RBUgY6SuDKivk= X-Received: by 2002:a05:600c:21d1:b0:381:4fed:159a with SMTP id x17-20020a05600c21d100b003814fed159amr15601985wmj.143.1650874926493; Mon, 25 Apr 2022 01:22:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/3dRybdDZDRPKfC75dqpdz6R++AejA2+IGjo2roCm92HFyDce4aP6XDzA5ArkFmkvTb/YyA== X-Received: by 2002:a05:600c:21d1:b0:381:4fed:159a with SMTP id x17-20020a05600c21d100b003814fed159amr15601961wmj.143.1650874926243; Mon, 25 Apr 2022 01:22:06 -0700 (PDT) From: Martin Kletzander To: qemu-devel@nongnu.org Subject: [PATCH 15/18] audio: Be more strict during audio backend initialisation Date: Mon, 25 Apr 2022 10:21:58 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , libvir-list@redhat.com, Christian Schoenebeck , Yanan Wang , Gerd Hoffmann , "Edgar E. Iglesias" , Qiuhao Li , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Marcel Apfelbaum , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Thomas Huth , Alistair Francis , Alexander Bulekov , Bandan Das , qemu-arm@nongnu.org, Jan Kiszka , Pavel Dovgalyuk , Eduardo Habkost , Darren Kenny , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1650874973688100012 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that audiodev=3D is required and audio_init() will not be called without and AudioDev we can remove the fallback functionality and error out in case audio drivers fail initialisation or when the driver does not exist. Signed-off-by: Martin Kletzander --- audio/audio.c | 146 ++++++-------------------------- docs/about/deprecated.rst | 8 -- docs/about/removed-features.rst | 8 ++ 3 files changed, 34 insertions(+), 128 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 97eb645764c1..c944cf817cf9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -87,6 +87,8 @@ audio_driver *audio_driver_lookup(const char *name) } } =20 + error_setg(&error_fatal, "Unknown audio driver `%s'", name); + /* Avoid compiler complaining that we do not return in non-void functi= on */ return NULL; } =20 @@ -104,8 +106,6 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 -static bool legacy_config =3D true; - int audio_bug (const char *funcname, int cond) { if (cond) { @@ -1532,31 +1532,27 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf,= size_t size) return total; } =20 -static int audio_driver_init(AudioState *s, struct audio_driver *drv, - bool msg, Audiodev *dev) +static void audio_driver_init(AudioState *s, struct audio_driver *drv, + Audiodev *dev) { s->drv_opaque =3D drv->init(dev); =20 - if (s->drv_opaque) { - if (!drv->pcm_ops->get_buffer_in) { - drv->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; - drv->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; - } - if (!drv->pcm_ops->get_buffer_out) { - drv->pcm_ops->get_buffer_out =3D audio_generic_get_buffer_out; - drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; - } + if (!s->drv_opaque) { + error_setg(&error_fatal, "Could not init `%s' audio driver", drv->= name); + } =20 - audio_init_nb_voices_out(s, drv); - audio_init_nb_voices_in(s, drv); - s->drv =3D drv; - return 0; - } else { - if (msg) { - dolog("Could not init `%s' audio driver\n", drv->name); - } - return -1; + if (!drv->pcm_ops->get_buffer_in) { + drv->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; + drv->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; } + if (!drv->pcm_ops->get_buffer_out) { + drv->pcm_ops->get_buffer_out =3D audio_generic_get_buffer_out; + drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; + } + + audio_init_nb_voices_out(s, drv); + audio_init_nb_voices_in(s, drv); + s->drv =3D drv; } =20 static void audio_vm_change_state_handler (void *opaque, bool running, @@ -1661,79 +1657,19 @@ static const VMStateDescription vmstate_audio =3D { =20 static void audio_validate_opts(Audiodev *dev, Error **errp); =20 -static AudiodevListEntry *audiodev_find( - AudiodevListHead *head, const char *drvname) -{ - AudiodevListEntry *e; - QSIMPLEQ_FOREACH(e, head, next) { - if (strcmp(AudiodevDriver_str(e->dev->driver), drvname) =3D=3D 0) { - return e; - } - } - - return NULL; -} - -/* - * if we have dev, this function was called because of an -audiodev argume= nt =3D> - * initialize a new state with it - * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created - * state or create a new one - */ -static AudioState *audio_init(Audiodev *dev, const char *name) +static AudioState *audio_init(Audiodev *dev) { static bool atexit_registered; - size_t i; - int done =3D 0; const char *drvname =3D NULL; VMChangeStateEntry *e; AudioState *s; - struct audio_driver *driver; - /* silence gcc warning about uninitialized variable */ - AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); - - if (using_spice) { - /* - * When using spice allow the spice audio driver being picked - * as default. - * - * Temporary hack. Using audio devices without explicit - * audiodev=3D property is already deprecated. Same goes for - * the -soundhw switch. Once this support gets finally - * removed we can also drop the concept of a default audio - * backend and this can go away. - */ - driver =3D audio_driver_lookup("spice"); - if (driver) { - driver->can_be_default =3D 1; - } - } =20 - if (dev) { - /* -audiodev option */ - legacy_config =3D false; - drvname =3D AudiodevDriver_str(dev->driver); - } else if (!QTAILQ_EMPTY(&audio_states)) { - if (!legacy_config) { - dolog("Device %s: audiodev default parameter is deprecated, pl= ease " - "specify audiodev=3D%s\n", name, - QTAILQ_FIRST(&audio_states)->dev->id); - } - return QTAILQ_FIRST(&audio_states); - } else { - /* legacy implicit initialization */ - head =3D audio_handle_legacy_opts(); - /* - * In case of legacy initialization, all Audiodevs in the list wil= l have - * the same configuration (except the driver), so it doesn't matte= r which - * one we chose. We need an Audiodev to set up AudioState before = we can - * init a driver. Also note that dev at this point is still in the - * list. - */ - dev =3D QSIMPLEQ_FIRST(&head)->dev; - audio_validate_opts(dev, &error_abort); + if (!dev) { + error_setg(&error_abort, "Mandatory audiodev parameter required"); } =20 + drvname =3D AudiodevDriver_str(dev->driver); + s =3D g_new0(AudioState, 1); s->dev =3D dev; =20 @@ -1763,37 +1699,7 @@ static AudioState *audio_init(Audiodev *dev, const c= har *name) s->nb_hw_voices_in =3D 0; } =20 - if (drvname) { - driver =3D audio_driver_lookup(drvname); - if (driver) { - done =3D !audio_driver_init(s, driver, true, dev); - } else { - dolog ("Unknown audio driver `%s'\n", drvname); - } - } else { - for (i =3D 0; audio_prio_list[i]; i++) { - AudiodevListEntry *e =3D audiodev_find(&head, audio_prio_list[= i]); - driver =3D audio_driver_lookup(audio_prio_list[i]); - - if (e && driver) { - s->dev =3D dev =3D e->dev; - audio_validate_opts(dev, &error_abort); - done =3D !audio_driver_init(s, driver, false, dev); - if (done) { - e->dev =3D NULL; - break; - } - } - } - } - audio_free_audiodev_list(&head); - - if (!done) { - driver =3D audio_driver_lookup("none"); - done =3D !audio_driver_init(s, driver, false, dev); - assert(done); - dolog("warning: Using timer based audio emulation\n"); - } + audio_driver_init(s, audio_driver_lookup(drvname), dev); =20 if (dev->timer_period <=3D 0) { s->period_ticks =3D 1; @@ -2120,7 +2026,7 @@ void audio_init_audiodevs(void) AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev, NULL); + audio_init(e->dev); } } =20 @@ -2133,7 +2039,7 @@ static void audio_init_dummy(const char *id) dev->id =3D g_strdup(id); =20 audio_validate_opts(dev, &error_abort); - audio_init(dev, NULL); + audio_init(dev); =20 e->dev =3D dev; QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 7ba71ebd3435..b2255319e347 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -31,14 +31,6 @@ backend settings instead of environment variables. To e= ase migration to the new format, the ``-audiodev-help`` option can be used to convert the current values of the environment variables to ``-audiodev`` options. =20 -Creating sound card devices and vnc without ``audiodev=3D`` property (sinc= e 4.2) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''= '''' - -When not using the deprecated legacy audio config, each sound card -should specify an ``audiodev=3D`` property. Additionally, when using -vnc, you should specify an ``audiodev=3D`` property if you plan to -transmit audio through the VNC protocol. - ``-chardev`` backend aliases ``tty`` and ``parport`` (since 6.0) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 086ba3edb042..f9eea4dda327 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -346,6 +346,14 @@ needs two devices (``-device intel-hda -device hda-dup= lex``) and pcspk-audiodev=3D``. And ``AC97`` and ``ES1370`` now have to be specified in uppercase. =20 +Creating sound card devices and vnc without ``audiodev=3D`` property (remo= ved in 7.1) +''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''= ''''''''' + +When not using the deprecated legacy audio config, each sound card +should specify an ``audiodev=3D`` property. Additionally, when using +vnc, you should specify an ``audiodev=3D`` property if you plan to +transmit audio through the VNC protocol. + =20 QEMU Machine Protocol (QMP) commands ------------------------------------ --=20 2.35.1