Patchwork [RFC] Allow building without graphics support

login
register
mail settings
Submitter Scott Wood
Date Dec. 12, 2012, 3:18 a.m.
Message ID <20121212031856.GA26121@buserror.net>
Download mbox | patch
Permalink /patch/205353/
State New
Headers show

Comments

Scott Wood - Dec. 12, 2012, 3:18 a.m.
QEMU is sometimes used in embedded contexts, where graphical support
is unnecessary.  The ability to turn off graphics support not only
saves some space, but it eliminates the dependency on pixman.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
There are undoubtedly some rough edges that need to be cleaned up and
other parts of graphics code that could be compiled out -- this is mainly
meant to see what people think of the concept.

My immediate motivation was that the QEMU-supplied pixman was being a
pain to cross compile (especially without hacking up the generated QEMU
makefiles to pass additional things to pixman's configure), and in
general it would be nice to not have to carry around graphical baggage
when running on hardware that doesn't even have a display (so I was more
inclined to do this than to spend effort fixing the pixman build).
---
 Makefile.objs    |    7 +++++--
 configure        |   26 +++++++++++++++++++++++++-
 console.h        |    4 ++++
 hw/Makefile.objs |    4 ++++
 no-console.c     |    8 ++++++++
 qemu-char.c      |    2 ++
 qemu-pixman.c    |    1 +
 qemu-pixman.h    |    4 ++++
 ui/Makefile.objs |    2 ++
 ui/vnc.h         |    4 ++++
 vl.c             |   14 ++++++++++++--
 11 files changed, 71 insertions(+), 5 deletions(-)
 create mode 100644 no-console.c
Stefan Weil - Dec. 12, 2012, 6:46 a.m.
Am 12.12.2012 04:18, schrieb Scott Wood:
> QEMU is sometimes used in embedded contexts, where graphical support
> is unnecessary.  The ability to turn off graphics support not only
> saves some space, but it eliminates the dependency on pixman.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> There are undoubtedly some rough edges that need to be cleaned up and
> other parts of graphics code that could be compiled out -- this is mainly
> meant to see what people think of the concept.
>
> My immediate motivation was that the QEMU-supplied pixman was being a
> pain to cross compile (especially without hacking up the generated QEMU
> makefiles to pass additional things to pixman's configure), and in
> general it would be nice to not have to carry around graphical baggage
> when running on hardware that doesn't even have a display (so I was more
> inclined to do this than to spend effort fixing the pixman build).

Hi,

cross compilation works for me with the internal pixman.
Here is an example which I use to compile Windows 64 bit
executables on Debian:

./configure' '--cross-prefix=amd64-mingw32msvc-'

Are there still problems with cross compilation in latest QEMU?

Regards,
Stefan Weil
Gerd Hoffmann - Dec. 12, 2012, 7:52 a.m.
On 12/12/12 04:18, Scott Wood wrote:
> QEMU is sometimes used in embedded contexts, where graphical support
> is unnecessary.  The ability to turn off graphics support not only
> saves some space, but it eliminates the dependency on pixman.

We have tons of hand-crafted pixel shuffeling code all over the place
which I want replace with pixman library calls.  It's a long road and
will take quite some time.

I wanna have pixman as core service in qemu for that, not some optional
add-on.

> My immediate motivation was that the QEMU-supplied pixman was being a
> pain to cross compile (especially without hacking up the generated QEMU
> makefiles to pass additional things to pixman's configure),

We pass on cross-prefix to pixman's configure, so it should
JustWork[tm].  And it actually works for windows cross builds using the
mingw toolchain.  If it doesn't work for your setup I'd much prefer to
fix that.

> and in
> general it would be nice to not have to carry around graphical baggage
> when running on hardware that doesn't even have a display (so I was more
> inclined to do this than to spend effort fixing the pixman build).

I run qemu on headless machines alot, then connect via vnc/spice ...

cheers,
  Gerd
