vhost-user-gpu.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /*
  2. * vhost-user GPU Device
  3. *
  4. * Copyright Red Hat, Inc. 2018
  5. *
  6. * Authors:
  7. * Marc-André Lureau <marcandre.lureau@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "hw/qdev-properties.h"
  14. #include "hw/virtio/virtio-gpu.h"
  15. #include "chardev/char-fe.h"
  16. #include "qapi/error.h"
  17. #include "migration/blocker.h"
  18. #define VHOST_USER_GPU(obj) \
  19. OBJECT_CHECK(VhostUserGPU, (obj), TYPE_VHOST_USER_GPU)
  20. typedef enum VhostUserGpuRequest {
  21. VHOST_USER_GPU_NONE = 0,
  22. VHOST_USER_GPU_GET_PROTOCOL_FEATURES,
  23. VHOST_USER_GPU_SET_PROTOCOL_FEATURES,
  24. VHOST_USER_GPU_GET_DISPLAY_INFO,
  25. VHOST_USER_GPU_CURSOR_POS,
  26. VHOST_USER_GPU_CURSOR_POS_HIDE,
  27. VHOST_USER_GPU_CURSOR_UPDATE,
  28. VHOST_USER_GPU_SCANOUT,
  29. VHOST_USER_GPU_UPDATE,
  30. VHOST_USER_GPU_DMABUF_SCANOUT,
  31. VHOST_USER_GPU_DMABUF_UPDATE,
  32. } VhostUserGpuRequest;
  33. typedef struct VhostUserGpuDisplayInfoReply {
  34. struct virtio_gpu_resp_display_info info;
  35. } VhostUserGpuDisplayInfoReply;
  36. typedef struct VhostUserGpuCursorPos {
  37. uint32_t scanout_id;
  38. uint32_t x;
  39. uint32_t y;
  40. } QEMU_PACKED VhostUserGpuCursorPos;
  41. typedef struct VhostUserGpuCursorUpdate {
  42. VhostUserGpuCursorPos pos;
  43. uint32_t hot_x;
  44. uint32_t hot_y;
  45. uint32_t data[64 * 64];
  46. } QEMU_PACKED VhostUserGpuCursorUpdate;
  47. typedef struct VhostUserGpuScanout {
  48. uint32_t scanout_id;
  49. uint32_t width;
  50. uint32_t height;
  51. } QEMU_PACKED VhostUserGpuScanout;
  52. typedef struct VhostUserGpuUpdate {
  53. uint32_t scanout_id;
  54. uint32_t x;
  55. uint32_t y;
  56. uint32_t width;
  57. uint32_t height;
  58. uint8_t data[];
  59. } QEMU_PACKED VhostUserGpuUpdate;
  60. typedef struct VhostUserGpuDMABUFScanout {
  61. uint32_t scanout_id;
  62. uint32_t x;
  63. uint32_t y;
  64. uint32_t width;
  65. uint32_t height;
  66. uint32_t fd_width;
  67. uint32_t fd_height;
  68. uint32_t fd_stride;
  69. uint32_t fd_flags;
  70. int fd_drm_fourcc;
  71. } QEMU_PACKED VhostUserGpuDMABUFScanout;
  72. typedef struct VhostUserGpuMsg {
  73. uint32_t request; /* VhostUserGpuRequest */
  74. uint32_t flags;
  75. uint32_t size; /* the following payload size */
  76. union {
  77. VhostUserGpuCursorPos cursor_pos;
  78. VhostUserGpuCursorUpdate cursor_update;
  79. VhostUserGpuScanout scanout;
  80. VhostUserGpuUpdate update;
  81. VhostUserGpuDMABUFScanout dmabuf_scanout;
  82. struct virtio_gpu_resp_display_info display_info;
  83. uint64_t u64;
  84. } payload;
  85. } QEMU_PACKED VhostUserGpuMsg;
  86. static VhostUserGpuMsg m __attribute__ ((unused));
  87. #define VHOST_USER_GPU_HDR_SIZE \
  88. (sizeof(m.request) + sizeof(m.size) + sizeof(m.flags))
  89. #define VHOST_USER_GPU_MSG_FLAG_REPLY 0x4
  90. static void vhost_user_gpu_update_blocked(VhostUserGPU *g, bool blocked);
  91. static void
  92. vhost_user_gpu_handle_cursor(VhostUserGPU *g, VhostUserGpuMsg *msg)
  93. {
  94. VhostUserGpuCursorPos *pos = &msg->payload.cursor_pos;
  95. struct virtio_gpu_scanout *s;
  96. if (pos->scanout_id >= g->parent_obj.conf.max_outputs) {
  97. return;
  98. }
  99. s = &g->parent_obj.scanout[pos->scanout_id];
  100. if (msg->request == VHOST_USER_GPU_CURSOR_UPDATE) {
  101. VhostUserGpuCursorUpdate *up = &msg->payload.cursor_update;
  102. if (!s->current_cursor) {
  103. s->current_cursor = cursor_alloc(64, 64);
  104. }
  105. s->current_cursor->hot_x = up->hot_x;
  106. s->current_cursor->hot_y = up->hot_y;
  107. memcpy(s->current_cursor->data, up->data,
  108. 64 * 64 * sizeof(uint32_t));
  109. dpy_cursor_define(s->con, s->current_cursor);
  110. }
  111. dpy_mouse_set(s->con, pos->x, pos->y,
  112. msg->request != VHOST_USER_GPU_CURSOR_POS_HIDE);
  113. }
  114. static void
  115. vhost_user_gpu_send_msg(VhostUserGPU *g, const VhostUserGpuMsg *msg)
  116. {
  117. qemu_chr_fe_write(&g->vhost_chr, (uint8_t *)msg,
  118. VHOST_USER_GPU_HDR_SIZE + msg->size);
  119. }
  120. static void
  121. vhost_user_gpu_unblock(VhostUserGPU *g)
  122. {
  123. VhostUserGpuMsg msg = {
  124. .request = VHOST_USER_GPU_DMABUF_UPDATE,
  125. .flags = VHOST_USER_GPU_MSG_FLAG_REPLY,
  126. };
  127. vhost_user_gpu_send_msg(g, &msg);
  128. }
  129. static void
  130. vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)
  131. {
  132. QemuConsole *con = NULL;
  133. struct virtio_gpu_scanout *s;
  134. switch (msg->request) {
  135. case VHOST_USER_GPU_GET_PROTOCOL_FEATURES: {
  136. VhostUserGpuMsg reply = {
  137. .request = msg->request,
  138. .flags = VHOST_USER_GPU_MSG_FLAG_REPLY,
  139. .size = sizeof(uint64_t),
  140. };
  141. vhost_user_gpu_send_msg(g, &reply);
  142. break;
  143. }
  144. case VHOST_USER_GPU_SET_PROTOCOL_FEATURES: {
  145. break;
  146. }
  147. case VHOST_USER_GPU_GET_DISPLAY_INFO: {
  148. struct virtio_gpu_resp_display_info display_info = { {} };
  149. VhostUserGpuMsg reply = {
  150. .request = msg->request,
  151. .flags = VHOST_USER_GPU_MSG_FLAG_REPLY,
  152. .size = sizeof(struct virtio_gpu_resp_display_info),
  153. };
  154. display_info.hdr.type = VIRTIO_GPU_RESP_OK_DISPLAY_INFO;
  155. virtio_gpu_base_fill_display_info(VIRTIO_GPU_BASE(g), &display_info);
  156. memcpy(&reply.payload.display_info, &display_info,
  157. sizeof(display_info));
  158. vhost_user_gpu_send_msg(g, &reply);
  159. break;
  160. }
  161. case VHOST_USER_GPU_SCANOUT: {
  162. VhostUserGpuScanout *m = &msg->payload.scanout;
  163. if (m->scanout_id >= g->parent_obj.conf.max_outputs) {
  164. return;
  165. }
  166. g->parent_obj.enable = 1;
  167. s = &g->parent_obj.scanout[m->scanout_id];
  168. con = s->con;
  169. if (m->scanout_id == 0 && m->width == 0) {
  170. s->ds = qemu_create_message_surface(640, 480,
  171. "Guest disabled display.");
  172. dpy_gfx_replace_surface(con, s->ds);
  173. } else {
  174. s->ds = qemu_create_displaysurface(m->width, m->height);
  175. /* replace surface on next update */
  176. }
  177. break;
  178. }
  179. case VHOST_USER_GPU_DMABUF_SCANOUT: {
  180. VhostUserGpuDMABUFScanout *m = &msg->payload.dmabuf_scanout;
  181. int fd = qemu_chr_fe_get_msgfd(&g->vhost_chr);
  182. QemuDmaBuf *dmabuf;
  183. if (m->scanout_id >= g->parent_obj.conf.max_outputs) {
  184. error_report("invalid scanout: %d", m->scanout_id);
  185. if (fd >= 0) {
  186. close(fd);
  187. }
  188. break;
  189. }
  190. g->parent_obj.enable = 1;
  191. con = g->parent_obj.scanout[m->scanout_id].con;
  192. dmabuf = &g->dmabuf[m->scanout_id];
  193. if (dmabuf->fd >= 0) {
  194. close(dmabuf->fd);
  195. dmabuf->fd = -1;
  196. }
  197. if (!console_has_gl_dmabuf(con)) {
  198. /* it would be nice to report that error earlier */
  199. error_report("console doesn't support dmabuf!");
  200. break;
  201. }
  202. dpy_gl_release_dmabuf(con, dmabuf);
  203. if (fd == -1) {
  204. dpy_gl_scanout_disable(con);
  205. break;
  206. }
  207. *dmabuf = (QemuDmaBuf) {
  208. .fd = fd,
  209. .width = m->fd_width,
  210. .height = m->fd_height,
  211. .stride = m->fd_stride,
  212. .fourcc = m->fd_drm_fourcc,
  213. .y0_top = m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
  214. };
  215. dpy_gl_scanout_dmabuf(con, dmabuf);
  216. break;
  217. }
  218. case VHOST_USER_GPU_DMABUF_UPDATE: {
  219. VhostUserGpuUpdate *m = &msg->payload.update;
  220. if (m->scanout_id >= g->parent_obj.conf.max_outputs ||
  221. !g->parent_obj.scanout[m->scanout_id].con) {
  222. error_report("invalid scanout update: %d", m->scanout_id);
  223. vhost_user_gpu_unblock(g);
  224. break;
  225. }
  226. con = g->parent_obj.scanout[m->scanout_id].con;
  227. if (!console_has_gl(con)) {
  228. error_report("console doesn't support GL!");
  229. vhost_user_gpu_unblock(g);
  230. break;
  231. }
  232. dpy_gl_update(con, m->x, m->y, m->width, m->height);
  233. g->backend_blocked = true;
  234. break;
  235. }
  236. case VHOST_USER_GPU_UPDATE: {
  237. VhostUserGpuUpdate *m = &msg->payload.update;
  238. if (m->scanout_id >= g->parent_obj.conf.max_outputs) {
  239. break;
  240. }
  241. s = &g->parent_obj.scanout[m->scanout_id];
  242. con = s->con;
  243. pixman_image_t *image =
  244. pixman_image_create_bits(PIXMAN_x8r8g8b8,
  245. m->width,
  246. m->height,
  247. (uint32_t *)m->data,
  248. m->width * 4);
  249. pixman_image_composite(PIXMAN_OP_SRC,
  250. image, NULL, s->ds->image,
  251. 0, 0, 0, 0, m->x, m->y, m->width, m->height);
  252. pixman_image_unref(image);
  253. if (qemu_console_surface(con) != s->ds) {
  254. dpy_gfx_replace_surface(con, s->ds);
  255. } else {
  256. dpy_gfx_update(con, m->x, m->y, m->width, m->height);
  257. }
  258. break;
  259. }
  260. default:
  261. g_warning("unhandled message %d %d", msg->request, msg->size);
  262. }
  263. if (con && qemu_console_is_gl_blocked(con)) {
  264. vhost_user_gpu_update_blocked(g, true);
  265. }
  266. }
  267. static void
  268. vhost_user_gpu_chr_read(void *opaque)
  269. {
  270. VhostUserGPU *g = opaque;
  271. VhostUserGpuMsg *msg = NULL;
  272. VhostUserGpuRequest request;
  273. uint32_t size, flags;
  274. int r;
  275. r = qemu_chr_fe_read_all(&g->vhost_chr,
  276. (uint8_t *)&request, sizeof(uint32_t));
  277. if (r != sizeof(uint32_t)) {
  278. error_report("failed to read msg header: %d, %d", r, errno);
  279. goto end;
  280. }
  281. r = qemu_chr_fe_read_all(&g->vhost_chr,
  282. (uint8_t *)&flags, sizeof(uint32_t));
  283. if (r != sizeof(uint32_t)) {
  284. error_report("failed to read msg flags");
  285. goto end;
  286. }
  287. r = qemu_chr_fe_read_all(&g->vhost_chr,
  288. (uint8_t *)&size, sizeof(uint32_t));
  289. if (r != sizeof(uint32_t)) {
  290. error_report("failed to read msg size");
  291. goto end;
  292. }
  293. msg = g_malloc(VHOST_USER_GPU_HDR_SIZE + size);
  294. g_return_if_fail(msg != NULL);
  295. r = qemu_chr_fe_read_all(&g->vhost_chr,
  296. (uint8_t *)&msg->payload, size);
  297. if (r != size) {
  298. error_report("failed to read msg payload %d != %d", r, size);
  299. goto end;
  300. }
  301. msg->request = request;
  302. msg->flags = size;
  303. msg->size = size;
  304. if (request == VHOST_USER_GPU_CURSOR_UPDATE ||
  305. request == VHOST_USER_GPU_CURSOR_POS ||
  306. request == VHOST_USER_GPU_CURSOR_POS_HIDE) {
  307. vhost_user_gpu_handle_cursor(g, msg);
  308. } else {
  309. vhost_user_gpu_handle_display(g, msg);
  310. }
  311. end:
  312. g_free(msg);
  313. }
  314. static void
  315. vhost_user_gpu_update_blocked(VhostUserGPU *g, bool blocked)
  316. {
  317. qemu_set_fd_handler(g->vhost_gpu_fd,
  318. blocked ? NULL : vhost_user_gpu_chr_read, NULL, g);
  319. }
  320. static void
  321. vhost_user_gpu_gl_unblock(VirtIOGPUBase *b)
  322. {
  323. VhostUserGPU *g = VHOST_USER_GPU(b);
  324. if (g->backend_blocked) {
  325. vhost_user_gpu_unblock(VHOST_USER_GPU(g));
  326. g->backend_blocked = false;
  327. }
  328. vhost_user_gpu_update_blocked(VHOST_USER_GPU(g), false);
  329. }
  330. static bool
  331. vhost_user_gpu_do_set_socket(VhostUserGPU *g, Error **errp)
  332. {
  333. Chardev *chr;
  334. int sv[2];
  335. if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
  336. error_setg_errno(errp, errno, "socketpair() failed");
  337. return false;
  338. }
  339. chr = CHARDEV(object_new(TYPE_CHARDEV_SOCKET));
  340. if (!chr || qemu_chr_add_client(chr, sv[0]) == -1) {
  341. error_setg(errp, "Failed to make socket chardev");
  342. goto err;
  343. }
  344. if (!qemu_chr_fe_init(&g->vhost_chr, chr, errp)) {
  345. goto err;
  346. }
  347. if (vhost_user_gpu_set_socket(&g->vhost->dev, sv[1]) < 0) {
  348. error_setg(errp, "Failed to set vhost-user-gpu socket");
  349. qemu_chr_fe_deinit(&g->vhost_chr, false);
  350. goto err;
  351. }
  352. g->vhost_gpu_fd = sv[0];
  353. vhost_user_gpu_update_blocked(g, false);
  354. close(sv[1]);
  355. return true;
  356. err:
  357. close(sv[0]);
  358. close(sv[1]);
  359. if (chr) {
  360. object_unref(OBJECT(chr));
  361. }
  362. return false;
  363. }
  364. static void
  365. vhost_user_gpu_get_config(VirtIODevice *vdev, uint8_t *config_data)
  366. {
  367. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  368. VirtIOGPUBase *b = VIRTIO_GPU_BASE(vdev);
  369. struct virtio_gpu_config *vgconfig =
  370. (struct virtio_gpu_config *)config_data;
  371. int ret;
  372. memset(config_data, 0, sizeof(struct virtio_gpu_config));
  373. ret = vhost_dev_get_config(&g->vhost->dev,
  374. config_data, sizeof(struct virtio_gpu_config));
  375. if (ret) {
  376. error_report("vhost-user-gpu: get device config space failed");
  377. return;
  378. }
  379. /* those fields are managed by qemu */
  380. vgconfig->num_scanouts = b->virtio_config.num_scanouts;
  381. vgconfig->events_read = b->virtio_config.events_read;
  382. vgconfig->events_clear = b->virtio_config.events_clear;
  383. }
  384. static void
  385. vhost_user_gpu_set_config(VirtIODevice *vdev,
  386. const uint8_t *config_data)
  387. {
  388. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  389. VirtIOGPUBase *b = VIRTIO_GPU_BASE(vdev);
  390. const struct virtio_gpu_config *vgconfig =
  391. (const struct virtio_gpu_config *)config_data;
  392. int ret;
  393. if (vgconfig->events_clear) {
  394. b->virtio_config.events_read &= ~vgconfig->events_clear;
  395. }
  396. ret = vhost_dev_set_config(&g->vhost->dev, config_data,
  397. 0, sizeof(struct virtio_gpu_config),
  398. VHOST_SET_CONFIG_TYPE_MASTER);
  399. if (ret) {
  400. error_report("vhost-user-gpu: set device config space failed");
  401. return;
  402. }
  403. }
  404. static void
  405. vhost_user_gpu_set_status(VirtIODevice *vdev, uint8_t val)
  406. {
  407. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  408. Error *err = NULL;
  409. if (val & VIRTIO_CONFIG_S_DRIVER_OK && vdev->vm_running) {
  410. if (!vhost_user_gpu_do_set_socket(g, &err)) {
  411. error_report_err(err);
  412. return;
  413. }
  414. vhost_user_backend_start(g->vhost);
  415. } else {
  416. /* unblock any wait and stop processing */
  417. if (g->vhost_gpu_fd != -1) {
  418. vhost_user_gpu_update_blocked(g, true);
  419. qemu_chr_fe_deinit(&g->vhost_chr, true);
  420. g->vhost_gpu_fd = -1;
  421. }
  422. vhost_user_backend_stop(g->vhost);
  423. }
  424. }
  425. static bool
  426. vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx)
  427. {
  428. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  429. return vhost_virtqueue_pending(&g->vhost->dev, idx);
  430. }
  431. static void
  432. vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask)
  433. {
  434. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  435. vhost_virtqueue_mask(&g->vhost->dev, vdev, idx, mask);
  436. }
  437. static void
  438. vhost_user_gpu_instance_init(Object *obj)
  439. {
  440. VhostUserGPU *g = VHOST_USER_GPU(obj);
  441. g->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND));
  442. object_property_add_alias(obj, "chardev",
  443. OBJECT(g->vhost), "chardev");
  444. }
  445. static void
  446. vhost_user_gpu_instance_finalize(Object *obj)
  447. {
  448. VhostUserGPU *g = VHOST_USER_GPU(obj);
  449. object_unref(OBJECT(g->vhost));
  450. }
  451. static void
  452. vhost_user_gpu_reset(VirtIODevice *vdev)
  453. {
  454. VhostUserGPU *g = VHOST_USER_GPU(vdev);
  455. virtio_gpu_base_reset(VIRTIO_GPU_BASE(vdev));
  456. vhost_user_backend_stop(g->vhost);
  457. }
  458. static int
  459. vhost_user_gpu_config_change(struct vhost_dev *dev)
  460. {
  461. error_report("vhost-user-gpu: unhandled backend config change");
  462. return -1;
  463. }
  464. static const VhostDevConfigOps config_ops = {
  465. .vhost_dev_config_notifier = vhost_user_gpu_config_change,
  466. };
  467. static void
  468. vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp)
  469. {
  470. VhostUserGPU *g = VHOST_USER_GPU(qdev);
  471. VirtIODevice *vdev = VIRTIO_DEVICE(g);
  472. vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops);
  473. if (vhost_user_backend_dev_init(g->vhost, vdev, 2, errp) < 0) {
  474. return;
  475. }
  476. if (virtio_has_feature(g->vhost->dev.features, VIRTIO_GPU_F_VIRGL)) {
  477. g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED;
  478. }
  479. if (!virtio_gpu_base_device_realize(qdev, NULL, NULL, errp)) {
  480. return;
  481. }
  482. g->vhost_gpu_fd = -1;
  483. }
  484. static Property vhost_user_gpu_properties[] = {
  485. VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf),
  486. DEFINE_PROP_END_OF_LIST(),
  487. };
  488. static void
  489. vhost_user_gpu_class_init(ObjectClass *klass, void *data)
  490. {
  491. DeviceClass *dc = DEVICE_CLASS(klass);
  492. VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
  493. VirtIOGPUBaseClass *vgc = VIRTIO_GPU_BASE_CLASS(klass);
  494. vgc->gl_unblock = vhost_user_gpu_gl_unblock;
  495. vdc->realize = vhost_user_gpu_device_realize;
  496. vdc->reset = vhost_user_gpu_reset;
  497. vdc->set_status = vhost_user_gpu_set_status;
  498. vdc->guest_notifier_mask = vhost_user_gpu_guest_notifier_mask;
  499. vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending;
  500. vdc->get_config = vhost_user_gpu_get_config;
  501. vdc->set_config = vhost_user_gpu_set_config;
  502. device_class_set_props(dc, vhost_user_gpu_properties);
  503. }
  504. static const TypeInfo vhost_user_gpu_info = {
  505. .name = TYPE_VHOST_USER_GPU,
  506. .parent = TYPE_VIRTIO_GPU_BASE,
  507. .instance_size = sizeof(VhostUserGPU),
  508. .instance_init = vhost_user_gpu_instance_init,
  509. .instance_finalize = vhost_user_gpu_instance_finalize,
  510. .class_init = vhost_user_gpu_class_init,
  511. };
  512. static void vhost_user_gpu_register_types(void)
  513. {
  514. type_register_static(&vhost_user_gpu_info);
  515. }
  516. type_init(vhost_user_gpu_register_types)