From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,
qemu-devel@nongnu.org, qemu-stable@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Zheyu Ma <zheyuma97@gmail.com>
Subject: Re: [PATCH v1 2/4] virtio-snd: factor card setup out of realize func
Date: Mon, 22 Apr 2024 15:23:30 +0200 [thread overview]
Message-ID: <095032a6-df77-44b3-85e5-750993332a26@linaro.org> (raw)
In-Reply-To: <62de737e3320e647454a306bb87c6eb20a2c0cfb.1713789200.git.manos.pitsidianakis@linaro.org>
On 22/4/24 14:52, Manos Pitsidianakis wrote:
> Extract audio card setup logic out of the device realize callback so
> that it can be re-used in follow up commits.
>
> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> ---
> hw/audio/virtio-snd.c | 72 ++++++++++++++++++++++++-------------------
> 1 file changed, 41 insertions(+), 31 deletions(-)
> +static void virtio_snd_realize(DeviceState *dev, Error **errp)
> +{
> + ERRP_GUARD();
> + VirtIOSound *vsnd = VIRTIO_SND(dev);
> + VirtIODevice *vdev = VIRTIO_DEVICE(dev);
> +
> + trace_virtio_snd_realize(vsnd);
> +
> + vsnd->vmstate =
> + qemu_add_vm_change_state_handler(virtio_snd_vm_state_change, vsnd);
> +
> + virtio_init(vdev, VIRTIO_ID_SOUND, sizeof(virtio_snd_config));
> + virtio_add_feature(&vsnd->features, VIRTIO_F_VERSION_1);
> +
> vsnd->queues[VIRTIO_SND_VQ_CONTROL] =
> virtio_add_queue(vdev, 64, virtio_snd_handle_ctrl);
> vsnd->queues[VIRTIO_SND_VQ_EVENT] =
> @@ -1123,26 +1149,10 @@ static void virtio_snd_realize(DeviceState *dev, Error **errp)
> QTAILQ_INIT(&vsnd->cmdq);
> QSIMPLEQ_INIT(&vsnd->invalid);
>
> - for (uint32_t i = 0; i < vsnd->snd_conf.streams; i++) {
> - status = virtio_snd_set_pcm_params(vsnd, i, &default_params);
> - if (status != cpu_to_le32(VIRTIO_SND_S_OK)) {
> - error_setg(errp,
> - "Can't initialize stream params, device responded with %s.",
> - print_code(status));
> - goto error_cleanup;
> - }
> - status = virtio_snd_pcm_prepare(vsnd, i);
> - if (status != cpu_to_le32(VIRTIO_SND_S_OK)) {
> - error_setg(errp,
> - "Can't prepare streams, device responded with %s.",
> - print_code(status));
> - goto error_cleanup;
> - }
> + if (virtio_snd_setup(vsnd, errp)) {
> + return;
> }
>
> - return;
> -
> -error_cleanup:
> virtio_snd_unrealize(dev);
We usually handle failure as:
if (!virtio_snd_setup(vsnd, errp)) {
virtio_snd_unrealize(dev);
}
> }
>
Otherwise LGTM.
next prev parent reply other threads:[~2024-04-22 13:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 12:52 [PATCH v1 0/4] virtio_snd_set_config: Fix #2296 Manos Pitsidianakis
2024-04-22 12:52 ` [PATCH v1 1/4] virtio-snd: add virtio_snd_is_config_valid() Manos Pitsidianakis
2024-04-22 13:20 ` Philippe Mathieu-Daudé
2024-04-22 12:52 ` [PATCH v1 2/4] virtio-snd: factor card setup out of realize func Manos Pitsidianakis
2024-04-22 13:23 ` Philippe Mathieu-Daudé [this message]
2024-04-22 12:52 ` [PATCH v1 3/4] virtio-snd: factor card removal out of unrealize() Manos Pitsidianakis
2024-04-22 13:27 ` Philippe Mathieu-Daudé
2024-04-23 8:17 ` Philippe Mathieu-Daudé
2024-04-22 12:52 ` [PATCH v1 4/4] virtio_snd_set_config: validate and re-setup card Manos Pitsidianakis
2024-09-01 13:25 ` [PATCH v1 0/4] virtio_snd_set_config: Fix #2296 Volker Rümelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=095032a6-df77-44b3-85e5-750993332a26@linaro.org \
--to=philmd@linaro.org \
--cc=kraxel@redhat.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=zheyuma97@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).