2
0

vhost-user-gpu-pci.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * vhost-user GPU PCI 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 "hw/virtio/virtio-gpu-pci.h"
  13. #include "qom/object.h"
  14. #define TYPE_VHOST_USER_GPU_PCI "vhost-user-gpu-pci"
  15. typedef struct VhostUserGPUPCI VhostUserGPUPCI;
  16. DECLARE_INSTANCE_CHECKER(VhostUserGPUPCI, VHOST_USER_GPU_PCI,
  17. TYPE_VHOST_USER_GPU_PCI)
  18. struct VhostUserGPUPCI {
  19. VirtIOGPUPCIBase parent_obj;
  20. VhostUserGPU vdev;
  21. };
  22. static void vhost_user_gpu_pci_initfn(Object *obj)
  23. {
  24. VhostUserGPUPCI *dev = VHOST_USER_GPU_PCI(obj);
  25. virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  26. TYPE_VHOST_USER_GPU);
  27. VIRTIO_GPU_PCI_BASE(obj)->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_gpu_pci_info = {
  32. .generic_name = TYPE_VHOST_USER_GPU_PCI,
  33. .parent = TYPE_VIRTIO_GPU_PCI_BASE,
  34. .instance_size = sizeof(VhostUserGPUPCI),
  35. .instance_init = vhost_user_gpu_pci_initfn,
  36. };
  37. module_obj(TYPE_VHOST_USER_GPU_PCI);
  38. module_kconfig(VHOST_USER_GPU);
  39. static void vhost_user_gpu_pci_register_types(void)
  40. {
  41. virtio_pci_types_register(&vhost_user_gpu_pci_info);
  42. }
  43. type_init(vhost_user_gpu_pci_register_types)