Patchwork Make VNC support optional

login
register
mail settings
Submitter Jes Sorensen
Date March 11, 2011, 12:38 p.m.
Message ID <1299847134-5854-1-git-send-email-Jes.Sorensen@redhat.com>
Download mbox | patch
Permalink /patch/86416/
State New
Headers show

Comments

Jes Sorensen - March 11, 2011, 12:38 p.m.
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 +++++++++++++++++++++++++------------
 monitor.c     |   16 ++++++++++++++++
 vl.c          |   10 +++++++++-
 4 files changed, 60 insertions(+), 22 deletions(-)
Anthony Liguori - March 11, 2011, 1:36 p.m.
On 03/11/2011 06:38 AM, Jes.Sorensen@redhat.com wrote:
> 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 +++++++++++++++++++++++++------------
>   monitor.c     |   16 ++++++++++++++++
>   vl.c          |   10 +++++++++-
>   4 files changed, 60 insertions(+), 22 deletions(-)
>
> diff --git a/Makefile.objs b/Makefile.objs
> index 9e98a66..58388e2 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_THREAD) += qemu-thread.o
> diff --git a/configure b/configure
> index 39cdf2b..a64b750 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
>     echo "CONFIG_THREAD=y">>  $config_host_mak
>   fi
> diff --git a/monitor.c b/monitor.c
> index 22ae3bb..4425315 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -441,6 +441,7 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
>           case QEVENT_RESUME:
>               event_name = "RESUME";
>               break;
> +#ifdef CONFIG_VNC
>           case QEVENT_VNC_CONNECTED:
>               event_name = "VNC_CONNECTED";
>               break;
> @@ -450,6 +451,7 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
>           case QEVENT_VNC_DISCONNECTED:
>               event_name = "VNC_DISCONNECTED";
>               break;
> +#endif

No need to if this out.

>           case QEVENT_BLOCK_IO_ERROR:
>               event_name = "BLOCK_IO_ERROR";
>               break;
> @@ -1016,6 +1018,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 +1065,7 @@ static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
>
>       return 0;
>   }
> +#endif
>
>   /**
>    * do_change(): Change a removable medium, or VNC configuration
> @@ -1073,11 +1077,15 @@ static int do_change(Monitor *mon, const QDict *qdict, QObject **ret_data)
>       const char *arg = qdict_get_try_str(qdict, "arg");
>       int ret;
>
> +#ifdef CONFIG_VNC
>       if (strcmp(device, "vnc") == 0) {
>           ret = do_change_vnc(mon, target, arg);
>       } else {
> +#endif
>           ret = do_change_block(mon, device, target, arg);
> +#ifdef CONFIG_VNC
>       }
> +#endif
>
>       return ret;
>   }

Or this stuff.

Provide a stub function for changing the VNC password and have it return 
a failure.  Then this function can check that failure and throw a proper 
QError indicating that VNC is not present.

> @@ -1119,6 +1127,7 @@ static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
>           return 0;
>       }
>
> +#ifdef CONFIG_VNC
>       if (strcmp(protocol, "vnc") == 0) {
>           if (fail_if_connected || disconnect_if_connected) {
>               /* vnc supports "connected=keep" only */
> @@ -1134,6 +1143,7 @@ static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
>           }
>           return 0;
>       }
> +#endif
>
>       qerror_report(QERR_INVALID_PARAMETER, "protocol");
>       return -1;
> @@ -1170,6 +1180,7 @@ static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
>           return 0;
>       }
>
> +#ifdef CONFIG_VNC
>       if (strcmp(protocol, "vnc") == 0) {
>           rc = vnc_display_pw_expire(NULL, when);
>           if (rc != 0) {
> @@ -1178,6 +1189,7 @@ static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
>           }
>           return 0;
>       }
> +#endif
>
>       qerror_report(QERR_INVALID_PARAMETER, "protocol");
>       return -1;
> @@ -3002,6 +3014,7 @@ static const mon_cmd_t info_cmds[] = {
>           .user_print = do_info_mice_print,
>           .mhandler.info_new = do_info_mice,
>       },
> +#ifdef CONFIG_VNC
>       {
>           .name       = "vnc",
>           .args_type  = "",
> @@ -3010,6 +3023,7 @@ static const mon_cmd_t info_cmds[] = {
>           .user_print = do_info_vnc_print,
>           .mhandler.info_new = do_info_vnc,
>       },
> +#endif

We don't want to hide commands based on compile settings.

Otherwise, looks good.

Regards,

Anthony Liguori
Jes Sorensen - March 11, 2011, 1:43 p.m.
On 03/11/11 14:36, Anthony Liguori wrote:
>> diff --git a/monitor.c b/monitor.c
>> index 22ae3bb..4425315 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -441,6 +441,7 @@ void monitor_protocol_event(MonitorEvent event,
>> QObject *data)
>>           case QEVENT_RESUME:
>>               event_name = "RESUME";
>>               break;
>> +#ifdef CONFIG_VNC
>>           case QEVENT_VNC_CONNECTED:
>>               event_name = "VNC_CONNECTED";
>>               break;
>> @@ -450,6 +451,7 @@ void monitor_protocol_event(MonitorEvent event,
>> QObject *data)
>>           case QEVENT_VNC_DISCONNECTED:
>>               event_name = "VNC_DISCONNECTED";
>>               break;
>> +#endif
> 
> No need to if this out.

I realized that, but I figured it would reduce the code a bit more. I'll
leave it in.

>> @@ -1073,11 +1077,15 @@ static int do_change(Monitor *mon, const QDict
>> *qdict, QObject **ret_data)
>>       const char *arg = qdict_get_try_str(qdict, "arg");
>>       int ret;
>>
>> +#ifdef CONFIG_VNC
>>       if (strcmp(device, "vnc") == 0) {
>>           ret = do_change_vnc(mon, target, arg);
>>       } else {
>> +#endif
>>           ret = do_change_block(mon, device, target, arg);
>> +#ifdef CONFIG_VNC
>>       }
>> +#endif
>>
>>       return ret;
>>   }
> 
> Or this stuff.
> 
> Provide a stub function for changing the VNC password and have it return
> a failure.  Then this function can check that failure and throw a proper
> QError indicating that VNC is not present.

