ia64/xen-unstable

view tools/ioemu/patches/vnc-display-find-unused @ 11569:317e8516d464

[qemu patches] Update patches for changeset 11561:c742b2ae920c.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Thu Sep 21 19:28:35 2006 +0100 (2006-09-21)
parents a7dcafb540be
children 043f8799e68e
line source
1 Index: ioemu/vnc.c
2 ===================================================================
3 --- ioemu.orig/vnc.c 2006-09-21 19:11:00.000000000 +0100
4 +++ ioemu/vnc.c 2006-09-21 19:11:03.000000000 +0100
5 @@ -1181,7 +1181,7 @@
6 }
7 }
9 -void vnc_display_init(DisplayState *ds, int display)
10 +int vnc_display_init(DisplayState *ds, int display, int find_unused)
11 {
12 struct sockaddr_in addr;
13 int reuse_addr, ret;
14 @@ -1212,10 +1212,6 @@
15 exit(1);
16 }
18 - addr.sin_family = AF_INET;
19 - addr.sin_port = htons(5900 + display);
20 - memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
21 -
22 reuse_addr = 1;
23 ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR,
24 (const char *)&reuse_addr, sizeof(reuse_addr));
25 @@ -1224,7 +1220,16 @@
26 exit(1);
27 }
29 + retry:
30 + addr.sin_family = AF_INET;
31 + addr.sin_port = htons(5900 + display);
32 + memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
33 +
34 if (bind(vs->lsock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
35 + if (find_unused && errno == EADDRINUSE) {
36 + display++;
37 + goto retry;
38 + }
39 fprintf(stderr, "bind() failed\n");
40 exit(1);
41 }
42 @@ -1245,6 +1250,8 @@
43 vs->ds->dpy_refresh = vnc_dpy_refresh;
45 vnc_dpy_resize(vs->ds, 640, 400);
46 +
47 + return display;
48 }
50 int vnc_start_viewer(int port)
51 Index: ioemu/vl.c
52 ===================================================================
53 --- ioemu.orig/vl.c 2006-09-21 19:10:53.000000000 +0100
54 +++ ioemu/vl.c 2006-09-21 19:11:03.000000000 +0100
55 @@ -121,6 +121,7 @@
56 static DisplayState display_state;
57 int nographic;
58 int vncviewer;
59 +int vncunused;
60 const char* keyboard_layout = NULL;
61 int64_t ticks_per_sec;
62 int boot_device = 'c';
63 @@ -5342,6 +5343,7 @@
64 "-loadvm file start right away with a saved state (loadvm in monitor)\n"
65 "-vnc display start a VNC server on display\n"
66 "-vncviewer start a vncviewer process for this domain\n"
67 + "-vncunused bind the VNC server to an unused port\n"
68 "-timeoffset time offset (in seconds) from local time\n"
69 "-acpi disable or enable ACPI of HVM domain \n"
70 "\n"
71 @@ -5431,6 +5433,7 @@
72 QEMU_OPTION_timeoffset,
73 QEMU_OPTION_acpi,
74 QEMU_OPTION_vncviewer,
75 + QEMU_OPTION_vncunused,
76 };
78 typedef struct QEMUOption {
79 @@ -5506,6 +5509,7 @@
80 { "smp", HAS_ARG, QEMU_OPTION_smp },
81 { "vnc", HAS_ARG, QEMU_OPTION_vnc },
82 { "vncviewer", 0, QEMU_OPTION_vncviewer },
83 + { "vncunused", 0, QEMU_OPTION_vncunused },
85 /* temporary options */
86 { "usb", 0, QEMU_OPTION_usb },
87 @@ -5873,6 +5877,7 @@
88 snapshot = 0;
89 nographic = 0;
90 vncviewer = 0;
91 + vncunused = 0;
92 kernel_filename = NULL;
93 kernel_cmdline = "";
94 #ifdef TARGET_PPC
95 @@ -6270,6 +6275,11 @@
96 case QEMU_OPTION_vncviewer:
97 vncviewer++;
98 break;
99 + case QEMU_OPTION_vncunused:
100 + vncunused++;
101 + if (vnc_display == -1)
102 + vnc_display = -2;
103 + break;
104 }
105 }
106 }
107 @@ -6483,7 +6493,7 @@
108 if (nographic) {
109 dumb_display_init(ds);
110 } else if (vnc_display != -1) {
111 - vnc_display_init(ds, vnc_display);
112 + vnc_display = vnc_display_init(ds, vnc_display, vncunused);
113 if (vncviewer)
114 vnc_start_viewer(vnc_display);
115 } else {
116 Index: ioemu/vl.h
117 ===================================================================
118 --- ioemu.orig/vl.h 2006-09-21 19:10:53.000000000 +0100
119 +++ ioemu/vl.h 2006-09-21 19:11:03.000000000 +0100
120 @@ -785,7 +785,7 @@
121 void cocoa_display_init(DisplayState *ds, int full_screen);
123 /* vnc.c */
124 -void vnc_display_init(DisplayState *ds, int display);
125 +int vnc_display_init(DisplayState *ds, int display, int find_unused);
126 int vnc_start_viewer(int port);
128 /* ide.c */