137 |
137 |
.watch_remove = watch_remove,
|
138 |
138 |
};
|
139 |
139 |
|
|
140 |
/* config string parsing */
|
|
141 |
|
|
142 |
static int name2enum(const char *string, const char *table[], int entries)
|
|
143 |
{
|
|
144 |
int i;
|
|
145 |
|
|
146 |
if (string) {
|
|
147 |
for (i = 0; i < entries; i++) {
|
|
148 |
if (!table[i]) {
|
|
149 |
continue;
|
|
150 |
}
|
|
151 |
if (strcmp(string, table[i]) != 0) {
|
|
152 |
continue;
|
|
153 |
}
|
|
154 |
return i;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
return -1;
|
|
158 |
}
|
|
159 |
|
|
160 |
static int parse_name(const char *string, const char *optname,
|
|
161 |
const char *table[], int entries)
|
|
162 |
{
|
|
163 |
int value = name2enum(string, table, entries);
|
|
164 |
|
|
165 |
if (value != -1) {
|
|
166 |
return value;
|
|
167 |
}
|
|
168 |
fprintf(stderr, "spice: invalid %s: %s\n", optname, string);
|
|
169 |
exit(1);
|
|
170 |
}
|
|
171 |
|
|
172 |
static const char *compression_names[] = {
|
|
173 |
[ SPICE_IMAGE_COMPRESS_OFF ] = "off",
|
|
174 |
[ SPICE_IMAGE_COMPRESS_AUTO_GLZ ] = "auto_glz",
|
|
175 |
[ SPICE_IMAGE_COMPRESS_AUTO_LZ ] = "auto_lz",
|
|
176 |
[ SPICE_IMAGE_COMPRESS_QUIC ] = "quic",
|
|
177 |
[ SPICE_IMAGE_COMPRESS_GLZ ] = "glz",
|
|
178 |
[ SPICE_IMAGE_COMPRESS_LZ ] = "lz",
|
|
179 |
};
|
|
180 |
#define parse_compression(_name) \
|
|
181 |
parse_name(_name, "image compression", \
|
|
182 |
compression_names, ARRAY_SIZE(compression_names))
|
|
183 |
|
|
184 |
static const char *wan_compression_names[] = {
|
|
185 |
[ SPICE_WAN_COMPRESSION_AUTO ] = "auto",
|
|
186 |
[ SPICE_WAN_COMPRESSION_NEVER ] = "never",
|
|
187 |
[ SPICE_WAN_COMPRESSION_ALWAYS ] = "always",
|
|
188 |
};
|
|
189 |
#define parse_wan_compression(_name) \
|
|
190 |
parse_name(_name, "wan compression", \
|
|
191 |
wan_compression_names, ARRAY_SIZE(wan_compression_names))
|
|
192 |
|
140 |
193 |
/* functions for the rest of qemu */
|
141 |
194 |
|
142 |
195 |
void qemu_spice_init(void)
|
... | ... | |
150 |
203 |
*x509_cert_file = NULL,
|
151 |
204 |
*x509_cacert_file = NULL;
|
152 |
205 |
int port, tls_port, len;
|
|
206 |
spice_image_compression_t compression;
|
|
207 |
spice_wan_compression_t wan_compr;
|
153 |
208 |
|
154 |
209 |
if (!opts) {
|
155 |
210 |
return;
|
... | ... | |
217 |
272 |
spice_server_set_noauth(spice_server);
|
218 |
273 |
}
|
219 |
274 |
|
220 |
|
/* TODO: make configurable via cmdline */
|
221 |
|
spice_server_set_image_compression(spice_server, SPICE_IMAGE_COMPRESS_AUTO_GLZ);
|
|
275 |
compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
|
|
276 |
str = qemu_opt_get(opts, "image-compression");
|
|
277 |
if (str) {
|
|
278 |
compression = parse_compression(str);
|
|
279 |
}
|
|
280 |
spice_server_set_image_compression(spice_server, compression);
|
|
281 |
|
|
282 |
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
|
|
283 |
str = qemu_opt_get(opts, "jpeg-wan-compression");
|
|
284 |
if (str) {
|
|
285 |
wan_compr = parse_wan_compression(str);
|
|
286 |
}
|
|
287 |
spice_server_set_jpeg_compression(spice_server, wan_compr);
|
|
288 |
|
|
289 |
wan_compr = SPICE_WAN_COMPRESSION_AUTO;
|
|
290 |
str = qemu_opt_get(opts, "zlib-glz-wan-compression");
|
|
291 |
if (str) {
|
|
292 |
wan_compr = parse_wan_compression(str);
|
|
293 |
}
|
|
294 |
spice_server_set_zlib_glz_compression(spice_server, wan_compr);
|
222 |
295 |
|
223 |
296 |
spice_server_init(spice_server, &core_interface);
|
224 |
297 |
using_spice = 1;
|