Ok, I can do that.

>> @@ -3002,6 +3014,7 @@ static const mon_cmd_t info_cmds[] = {
>>           .user_print = do_info_mice_print,
>>           .mhandler.info_new = do_info_mice,
>>       },
>> +#ifdef CONFIG_VNC
>>       {
>>           .name       = "vnc",
>>           .args_type  = "",
>> @@ -3010,6 +3023,7 @@ static const mon_cmd_t info_cmds[] = {
>>           .user_print = do_info_vnc_print,
>>           .mhandler.info_new = do_info_vnc,
>>       },
>> +#endif
> 
> We don't want to hide commands based on compile settings.
> 
> Otherwise, looks good.

I am not sure I follow you here, you prefer to have the commands visible
even though they are disabled? There are other commands which get
disabled like this as well.

Cheers,
Jes
Anthony Liguori - March 11, 2011, 2 p.m.
On 03/11/2011 07:43 AM, Jes Sorensen wrote:
> On 03/11/11 14:36, Anthony Liguori wrote:
>>> diff --git a/monitor.c b/monitor.c
>>> index 22ae3bb..4425315 100644
>>> --- a/monitor.c
>>> +++ b/monitor.c
>>> @@ -441,6 +441,7 @@ void monitor_protocol_event(MonitorEvent event,
>>> QObject *data)
>>>            case QEVENT_RESUME:
>>>                event_name = "RESUME";
>>>                break;
>>> +#ifdef CONFIG_VNC
>>>            case QEVENT_VNC_CONNECTED:
>>>                event_name = "VNC_CONNECTED";
>>>                break;
>>> @@ -450,6 +451,7 @@ void monitor_protocol_event(MonitorEvent event,
>>> QObject *data)
>>>            case QEVENT_VNC_DISCONNECTED:
>>>                event_name = "VNC_DISCONNECTED";
>>>                break;
>>> +#endif
>> No need to if this out.
> I realized that, but I figured it would reduce the code a bit more. I'll
> leave it in.

fwiw, it's all gone in my tree so you don't need to worry about it 
sticking around :-)

> @@ -3002,6 +3014,7 @@ static const mon_cmd_t info_cmds[] = {
>>>            .user_print = do_info_mice_print,
>>>            .mhandler.info_new = do_info_mice,
>>>        },
>>> +#ifdef CONFIG_VNC
>>>        {
>>>            .name       = "vnc",
>>>            .args_type  = "",
>>> @@ -3010,6 +3023,7 @@ static const mon_cmd_t info_cmds[] = {
>>>            .user_print = do_info_vnc_print,
>>>            .mhandler.info_new = do_info_vnc,
>>>        },
>>> +#endif
>> We don't want to hide commands based on compile settings.
>>
>> Otherwise, looks good.
> I am not sure I follow you here, you prefer to have the commands visible
> even though they are disabled? There are other commands which get
> disabled like this as well.

Yeah and that's wrong and I've fixed that in my QAPI branch.

If a command is #if 0'd out, then it doesn't show up in query-commands 
and if you try to use it, it returns a CommandNotFound which is the same 
error as any garbage command would produce.

But query-commands is not just useful for feature checking, but also for 
getting the schema to generate bindings.  We have this problem with 
command line options today, there's no good way to ask QEMU for every 
possible command line option if you're trying to build tooling around it 
because it depends on how QEMU is configured.

Having the command and returning FeatureDisabled means that QEMU still 
can advertise the command's schema and a user can differentiate between 
a feature that's explicitly disabled, for instance, in RHEL for support 
concerns, and a command that this QEMU just knows nothing about.

This is nice for a GUI because you can expose a different error message 
to the user.  For CommandNotFound, you might say, "This version of QEMU 
is too old for this feature" whereas for FeatureDisabled, you would say, 
"This version of QEMU disables this feature, contact your vendor."

Regards,

Anthony Liguori

> Cheers,
> Jes
>

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 9e98a66..58388e2 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_THREAD) += qemu-thread.o
diff --git a/configure b/configure
index 39cdf2b..a64b750 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
   echo "CONFIG_THREAD=y" >> $config_host_mak
 fi
