vl: drop display_type variable
Switch over all leftover users to qapi DisplayType. Then delete the unused display_type variable. Add 'default' DisplayType, which isn't an actual display type but a placeholder for "user didn't specify a display". It will be replaced by the DisplayType actually used, which in turn depends on the DisplayTypes availabel in the particular build. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20180202111022.19269-13-kraxel@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
9b9b46c71c
commit
e3af9f9a40
@ -1020,7 +1020,7 @@
|
|||||||
#
|
#
|
||||||
##
|
##
|
||||||
{ 'enum' : 'DisplayType',
|
{ 'enum' : 'DisplayType',
|
||||||
'data' : [ 'none', 'gtk', 'sdl',
|
'data' : [ 'default', 'none', 'gtk', 'sdl',
|
||||||
'egl-headless', 'curses', 'cocoa' ] }
|
'egl-headless', 'curses', 'cocoa' ] }
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -1042,7 +1042,8 @@
|
|||||||
'*window-close' : 'bool',
|
'*window-close' : 'bool',
|
||||||
'*gl' : 'bool' },
|
'*gl' : 'bool' },
|
||||||
'discriminator' : 'type',
|
'discriminator' : 'type',
|
||||||
'data' : { 'none' : 'DisplayNoOpts',
|
'data' : { 'default' : 'DisplayNoOpts',
|
||||||
|
'none' : 'DisplayNoOpts',
|
||||||
'gtk' : 'DisplayGTK',
|
'gtk' : 'DisplayGTK',
|
||||||
'sdl' : 'DisplayNoOpts',
|
'sdl' : 'DisplayNoOpts',
|
||||||
'egl-headless' : 'DisplayNoOpts',
|
'egl-headless' : 'DisplayNoOpts',
|
||||||
|
54
vl.c
54
vl.c
@ -2080,24 +2080,12 @@ static void select_vgahw(const char *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef enum LegacyDisplayType {
|
static void parse_display(const char *p)
|
||||||
DT_DEFAULT,
|
|
||||||
DT_CURSES,
|
|
||||||
DT_SDL,
|
|
||||||
DT_COCOA,
|
|
||||||
DT_GTK,
|
|
||||||
DT_EGL,
|
|
||||||
DT_NONE,
|
|
||||||
} LegacyDisplayType;
|
|
||||||
|
|
||||||
static LegacyDisplayType select_display(const char *p)
|
|
||||||
{
|
{
|
||||||
const char *opts;
|
const char *opts;
|
||||||
LegacyDisplayType display = DT_DEFAULT;
|
|
||||||
|
|
||||||
if (strstart(p, "sdl", &opts)) {
|
if (strstart(p, "sdl", &opts)) {
|
||||||
#ifdef CONFIG_SDL
|
#ifdef CONFIG_SDL
|
||||||
display = DT_SDL;
|
|
||||||
dpy.type = DISPLAY_TYPE_SDL;
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
while (*opts) {
|
while (*opts) {
|
||||||
const char *nextopt;
|
const char *nextopt;
|
||||||
@ -2172,7 +2160,6 @@ static LegacyDisplayType select_display(const char *p)
|
|||||||
} else if (strstart(p, "egl-headless", &opts)) {
|
} else if (strstart(p, "egl-headless", &opts)) {
|
||||||
#ifdef CONFIG_OPENGL_DMABUF
|
#ifdef CONFIG_OPENGL_DMABUF
|
||||||
display_opengl = 1;
|
display_opengl = 1;
|
||||||
display = DT_EGL;
|
|
||||||
dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
|
dpy.type = DISPLAY_TYPE_EGL_HEADLESS;
|
||||||
#else
|
#else
|
||||||
error_report("egl support is disabled");
|
error_report("egl support is disabled");
|
||||||
@ -2180,7 +2167,6 @@ static LegacyDisplayType select_display(const char *p)
|
|||||||
#endif
|
#endif
|
||||||
} else if (strstart(p, "curses", &opts)) {
|
} else if (strstart(p, "curses", &opts)) {
|
||||||
#ifdef CONFIG_CURSES
|
#ifdef CONFIG_CURSES
|
||||||
display = DT_CURSES;
|
|
||||||
dpy.type = DISPLAY_TYPE_CURSES;
|
dpy.type = DISPLAY_TYPE_CURSES;
|
||||||
#else
|
#else
|
||||||
error_report("curses support is disabled");
|
error_report("curses support is disabled");
|
||||||
@ -2188,7 +2174,6 @@ static LegacyDisplayType select_display(const char *p)
|
|||||||
#endif
|
#endif
|
||||||
} else if (strstart(p, "gtk", &opts)) {
|
} else if (strstart(p, "gtk", &opts)) {
|
||||||
#ifdef CONFIG_GTK
|
#ifdef CONFIG_GTK
|
||||||
display = DT_GTK;
|
|
||||||
dpy.type = DISPLAY_TYPE_GTK;
|
dpy.type = DISPLAY_TYPE_GTK;
|
||||||
while (*opts) {
|
while (*opts) {
|
||||||
const char *nextopt;
|
const char *nextopt;
|
||||||
@ -2225,14 +2210,11 @@ static LegacyDisplayType select_display(const char *p)
|
|||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
} else if (strstart(p, "none", &opts)) {
|
} else if (strstart(p, "none", &opts)) {
|
||||||
display = DT_NONE;
|
|
||||||
dpy.type = DISPLAY_TYPE_NONE;
|
dpy.type = DISPLAY_TYPE_NONE;
|
||||||
} else {
|
} else {
|
||||||
error_report("unknown display type");
|
error_report("unknown display type");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int balloon_parse(const char *arg)
|
static int balloon_parse(const char *arg)
|
||||||
@ -3056,7 +3038,6 @@ int main(int argc, char **argv, char **envp)
|
|||||||
const char *incoming = NULL;
|
const char *incoming = NULL;
|
||||||
bool userconfig = true;
|
bool userconfig = true;
|
||||||
bool nographic = false;
|
bool nographic = false;
|
||||||
LegacyDisplayType display_type = DT_DEFAULT;
|
|
||||||
int display_remote = 0;
|
int display_remote = 0;
|
||||||
const char *log_mask = NULL;
|
const char *log_mask = NULL;
|
||||||
const char *log_file = NULL;
|
const char *log_file = NULL;
|
||||||
@ -3250,18 +3231,16 @@ int main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_display:
|
case QEMU_OPTION_display:
|
||||||
display_type = select_display(optarg);
|
parse_display(optarg);
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_nographic:
|
case QEMU_OPTION_nographic:
|
||||||
olist = qemu_find_opts("machine");
|
olist = qemu_find_opts("machine");
|
||||||
qemu_opts_parse_noisily(olist, "graphics=off", false);
|
qemu_opts_parse_noisily(olist, "graphics=off", false);
|
||||||
nographic = true;
|
nographic = true;
|
||||||
display_type = DT_NONE;
|
|
||||||
dpy.type = DISPLAY_TYPE_NONE;
|
dpy.type = DISPLAY_TYPE_NONE;
|
||||||
break;
|
break;
|
||||||
case QEMU_OPTION_curses:
|
case QEMU_OPTION_curses:
|
||||||
#ifdef CONFIG_CURSES
|
#ifdef CONFIG_CURSES
|
||||||
display_type = DT_CURSES;
|
|
||||||
dpy.type = DISPLAY_TYPE_CURSES;
|
dpy.type = DISPLAY_TYPE_CURSES;
|
||||||
#else
|
#else
|
||||||
error_report("curses support is disabled");
|
error_report("curses support is disabled");
|
||||||
@ -3665,7 +3644,6 @@ int main(int argc, char **argv, char **envp)
|
|||||||
break;
|
break;
|
||||||
case QEMU_OPTION_sdl:
|
case QEMU_OPTION_sdl:
|
||||||
#ifdef CONFIG_SDL
|
#ifdef CONFIG_SDL
|
||||||
display_type = DT_SDL;
|
|
||||||
dpy.type = DISPLAY_TYPE_SDL;
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
@ -4281,7 +4259,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_CURSES
|
#ifdef CONFIG_CURSES
|
||||||
if (display_type == DT_CURSES) {
|
if (dpy.type == DISPLAY_TYPE_CURSES) {
|
||||||
error_report("curses display cannot be used with -daemonize");
|
error_report("curses display cannot be used with -daemonize");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -4327,39 +4305,35 @@ int main(int argc, char **argv, char **envp)
|
|||||||
display_remote++;
|
display_remote++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (display_type == DT_DEFAULT && !display_remote) {
|
if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) {
|
||||||
#if defined(CONFIG_GTK)
|
#if defined(CONFIG_GTK)
|
||||||
display_type = DT_GTK;
|
|
||||||
dpy.type = DISPLAY_TYPE_GTK;
|
dpy.type = DISPLAY_TYPE_GTK;
|
||||||
#elif defined(CONFIG_SDL)
|
#elif defined(CONFIG_SDL)
|
||||||
display_type = DT_SDL;
|
|
||||||
dpy.type = DISPLAY_TYPE_SDL;
|
dpy.type = DISPLAY_TYPE_SDL;
|
||||||
#elif defined(CONFIG_COCOA)
|
#elif defined(CONFIG_COCOA)
|
||||||
display_type = DT_COCOA;
|
|
||||||
dpy.type = DISPLAY_TYPE_COCOA;
|
dpy.type = DISPLAY_TYPE_COCOA;
|
||||||
#elif defined(CONFIG_VNC)
|
#elif defined(CONFIG_VNC)
|
||||||
vnc_parse("localhost:0,to=99,id=default", &error_abort);
|
vnc_parse("localhost:0,to=99,id=default", &error_abort);
|
||||||
#else
|
#else
|
||||||
display_type = DT_NONE;
|
|
||||||
dpy.type = DISPLAY_TYPE_NONE;
|
dpy.type = DISPLAY_TYPE_NONE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((no_frame || alt_grab || ctrl_grab) && display_type != DT_SDL) {
|
if ((no_frame || alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) {
|
||||||
error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
|
error_report("-no-frame, -alt-grab and -ctrl-grab are only valid "
|
||||||
"for SDL, ignoring option");
|
"for SDL, ignoring option");
|
||||||
}
|
}
|
||||||
if (dpy.has_window_close &&
|
if (dpy.has_window_close &&
|
||||||
(display_type != DT_GTK && display_type != DT_SDL)) {
|
(dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) {
|
||||||
error_report("-no-quit is only valid for GTK and SDL, "
|
error_report("-no-quit is only valid for GTK and SDL, "
|
||||||
"ignoring option");
|
"ignoring option");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display_type == DT_GTK) {
|
if (dpy.type == DISPLAY_TYPE_GTK) {
|
||||||
early_gtk_display_init(&dpy);
|
early_gtk_display_init(&dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display_type == DT_SDL) {
|
if (dpy.type == DISPLAY_TYPE_SDL) {
|
||||||
sdl_display_early_init(&dpy);
|
sdl_display_early_init(&dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4690,17 +4664,17 @@ int main(int argc, char **argv, char **envp)
|
|||||||
ds = init_displaystate();
|
ds = init_displaystate();
|
||||||
|
|
||||||
/* init local displays */
|
/* init local displays */
|
||||||
switch (display_type) {
|
switch (dpy.type) {
|
||||||
case DT_CURSES:
|
case DISPLAY_TYPE_CURSES:
|
||||||
curses_display_init(ds, &dpy);
|
curses_display_init(ds, &dpy);
|
||||||
break;
|
break;
|
||||||
case DT_SDL:
|
case DISPLAY_TYPE_SDL:
|
||||||
sdl_display_init(ds, &dpy);
|
sdl_display_init(ds, &dpy);
|
||||||
break;
|
break;
|
||||||
case DT_COCOA:
|
case DISPLAY_TYPE_COCOA:
|
||||||
cocoa_display_init(ds, &dpy);
|
cocoa_display_init(ds, &dpy);
|
||||||
break;
|
break;
|
||||||
case DT_GTK:
|
case DISPLAY_TYPE_GTK:
|
||||||
gtk_display_init(ds, &dpy);
|
gtk_display_init(ds, &dpy);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -4721,7 +4695,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_OPENGL_DMABUF
|
#ifdef CONFIG_OPENGL_DMABUF
|
||||||
if (display_type == DT_EGL) {
|
if (dpy.type == DISPLAY_TYPE_EGL_HEADLESS) {
|
||||||
egl_headless_init(&dpy);
|
egl_headless_init(&dpy);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user