John Spencer - Dec. 12, 2012, 4:28 p.m.
On 12/12/2012 04:18 AM, Scott Wood wrote:
> QEMU is sometimes used in embedded contexts, where graphical support
> is unnecessary.  The ability to turn off graphics support not only
> saves some space, but it eliminates the dependency on pixman.
>
> Signed-off-by: Scott Wood<scottwood@freescale.com>
> ---
> There are undoubtedly some rough edges that need to be cleaned up and
> other parts of graphics code that could be compiled out -- this is mainly
> meant to see what people think of the concept.
>
> My immediate motivation was that the QEMU-supplied pixman was being a
> pain to cross compile (especially without hacking up the generated QEMU
> makefiles to pass additional things to pixman's configure), and in
> general it would be nice to not have to carry around graphical baggage
> when running on hardware that doesn't even have a display (so I was more
> inclined to do this than to spend effort fixing the pixman build).
> ---

very nice, i hope this one makes it upstream.
it's always good to minimize external dependencies, or make them 
optional when they're unneeded in some cases.
i can imagine that qemu terminal mode is often sufficient, for example
when using rob landley's pre-built aboriginal linux system images.
Peter Maydell - Dec. 12, 2012, 4:47 p.m.
On 12 December 2012 03:18, Scott Wood <scottwood@freescale.com> wrote:
> QEMU is sometimes used in embedded contexts, where graphical support
> is unnecessary.  The ability to turn off graphics support not only
> saves some space, but it eliminates the dependency on pixman.

