From nobody Tue Dec 16 07:33:20 2025 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=1650874946; cv=none; d=zohomail.com; s=zohoarc; b=HocSWyD+vlQNKLRtccAfaANydUkr8TTxxBxqIToHRTjW0aFLrck9KCgAdfgqsAm/RP+Y6BJg4hp/7QIMOTXhbo0L8uup+fB1LNZyrRnRAU3cZDJBWTrdp39xWJDjcAWB5lTBGUa5fFoSTXtmo0kpXGwD2cyu9PhBXu1heISndhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650874946; 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=PAZUwc5ZqVj8eUHH2Oe1Tiz0RIqORJb8+QvvQ1BqMLI=; b=BjMmGOW6WMwj7s7ha6u8QarFhHSTZDa9j8pNoUo+dr1zEpKxoD6w899MM9Y7KCXg6XKBADBphPHEEa/4FPUG4imSll1tXYzQWT1nm8paD3rk4hD1SZVYEkz008/sQ951UNU03759HjOsEcoFp+YqH/qEmCFyr6COe1XEnAkcLOA= 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 1650874946433312.4081709777389; Mon, 25 Apr 2022 01:22:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-4lPjBJSUP4CuhHia4D7nfw-1; Mon, 25 Apr 2022 04:22:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 466B41C05EAA; Mon, 25 Apr 2022 08:22:14 +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 3245A40D0186; Mon, 25 Apr 2022 08:22:14 +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 6FDD01940373; Mon, 25 Apr 2022 08:22:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BEDAB194036C for ; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9E7BA40316B; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A86440314F for ; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 7EACA29AB45A for ; Mon, 25 Apr 2022 08:22:08 +0000 (UTC) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-53-_b1yJ-5EN0KeiD-fHbYD3Q-1; Mon, 25 Apr 2022 04:22:06 -0400 Received: by mail-wm1-f72.google.com with SMTP id h65-20020a1c2144000000b0038e9ce3b29cso9970923wmh.2 for ; Mon, 25 Apr 2022 01:22:05 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g13-20020a5d64ed000000b0020a9e488976sm8952474wri.25.2022.04.25.01.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 01:22:04 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 40E2E67B1B5D; 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=1650874945; 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=PAZUwc5ZqVj8eUHH2Oe1Tiz0RIqORJb8+QvvQ1BqMLI=; b=RdDtYxFwUQ0JgL8kWcrZaoqlX28NFq8VdIkA7JgGWf8lrAsbmoqGU3eortQCN5GnAXQbDc +RSOB5xXmanXp9LqbLi9C3nOokcMowiHSLNwUD8PhE+gG1FG2+zGiHOpe7GyPfi1Duvwjg EMK0VUdLNdPqzlp/xYCAIOtYEI8485E= X-MC-Unique: 4lPjBJSUP4CuhHia4D7nfw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: _b1yJ-5EN0KeiD-fHbYD3Q-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=PAZUwc5ZqVj8eUHH2Oe1Tiz0RIqORJb8+QvvQ1BqMLI=; b=lTxD4TJiCNTcxixWQQiQ4eEow+BFX+EGwQFL3UA4APMbKvBgJ9Fpf9xjPw6sjExP+H gL2F+qW1GtucGV9QMncCZT+eCkttYA5FDcSz3FWb7gcqPjBkvwoZQiwPBd/JGPNBLINK iP7Z1g7AxHiPWn+WjqNykmoZarOWizYeVwcdHW2qn0vZL7eN1eFilkIfVvnByzZX4w7e 0ttrhm65lr4cFTcOoYMka/z+N4kOsJ6dfRv4h/q0UoJVz5g1fpxjWeTN/ox7Mlxc/Y5r fxWvKE4L3hjvApvsPXug+e7CziCxqXcB7JYlLEzVgh5cHhmwSyoJC+FVovyYhMPCm9fZ UfaA== X-Gm-Message-State: AOAM531DIqcFoegN1Lh6PfT3+wMZiaXeqb6gZrujw2nQh6f2tGVUgIa2 xKilVFR7h6HnGRen9X47krYes93K82VB+nVYzb/0NYOFqrxqkd/ChCnux5pVTjg7/bnhJ+VcR3A dvZse8YaOz9+tcQ48P9Q= X-Received: by 2002:a5d:47a4:0:b0:20a:c95e:b3f3 with SMTP id 4-20020a5d47a4000000b0020ac95eb3f3mr12086553wrb.663.1650874924929; Mon, 25 Apr 2022 01:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9AN3DTpD4mNyWicCScIo/ePV7PEwSCtTlMYdcy2N7R8rIsAaI7dxGdpvi0OKSlN4jAW/JFA== X-Received: by 2002:a5d:47a4:0:b0:20a:c95e:b3f3 with SMTP id 4-20020a5d47a4000000b0020ac95eb3f3mr12086529wrb.663.1650874924731; Mon, 25 Apr 2022 01:22:04 -0700 (PDT) From: Martin Kletzander To: qemu-devel@nongnu.org Subject: [PATCH 08/18] audio: Add easy dummy audio initialiser Date: Mon, 25 Apr 2022 10:21:51 +0200 Message-Id: <7b0a067b8b0a32ef7ec7c040d1e79d40a9a6b0de.1650874791.git.mkletzan@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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.84 on 10.11.54.1 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: 1650874973253100008 Content-Type: text/plain; charset="utf-8"; x-default="true" In case of sound devices which are created by default (some of them even wi= th -nodefaults) it would not be nice to users if qemu required explicit: -audiodev driver=3Dnone,id=3Daudio0 -machine default-audiodev=3Daudio0 when they just want to run a VM and not care about any audio output. Inste= ad this little helper makes it easy to create a dummy audiodev (driver=3Dnone)= in case there is no default-audiodev specified for the machine. To make sure = users are not surprised by no sound output a helping message is also printed out. Signed-off-by: Martin Kletzander --- audio/audio.c | 34 ++++++++++++++++++++++++++++++++++ audio/audio.h | 2 ++ 2 files changed, 36 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 9e91a5a4f2b8..671845c65d18 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -37,6 +37,7 @@ #include "sysemu/runstate.h" #include "ui/qemu-spice.h" #include "trace.h" +#include "hw/boards.h" =20 #define AUDIO_CAP "audio" #include "audio_int.h" @@ -2122,6 +2123,39 @@ void audio_init_audiodevs(void) } } =20 +static void audio_init_dummy(const char *id) +{ + Audiodev *dev =3D g_new0(Audiodev, 1); + AudiodevListEntry *e =3D g_new0(AudiodevListEntry, 1); + + dev->driver =3D AUDIODEV_DRIVER_NONE; + dev->id =3D g_strdup(id); + + audio_validate_opts(dev, &error_abort); + audio_init(dev, NULL); + + e->dev =3D dev; + QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); +} + +const char *audio_maybe_init_dummy(const char *default_id) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + + if (ms->default_audiodev) { + return ms->default_audiodev; + } + + dolog("warning: No audiodev specified for implicit machine devices, " + "no audio output will be available for these. " + "For setting a backend audiodev for such devices try using " + "the default-audiodev machine option.\n"); + + audio_init_dummy(default_id); + + return default_id; +} + audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) { return (audsettings) { diff --git a/audio/audio.h b/audio/audio.h index 3d5ecdecd5c1..335704a4ddb1 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -175,6 +175,8 @@ void audio_legacy_help(void); AudioState *audio_state_by_name(const char *name); const char *audio_get_id(QEMUSoundCard *card); =20 +const char *audio_maybe_init_dummy(const char *default_id); + #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) =20 --=20 2.35.1