[Spice-devel] [PATCH spice-server 3/3] record: Allocate recording file globally from reds.c
Jonathon Jongsma
jjongsma at redhat.com
Thu Mar 2 15:14:48 UTC 2017
On Thu, 2017-03-02 at 10:38 +0000, Frediano Ziglio wrote:
> Allows to use recording function for multiple purposes.
> This will allow to register multiple screen VM or recording
> additional stuff like sound.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/red-worker.c | 6 +-----
> server/reds-private.h | 2 ++
> server/reds.c | 17 +++++++++++++++++
> server/reds.h | 5 +++++
> 4 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 93cb615..326e775 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -1312,7 +1312,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> QXLDevInitInfo init_info;
> RedWorker *worker;
> Dispatcher *dispatcher;
> - const char *record_filename;
> RedsState *reds = red_qxl_get_server(qxl->st);
> RedChannel *channel;
>
> @@ -1322,10 +1321,7 @@ RedWorker* red_worker_new(QXLInstance *qxl,
> worker->core = event_loop_core;
> worker->core.main_context = g_main_context_new();
>
> - record_filename = getenv("SPICE_WORKER_RECORD_FILENAME");
> - if (record_filename) {
> - worker->record = red_record_new(record_filename);
> - }
> + worker->record = reds_get_record(reds);
> dispatcher = red_qxl_get_dispatcher(qxl);
> dispatcher_set_opaque(dispatcher, worker);
>
> diff --git a/server/reds-private.h b/server/reds-private.h
> index e7e9ad7..07b7b38 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -25,6 +25,7 @@
> #include "main-channel.h"
> #include "inputs-channel.h"
> #include "stat-file.h"
> +#include "red-record-qxl.h"
>
> #define MIGRATE_TIMEOUT (MSEC_PER_SEC * 10)
> #define MM_TIME_DELTA 400 /*ms*/
> @@ -135,6 +136,7 @@ struct RedsState {
> SpiceCoreInterfaceInternal core;
> GList *qxl_instances;
> MainDispatcher *main_dispatcher;
> + RedRecord *record;
> };
>
> #define FOREACH_QXL_INSTANCE(_reds, _iter, _qxl) \
> diff --git a/server/reds.c b/server/reds.c
> index f99dfda..9453a53 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3452,7 +3452,9 @@ static const char default_video_codecs[] =
> "spice:mjpeg;" GSTREAMER_CODECS;
> /* new interface */
> SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
> {
> + const char *record_filename;
> RedsState *reds = spice_new0(RedsState, 1);
> +
> reds->config = spice_new0(RedServerConfig, 1);
> reds->config->default_channel_security =
> SPICE_CHANNEL_SECURITY_NONE | SPICE_CHANNEL_SECURITY_SSL;
> @@ -3484,6 +3486,12 @@ SPICE_GNUC_VISIBLE SpiceServer
> *spice_server_new(void)
> reds->listen_socket = -1;
> reds->secure_listen_socket = -1;
>
> + /* This environment was in red-worker tso the "WORKER" in it.
typo: tso -> so
> + * For compatibility reason we maintain the old name */
> + record_filename = getenv("SPICE_WORKER_RECORD_FILENAME");
> + if (record_filename) {
> + reds->record = red_record_new(record_filename);
> + }
> return reds;
> }
>
> @@ -4519,3 +4527,12 @@ static RedCharDeviceVDIPort
> *red_char_device_vdi_port_new(RedsState *reds)
> "self-tokens",
> (guint64)REDS_NUM_INTERNAL_AGENT_MESSAGES,
> NULL);
> }
> +
> +RedRecord *reds_get_record(RedsState *reds)
> +{
> + if (reds->record) {
> + return red_record_ref(reds->record);
> + }
> +
> + return NULL;
> +}
I don't see reds->record unreffed anywhere.
Jonathon
> diff --git a/server/reds.h b/server/reds.h
> index 28e3444..2748102 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -101,6 +101,11 @@ SpiceCoreInterfaceInternal*
> reds_get_core_interface(RedsState *reds);
> void reds_update_client_mouse_allowed(RedsState *reds);
> MainDispatcher* reds_get_main_dispatcher(RedsState *reds);
>
> +/* Get the recording object stored in RedsState.
> + * You should free with red_record_unref.
> + */
> +struct RedRecord *reds_get_record(RedsState *reds);
> +
> /* fd watches/timers */
> SpiceWatch *reds_core_watch_add(RedsState *reds,
> int fd, int event_mask,
More information about the Spice-devel
mailing list