spice-display.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * Copyright (C) 2010 Red Hat, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 or
  7. * (at your option) version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "qemu-common.h"
  18. #include "ui/qemu-spice.h"
  19. #include "qemu/timer.h"
  20. #include "qemu/queue.h"
  21. #include "monitor/monitor.h"
  22. #include "ui/console.h"
  23. #include "sysemu/sysemu.h"
  24. #include "trace.h"
  25. #include "ui/spice-display.h"
  26. static int debug = 0;
  27. static void GCC_FMT_ATTR(2, 3) dprint(int level, const char *fmt, ...)
  28. {
  29. va_list args;
  30. if (level <= debug) {
  31. va_start(args, fmt);
  32. vfprintf(stderr, fmt, args);
  33. va_end(args);
  34. }
  35. }
  36. int qemu_spice_rect_is_empty(const QXLRect* r)
  37. {
  38. return r->top == r->bottom || r->left == r->right;
  39. }
  40. void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r)
  41. {
  42. if (qemu_spice_rect_is_empty(r)) {
  43. return;
  44. }
  45. if (qemu_spice_rect_is_empty(dest)) {
  46. *dest = *r;
  47. return;
  48. }
  49. dest->top = MIN(dest->top, r->top);
  50. dest->left = MIN(dest->left, r->left);
  51. dest->bottom = MAX(dest->bottom, r->bottom);
  52. dest->right = MAX(dest->right, r->right);
  53. }
  54. QXLCookie *qxl_cookie_new(int type, uint64_t io)
  55. {
  56. QXLCookie *cookie;
  57. cookie = g_malloc0(sizeof(*cookie));
  58. cookie->type = type;
  59. cookie->io = io;
  60. return cookie;
  61. }
  62. void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
  63. qxl_async_io async)
  64. {
  65. trace_qemu_spice_add_memslot(ssd->qxl.id, memslot->slot_id,
  66. memslot->virt_start, memslot->virt_end,
  67. async);
  68. if (async != QXL_SYNC) {
  69. spice_qxl_add_memslot_async(&ssd->qxl, memslot,
  70. (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
  71. QXL_IO_MEMSLOT_ADD_ASYNC));
  72. } else {
  73. ssd->worker->add_memslot(ssd->worker, memslot);
  74. }
  75. }
  76. void qemu_spice_del_memslot(SimpleSpiceDisplay *ssd, uint32_t gid, uint32_t sid)
  77. {
  78. trace_qemu_spice_del_memslot(ssd->qxl.id, gid, sid);
  79. ssd->worker->del_memslot(ssd->worker, gid, sid);
  80. }
  81. void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
  82. QXLDevSurfaceCreate *surface,
  83. qxl_async_io async)
  84. {
  85. trace_qemu_spice_create_primary_surface(ssd->qxl.id, id, surface, async);
  86. if (async != QXL_SYNC) {
  87. spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface,
  88. (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
  89. QXL_IO_CREATE_PRIMARY_ASYNC));
  90. } else {
  91. ssd->worker->create_primary_surface(ssd->worker, id, surface);
  92. }
  93. }
  94. void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
  95. uint32_t id, qxl_async_io async)
  96. {
  97. trace_qemu_spice_destroy_primary_surface(ssd->qxl.id, id, async);
  98. if (async != QXL_SYNC) {
  99. spice_qxl_destroy_primary_surface_async(&ssd->qxl, id,
  100. (uintptr_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
  101. QXL_IO_DESTROY_PRIMARY_ASYNC));
  102. } else {
  103. ssd->worker->destroy_primary_surface(ssd->worker, id);
  104. }
  105. }
  106. void qemu_spice_wakeup(SimpleSpiceDisplay *ssd)
  107. {
  108. trace_qemu_spice_wakeup(ssd->qxl.id);
  109. ssd->worker->wakeup(ssd->worker);
  110. }
  111. static int spice_display_is_running;
  112. void qemu_spice_display_start(void)
  113. {
  114. spice_display_is_running = true;
  115. }
  116. void qemu_spice_display_stop(void)
  117. {
  118. spice_display_is_running = false;
  119. }
  120. int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
  121. {
  122. return spice_display_is_running;
  123. }
  124. static void qemu_spice_create_one_update(SimpleSpiceDisplay *ssd,
  125. QXLRect *rect)
  126. {
  127. SimpleSpiceUpdate *update;
  128. QXLDrawable *drawable;
  129. QXLImage *image;
  130. QXLCommand *cmd;
  131. int bw, bh;
  132. struct timespec time_space;
  133. pixman_image_t *dest;
  134. trace_qemu_spice_create_update(
  135. rect->left, rect->right,
  136. rect->top, rect->bottom);
  137. update = g_malloc0(sizeof(*update));
  138. drawable = &update->drawable;
  139. image = &update->image;
  140. cmd = &update->ext.cmd;
  141. bw = rect->right - rect->left;
  142. bh = rect->bottom - rect->top;
  143. update->bitmap = g_malloc(bw * bh * 4);
  144. drawable->bbox = *rect;
  145. drawable->clip.type = SPICE_CLIP_TYPE_NONE;
  146. drawable->effect = QXL_EFFECT_OPAQUE;
  147. drawable->release_info.id = (uintptr_t)update;
  148. drawable->type = QXL_DRAW_COPY;
  149. drawable->surfaces_dest[0] = -1;
  150. drawable->surfaces_dest[1] = -1;
  151. drawable->surfaces_dest[2] = -1;
  152. clock_gettime(CLOCK_MONOTONIC, &time_space);
  153. /* time in milliseconds from epoch. */
  154. drawable->mm_time = time_space.tv_sec * 1000
  155. + time_space.tv_nsec / 1000 / 1000;
  156. drawable->u.copy.rop_descriptor = SPICE_ROPD_OP_PUT;
  157. drawable->u.copy.src_bitmap = (uintptr_t)image;
  158. drawable->u.copy.src_area.right = bw;
  159. drawable->u.copy.src_area.bottom = bh;
  160. QXL_SET_IMAGE_ID(image, QXL_IMAGE_GROUP_DEVICE, ssd->unique++);
  161. image->descriptor.type = SPICE_IMAGE_TYPE_BITMAP;
  162. image->bitmap.flags = QXL_BITMAP_DIRECT | QXL_BITMAP_TOP_DOWN;
  163. image->bitmap.stride = bw * 4;
  164. image->descriptor.width = image->bitmap.x = bw;
  165. image->descriptor.height = image->bitmap.y = bh;
  166. image->bitmap.data = (uintptr_t)(update->bitmap);
  167. image->bitmap.palette = 0;
  168. image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
  169. dest = pixman_image_create_bits(PIXMAN_x8r8g8b8, bw, bh,
  170. (void *)update->bitmap, bw * 4);
  171. pixman_image_composite(PIXMAN_OP_SRC, ssd->surface, NULL, ssd->mirror,
  172. rect->left, rect->top, 0, 0,
  173. rect->left, rect->top, bw, bh);
  174. pixman_image_composite(PIXMAN_OP_SRC, ssd->mirror, NULL, dest,
  175. rect->left, rect->top, 0, 0,
  176. 0, 0, bw, bh);
  177. pixman_image_unref(dest);
  178. cmd->type = QXL_CMD_DRAW;
  179. cmd->data = (uintptr_t)drawable;
  180. QTAILQ_INSERT_TAIL(&ssd->updates, update, next);
  181. }
  182. static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
  183. {
  184. static const int blksize = 32;
  185. int blocks = (ds_get_width(ssd->ds) + blksize - 1) / blksize;
  186. int dirty_top[blocks];
  187. int y, yoff, x, xoff, blk, bw;
  188. int bpp = ds_get_bytes_per_pixel(ssd->ds);
  189. uint8_t *guest, *mirror;
  190. if (qemu_spice_rect_is_empty(&ssd->dirty)) {
  191. return;
  192. };
  193. if (ssd->surface == NULL) {
  194. ssd->surface = pixman_image_ref(ds_get_image(ssd->ds));
  195. ssd->mirror = qemu_pixman_mirror_create(ds_get_format(ssd->ds),
  196. ds_get_image(ssd->ds));
  197. }
  198. for (blk = 0; blk < blocks; blk++) {
  199. dirty_top[blk] = -1;
  200. }
  201. guest = ds_get_data(ssd->ds);
  202. mirror = (void *)pixman_image_get_data(ssd->mirror);
  203. for (y = ssd->dirty.top; y < ssd->dirty.bottom; y++) {
  204. yoff = y * ds_get_linesize(ssd->ds);
  205. for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) {
  206. xoff = x * bpp;
  207. blk = x / blksize;
  208. bw = MIN(blksize, ssd->dirty.right - x);
  209. if (memcmp(guest + yoff + xoff,
  210. mirror + yoff + xoff,
  211. bw * bpp) == 0) {
  212. if (dirty_top[blk] != -1) {
  213. QXLRect update = {
  214. .top = dirty_top[blk],
  215. .bottom = y,
  216. .left = x,
  217. .right = x + bw,
  218. };
  219. qemu_spice_create_one_update(ssd, &update);
  220. dirty_top[blk] = -1;
  221. }
  222. } else {
  223. if (dirty_top[blk] == -1) {
  224. dirty_top[blk] = y;
  225. }
  226. }
  227. }
  228. }
  229. for (x = ssd->dirty.left; x < ssd->dirty.right; x += blksize) {
  230. blk = x / blksize;
  231. bw = MIN(blksize, ssd->dirty.right - x);
  232. if (dirty_top[blk] != -1) {
  233. QXLRect update = {
  234. .top = dirty_top[blk],
  235. .bottom = ssd->dirty.bottom,
  236. .left = x,
  237. .right = x + bw,
  238. };
  239. qemu_spice_create_one_update(ssd, &update);
  240. dirty_top[blk] = -1;
  241. }
  242. }
  243. memset(&ssd->dirty, 0, sizeof(ssd->dirty));
  244. }
  245. /*
  246. * Called from spice server thread context (via interface_release_resource)
  247. * We do *not* hold the global qemu mutex here, so extra care is needed
  248. * when calling qemu functions. QEMU interfaces used:
  249. * - g_free (underlying glibc free is re-entrant).
  250. */
  251. void qemu_spice_destroy_update(SimpleSpiceDisplay *sdpy, SimpleSpiceUpdate *update)
  252. {
  253. g_free(update->bitmap);
  254. g_free(update);
  255. }
  256. void qemu_spice_create_host_memslot(SimpleSpiceDisplay *ssd)
  257. {
  258. QXLDevMemSlot memslot;
  259. dprint(1, "%s:\n", __FUNCTION__);
  260. memset(&memslot, 0, sizeof(memslot));
  261. memslot.slot_group_id = MEMSLOT_GROUP_HOST;
  262. memslot.virt_end = ~0;
  263. qemu_spice_add_memslot(ssd, &memslot, QXL_SYNC);
  264. }
  265. void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)
  266. {
  267. QXLDevSurfaceCreate surface;
  268. memset(&surface, 0, sizeof(surface));
  269. dprint(1, "%s: %dx%d\n", __FUNCTION__,
  270. ds_get_width(ssd->ds), ds_get_height(ssd->ds));
  271. surface.format = SPICE_SURFACE_FMT_32_xRGB;
  272. surface.width = ds_get_width(ssd->ds);
  273. surface.height = ds_get_height(ssd->ds);
  274. surface.stride = -surface.width * 4;
  275. surface.mouse_mode = true;
  276. surface.flags = 0;
  277. surface.type = 0;
  278. surface.mem = (uintptr_t)ssd->buf;
  279. surface.group_id = MEMSLOT_GROUP_HOST;
  280. qemu_spice_create_primary_surface(ssd, 0, &surface, QXL_SYNC);
  281. }
  282. void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd)
  283. {
  284. dprint(1, "%s:\n", __FUNCTION__);
  285. qemu_spice_destroy_primary_surface(ssd, 0, QXL_SYNC);
  286. }
  287. void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
  288. {
  289. ssd->ds = ds;
  290. qemu_mutex_init(&ssd->lock);
  291. QTAILQ_INIT(&ssd->updates);
  292. ssd->mouse_x = -1;
  293. ssd->mouse_y = -1;
  294. if (ssd->num_surfaces == 0) {
  295. ssd->num_surfaces = 1024;
  296. }
  297. ssd->bufsize = (16 * 1024 * 1024);
  298. ssd->buf = g_malloc(ssd->bufsize);
  299. }
  300. /* display listener callbacks */
  301. void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
  302. int x, int y, int w, int h)
  303. {
  304. QXLRect update_area;
  305. dprint(2, "%s: x %d y %d w %d h %d\n", __FUNCTION__, x, y, w, h);
  306. update_area.left = x,
  307. update_area.right = x + w;
  308. update_area.top = y;
  309. update_area.bottom = y + h;
  310. if (qemu_spice_rect_is_empty(&ssd->dirty)) {
  311. ssd->notify++;
  312. }
  313. qemu_spice_rect_union(&ssd->dirty, &update_area);
  314. }
  315. void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
  316. {
  317. SimpleSpiceUpdate *update;
  318. dprint(1, "%s:\n", __FUNCTION__);
  319. memset(&ssd->dirty, 0, sizeof(ssd->dirty));
  320. if (ssd->surface) {
  321. pixman_image_unref(ssd->surface);
  322. ssd->surface = NULL;
  323. pixman_image_unref(ssd->mirror);
  324. ssd->mirror = NULL;
  325. }
  326. qemu_mutex_lock(&ssd->lock);
  327. while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
  328. QTAILQ_REMOVE(&ssd->updates, update, next);
  329. qemu_spice_destroy_update(ssd, update);
  330. }
  331. qemu_mutex_unlock(&ssd->lock);
  332. qemu_spice_destroy_host_primary(ssd);
  333. qemu_spice_create_host_primary(ssd);
  334. memset(&ssd->dirty, 0, sizeof(ssd->dirty));
  335. ssd->notify++;
  336. }
  337. void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
  338. {
  339. if (ssd->cursor) {
  340. dpy_cursor_define(ssd->ds, ssd->cursor);
  341. cursor_put(ssd->cursor);
  342. ssd->cursor = NULL;
  343. }
  344. if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
  345. dpy_mouse_set(ssd->ds, ssd->mouse_x, ssd->mouse_y, 1);
  346. ssd->mouse_x = -1;
  347. ssd->mouse_y = -1;
  348. }
  349. }
  350. void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
  351. {
  352. dprint(3, "%s:\n", __func__);
  353. vga_hw_update();
  354. qemu_mutex_lock(&ssd->lock);
  355. if (QTAILQ_EMPTY(&ssd->updates)) {
  356. qemu_spice_create_update(ssd);
  357. ssd->notify++;
  358. }
  359. qemu_spice_cursor_refresh_unlocked(ssd);
  360. qemu_mutex_unlock(&ssd->lock);
  361. if (ssd->notify) {
  362. ssd->notify = 0;
  363. qemu_spice_wakeup(ssd);
  364. dprint(2, "%s: notify\n", __FUNCTION__);
  365. }
  366. }
  367. /* spice display interface callbacks */
  368. static void interface_attach_worker(QXLInstance *sin, QXLWorker *qxl_worker)
  369. {
  370. SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
  371. dprint(1, "%s:\n", __FUNCTION__);
  372. ssd->worker = qxl_worker;
  373. }
  374. static void interface_set_compression_level(QXLInstance *sin, int level)
  375. {
  376. dprint(1, "%s:\n", __FUNCTION__);
  377. /* nothing to do */
  378. }
  379. static void interface_set_mm_time(QXLInstance *sin, uint32_t mm_time)
  380. {
  381. dprint(3, "%s:\n", __FUNCTION__);
  382. /* nothing to do */
  383. }
  384. static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info)
  385. {
  386. SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
  387. info->memslot_gen_bits = MEMSLOT_GENERATION_BITS;
  388. info->memslot_id_bits = MEMSLOT_SLOT_BITS;
  389. info->num_memslots = NUM_MEMSLOTS;
  390. info->num_memslots_groups = NUM_MEMSLOTS_GROUPS;
  391. info->internal_groupslot_id = 0;
  392. info->qxl_ram_size = ssd->bufsize;
  393. info->n_surfaces = ssd->num_surfaces;
  394. }
  395. static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
  396. {
  397. SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
  398. SimpleSpiceUpdate *update;
  399. int ret = false;
  400. dprint(3, "%s:\n", __FUNCTION__);
  401. qemu_mutex_lock(&ssd->lock);
  402. update = QTAILQ_FIRST(&ssd->updates);
  403. if (update != NULL) {
  404. QTAILQ_REMOVE(&ssd->updates, update, next);
  405. *ext = update->ext;
  406. ret = true;
  407. }
  408. qemu_mutex_unlock(&ssd->lock);
  409. return ret;
  410. }
  411. static int interface_req_cmd_notification(QXLInstance *sin)
  412. {
  413. dprint(1, "%s:\n", __FUNCTION__);
  414. return 1;
  415. }
  416. static void interface_release_resource(QXLInstance *sin,
  417. struct QXLReleaseInfoExt ext)
  418. {
  419. SimpleSpiceDisplay *ssd = container_of(sin, SimpleSpiceDisplay, qxl);
  420. uintptr_t id;
  421. dprint(2, "%s:\n", __FUNCTION__);
  422. id = ext.info->id;
  423. qemu_spice_destroy_update(ssd, (void*)id);
  424. }
  425. static int interface_get_cursor_command(QXLInstance *sin, struct QXLCommandExt *ext)
  426. {
  427. dprint(3, "%s:\n", __FUNCTION__);
  428. return false;
  429. }
  430. static int interface_req_cursor_notification(QXLInstance *sin)
  431. {
  432. dprint(1, "%s:\n", __FUNCTION__);
  433. return 1;
  434. }
  435. static void interface_notify_update(QXLInstance *sin, uint32_t update_id)
  436. {
  437. fprintf(stderr, "%s: abort()\n", __FUNCTION__);
  438. abort();
  439. }
  440. static int interface_flush_resources(QXLInstance *sin)
  441. {
  442. fprintf(stderr, "%s: abort()\n", __FUNCTION__);
  443. abort();
  444. return 0;
  445. }
  446. static void interface_update_area_complete(QXLInstance *sin,
  447. uint32_t surface_id,
  448. QXLRect *dirty, uint32_t num_updated_rects)
  449. {
  450. /* should never be called, used in qxl native mode only */
  451. fprintf(stderr, "%s: abort()\n", __func__);
  452. abort();
  453. }
  454. /* called from spice server thread context only */
  455. static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
  456. {
  457. /* should never be called, used in qxl native mode only */
  458. fprintf(stderr, "%s: abort()\n", __func__);
  459. abort();
  460. }
  461. static void interface_set_client_capabilities(QXLInstance *sin,
  462. uint8_t client_present,
  463. uint8_t caps[58])
  464. {
  465. dprint(3, "%s:\n", __func__);
  466. }
  467. static int interface_client_monitors_config(QXLInstance *sin,
  468. VDAgentMonitorsConfig *monitors_config)
  469. {
  470. dprint(3, "%s:\n", __func__);
  471. return 0; /* == not supported by guest */
  472. }
  473. static const QXLInterface dpy_interface = {
  474. .base.type = SPICE_INTERFACE_QXL,
  475. .base.description = "qemu simple display",
  476. .base.major_version = SPICE_INTERFACE_QXL_MAJOR,
  477. .base.minor_version = SPICE_INTERFACE_QXL_MINOR,
  478. .attache_worker = interface_attach_worker,
  479. .set_compression_level = interface_set_compression_level,
  480. .set_mm_time = interface_set_mm_time,
  481. .get_init_info = interface_get_init_info,
  482. /* the callbacks below are called from spice server thread context */
  483. .get_command = interface_get_command,
  484. .req_cmd_notification = interface_req_cmd_notification,
  485. .release_resource = interface_release_resource,
  486. .get_cursor_command = interface_get_cursor_command,
  487. .req_cursor_notification = interface_req_cursor_notification,
  488. .notify_update = interface_notify_update,
  489. .flush_resources = interface_flush_resources,
  490. .async_complete = interface_async_complete,
  491. .update_area_complete = interface_update_area_complete,
  492. .set_client_capabilities = interface_set_client_capabilities,
  493. .client_monitors_config = interface_client_monitors_config,
  494. };
  495. static SimpleSpiceDisplay sdpy;
  496. static void display_update(struct DisplayState *ds, int x, int y, int w, int h)
  497. {
  498. qemu_spice_display_update(&sdpy, x, y, w, h);
  499. }
  500. static void display_resize(struct DisplayState *ds)
  501. {
  502. qemu_spice_display_resize(&sdpy);
  503. }
  504. static void display_refresh(struct DisplayState *ds)
  505. {
  506. qemu_spice_display_refresh(&sdpy);
  507. }
  508. static DisplayChangeListener display_listener = {
  509. .dpy_gfx_update = display_update,
  510. .dpy_gfx_resize = display_resize,
  511. .dpy_refresh = display_refresh,
  512. };
  513. void qemu_spice_display_init(DisplayState *ds)
  514. {
  515. assert(sdpy.ds == NULL);
  516. qemu_spice_display_init_common(&sdpy, ds);
  517. sdpy.qxl.base.sif = &dpy_interface.base;
  518. qemu_spice_add_interface(&sdpy.qxl.base);
  519. assert(sdpy.worker);
  520. qemu_spice_create_host_memslot(&sdpy);
  521. qemu_spice_create_host_primary(&sdpy);
  522. register_displaychangelistener(ds, &display_listener);
  523. }