vhost-user-vga.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * vhost-user VGA device
  3. *
  4. * Copyright Red Hat, Inc. 2018
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  7. * See the COPYING file in the top-level directory.
  8. *
  9. */
  10. #include "qemu/osdep.h"
  11. #include "qapi/error.h"
  12. #include "virtio-vga.h"
  13. #define TYPE_VHOST_USER_VGA "vhost-user-vga"
  14. #define VHOST_USER_VGA(obj) \
  15. OBJECT_CHECK(VhostUserVGA, (obj), TYPE_VHOST_USER_VGA)
  16. typedef struct VhostUserVGA {
  17. VirtIOVGABase parent_obj;
  18. VhostUserGPU vdev;
  19. } VhostUserVGA;
  20. static void vhost_user_vga_inst_initfn(Object *obj)
  21. {
  22. VhostUserVGA *dev = VHOST_USER_VGA(obj);
  23. virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  24. TYPE_VHOST_USER_GPU);
  25. VIRTIO_VGA_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
  26. object_property_add_alias(obj, "chardev",
  27. OBJECT(&dev->vdev), "chardev",
  28. &error_abort);
  29. }
  30. static const VirtioPCIDeviceTypeInfo vhost_user_vga_info = {
  31. .generic_name = TYPE_VHOST_USER_VGA,
  32. .parent = TYPE_VIRTIO_VGA_BASE,
  33. .instance_size = sizeof(struct VhostUserVGA),
  34. .instance_init = vhost_user_vga_inst_initfn,
  35. };
  36. static void vhost_user_vga_register_types(void)
  37. {
  38. virtio_pci_types_register(&vhost_user_vga_info);
  39. }
  40. type_init(vhost_user_vga_register_types)