From nobody Sun May 19 11:06:49 2024 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1662625174; cv=none; d=zohomail.com; s=zohoarc; b=KJ7jxZ2zPnfX2yeC5WhVb71x0rrr7TNg2QckReb+c8F1g03hUIm8vlMkKxW1t7edOpZ/XvnaH/ahGOA00+X7Sv0UE37bLtWaAhcRxhNwzjEn6xcPKjuPZzVQK9SUf4+k0LPoQvuAlXOPhLexkObTYSSCcGbv9EIk8r4N0xRgirI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662625174; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=c615+fQCUqR4y6SwKuEO/6enSBHYXNAqv2S8rVOrY+Q=; b=PxGSfu1+sEH27EQUDHhoOwQxkEEh356foG6JN6EKwqe7DSFVayDKDBkJcHsKHpsRu6A3tNBvehkRhKPf4ouWM80cfkEyyahgeO55yOGidLhDZEcMjQs+ps15LpFp8dJtwB+EZ9di5kKnlcAyttdMG+PLluhvO1zBQPnqGC4hPeA= 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 1662625174801570.0734150657717; Thu, 8 Sep 2022 01:19:34 -0700 (PDT) Received: from localhost ([::1]:44642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWCl3-0004Qz-It for importer@patchew.org; Thu, 08 Sep 2022 04:19:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWCgQ-0002Iy-Pq for qemu-devel@nongnu.org; Thu, 08 Sep 2022 04:14:46 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:35970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oWCgO-0007CP-Vm for qemu-devel@nongnu.org; Thu, 08 Sep 2022 04:14:46 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 715F6209DD; Thu, 8 Sep 2022 08:14:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 068561322C; Thu, 8 Sep 2022 08:14:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OMUmO3KkGWNxJQAAMHmgww (envelope-from ); Thu, 08 Sep 2022 08:14:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662624883; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=c615+fQCUqR4y6SwKuEO/6enSBHYXNAqv2S8rVOrY+Q=; b=AcK/MWASRbt2evONZlv1F3wM3+CBbvxatiFLd1A8r0WEULZ6Zw8f5pu1bc2Z5GaHPwlE3f iMcA7eo1h1EVt+NVrJW6gz+XiFxKAvbw/PGuz432mDoKaDurAVsmamTwZng9xSifzMq3iD N3s7RrmvbJdJARFgsdoTp4tJc72mvEs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662624883; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=c615+fQCUqR4y6SwKuEO/6enSBHYXNAqv2S8rVOrY+Q=; b=WBNxsMiGdkF9qZTXsjzv4rnhcD9128ED5sht34VBupzgMyqH9rGDNqCS9/FLLdvcC/mBh7 FD4DtBFp4ZqgqUDQ== From: Claudio Fontana To: Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Schoenebeck , Akihiko Odaki , =?UTF-8?q?Volker=20R=C3=BCmelin?= Cc: Claudio Fontana , qemu-devel@nongnu.org, Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , BALATON Zoltan Subject: [PATCH v3] audio: add help option for -audio and -audiodev Date: Thu, 8 Sep 2022 10:14:41 +0200 Message-Id: <20220908081441.7111-1-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 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=195.135.220.29; envelope-from=cfontana@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1662625176892100001 Content-Type: text/plain; charset="utf-8" add a simple help option for -audio and -audiodev to show the list of available drivers, and document them. Signed-off-by: Claudio Fontana --- audio/audio.c | 19 +++++++++++++++++++ audio/audio.h | 1 + qemu-options.hx | 10 ++++++---- softmmu/vl.c | 9 +++++++-- 4 files changed, 33 insertions(+), 6 deletions(-) v2 -> v3: use AudiodevDriver_str and AUDIODEV_DRIVER__MAX to loop over drivers instead of audio_prio_list (Volker). v1 -> v2: also extend the help to -audio. -audio help -audio driver=3Dhelp -audiodev help will all show the same results. diff --git a/audio/audio.c b/audio/audio.c index 4f4bb10cce..6647ed5b1e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -32,6 +32,7 @@ #include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" #include "qemu/module.h" +#include "qemu/help_option.h" #include "sysemu/sysemu.h" #include "sysemu/replay.h" #include "sysemu/runstate.h" @@ -2105,10 +2106,28 @@ static void audio_validate_opts(Audiodev *dev, Erro= r **errp) } } =20 +void audio_help(void) +{ + int i; + + printf("Available audio drivers:\n"); + + for (i =3D 0; i < AUDIODEV_DRIVER__MAX; i++) { + audio_driver *driver =3D audio_driver_lookup(AudiodevDriver_str(i)= ); + if (driver) { + printf("%s\n", driver->name); + } + } +} + void audio_parse_option(const char *opt) { Audiodev *dev =3D NULL; =20 + if (is_help_option(opt)) { + audio_help(); + exit(EXIT_SUCCESS); + } Visitor *v =3D qobject_input_visitor_new_str(opt, "driver", &error_fat= al); visit_type_Audiodev(v, NULL, &dev, &error_fatal); visit_free(v); diff --git a/audio/audio.h b/audio/audio.h index 27e67079a0..01bdc567fb 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -171,6 +171,7 @@ void audio_sample_from_uint64(void *samples, int pos, void audio_define(Audiodev *audio); void audio_parse_option(const char *opt); bool audio_init_audiodevs(void); +void audio_help(void); void audio_legacy_help(void); =20 AudioState *audio_state_by_name(const char *name); diff --git a/qemu-options.hx b/qemu-options.hx index 31c04f7eea..04cd4dacfc 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -704,10 +704,11 @@ 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 host backend options are the same as with the corresponding - ``-audiodev`` options below. The guest hardware model can be set with - ``model=3Dmodelname``. Use ``model=3Dhelp`` to list the available devi= ce - types. + 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. =20 The following two example do exactly the same, to show how ``-audio`` can be used to shorten the command line length: @@ -721,6 +722,7 @@ ERST DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, "-audiodev [driver=3D]driver,id=3Did[,prop[=3Dvalue][,...]]\n" " specifies the audio backend to use\n" + " Use ``-audiodev help`` to list the available drivers\= n" " id=3D identifier of the backend\n" " timer-period=3D timer period in microseconds\n" " in|out.mixing-engine=3D use mixing engine to mix stre= ams inside QEMU\n" diff --git a/softmmu/vl.c b/softmmu/vl.c index dea4005e47..2f8eecf5c1 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2842,11 +2842,16 @@ void qemu_init(int argc, char **argv, char **envp) audio_parse_option(optarg); break; case QEMU_OPTION_audio: { - QDict *dict =3D keyval_parse(optarg, "driver", NULL, &erro= r_fatal); + bool help; char *model; Audiodev *dev =3D NULL; Visitor *v; - + QDict *dict =3D keyval_parse(optarg, "driver", &help, &err= or_fatal); + if (help || (qdict_haskey(dict, "driver") && + is_help_option(qdict_get_str(dict, "driver"))= )) { + audio_help(); + exit(EXIT_SUCCESS); + } if (!qdict_haskey(dict, "id")) { qdict_put_str(dict, "id", "audiodev0"); } --=20 2.26.2