I would expect that we'd want to use pixman in the emulation
of graphics devices (which should be visible to the guest even
if the host doesn't have display support).

> My immediate motivation was that the QEMU-supplied pixman was being a
> pain to cross compile

Problems with cross compilation should be reported as bugs
so we can fix them -- we need to fix them anyway for the more
common case where there is host graphics support.

-- PMM
Andreas Färber - Dec. 12, 2012, 4:54 p.m.
Am 12.12.2012 17:28, schrieb John Spencer:
> On 12/12/2012 04:18 AM, Scott Wood wrote:
>> QEMU is sometimes used in embedded contexts, where graphical support
>> is unnecessary.  The ability to turn off graphics support not only
>> saves some space, but it eliminates the dependency on pixman.
>>
>> Signed-off-by: Scott Wood<scottwood@freescale.com>
>> ---
>> There are undoubtedly some rough edges that need to be cleaned up and
>> other parts of graphics code that could be compiled out -- this is mainly
>> meant to see what people think of the concept.
>>
>> My immediate motivation was that the QEMU-supplied pixman was being a
>> pain to cross compile (especially without hacking up the generated QEMU
>> makefiles to pass additional things to pixman's configure), and in
>> general it would be nice to not have to carry around graphical baggage
>> when running on hardware that doesn't even have a display (so I was more
>> inclined to do this than to spend effort fixing the pixman build).
>> ---
> 
> very nice, i hope this one makes it upstream.
> it's always good to minimize external dependencies, or make them
> optional when they're unneeded in some cases.

There is already a patch by Robert Schiele on the list, let's not
reinvent the wheel here. That part should be pretty uncontroversial.
What this patch does on top is prone to clash with a number of ongoing
refactorings so I'd rather hold that off a bit.

Andreas
Andreas Färber - Dec. 12, 2012, 5:09 p.m.
Am 12.12.2012 17:47, schrieb Peter Maydell:
> On 12 December 2012 03:18, Scott Wood <scottwood@freescale.com> wrote:
>> QEMU is sometimes used in embedded contexts, where graphical support
>> is unnecessary.  The ability to turn off graphics support not only
>> saves some space, but it eliminates the dependency on pixman.
> 
> I would expect that we'd want to use pixman in the emulation
> of graphics devices (which should be visible to the guest even
> if the host doesn't have display support).
> 
>> My immediate motivation was that the QEMU-supplied pixman was being a
>> pain to cross compile
> 
> Problems with cross compilation should be reported as bugs
> so we can fix them -- we need to fix them anyway for the more
> common case where there is host graphics support.

I already reported that the submodule does not configure on OSX/ppc
v10.5.8 - apparently due to some PKG_ macros not getting resolved. I
suspected aclocal not picking up pkg.m4 file but setting ACLOCAL_FLAGS
did not help. Do we need a more modern pkg-config version than we are
testing for?
Another issue seemed to be that our Makefile did not take into account
that I may be building with, e.g., "gcc -arch ppc64" and passing a
specific $PATH for 64-bit libraries / aclocal / pkgconfig to our configure.

The latest stable pixman configured but didn't compile on OSX/ppc due to
undefined identifiers or something. (The broken submodule version makes
it unhandy to fix this.)
This is holding up my Cocoa review of the gfx_ hook (that you haven't
jumped in to help out for v1.3) and I seriously doubt that it makes any
difference if I go through the hoops of posting the same info on
Launchpad when it Simply Works(tm) on Linux distros...

Testing on OSX/i386 v10.6 is still on my TODO list.

Andreas
Peter Maydell - Dec. 12, 2012, 5:37 p.m.
On 12 December 2012 17:09, Andreas Färber <andreas.faerber@web.de> wrote:
> I already reported that the submodule does not configure on OSX/ppc
> v10.5.8 - apparently due to some PKG_ macros not getting resolved. I
> suspected aclocal not picking up pkg.m4 file but setting ACLOCAL_FLAGS
> did not help. Do we need a more modern pkg-config version than we are
> testing for?
> Another issue seemed to be that our Makefile did not take into account
> that I may be building with, e.g., "gcc -arch ppc64" and passing a
> specific $PATH for 64-bit libraries / aclocal / pkgconfig to our configure.

Hmm. On my OSX 10.8.2 box we pick up and use a system pixman.
Forcing the internal pixman compiles, at least (haven't tested
running it since I'm remote from the box currently). But that's
just using the default C compiler and options.

> This is holding up my Cocoa review of the gfx_ hook (that you haven't
> jumped in to help out for v1.3)

Yeah, sorry. MacOSX stuff is something I do in my spare time
so it's the first to fall off the end of the queue, I'm afraid.

-- PMM
Paolo Bonzini - Dec. 12, 2012, 5:42 p.m.
Il 12/12/2012 18:09, Andreas Färber ha scritto:
>> > Problems with cross compilation should be reported as bugs
>> > so we can fix them -- we need to fix them anyway for the more
>> > common case where there is host graphics support.
> I already reported that the submodule does not configure on OSX/ppc
> v10.5.8 - apparently due to some PKG_ macros not getting resolved

Have you tried simply installing pixman from fink or macports or
homebrew (or whatever is fancy these days...)?

Paolo
Scott Wood - Dec. 13, 2012, 12:51 a.m.
On 12/12/2012 10:47:04 AM, Peter Maydell wrote:
> On 12 December 2012 03:18, Scott Wood <scottwood@freescale.com> wrote:
> > QEMU is sometimes used in embedded contexts, where graphical support
> > is unnecessary.  The ability to turn off graphics support not only
> > saves some space, but it eliminates the dependency on pixman.
> 
> I would expect that we'd want to use pixman in the emulation
> of graphics devices (which should be visible to the guest even
> if the host doesn't have display support).

And those devices would have a dependency on the QEMU graphics  
subsystem.  Not all targets have graphics devices to be emulated.

> > My immediate motivation was that the QEMU-supplied pixman was being  
> a
> > pain to cross compile
> 
> Problems with cross compilation should be reported as bugs
> so we can fix them -- we need to fix them anyway for the more
> common case where there is host graphics support.

Sure.  It wasn't meant as a long-term alternative to fixing pixman  
issues, so much as as a final nudge to do something I'd wanted to do  
before.

-Scott
Scott Wood - Dec. 13, 2012, 12:53 a.m.
On 12/12/2012 10:54:04 AM, Andreas Färber wrote:
> Am 12.12.2012 17:28, schrieb John Spencer:
> > On 12/12/2012 04:18 AM, Scott Wood wrote:
> >> QEMU is sometimes used in embedded contexts, where graphical  
> support
> >> is unnecessary.  The ability to turn off graphics support not only
> >> saves some space, but it eliminates the dependency on pixman.
> >>
> >> Signed-off-by: Scott Wood<scottwood@freescale.com>
> >> ---
> >> There are undoubtedly some rough edges that need to be cleaned up  
> and
> >> other parts of graphics code that could be compiled out -- this is  
> mainly
> >> meant to see what people think of the concept.
> >>
> >> My immediate motivation was that the QEMU-supplied pixman was  
> being a
> >> pain to cross compile (especially without hacking up the generated  
> QEMU
> >> makefiles to pass additional things to pixman's configure), and in
> >> general it would be nice to not have to carry around graphical  
> baggage
> >> when running on hardware that doesn't even have a display (so I  
> was more
> >> inclined to do this than to spend effort fixing the pixman build).
> >> ---
> >
> > very nice, i hope this one makes it upstream.
> > it's always good to minimize external dependencies, or make them
> > optional when they're unneeded in some cases.
> 
> There is already a patch by Robert Schiele on the list, let's not
> reinvent the wheel here. That part should be pretty uncontroversial.
> What this patch does on top is prone to clash with a number of ongoing
> refactorings so I'd rather hold that off a bit.

Ah, didn't notice that -- though tying it to CONFIG_USER_ONLY doesn't  
help my use case.

-Scott

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 3c7abca..360500d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -68,8 +68,11 @@  endif
 common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/
 common-obj-y += net.o net/
 common-obj-y += qom/
-common-obj-y += readline.o console.o cursor.o
-common-obj-y += qemu-pixman.o
+common-obj-y += readline.o
+common-obj-$(CONFIG_GRAPHICS) += console.o cursor.o qemu-pixman.o
+ifneq ($(CONFIG_GRAPHICS),y)
+common-obj-y += no-console.o
+endif
 common-obj-y += $(oslib-obj-y)
 common-obj-$(CONFIG_WIN32) += os-win32.o
 common-obj-$(CONFIG_POSIX) += os-posix.o
diff --git a/configure b/configure
index 38b1cc6..6cb73e6 100755
--- a/configure
+++ b/configure
@@ -223,6 +223,7 @@  libiscsi=""
 coroutine=""
 seccomp=""
 glusterfs=""
+graphics="yes"
 
 # parse CC options first
 for opt do
@@ -880,6 +881,14 @@  for opt do
   ;;
   --enable-glusterfs) glusterfs="yes"
   ;;
+  --disable-graphics)
+    graphics="no"
+    vnc="no"
+    spice="no"
+    curses="no"
+  ;;
+  --enable-graphics) graphics="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -1128,6 +1137,8 @@  echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
 echo "                           gthread, ucontext, sigaltstack, windows"
 echo "  --enable-glusterfs       enable GlusterFS backend"
 echo "  --disable-glusterfs      disable GlusterFS backend"
+echo "  --enable-graphics        enable graphics support (default)"
+echo "  --disable-graphics       disable graphics support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2126,6 +2137,14 @@  fi
 ##########################################
 # pixman support probe
 
+if test "$graphics" = "no"; then
+  pixman="not needed"
+  if test "$vnc" = "yes" -o "$spice" = "yes"; then
+    echo "ERROR: graphics disabled but vnc or spice enabled"
+    exit 1
+  fi
+fi
+
 if test "$pixman" = ""; then
   if $pkg_config --atleast-version=0.18.4 pixman-1 > /dev/null 2>&1; then
     pixman="system"
@@ -2136,7 +2155,7 @@  fi
 if test "$pixman" = "system"; then
   pixman_cflags=`$pkg_config --cflags pixman-1 2>/dev/null`
   pixman_libs=`$pkg_config --libs pixman-1 2>/dev/null`
-else
+elif test "$pixman" != "not needed"; then
   if test ! -d ${source_path}/pixman/pixman; then
     echo "ERROR: pixman not present (or older than 0.18.4). Your options:"
     echo "  (1) Preferred: Install the pixman devel package (any recent"
@@ -3257,6 +3276,7 @@  echo "build guest agent $guest_agent"
 echo "seccomp support   $seccomp"
 echo "coroutine backend $coroutine_backend"
 echo "GlusterFS support $glusterfs"
+echo "graphics          $graphics"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -3603,6 +3623,10 @@  if test "$glusterfs" = "yes" ; then
   echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
 fi
 
+if test "$graphics" = "yes" ; then
+  echo "CONFIG_GRAPHICS=y" >> $config_host_mak
+fi
+
 # USB host support
 case "$usb" in
 linux)
