vnc.c (55cf09a02b6f86c15b41395010a2b6b7a8eda7c7) | vnc.c (85bc58520c0e43660cbbe51b9eb5022a0baafe9f) |
---|---|
1/* 2 * QEMU VNC display driver 3 * 4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> 5 * Copyright (C) 2006 Fabrice Bellard 6 * Copyright (C) 2009 Red Hat, Inc 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy --- 686 unchanged lines hidden (view full) --- 695 vs->abort = true; 696 vnc_unlock_output(vs); 697 } 698 QTAILQ_FOREACH(vs, &vd->clients, next) { 699 vnc_jobs_join(vs); 700 } 701 QTAILQ_FOREACH(vs, &vd->clients, next) { 702 vnc_lock_output(vs); | 1/* 2 * QEMU VNC display driver 3 * 4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws> 5 * Copyright (C) 2006 Fabrice Bellard 6 * Copyright (C) 2009 Red Hat, Inc 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy --- 686 unchanged lines hidden (view full) --- 695 vs->abort = true; 696 vnc_unlock_output(vs); 697 } 698 QTAILQ_FOREACH(vs, &vd->clients, next) { 699 vnc_jobs_join(vs); 700 } 701 QTAILQ_FOREACH(vs, &vd->clients, next) { 702 vnc_lock_output(vs); |
703 if (vs->update == VNC_STATE_UPDATE_NONE && 704 vs->job_update != VNC_STATE_UPDATE_NONE) { 705 /* job aborted before completion */ 706 vs->update = vs->job_update; 707 vs->job_update = VNC_STATE_UPDATE_NONE; 708 } | |
709 vs->abort = false; 710 vnc_unlock_output(vs); 711 } 712} 713 714int vnc_server_fb_stride(VncDisplay *vd) 715{ 716 return pixman_image_get_stride(vd->server); --- 297 unchanged lines hidden (view full) --- 1014{ 1015 size_t offset = 1016 vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel; 1017 1018 if (vs->audio_cap) { 1019 int bps; 1020 switch (vs->as.fmt) { 1021 default: | 703 vs->abort = false; 704 vnc_unlock_output(vs); 705 } 706} 707 708int vnc_server_fb_stride(VncDisplay *vd) 709{ 710 return pixman_image_get_stride(vd->server); --- 297 unchanged lines hidden (view full) --- 1008{ 1009 size_t offset = 1010 vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel; 1011 1012 if (vs->audio_cap) { 1013 int bps; 1014 switch (vs->as.fmt) { 1015 default: |
1022 case AUD_FMT_U8: 1023 case AUD_FMT_S8: | 1016 case AUDIO_FORMAT_U8: 1017 case AUDIO_FORMAT_S8: |
1024 bps = 1; 1025 break; | 1018 bps = 1; 1019 break; |
1026 case AUD_FMT_U16: 1027 case AUD_FMT_S16: | 1020 case AUDIO_FORMAT_U16: 1021 case AUDIO_FORMAT_S16: |
1028 bps = 2; 1029 break; | 1022 bps = 2; 1023 break; |
1030 case AUD_FMT_U32: 1031 case AUD_FMT_S32: | 1024 case AUDIO_FORMAT_U32: 1025 case AUDIO_FORMAT_S32: |
1032 bps = 4; 1033 break; 1034 } 1035 offset += vs->as.freq * bps * vs->as.nchannels; 1036 } 1037 1038 /* Put a floor of 1MB on offset, so that if we have a large pending 1039 * buffer and the display is resized to a small size & back again --- 1330 unchanged lines hidden (view full) --- 2370 break; 2371 case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE: 2372 audio_del(vs); 2373 break; 2374 case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT: 2375 if (len == 4) 2376 return 10; 2377 switch (read_u8(data, 4)) { | 1026 bps = 4; 1027 break; 1028 } 1029 offset += vs->as.freq * bps * vs->as.nchannels; 1030 } 1031 1032 /* Put a floor of 1MB on offset, so that if we have a large pending 1033 * buffer and the display is resized to a small size & back again --- 1330 unchanged lines hidden (view full) --- 2364 break; 2365 case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE: 2366 audio_del(vs); 2367 break; 2368 case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT: 2369 if (len == 4) 2370 return 10; 2371 switch (read_u8(data, 4)) { |
2378 case 0: vs->as.fmt = AUD_FMT_U8; break; 2379 case 1: vs->as.fmt = AUD_FMT_S8; break; 2380 case 2: vs->as.fmt = AUD_FMT_U16; break; 2381 case 3: vs->as.fmt = AUD_FMT_S16; break; 2382 case 4: vs->as.fmt = AUD_FMT_U32; break; 2383 case 5: vs->as.fmt = AUD_FMT_S32; break; | 2372 case 0: vs->as.fmt = AUDIO_FORMAT_U8; break; 2373 case 1: vs->as.fmt = AUDIO_FORMAT_S8; break; 2374 case 2: vs->as.fmt = AUDIO_FORMAT_U16; break; 2375 case 3: vs->as.fmt = AUDIO_FORMAT_S16; break; 2376 case 4: vs->as.fmt = AUDIO_FORMAT_U32; break; 2377 case 5: vs->as.fmt = AUDIO_FORMAT_S32; break; |
2384 default: 2385 VNC_DEBUG("Invalid audio format %d\n", read_u8(data, 4)); 2386 vnc_client_error(vs); 2387 break; 2388 } 2389 vs->as.nchannels = read_u8(data, 5); 2390 if (vs->as.nchannels != 1 && vs->as.nchannels != 2) { 2391 VNC_DEBUG("Invalid audio channel count %d\n", --- 714 unchanged lines hidden (view full) --- 3106 vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); 3107 vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); 3108 3109 vs->last_x = -1; 3110 vs->last_y = -1; 3111 3112 vs->as.freq = 44100; 3113 vs->as.nchannels = 2; | 2378 default: 2379 VNC_DEBUG("Invalid audio format %d\n", read_u8(data, 4)); 2380 vnc_client_error(vs); 2381 break; 2382 } 2383 vs->as.nchannels = read_u8(data, 5); 2384 if (vs->as.nchannels != 1 && vs->as.nchannels != 2) { 2385 VNC_DEBUG("Invalid audio channel count %d\n", --- 714 unchanged lines hidden (view full) --- 3100 vnc_qmp_event(vs, QAPI_EVENT_VNC_CONNECTED); 3101 vnc_set_share_mode(vs, VNC_SHARE_MODE_CONNECTING); 3102 3103 vs->last_x = -1; 3104 vs->last_y = -1; 3105 3106 vs->as.freq = 44100; 3107 vs->as.nchannels = 2; |
3114 vs->as.fmt = AUD_FMT_S16; | 3108 vs->as.fmt = AUDIO_FORMAT_S16; |
3115 vs->as.endianness = 0; 3116 3117 qemu_mutex_init(&vs->output_mutex); 3118 vs->bh = qemu_bh_new(vnc_jobs_bh, vs); 3119 3120 QTAILQ_INSERT_TAIL(&vd->clients, vs, next); 3121 if (first_client) { 3122 vnc_update_server_surface(vd); --- 236 unchanged lines hidden (view full) --- 3359 .type = QEMU_OPT_NUMBER, 3360 },{ 3361 .name = "sasl", 3362 .type = QEMU_OPT_BOOL, 3363 },{ 3364 .name = "acl", 3365 .type = QEMU_OPT_BOOL, 3366 },{ | 3109 vs->as.endianness = 0; 3110 3111 qemu_mutex_init(&vs->output_mutex); 3112 vs->bh = qemu_bh_new(vnc_jobs_bh, vs); 3113 3114 QTAILQ_INSERT_TAIL(&vd->clients, vs, next); 3115 if (first_client) { 3116 vnc_update_server_surface(vd); --- 236 unchanged lines hidden (view full) --- 3353 .type = QEMU_OPT_NUMBER, 3354 },{ 3355 .name = "sasl", 3356 .type = QEMU_OPT_BOOL, 3357 },{ 3358 .name = "acl", 3359 .type = QEMU_OPT_BOOL, 3360 },{ |
3367 .name = "tls-authz", 3368 .type = QEMU_OPT_STRING, 3369 },{ 3370 .name = "sasl-authz", 3371 .type = QEMU_OPT_STRING, 3372 },{ | |
3373 .name = "lossy", 3374 .type = QEMU_OPT_BOOL, 3375 },{ 3376 .name = "non-adaptive", 3377 .type = QEMU_OPT_BOOL, 3378 }, 3379 { /* end of list */ } 3380 }, --- 422 unchanged lines hidden (view full) --- 3803 size_t nsaddr, nwsaddr; 3804 const char *share, *device_id; 3805 QemuConsole *con; 3806 bool password = false; 3807 bool reverse = false; 3808 const char *credid; 3809 bool sasl = false; 3810 int acl = 0; | 3361 .name = "lossy", 3362 .type = QEMU_OPT_BOOL, 3363 },{ 3364 .name = "non-adaptive", 3365 .type = QEMU_OPT_BOOL, 3366 }, 3367 { /* end of list */ } 3368 }, --- 422 unchanged lines hidden (view full) --- 3791 size_t nsaddr, nwsaddr; 3792 const char *share, *device_id; 3793 QemuConsole *con; 3794 bool password = false; 3795 bool reverse = false; 3796 const char *credid; 3797 bool sasl = false; 3798 int acl = 0; |
3811 const char *tlsauthz; 3812 const char *saslauthz; | |
3813 int lock_key_sync = 1; 3814 int key_delay_ms; 3815 3816 if (!vd) { 3817 error_setg(errp, "VNC display not active"); 3818 return; 3819 } 3820 vnc_display_close(vd); --- 55 unchanged lines hidden (view full) --- 3876 object_ref(OBJECT(vd->tlscreds)); 3877 3878 if (vd->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { 3879 error_setg(errp, 3880 "Expecting TLS credentials with a server endpoint"); 3881 goto fail; 3882 } 3883 } | 3799 int lock_key_sync = 1; 3800 int key_delay_ms; 3801 3802 if (!vd) { 3803 error_setg(errp, "VNC display not active"); 3804 return; 3805 } 3806 vnc_display_close(vd); --- 55 unchanged lines hidden (view full) --- 3862 object_ref(OBJECT(vd->tlscreds)); 3863 3864 if (vd->tlscreds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { 3865 error_setg(errp, 3866 "Expecting TLS credentials with a server endpoint"); 3867 goto fail; 3868 } 3869 } |
3884 if (qemu_opt_get(opts, "acl")) { 3885 error_report("The 'acl' option to -vnc is deprecated. " 3886 "Please use the 'tls-authz' and 'sasl-authz' " 3887 "options instead"); 3888 } | |
3889 acl = qemu_opt_get_bool(opts, "acl", false); | 3870 acl = qemu_opt_get_bool(opts, "acl", false); |
3890 tlsauthz = qemu_opt_get(opts, "tls-authz"); 3891 if (acl && tlsauthz) { 3892 error_setg(errp, "'acl' option is mutually exclusive with the " 3893 "'tls-authz' option"); 3894 goto fail; 3895 } 3896 if (tlsauthz && !vd->tlscreds) { 3897 error_setg(errp, "'tls-authz' provided but TLS is not enabled"); 3898 goto fail; 3899 } | |
3900 | 3871 |
3901 saslauthz = qemu_opt_get(opts, "sasl-authz"); 3902 if (acl && saslauthz) { 3903 error_setg(errp, "'acl' option is mutually exclusive with the " 3904 "'sasl-authz' option"); 3905 goto fail; 3906 } 3907 if (saslauthz && !sasl) { 3908 error_setg(errp, "'sasl-authz' provided but SASL auth is not enabled"); 3909 goto fail; 3910 } 3911 | |
3912 share = qemu_opt_get(opts, "share"); 3913 if (share) { 3914 if (strcmp(share, "ignore") == 0) { 3915 vd->share_policy = VNC_SHARE_POLICY_IGNORE; 3916 } else if (strcmp(share, "allow-exclusive") == 0) { 3917 vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; 3918 } else if (strcmp(share, "force-shared") == 0) { 3919 vd->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; --- 12 unchanged lines hidden (view full) --- 3932 vd->non_adaptive = qemu_opt_get_bool(opts, "non-adaptive", false); 3933 /* adaptive updates are only used with tight encoding and 3934 * if lossy updates are enabled so we can disable all the 3935 * calculations otherwise */ 3936 if (!vd->lossy) { 3937 vd->non_adaptive = true; 3938 } 3939 | 3872 share = qemu_opt_get(opts, "share"); 3873 if (share) { 3874 if (strcmp(share, "ignore") == 0) { 3875 vd->share_policy = VNC_SHARE_POLICY_IGNORE; 3876 } else if (strcmp(share, "allow-exclusive") == 0) { 3877 vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; 3878 } else if (strcmp(share, "force-shared") == 0) { 3879 vd->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; --- 12 unchanged lines hidden (view full) --- 3892 vd->non_adaptive = qemu_opt_get_bool(opts, "non-adaptive", false); 3893 /* adaptive updates are only used with tight encoding and 3894 * if lossy updates are enabled so we can disable all the 3895 * calculations otherwise */ 3896 if (!vd->lossy) { 3897 vd->non_adaptive = true; 3898 } 3899 |
3940 if (tlsauthz) { 3941 vd->tlsauthzid = g_strdup(tlsauthz); 3942 } else if (acl) { | 3900 if (acl) { |
3943 if (strcmp(vd->id, "default") == 0) { 3944 vd->tlsauthzid = g_strdup("vnc.x509dname"); 3945 } else { 3946 vd->tlsauthzid = g_strdup_printf("vnc.%s.x509dname", vd->id); 3947 } 3948 vd->tlsauthz = QAUTHZ(qauthz_list_new(vd->tlsauthzid, 3949 QAUTHZ_LIST_POLICY_DENY, 3950 &error_abort)); 3951 } 3952#ifdef CONFIG_VNC_SASL | 3901 if (strcmp(vd->id, "default") == 0) { 3902 vd->tlsauthzid = g_strdup("vnc.x509dname"); 3903 } else { 3904 vd->tlsauthzid = g_strdup_printf("vnc.%s.x509dname", vd->id); 3905 } 3906 vd->tlsauthz = QAUTHZ(qauthz_list_new(vd->tlsauthzid, 3907 QAUTHZ_LIST_POLICY_DENY, 3908 &error_abort)); 3909 } 3910#ifdef CONFIG_VNC_SASL |
3953 if (sasl) { 3954 if (saslauthz) { 3955 vd->sasl.authzid = g_strdup(saslauthz); 3956 } else if (acl) { 3957 if (strcmp(vd->id, "default") == 0) { 3958 vd->sasl.authzid = g_strdup("vnc.username"); 3959 } else { 3960 vd->sasl.authzid = g_strdup_printf("vnc.%s.username", vd->id); 3961 } 3962 vd->sasl.authz = QAUTHZ(qauthz_list_new(vd->sasl.authzid, 3963 QAUTHZ_LIST_POLICY_DENY, 3964 &error_abort)); | 3911 if (acl && sasl) { 3912 if (strcmp(vd->id, "default") == 0) { 3913 vd->sasl.authzid = g_strdup("vnc.username"); 3914 } else { 3915 vd->sasl.authzid = g_strdup_printf("vnc.%s.username", vd->id); |
3965 } | 3916 } |
3917 vd->sasl.authz = QAUTHZ(qauthz_list_new(vd->sasl.authzid, 3918 QAUTHZ_LIST_POLICY_DENY, 3919 &error_abort)); |
|
3966 } 3967#endif 3968 3969 if (vnc_display_setup_auth(&vd->auth, &vd->subauth, 3970 vd->tlscreds, password, 3971 sasl, false, errp) < 0) { 3972 goto fail; 3973 } --- 149 unchanged lines hidden --- | 3920 } 3921#endif 3922 3923 if (vnc_display_setup_auth(&vd->auth, &vd->subauth, 3924 vd->tlscreds, password, 3925 sasl, false, errp) < 0) { 3926 goto fail; 3927 } --- 149 unchanged lines hidden --- |