From nobody Tue Feb 10 19:23:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696510831; cv=none; d=zohomail.com; s=zohoarc; b=XQ8zRsOOi5CJ1JKC5n8eSOLN1+lmnH7ckHdjy9TSSp/80nNoXtY31t9uzeWv2YeOQ6h9vxEfkj+eDMis+6R/SzagqGSIw/TXUdcrgpbpJPrXNCSc6Ur6EMe3a/Yu23hiKsUZw2giTcjZpvXcqZJNPzXfy19VkGwljJiobZbpDvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696510831; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+UN/2lHlsKjyWdODn3no2MX1PZjTG24Zr1xY9Gvy6c0=; b=G/GI9qQjGZ6YisR915GQpY2kkAmQrRJwajipNl1iRB/HGXj/JBhUdmwTzZ62BtyU/YQ/lp+wBER3tCUXHxMzpS5OCZErc15TfLSWkiPSY1OfoCcxAPVxYkfFZs/w02xKjFIHJ8CfYtkmMHo0hivni2JP5brb+p9E9SG9Pk0ZByE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696510831599673.9046119144155; Thu, 5 Oct 2023 06:00:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoNwX-0000AM-3G; Thu, 05 Oct 2023 08:59:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoNwL-0008K8-RE for qemu-devel@nongnu.org; Thu, 05 Oct 2023 08:58:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoNwC-0007m9-24 for qemu-devel@nongnu.org; Thu, 05 Oct 2023 08:58:49 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-_YVPUlBbM-SCEoQp2fbD0w-1; Thu, 05 Oct 2023 08:58:26 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9b274cc9636so87712766b.0 for ; Thu, 05 Oct 2023 05:58:25 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id h13-20020a17090619cd00b009ae587ce135sm1151954ejd.223.2023.10.05.05.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 05:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696510721; h=from:from: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; bh=+UN/2lHlsKjyWdODn3no2MX1PZjTG24Zr1xY9Gvy6c0=; b=MEjEIujan8WNARpv6MJ3bm/LPQlgsm4g60ezwxfqjpFWsypOrVj+95EdnKLDTKeqS3FyyL lFW+YAu2E9YDBnU9KTUCdzmz1S8ZD376i8sB/JRRF/+MLQXjp6vM07eUZTYmlXIztlp1w3 GvbdfjblG4LqmsFEmI4oOZUpe88yL/k= X-MC-Unique: _YVPUlBbM-SCEoQp2fbD0w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696510704; x=1697115504; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+UN/2lHlsKjyWdODn3no2MX1PZjTG24Zr1xY9Gvy6c0=; b=i4GxSqnA3elcJVHpJrlHXA6GJkev+eAMoMCJmySywD2XBFwNL0i8veMWEErh/xni4k KsDc2Ffx3mHabbBCpdIG4fgvAhbblVbCiPFQPDSHqZEo7wDzkCTgWJ9Ztc9zVskBG62o nPmaymdFFbT4YULEH0ia3PNFPrIWlO6kXCHSmMn3p3o7M7JpaBmUIs2U3NAs40NEFmgo gJUpNIkEpYD0ShHotEZCDUZ255q40b7dwPeK3Ga43iJLhdZVoxu2KLb4YHYLV9CG1o4g LiNxIu6f3eTZvj9aycLEVVzfMmo5UG77SlLQp120pxudJUYj68MHuMFWdA+suS1Ub4hx qcyw== X-Gm-Message-State: AOJu0YxzGTDoIUTHtrOJ0Sqw4Vut/xPae74yPTbUMge7qRxlemsGtJYe C17J4g49zPJUxNp/Rdv/qzB74EOhIFeSU60fEVVLFqvM+c9tWk4bsx58FcCfMRtOVOVNYOuRTU8 jejUgJBrc/ZZx4mvObyOGHGviOf55KqzcbiFogQpRfCkIMxZqYphq1s4/6BX28oM32RUxHyduC8 Y= X-Received: by 2002:a17:906:100e:b0:9b3:47f:1c05 with SMTP id 14-20020a170906100e00b009b3047f1c05mr4125878ejm.64.1696510704472; Thu, 05 Oct 2023 05:58:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEi5UjYnfBhF4whb5VPv8Bo4zvw4BHKefSFmcl0MZUMlX3uggQVSnNkVjFEMxIOIj0/PTnugQ== X-Received: by 2002:a17:906:100e:b0:9b3:47f:1c05 with SMTP id 14-20020a170906100e00b009b3047f1c05mr4125870ejm.64.1696510704184; Thu, 05 Oct 2023 05:58:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: balaton@eik.bme.hu, berrange@redhat.com Subject: [PATCH 4/7] audio: extend -audio to allow creating a default backend Date: Thu, 5 Oct 2023 14:58:12 +0200 Message-ID: <20231005125815.66082-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231005125815.66082-1-pbonzini@redhat.com> References: <20231005125815.66082-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1696510832629100003 Content-Type: text/plain; charset="utf-8" If "-audio BACKEND" is used without a model, the resulting backend will be used whenever the audiodev property is not specified. Signed-off-by: Paolo Bonzini --- qemu-options.hx | 29 +++++++++++++++++++++-------- system/vl.c | 27 +++++++++++++++------------ 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 9ce8a5b9578..5f4c240a1e2 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -728,20 +728,22 @@ ERST =20 =20 DEF("audio", HAS_ARG, QEMU_OPTION_audio, + "-audio [driver=3D]driver[,prop[=3Dvalue][,...]]\n" + " specifies default audio backend when `audiodev` is no= t\n" + " used to create a machine or sound device;" + " options are the same as for -audiodev\n" "-audio [driver=3D]driver,model=3Dvalue[,prop[=3Dvalue][,...]]\n" " specifies the audio backend and device to use;\n" " apart from 'model', options are the same as for -audi= odev.\n" " use '-audio model=3Dhelp' to show possible devices.\n= ", QEMU_ARCH_ALL) SRST -``-audio [driver=3D]driver,model=3Dvalue[,prop[=3Dvalue][,...]]`` - This option is a shortcut for configuring both the guest audio - hardware and the host audio backend in one go. - The driver option is the same as with the corresponding ``-audiodev`` = option below. - The guest hardware model can be set with ``model=3Dmodelname``. - - Use ``driver=3Dhelp`` to list the available drivers, - and ``model=3Dhelp`` to list the available device types. +``-audio [driver=3D]driver[,model=3Dvalue][,prop[=3Dvalue][,...]]`` + If the ``model`` option is specified, ``-audio`` is a shortcut + for configuring both the guest audio hardware and the host audio + backend in one go. The guest hardware model can be set with + ``model=3Dmodelname``. Use ``model=3Dhelp`` to list the available + device types. =20 The following two example do exactly the same, to show how ``-audio`` can be used to shorten the command line length: @@ -750,6 +752,17 @@ SRST =20 |qemu_system| -audiodev pa,id=3Dpa -device sb16,audiodev=3Dpa |qemu_system| -audio pa,model=3Dsb16 + + If the ``model`` option is not specified, ``-audio`` is used to + configure a default audio backend that will be used whenever the + ``audiodev`` property is not set on a device or machine. In + particular, ``-audio none`` ensures that no audio is produced even + for machines that have embedded sound hardware. + + In both cases, the driver option is the same as with the corresponding + ``-audiodev`` option below. Use ``driver=3Dhelp`` to list the availab= le + drivers. + ERST =20 DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, diff --git a/system/vl.c b/system/vl.c index 7ca92d4490d..72be5a49764 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2935,7 +2935,7 @@ void qemu_init(int argc, char **argv) break; case QEMU_OPTION_audio: { bool help; - char *model; + char *model =3D NULL; Audiodev *dev =3D NULL; Visitor *v; QDict *dict =3D keyval_parse(optarg, "driver", &help, &err= or_fatal); @@ -2948,22 +2948,25 @@ void qemu_init(int argc, char **argv) if (!qdict_haskey(dict, "id")) { qdict_put_str(dict, "id", "audiodev0"); } - if (!qdict_haskey(dict, "model")) { - error_setg(&error_fatal, "Parameter 'model' is missing= "); - } - model =3D g_strdup(qdict_get_str(dict, "model")); - qdict_del(dict, "model"); - if (is_help_option(model)) { - show_valid_soundhw(); - exit(0); + if (qdict_haskey(dict, "model")) { + model =3D g_strdup(qdict_get_str(dict, "model")); + qdict_del(dict, "model"); + if (is_help_option(model)) { + show_valid_soundhw(); + exit(0); + } } v =3D qobject_input_visitor_new_keyval(QOBJECT(dict)); qobject_unref(dict); visit_type_Audiodev(v, NULL, &dev, &error_fatal); visit_free(v); - audio_define(dev); - select_soundhw(model, dev->id); - g_free(model); + if (model) { + audio_define(dev); + select_soundhw(model, dev->id); + g_free(model); + } else { + audio_define_default(dev, &error_fatal); + } break; } case QEMU_OPTION_h: --=20 2.41.0