diff --git a/console.h b/console.h
index 50a0512..49d8469 100644
--- a/console.h
+++ b/console.h
@@ -120,8 +120,10 @@  struct PixelFormat {
 };
 
 struct DisplaySurface {
+#ifdef CONFIG_GRAPHICS
     pixman_format_code_t format;
     pixman_image_t *image;
+#endif
     uint8_t flags;
 
     struct PixelFormat pf;
@@ -340,6 +342,7 @@  static inline bool dpy_cursor_define_supported(struct DisplayState *s)
     return false;
 }
 
+#ifdef CONFIG_GRAPHICS
 static inline int ds_get_linesize(DisplayState *ds)
 {
     return pixman_image_get_stride(ds->surface->image);
@@ -401,6 +404,7 @@  static inline int ds_get_bmask(DisplayState *ds)
 {
     return ds->surface->pf.bmask;
 }
+#endif
 
 #ifdef CONFIG_CURSES
 #include <curses.h>
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index d581d8d..6297759 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -127,12 +127,14 @@  common-obj-y += sysbus.o isa-bus.o
 common-obj-y += qdev-addr.o
 
 # VGA
+ifeq ($(CONFIG_GRAPHICS), y)
 common-obj-$(CONFIG_VGA_PCI) += vga-pci.o
 common-obj-$(CONFIG_VGA_ISA) += vga-isa.o
 common-obj-$(CONFIG_VGA_ISA_MM) += vga-isa-mm.o
 common-obj-$(CONFIG_VMWARE_VGA) += vmware_vga.o
 common-obj-$(CONFIG_VMMOUSE) += vmmouse.o
 common-obj-$(CONFIG_VGA_CIRRUS) += cirrus_vga.o
+endif
 
 common-obj-$(CONFIG_RC4030) += rc4030.o
 common-obj-$(CONFIG_DP8393X) += dp8393x.o
@@ -200,7 +202,9 @@  obj-$(CONFIG_SOFTMMU) += vhost_net.o
 obj-$(CONFIG_VHOST_NET) += vhost.o
 obj-$(CONFIG_REALLY_VIRTFS) += 9pfs/
 obj-$(CONFIG_NO_PCI) += pci-stub.o
+ifeq ($(CONFIG_GRAPHICS), y)
 obj-$(CONFIG_VGA) += vga.o
+endif
 obj-$(CONFIG_SOFTMMU) += device-hotplug.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
diff --git a/no-console.c b/no-console.c
new file mode 100644
index 0000000..f4e418f
--- /dev/null
+++ b/no-console.c
@@ -0,0 +1,8 @@ 
+#include "qemu-common.h"
+#include "error.h"
+#include "qmp-commands.h"
+
+void qmp_screendump(const char *filename, Error **errp)
+{
+  error_setg(errp, "device doesn't support screendump\n");
+}
diff --git a/qemu-char.c b/qemu-char.c
index 242b799..e488e2c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2735,7 +2735,9 @@  static const struct {
     { .name = "socket",    .open = qemu_chr_open_socket },
     { .name = "udp",       .open = qemu_chr_open_udp },
     { .name = "msmouse",   .open = qemu_chr_open_msmouse },
+#ifdef CONFIG_GRAPHICS
     { .name = "vc",        .open = text_console_init },
+#endif
 #ifdef _WIN32
     { .name = "file",      .open = qemu_chr_open_win_file_out },
     { .name = "pipe",      .open = qemu_chr_open_win_pipe },
diff --git a/qemu-pixman.c b/qemu-pixman.c
index e46e180..821a525 100644
--- a/qemu-pixman.c
+++ b/qemu-pixman.c
@@ -3,6 +3,7 @@ 
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu-common.h"
 #include "qemu-pixman.h"
 
 int qemu_pixman_get_type(int rshift, int gshift, int bshift)
diff --git a/qemu-pixman.h b/qemu-pixman.h
index bee55eb..0844816 100644
--- a/qemu-pixman.h
+++ b/qemu-pixman.h
@@ -6,6 +6,8 @@ 
 #ifndef QEMU_PIXMAN_H
 #define QEMU_PIXMAN_H
 
+#ifdef CONFIG_GRAPHICS
+
 #include <pixman.h>
 
 #include "console.h"
@@ -36,4 +38,6 @@  pixman_image_t *qemu_pixman_mirror_create(pixman_format_code_t format,
                                           pixman_image_t *image);
 void qemu_pixman_image_unref(pixman_image_t *image);
 
+#endif /* CONFIG_GRAPHICS */
+
 #endif /* QEMU_PIXMAN_H */
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index adc07be..91cca0b 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -8,7 +8,9 @@  vnc-obj-y += vnc-jobs.o
 
 common-obj-y += keymaps.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
+ifeq ($(CONFIG_GRAPHICS),y)
 common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
+endif
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
diff --git a/ui/vnc.h b/ui/vnc.h
index 6141e88..60b19cd 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -41,6 +41,8 @@ 
 #include "vnc-palette.h"
 #include "vnc-enc-zrle.h"
 
+#ifdef CONFIG_VNC
+
 // #define _VNC_DEBUG 1
 
 #ifdef _VNC_DEBUG
@@ -560,4 +562,6 @@  int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);
 int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);
 void vnc_zrle_clear(VncState *vs);
 
