All of lore.kernel.org
 help / color / mirror / Atom feed
* [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active
@ 2023-07-19 23:21 Roman Kiryanov
  2023-07-20 15:40 ` Stefan Hajnoczi
  2023-07-21  7:44 ` Matias Ezequiel Vara Larsen
  0 siblings, 2 replies; 5+ messages in thread
From: Roman Kiryanov @ 2023-07-19 23:21 UTC (permalink / raw)
  To: virtio-dev; +Cc: JP Cottin, Jorge Moreira Broche

Hi,

I work in Android Studio Emulator and we use virtio-snd (implemented
ourselves) for audio output/input. According to the spec (1.2), the
device has one TX virtqueue for all output streams and one RX
virtqueue for all input streams. Each stream may and usually have more
than one period (I request 4 periods).

Because virtqueues are shared between streams (if there are more than
one stream in the same direction), I cannot fetch vq messages when a
stream needs one. I fetch vq messages (and put them into my own buffer
to process them later) when the kernel puts them into a vq. I hope
this is correct. I think I tried processing them immediately (at least
for TX) but the kernel was not happy with this because I was draining
the buffer too fast causing XRUN.

If a snapshot request comes when audio streams are active I may have
several unprocessed messages for several streams for both TX and RX.
In my case messages are VirtQueueElement* which I don't think can be
saved directly.

Could you please advise what a device is expected to do in this case?

Thank you.

Regards,
Roman.

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active
  2023-07-19 23:21 [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active Roman Kiryanov
@ 2023-07-20 15:40 ` Stefan Hajnoczi
  2023-07-22  5:15   ` Roman Kiryanov
  2023-07-21  7:44 ` Matias Ezequiel Vara Larsen
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2023-07-20 15:40 UTC (permalink / raw)
  To: Roman Kiryanov; +Cc: virtio-dev, JP Cottin, Jorge Moreira Broche

[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]

On Wed, Jul 19, 2023 at 04:21:08PM -0700, Roman Kiryanov wrote:
> Hi,
> 
> I work in Android Studio Emulator and we use virtio-snd (implemented
> ourselves) for audio output/input. According to the spec (1.2), the
> device has one TX virtqueue for all output streams and one RX
> virtqueue for all input streams. Each stream may and usually have more
> than one period (I request 4 periods).
> 
> Because virtqueues are shared between streams (if there are more than
> one stream in the same direction), I cannot fetch vq messages when a
> stream needs one. I fetch vq messages (and put them into my own buffer
> to process them later) when the kernel puts them into a vq. I hope
> this is correct. I think I tried processing them immediately (at least
> for TX) but the kernel was not happy with this because I was draining
> the buffer too fast causing XRUN.
> 
> If a snapshot request comes when audio streams are active I may have
> several unprocessed messages for several streams for both TX and RX.
> In my case messages are VirtQueueElement* which I don't think can be
> saved directly.
> 
> Could you please advise what a device is expected to do in this case?

Do you mean QEMU's VirtQueueElement? There are devices in QEMU that
save/load in-flight VirtQueueElements. See qemu_put_virtqueue_element().

Often devices quiesce (e.g. by draining in-flight I/O requests) when the
VM is stopped before the device state is saved. That makes life simpler.

Stefan

> 
> Thank you.
> 
> Regards,
> Roman.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active
  2023-07-19 23:21 [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active Roman Kiryanov
  2023-07-20 15:40 ` Stefan Hajnoczi
@ 2023-07-21  7:44 ` Matias Ezequiel Vara Larsen
  2023-07-22  5:19   ` Roman Kiryanov
  1 sibling, 1 reply; 5+ messages in thread
From: Matias Ezequiel Vara Larsen @ 2023-07-21  7:44 UTC (permalink / raw)
  To: Roman Kiryanov; +Cc: virtio-dev, JP Cottin, Jorge Moreira Broche

Hello Roman,

On Wed, Jul 19, 2023 at 04:21:08PM -0700, Roman Kiryanov wrote:
> Hi,
> 
> I work in Android Studio Emulator and we use virtio-snd (implemented
> ourselves) for audio output/input. According to the spec (1.2), the
> device has one TX virtqueue for all output streams and one RX
> virtqueue for all input streams. Each stream may and usually have more
> than one period (I request 4 periods).
> 
> Because virtqueues are shared between streams (if there are more than
> one stream in the same direction), I cannot fetch vq messages when a
> stream needs one. I fetch vq messages (and put them into my own buffer
> to process them later) when the kernel puts them into a vq. I hope
> this is correct. 

I think this is correct. If I understand correctly, this is the idea of
the pre-buffering after the PREPARE command, i.e., to feed the audio
engine before to START streaming (see section 5.14.6.6.1 PCM Command
Lifecycle).

> I think I tried processing them immediately (at least
> for TX) but the kernel was not happy with this because I was draining
> the buffer too fast causing XRUN.
> If a snapshot request comes when audio streams are active I may have
> several unprocessed messages for several streams for both TX and RX.
> In my case messages are VirtQueueElement* which I don't think can be
> saved directly.
> 
> Could you please advise what a device is expected to do in this case?
> 

Do you mean what a VMM shall do when taking a snapshot regarding the
virtio-snd device?

Matias


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active
  2023-07-20 15:40 ` Stefan Hajnoczi
@ 2023-07-22  5:15   ` Roman Kiryanov
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Kiryanov @ 2023-07-22  5:15 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: virtio-dev, JP Cottin, Jorge Moreira Broche

On Thu, Jul 20, 2023 at 8:41 AM Stefan Hajnoczi <stefanha@redhat.com> wrote:

> > Could you please advise what a device is expected to do in this case?
>
> Do you mean QEMU's VirtQueueElement? There are devices in QEMU that
> save/load in-flight VirtQueueElements. See qemu_put_virtqueue_element().

Thank you, Stefan. I found examples on how to use
qemu_put_virtqueue_element. This is clear now.

Regards,
Roman.

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active
  2023-07-21  7:44 ` Matias Ezequiel Vara Larsen
@ 2023-07-22  5:19   ` Roman Kiryanov
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Kiryanov @ 2023-07-22  5:19 UTC (permalink / raw)
  To: Matias Ezequiel Vara Larsen; +Cc: virtio-dev, JP Cottin, Jorge Moreira Broche

On Fri, Jul 21, 2023 at 12:44 AM Matias Ezequiel Vara Larsen
<mvaralar@redhat.com> wrote:
> > Could you please advise what a device is expected to do in this case?
> >
>
> Do you mean what a VMM shall do when taking a snapshot regarding the
> virtio-snd device?

Thank you for looking into this, Matias. Stefan already pointed to use
qemu_put_virtqueue_element to save unprocessed messages in virtio-snd
when taking a snapshot.

Regards,
Roman.

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-22  5:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19 23:21 [virtio-dev] virtio-snd and snapshots (e.g. in QEMU) when audio is active Roman Kiryanov
2023-07-20 15:40 ` Stefan Hajnoczi
2023-07-22  5:15   ` Roman Kiryanov
2023-07-21  7:44 ` Matias Ezequiel Vara Larsen
2023-07-22  5:19   ` Roman Kiryanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.