@@ -72,7 +72,7 @@ use to communicate as well as share the guests memory over a memfd.
::
host# qemu-system \
- -device vhost-user-video-pci,chardev=video,id=video \
+ -device vhost-user-video-pci,chardev=video,dev_type=decoder,id=video \
-chardev socket,path=/tmp//video.sock,id=video \
-m 4096 \
-object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \
@@ -300,8 +300,16 @@ static void vhost_user_video_device_realize(DeviceState *dev, Error **errp)
return;
}
- /* TODO Implement VIDEO_ENC, currently only support VIDEO_DEC */
- virtio_init(vdev, VIRTIO_ID_VIDEO_DECODER, sizeof(struct virtio_video_config));
+ if (video->conf.type == NULL || !strcmp(video->conf.type, "decoder")) {
+ virtio_init(vdev, VIRTIO_ID_VIDEO_DECODER,
+ sizeof(struct virtio_video_config));
+ } else if (!strcmp(video->conf.type, "encoder")) {
+ virtio_init(vdev, VIRTIO_ID_VIDEO_ENCODER,
+ sizeof(struct virtio_video_config));
+ } else {
+ error_report("invalid type received: %s", video->conf.type);
+ goto vhost_dev_init_failed;
+ }
/* one command queue and one event queue */
video->vhost_dev.nvqs = 2;
@@ -375,6 +383,7 @@ static const VMStateDescription vhost_user_video_vmstate = {
static Property vhost_user_video_properties[] = {
DEFINE_PROP_CHR("chardev", VHostUserVIDEO, conf.chardev),
+ DEFINE_PROP_STRING("dev_type", VHostUserVIDEO, conf.type),
DEFINE_PROP_END_OF_LIST(),
};
@@ -22,6 +22,7 @@
typedef struct {
CharBackend chardev;
+ char *type;
struct virtio_video_config config;
} VHostUserVIDEOConf;
Add dev_type to the command line interface. This way we can select dev_type=encoder or dev_type=decoder and assign the virtio ID appropiately. If ommited, default virtio ID used is decoder's ID. Example: -device vhost-user-video-pci,chardev=video,dev_type=encoder,id=video Signed-off-by: Albert Esteve <aesteve@redhat.com> --- docs/system/devices/vhost-user-video.rst | 2 +- hw/display/vhost-user-video.c | 13 +++++++++++-- include/hw/virtio/vhost-user-video.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-)