+#endif
+
 #endif /* __QEMU_VNC_H */
diff --git a/vl.c b/vl.c
index a3ab384..5679db3 100644
--- a/vl.c
+++ b/vl.c
@@ -180,8 +180,14 @@  int main(int argc, char **argv)
 static const char *data_dir;
 const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
+
+#ifdef CONFIG_GRAPHICS
 DisplayType display_type = DT_DEFAULT;
 static int display_remote;
+#else
+DisplayType display_type = DT_NOGRAPHIC;
+#endif
+
 const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
@@ -2532,7 +2538,9 @@  int main(int argc, char **argv, char **envp)
     const char *initrd_filename;
     const char *kernel_filename, *kernel_cmdline;
     char boot_devices[33] = "cad"; /* default to HD->floppy->CD-ROM */
+#ifdef CONFIG_GRAPHICS
     DisplayState *ds;
+#endif
     int cyls, heads, secs, translation;
     QemuOpts *hda_opts = NULL, *opts, *machine_opts;
     QemuOptsList *olist;
@@ -3887,6 +3895,7 @@  int main(int argc, char **argv, char **envp)
 
     net_check_clients();
 
+#ifdef CONFIG_GRAPHICS
     /* just use the first displaystate for the moment */
     ds = get_displaystate();
 
@@ -3927,7 +3936,7 @@  int main(int argc, char **argv, char **envp)
     default:
         break;
     }
-
+#endif /* CONFIG_GRAPHICS */
     /* must be after terminal init, SDL library changes signal handlers */
     os_setup_signal_handling();
 
@@ -3954,9 +3963,10 @@  int main(int argc, char **argv, char **envp)
         qemu_spice_display_init(ds);
     }
 #endif
-
+#ifdef CONFIG_GRAPHICS
     /* display setup */
     text_consoles_set_display(ds);
+#endif
 
     if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
         exit(1);