ui: rename misleading 'VncDisplay' variables
Normally code declares 'VncDisplay *vd' or 'VncState *vs' but there are a bunch of places which misleadingly declare 'VncDisplay *vs'. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1475163940-26094-5-git-send-email-berrange@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
		
							parent
							
								
									38e5756a61
								
							
						
					
					
						commit
						bf01c1794e
					
				
							
								
								
									
										274
									
								
								ui/vnc.c
									
									
									
									
									
								
							
							
						
						
									
										274
									
								
								ui/vnc.c
									
									
									
									
									
								
							@ -3098,17 +3098,17 @@ static gboolean vnc_listen_io(QIOChannel *ioc,
 | 
				
			|||||||
                              GIOCondition condition,
 | 
					                              GIOCondition condition,
 | 
				
			||||||
                              void *opaque)
 | 
					                              void *opaque)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs = opaque;
 | 
					    VncDisplay *vd = opaque;
 | 
				
			||||||
    QIOChannelSocket *sioc = NULL;
 | 
					    QIOChannelSocket *sioc = NULL;
 | 
				
			||||||
    Error *err = NULL;
 | 
					    Error *err = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Catch-up */
 | 
					    /* Catch-up */
 | 
				
			||||||
    graphic_hw_update(vs->dcl.con);
 | 
					    graphic_hw_update(vd->dcl.con);
 | 
				
			||||||
    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
 | 
					    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
 | 
				
			||||||
    if (sioc != NULL) {
 | 
					    if (sioc != NULL) {
 | 
				
			||||||
        qio_channel_set_delay(QIO_CHANNEL(sioc), false);
 | 
					        qio_channel_set_delay(QIO_CHANNEL(sioc), false);
 | 
				
			||||||
        vnc_connect(vs, sioc, false,
 | 
					        vnc_connect(vd, sioc, false,
 | 
				
			||||||
                    ioc != QIO_CHANNEL(vs->lsock));
 | 
					                    ioc != QIO_CHANNEL(vd->lsock));
 | 
				
			||||||
        object_unref(OBJECT(sioc));
 | 
					        object_unref(OBJECT(sioc));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* client probably closed connection before we got there */
 | 
					        /* client probably closed connection before we got there */
 | 
				
			||||||
@ -3131,106 +3131,108 @@ static const DisplayChangeListenerOps dcl_ops = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void vnc_display_init(const char *id)
 | 
					void vnc_display_init(const char *id)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs;
 | 
					    VncDisplay *vd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (vnc_display_find(id) != NULL) {
 | 
					    if (vnc_display_find(id) != NULL) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    vs = g_malloc0(sizeof(*vs));
 | 
					    vd = g_malloc0(sizeof(*vd));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vs->id = strdup(id);
 | 
					    vd->id = strdup(id);
 | 
				
			||||||
    QTAILQ_INSERT_TAIL(&vnc_displays, vs, next);
 | 
					    QTAILQ_INSERT_TAIL(&vnc_displays, vd, next);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QTAILQ_INIT(&vs->clients);
 | 
					    QTAILQ_INIT(&vd->clients);
 | 
				
			||||||
    vs->expires = TIME_MAX;
 | 
					    vd->expires = TIME_MAX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (keyboard_layout) {
 | 
					    if (keyboard_layout) {
 | 
				
			||||||
        trace_vnc_key_map_init(keyboard_layout);
 | 
					        trace_vnc_key_map_init(keyboard_layout);
 | 
				
			||||||
        vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
 | 
					        vd->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
 | 
					        vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!vs->kbd_layout)
 | 
					    if (!vd->kbd_layout) {
 | 
				
			||||||
        exit(1);
 | 
					        exit(1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
					    vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
				
			||||||
    vs->connections_limit = 32;
 | 
					    vd->connections_limit = 32;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qemu_mutex_init(&vs->mutex);
 | 
					    qemu_mutex_init(&vd->mutex);
 | 
				
			||||||
    vnc_start_worker_thread();
 | 
					    vnc_start_worker_thread();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vs->dcl.ops = &dcl_ops;
 | 
					    vd->dcl.ops = &dcl_ops;
 | 
				
			||||||
    register_displaychangelistener(&vs->dcl);
 | 
					    register_displaychangelistener(&vd->dcl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void vnc_display_close(VncDisplay *vs)
 | 
					static void vnc_display_close(VncDisplay *vd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!vs)
 | 
					    if (!vd) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    vs->is_unix = false;
 | 
					 | 
				
			||||||
    if (vs->lsock != NULL) {
 | 
					 | 
				
			||||||
        if (vs->lsock_tag) {
 | 
					 | 
				
			||||||
            g_source_remove(vs->lsock_tag);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        object_unref(OBJECT(vs->lsock));
 | 
					    vd->is_unix = false;
 | 
				
			||||||
        vs->lsock = NULL;
 | 
					    if (vd->lsock != NULL) {
 | 
				
			||||||
 | 
					        if (vd->lsock_tag) {
 | 
				
			||||||
 | 
					            g_source_remove(vd->lsock_tag);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    if (vs->lwebsock != NULL) {
 | 
					        object_unref(OBJECT(vd->lsock));
 | 
				
			||||||
        if (vs->lwebsock_tag) {
 | 
					        vd->lsock = NULL;
 | 
				
			||||||
            g_source_remove(vs->lwebsock_tag);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
        object_unref(OBJECT(vs->lwebsock));
 | 
					    if (vd->lwebsock != NULL) {
 | 
				
			||||||
        vs->lwebsock = NULL;
 | 
					        if (vd->lwebsock_tag) {
 | 
				
			||||||
 | 
					            g_source_remove(vd->lwebsock_tag);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    vs->auth = VNC_AUTH_INVALID;
 | 
					        object_unref(OBJECT(vd->lwebsock));
 | 
				
			||||||
    vs->subauth = VNC_AUTH_INVALID;
 | 
					        vd->lwebsock = NULL;
 | 
				
			||||||
    if (vs->tlscreds) {
 | 
					 | 
				
			||||||
        object_unparent(OBJECT(vs->tlscreds));
 | 
					 | 
				
			||||||
        vs->tlscreds = NULL;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    g_free(vs->tlsaclname);
 | 
					    vd->auth = VNC_AUTH_INVALID;
 | 
				
			||||||
    vs->tlsaclname = NULL;
 | 
					    vd->subauth = VNC_AUTH_INVALID;
 | 
				
			||||||
 | 
					    if (vd->tlscreds) {
 | 
				
			||||||
 | 
					        object_unparent(OBJECT(vd->tlscreds));
 | 
				
			||||||
 | 
					        vd->tlscreds = NULL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    g_free(vd->tlsaclname);
 | 
				
			||||||
 | 
					    vd->tlsaclname = NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int vnc_display_password(const char *id, const char *password)
 | 
					int vnc_display_password(const char *id, const char *password)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs = vnc_display_find(id);
 | 
					    VncDisplay *vd = vnc_display_find(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!vs) {
 | 
					    if (!vd) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (vs->auth == VNC_AUTH_NONE) {
 | 
					    if (vd->auth == VNC_AUTH_NONE) {
 | 
				
			||||||
        error_printf_unless_qmp("If you want use passwords please enable "
 | 
					        error_printf_unless_qmp("If you want use passwords please enable "
 | 
				
			||||||
                                "password auth using '-vnc ${dpy},password'.\n");
 | 
					                                "password auth using '-vnc ${dpy},password'.\n");
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_free(vs->password);
 | 
					    g_free(vd->password);
 | 
				
			||||||
    vs->password = g_strdup(password);
 | 
					    vd->password = g_strdup(password);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int vnc_display_pw_expire(const char *id, time_t expires)
 | 
					int vnc_display_pw_expire(const char *id, time_t expires)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs = vnc_display_find(id);
 | 
					    VncDisplay *vd = vnc_display_find(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!vs) {
 | 
					    if (!vd) {
 | 
				
			||||||
        return -EINVAL;
 | 
					        return -EINVAL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    vs->expires = expires;
 | 
					    vd->expires = expires;
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void vnc_display_print_local_addr(VncDisplay *vs)
 | 
					static void vnc_display_print_local_addr(VncDisplay *vd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    SocketAddress *addr;
 | 
					    SocketAddress *addr;
 | 
				
			||||||
    Error *err = NULL;
 | 
					    Error *err = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    addr = qio_channel_socket_get_local_address(vs->lsock, &err);
 | 
					    addr = qio_channel_socket_get_local_address(vd->lsock, &err);
 | 
				
			||||||
    if (!addr) {
 | 
					    if (!addr) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -3323,7 +3325,7 @@ static QemuOptsList qemu_vnc_opts = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
vnc_display_setup_auth(VncDisplay *vs,
 | 
					vnc_display_setup_auth(VncDisplay *vd,
 | 
				
			||||||
                       bool password,
 | 
					                       bool password,
 | 
				
			||||||
                       bool sasl,
 | 
					                       bool sasl,
 | 
				
			||||||
                       bool websocket,
 | 
					                       bool websocket,
 | 
				
			||||||
@ -3377,85 +3379,85 @@ vnc_display_setup_auth(VncDisplay *vs,
 | 
				
			|||||||
     * result has the same security characteristics.
 | 
					     * result has the same security characteristics.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (password) {
 | 
					    if (password) {
 | 
				
			||||||
        if (vs->tlscreds) {
 | 
					        if (vd->tlscreds) {
 | 
				
			||||||
            vs->auth = VNC_AUTH_VENCRYPT;
 | 
					            vd->auth = VNC_AUTH_VENCRYPT;
 | 
				
			||||||
            if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
					                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with x509 password auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with x509 password auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_X509VNC;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_X509VNC;
 | 
				
			||||||
            } else if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            } else if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
					                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with TLS password auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with TLS password auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_TLSVNC;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                error_setg(errp,
 | 
					                error_setg(errp,
 | 
				
			||||||
                           "Unsupported TLS cred type %s",
 | 
					                           "Unsupported TLS cred type %s",
 | 
				
			||||||
                           object_get_typename(OBJECT(vs->tlscreds)));
 | 
					                           object_get_typename(OBJECT(vd->tlscreds)));
 | 
				
			||||||
                return -1;
 | 
					                return -1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            VNC_DEBUG("Initializing VNC server with password auth\n");
 | 
					            VNC_DEBUG("Initializing VNC server with password auth\n");
 | 
				
			||||||
            vs->auth = VNC_AUTH_VNC;
 | 
					            vd->auth = VNC_AUTH_VNC;
 | 
				
			||||||
            vs->subauth = VNC_AUTH_INVALID;
 | 
					            vd->subauth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (websocket) {
 | 
					        if (websocket) {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_VNC;
 | 
					            vd->ws_auth = VNC_AUTH_VNC;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_INVALID;
 | 
					            vd->ws_auth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if (sasl) {
 | 
					    } else if (sasl) {
 | 
				
			||||||
        if (vs->tlscreds) {
 | 
					        if (vd->tlscreds) {
 | 
				
			||||||
            vs->auth = VNC_AUTH_VENCRYPT;
 | 
					            vd->auth = VNC_AUTH_VENCRYPT;
 | 
				
			||||||
            if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
					                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with x509 SASL auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with x509 SASL auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_X509SASL;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_X509SASL;
 | 
				
			||||||
            } else if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            } else if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
					                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with TLS SASL auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with TLS SASL auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_TLSSASL;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                error_setg(errp,
 | 
					                error_setg(errp,
 | 
				
			||||||
                           "Unsupported TLS cred type %s",
 | 
					                           "Unsupported TLS cred type %s",
 | 
				
			||||||
                           object_get_typename(OBJECT(vs->tlscreds)));
 | 
					                           object_get_typename(OBJECT(vd->tlscreds)));
 | 
				
			||||||
                return -1;
 | 
					                return -1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            VNC_DEBUG("Initializing VNC server with SASL auth\n");
 | 
					            VNC_DEBUG("Initializing VNC server with SASL auth\n");
 | 
				
			||||||
            vs->auth = VNC_AUTH_SASL;
 | 
					            vd->auth = VNC_AUTH_SASL;
 | 
				
			||||||
            vs->subauth = VNC_AUTH_INVALID;
 | 
					            vd->subauth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (websocket) {
 | 
					        if (websocket) {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_SASL;
 | 
					            vd->ws_auth = VNC_AUTH_SASL;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_INVALID;
 | 
					            vd->ws_auth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        if (vs->tlscreds) {
 | 
					        if (vd->tlscreds) {
 | 
				
			||||||
            vs->auth = VNC_AUTH_VENCRYPT;
 | 
					            vd->auth = VNC_AUTH_VENCRYPT;
 | 
				
			||||||
            if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
					                                    TYPE_QCRYPTO_TLS_CREDS_X509)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with x509 no auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with x509 no auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_X509NONE;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_X509NONE;
 | 
				
			||||||
            } else if (object_dynamic_cast(OBJECT(vs->tlscreds),
 | 
					            } else if (object_dynamic_cast(OBJECT(vd->tlscreds),
 | 
				
			||||||
                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
					                                           TYPE_QCRYPTO_TLS_CREDS_ANON)) {
 | 
				
			||||||
                VNC_DEBUG("Initializing VNC server with TLS no auth\n");
 | 
					                VNC_DEBUG("Initializing VNC server with TLS no auth\n");
 | 
				
			||||||
                vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE;
 | 
					                vd->subauth = VNC_AUTH_VENCRYPT_TLSNONE;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                error_setg(errp,
 | 
					                error_setg(errp,
 | 
				
			||||||
                           "Unsupported TLS cred type %s",
 | 
					                           "Unsupported TLS cred type %s",
 | 
				
			||||||
                           object_get_typename(OBJECT(vs->tlscreds)));
 | 
					                           object_get_typename(OBJECT(vd->tlscreds)));
 | 
				
			||||||
                return -1;
 | 
					                return -1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            VNC_DEBUG("Initializing VNC server with no auth\n");
 | 
					            VNC_DEBUG("Initializing VNC server with no auth\n");
 | 
				
			||||||
            vs->auth = VNC_AUTH_NONE;
 | 
					            vd->auth = VNC_AUTH_NONE;
 | 
				
			||||||
            vs->subauth = VNC_AUTH_INVALID;
 | 
					            vd->subauth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (websocket) {
 | 
					        if (websocket) {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_NONE;
 | 
					            vd->ws_auth = VNC_AUTH_NONE;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            vs->ws_auth = VNC_AUTH_INVALID;
 | 
					            vd->ws_auth = VNC_AUTH_INVALID;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
@ -3509,7 +3511,7 @@ vnc_display_create_creds(bool x509,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void vnc_display_open(const char *id, Error **errp)
 | 
					void vnc_display_open(const char *id, Error **errp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs = vnc_display_find(id);
 | 
					    VncDisplay *vd = vnc_display_find(id);
 | 
				
			||||||
    QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
 | 
					    QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
 | 
				
			||||||
    SocketAddress *saddr = NULL, *wsaddr = NULL;
 | 
					    SocketAddress *saddr = NULL, *wsaddr = NULL;
 | 
				
			||||||
    const char *share, *device_id;
 | 
					    const char *share, *device_id;
 | 
				
			||||||
@ -3529,11 +3531,11 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
    int key_delay_ms;
 | 
					    int key_delay_ms;
 | 
				
			||||||
    bool ws_enabled = false;
 | 
					    bool ws_enabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!vs) {
 | 
					    if (!vd) {
 | 
				
			||||||
        error_setg(errp, "VNC display not active");
 | 
					        error_setg(errp, "VNC display not active");
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    vnc_display_close(vs);
 | 
					    vnc_display_close(vd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!opts) {
 | 
					    if (!opts) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
@ -3674,17 +3676,17 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
                       credid);
 | 
					                       credid);
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vs->tlscreds = (QCryptoTLSCreds *)
 | 
					        vd->tlscreds = (QCryptoTLSCreds *)
 | 
				
			||||||
            object_dynamic_cast(creds,
 | 
					            object_dynamic_cast(creds,
 | 
				
			||||||
                                TYPE_QCRYPTO_TLS_CREDS);
 | 
					                                TYPE_QCRYPTO_TLS_CREDS);
 | 
				
			||||||
        if (!vs->tlscreds) {
 | 
					        if (!vd->tlscreds) {
 | 
				
			||||||
            error_setg(errp, "Object with id '%s' is not TLS credentials",
 | 
					            error_setg(errp, "Object with id '%s' is not TLS credentials",
 | 
				
			||||||
                       credid);
 | 
					                       credid);
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        object_ref(OBJECT(vs->tlscreds));
 | 
					        object_ref(OBJECT(vd->tlscreds));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (vs->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
 | 
					        if (vd->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
 | 
				
			||||||
            error_setg(errp,
 | 
					            error_setg(errp,
 | 
				
			||||||
                       "Expecting TLS credentials with a server endpoint");
 | 
					                       "Expecting TLS credentials with a server endpoint");
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
@ -3705,12 +3707,12 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
                    x509verify = true;
 | 
					                    x509verify = true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            vs->tlscreds = vnc_display_create_creds(x509,
 | 
					            vd->tlscreds = vnc_display_create_creds(x509,
 | 
				
			||||||
                                                    x509verify,
 | 
					                                                    x509verify,
 | 
				
			||||||
                                                    path,
 | 
					                                                    path,
 | 
				
			||||||
                                                    vs->id,
 | 
					                                                    vd->id,
 | 
				
			||||||
                                                    errp);
 | 
					                                                    errp);
 | 
				
			||||||
            if (!vs->tlscreds) {
 | 
					            if (!vd->tlscreds) {
 | 
				
			||||||
                goto fail;
 | 
					                goto fail;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -3720,54 +3722,54 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
    share = qemu_opt_get(opts, "share");
 | 
					    share = qemu_opt_get(opts, "share");
 | 
				
			||||||
    if (share) {
 | 
					    if (share) {
 | 
				
			||||||
        if (strcmp(share, "ignore") == 0) {
 | 
					        if (strcmp(share, "ignore") == 0) {
 | 
				
			||||||
            vs->share_policy = VNC_SHARE_POLICY_IGNORE;
 | 
					            vd->share_policy = VNC_SHARE_POLICY_IGNORE;
 | 
				
			||||||
        } else if (strcmp(share, "allow-exclusive") == 0) {
 | 
					        } else if (strcmp(share, "allow-exclusive") == 0) {
 | 
				
			||||||
            vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
					            vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
				
			||||||
        } else if (strcmp(share, "force-shared") == 0) {
 | 
					        } else if (strcmp(share, "force-shared") == 0) {
 | 
				
			||||||
            vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;
 | 
					            vd->share_policy = VNC_SHARE_POLICY_FORCE_SHARED;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            error_setg(errp, "unknown vnc share= option");
 | 
					            error_setg(errp, "unknown vnc share= option");
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
					        vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    vs->connections_limit = qemu_opt_get_number(opts, "connections", 32);
 | 
					    vd->connections_limit = qemu_opt_get_number(opts, "connections", 32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_VNC_JPEG
 | 
					#ifdef CONFIG_VNC_JPEG
 | 
				
			||||||
    vs->lossy = qemu_opt_get_bool(opts, "lossy", false);
 | 
					    vd->lossy = qemu_opt_get_bool(opts, "lossy", false);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    vs->non_adaptive = qemu_opt_get_bool(opts, "non-adaptive", false);
 | 
					    vd->non_adaptive = qemu_opt_get_bool(opts, "non-adaptive", false);
 | 
				
			||||||
    /* adaptive updates are only used with tight encoding and
 | 
					    /* adaptive updates are only used with tight encoding and
 | 
				
			||||||
     * if lossy updates are enabled so we can disable all the
 | 
					     * if lossy updates are enabled so we can disable all the
 | 
				
			||||||
     * calculations otherwise */
 | 
					     * calculations otherwise */
 | 
				
			||||||
    if (!vs->lossy) {
 | 
					    if (!vd->lossy) {
 | 
				
			||||||
        vs->non_adaptive = true;
 | 
					        vd->non_adaptive = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (acl) {
 | 
					    if (acl) {
 | 
				
			||||||
        if (strcmp(vs->id, "default") == 0) {
 | 
					        if (strcmp(vd->id, "default") == 0) {
 | 
				
			||||||
            vs->tlsaclname = g_strdup("vnc.x509dname");
 | 
					            vd->tlsaclname = g_strdup("vnc.x509dname");
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            vs->tlsaclname = g_strdup_printf("vnc.%s.x509dname", vs->id);
 | 
					            vd->tlsaclname = g_strdup_printf("vnc.%s.x509dname", vd->id);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        qemu_acl_init(vs->tlsaclname);
 | 
					        qemu_acl_init(vd->tlsaclname);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#ifdef CONFIG_VNC_SASL
 | 
					#ifdef CONFIG_VNC_SASL
 | 
				
			||||||
    if (acl && sasl) {
 | 
					    if (acl && sasl) {
 | 
				
			||||||
        char *aclname;
 | 
					        char *aclname;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (strcmp(vs->id, "default") == 0) {
 | 
					        if (strcmp(vd->id, "default") == 0) {
 | 
				
			||||||
            aclname = g_strdup("vnc.username");
 | 
					            aclname = g_strdup("vnc.username");
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            aclname = g_strdup_printf("vnc.%s.username", vs->id);
 | 
					            aclname = g_strdup_printf("vnc.%s.username", vd->id);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vs->sasl.acl = qemu_acl_init(aclname);
 | 
					        vd->sasl.acl = qemu_acl_init(aclname);
 | 
				
			||||||
        g_free(aclname);
 | 
					        g_free(aclname);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (vnc_display_setup_auth(vs, password, sasl, ws_enabled, errp) < 0) {
 | 
					    if (vnc_display_setup_auth(vd, password, sasl, ws_enabled, errp) < 0) {
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3778,8 +3780,8 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    vs->lock_key_sync = lock_key_sync;
 | 
					    vd->lock_key_sync = lock_key_sync;
 | 
				
			||||||
    vs->key_delay_ms = key_delay_ms;
 | 
					    vd->key_delay_ms = key_delay_ms;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    device_id = qemu_opt_get(opts, "display");
 | 
					    device_id = qemu_opt_get(opts, "display");
 | 
				
			||||||
    if (device_id) {
 | 
					    if (device_id) {
 | 
				
			||||||
@ -3795,57 +3797,57 @@ void vnc_display_open(const char *id, Error **errp)
 | 
				
			|||||||
        con = NULL;
 | 
					        con = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (con != vs->dcl.con) {
 | 
					    if (con != vd->dcl.con) {
 | 
				
			||||||
        unregister_displaychangelistener(&vs->dcl);
 | 
					        unregister_displaychangelistener(&vd->dcl);
 | 
				
			||||||
        vs->dcl.con = con;
 | 
					        vd->dcl.con = con;
 | 
				
			||||||
        register_displaychangelistener(&vs->dcl);
 | 
					        register_displaychangelistener(&vd->dcl);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (reverse) {
 | 
					    if (reverse) {
 | 
				
			||||||
        /* connect to viewer */
 | 
					        /* connect to viewer */
 | 
				
			||||||
        QIOChannelSocket *sioc = NULL;
 | 
					        QIOChannelSocket *sioc = NULL;
 | 
				
			||||||
        vs->lsock = NULL;
 | 
					        vd->lsock = NULL;
 | 
				
			||||||
        vs->lwebsock = NULL;
 | 
					        vd->lwebsock = NULL;
 | 
				
			||||||
        if (ws_enabled) {
 | 
					        if (ws_enabled) {
 | 
				
			||||||
            error_setg(errp, "Cannot use websockets in reverse mode");
 | 
					            error_setg(errp, "Cannot use websockets in reverse mode");
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
 | 
					        vd->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
 | 
				
			||||||
        sioc = qio_channel_socket_new();
 | 
					        sioc = qio_channel_socket_new();
 | 
				
			||||||
        if (qio_channel_socket_connect_sync(sioc, saddr, errp) < 0) {
 | 
					        if (qio_channel_socket_connect_sync(sioc, saddr, errp) < 0) {
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vnc_connect(vs, sioc, false, false);
 | 
					        vnc_connect(vd, sioc, false, false);
 | 
				
			||||||
        object_unref(OBJECT(sioc));
 | 
					        object_unref(OBJECT(sioc));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        vs->lsock = qio_channel_socket_new();
 | 
					        vd->lsock = qio_channel_socket_new();
 | 
				
			||||||
        if (qio_channel_socket_listen_sync(vs->lsock, saddr, errp) < 0) {
 | 
					        if (qio_channel_socket_listen_sync(vd->lsock, saddr, errp) < 0) {
 | 
				
			||||||
            goto fail;
 | 
					            goto fail;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vs->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
 | 
					        vd->is_unix = saddr->type == SOCKET_ADDRESS_KIND_UNIX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (ws_enabled) {
 | 
					        if (ws_enabled) {
 | 
				
			||||||
            vs->lwebsock = qio_channel_socket_new();
 | 
					            vd->lwebsock = qio_channel_socket_new();
 | 
				
			||||||
            if (qio_channel_socket_listen_sync(vs->lwebsock,
 | 
					            if (qio_channel_socket_listen_sync(vd->lwebsock,
 | 
				
			||||||
                                               wsaddr, errp) < 0) {
 | 
					                                               wsaddr, errp) < 0) {
 | 
				
			||||||
                object_unref(OBJECT(vs->lsock));
 | 
					                object_unref(OBJECT(vd->lsock));
 | 
				
			||||||
                vs->lsock = NULL;
 | 
					                vd->lsock = NULL;
 | 
				
			||||||
                goto fail;
 | 
					                goto fail;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        vs->lsock_tag = qio_channel_add_watch(
 | 
					        vd->lsock_tag = qio_channel_add_watch(
 | 
				
			||||||
            QIO_CHANNEL(vs->lsock),
 | 
					            QIO_CHANNEL(vd->lsock),
 | 
				
			||||||
            G_IO_IN, vnc_listen_io, vs, NULL);
 | 
					            G_IO_IN, vnc_listen_io, vd, NULL);
 | 
				
			||||||
        if (ws_enabled) {
 | 
					        if (ws_enabled) {
 | 
				
			||||||
            vs->lwebsock_tag = qio_channel_add_watch(
 | 
					            vd->lwebsock_tag = qio_channel_add_watch(
 | 
				
			||||||
                QIO_CHANNEL(vs->lwebsock),
 | 
					                QIO_CHANNEL(vd->lwebsock),
 | 
				
			||||||
                G_IO_IN, vnc_listen_io, vs, NULL);
 | 
					                G_IO_IN, vnc_listen_io, vd, NULL);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (show_vnc_port) {
 | 
					    if (show_vnc_port) {
 | 
				
			||||||
        vnc_display_print_local_addr(vs);
 | 
					        vnc_display_print_local_addr(vd);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qapi_free_SocketAddress(saddr);
 | 
					    qapi_free_SocketAddress(saddr);
 | 
				
			||||||
@ -3860,16 +3862,16 @@ fail:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void vnc_display_add_client(const char *id, int csock, bool skipauth)
 | 
					void vnc_display_add_client(const char *id, int csock, bool skipauth)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VncDisplay *vs = vnc_display_find(id);
 | 
					    VncDisplay *vd = vnc_display_find(id);
 | 
				
			||||||
    QIOChannelSocket *sioc;
 | 
					    QIOChannelSocket *sioc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!vs) {
 | 
					    if (!vd) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sioc = qio_channel_socket_new_fd(csock, NULL);
 | 
					    sioc = qio_channel_socket_new_fd(csock, NULL);
 | 
				
			||||||
    if (sioc) {
 | 
					    if (sioc) {
 | 
				
			||||||
        vnc_connect(vs, sioc, skipauth, false);
 | 
					        vnc_connect(vd, sioc, skipauth, false);
 | 
				
			||||||
        object_unref(OBJECT(sioc));
 | 
					        object_unref(OBJECT(sioc));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user