* [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional
@ 2011-03-15 12:36 Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
` (6 more replies)
0 siblings, 7 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Hi,
This is the second version of the -display patches and the option to
make VNC optional.
It introduces a new -display argument to consolidate the current
-sdl/-curses/-nographic/-vnc arguments and I included the patch I
posted last week to consolidate the DisplaySurface code.
New in this series is support for sub-parameters for SDL, and
-display vnc. I have added documentation to the SDL side, but I am not
quite comfortable with the bits needed to convert the VNC bits, so I
have not included that for now. Would be good to get someone who knows
docbook (or whatever the format is we use) to make sure it is done
correctly. Basically the -display=vnc option supports sub-arbuments as
Anthony suggested yesterday.
Cheers,
Jes
Jes Sorensen (7):
Consolidate DisplaySurface allocation in qemu_alloc_display()
Introduce -display argument
Introduce -display none
Add support for -display vnc
error message if user specifies SDL cmd line option when SDL is
disabled
error message if user specifies curses on cmd line when curses is
disabled
Make VNC support optional
Makefile.objs | 19 ++++----
configure | 37 +++++++++++-----
console.c | 45 +++++++++++---------
console.h | 29 +++++++++++-
monitor.c | 22 ++++-----
qemu-options.hx | 48 +++++++++++++++-----
qerror.h | 3 +
sysemu.h | 1 +
ui/sdl.c | 21 +++------
ui/vnc.c | 14 ++++--
vl.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
11 files changed, 278 insertions(+), 90 deletions(-)
--
1.7.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 14:49 ` [Qemu-devel] " Anthony Liguori
2011-03-15 12:36 ` [Qemu-devel] [PATCH 2/7] Introduce -display argument Jes.Sorensen
` (5 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
This removes various code duplication from console.e and sdl.c
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.c | 45 +++++++++++++++++++++++++--------------------
console.h | 3 +++
ui/sdl.c | 21 ++++++++-------------
3 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/console.c b/console.c
index 57d6eb5..4939a72 100644
--- a/console.c
+++ b/console.c
@@ -1278,35 +1278,40 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
{
DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
- surface->width = width;
- surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ int linesize = width * 4;
+ surface = qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
return surface;
}
static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
int width, int height)
{
+ int linesize = width * 4;
+ surface = qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
+ return surface;
+}
+
+DisplaySurface*
+qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags)
+{
+ void *data;
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
- if (surface->flags & QEMU_ALLOCATED_FLAG)
- surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
- else
- surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
+ surface->linesize = linesize;
+ surface->pf = pf;
+ if (surface->flags & QEMU_ALLOCATED_FLAG) {
+ data = qemu_realloc(surface->data,
+ surface->linesize * surface->height);
+ } else {
+ data = qemu_malloc(surface->linesize * surface->height);
+ }
+ surface->data = (uint8_t *)data;
+ surface->flags = newflags | QEMU_ALLOCATED_FLAG;
#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
+ surface->flags |= QEMU_BIG_ENDIAN_FLAG;
#endif
return surface;
diff --git a/console.h b/console.h
index f4e4741..dec9a76 100644
--- a/console.h
+++ b/console.h
@@ -189,6 +189,9 @@ void register_displaystate(DisplayState *ds);
DisplayState *get_displaystate(void);
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data);
+DisplaySurface* qemu_alloc_display(DisplaySurface *surface, int width,
+ int height, int linesize,
+ PixelFormat pf, int newflags);
PixelFormat qemu_different_endianness_pixelformat(int bpp);
PixelFormat qemu_default_pixelformat(int bpp);
diff --git a/ui/sdl.c b/ui/sdl.c
index 47ac49c..6c10ea6 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -176,23 +176,18 @@ static DisplaySurface* sdl_create_displaysurface(int width, int height)
surface->width = width;
surface->height = height;
-
+
if (scaling_active) {
+ int linesize;
+ PixelFormat pf;
if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ linesize = width * 4;
+ pf = qemu_default_pixelformat(32);
} else {
- surface->linesize = width * host_format.BytesPerPixel;
- surface->pf = sdl_to_qemu_pixelformat(&host_format);
+ linesize = width * host_format.BytesPerPixel;
+ pf = sdl_to_qemu_pixelformat(&host_format);
}
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
- return surface;
+ return qemu_alloc_display(surface, width, height, linesize, pf, 0);
}
if (host_format.BitsPerPixel == 16)
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 2/7] Introduce -display argument
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 14:07 ` [Qemu-devel] " Peter Maydell
2011-03-15 14:51 ` Anthony Liguori
2011-03-15 12:36 ` [Qemu-devel] [PATCH 3/7] Introduce -display none Jes.Sorensen
` (4 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
This patch introduces a -display argument which consolidates the
setting of the display mode. Valid options are:
sdl/curses/default/serial (serial is equivalent to -nographic)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
qemu-options.hx | 27 +++++++++++++++++++
vl.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index badb730..f08ffb1 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -590,6 +590,33 @@ STEXI
@table @option
ETEXI
+DEF("display", HAS_ARG, QEMU_OPTION_display,
+ "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
+ " [,window_close=on|off]|curses|serial\n"
+ " select display type\n", QEMU_ARCH_ALL)
+STEXI
+@item -display @var{type}
+@findex -display
+Select type of display to use. This option is a replacement for the
+old style -sdl/-curses/... options. Valid values for @var{type} are
+@table @option
+@item sdl
+Pick the SDL display option.
+@item curses
+Pick the curses display option. Normally, QEMU uses SDL to display the
+VGA output. With this option, QEMU can display the VGA output when in
+text mode using a curses/ncurses interface. Nothing is displayed in
+graphical mode.
+@item serial
+Normally, QEMU uses SDL to display the VGA output. With this option,
+you can totally disable graphical output so that QEMU is a simple
+command line application. The emulated serial port is redirected on
+the console. Therefore, you can still use QEMU to debug a Linux kernel
+with a serial console. This option is equivalent to the old -nographic
+argument.
+@end table
+ETEXI
+
DEF("nographic", 0, QEMU_OPTION_nographic,
"-nographic disable graphical output and redirect serial I/Os to console\n",
QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index 5e007a7..c88ee58 100644
--- a/vl.c
+++ b/vl.c
@@ -1554,6 +1554,80 @@ static void select_vgahw (const char *p)
}
}
+static DisplayType select_display(const char *p)
+{
+ const char *opts;
+ DisplayType display = DT_DEFAULT;
+
+ if (strstart(p, "sdl", &opts)) {
+#ifdef CONFIG_SDL
+ display = DT_SDL;
+ while (*opts) {
+ const char *nextopt;
+
+ if (strstart(opts, ",frame=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ no_frame = 0;
+ } else if (strstart(opts, "off", &nextopt)) {
+ no_frame = 1;
+ } else {
+ goto invalid_display;
+ }
+ } else if (strstart(opts, ",alt_grab=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ alt_grab = 1;
+ } else if (strstart(opts, "off", &nextopt)) {
+ alt_grab = 0;
+ } else {
+ goto invalid_display;
+ }
+ } else if (strstart(opts, ",ctrl_grab=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ ctrl_grab = 1;
+ } else if (strstart(opts, "off", &nextopt)) {
+ ctrl_grab = 0;
+ } else {
+ goto invalid_display;
+ }
+ } else if (strstart(opts, ",window_close=", &nextopt)) {
+ opts = nextopt;
+ if (strstart(opts, "on", &nextopt)) {
+ no_quit = 0;
+ } else if (strstart(opts, "off", &nextopt)) {
+ no_quit = 1;
+ } else {
+ goto invalid_display;
+ }
+ } else {
+ goto invalid_display;
+ }
+ opts = nextopt;
+ }
+#else
+ fprintf(stderr, "SDL support is disabled\n");
+ exit(1);
+#endif
+ } else if (strstart(p, "curses", &opts)) {
+#ifdef CONFIG_CURSES
+ display = DT_CURSES;
+#else
+ fprintf(stderr, "Curses support is disabled\n");
+ exit(1);
+#endif
+ } else if (strstart(p, "serial", &opts)) {
+ display = DT_NOGRAPHIC;
+ } else {
+ invalid_display:
+ fprintf(stderr, "Unknown display type: %s\n", p);
+ exit(1);
+ }
+
+ return display;
+}
+
static int balloon_parse(const char *arg)
{
QemuOpts *opts;
@@ -2152,6 +2226,9 @@ int main(int argc, char **argv, char **envp)
}
numa_add(optarg);
break;
+ case QEMU_OPTION_display:
+ display_type = select_display(optarg);
+ break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 3/7] Introduce -display none
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 2/7] Introduce -display argument Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 4/7] Add support for -display vnc Jes.Sorensen
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
New option -display none. This option differs from -display nographic
by not trying to take control of stdio etc. but instead behaves as if
a graphics display is enabled, except that it doesn't show one.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
qemu-options.hx | 8 +++++++-
sysemu.h | 1 +
vl.c | 2 ++
3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index f08ffb1..80506e7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -592,7 +592,7 @@ ETEXI
DEF("display", HAS_ARG, QEMU_OPTION_display,
"-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
- " [,window_close=on|off]|curses|serial\n"
+ " [,window_close=on|off]|curses|none|serial\n"
" select display type\n", QEMU_ARCH_ALL)
STEXI
@item -display @var{type}
@@ -607,6 +607,12 @@ Pick the curses display option. Normally, QEMU uses SDL to display the
VGA output. With this option, QEMU can display the VGA output when in
text mode using a curses/ncurses interface. Nothing is displayed in
graphical mode.
+@item none
+Pick the none display option. This option will still run with an
+emulated graphics card, but none will be displayed to the QEMU
+user. This options differs from the -nographic option in that QEMU
+will behave like if one of the display options had been picked, it
+will not change the control on the command line.
@item serial
Normally, QEMU uses SDL to display the VGA output. With this option,
you can totally disable graphical output so that QEMU is a simple
diff --git a/sysemu.h b/sysemu.h
index 0a83ab9..c43c7af 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -110,6 +110,7 @@ typedef enum DisplayType
DT_CURSES,
DT_SDL,
DT_NOGRAPHIC,
+ DT_NONE,
} DisplayType;
extern int autostart;
diff --git a/vl.c b/vl.c
index c88ee58..d12ac96 100644
--- a/vl.c
+++ b/vl.c
@@ -1619,6 +1619,8 @@ static DisplayType select_display(const char *p)
#endif
} else if (strstart(p, "serial", &opts)) {
display = DT_NOGRAPHIC;
+ } else if (strstart(p, "none", &opts)) {
+ display = DT_NONE;
} else {
invalid_display:
fprintf(stderr, "Unknown display type: %s\n", p);
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 4/7] Add support for -display vnc
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
` (2 preceding siblings ...)
2011-03-15 12:36 ` [Qemu-devel] [PATCH 3/7] Introduce -display none Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 5/7] error message if user specifies SDL cmd line option when SDL is disabled Jes.Sorensen
` (2 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
qemu-options.hx | 5 ++++-
vl.c | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 80506e7..e2a31bc 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -592,7 +592,8 @@ ETEXI
DEF("display", HAS_ARG, QEMU_OPTION_display,
"-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
- " [,window_close=on|off]|curses|none|serial\n"
+ " [,window_close=on|off]|curses|none|serial|\n"
+ " vnc=<display>[,<optargs>]\n"
" select display type\n", QEMU_ARCH_ALL)
STEXI
@item -display @var{type}
@@ -620,6 +621,8 @@ command line application. The emulated serial port is redirected on
the console. Therefore, you can still use QEMU to debug a Linux kernel
with a serial console. This option is equivalent to the old -nographic
argument.
+@item vnc
+Start a VNC server on display <arg>
@end table
ETEXI
diff --git a/vl.c b/vl.c
index d12ac96..e58958d 100644
--- a/vl.c
+++ b/vl.c
@@ -1610,6 +1610,20 @@ static DisplayType select_display(const char *p)
fprintf(stderr, "SDL support is disabled\n");
exit(1);
#endif
+ } else if (strstart(p, "vnc", &opts)) {
+ display_remote++;
+
+ if (*opts) {
+ const char *nextopt;
+
+ if (strstart(opts, "=", &nextopt)) {
+ vnc_display = nextopt;
+ }
+ }
+ if (!vnc_display) {
+ fprintf(stderr, "VNC requires a display argument vnc=<display>\n");
+ exit(1);
+ }
} else if (strstart(p, "curses", &opts)) {
#ifdef CONFIG_CURSES
display = DT_CURSES;
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 5/7] error message if user specifies SDL cmd line option when SDL is disabled
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
` (3 preceding siblings ...)
2011-03-15 12:36 ` [Qemu-devel] [PATCH 4/7] Add support for -display vnc Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 6/7] error message if user specifies curses on cmd line when curses " Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 7/7] Make VNC support optional Jes.Sorensen
6 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
qemu-options.hx | 10 ----------
vl.c | 8 ++++++++
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index e2a31bc..ee7e1d7 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -652,11 +652,9 @@ QEMU can display the VGA output when in text mode using a
curses/ncurses interface. Nothing is displayed in graphical mode.
ETEXI
-#ifdef CONFIG_SDL
DEF("no-frame", 0, QEMU_OPTION_no_frame,
"-no-frame open SDL window without a frame and window decorations\n",
QEMU_ARCH_ALL)
-#endif
STEXI
@item -no-frame
@findex -no-frame
@@ -665,42 +663,34 @@ available screen space. This makes the using QEMU in a dedicated desktop
workspace more convenient.
ETEXI
-#ifdef CONFIG_SDL
DEF("alt-grab", 0, QEMU_OPTION_alt_grab,
"-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n",
QEMU_ARCH_ALL)
-#endif
STEXI
@item -alt-grab
@findex -alt-grab
Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt).
ETEXI
-#ifdef CONFIG_SDL
DEF("ctrl-grab", 0, QEMU_OPTION_ctrl_grab,
"-ctrl-grab use Right-Ctrl to grab mouse (instead of Ctrl-Alt)\n",
QEMU_ARCH_ALL)
-#endif
STEXI
@item -ctrl-grab
@findex -ctrl-grab
Use Right-Ctrl to grab mouse (instead of Ctrl-Alt).
ETEXI
-#ifdef CONFIG_SDL
DEF("no-quit", 0, QEMU_OPTION_no_quit,
"-no-quit disable SDL window close capability\n", QEMU_ARCH_ALL)
-#endif
STEXI
@item -no-quit
@findex -no-quit
Disable SDL window close capability.
ETEXI
-#ifdef CONFIG_SDL
DEF("sdl", 0, QEMU_OPTION_sdl,
"-sdl enable SDL\n", QEMU_ARCH_ALL)
-#endif
STEXI
@item -sdl
@findex -sdl
diff --git a/vl.c b/vl.c
index e58958d..4bc81cf 100644
--- a/vl.c
+++ b/vl.c
@@ -2626,6 +2626,14 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_sdl:
display_type = DT_SDL;
break;
+#else
+ case QEMU_OPTION_no_frame:
+ case QEMU_OPTION_alt_grab:
+ case QEMU_OPTION_ctrl_grab:
+ case QEMU_OPTION_no_quit:
+ case QEMU_OPTION_sdl:
+ fprintf(stderr, "SDL support is disabled\n");
+ exit(1);
#endif
case QEMU_OPTION_pidfile:
pid_file = optarg;
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 6/7] error message if user specifies curses on cmd line when curses is disabled
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
` (4 preceding siblings ...)
2011-03-15 12:36 ` [Qemu-devel] [PATCH 5/7] error message if user specifies SDL cmd line option when SDL is disabled Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 7/7] Make VNC support optional Jes.Sorensen
6 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
qemu-options.hx | 2 --
vl.c | 7 +++++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index ee7e1d7..b6b125c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -639,11 +639,9 @@ the console. Therefore, you can still use QEMU to debug a Linux kernel
with a serial console.
ETEXI
-#ifdef CONFIG_CURSES
DEF("curses", 0, QEMU_OPTION_curses,
"-curses use a curses/ncurses interface instead of SDL\n",
QEMU_ARCH_ALL)
-#endif
STEXI
@item -curses
@findex curses
diff --git a/vl.c b/vl.c
index 4bc81cf..baa267a 100644
--- a/vl.c
+++ b/vl.c
@@ -2248,11 +2248,14 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
break;
-#ifdef CONFIG_CURSES
case QEMU_OPTION_curses:
+#ifdef CONFIG_CURSES
display_type = DT_CURSES;
- break;
+#else
+ fprintf(stderr, "Curses support is disabled\n");
+ exit(1);
#endif
+ break;
case QEMU_OPTION_portrait:
graphic_rotate = 1;
break;
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 7/7] Make VNC support optional
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
` (5 preceding siblings ...)
2011-03-15 12:36 ` [Qemu-devel] [PATCH 6/7] error message if user specifies curses on cmd line when curses " Jes.Sorensen
@ 2011-03-15 12:36 ` Jes.Sorensen
6 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 12:36 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Per default VNC is enabled.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
Makefile.objs | 19 ++++++++++---------
configure | 37 +++++++++++++++++++++++++------------
console.h | 26 ++++++++++++++++++++++++--
monitor.c | 22 ++++++++++------------
qerror.h | 3 +++
ui/vnc.c | 14 ++++++++++----
vl.c | 21 +++++++++++++++++----
7 files changed, 99 insertions(+), 43 deletions(-)
diff --git a/Makefile.objs b/Makefile.objs
index a52f42f..9796d12 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -127,19 +127,20 @@ common-obj-y += $(addprefix audio/, $(audio-obj-y))
ui-obj-y += keymaps.o
ui-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
ui-obj-$(CONFIG_CURSES) += curses.o
-ui-obj-y += vnc.o d3des.o
-ui-obj-y += vnc-enc-zlib.o vnc-enc-hextile.o
-ui-obj-y += vnc-enc-tight.o vnc-palette.o
-ui-obj-y += vnc-enc-zrle.o
-ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
-ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
-ui-obj-$(CONFIG_COCOA) += cocoa.o
+vnc-obj-y += vnc.o d3des.o
+vnc-obj-y += vnc-enc-zlib.o vnc-enc-hextile.o
+vnc-obj-y += vnc-enc-tight.o vnc-palette.o
+vnc-obj-y += vnc-enc-zrle.o
+vnc-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
+vnc-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
+vnc-obj-$(CONFIG_COCOA) += cocoa.o
ifdef CONFIG_VNC_THREAD
-ui-obj-y += vnc-jobs-async.o
+vnc-obj-y += vnc-jobs-async.o
else
-ui-obj-y += vnc-jobs-sync.o
+vnc-obj-y += vnc-jobs-sync.o
endif
common-obj-y += $(addprefix ui/, $(ui-obj-y))
+common-obj-$(CONFIG_VNC) += $(addprefix ui/, $(vnc-obj-y))
common-obj-y += iov.o acl.o
common-obj-$(CONFIG_POSIX) += qemu-thread-posix.o compatfd.o
diff --git a/configure b/configure
index a166de0..abd3317 100755
--- a/configure
+++ b/configure
@@ -117,6 +117,7 @@ kvm=""
kvm_para=""
nptl=""
sdl=""
+vnc="yes"
sparse="no"
uuid=""
vde=""
@@ -539,6 +540,10 @@ for opt do
;;
--enable-sdl) sdl="yes"
;;
+ --disable-vnc) vnc="no"
+ ;;
+ --enable-vnc) vnc="yes"
+ ;;
--fmod-lib=*) fmod_lib="$optarg"
;;
--fmod-inc=*) fmod_inc="$optarg"
@@ -836,6 +841,8 @@ echo " --disable-strip disable stripping binaries"
echo " --disable-werror disable compilation abort on warning"
echo " --disable-sdl disable SDL"
echo " --enable-sdl enable SDL"
+echo " --disable-vnc disable VNC"
+echo " --enable-vnc enable VNC"
echo " --enable-cocoa enable COCOA (Mac OS X only)"
echo " --audio-drv-list=LIST set audio drivers list:"
echo " Available drivers: $audio_possible_drivers"
@@ -1273,7 +1280,7 @@ fi
##########################################
# VNC TLS detection
-if test "$vnc_tls" != "no" ; then
+if test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
cat > $TMPC <<EOF
#include <gnutls/gnutls.h>
int main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
@@ -1293,7 +1300,7 @@ fi
##########################################
# VNC SASL detection
-if test "$vnc_sasl" != "no" ; then
+if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
cat > $TMPC <<EOF
#include <sasl/sasl.h>
#include <stdio.h>
@@ -1315,7 +1322,7 @@ fi
##########################################
# VNC JPEG detection
-if test "$vnc_jpeg" != "no" ; then
+if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
cat > $TMPC <<EOF
#include <stdio.h>
#include <jpeglib.h>
@@ -1336,7 +1343,7 @@ fi
##########################################
# VNC PNG detection
-if test "$vnc_png" != "no" ; then
+if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
cat > $TMPC <<EOF
//#include <stdio.h>
#include <png.h>
@@ -2495,11 +2502,14 @@ echo "Audio drivers $audio_drv_list"
echo "Extra audio cards $audio_card_list"
echo "Block whitelist $block_drv_whitelist"
echo "Mixer emulation $mixemu"
-echo "VNC TLS support $vnc_tls"
-echo "VNC SASL support $vnc_sasl"
-echo "VNC JPEG support $vnc_jpeg"
-echo "VNC PNG support $vnc_png"
-echo "VNC thread $vnc_thread"
+echo "VNC support $vnc"
+if test "$vnc" = "yes" ; then
+ echo "VNC TLS support $vnc_tls"
+ echo "VNC SASL support $vnc_sasl"
+ echo "VNC JPEG support $vnc_jpeg"
+ echo "VNC PNG support $vnc_png"
+ echo "VNC thread $vnc_thread"
+fi
if test -n "$sparc_cpu"; then
echo "Target Sparc Arch $sparc_cpu"
fi
@@ -2649,6 +2659,9 @@ echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
if test "$mixemu" = "yes" ; then
echo "CONFIG_MIXEMU=y" >> $config_host_mak
fi
+if test "$vnc" = "yes" ; then
+ echo "CONFIG_VNC=y" >> $config_host_mak
+fi
if test "$vnc_tls" = "yes" ; then
echo "CONFIG_VNC_TLS=y" >> $config_host_mak
echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
@@ -2657,15 +2670,15 @@ if test "$vnc_sasl" = "yes" ; then
echo "CONFIG_VNC_SASL=y" >> $config_host_mak
echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
fi
-if test "$vnc_jpeg" != "no" ; then
+if test "$vnc_jpeg" = "yes" ; then
echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
fi
-if test "$vnc_png" != "no" ; then
+if test "$vnc_png" = "yes" ; then
echo "CONFIG_VNC_PNG=y" >> $config_host_mak
echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
fi
-if test "$vnc_thread" != "no" ; then
+if test "$vnc_thread" = "yes" ; then
echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
fi
if test "$fnmatch" = "yes" ; then
diff --git a/console.h b/console.h
index dec9a76..317da1b 100644
--- a/console.h
+++ b/console.h
@@ -4,6 +4,8 @@
#include "qemu-char.h"
#include "qdict.h"
#include "notify.h"
+#include "qerror.h"
+#include "monitor.h"
/* keyboard/mouse support */
@@ -371,12 +373,32 @@ void cocoa_display_init(DisplayState *ds, int full_screen);
void vnc_display_init(DisplayState *ds);
void vnc_display_close(DisplayState *ds);
int vnc_display_open(DisplayState *ds, const char *display);
-int vnc_display_password(DisplayState *ds, const char *password);
int vnc_display_disable_login(DisplayState *ds);
+char *vnc_display_local_addr(DisplayState *ds);
+#ifdef CONFIG_VNC
+int vnc_display_password(DisplayState *ds, const char *password);
int vnc_display_pw_expire(DisplayState *ds, time_t expires);
void do_info_vnc_print(Monitor *mon, const QObject *data);
void do_info_vnc(Monitor *mon, QObject **ret_data);
-char *vnc_display_local_addr(DisplayState *ds);
+#else
+static inline int vnc_display_password(DisplayState *ds, const char *password)
+{
+ qerror_report(QERR_FEATURE_DISABLED, "vnc");
+ return -ENODEV;
+}
+static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
+{
+ qerror_report(QERR_FEATURE_DISABLED, "vnc");
+ return -ENODEV;
+};
+static inline void do_info_vnc(Monitor *mon, QObject **ret_data)
+{
+};
+static inline void do_info_vnc_print(Monitor *mon, const QObject *data)
+{
+ monitor_printf(mon, "VNC support disabled\n");
+};
+#endif
/* curses.c */
void curses_display_init(DisplayState *ds, int full_screen);
diff --git a/monitor.c b/monitor.c
index 22ae3bb..4a54c55 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1016,6 +1016,7 @@ static int do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
+#ifdef CONFIG_VNC
static int change_vnc_password(const char *password)
{
if (!password || !password[0]) {
@@ -1062,6 +1063,13 @@ static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
return 0;
}
+#else
+static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
+{
+ qerror_report(QERR_FEATURE_DISABLED, "vnc");
+ return -ENODEV;
+}
+#endif
/**
* do_change(): Change a removable medium, or VNC configuration
@@ -1127,12 +1135,7 @@ static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
/* Note that setting an empty password will not disable login through
* this interface. */
- rc = vnc_display_password(NULL, password);
- if (rc != 0) {
- qerror_report(QERR_SET_PASSWD_FAILED);
- return -1;
- }
- return 0;
+ return vnc_display_password(NULL, password);
}
qerror_report(QERR_INVALID_PARAMETER, "protocol");
@@ -1171,12 +1174,7 @@ static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
}
if (strcmp(protocol, "vnc") == 0) {
- rc = vnc_display_pw_expire(NULL, when);
- if (rc != 0) {
- qerror_report(QERR_SET_PASSWD_FAILED);
- return -1;
- }
- return 0;
+ return vnc_display_pw_expire(NULL, when);
}
qerror_report(QERR_INVALID_PARAMETER, "protocol");
diff --git a/qerror.h b/qerror.h
index f732d45..df61d2c 100644
--- a/qerror.h
+++ b/qerror.h
@@ -171,4 +171,7 @@ QError *qobject_to_qerror(const QObject *obj);
#define QERR_VNC_SERVER_FAILED \
"{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
+#define QERR_FEATURE_DISABLED \
+ "{ 'class': 'FeatureDisabled', 'data': { 'name': %s } }"
+
#endif /* QERROR_H */
diff --git a/ui/vnc.c b/ui/vnc.c
index 34dc0cd..dd7a44a 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2638,16 +2638,19 @@ int vnc_display_disable_login(DisplayState *ds)
int vnc_display_password(DisplayState *ds, const char *password)
{
+ int ret = 0;
VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display;
if (!vs) {
- return -1;
+ ret = -EINVAL;
+ goto out;
}
if (!password) {
/* This is not the intention of this interface but err on the side
of being safe */
- return vnc_display_disable_login(ds);
+ ret = vnc_display_disable_login(ds);
+ goto out;
}
if (vs->password) {
@@ -2656,8 +2659,11 @@ int vnc_display_password(DisplayState *ds, const char *password)
}
vs->password = qemu_strdup(password);
vs->auth = VNC_AUTH_VNC;
-
- return 0;
+out:
+ if (ret != 0) {
+ qerror_report(QERR_SET_PASSWD_FAILED);
+ }
+ return ret;
}
int vnc_display_pw_expire(DisplayState *ds, time_t expires)
diff --git a/vl.c b/vl.c
index baa267a..7e852f5 100644
--- a/vl.c
+++ b/vl.c
@@ -206,7 +206,9 @@ int smp_cpus = 1;
int max_cpus = 0;
int smp_cores = 1;
int smp_threads = 1;
+#ifdef CONFIG_VNC
const char *vnc_display;
+#endif
int acpi_enabled = 1;
int no_hpet = 0;
int fd_bootchk = 1;
@@ -2027,7 +2029,9 @@ int main(int argc, char **argv, char **envp)
int tb_size;
const char *pid_file = NULL;
const char *incoming = NULL;
+#ifdef CONFIG_VNC
int show_vnc_port = 0;
+#endif
int defconfig = 1;
const char *trace_file = NULL;
@@ -2685,9 +2689,14 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_vnc:
+#ifdef CONFIG_VNC
display_remote++;
- vnc_display = optarg;
- break;
+ vnc_display = optarg;
+#else
+ fprintf(stderr, "VNC support is disabled\n");
+ exit(1);
+#endif
+ break;
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
@@ -3141,12 +3150,14 @@ int main(int argc, char **argv, char **envp)
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
display_type = DT_SDL;
-#else
+#elif defined(CONFIG_VNC)
vnc_display = "localhost:0,to=99";
show_vnc_port = 1;
+#else
+ display_type = DT_NONE;
#endif
}
-
+
/* init local displays */
switch (display_type) {
@@ -3170,6 +3181,7 @@ int main(int argc, char **argv, char **envp)
break;
}
+#ifdef CONFIG_VNC
/* init remote displays */
if (vnc_display) {
vnc_display_init(ds);
@@ -3180,6 +3192,7 @@ int main(int argc, char **argv, char **envp)
printf("VNC server running on `%s'\n", vnc_display_local_addr(ds));
}
}
+#endif
#ifdef CONFIG_SPICE
if (using_spice && !qxl_enabled) {
qemu_spice_display_init(ds);
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 12:36 ` [Qemu-devel] [PATCH 2/7] Introduce -display argument Jes.Sorensen
@ 2011-03-15 14:07 ` Peter Maydell
2011-03-15 14:53 ` Anthony Liguori
2011-03-15 15:14 ` Alexander Graf
2011-03-15 14:51 ` Anthony Liguori
1 sibling, 2 replies; 19+ messages in thread
From: Peter Maydell @ 2011-03-15 14:07 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: jan.kiszka, qemu-devel
On 15 March 2011 12:36, <Jes.Sorensen@redhat.com> wrote:
> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>
> This patch introduces a -display argument which consolidates the
> setting of the display mode. Valid options are:
> sdl/curses/default/serial (serial is equivalent to -nographic)
So I still think that we should not be including any new
-display subargument which mirrors the behaviour of -nographic.
-display represents an opportunity to provide a set of orthogonal
command line options which affect the handling of particular
devices; it ought to mean "what happens to VGA/video output?",
and should not change the behaviour of any other devices.
-nographic is effectively a convenience shortcut which changes
the behaviour of several different devices (display, serial,
parallel, at least). It doesn't belong under '-display' from
an orthogonality argument, and people who want it because it
is a shortcut will be better served by the existing '-nographic'
because it's less typing than '-display serial' anyway.
(Ideally we should document '-nographic' by saying that it
is equivalent to some set of other options including
-display none -serial stdio and whatever else it does.)
-- PMM
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-15 12:36 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
@ 2011-03-15 14:49 ` Anthony Liguori
2011-03-15 14:53 ` Jes Sorensen
0 siblings, 1 reply; 19+ messages in thread
From: Anthony Liguori @ 2011-03-15 14:49 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: jan.kiszka, qemu-devel, peter.maydell
On 03/15/2011 07:36 AM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> This removes various code duplication from console.e and sdl.c
>
> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
> ---
> console.c | 45 +++++++++++++++++++++++++--------------------
> console.h | 3 +++
> ui/sdl.c | 21 ++++++++-------------
> 3 files changed, 36 insertions(+), 33 deletions(-)
>
> diff --git a/console.c b/console.c
> index 57d6eb5..4939a72 100644
> --- a/console.c
> +++ b/console.c
> @@ -1278,35 +1278,40 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
> {
> DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
>
> - surface->width = width;
> - surface->height = height;
> - surface->linesize = width * 4;
> - surface->pf = qemu_default_pixelformat(32);
> -#ifdef HOST_WORDS_BIGENDIAN
> - surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
> -#else
> - surface->flags = QEMU_ALLOCATED_FLAG;
> -#endif
> - surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
> -
> + int linesize = width * 4;
> + surface = qemu_alloc_display(surface, width, height, linesize,
> + qemu_default_pixelformat(32), 0);
> return surface;
> }
>
> static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
> int width, int height)
> {
> + int linesize = width * 4;
> + surface = qemu_alloc_display(surface, width, height, linesize,
> + qemu_default_pixelformat(32), 0);
> + return surface;
> +}
> +
> +DisplaySurface*
> +qemu_alloc_display(DisplaySurface *surface, int width, int height,
> + int linesize, PixelFormat pf, int newflags)
> +{
> + void *data;
> surface->width = width;
> surface->height = height;
> - surface->linesize = width * 4;
> - surface->pf = qemu_default_pixelformat(32);
> - if (surface->flags& QEMU_ALLOCATED_FLAG)
> - surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
> - else
> - surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
> + surface->linesize = linesize;
> + surface->pf = pf;
> + if (surface->flags& QEMU_ALLOCATED_FLAG) {
> + data = qemu_realloc(surface->data,
> + surface->linesize * surface->height);
> + } else {
> + data = qemu_malloc(surface->linesize * surface->height);
> + }
> + surface->data = (uint8_t *)data;
> + surface->flags = newflags | QEMU_ALLOCATED_FLAG;
> #ifdef HOST_WORDS_BIGENDIAN
> - surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
> -#else
> - surface->flags = QEMU_ALLOCATED_FLAG;
> + surface->flags |= QEMU_BIG_ENDIAN_FLAG;
> #endif
>
> return surface;
> diff --git a/console.h b/console.h
> index f4e4741..dec9a76 100644
> --- a/console.h
> +++ b/console.h
> @@ -189,6 +189,9 @@ void register_displaystate(DisplayState *ds);
> DisplayState *get_displaystate(void);
> DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
> int linesize, uint8_t *data);
> +DisplaySurface* qemu_alloc_display(DisplaySurface *surface, int width,
> + int height, int linesize,
> + PixelFormat pf, int newflags);
Is it really useful at all to return DisplaySurface? When I see a
return value of 'DisplaySurface *' and an alloc in the function name, I
assume this function allocates a display surface but it's really
allocating the framebuffer within a display surface.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 12:36 ` [Qemu-devel] [PATCH 2/7] Introduce -display argument Jes.Sorensen
2011-03-15 14:07 ` [Qemu-devel] " Peter Maydell
@ 2011-03-15 14:51 ` Anthony Liguori
2011-03-15 14:54 ` Jes Sorensen
1 sibling, 1 reply; 19+ messages in thread
From: Anthony Liguori @ 2011-03-15 14:51 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: jan.kiszka, qemu-devel, peter.maydell
On 03/15/2011 07:36 AM, Jes.Sorensen@redhat.com wrote:
> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>
> This patch introduces a -display argument which consolidates the
> setting of the display mode. Valid options are:
> sdl/curses/default/serial (serial is equivalent to -nographic)
>
> Signed-off-by: Jes Sorensen<Jes.Sorensen@redhat.com>
> ---
> qemu-options.hx | 27 +++++++++++++++++++
> vl.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 104 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index badb730..f08ffb1 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -590,6 +590,33 @@ STEXI
> @table @option
> ETEXI
>
> +DEF("display", HAS_ARG, QEMU_OPTION_display,
> + "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
> + " [,window_close=on|off]|curses|serial\n"
> + " select display type\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -display @var{type}
> +@findex -display
> +Select type of display to use. This option is a replacement for the
> +old style -sdl/-curses/... options. Valid values for @var{type} are
> +@table @option
> +@item sdl
> +Pick the SDL display option.
> +@item curses
> +Pick the curses display option. Normally, QEMU uses SDL to display the
> +VGA output. With this option, QEMU can display the VGA output when in
> +text mode using a curses/ncurses interface. Nothing is displayed in
> +graphical mode.
> +@item serial
> +Normally, QEMU uses SDL to display the VGA output. With this option,
> +you can totally disable graphical output so that QEMU is a simple
> +command line application. The emulated serial port is redirected on
> +the console. Therefore, you can still use QEMU to debug a Linux kernel
> +with a serial console. This option is equivalent to the old -nographic
> +argument.
> +@end table
> +ETEXI
> +
> DEF("nographic", 0, QEMU_OPTION_nographic,
> "-nographic disable graphical output and redirect serial I/Os to console\n",
> QEMU_ARCH_ALL)
> diff --git a/vl.c b/vl.c
> index 5e007a7..c88ee58 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1554,6 +1554,80 @@ static void select_vgahw (const char *p)
> }
> }
>
> +static DisplayType select_display(const char *p)
> +{
> + const char *opts;
> + DisplayType display = DT_DEFAULT;
> +
> + if (strstart(p, "sdl",&opts)) {
> +#ifdef CONFIG_SDL
> + display = DT_SDL;
> + while (*opts) {
> + const char *nextopt;
> +
> + if (strstart(opts, ",frame=",&nextopt)) {
> + opts = nextopt;
> + if (strstart(opts, "on",&nextopt)) {
> + no_frame = 0;
> + } else if (strstart(opts, "off",&nextopt)) {
> + no_frame = 1;
> + } else {
> + goto invalid_display;
> + }
> + } else if (strstart(opts, ",alt_grab=",&nextopt)) {
> + opts = nextopt;
> + if (strstart(opts, "on",&nextopt)) {
> + alt_grab = 1;
> + } else if (strstart(opts, "off",&nextopt)) {
> + alt_grab = 0;
> + } else {
> + goto invalid_display;
> + }
> + } else if (strstart(opts, ",ctrl_grab=",&nextopt)) {
> + opts = nextopt;
> + if (strstart(opts, "on",&nextopt)) {
> + ctrl_grab = 1;
> + } else if (strstart(opts, "off",&nextopt)) {
> + ctrl_grab = 0;
> + } else {
> + goto invalid_display;
> + }
> + } else if (strstart(opts, ",window_close=",&nextopt)) {
> + opts = nextopt;
> + if (strstart(opts, "on",&nextopt)) {
> + no_quit = 0;
> + } else if (strstart(opts, "off",&nextopt)) {
> + no_quit = 1;
> + } else {
> + goto invalid_display;
> + }
> + } else {
> + goto invalid_display;
> + }
> + opts = nextopt;
> + }
So the natural reaction here is going to be, "just use QemuOpts". But
this is harder than it seems. The problem is that the VNC options
inverse the meaning of booleans making conversion of VNC to use QemuOpts
much harder than it would appear.
Doing it this way lets us pass the vnc option string directly to
vnc_display_open(). I don't like it much, but I don't mind it as an
interim step.
Regards,
Anthony Liguori
> +#else
> + fprintf(stderr, "SDL support is disabled\n");
> + exit(1);
> +#endif
> + } else if (strstart(p, "curses",&opts)) {
> +#ifdef CONFIG_CURSES
> + display = DT_CURSES;
> +#else
> + fprintf(stderr, "Curses support is disabled\n");
> + exit(1);
> +#endif
> + } else if (strstart(p, "serial",&opts)) {
> + display = DT_NOGRAPHIC;
> + } else {
> + invalid_display:
> + fprintf(stderr, "Unknown display type: %s\n", p);
> + exit(1);
> + }
> +
> + return display;
> +}
> +
> static int balloon_parse(const char *arg)
> {
> QemuOpts *opts;
> @@ -2152,6 +2226,9 @@ int main(int argc, char **argv, char **envp)
> }
> numa_add(optarg);
> break;
> + case QEMU_OPTION_display:
> + display_type = select_display(optarg);
> + break;
> case QEMU_OPTION_nographic:
> display_type = DT_NOGRAPHIC;
> break;
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-15 14:49 ` [Qemu-devel] " Anthony Liguori
@ 2011-03-15 14:53 ` Jes Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes Sorensen @ 2011-03-15 14:53 UTC (permalink / raw)
To: Anthony Liguori; +Cc: jan.kiszka, qemu-devel, peter.maydell
On 03/15/11 15:49, Anthony Liguori wrote:
>> index f4e4741..dec9a76 100644
>> --- a/console.h
>> +++ b/console.h
>> @@ -189,6 +189,9 @@ void register_displaystate(DisplayState *ds);
>> DisplayState *get_displaystate(void);
>> DisplaySurface* qemu_create_displaysurface_from(int width, int
>> height, int bpp,
>> int linesize,
>> uint8_t *data);
>> +DisplaySurface* qemu_alloc_display(DisplaySurface *surface, int width,
>> + int height, int linesize,
>> + PixelFormat pf, int newflags);
>
> Is it really useful at all to return DisplaySurface? When I see a
> return value of 'DisplaySurface *' and an alloc in the function name, I
> assume this function allocates a display surface but it's really
> allocating the framebuffer within a display surface.
I am not sure what is better here - if you have a better suggestion for
the name, I am all open. The reason it turned out this way is that there
are already other ways where the DisplaySurface itself can be allocated.
Cheers,
Jes
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 14:07 ` [Qemu-devel] " Peter Maydell
@ 2011-03-15 14:53 ` Anthony Liguori
2011-03-15 14:55 ` Jes Sorensen
2011-03-15 15:14 ` Alexander Graf
1 sibling, 1 reply; 19+ messages in thread
From: Anthony Liguori @ 2011-03-15 14:53 UTC (permalink / raw)
To: Peter Maydell; +Cc: Jes.Sorensen, qemu-devel, jan.kiszka
On 03/15/2011 09:07 AM, Peter Maydell wrote:
> On 15 March 2011 12:36,<Jes.Sorensen@redhat.com> wrote:
>> From: Jes Sorensen<Jes.Sorensen@redhat.com>
>>
>> This patch introduces a -display argument which consolidates the
>> setting of the display mode. Valid options are:
>> sdl/curses/default/serial (serial is equivalent to -nographic)
> So I still think that we should not be including any new
> -display subargument which mirrors the behaviour of -nographic.
>
> -display represents an opportunity to provide a set of orthogonal
> command line options which affect the handling of particular
> devices; it ought to mean "what happens to VGA/video output?",
> and should not change the behaviour of any other devices.
>
> -nographic is effectively a convenience shortcut which changes
> the behaviour of several different devices (display, serial,
> parallel, at least). It doesn't belong under '-display' from
> an orthogonality argument, and people who want it because it
> is a shortcut will be better served by the existing '-nographic'
> because it's less typing than '-display serial' anyway.
Yeah, I think I agree. We shouldn't have a -display nographic.
Regards,
Anthony Liguori
> (Ideally we should document '-nographic' by saying that it
> is equivalent to some set of other options including
> -display none -serial stdio and whatever else it does.)
>
> -- PMM
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 14:51 ` Anthony Liguori
@ 2011-03-15 14:54 ` Jes Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes Sorensen @ 2011-03-15 14:54 UTC (permalink / raw)
To: Anthony Liguori; +Cc: jan.kiszka, qemu-devel, peter.maydell
On 03/15/11 15:51, Anthony Liguori wrote:
>> + } else if (strstart(opts, ",window_close=",&nextopt)) {
>> + opts = nextopt;
>> + if (strstart(opts, "on",&nextopt)) {
>> + no_quit = 0;
>> + } else if (strstart(opts, "off",&nextopt)) {
>> + no_quit = 1;
>> + } else {
>> + goto invalid_display;
>> + }
>> + } else {
>> + goto invalid_display;
>> + }
>> + opts = nextopt;
>> + }
>
> So the natural reaction here is going to be, "just use QemuOpts". But
> this is harder than it seems. The problem is that the VNC options
> inverse the meaning of booleans making conversion of VNC to use QemuOpts
> much harder than it would appear.
>
> Doing it this way lets us pass the vnc option string directly to
> vnc_display_open(). I don't like it much, but I don't mind it as an
> interim step.
Yeah, it isn't particularly pretty, but it really requires we rewamp the
arguments completely which I think is out of scope for the initial
change here.
Cheers,
Jes
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 14:53 ` Anthony Liguori
@ 2011-03-15 14:55 ` Jes Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes Sorensen @ 2011-03-15 14:55 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Peter Maydell, qemu-devel, jan.kiszka
On 03/15/11 15:53, Anthony Liguori wrote:
>> -nographic is effectively a convenience shortcut which changes
>> the behaviour of several different devices (display, serial,
>> parallel, at least). It doesn't belong under '-display' from
>> an orthogonality argument, and people who want it because it
>> is a shortcut will be better served by the existing '-nographic'
>> because it's less typing than '-display serial' anyway.
>
> Yeah, I think I agree. We shouldn't have a -display nographic.
Ok, consider it gone. I've never used it, so a I am more than happy to
axe it :)
Cheers,
Jes
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Qemu-devel] Re: [PATCH 2/7] Introduce -display argument
2011-03-15 14:07 ` [Qemu-devel] " Peter Maydell
2011-03-15 14:53 ` Anthony Liguori
@ 2011-03-15 15:14 ` Alexander Graf
1 sibling, 0 replies; 19+ messages in thread
From: Alexander Graf @ 2011-03-15 15:14 UTC (permalink / raw)
To: Peter Maydell; +Cc: Jes.Sorensen, qemu-devel, jan.kiszka
On 15.03.2011, at 15:07, Peter Maydell wrote:
> On 15 March 2011 12:36, <Jes.Sorensen@redhat.com> wrote:
>> From: Jes Sorensen <Jes.Sorensen@redhat.com>
>>
>> This patch introduces a -display argument which consolidates the
>> setting of the display mode. Valid options are:
>> sdl/curses/default/serial (serial is equivalent to -nographic)
>
> So I still think that we should not be including any new
> -display subargument which mirrors the behaviour of -nographic.
>
> -display represents an opportunity to provide a set of orthogonal
> command line options which affect the handling of particular
> devices; it ought to mean "what happens to VGA/video output?",
> and should not change the behaviour of any other devices.
>
> -nographic is effectively a convenience shortcut which changes
> the behaviour of several different devices (display, serial,
> parallel, at least). It doesn't belong under '-display' from
> an orthogonality argument, and people who want it because it
> is a shortcut will be better served by the existing '-nographic'
> because it's less typing than '-display serial' anyway.
>
> (Ideally we should document '-nographic' by saying that it
> is equivalent to some set of other options including
> -display none -serial stdio and whatever else it does.)
Ideally it should also be implemented as such :)
Alex
^ permalink raw reply [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-16 12:33 [Qemu-devel] [PATCH v5 0/7] Introduce -display and make VNC optional Jes.Sorensen
@ 2011-03-16 12:33 ` Jes.Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-16 12:33 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
This removes various code duplication from console.e and sdl.c
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.c | 46 ++++++++++++++++++++++++----------------------
console.h | 2 ++
ui/sdl.c | 20 ++++++++------------
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/console.c b/console.c
index 57d6eb5..f86186f 100644
--- a/console.c
+++ b/console.c
@@ -1278,38 +1278,40 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
{
DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
- surface->width = width;
- surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
return surface;
}
static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
int width, int height)
{
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
+ return surface;
+}
+
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags)
+{
+ void *data;
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
- if (surface->flags & QEMU_ALLOCATED_FLAG)
- surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
- else
- surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
+ surface->linesize = linesize;
+ surface->pf = pf;
+ if (surface->flags & QEMU_ALLOCATED_FLAG) {
+ data = qemu_realloc(surface->data,
+ surface->linesize * surface->height);
+ } else {
+ data = qemu_malloc(surface->linesize * surface->height);
+ }
+ surface->data = (uint8_t *)data;
+ surface->flags = newflags | QEMU_ALLOCATED_FLAG;
#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
+ surface->flags |= QEMU_BIG_ENDIAN_FLAG;
#endif
-
- return surface;
}
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
diff --git a/console.h b/console.h
index f4e4741..711895e 100644
--- a/console.h
+++ b/console.h
@@ -189,6 +189,8 @@ void register_displaystate(DisplayState *ds);
DisplayState *get_displaystate(void);
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data);
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags);
PixelFormat qemu_different_endianness_pixelformat(int bpp);
PixelFormat qemu_default_pixelformat(int bpp);
diff --git a/ui/sdl.c b/ui/sdl.c
index 47ac49c..c5bb0a3 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -176,22 +176,18 @@ static DisplaySurface* sdl_create_displaysurface(int width, int height)
surface->width = width;
surface->height = height;
-
+
if (scaling_active) {
+ int linesize;
+ PixelFormat pf;
if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ linesize = width * 4;
+ pf = qemu_default_pixelformat(32);
} else {
- surface->linesize = width * host_format.BytesPerPixel;
- surface->pf = sdl_to_qemu_pixelformat(&host_format);
+ linesize = width * host_format.BytesPerPixel;
+ pf = sdl_to_qemu_pixelformat(&host_format);
}
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ qemu_alloc_display(surface, width, height, linesize, pf, 0);
return surface;
}
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-16 11:00 [Qemu-devel] [PATCH v4 0/7] Introduce -display and make VNC optional Jes.Sorensen
@ 2011-03-16 11:00 ` Jes.Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-16 11:00 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
This removes various code duplication from console.e and sdl.c
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.c | 46 ++++++++++++++++++++++++----------------------
console.h | 2 ++
ui/sdl.c | 20 ++++++++------------
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/console.c b/console.c
index 57d6eb5..f86186f 100644
--- a/console.c
+++ b/console.c
@@ -1278,38 +1278,40 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
{
DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
- surface->width = width;
- surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
return surface;
}
static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
int width, int height)
{
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
+ return surface;
+}
+
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags)
+{
+ void *data;
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
- if (surface->flags & QEMU_ALLOCATED_FLAG)
- surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
- else
- surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
+ surface->linesize = linesize;
+ surface->pf = pf;
+ if (surface->flags & QEMU_ALLOCATED_FLAG) {
+ data = qemu_realloc(surface->data,
+ surface->linesize * surface->height);
+ } else {
+ data = qemu_malloc(surface->linesize * surface->height);
+ }
+ surface->data = (uint8_t *)data;
+ surface->flags = newflags | QEMU_ALLOCATED_FLAG;
#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
+ surface->flags |= QEMU_BIG_ENDIAN_FLAG;
#endif
-
- return surface;
}
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
diff --git a/console.h b/console.h
index f4e4741..711895e 100644
--- a/console.h
+++ b/console.h
@@ -189,6 +189,8 @@ void register_displaystate(DisplayState *ds);
DisplayState *get_displaystate(void);
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data);
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags);
PixelFormat qemu_different_endianness_pixelformat(int bpp);
PixelFormat qemu_default_pixelformat(int bpp);
diff --git a/ui/sdl.c b/ui/sdl.c
index 47ac49c..c5bb0a3 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -176,22 +176,18 @@ static DisplaySurface* sdl_create_displaysurface(int width, int height)
surface->width = width;
surface->height = height;
-
+
if (scaling_active) {
+ int linesize;
+ PixelFormat pf;
if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ linesize = width * 4;
+ pf = qemu_default_pixelformat(32);
} else {
- surface->linesize = width * host_format.BytesPerPixel;
- surface->pf = sdl_to_qemu_pixelformat(&host_format);
+ linesize = width * host_format.BytesPerPixel;
+ pf = sdl_to_qemu_pixelformat(&host_format);
}
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ qemu_alloc_display(surface, width, height, linesize, pf, 0);
return surface;
}
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display()
2011-03-15 15:45 [Qemu-devel] [PATCH v3 0/7] Introduce -display and make VNC optional Jes.Sorensen
@ 2011-03-15 15:45 ` Jes.Sorensen
0 siblings, 0 replies; 19+ messages in thread
From: Jes.Sorensen @ 2011-03-15 15:45 UTC (permalink / raw)
To: qemu-devel; +Cc: jan.kiszka, peter.maydell
From: Jes Sorensen <Jes.Sorensen@redhat.com>
This removes various code duplication from console.e and sdl.c
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
console.c | 46 ++++++++++++++++++++++++----------------------
console.h | 2 ++
ui/sdl.c | 20 ++++++++------------
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/console.c b/console.c
index 57d6eb5..f86186f 100644
--- a/console.c
+++ b/console.c
@@ -1278,38 +1278,40 @@ static DisplaySurface* defaultallocator_create_displaysurface(int width, int hei
{
DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
- surface->width = width;
- surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
return surface;
}
static DisplaySurface* defaultallocator_resize_displaysurface(DisplaySurface *surface,
int width, int height)
{
+ int linesize = width * 4;
+ qemu_alloc_display(surface, width, height, linesize,
+ qemu_default_pixelformat(32), 0);
+ return surface;
+}
+
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags)
+{
+ void *data;
surface->width = width;
surface->height = height;
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
- if (surface->flags & QEMU_ALLOCATED_FLAG)
- surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
- else
- surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
+ surface->linesize = linesize;
+ surface->pf = pf;
+ if (surface->flags & QEMU_ALLOCATED_FLAG) {
+ data = qemu_realloc(surface->data,
+ surface->linesize * surface->height);
+ } else {
+ data = qemu_malloc(surface->linesize * surface->height);
+ }
+ surface->data = (uint8_t *)data;
+ surface->flags = newflags | QEMU_ALLOCATED_FLAG;
#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
+ surface->flags |= QEMU_BIG_ENDIAN_FLAG;
#endif
-
- return surface;
}
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
diff --git a/console.h b/console.h
index f4e4741..711895e 100644
--- a/console.h
+++ b/console.h
@@ -189,6 +189,8 @@ void register_displaystate(DisplayState *ds);
DisplayState *get_displaystate(void);
DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
int linesize, uint8_t *data);
+void qemu_alloc_display(DisplaySurface *surface, int width, int height,
+ int linesize, PixelFormat pf, int newflags);
PixelFormat qemu_different_endianness_pixelformat(int bpp);
PixelFormat qemu_default_pixelformat(int bpp);
diff --git a/ui/sdl.c b/ui/sdl.c
index 47ac49c..c5bb0a3 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -176,22 +176,18 @@ static DisplaySurface* sdl_create_displaysurface(int width, int height)
surface->width = width;
surface->height = height;
-
+
if (scaling_active) {
+ int linesize;
+ PixelFormat pf;
if (host_format.BytesPerPixel != 2 && host_format.BytesPerPixel != 4) {
- surface->linesize = width * 4;
- surface->pf = qemu_default_pixelformat(32);
+ linesize = width * 4;
+ pf = qemu_default_pixelformat(32);
} else {
- surface->linesize = width * host_format.BytesPerPixel;
- surface->pf = sdl_to_qemu_pixelformat(&host_format);
+ linesize = width * host_format.BytesPerPixel;
+ pf = sdl_to_qemu_pixelformat(&host_format);
}
-#ifdef HOST_WORDS_BIGENDIAN
- surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
-#else
- surface->flags = QEMU_ALLOCATED_FLAG;
-#endif
- surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
-
+ qemu_alloc_display(surface, width, height, linesize, pf, 0);
return surface;
}
--
1.7.4
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2011-03-16 12:34 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-15 12:36 [Qemu-devel] [PATCH v2 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
2011-03-15 14:49 ` [Qemu-devel] " Anthony Liguori
2011-03-15 14:53 ` Jes Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 2/7] Introduce -display argument Jes.Sorensen
2011-03-15 14:07 ` [Qemu-devel] " Peter Maydell
2011-03-15 14:53 ` Anthony Liguori
2011-03-15 14:55 ` Jes Sorensen
2011-03-15 15:14 ` Alexander Graf
2011-03-15 14:51 ` Anthony Liguori
2011-03-15 14:54 ` Jes Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 3/7] Introduce -display none Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 4/7] Add support for -display vnc Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 5/7] error message if user specifies SDL cmd line option when SDL is disabled Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 6/7] error message if user specifies curses on cmd line when curses " Jes.Sorensen
2011-03-15 12:36 ` [Qemu-devel] [PATCH 7/7] Make VNC support optional Jes.Sorensen
2011-03-15 15:45 [Qemu-devel] [PATCH v3 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-15 15:45 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
2011-03-16 11:00 [Qemu-devel] [PATCH v4 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-16 11:00 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
2011-03-16 12:33 [Qemu-devel] [PATCH v5 0/7] Introduce -display and make VNC optional Jes.Sorensen
2011-03-16 12:33 ` [Qemu-devel] [PATCH 1/7] Consolidate DisplaySurface allocation in qemu_alloc_display() Jes.Sorensen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.