From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651059243032389.7579613119955; Wed, 27 Apr 2022 04:34:03 -0700 (PDT) Received: from localhost ([::1]:44462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njfvi-0003jE-QI for importer@patchew.org; Wed, 27 Apr 2022 07:34:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuK-0000qG-N4 for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:38 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:39440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuI-0001oU-4K for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:31 -0400 Received: by mail-ej1-x631.google.com with SMTP id bv19so2788098ejb.6 for ; Wed, 27 Apr 2022 04:32:29 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dI4QUL68g98m6gN/IHVwAh/Pz9XOOQumqChvJ9IcdoQ=; b=ZY7jA/N+mjlBmLfSSPW2h6w0FG3FprhdhRjMHgMK6dG5cIb6f3oey9s81oz/bgUDJs 52yXCgNHbUWNDu0Nn+v1zQ8w9aaVFjRf+76RwBpiqUB+yhv0KrSFZm1togyHfhWbsRrC 1lGE/24NooH01TEIxe3A7oiqBBlnEcQMiW3Dzt5X9yoeP47BiBqawVPzOm6C3M4SN6LQ bMEOI7teSHGpJwUnhXAZt+DEGoqg8phtuQ/GTNmxlEfKc2dBlQzlGuoPmurRHOzZMz8J lLT7klzb6iYWvVHsk4qP+up34c1vaZHR2l9kgTxbUgKGWqeGwz3ssXCjAwKUHf1OkAt5 rahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=dI4QUL68g98m6gN/IHVwAh/Pz9XOOQumqChvJ9IcdoQ=; b=28F2+16YyG5buzVNYWP4NxWBA+5dNMAEGVjh+r8p6sIeur4VtMXihaC4TMoSQel+wk 59B9QrbbNaDUfVAtQtW/X44k1vtbPBjH1WD65HGgXfeO/xeCb88RYyDJqFEQrpfzPlyt d9U2qZN7KjLGHz83dQ2NnNFtftOxIwCpO2UBXhhGXGw954HxAS1KhXMbJTCI3BgH4SjI enJisXXCVmQdUTKZlLTIqiH1hNO9OUENVSgYVSuadBhp0x6VNphTNLHP22tsYTOhh9CJ JXQwO3b2qzwGeg5GNbSN4DeG86THw2+b/CAd0LtgrAVtH7wTZjov5CFu2/vH1MZOrww/ dxEQ== X-Gm-Message-State: AOAM532+hNLo35KcejCXK5ipP/i8fHcaKeQ/cmq6tlNClQOzXoxtPVfx 1EkuJm9TqSXd1j6HxUhTafUXOci+JiALgw== X-Google-Smtp-Source: ABdhPJzqE4H9zjblr/8xwKZPHHnAaItU9t/J+G0OLAQNh763TiPJIKmw5YhNZFODG9FwzF1jIk/Ubw== X-Received: by 2002:a17:907:97cd:b0:6f3:aeb8:6002 with SMTP id js13-20020a17090797cd00b006f3aeb86002mr7883145ejc.530.1651059148557; Wed, 27 Apr 2022 04:32:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/6] pc: remove -soundhw pcspk Date: Wed, 27 Apr 2022 13:32:20 +0200 Message-Id: <20220427113225.112521-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::631; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x631.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651059244125100001 Content-Type: text/plain; charset="utf-8" The pcspk device is the only user of isa_register_soundhw, and the only -soundhw option which does not create a new device (it hacks into the PCSpkState by hand). Remove it, since it was deprecated. Signed-off-by: Paolo Bonzini --- hw/audio/pcspk.c | 10 ---------- hw/audio/soundhw.c | 27 ++++----------------------- include/hw/audio/soundhw.h | 3 --- 3 files changed, 4 insertions(+), 36 deletions(-) diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index dfc7ebca4e..daf92a4ce1 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -245,18 +245,8 @@ static const TypeInfo pcspk_info =3D { .class_init =3D pcspk_class_initfn, }; =20 -static int pcspk_audio_init_soundhw(ISABus *bus) -{ - PCSpkState *s =3D pcspk_state; - - warn_report("'-soundhw pcspk' is deprecated, " - "please set a backend using '-machine pcspk-audiodev=3D' instead"); - return pcspk_audio_init(s); -} - static void pcspk_register(void) { type_register_static(&pcspk_info); - isa_register_soundhw("pcspk", "PC speaker", pcspk_audio_init_soundhw); } type_init(pcspk_register) diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index 173b674ff5..f7d94d7dfa 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -36,26 +36,12 @@ struct soundhw { const char *typename; int enabled; int isa; - union { - int (*init_isa) (ISABus *bus); - int (*init_pci) (PCIBus *bus); - } init; + int (*init_pci) (PCIBus *bus); }; =20 static struct soundhw soundhw[9]; static int soundhw_count; =20 -void isa_register_soundhw(const char *name, const char *descr, - int (*init_isa)(ISABus *bus)) -{ - assert(soundhw_count < ARRAY_SIZE(soundhw) - 1); - soundhw[soundhw_count].name =3D name; - soundhw[soundhw_count].descr =3D descr; - soundhw[soundhw_count].isa =3D 1; - soundhw[soundhw_count].init.init_isa =3D init_isa; - soundhw_count++; -} - void pci_register_soundhw(const char *name, const char *descr, int (*init_pci)(PCIBus *bus)) { @@ -63,7 +49,7 @@ void pci_register_soundhw(const char *name, const char *d= escr, soundhw[soundhw_count].name =3D name; soundhw[soundhw_count].descr =3D descr; soundhw[soundhw_count].isa =3D 0; - soundhw[soundhw_count].init.init_pci =3D init_pci; + soundhw[soundhw_count].init_pci =3D init_pci; soundhw_count++; } =20 @@ -158,18 +144,13 @@ void soundhw_init(void) } else { pci_create_simple(pci_bus, -1, c->typename); } - } else if (c->isa) { - if (!isa_bus) { - error_report("ISA bus not available for %s", c->name); - exit(1); - } - c->init.init_isa(isa_bus); } else { + assert(!c->isa); if (!pci_bus) { error_report("PCI bus not available for %s", c->name); exit(1); } - c->init.init_pci(pci_bus); + c->init_pci(pci_bus); } } } diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h index f09a297854..e68685fcda 100644 --- a/include/hw/audio/soundhw.h +++ b/include/hw/audio/soundhw.h @@ -1,9 +1,6 @@ #ifndef HW_SOUNDHW_H #define HW_SOUNDHW_H =20 -void isa_register_soundhw(const char *name, const char *descr, - int (*init_isa)(ISABus *bus)); - void pci_register_soundhw(const char *name, const char *descr, int (*init_pci)(PCIBus *bus)); void deprecated_register_soundhw(const char *name, const char *descr, --=20 2.35.1 From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651059542655453.9893648946096; Wed, 27 Apr 2022 04:39:02 -0700 (PDT) Received: from localhost ([::1]:55550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njg0a-0002iI-VO for importer@patchew.org; Wed, 27 Apr 2022 07:39:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuQ-0000s0-Jt for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:38 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:45824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuJ-0001oZ-VX for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:34 -0400 Received: by mail-ed1-x532.google.com with SMTP id be20so1560590edb.12 for ; Wed, 27 Apr 2022 04:32:30 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XcEbAj7DkotRRBN7FgHWWPGt3A08+JD5zJxGjzXCVh8=; b=QZx4PIrTJXaSqwJJBTNC8sJYqYseKQNpNANMnEtjQm+JKQBPJsUECazHjLEdZKjOrJ 2RKb6f03w5HRyw98dcX22457Ve/QQFC86w0I3DtVe0eWl+HzEI/gCpzlF0oQTcARiHSC mhEhYJzC3k02sMfefgsSQBEquN5AC/YWaxYOT+GO22jGwNnnuUrsO0PbenQ6dGYdAVsk AUh6IpHyGDvsvXqOfSg87pSzpjiz1koCNMMLAU7eoUyexg/V69D1OOr0MX9bg1sWt7yE jF5p7w1GYwkpg8NADpy2uPSDls6ukiQxoBmXr9PjXKRRgCl27oHQ6cbZuRNB7r0MzEjU 2BPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=XcEbAj7DkotRRBN7FgHWWPGt3A08+JD5zJxGjzXCVh8=; b=0yFtDrAuUQ3I4CsDtaqtD5wgQ2vXVEiMz/YaC4W3Qbghw9zTojvvNQSFEY/EH4uDfn tGhh7HcxhrNWElWermiH65jS0P4y65sGfT3IqtCEAujix9iLlC3AFeoahdGYpg5nWFi6 shcn56IDraKnMYTzCJjrHfnGBVRkjiNZiNQlQ/qIviwNQzYb34VBatdeBWnIVs6DfmTj D3GMTmyMYNGK1fAGZEt5OnI0QvOdQcahPi1/H+goAypNlSV+ruxe2DIv97Jb/hEzI1jo fceqxur2ZOX99QY0gVMLnn8BVqeUaqw42g8r5uRtKaEmPCX65sFcFW+RpdJcYc8Q162K YsJw== X-Gm-Message-State: AOAM530zuo8tKLTx0pJ8I2sWQS8zySx+TV/FrvaceLm+qAe2ZGiWt8Q6 i8lUc7wVFF9tRu6A4p2mOea8eQsPlZV9jw== X-Google-Smtp-Source: ABdhPJxu+69Wc1f/roEQDTL2P13UwJvZ1UCzxMEJevOTbW17j9wY0mwY/lfyaQPLAxwXXs75sfdbrQ== X-Received: by 2002:aa7:c3ca:0:b0:425:ecfc:4258 with SMTP id l10-20020aa7c3ca000000b00425ecfc4258mr14880066edr.266.1651059149472; Wed, 27 Apr 2022 04:32:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 2/6] soundhw: remove ability to create multiple soundcards Date: Wed, 27 Apr 2022 13:32:21 +0200 Message-Id: <20220427113225.112521-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651059543821100001 Content-Type: text/plain; charset="utf-8" The usefulness of enabling a dozen soundcards is dubious. Simplify the code by allowing a single instance of -soundhw, with no support for parsing either comma-separated values or 'soundhw all'. Signed-off-by: Paolo Bonzini --- hw/audio/soundhw.c | 88 +++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index f7d94d7dfa..097501fee1 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -25,6 +25,7 @@ #include "qemu/option.h" #include "qemu/help_option.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "qom/object.h" #include "hw/isa/isa.h" #include "hw/pci/pci.h" @@ -34,7 +35,6 @@ struct soundhw { const char *name; const char *descr; const char *typename; - int enabled; int isa; int (*init_pci) (PCIBus *bus); }; @@ -64,10 +64,16 @@ void deprecated_register_soundhw(const char *name, cons= t char *descr, soundhw_count++; } =20 +static struct soundhw *selected =3D NULL; + void select_soundhw(const char *optarg) { struct soundhw *c; =20 + if (selected) { + error_setg(&error_fatal, "only one -soundhw option is allowed"); + } + if (is_help_option(optarg)) { show_valid_cards: =20 @@ -84,44 +90,15 @@ void select_soundhw(const char *optarg) exit(!is_help_option(optarg)); } else { - size_t l; - const char *p; - char *e; - int bad_card =3D 0; - - if (!strcmp(optarg, "all")) { - for (c =3D soundhw; c->name; ++c) { - c->enabled =3D 1; + for (c =3D soundhw; c->name; ++c) { + if (g_str_equal(c->name, optarg)) { + selected =3D c; + break; } - return; } =20 - p =3D optarg; - while (*p) { - e =3D strchr(p, ','); - l =3D !e ? strlen(p) : (size_t) (e - p); - - for (c =3D soundhw; c->name; ++c) { - if (!strncmp(c->name, p, l) && !c->name[l]) { - c->enabled =3D 1; - break; - } - } - - if (!c->name) { - if (l > 80) { - error_report("Unknown sound card name (too big to show= )"); - } - else { - error_report("Unknown sound card name `%.*s'", - (int) l, p); - } - bad_card =3D 1; - } - p +=3D l + (e !=3D NULL); - } - - if (bad_card) { + if (!c->name) { + error_report("Unknown sound card name `%s'", optarg); goto show_valid_cards; } } @@ -129,30 +106,29 @@ void select_soundhw(const char *optarg) =20 void soundhw_init(void) { - struct soundhw *c; + struct soundhw *c =3D selected; ISABus *isa_bus =3D (ISABus *) object_resolve_path_type("", TYPE_ISA_B= US, NULL); PCIBus *pci_bus =3D (PCIBus *) object_resolve_path_type("", TYPE_PCI_B= US, NULL); =20 - for (c =3D soundhw; c->name; ++c) { - if (c->enabled) { - if (c->typename) { - warn_report("'-soundhw %s' is deprecated, " - "please use '-device %s' instead", - c->name, c->typename); - if (c->isa) { - isa_create_simple(isa_bus, c->typename); - } else { - pci_create_simple(pci_bus, -1, c->typename); - } - } else { - assert(!c->isa); - if (!pci_bus) { - error_report("PCI bus not available for %s", c->name); - exit(1); - } - c->init_pci(pci_bus); - } + if (!c) { + return; + } + if (c->typename) { + warn_report("'-soundhw %s' is deprecated, " + "please use '-device %s' instead", + c->name, c->typename); + if (c->isa) { + isa_create_simple(isa_bus, c->typename); + } else { + pci_create_simple(pci_bus, -1, c->typename); } + } else { + assert(!c->isa); + if (!pci_bus) { + error_report("PCI bus not available for %s", c->name); + exit(1); + } + c->init_pci(pci_bus); } } =20 --=20 2.35.1 From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651060017688937.6891260156777; Wed, 27 Apr 2022 04:46:57 -0700 (PDT) Received: from localhost ([::1]:35412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njg8G-0000cG-Ft for importer@patchew.org; Wed, 27 Apr 2022 07:46:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuS-0000tV-1a for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:40 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:41927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuL-0001pC-78 for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:36 -0400 Received: by mail-ej1-x636.google.com with SMTP id dk23so2779123ejb.8 for ; Wed, 27 Apr 2022 04:32:31 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/pSiiolR4M6W1WjSd8pasEM62dxnIZG2DNdUhvZONkg=; b=IGj99rax8KfteX3MMQyO2VAmehcg9zNsJu4DsGQQ6/PRFgaj4zU6rgBpty5GCTLxqs sD55tDNJh5Tzdma3jDbgUR81milWIIrHeRrVgWrm6TsziEn6fuo+28gB/KBqE+Ay96s5 BMGSxOkwu0ncI93RXQILSwFeB4HzhB20r54PL09L93MXWM8h6HFhwxyS5yU1OYC/UU1i MRT/OoE2ZIEpBkoYZb5dDKgpiH7w0aSANsFtnQu/L1ZuLLOohcTR/kK/oOUP7jNWXdqn irLY7CJ0KApphHw7C9eUVYBp0KHHJdnNR84VT8Ik24V8aLiZKsqiqQFEF2rdg7cL1Qmt uKPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/pSiiolR4M6W1WjSd8pasEM62dxnIZG2DNdUhvZONkg=; b=ROcyPwF7FPcnAKU0BmbAaLay2OC/7kLHoUfRYB3TK8BGkzS3N+24STNOVOXYb4EMxg y753LsMGJPJPH55JzZKPdawT77vrDC9+1XoEP5OtfmJTyTSAfKKZQWhCKNOZCOUCyWy7 QkevAj+waRhLVEifteyfqV7QdOKG7yVRoOq3Tcb5/RtbUlu3a3ZuiTHwbhlIlsZ644Km ulBvyhdHFBmRhWYwxMB8B1WFfiok2k3vDrvzzho+lwemUDjCkAFTasAptNX8ccHoz8H7 dHtRrv+JCjqMvqU1Lea3/i6QWpVbnuJSDUHsZmVCW43nrzF2HhOLK2k5kU7C0EYAC+gA P+iQ== X-Gm-Message-State: AOAM531nNCYBt2sWQhNsTNIxgCblV9RVrktrfAA7Tf92tkN2sVGmP6B2 mblhl5fV8t7az6z0k3YIcpFCgbR/45GcNw== X-Google-Smtp-Source: ABdhPJyWltN7Hp/Vl54lwuAPKdSQsioP1kBTh7hkn+Tc3c+sJFY9P4eE1Og1jp4dQzhrpcRG5PQ+Eg== X-Received: by 2002:a17:907:c31a:b0:6f3:cd46:4092 with SMTP id tl26-20020a170907c31a00b006f3cd464092mr1803142ejc.592.1651059150301; Wed, 27 Apr 2022 04:32:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 3/6] soundhw: extract soundhw help to a separate function Date: Wed, 27 Apr 2022 13:32:22 +0200 Message-Id: <20220427113225.112521-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::636; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651060018881100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- hw/audio/soundhw.c | 33 +++++++++++++++++++-------------- include/hw/audio/soundhw.h | 1 + 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index 097501fee1..0fb64bdc8f 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -64,6 +64,21 @@ void deprecated_register_soundhw(const char *name, const= char *descr, soundhw_count++; } =20 +void show_valid_soundhw(void) +{ + struct soundhw *c; + + if (soundhw_count) { + printf("Valid sound card names (comma separated):\n"); + for (c =3D soundhw; c->name; ++c) { + printf ("%-11s %s\n", c->name, c->descr); + } + } else { + printf("Machine has no user-selectable audio hardware " + "(it may or may not have always-present audio hardware).\n= "); + } +} + static struct soundhw *selected =3D NULL; =20 void select_soundhw(const char *optarg) @@ -75,19 +90,8 @@ void select_soundhw(const char *optarg) } =20 if (is_help_option(optarg)) { - show_valid_cards: - - if (soundhw_count) { - printf("Valid sound card names (comma separated):\n"); - for (c =3D soundhw; c->name; ++c) { - printf ("%-11s %s\n", c->name, c->descr); - } - printf("\n-soundhw all will enable all of the above\n"); - } else { - printf("Machine has no user-selectable audio hardware " - "(it may or may not have always-present audio hardware= ).\n"); - } - exit(!is_help_option(optarg)); + show_valid_soundhw(); + exit(0); } else { for (c =3D soundhw; c->name; ++c) { @@ -99,7 +103,8 @@ void select_soundhw(const char *optarg) =20 if (!c->name) { error_report("Unknown sound card name `%s'", optarg); - goto show_valid_cards; + show_valid_soundhw(); + exit(1); } } } diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h index e68685fcda..dec5c0cdca 100644 --- a/include/hw/audio/soundhw.h +++ b/include/hw/audio/soundhw.h @@ -7,6 +7,7 @@ void deprecated_register_soundhw(const char *name, const ch= ar *descr, int isa, const char *typename); =20 void soundhw_init(void); +void show_valid_soundhw(void); void select_soundhw(const char *optarg); =20 #endif --=20 2.35.1 From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165105941920463.88598982316216; Wed, 27 Apr 2022 04:36:59 -0700 (PDT) Received: from localhost ([::1]:50180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njfya-0007cp-7l for importer@patchew.org; Wed, 27 Apr 2022 07:36:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuS-0000tZ-3M for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:40 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:43605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuM-0001pJ-G1 for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:38 -0400 Received: by mail-ed1-x532.google.com with SMTP id b24so1569672edu.10 for ; Wed, 27 Apr 2022 04:32:32 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZeIWCK8hg6Sj8fOxFWWHzcrLf3ZpiEYw763wTq7Q2pQ=; b=lMj+s7Sawh/YBJHDRjaG9nHVg0wpWyp9OHC6kPr8RioYOIeYs+AVOOx0P/6mEQ4reL /itcselVc0FL5brGYCs8a68SqTZsBb/KS7tHOTQXCoZ64I83a5Xx6ExvPOiXXpNuEfsq xkC8ndwDdZOKY5VLM+tCC26yaStTJq5A9TGXmuq15KK/Gkk/oFDmeUY/6mPCvkqQeCcz Lg/VVpgKL3yR7m6nWilBTr3nevecO4HjrSYohNm5XbQP5NOZW5omKaSyuaxiD+2cHDVU 0geMRupvAxsSZ4LPvxk+0B2hl5ggO4VQ/3DWtrDUijXhhJ1vKTLIl2isvWRXTSGX9RHQ KrQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZeIWCK8hg6Sj8fOxFWWHzcrLf3ZpiEYw763wTq7Q2pQ=; b=f7Y2HrHxNrCWVlTM0mh6f1ZLk3imuEygZbJfgFdxKivw38RoeRxssI+Ypc5dCvemGO KI8QuxoTDYdmIYzfrWSxBs8wuU58otCzEzCV442aHFyN5g7Lkzh7ac+BE/x5a9UjdzyG ckmrFpIQzW81Oo14EXL0xwzU2L6Ccf51vQpRr1vcT/e6C/NNlEeuJeZpuVCYNTo0TSbi WvnTN+UGgK7Uwf+jd7aolMhNFJkdy7avxluEkShj3OLmjVDPYV2vsWZ0D+th2TMaa1rB W/fX0KnevxcFIbXJYP/wCKYvR2Ux47bTZNX0s3bg7We8cfBUzc2T1l+BImS2IfP1uiPx dQQA== X-Gm-Message-State: AOAM53224nzD6wMw0wEtFqqEHdHMIDIr9ELP9CF8R9+PWgkTYpczhwid PSQxkVsrzi6c88aMAk2tUk7C+l16OOp/qg== X-Google-Smtp-Source: ABdhPJyjT5cklD2AcL6PZn3QosXmNouptlUeilFgVunSnVxePtvdl+eelFJG/cscspgAyhkbQ/ZqKg== X-Received: by 2002:a50:c099:0:b0:415:f5c7:700e with SMTP id k25-20020a50c099000000b00415f5c7700emr29400671edf.205.1651059151256; Wed, 27 Apr 2022 04:32:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 4/6] soundhw: unify initialization for ISA and PCI soundhw Date: Wed, 27 Apr 2022 13:32:23 +0200 Message-Id: <20220427113225.112521-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651059420560100001 Content-Type: text/plain; charset="utf-8" Use qdev_new instead of distinguishing isa_create_simple/pci_create_simple. Signed-off-by: Paolo Bonzini --- hw/audio/soundhw.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index 0fb64bdc8f..a9d8807b18 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -114,25 +114,27 @@ void soundhw_init(void) struct soundhw *c =3D selected; ISABus *isa_bus =3D (ISABus *) object_resolve_path_type("", TYPE_ISA_B= US, NULL); PCIBus *pci_bus =3D (PCIBus *) object_resolve_path_type("", TYPE_PCI_B= US, NULL); + BusState *bus; =20 - if (!c) { - return; - } - if (c->typename) { - warn_report("'-soundhw %s' is deprecated, " - "please use '-device %s' instead", - c->name, c->typename); - if (c->isa) { - isa_create_simple(isa_bus, c->typename); - } else { - pci_create_simple(pci_bus, -1, c->typename); + if (c->isa) { + if (!isa_bus) { + error_report("ISA bus not available for %s", c->name); + exit(1); } + bus =3D BUS(isa_bus); } else { - assert(!c->isa); if (!pci_bus) { error_report("PCI bus not available for %s", c->name); exit(1); } + bus =3D BUS(pci_bus); + } + + if (c->typename) { + DeviceState *dev =3D qdev_new(c->typename); + qdev_realize_and_unref(dev, bus, &error_fatal); + } else { + assert(!c->isa); c->init_pci(pci_bus); } } --=20 2.35.1 From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651060400199883.1578306187366; Wed, 27 Apr 2022 04:53:20 -0700 (PDT) Received: from localhost ([::1]:43402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njgEQ-0006E9-LF for importer@patchew.org; Wed, 27 Apr 2022 07:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuV-0000zs-1B for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:43 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:35548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuR-0001pW-PA for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:42 -0400 Received: by mail-ej1-x62c.google.com with SMTP id l7so2818906ejn.2 for ; Wed, 27 Apr 2022 04:32:33 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gQ7UtdFAbXFv5YAxs4I1WqXwVn14/HuQbkfQM7Bmago=; b=mI4rhjAaTC6AQFZ/p9wJeWw64H+O+Qw09Su+AIdgPzmIVlVzCgDupY+/2whmlLuyu+ q7QuK4uCXNTpORaI1IpkIxWcMSlktoSgtlnQnecuWbnBYLw8ex0VCOW33jW4+zCcy1Yp 5VQHWHps2jrRgS9YruzF63Ec8Tp64gxKDVjz2qsV7bNUVkqNP3satN1s4OTtHb0Y8vkE PLx7YZuNedOR2/ImqwEAwKfswPH6gLe8WtoZyL4/8QmAJ0cYj92arKPmC7m//Opv9AXj Gz5A13F3FGCV4qWeifoc0UnlXP/dERSvuLDSYL731oM1L3rcKpZHpLFZbDxsZw13Rxjb rGDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gQ7UtdFAbXFv5YAxs4I1WqXwVn14/HuQbkfQM7Bmago=; b=6r2gzLmRZFu4Eh2uTvtsnS6ab9KE8b2Ts9+jdAfh898PRTk3PyCpBOyctJNEIP8R9b KW20MaAqHaD+57Mbpc+YJixbtsGtaB+n5/9Bk/zI8oMlja665kQvl/iY/m6fCdRjQpuz W8kF7Jh3XT6nxcHssp5HPuPKja1xydB/MxB1R11Yfa2okc5m2eytipFsjBU079M31gwS fNH2wPb118dkWLvTPQ9ix4cKOGJ7Uf8bkrszLXsZC1338MHgVTvSccIVAu0uenk3love h07WKMv2gyHMHgeVBBqFJECDIGMF69SEjGmZr0plvbMdefuXdg6Ude7QjABTnzsR3GxO uagw== X-Gm-Message-State: AOAM533w4LgpKxA0bAYUr1TJ95zE9q8jEvQNsYgx9t4K4rQJTRPNATQQ HZGFMQdOWE2nPEoBggVPHYlP79qYMrV/1w== X-Google-Smtp-Source: ABdhPJwJR6tPIBxIHEYVUh+FDZQ2FZcu+snHq4usSCIq0KFh2rS4nh1/Zg8IjTwkVRu/hBxw4JYO8A== X-Received: by 2002:a17:907:7811:b0:6ef:a896:b407 with SMTP id la17-20020a170907781100b006efa896b407mr24979695ejc.645.1651059152261; Wed, 27 Apr 2022 04:32:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 5/6] soundhw: move help handling to vl.c Date: Wed, 27 Apr 2022 13:32:24 +0200 Message-Id: <20220427113225.112521-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::62c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651060400485100001 Content-Type: text/plain; charset="utf-8" This will allow processing "-audio model=3Dhelp" even if the backend part of the option is missing. Signed-off-by: Paolo Bonzini --- hw/audio/soundhw.c | 24 +++++++++--------------- softmmu/vl.c | 4 ++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index a9d8807b18..d81ae91136 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -89,23 +89,17 @@ void select_soundhw(const char *optarg) error_setg(&error_fatal, "only one -soundhw option is allowed"); } =20 - if (is_help_option(optarg)) { - show_valid_soundhw(); - exit(0); + for (c =3D soundhw; c->name; ++c) { + if (g_str_equal(c->name, optarg)) { + selected =3D c; + break; + } } - else { - for (c =3D soundhw; c->name; ++c) { - if (g_str_equal(c->name, optarg)) { - selected =3D c; - break; - } - } =20 - if (!c->name) { - error_report("Unknown sound card name `%s'", optarg); - show_valid_soundhw(); - exit(1); - } + if (!c->name) { + error_report("Unknown sound card name `%s'", optarg); + show_valid_soundhw(); + exit(1); } } =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index c2919579fd..5bea0eb3eb 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3019,6 +3019,10 @@ void qemu_init(int argc, char **argv, char **envp) audio_parse_option(optarg); break; case QEMU_OPTION_soundhw: + if (is_help_option(optarg)) { + show_valid_soundhw(); + exit(0); + } select_soundhw (optarg); break; case QEMU_OPTION_h: --=20 2.35.1 From nobody Mon Feb 9 20:11:57 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16510596243671022.2762288902412; Wed, 27 Apr 2022 04:40:24 -0700 (PDT) Received: from localhost ([::1]:57044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njg1u-0003ij-L0 for importer@patchew.org; Wed, 27 Apr 2022 07:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njfuT-0000wP-OW for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:42 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:36774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1njfuP-0001pc-3G for qemu-devel@nongnu.org; Wed, 27 Apr 2022 07:32:41 -0400 Received: by mail-ed1-x52d.google.com with SMTP id a1so1593118edt.3 for ; Wed, 27 Apr 2022 04:32:34 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:1c09:f536:3de6:228c]) by smtp.gmail.com with ESMTPSA id d26-20020a170906305a00b006f3a7ffbb0esm3099216ejd.70.2022.04.27.04.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sC4EUyeadX0kiWLL/N50KYKk9Kd0mvKDUWRk330XjXg=; b=ikkTuVwDC2DTAwzbgHtcPwmFoKDMkIimiz4MrHPgQWReXIsyqA9M5COp8vukvJaTXw NuCZt4ZX2O7KMtqNm6g+yTvztcG536pxeMJfmJYm/64L0+dJZRAeKVo5gRJpMKps6g1L bG3TQ7aGrjB6dpkyQ69tH4pBR4enmvrouIznu4nTc4CEynd+mFZ6UQ8vOXOc0td5/UMx ayr6Rp2QVzx7J88kIDBu5nY5C01WARy07F603rbkU/rjxlbskggOuHVkHi/193RHjkXm Gt6cLh0u0me9ARqKlqcWWz0fh32uCgbjosrSQDNe69m3fSlqsJAPp+lWkTpnhwaVO6cL QCyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sC4EUyeadX0kiWLL/N50KYKk9Kd0mvKDUWRk330XjXg=; b=4gLFjEfgz9v9qfw6iKNJPB0gOhWS/GlN1gsS+3dOo5Zea5KO6+bcOCsQjDvXKuMjNs 7UeulnaXMgDBprhgJIQqUSNJJ2NHUV8/K3vMRDlRTx/zb2c3I6VPmNSXnNIxRcelgnyr 9HIlwJTtuFrtInAcNWR+q/KIqAJ/Iintet5iO2qgHZK2BTdEvN7FWdhzNSjHhLlcCxPq +hmZz0kD5zomRC196AqskzeKkR3suJSWEsT5J/ujB8FOU5PywC2OdHyMhkPeEtP7QRqj IDw1ehkEJS9L1Wv/KqCPrJDNI5cfA5/1tJ2RdRSyelVIC5OZMBnBUzMDr+cigFCHbupE JWnw== X-Gm-Message-State: AOAM532BuvKc7o4uHyokXXelqitHa9qyB+0KIswecRiRtDbsdgrSbIsx zP4xQ8Yr/c18h6uwNCB8N2GolWAPP4pPtg== X-Google-Smtp-Source: ABdhPJxBT59+nsPq5JQ36cgBzEQS94pdTqKPor9PwQjuRpAqNhklO2L1eUjXPng6Fp7QG4MKuy0ycQ== X-Received: by 2002:a05:6402:34c8:b0:423:f53f:6365 with SMTP id w8-20020a05640234c800b00423f53f6365mr30408378edc.274.1651059153220; Wed, 27 Apr 2022 04:32:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 6/6] vl: introduce -audio as a replacement for -soundhw Date: Wed, 27 Apr 2022 13:32:25 +0200 Message-Id: <20220427113225.112521-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427113225.112521-1-pbonzini@redhat.com> References: <20220427113225.112521-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=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: mkletzan@redhat.com, berrange@redhat.com, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1651059625308100001 Content-Type: text/plain; charset="utf-8" -audio is used like "-audio pa,model=3Dsb16". It is almost as simple as -soundhw, but it reuses the -audiodev parsing machinery and attaches an audiodev to the newly-created device. The main 'feature' is that it knows about adding the codec device for model=3Dintel-hda, and adding the audiodev to the codec device. In the future, it could be extended to support default models or builtin devices, just like -nic, or even a default backend. For now, keep it simple. JSON parsing is not supported for -audio. This is okay because the option is targeted at end users, not programs. Signed-off-by: Paolo Bonzini --- audio/audio.c | 8 +++++- audio/audio.h | 1 + docs/about/deprecated.rst | 9 ------ docs/about/removed-features.rst | 7 +++++ hw/audio/intel-hda.c | 5 ++-- hw/audio/soundhw.c | 12 +++++--- include/hw/audio/soundhw.h | 4 +-- qemu-options.hx | 51 ++++++++++++++++----------------- softmmu/vl.c | 28 ++++++++++++++++-- 9 files changed, 76 insertions(+), 49 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 9e91a5a4f2..a02f3ce5c6 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2099,13 +2099,19 @@ static void audio_validate_opts(Audiodev *dev, Erro= r **errp) =20 void audio_parse_option(const char *opt) { - AudiodevListEntry *e; Audiodev *dev =3D NULL; =20 Visitor *v =3D qobject_input_visitor_new_str(opt, "driver", &error_fat= al); visit_type_Audiodev(v, NULL, &dev, &error_fatal); visit_free(v); =20 + audio_define(dev); +} + +void audio_define(Audiodev *dev) +{ + AudiodevListEntry *e; + audio_validate_opts(dev, &error_fatal); =20 e =3D g_new0(AudiodevListEntry, 1); diff --git a/audio/audio.h b/audio/audio.h index 3d5ecdecd5..b5e17cd218 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -168,6 +168,7 @@ void audio_sample_to_uint64(const void *samples, int po= s, void audio_sample_from_uint64(void *samples, int pos, uint64_t left, uint64_t right); =20 +void audio_define(Audiodev *audio); void audio_parse_option(const char *opt); void audio_init_audiodevs(void); void audio_legacy_help(void); diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 896e5a97ab..70885d09f3 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -39,15 +39,6 @@ should specify an ``audiodev=3D`` property. Additionall= y, when using vnc, you should specify an ``audiodev=3D`` property if you plan to transmit audio through the VNC protocol. =20 -Creating sound card devices using ``-soundhw`` (since 5.1) -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -Sound card devices should be created using ``-device`` instead. The -names are the same for most devices. The exceptions are ``hda`` which -needs two devices (``-device intel-hda -device hda-duplex``) and -``pcspk`` which can be activated using ``-machine -pcspk-audiodev=3D``. - ``-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 3f324d0536..eabc6c63ac 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -632,6 +632,13 @@ tripped up the CI testing and was suspected to be quit= e broken. For that reason the maintainers strongly suspected no one actually used it. =20 =20 +Creating sound card devices using ``-soundhw`` (removed in 7.1) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Sound card devices should be created using ``-device`` or ``-audio``. +The exception is ``pcspk`` which can be activated using ``-machine +pcspk-audiodev=3D``. + TCG introspection features -------------------------- =20 diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index bc77e3d8c9..f38117057b 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -1311,17 +1311,16 @@ static const TypeInfo hda_codec_device_type_info = =3D { * create intel hda controller with codec attached to it, * so '-soundhw hda' works. */ -static int intel_hda_and_codec_init(PCIBus *bus) +static int intel_hda_and_codec_init(PCIBus *bus, const char *audiodev) { DeviceState *controller; BusState *hdabus; DeviceState *codec; =20 - warn_report("'-soundhw hda' is deprecated, " - "please use '-device intel-hda -device hda-duplex' instead= "); controller =3D DEVICE(pci_create_simple(bus, -1, "intel-hda")); hdabus =3D QLIST_FIRST(&controller->child_bus); codec =3D qdev_new("hda-duplex"); + qdev_prop_set_string(codec, "audiodev", audiodev); qdev_realize_and_unref(codec, hdabus, &error_fatal); return 0; } diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c index d81ae91136..e979be08ce 100644 --- a/hw/audio/soundhw.c +++ b/hw/audio/soundhw.c @@ -27,6 +27,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object.h" +#include "hw/qdev-properties.h" #include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/audio/soundhw.h" @@ -36,14 +37,14 @@ struct soundhw { const char *descr; const char *typename; int isa; - int (*init_pci) (PCIBus *bus); + int (*init_pci) (PCIBus *bus, const char *audiodev); }; =20 static struct soundhw soundhw[9]; static int soundhw_count; =20 void pci_register_soundhw(const char *name, const char *descr, - int (*init_pci)(PCIBus *bus)) + int (*init_pci)(PCIBus *bus, const char *audiode= v)) { assert(soundhw_count < ARRAY_SIZE(soundhw) - 1); soundhw[soundhw_count].name =3D name; @@ -80,8 +81,9 @@ void show_valid_soundhw(void) } =20 static struct soundhw *selected =3D NULL; +static const char *audiodev_id; =20 -void select_soundhw(const char *optarg) +void select_soundhw(const char *optarg, const char *audiodev) { struct soundhw *c; =20 @@ -92,6 +94,7 @@ void select_soundhw(const char *optarg) for (c =3D soundhw; c->name; ++c) { if (g_str_equal(c->name, optarg)) { selected =3D c; + audiodev_id =3D audiodev; break; } } @@ -126,10 +129,11 @@ void soundhw_init(void) =20 if (c->typename) { DeviceState *dev =3D qdev_new(c->typename); + qdev_prop_set_string(dev, "audiodev", audiodev_id); qdev_realize_and_unref(dev, bus, &error_fatal); } else { assert(!c->isa); - c->init_pci(pci_bus); + c->init_pci(pci_bus, audiodev_id); } } =20 diff --git a/include/hw/audio/soundhw.h b/include/hw/audio/soundhw.h index dec5c0cdca..270717a06a 100644 --- a/include/hw/audio/soundhw.h +++ b/include/hw/audio/soundhw.h @@ -2,12 +2,12 @@ #define HW_SOUNDHW_H =20 void pci_register_soundhw(const char *name, const char *descr, - int (*init_pci)(PCIBus *bus)); + int (*init_pci)(PCIBus *bus, const char *audiode= v)); void deprecated_register_soundhw(const char *name, const char *descr, int isa, const char *typename); =20 void soundhw_init(void); void show_valid_soundhw(void); -void select_soundhw(const char *optarg); +void select_soundhw(const char *optarg, const char *audiodev); =20 #endif diff --git a/qemu-options.hx b/qemu-options.hx index bc196808ae..862263d435 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -661,6 +661,30 @@ SRST (deprecated) environment variables. ERST =20 +DEF("audio", HAS_ARG, QEMU_OPTION_audio, + "-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 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 following two example do exactly the same, to show how ``-audio`` + can be used to shorten the command line length: + + .. parsed-literal:: + + |qemu_system| -audiodev pa,id=3Dpa -device sb16,audiodev=3Dpa + |qemu_system| -audio pa,model=3Dsb16 +ERST + DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, "-audiodev [driver=3D]driver,id=3Did[,prop[=3Dvalue][,...]]\n" " specifies the audio backend to use\n" @@ -892,33 +916,6 @@ SRST ``qemu.wav``. ERST =20 -DEF("soundhw", HAS_ARG, QEMU_OPTION_soundhw, - "-soundhw c1,... enable audio support\n" - " and only specified sound cards (comma separated list)= \n" - " use '-soundhw help' to get the list of supported card= s\n" - " use '-soundhw all' to enable all of them\n", QEMU_ARC= H_ALL) -SRST -``-soundhw card1[,card2,...] or -soundhw all`` - Enable audio and selected sound hardware. Use 'help' to print all - available sound hardware. For example: - - .. parsed-literal:: - - |qemu_system_x86| -soundhw sb16,adlib disk.img - |qemu_system_x86| -soundhw es1370 disk.img - |qemu_system_x86| -soundhw ac97 disk.img - |qemu_system_x86| -soundhw hda disk.img - |qemu_system_x86| -soundhw all disk.img - |qemu_system_x86| -soundhw help - - Note that Linux's i810\_audio OSS kernel (for AC97) module might - require manually specifying clocking. - - :: - - modprobe i810_audio clocking=3D48000 -ERST - DEF("device", HAS_ARG, QEMU_OPTION_device, "-device driver[,prop[=3Dvalue][,...]]\n" " add device (based on driver)\n" diff --git a/softmmu/vl.c b/softmmu/vl.c index 5bea0eb3eb..979bbda5aa 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -116,6 +116,8 @@ #include "crypto/init.h" #include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" +#include "qapi/qapi-types-audio.h" +#include "qapi/qapi-visit-audio.h" #include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-compat.h" #include "qapi/qapi-visit-ui.h" @@ -3018,13 +3020,33 @@ void qemu_init(int argc, char **argv, char **envp) case QEMU_OPTION_audiodev: audio_parse_option(optarg); break; - case QEMU_OPTION_soundhw: - if (is_help_option(optarg)) { + case QEMU_OPTION_audio: { + QDict *dict =3D keyval_parse(optarg, "driver", NULL, &erro= r_fatal); + char *model; + Audiodev *dev =3D NULL; + Visitor *v; + + 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); } - select_soundhw (optarg); + 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); break; + } case QEMU_OPTION_h: help(0); break; --=20 2.35.1