mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
hw/virtio: add vhost-user-snd and vhost-user-snd-pci devices
Tested with rust-vmm vhost-user-sound daemon:
RUST_LOG=trace cargo run --bin vhost-user-sound -- --socket /tmp/snd.sock --backend null
Invocation:
qemu-system-x86_64 \
-qmp unix:./qmp-sock,server,wait=off \
-m 4096 \
-numa node,memdev=mem \
-object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \
-D qemu.log \
-d guest_errors,trace:\*snd\*,trace:\*sound\*,trace:\*vhost\* \
-chardev socket,id=vsnd,path=/tmp/snd.sock \
-device vhost-user-snd-pci,chardev=vsnd,id=snd \
/path/to/disk
[AJB: imported from 54ae1cdd15
.patch]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-Id: <20240104210945.1223134-7-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a50616b50d
commit
4ae0fc18a1
6 changed files with 181 additions and 0 deletions
67
hw/virtio/vhost-user-snd.c
Normal file
67
hw/virtio/vhost-user-snd.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Vhost-user snd virtio device
|
||||
*
|
||||
* Copyright (c) 2023 Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
|
||||
*
|
||||
* Simple wrapper of the generic vhost-user-device.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/virtio/virtio-bus.h"
|
||||
#include "hw/virtio/vhost-user-snd.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_snd.h"
|
||||
|
||||
static const VMStateDescription vu_snd_vmstate = {
|
||||
.name = "vhost-user-snd",
|
||||
.unmigratable = 1,
|
||||
};
|
||||
|
||||
static Property vsnd_properties[] = {
|
||||
DEFINE_PROP_CHR("chardev", VHostUserBase, chardev),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void vu_snd_base_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
VHostUserBase *vub = VHOST_USER_BASE(dev);
|
||||
VHostUserBaseClass *vubs = VHOST_USER_BASE_GET_CLASS(dev);
|
||||
|
||||
vub->virtio_id = VIRTIO_ID_SOUND;
|
||||
vub->num_vqs = 4;
|
||||
vub->config_size = sizeof(struct virtio_snd_config);
|
||||
vub->vq_size = 64;
|
||||
|
||||
vubs->parent_realize(dev, errp);
|
||||
}
|
||||
|
||||
static void vu_snd_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass);
|
||||
|
||||
dc->vmsd = &vu_snd_vmstate;
|
||||
device_class_set_props(dc, vsnd_properties);
|
||||
device_class_set_parent_realize(dc, vu_snd_base_realize,
|
||||
&vubc->parent_realize);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
|
||||
}
|
||||
|
||||
static const TypeInfo vu_snd_info = {
|
||||
.name = TYPE_VHOST_USER_SND,
|
||||
.parent = TYPE_VHOST_USER_BASE,
|
||||
.instance_size = sizeof(VHostUserSound),
|
||||
.class_init = vu_snd_class_init,
|
||||
};
|
||||
|
||||
static void vu_snd_register_types(void)
|
||||
{
|
||||
type_register_static(&vu_snd_info);
|
||||
}
|
||||
|
||||
type_init(vu_snd_register_types)
|
Loading…
Add table
Add a link
Reference in a new issue