2
0

vhost-user-vga.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include "qom/object.h"
  14. #define TYPE_VHOST_USER_VGA "vhost-user-vga"
  15. typedef struct VhostUserVGA VhostUserVGA;
  16. DECLARE_INSTANCE_CHECKER(VhostUserVGA, VHOST_USER_VGA,
  17. TYPE_VHOST_USER_VGA)
  18. struct VhostUserVGA {
  19. VirtIOVGABase parent_obj;
  20. VhostUserGPU vdev;
  21. };
  22. static void vhost_user_vga_inst_initfn(Object *obj)
  23. {
  24. VhostUserVGA *dev = VHOST_USER_VGA(obj);
  25. virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  26. TYPE_VHOST_USER_GPU);
  27. VIRTIO_VGA_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
  28. object_property_add_alias(obj, "chardev",
  29. OBJECT(&dev->vdev), "chardev");
  30. }
  31. static const VirtioPCIDeviceTypeInfo vhost_user_vga_info = {
  32. .generic_name = TYPE_VHOST_USER_VGA,
  33. .parent = TYPE_VIRTIO_VGA_BASE,
  34. .instance_size = sizeof(VhostUserVGA),
  35. .instance_init = vhost_user_vga_inst_initfn,
  36. };
  37. module_obj(TYPE_VHOST_USER_VGA);
  38. module_kconfig(VHOST_USER_VGA);
  39. static void vhost_user_vga_register_types(void)
  40. {
  41. virtio_pci_types_register(&vhost_user_vga_info);
  42. }
  43. type_init(vhost_user_vga_register_types)