]> git.proxmox.com Git - spiceterm.git/blob - test_display_base.c
cleanup/merge header files
[spiceterm.git] / test_display_base.c
1 #include <stdlib.h>
2 #include <math.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <signal.h>
7 #include <wait.h>
8 #include <sys/select.h>
9 #include <sys/types.h>
10 #include <getopt.h>
11
12 #include <spice.h>
13 #include <spice/enums.h>
14 #include <spice/macros.h>
15 #include <spice/qxl_dev.h>
16
17 #include "glyphs.h"
18
19 #include "spiceterm.h"
20
21 #define MEM_SLOT_GROUP_ID 0
22
23 #define NOTIFY_DISPLAY_BATCH (SINGLE_PART/2)
24 #define NOTIFY_CURSOR_BATCH 10
25
26 /* these colours are from linux kernel drivers/char/vt.c */
27 /* the default colour table, for VGA+ colour systems */
28 int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
29 0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
30 int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
31 0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
32 int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
33 0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
34
35 /* Parts cribbed from spice-display.h/.c/qxl.c */
36
37 typedef struct SimpleSpiceUpdate {
38 QXLCommandExt ext; // first
39 QXLDrawable drawable;
40 QXLImage image;
41 uint8_t *bitmap;
42 } SimpleSpiceUpdate;
43
44 static void test_spice_destroy_update(SimpleSpiceUpdate *update)
45 {
46 if (!update) {
47 return;
48 }
49 if (update->drawable.clip.type != SPICE_CLIP_TYPE_NONE) {
50 uint8_t *ptr = (uint8_t*)update->drawable.clip.data;
51 free(ptr);
52 }
53 g_free(update->bitmap);
54 g_free(update);
55 }
56
57 #define DEFAULT_WIDTH 640
58 #define DEFAULT_HEIGHT 320
59
60 //#define SINGLE_PART 4
61 //static const int angle_parts = 64 / SINGLE_PART;
62 static int unique = 1;
63 //static int color = -1;
64 //static int c_i = 0;
65
66 __attribute__((noreturn))
67 static void sigchld_handler(int signal_num) // wait for the child process and exit
68 {
69 int status;
70 wait(&status);
71 exit(0);
72 }
73
74 static void set_cmd(QXLCommandExt *ext, uint32_t type, QXLPHYSICAL data)
75 {
76 ext->cmd.type = type;
77 ext->cmd.data = data;
78 ext->cmd.padding = 0;
79 ext->group_id = MEM_SLOT_GROUP_ID;
80 ext->flags = 0;
81 }
82
83 static void simple_set_release_info(QXLReleaseInfo *info, intptr_t ptr)
84 {
85 info->id = ptr;
86 //info->group_id = MEM_SLOT_GROUP_ID;
87 }
88
89 // We shall now have a ring of commands, so that we can update
90 // it from a separate thread - since get_command is called from
91 // the worker thread, and we need to sometimes do an update_area,
92 // which cannot be done from red_worker context (not via dispatcher,
93 // since you get a deadlock, and it isn't designed to be done
94 // any other way, so no point testing that).
95
96
97 static void push_command(Test *test, QXLCommandExt *ext)
98 {
99 g_mutex_lock(test->command_mutex);
100
101 while (test->commands_end - test->commands_start >= COMMANDS_SIZE) {
102 g_cond_wait(test->command_cond, test->command_mutex);
103 }
104 g_assert(test->commands_end - test->commands_start < COMMANDS_SIZE);
105 test->commands[test->commands_end % COMMANDS_SIZE] = ext;
106 test->commands_end++;
107 g_mutex_unlock(test->command_mutex);
108
109 test->qxl_worker->wakeup(test->qxl_worker);
110 }
111
112 /* bitmap are freed, so they must be allocated with g_malloc */
113 SimpleSpiceUpdate *test_spice_create_update_from_bitmap(uint32_t surface_id,
114 QXLRect bbox,
115 uint8_t *bitmap)
116 {
117 SimpleSpiceUpdate *update;
118 QXLDrawable *drawable;
119 QXLImage *image;
120 uint32_t bw, bh;
121
122 bh = bbox.bottom - bbox.top;
123 bw = bbox.right - bbox.left;
124
125 update = g_new0(SimpleSpiceUpdate, 1);
126 update->bitmap = bitmap;
127 drawable = &update->drawable;
128 image = &update->image;
129
130 drawable->surface_id = surface_id;
131
132 drawable->bbox = bbox;
133 drawable->clip.type = SPICE_CLIP_TYPE_NONE;
134 drawable->effect = QXL_EFFECT_OPAQUE;
135 simple_set_release_info(&drawable->release_info, (intptr_t)update);
136 drawable->type = QXL_DRAW_COPY;
137 drawable->surfaces_dest[0] = -1;
138 drawable->surfaces_dest[1] = -1;
139 drawable->surfaces_dest[2] = -1;
140
141 drawable->u.copy.rop_descriptor = SPICE_ROPD_OP_PUT;
142 drawable->u.copy.src_bitmap = (intptr_t)image;
143 drawable->u.copy.src_area.right = bw;
144 drawable->u.copy.src_area.bottom = bh;
145
146 QXL_SET_IMAGE_ID(image, QXL_IMAGE_GROUP_DEVICE, unique);
147 image->descriptor.type = SPICE_IMAGE_TYPE_BITMAP;
148 image->bitmap.flags = QXL_BITMAP_DIRECT | QXL_BITMAP_TOP_DOWN;
149 image->bitmap.stride = bw * 4;
150 image->descriptor.width = image->bitmap.x = bw;
151 image->descriptor.height = image->bitmap.y = bh;
152 image->bitmap.data = (intptr_t)bitmap;
153 image->bitmap.palette = 0;
154 image->bitmap.format = SPICE_BITMAP_FMT_32BIT;
155
156 set_cmd(&update->ext, QXL_CMD_DRAW, (intptr_t)drawable);
157
158 return update;
159 }
160
161 static SimpleSpiceUpdate *test_draw_char(Test *test, int x, int y, int c, int fg, int bg)
162 {
163 int top, left;
164 uint8_t *dst;
165 uint8_t *bitmap;
166 int bw, bh;
167 int i, j;
168 QXLRect bbox;
169
170 left = x*8;
171 top = y*16;
172
173 // printf("DRAWCHAR %d %d %d\n", left, top, c);
174
175 unique++;
176
177 bw = 8;
178 bh = 16;
179
180 bitmap = dst = g_malloc(bw * bh * 4);
181
182 unsigned char *data = vt_font_data + c*16;
183 unsigned char d = *data;
184
185 g_assert(fg >= 0 && fg < 16);
186 g_assert(bg >= 0 && bg < 16);
187
188 unsigned char fgc_red = default_red[fg];
189 unsigned char fgc_blue = default_blu[fg];
190 unsigned char fgc_green = default_grn[fg];
191 unsigned char bgc_red = default_red[bg];
192 unsigned char bgc_blue = default_blu[bg];
193 unsigned char bgc_green = default_grn[bg];
194
195 for (j = 0; j < 16; j++) {
196 for (i = 0; i < 8; i++) {
197 if ((i&7) == 0) {
198 d=*data;
199 data++;
200 }
201 if (d&0x80) {
202 *(dst) = fgc_blue;
203 *(dst+1) = fgc_green;
204 *(dst+2) = fgc_red;
205 *(dst+3) = 0;
206 } else {
207 *(dst) = bgc_blue;
208 *(dst+1) = bgc_green;
209 *(dst+2) = bgc_red;
210 *(dst+3) = 0;
211 }
212 d<<=1;
213 dst += 4;
214 }
215 }
216
217 bbox.left = left; bbox.top = top;
218 bbox.right = left + bw; bbox.bottom = top + bh;
219
220 return test_spice_create_update_from_bitmap(0, bbox, bitmap);
221 }
222
223 void test_spice_scroll(Test *test, int x1, int y1, int x2, int y2, int src_x, int src_y)
224 {
225 SimpleSpiceUpdate *update;
226 QXLDrawable *drawable;
227 QXLRect bbox;
228
229 int surface_id = 0; // fixme
230
231 update = g_new0(SimpleSpiceUpdate, 1);
232 drawable = &update->drawable;
233
234 bbox.left = x1;
235 bbox.top = y1;
236 bbox.right = x2;
237 bbox.bottom = y2;
238
239 drawable->surface_id = surface_id;
240
241 drawable->bbox = bbox;
242 drawable->clip.type = SPICE_CLIP_TYPE_NONE;
243 drawable->effect = QXL_EFFECT_OPAQUE;
244 simple_set_release_info(&drawable->release_info, (intptr_t)update);
245 drawable->type = QXL_COPY_BITS;
246 drawable->surfaces_dest[0] = -1;
247 drawable->surfaces_dest[1] = -1;
248 drawable->surfaces_dest[2] = -1;
249
250 drawable->u.copy_bits.src_pos.x = src_x;
251 drawable->u.copy_bits.src_pos.y = src_y;
252
253 set_cmd(&update->ext, QXL_CMD_DRAW, (intptr_t)drawable);
254
255 push_command(test, &update->ext);
256 }
257
258 void test_spice_clear(Test *test, int x1, int y1, int x2, int y2)
259 {
260 SimpleSpiceUpdate *update;
261 QXLDrawable *drawable;
262 QXLRect bbox;
263
264 int surface_id = 0; // fixme
265
266 update = g_new0(SimpleSpiceUpdate, 1);
267 drawable = &update->drawable;
268
269 bbox.left = x1;
270 bbox.top = y1;
271 bbox.right = x2;
272 bbox.bottom = y2;
273
274 drawable->surface_id = surface_id;
275
276 drawable->bbox = bbox;
277 drawable->clip.type = SPICE_CLIP_TYPE_NONE;
278 drawable->effect = QXL_EFFECT_OPAQUE;
279 simple_set_release_info(&drawable->release_info, (intptr_t)update);
280 drawable->type = QXL_DRAW_BLACKNESS;
281 drawable->surfaces_dest[0] = -1;
282 drawable->surfaces_dest[1] = -1;
283 drawable->surfaces_dest[2] = -1;
284
285 set_cmd(&update->ext, QXL_CMD_DRAW, (intptr_t)drawable);
286
287 push_command(test, &update->ext);
288 }
289
290 static void create_primary_surface(Test *test, uint32_t width,
291 uint32_t height)
292 {
293 QXLWorker *qxl_worker = test->qxl_worker;
294 QXLDevSurfaceCreate surface = { 0, };
295
296 g_assert(height <= MAX_HEIGHT);
297 g_assert(width <= MAX_WIDTH);
298 g_assert(height > 0);
299 g_assert(width > 0);
300
301 surface.format = SPICE_SURFACE_FMT_32_xRGB;
302 surface.width = test->primary_width = width;
303 surface.height = test->primary_height = height;
304 surface.stride = -width * 4; /* negative? */
305 surface.mouse_mode = TRUE; /* unused by red_worker */
306 surface.flags = 0;
307 surface.type = 0; /* unused by red_worker */
308 surface.position = 0; /* unused by red_worker */
309 surface.mem = (uint64_t)&test->primary_surface;
310 surface.group_id = MEM_SLOT_GROUP_ID;
311
312 test->width = width;
313 test->height = height;
314
315 qxl_worker->create_primary_surface(qxl_worker, 0, &surface);
316 }
317
318 QXLDevMemSlot slot = {
319 .slot_group_id = MEM_SLOT_GROUP_ID,
320 .slot_id = 0,
321 .generation = 0,
322 .virt_start = 0,
323 .virt_end = ~0,
324 .addr_delta = 0,
325 .qxl_ram_size = ~0,
326 };
327
328 static void attache_worker(QXLInstance *qin, QXLWorker *_qxl_worker)
329 {
330 Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
331
332 if (test->qxl_worker) {
333 if (test->qxl_worker != _qxl_worker)
334 printf("%s ignored, %p is set, ignoring new %p\n", __func__,
335 test->qxl_worker, _qxl_worker);
336 else
337 printf("%s ignored, redundant\n", __func__);
338 return;
339 }
340 printf("%s\n", __func__);
341 test->qxl_worker = _qxl_worker;
342 test->qxl_worker->add_memslot(test->qxl_worker, &slot);
343 create_primary_surface(test, DEFAULT_WIDTH, DEFAULT_HEIGHT);
344 test->qxl_worker->start(test->qxl_worker);
345 }
346
347 static void set_compression_level(QXLInstance *qin, int level)
348 {
349 printf("%s\n", __func__);
350 }
351
352 static void set_mm_time(QXLInstance *qin, uint32_t mm_time)
353 {
354 }
355 static void get_init_info(QXLInstance *qin, QXLDevInitInfo *info)
356 {
357 memset(info, 0, sizeof(*info));
358 info->num_memslots = 1;
359 info->num_memslots_groups = 1;
360 info->memslot_id_bits = 1;
361 info->memslot_gen_bits = 1;
362 info->n_surfaces = 1;
363 }
364
365 // called from spice_server thread (i.e. red_worker thread)
366 static int get_command(QXLInstance *qin, struct QXLCommandExt *ext)
367 {
368 Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
369 int res = FALSE;
370
371 g_mutex_lock(test->command_mutex);
372
373 if ((test->commands_end - test->commands_start) == 0) {
374 res = FALSE;
375 goto ret;
376 }
377
378 *ext = *test->commands[test->commands_start % COMMANDS_SIZE];
379 g_assert(test->commands_start < test->commands_end);
380 test->commands_start++;
381 g_cond_signal(test->command_cond);
382
383 res = TRUE;
384
385 ret:
386 g_mutex_unlock(test->command_mutex);
387 return res;
388 }
389
390 static int req_cmd_notification(QXLInstance *qin)
391 {
392 //Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
393 //test->core->timer_start(test->wakeup_timer, test->wakeup_ms);
394
395 return TRUE;
396 }
397
398 static void release_resource(QXLInstance *qin, struct QXLReleaseInfoExt release_info)
399 {
400 QXLCommandExt *ext = (QXLCommandExt*)(unsigned long)release_info.info->id;
401 //printf("%s\n", __func__);
402 g_assert(release_info.group_id == MEM_SLOT_GROUP_ID);
403 switch (ext->cmd.type) {
404 case QXL_CMD_DRAW:
405 test_spice_destroy_update((void*)ext);
406 break;
407 case QXL_CMD_SURFACE:
408 free(ext);
409 break;
410 case QXL_CMD_CURSOR: {
411 QXLCursorCmd *cmd = (QXLCursorCmd *)(unsigned long)ext->cmd.data;
412 if (cmd->type == QXL_CURSOR_SET) {
413 free(cmd);
414 }
415 free(ext);
416 break;
417 }
418 default:
419 abort();
420 }
421 }
422
423 #define CURSOR_WIDTH 32
424 #define CURSOR_HEIGHT 32
425
426 static struct {
427 QXLCursor cursor;
428 uint8_t data[CURSOR_WIDTH * CURSOR_HEIGHT * 4]; // 32bit per pixel
429 } cursor;
430
431 static void cursor_init()
432 {
433 cursor.cursor.header.unique = 0;
434 cursor.cursor.header.type = SPICE_CURSOR_TYPE_COLOR32;
435 cursor.cursor.header.width = CURSOR_WIDTH;
436 cursor.cursor.header.height = CURSOR_HEIGHT;
437 cursor.cursor.header.hot_spot_x = 0;
438 cursor.cursor.header.hot_spot_y = 0;
439 cursor.cursor.data_size = CURSOR_WIDTH * CURSOR_HEIGHT * 4;
440
441 // X drivers addes it to the cursor size because it could be
442 // cursor data information or another cursor related stuffs.
443 // Otherwise, the code will break in client/cursor.cpp side,
444 // that expect the data_size plus cursor information.
445 // Blame cursor protocol for this. :-)
446 cursor.cursor.data_size += 128;
447 cursor.cursor.chunk.data_size = cursor.cursor.data_size;
448 cursor.cursor.chunk.prev_chunk = cursor.cursor.chunk.next_chunk = 0;
449 }
450
451 static int get_cursor_command(QXLInstance *qin, struct QXLCommandExt *ext)
452 {
453 Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
454 static int set = 1;
455 static int x = 0, y = 0;
456 QXLCursorCmd *cursor_cmd;
457 QXLCommandExt *cmd;
458
459 if (!test->cursor_notify) {
460 return FALSE;
461 }
462
463 test->cursor_notify--;
464 cmd = calloc(sizeof(QXLCommandExt), 1);
465 cursor_cmd = calloc(sizeof(QXLCursorCmd), 1);
466
467 cursor_cmd->release_info.id = (unsigned long)cmd;
468
469 if (set) {
470 cursor_cmd->type = QXL_CURSOR_SET;
471 cursor_cmd->u.set.position.x = 0;
472 cursor_cmd->u.set.position.y = 0;
473 cursor_cmd->u.set.visible = TRUE;
474 cursor_cmd->u.set.shape = (unsigned long)&cursor;
475 // Only a white rect (32x32) as cursor
476 memset(cursor.data, 255, sizeof(cursor.data));
477 set = 0;
478 } else {
479 cursor_cmd->type = QXL_CURSOR_MOVE;
480 cursor_cmd->u.position.x = x++ % test->primary_width;
481 cursor_cmd->u.position.y = y++ % test->primary_height;
482 }
483
484 cmd->cmd.data = (unsigned long)cursor_cmd;
485 cmd->cmd.type = QXL_CMD_CURSOR;
486 cmd->group_id = MEM_SLOT_GROUP_ID;
487 cmd->flags = 0;
488 *ext = *cmd;
489 //printf("%s\n", __func__);
490 return TRUE;
491 }
492
493 static int req_cursor_notification(QXLInstance *qin)
494 {
495 printf("%s\n", __func__);
496 return TRUE;
497 }
498
499 static void notify_update(QXLInstance *qin, uint32_t update_id)
500 {
501 printf("%s\n", __func__);
502 }
503
504 static int flush_resources(QXLInstance *qin)
505 {
506 printf("%s\n", __func__);
507 return TRUE;
508 }
509
510 static int client_monitors_config(QXLInstance *qin,
511 VDAgentMonitorsConfig *monitors_config)
512 {
513 if (!monitors_config) {
514 printf("%s: NULL monitors_config\n", __func__);
515 } else {
516 printf("%s: %d\n", __func__, monitors_config->num_of_monitors);
517 }
518 return 0;
519 }
520
521 static void set_client_capabilities(QXLInstance *qin,
522 uint8_t client_present,
523 uint8_t caps[58])
524 {
525 Test *test = SPICE_CONTAINEROF(qin, Test, qxl_instance);
526
527 printf("%s: present %d caps %d\n", __func__, client_present, caps[0]);
528 if (test->on_client_connected && client_present) {
529 test->on_client_connected(test);
530 }
531 if (test->on_client_disconnected && !client_present) {
532 test->on_client_disconnected(test);
533 }
534 }
535
536 static int client_count = 0;
537
538 static void client_connected(Test *test)
539 {
540 printf("Client connected\n");
541 client_count++;
542 }
543
544 static void client_disconnected(Test *test)
545 {
546
547 if (client_count > 0) {
548 client_count--;
549 printf("Client disconnected\n");
550 exit(0); // fixme: cleanup?
551 }
552 }
553
554 static void do_conn_timeout(void *opaque)
555 {
556 // Test *test = opaque;
557
558 if (client_count <= 0) {
559 printf("do_conn_timeout\n");
560 exit (0); // fixme: cleanup?
561 }
562 }
563
564
565 QXLInterface display_sif = {
566 .base = {
567 .type = SPICE_INTERFACE_QXL,
568 .description = "test",
569 .major_version = SPICE_INTERFACE_QXL_MAJOR,
570 .minor_version = SPICE_INTERFACE_QXL_MINOR
571 },
572 .attache_worker = attache_worker,
573 .set_compression_level = set_compression_level,
574 .set_mm_time = set_mm_time,
575 .get_init_info = get_init_info,
576
577 /* the callbacks below are called from spice server thread context */
578 .get_command = get_command,
579 .req_cmd_notification = req_cmd_notification,
580 .release_resource = release_resource,
581 .get_cursor_command = get_cursor_command,
582 .req_cursor_notification = req_cursor_notification,
583 .notify_update = notify_update,
584 .flush_resources = flush_resources,
585 .client_monitors_config = client_monitors_config,
586 .set_client_capabilities = set_client_capabilities,
587 };
588
589 /* interface for tests */
590 void test_add_display_interface(Test* test)
591 {
592 spice_server_add_interface(test->server, &test->qxl_instance.base);
593 }
594
595 static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
596 {
597 // printf("%s: %d\n", __func__, len);
598 return len;
599 }
600
601 static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
602 {
603 // printf("%s: %d\n", __func__, len);
604 return 0;
605 }
606
607 static void vmc_state(SpiceCharDeviceInstance *sin, int connected)
608 {
609 // printf("%s: %d\n", __func__, connected);
610 }
611
612 static SpiceCharDeviceInterface vdagent_sif = {
613 .base.type = SPICE_INTERFACE_CHAR_DEVICE,
614 .base.description = "test spice virtual channel char device",
615 .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
616 .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
617 .state = vmc_state,
618 .write = vmc_write,
619 .read = vmc_read,
620 };
621
622 SpiceCharDeviceInstance vdagent_sin = {
623 .base = {
624 .sif = &vdagent_sif.base,
625 },
626 .subtype = "vdagent",
627 };
628
629 void test_add_agent_interface(SpiceServer *server)
630 {
631 spice_server_add_interface(server, &vdagent_sin.base);
632 }
633
634 static void kbd_push_key(SpiceKbdInstance *sin, uint8_t frag)
635 {
636 Test *test = SPICE_CONTAINEROF(sin, Test, keyboard_sin);
637
638 printf("KEYCODE %u %p\n", frag, test);
639
640 }
641
642 void test_draw_update_char(Test *test, int x, int y, gunichar ch, TextAttributes attrib)
643 {
644 int fg, bg;
645
646 if (attrib.invers) {
647 bg = attrib.fgcol;
648 fg = attrib.bgcol;
649 } else {
650 bg = attrib.bgcol;
651 fg = attrib.fgcol;
652 }
653
654 if (attrib.bold) {
655 fg += 8;
656 }
657
658 // unsuported attributes = (attrib.blink || attrib.unvisible)
659
660 //if (attrib.uline) {
661 //rfbDrawLine (vt->screen, rx, ry + 14, rxe, ry + 14, fg);
662 //}
663
664 int c = vt_fontmap[ch];
665
666 SimpleSpiceUpdate *update;
667 update = test_draw_char(test, x, y, c, fg, bg);
668 push_command(test, &update->ext);
669 }
670
671 static uint8_t kbd_get_leds(SpiceKbdInstance *sin)
672 {
673 return 0;
674 }
675
676 static SpiceKbdInterface keyboard_sif = {
677 .base.type = SPICE_INTERFACE_KEYBOARD ,
678 .base.description = "spiceterm keyboard device",
679 .base.major_version = SPICE_INTERFACE_KEYBOARD_MAJOR,
680 .base.minor_version = SPICE_INTERFACE_KEYBOARD_MINOR,
681 .push_scan_freg = kbd_push_key,
682 .get_leds = kbd_get_leds,
683 };
684
685 void test_add_keyboard_interface(Test* test)
686 {
687 spice_server_add_interface(test->server, &test->keyboard_sin.base);
688 }
689
690 Test *test_new(SpiceCoreInterface *core)
691 {
692 int port = 5912;
693 Test *test = g_new0(Test, 1);
694 SpiceServer* server = spice_server_new();
695
696 test->command_cond = g_cond_new();
697 test->command_mutex = g_mutex_new();
698
699 test->on_client_connected = client_connected,
700 test->on_client_disconnected = client_disconnected,
701
702 test->qxl_instance.base.sif = &display_sif.base;
703 test->qxl_instance.id = 0;
704
705 test->keyboard_sin.base.sif = &keyboard_sif.base;
706
707 test->core = core;
708 test->server = server;
709
710 test->cursor_notify = NOTIFY_CURSOR_BATCH;
711 // some common initialization for all display tests
712 printf("TESTER: listening on port %d (unsecure)\n", port);
713 spice_server_set_port(server, port);
714 spice_server_set_noauth(server);
715 int res = spice_server_init(server, core);
716 if (res != 0) {
717 g_error("spice_server_init failed, res = %d\n", res);
718 }
719
720 cursor_init();
721
722 int timeout = 10; // max time to wait for client connection
723 test->conn_timeout_timer = core->timer_add(do_conn_timeout, test);
724 test->core->timer_start(test->conn_timeout_timer, timeout*1000);
725
726 return test;
727 }