vhost-user-gpu-pci.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #define TYPE_VHOST_USER_GPU_PCI "vhost-user-gpu-pci"
  14. #define VHOST_USER_GPU_PCI(obj) \
  15. OBJECT_CHECK(VhostUserGPUPCI, (obj), TYPE_VHOST_USER_GPU_PCI)
  16. typedef struct VhostUserGPUPCI {
  17. VirtIOGPUPCIBase parent_obj;
  18. VhostUserGPU vdev;
  19. } VhostUserGPUPCI;
  20. static void vhost_user_gpu_pci_initfn(Object *obj)
  21. {
  22. VhostUserGPUPCI *dev = VHOST_USER_GPU_PCI(obj);
  23. virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  24. TYPE_VHOST_USER_GPU);
  25. VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
  26. object_property_add_alias(obj, "chardev",
  27. OBJECT(&dev->vdev), "chardev");
  28. }
  29. static const VirtioPCIDeviceTypeInfo vhost_user_gpu_pci_info = {
  30. .generic_name = TYPE_VHOST_USER_GPU_PCI,
  31. .parent = TYPE_VIRTIO_GPU_PCI_BASE,
  32. .instance_size = sizeof(VhostUserGPUPCI),
  33. .instance_init = vhost_user_gpu_pci_initfn,
  34. };
  35. static void vhost_user_gpu_pci_register_types(void)
  36. {
  37. virtio_pci_types_register(&vhost_user_gpu_pci_info);
  38. }
  39. type_init(vhost_user_gpu_pci_register_types)