qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/7] stubs: VNC initialization stubs


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH v2 2/7] stubs: VNC initialization stubs
Date: Thu, 12 Nov 2015 17:02:13 -0200

This reduces the number of CONFIG_VNC #ifdefs in the vl.c code.

The only user-visible difference is that this will make QEMU
complain about syntax when using "-display vnc" ("VNC requires a
display argument vnc=<display>") even if CONFIG_VNC is disabled.

Signed-off-by: Eduardo Habkost <address@hidden>
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 include/ui/console.h   |  4 ++--
 stubs/Makefile.objs    |  1 +
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/vnc.c         | 22 ++++++++++++++++++++++
 vl.c                   | 15 +--------------
 5 files changed, 27 insertions(+), 16 deletions(-)
 create mode 100644 stubs/ui/Makefile.objs
 create mode 100644 stubs/ui/vnc.c

diff --git a/include/ui/console.h b/include/ui/console.h
index c249db4..30e5305 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -413,11 +413,11 @@ void vnc_display_init(const char *id);
 void vnc_display_open(const char *id, Error **errp);
 void vnc_display_add_client(const char *id, int csock, bool skipauth);
 char *vnc_display_local_addr(const char *id);
+QemuOpts *vnc_parse(const char *str, Error **errp);
+int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
 #ifdef CONFIG_VNC
 int vnc_display_password(const char *id, const char *password);
 int vnc_display_pw_expire(const char *id, time_t expires);
-QemuOpts *vnc_parse(const char *str, Error **errp);
-int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
 #else
 static inline int vnc_display_password(const char *id, const char *password)
 {
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index d7898a0..ecf06ae 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -38,3 +38,4 @@ stub-obj-y += qmp_pc_dimm_device_list.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += vhost.o
+stub-obj-y += ui/
diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
new file mode 100644
index 0000000..16ea29a
--- /dev/null
+++ b/stubs/ui/Makefile.objs
@@ -0,0 +1 @@
+stub-obj-y += vnc.o
diff --git a/stubs/ui/vnc.c b/stubs/ui/vnc.c
new file mode 100644
index 0000000..de89858
--- /dev/null
+++ b/stubs/ui/vnc.c
@@ -0,0 +1,22 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+QemuOpts *vnc_parse(const char *str, Error **errp)
+{
+    error_setg(errp, "VNC support is disabled");
+    return NULL;
+}
+
+int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+    error_setg(errp, "VNC support is disabled");
+    return -1;
+}
+
+char *vnc_display_local_addr(const char *id)
+{
+    /* This must never be called if CONFIG_VNC is disabled */
+    error_report("VNC support is disabled");
+    abort();
+}
diff --git a/vl.c b/vl.c
index bba1b0a..0558e87 100644
--- a/vl.c
+++ b/vl.c
@@ -2145,7 +2145,6 @@ static DisplayType select_display(const char *p)
         exit(1);
 #endif
     } else if (strstart(p, "vnc", &opts)) {
-#ifdef CONFIG_VNC
         if (*opts == '=') {
             Error *err = NULL;
             if (vnc_parse(opts + 1, &err) == NULL) {
@@ -2156,10 +2155,6 @@ static DisplayType select_display(const char *p)
             error_report("VNC requires a display argument vnc=<display>");
             exit(1);
         }
-#else
-        error_report("VNC support is disabled");
-        exit(1);
-#endif
     } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
         display = DT_CURSES;
@@ -2984,9 +2979,7 @@ int main(int argc, char **argv, char **envp)
     const char *qtest_log = NULL;
     const char *pid_file = NULL;
     const char *incoming = NULL;
-#ifdef CONFIG_VNC
     int show_vnc_port = 0;
-#endif
     bool defconfig = true;
     bool userconfig = true;
     const char *log_mask = NULL;
@@ -3726,17 +3719,12 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_vnc:
             {
-#ifdef CONFIG_VNC
                 Error *local_err = NULL;
 
                 if (vnc_parse(optarg, &local_err) == NULL) {
                     error_report_err(local_err);
                     exit(1);
                 }
-#else
-                error_report("VNC support is disabled");
-                exit(1);
-#endif
                 break;
             }
             case QEMU_OPTION_no_acpi:
@@ -4606,7 +4594,6 @@ int main(int argc, char **argv, char **envp)
     /* must be after terminal init, SDL library changes signal handlers */
     os_setup_signal_handling();
 
-#ifdef CONFIG_VNC
     /* init remote displays */
     qemu_opts_foreach(qemu_find_opts("vnc"),
                       vnc_init_func, NULL, NULL);
@@ -4615,7 +4602,7 @@ int main(int argc, char **argv, char **envp)
         printf("VNC server running on '%s'\n", ret);
         g_free(ret);
     }
-#endif
+
 #ifdef CONFIG_SPICE
     if (using_spice) {
         qemu_spice_display_init();
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]