1 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 Copyright (C) 2009-2015 Red Hat, Inc. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef REDS_PRIVATE_H_ 20 #define REDS_PRIVATE_H_ 21 22 #include <spice/protocol.h> 23 #include <spice/stats.h> 24 25 #include "main-dispatcher.h" 26 #include "main-channel.h" 27 #include "inputs-channel.h" 28 #include "stat-file.h" 29 #include "red-record-qxl.h" 30 #include "safe-list.hpp" 31 32 #define MIGRATE_TIMEOUT (MSEC_PER_SEC * 10) 33 #define MM_TIME_DELTA 400 /*ms*/ 34 35 typedef struct TicketAuthentication { 36 char password[SPICE_MAX_PASSWORD_LENGTH]; 37 time_t expiration_time; 38 } TicketAuthentication; 39 40 typedef struct TicketInfo { 41 RSA *rsa; 42 int rsa_size; 43 BIGNUM *bn; 44 SpiceLinkEncryptedTicket encrypted_ticket; 45 } TicketInfo; 46 47 typedef struct MonitorMode { 48 uint32_t x_res; 49 uint32_t y_res; 50 } MonitorMode; 51 52 typedef struct RedsMigPendingLink { 53 SpiceLinkMess *link_msg; 54 RedStream *stream; 55 } RedsMigPendingLink; 56 57 typedef struct RedsMigTargetClient { 58 RedClient *client; 59 GList *pending_links; 60 } RedsMigTargetClient; 61 62 typedef struct ChannelSecurityOptions ChannelSecurityOptions; 63 64 typedef struct RedSSLParameters { 65 char keyfile_password[256]; 66 char certs_file[256]; 67 char private_key_file[256]; 68 char ca_certificate_file[256]; 69 char dh_key_file[256]; 70 char ciphersuite[256]; 71 } RedSSLParameters; 72 73 typedef struct RedCharDeviceVDIPort RedCharDeviceVDIPort; 74 typedef struct RedServerConfig RedServerConfig; 75 76 struct RedsState { 77 SPICE_CXX_GLIB_ALLOCATOR 78 79 RedServerConfig *config; 80 int listen_socket; 81 int secure_listen_socket; 82 SpiceWatch *listen_watch; 83 SpiceWatch *secure_listen_watch; 84 red::shared_ptr<RedCharDeviceVDIPort> agent_dev; 85 int pending_mouse_event; 86 bool pending_device_display_info_message; 87 red::safe_list<RedClient*> clients; 88 red::shared_ptr<MainChannel> main_channel; 89 red::shared_ptr<InputsChannel> inputs_channel; 90 91 int mig_wait_connect; /* src waits for clients to establish connection to dest 92 (before migration starts) */ 93 int mig_wait_disconnect; /* src waits for clients to disconnect (after migration completes) */ 94 std::forward_list<RedClient*, red::Mallocator<RedClient*>> 95 mig_wait_disconnect_clients;/* List of RedsMigWaitDisconnectClient. Holds the clients 96 which the src waits for their disconnection */ 97 98 99 int mig_inprogress; 100 int expect_migrate; 101 int src_do_seamless_migrate; /* per migration. Updated after the migration handshake 102 between the 2 servers */ 103 int dst_do_seamless_migrate; /* per migration. Updated after the migration handshake 104 between the 2 servers */ 105 GList *mig_target_clients; 106 107 red::safe_list<red::shared_ptr<RedChannel>> channels; 108 SpiceMouseMode mouse_mode; 109 int is_client_mouse_allowed; 110 int dispatcher_allows_client_mouse; 111 MonitorMode monitor_mode; 112 SpiceTimer *mig_timer; 113 114 int vm_running; 115 red::safe_list<red::shared_ptr<RedCharDevice>> char_devices; 116 int seamless_migration_enabled; /* command line arg */ 117 118 SSL_CTX *ctx; 119 120 #ifdef RED_STATISTICS 121 RedStatFile *stat_file; 122 #endif 123 int allow_multiple_clients; 124 bool late_initialization_done; 125 126 /* Intermediate state for on going monitors config message from a single 127 * client, being passed to the guest */ 128 SpiceBuffer client_monitors_config; 129 130 int mm_time_enabled; 131 uint32_t mm_time_latency; 132 133 SpiceCharDeviceInstance *vdagent; 134 SpiceMigrateInstance *migration_interface; 135 136 SpiceCoreInterfaceInternal core; 137 red::safe_list<QXLInstance*> qxl_instances; // XXX owning 138 red::shared_ptr<MainDispatcher> main_dispatcher; 139 RedRecord *record; 140 }; 141 142 #define FOREACH_QXL_INSTANCE(_reds, _qxl) \ 143 for (auto _qxl: _reds->qxl_instances) 144 145 #endif /* REDS_PRIVATE_H_ */ 146