Skip to contentSkip to conversation

vnc: wrap vnc initialization code with CONFIG_VNC

PATCH Applied Chao Peng 2 participants 2 messages Jun 16, 2016

lore
Share & tools
lore

Chao Peng

author
#0 lore raw

PATCH 1/1 vnc: wrap vnc initialization code with CONFIG_VNC

commit f8c75b2486 (vnc: Initialization stubs) removed CONFIG_VNC in vl.c code. However qemu_find_opts("vnc") is NULL when vnc is configured out. Crash will happen in qemu_opts_foreach() before stub vnc_init_func() is called. This patch add it back.

Cc Eduardo Habkost <[email protected]>

---
Note: Of course there is other ways to fix it (e.g. check against NULL).
I feel comfortable in any way.

---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +2 -0
index 45eff56..2088491 100644
@@ -4557,8 +4557,10 @@ int main(int argc, char **argv, char **envp)
     os_setup_signal_handling();
 
     /* init remote displays */
+#ifdef CONFIG_VNC
     qemu_opts_foreach(qemu_find_opts("vnc"),
                       vnc_init_func, NULL, NULL);
+#endif
     if (show_vnc_port) {
         char *ret = vnc_display_local_addr("default");
         printf("VNC server running on '%s'\n", ret);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1 Applied
#1 lore raw
Quoted 10 lines · Chao Peng

commit f8c75b2486 (vnc: Initialization stubs) removed CONFIG_VNC in vl.c code. However qemu_find_opts("vnc") is NULL when vnc is configured out. Crash will happen in qemu_opts_foreach() before stub vnc_init_func() is called. This patch add it back.

Cc Eduardo Habkost <[email protected]>

---
Note: Of course there is other ways to fix it (e.g. check against NULL).
I feel comfortable in any way.

We can apply this fix now and then consider alternative ways to avoid the #ifdef.

Applied to my machine-next branch. Thanks!

Quoted 22 lines
---
 vl.c | 2 ++
 1 file changed, 2 insertions(+)
vl.c +2 -0
index 45eff56..2088491 100644
@@ -4557,8 +4557,10 @@ int main(int argc, char **argv, char **envp)
     os_setup_signal_handling();
 
     /* init remote displays */
+#ifdef CONFIG_VNC
     qemu_opts_foreach(qemu_find_opts("vnc"),
                       vnc_init_func, NULL, NULL);
+#endif
     if (show_vnc_port) {
         char *ret = vnc_display_local_addr("default");
         printf("VNC server running on '%s'\n", ret);
Signature · 1 line
1.8.3.1
Signature · 1 line
Eduardo