diff --git a/monitor.c b/monitor.c
index 22ae3bb..4425315 100644
--- a/monitor.c
+++ b/monitor.c
@@ -441,6 +441,7 @@  void monitor_protocol_event(MonitorEvent event, QObject *data)
         case QEVENT_RESUME:
             event_name = "RESUME";
             break;
+#ifdef CONFIG_VNC
         case QEVENT_VNC_CONNECTED:
             event_name = "VNC_CONNECTED";
             break;
@@ -450,6 +451,7 @@  void monitor_protocol_event(MonitorEvent event, QObject *data)
         case QEVENT_VNC_DISCONNECTED:
             event_name = "VNC_DISCONNECTED";
             break;
+#endif
         case QEVENT_BLOCK_IO_ERROR:
             event_name = "BLOCK_IO_ERROR";
             break;
@@ -1016,6 +1018,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 +1065,7 @@  static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
 
     return 0;
 }
+#endif
 
 /**
  * do_change(): Change a removable medium, or VNC configuration
@@ -1073,11 +1077,15 @@  static int do_change(Monitor *mon, const QDict *qdict, QObject **ret_data)
     const char *arg = qdict_get_try_str(qdict, "arg");
     int ret;
 
+#ifdef CONFIG_VNC
     if (strcmp(device, "vnc") == 0) {
         ret = do_change_vnc(mon, target, arg);
     } else {
+#endif
         ret = do_change_block(mon, device, target, arg);
+#ifdef CONFIG_VNC
     }
+#endif
 
     return ret;
 }
@@ -1119,6 +1127,7 @@  static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
         return 0;
     }
 
+#ifdef CONFIG_VNC
     if (strcmp(protocol, "vnc") == 0) {
         if (fail_if_connected || disconnect_if_connected) {
             /* vnc supports "connected=keep" only */
@@ -1134,6 +1143,7 @@  static int set_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
         }
         return 0;
     }
+#endif
 
     qerror_report(QERR_INVALID_PARAMETER, "protocol");
     return -1;
@@ -1170,6 +1180,7 @@  static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
         return 0;
     }
 
+#ifdef CONFIG_VNC
     if (strcmp(protocol, "vnc") == 0) {
         rc = vnc_display_pw_expire(NULL, when);
         if (rc != 0) {
@@ -1178,6 +1189,7 @@  static int expire_password(Monitor *mon, const QDict *qdict, QObject **ret_data)
         }
         return 0;
     }
+#endif
 
     qerror_report(QERR_INVALID_PARAMETER, "protocol");
     return -1;
@@ -3002,6 +3014,7 @@  static const mon_cmd_t info_cmds[] = {
         .user_print = do_info_mice_print,
         .mhandler.info_new = do_info_mice,
     },
+#ifdef CONFIG_VNC
     {
         .name       = "vnc",
         .args_type  = "",
@@ -3010,6 +3023,7 @@  static const mon_cmd_t info_cmds[] = {
         .user_print = do_info_vnc_print,
         .mhandler.info_new = do_info_vnc,
     },
+#endif
 #if defined(CONFIG_SPICE)
     {
         .name       = "spice",
@@ -3199,6 +3213,7 @@  static const mon_cmd_t qmp_query_cmds[] = {
         .user_print = do_info_mice_print,
         .mhandler.info_new = do_info_mice,
     },
+#ifdef CONFIG_VNC
     {
         .name       = "vnc",
         .args_type  = "",
@@ -3207,6 +3222,7 @@  static const mon_cmd_t qmp_query_cmds[] = {
         .user_print = do_info_vnc_print,
         .mhandler.info_new = do_info_vnc,
     },
+#endif
 #if defined(CONFIG_SPICE)
     {
         .name       = "spice",
diff --git a/vl.c b/vl.c
index a1faf65..08a1d72 100644
--- a/vl.c
+++ b/vl.c
@@ -208,7 +208,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 shmem_video = 0;
 int acpi_enabled = 1;
 int no_hpet = 0;
@@ -1940,7 +1942,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;
 
 #ifdef CONFIG_SIMPLE_TRACE
@@ -2585,10 +2589,12 @@  int main(int argc, char **argv, char **envp)
                     exit(1);
                 }
                 break;
+#ifdef CONFIG_VNC
 	    case QEMU_OPTION_vnc:
                 display_remote++;
 		vnc_display = optarg;
 		break;
+#endif
             case QEMU_OPTION_shmem_video:
                 shmem_video = 1;
                 break;
@@ -3049,7 +3055,7 @@  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;
 #endif
@@ -3078,6 +3084,7 @@  int main(int argc, char **argv, char **envp)
         break;
     }
 
+#ifdef CONFIG_VNC
     /* init remote displays */
     if (vnc_display) {
         vnc_display_init(ds);
@@ -3088,6 +3095,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);