vnc: -readconfig fixups
cover vnc: -readconfig fixups
Hi,
Series applies on top of the pending vnc pull request. Fix -writeconfig/-readconfig related fallout from the QemuOpts conversion of the vnc configuration.
cheers,
Gerd
Gerd Hoffmann (2):
vnc: set id at parse time not init time
vnc: -readconfig fix
include/ui/console.h | 1 - qmp.c | 1 - ui/vnc.c | 22 ++++++++++++---------- vl.c | 7 +++++-- 4 files changed, 17 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 vnc: set id at parse time not init time
This way the generated id will be stored in -writeconfig cfg files. Also we can make vnc_auto_assign_id() local to vnc.c.
--- include/ui/console.h | 1 - qmp.c | 1 - ui/vnc.c | 22 ++++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-)
include/ui/console.h +0 -1
@@ -335,7 +335,6 @@ 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); -void vnc_auto_assign_id (QemuOptsList *olist,QemuOpts *opts);#ifdef CONFIG_VNC int vnc_display_password (const char *id,const char *password);int vnc_display_pw_expire (const char *id,time_t expires);
qmp.c +0 -1
@@ -391,7 +391,6 @@ static void qmp_change_vnc_listen(const char *target, Error **errp)return ; } -vnc_auto_assign_id (olist, opts);vnc_display_open ("default" , errp); }
ui/vnc.c +12 -10
@@ -3687,12 +3687,7 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth)vnc_connect (vs, csock, skipauth, false); } -QemuOpts *vnc_parse_func (const char *str) -{ -return qemu_opts_parse (qemu_find_opts ("vnc" ), str,1 ); -} - -void vnc_auto_assign_id (QemuOptsList *olist,QemuOpts *opts) +static void vnc_auto_assign_id (QemuOptsList *olist,QemuOpts *opts) {int i =2 ;char *id;
@@ -3705,18 +3700,25 @@ void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts)qemu_opts_set_id (opts, id); } -int vnc_init_func (QemuOpts *opts,void *opaque) +QemuOpts *vnc_parse_func (const char *str) { -Error *local_err =NULL ;QemuOptsList *olist =qemu_find_opts ("vnc" ); -char *id = (char *)qemu_opts_id (opts); +QemuOpts *opts =qemu_opts_parse (olist, str,1 ); +const char *id =qemu_opts_id (opts);if (!id) {/* auto-assign id if not present */ vnc_auto_assign_id (olist, opts); - id = (char *)qemu_opts_id (opts); } +return opts; +} + +int vnc_init_func (QemuOpts *opts,void *opaque) +{ +Error *local_err =NULL ; +char *id = (char *)qemu_opts_id (opts); +assert (id);vnc_display_init (id);vnc_display_open (id, &local_err);if (local_err !=NULL ) {
Signature · 1 line
1.8.3.1
PATCH 2/2 vnc: -readconfig fix
In reply to Gerd HoffmannNow that -vnc goes through QemuOpts we can get vnc configuration via -readconfig too. So setting display_remote in the command line parsing code doesn't cut it any more, we must check QemuOpts instead to see whenever any vnc display is configured.
--- vl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
vl.c +5 -2
@@ -2000,7 +2000,6 @@ static DisplayType select_display(const char *p) }else if (strstart (p,"vnc" , &opts)) {#ifdef CONFIG_VNC if (*opts =='=' ) { - display_remote++;if (vnc_parse_func (opts+1 ) ==NULL ) {exit (1 ); }
@@ -3474,7 +3473,6 @@ int main(int argc, char **argv, char **envp)break ;case QEMU_OPTION_vnc:#ifdef CONFIG_VNC - display_remote++;if (vnc_parse_func (optarg) ==NULL ) {exit (1 ); }
@@ -3967,6 +3965,11 @@ int main(int argc, char **argv, char **envp) } } +#if defined(CONFIG_VNC ) +if (!QTAILQ_EMPTY (&(qemu_find_opts ("vnc" )->head))) { + display_remote++; + } +#endif if (display_type ==DT_DEFAULT && !display_remote) {#if defined(CONFIG_GTK ) display_type =DT_GTK ;
Signature · 1 line
1.8.3.1
Quoted 5 lines · Gerd Hoffmann
Hi,
Series applies on top of the pending vnc pull request. Fix -writeconfig/-readconfig related fallout from the QemuOpts conversion of the vnc configuration.
I don't like that ID "default" is special, but as long as I can't offer better ideas...