red-channel: Move alloc_recv_buf and release_recv_buf to RedChannelClient

These vfuncs are more appropriate in RedChannelClient.
The buffer they allocated are related to the client stream
which is managed directly by RedChannelClient.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-02-27 21:11:21 +00:00
parent 68c3e1f51d
commit 9af182b67a
14 changed files with 188 additions and 120 deletions

View File

@ -35,11 +35,13 @@ G_DEFINE_TYPE(CommonGraphicsChannelClient, common_graphics_channel_client, RED_T
#define GRAPHICS_CHANNEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_COMMON_GRAPHICS_CHANNEL, CommonGraphicsChannelPrivate))
#define GRAPHICS_CHANNEL_CLIENT_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_COMMON_GRAPHICS_CHANNEL_CLIENT, \
CommonGraphicsChannelClientPrivate))
struct CommonGraphicsChannelPrivate
{
QXLInstance *qxl;
uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE];
int during_target_migrate; /* TRUE when the client that is associated with the channel
is during migration. Turned off when the vm is started.
The flag is used to avoid sending messages that are artifacts
@ -47,10 +49,14 @@ struct CommonGraphicsChannelPrivate
of the primary surface) */
};
struct CommonGraphicsChannelClientPrivate {
uint8_t recv_buf[CHANNEL_RECEIVE_BUF_SIZE];
};
static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
CommonGraphicsChannel *common = COMMON_GRAPHICS_CHANNEL(channel);
CommonGraphicsChannelClient *common = COMMON_GRAPHICS_CHANNEL_CLIENT(rcc);
/* SPICE_MSGC_MIGRATE_DATA is the only client message whose size is dynamic */
if (type == SPICE_MSGC_MIGRATE_DATA) {
@ -157,8 +163,6 @@ common_graphics_channel_class_init(CommonGraphicsChannelClass *klass)
object_class->set_property = common_graphics_channel_set_property;
channel_class->config_socket = common_channel_config_socket;
channel_class->alloc_recv_buf = common_alloc_recv_buf;
channel_class->release_recv_buf = common_release_recv_buf;
g_object_class_install_property(object_class,
PROP_QXL,
@ -194,9 +198,16 @@ QXLInstance* common_graphics_channel_get_qxl(CommonGraphicsChannel *self)
static void
common_graphics_channel_client_init(CommonGraphicsChannelClient *self)
{
self->priv = GRAPHICS_CHANNEL_CLIENT_PRIVATE(self);
}
static void
common_graphics_channel_client_class_init(CommonGraphicsChannelClientClass *klass)
{
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
g_type_class_add_private(klass, sizeof(CommonGraphicsChannelClientPrivate));
client_class->alloc_recv_buf = common_alloc_recv_buf;
client_class->release_recv_buf = common_release_recv_buf;
}

View File

@ -27,15 +27,51 @@ G_DEFINE_TYPE(InputsChannelClient, inputs_channel_client, RED_TYPE_CHANNEL_CLIEN
#define INPUTS_CHANNEL_CLIENT_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_INPUTS_CHANNEL_CLIENT, InputsChannelClientPrivate))
// TODO: RECEIVE_BUF_SIZE used to be the same for inputs_channel and main_channel
// since it was defined once in reds.c which contained both.
// Now that they are split we can give a more fitting value for inputs - what
// should it be?
#define REDS_AGENT_WINDOW_SIZE 10
#define REDS_NUM_INTERNAL_AGENT_MESSAGES 1
// approximate max receive message size
#define RECEIVE_BUF_SIZE \
(4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
struct InputsChannelClientPrivate
{
uint16_t motion_count;
uint8_t recv_buf[RECEIVE_BUF_SIZE];
};
static uint8_t *
inputs_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size)
{
if (size > RECEIVE_BUF_SIZE) {
spice_printerr("error: too large incoming message");
return NULL;
}
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
return icc->priv->recv_buf;
}
static void
inputs_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size, uint8_t *msg)
{
}
static void
inputs_channel_client_class_init(InputsChannelClientClass *klass)
{
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
g_type_class_add_private(klass, sizeof(InputsChannelClientPrivate));
client_class->alloc_recv_buf = inputs_channel_client_alloc_msg_rcv_buf;
client_class->release_recv_buf = inputs_channel_client_release_msg_rcv_buf;
}
static void

View File

@ -43,22 +43,10 @@
#include "migration-protocol.h"
#include "utils.h"
// TODO: RECEIVE_BUF_SIZE used to be the same for inputs_channel and main_channel
// since it was defined once in reds.c which contained both.
// Now that they are split we can give a more fitting value for inputs - what
// should it be?
#define REDS_AGENT_WINDOW_SIZE 10
#define REDS_NUM_INTERNAL_AGENT_MESSAGES 1
// approximate max receive message size
#define RECEIVE_BUF_SIZE \
(4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
struct InputsChannel
{
RedChannel parent;
uint8_t recv_buf[RECEIVE_BUF_SIZE];
VDAgentMouseState mouse_state;
int src_during_migrate;
SpiceTimer *key_modifiers_timer;
@ -153,26 +141,6 @@ const VDAgentMouseState *inputs_channel_get_mouse_state(InputsChannel *inputs)
return &inputs->mouse_state;
}
static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size)
{
InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
if (size > RECEIVE_BUF_SIZE) {
spice_printerr("error: too large incoming message");
return NULL;
}
return inputs_channel->recv_buf;
}
static void inputs_channel_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
uint8_t *msg)
{
}
#define OUTGOING_OK 0
#define OUTGOING_FAILED -1
#define OUTGOING_BLOCKED 1
@ -628,8 +596,6 @@ inputs_channel_class_init(InputsChannelClass *klass)
/* channel callbacks */
channel_class->on_disconnect = inputs_channel_on_disconnect;
channel_class->send_item = inputs_channel_send_item;
channel_class->alloc_recv_buf = inputs_channel_alloc_msg_rcv_buf;
channel_class->release_recv_buf = inputs_channel_release_msg_rcv_buf;
channel_class->handle_migrate_data = inputs_channel_handle_migrate_data;
channel_class->handle_migrate_flush_mark = inputs_channel_handle_migrate_flush_mark;
}

View File

@ -46,6 +46,10 @@ G_DEFINE_TYPE(MainChannelClient, main_channel_client, RED_TYPE_CHANNEL_CLIENT)
#define MAIN_CHANNEL_CLIENT_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE((o), TYPE_MAIN_CHANNEL_CLIENT, MainChannelClientPrivate))
// approximate max receive message size for main channel
#define MAIN_CHANNEL_RECEIVE_BUF_SIZE \
(4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
struct MainChannelClientPrivate {
uint32_t connection_id;
uint32_t ping_id;
@ -63,6 +67,7 @@ struct MainChannelClientPrivate {
int mig_wait_prev_try_seamless;
int init_sent;
int seamless_mig_dst;
uint8_t recv_buf[MAIN_CHANNEL_RECEIVE_BUF_SIZE];
};
typedef struct RedPingPipeItem {
@ -194,9 +199,37 @@ static void main_channel_client_finalize(GObject *object)
G_OBJECT_CLASS(main_channel_client_parent_class)->finalize(object);
}
static uint8_t *
main_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size)
{
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
RedChannel *channel = red_channel_client_get_channel(rcc);
return reds_get_agent_data_buffer(red_channel_get_server(channel), mcc, size);
} else if (size > sizeof(mcc->priv->recv_buf)) {
/* message too large, caller will log a message and close the connection */
return NULL;
} else {
return mcc->priv->recv_buf;
}
}
static void
main_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size, uint8_t *msg)
{
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
RedChannel *channel = red_channel_client_get_channel(rcc);
reds_release_agent_data_buffer(red_channel_get_server(channel), msg);
}
}
static void main_channel_client_class_init(MainChannelClientClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
g_type_class_add_private(klass, sizeof(MainChannelClientPrivate));
@ -205,6 +238,9 @@ static void main_channel_client_class_init(MainChannelClientClass *klass)
object_class->finalize = main_channel_client_finalize;
object_class->constructed = main_channel_client_constructed;
client_class->alloc_recv_buf = main_channel_client_alloc_msg_rcv_buf;
client_class->release_recv_buf = main_channel_client_release_msg_rcv_buf;
g_object_class_install_property(object_class,
PROP_CONNECTION_ID,
g_param_spec_uint("connection-id",

View File

@ -28,15 +28,10 @@
#include "main-channel.h"
#include "main-channel-client.h"
// approximate max receive message size for main channel
#define MAIN_CHANNEL_RECEIVE_BUF_SIZE \
(4096 + (REDS_AGENT_WINDOW_SIZE + REDS_NUM_INTERNAL_AGENT_MESSAGES) * SPICE_AGENT_MAX_DATA_SIZE)
struct MainChannel
{
RedChannel parent;
uint8_t recv_buf[MAIN_CHANNEL_RECEIVE_BUF_SIZE];
// TODO: add refs and release (afrer all clients completed migration in one way or the other?)
RedsMigSpice mig_target;
int num_clients_mig_wait;
@ -248,35 +243,6 @@ static int main_channel_handle_message(RedChannelClient *rcc, uint16_t type,
return TRUE;
}
static uint8_t *main_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
MainChannel *main_chan = MAIN_CHANNEL(channel);
MainChannelClient *mcc = MAIN_CHANNEL_CLIENT(rcc);
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
return reds_get_agent_data_buffer(red_channel_get_server(channel), mcc, size);
} else if (size > sizeof(main_chan->recv_buf)) {
/* message too large, caller will log a message and close the connection */
return NULL;
} else {
return main_chan->recv_buf;
}
}
static void main_channel_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
uint8_t *msg)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
reds_release_agent_data_buffer(red_channel_get_server(channel), msg);
}
}
static int main_channel_handle_migrate_flush_mark(RedChannelClient *rcc)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
@ -349,8 +315,6 @@ main_channel_class_init(MainChannelClass *klass)
/* channel callbacks */
channel_class->on_disconnect = main_channel_client_on_disconnect;
channel_class->send_item = main_channel_client_send_item;
channel_class->alloc_recv_buf = main_channel_alloc_msg_rcv_buf;
channel_class->release_recv_buf = main_channel_release_msg_rcv_buf;
channel_class->handle_migrate_flush_mark = main_channel_handle_migrate_flush_mark;
channel_class->handle_migrate_data = main_channel_handle_migrate_data;
}

View File

@ -363,6 +363,9 @@ static void red_channel_client_constructed(GObject *object)
{
RedChannelClient *self = RED_CHANNEL_CLIENT(object);
RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(self);
spice_assert(klass->alloc_recv_buf && klass->release_recv_buf);
self->priv->outgoing.pos = 0;
self->priv->outgoing.size = 0;
@ -1053,8 +1056,7 @@ void red_channel_client_shutdown(RedChannelClient *rcc)
static uint8_t *red_channel_client_alloc_msg_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel);
RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(rcc);
return klass->alloc_recv_buf(rcc, type, size);
}
@ -1063,8 +1065,7 @@ static void red_channel_client_release_msg_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size,
uint8_t *msg)
{
RedChannel *channel = red_channel_client_get_channel(rcc);
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(channel);
RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(rcc);
klass->release_recv_buf(rcc, type, size, msg);
}

View File

@ -168,6 +168,9 @@ struct RedChannelClient
struct RedChannelClientClass
{
GObjectClass parent_class;
uint8_t *(*alloc_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size);
void (*release_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size, uint8_t *msg);
};
#define SPICE_SERVER_ERROR spice_server_error_quark()

View File

@ -198,8 +198,7 @@ red_channel_constructed(GObject *object)
G_OBJECT_CLASS(red_channel_parent_class)->constructed(object);
spice_assert(klass->on_disconnect &&
klass->alloc_recv_buf && klass->release_recv_buf);
spice_assert(klass->on_disconnect);
spice_assert(klass->handle_migrate_data ||
!(self->priv->migration_flags & SPICE_MIGRATE_NEED_DATA_TRANSFER));
}

View File

@ -43,12 +43,8 @@ typedef struct RedChannelClient RedChannelClient;
typedef struct RedClient RedClient;
typedef struct MainChannelClient MainChannelClient;
typedef uint8_t *(*channel_alloc_msg_recv_buf_proc)(RedChannelClient *channel,
uint16_t type, uint32_t size);
typedef int (*channel_handle_message_proc)(RedChannelClient *rcc, uint16_t type,
uint32_t size, void *msg);
typedef void (*channel_release_msg_recv_buf_proc)(RedChannelClient *channel,
uint16_t type, uint32_t size, uint8_t *msg);
typedef void (*channel_disconnect_proc)(RedChannelClient *rcc);
typedef int (*channel_configure_socket_proc)(RedChannelClient *rcc);
typedef void (*channel_send_pipe_item_proc)(RedChannelClient *rcc, RedPipeItem *item);
@ -122,8 +118,6 @@ struct RedChannelClass
channel_configure_socket_proc config_socket;
channel_disconnect_proc on_disconnect;
channel_send_pipe_item_proc send_item;
channel_alloc_msg_recv_buf_proc alloc_recv_buf;
channel_release_msg_recv_buf_proc release_recv_buf;
channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark;
channel_handle_migrate_data_proc handle_migrate_data;
channel_handle_migrate_data_get_serial_proc handle_migrate_data_get_serial;

View File

@ -43,6 +43,12 @@ typedef struct RedErrorItem {
VSCMsgError error;
} RedErrorItem;
static uint8_t *
smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size);
static void
smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc, uint16_t type,
uint32_t size, uint8_t *msg);
static void smart_card_channel_client_get_property(GObject *object,
guint property_id,
GValue *value,
@ -88,6 +94,10 @@ static void smart_card_channel_client_class_init(SmartCardChannelClientClass *kl
g_type_class_add_private(klass, sizeof(SmartCardChannelClientPrivate));
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
client_class->alloc_recv_buf = smartcard_channel_client_alloc_msg_rcv_buf;
client_class->release_recv_buf = smartcard_channel_client_release_msg_rcv_buf;
object_class->get_property = smart_card_channel_client_get_property;
object_class->set_property = smart_card_channel_client_set_property;
object_class->dispose = smart_card_channel_client_dispose;
@ -119,9 +129,9 @@ SmartCardChannelClient* smartcard_channel_client_create(RedChannel *channel,
return rcc;
}
uint8_t *smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size)
static uint8_t *
smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size)
{
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);
RedClient *client = red_channel_client_get_client(rcc);
@ -152,10 +162,9 @@ uint8_t *smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
}
}
void smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
uint8_t *msg)
static void
smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size, uint8_t *msg)
{
SmartCardChannelClient *scc = SMARTCARD_CHANNEL_CLIENT(rcc);

View File

@ -60,15 +60,6 @@ SmartCardChannelClient* smartcard_channel_client_create(RedChannel *channel,
int monitor_latency,
RedChannelCapabilities *caps);
uint8_t* smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size);
void smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
uint8_t *msg);
int smartcard_channel_client_handle_migrate_flush_mark(RedChannelClient *rcc);
void smartcard_channel_client_on_disconnect(RedChannelClient *rcc);
@ -96,15 +87,6 @@ void smartcard_channel_client_set_char_device(SmartCardChannelClient *scc,
RedCharDeviceSmartcard* smartcard_channel_client_get_char_device(SmartCardChannelClient *scc);
void smartcard_channel_client_release_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size,
uint8_t *msg);
uint8_t *smartcard_channel_client_alloc_msg_rcv_buf(RedChannelClient *rcc,
uint16_t type,
uint32_t size);
G_END_DECLS
#endif /* SMARTCARD_CHANNEL_CLIENT_H__ */

View File

@ -580,8 +580,6 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
channel_class->on_disconnect = smartcard_channel_client_on_disconnect;
channel_class->send_item = smartcard_channel_send_item;
channel_class->alloc_recv_buf = smartcard_channel_client_alloc_msg_rcv_buf;
channel_class->release_recv_buf = smartcard_channel_client_release_msg_rcv_buf;
channel_class->handle_migrate_flush_mark = smartcard_channel_client_handle_migrate_flush_mark;
channel_class->handle_migrate_data = smartcard_channel_client_handle_migrate_data;

View File

@ -1333,8 +1333,6 @@ snd_channel_class_init(SndChannelClass *klass)
object_class->finalize = snd_channel_finalize;
channel_class->config_socket = snd_channel_config_socket;
channel_class->alloc_recv_buf = snd_channel_client_alloc_recv_buf;
channel_class->release_recv_buf = snd_channel_client_release_recv_buf;
channel_class->on_disconnect = snd_channel_on_disconnect;
}
@ -1484,8 +1482,12 @@ void snd_set_playback_compression(int on)
}
static void
snd_channel_client_class_init(SndChannelClientClass *self)
snd_channel_client_class_init(SndChannelClientClass *klass)
{
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
client_class->alloc_recv_buf = snd_channel_client_alloc_recv_buf;
client_class->release_recv_buf = snd_channel_client_release_recv_buf;
}
static void

View File

@ -181,6 +181,42 @@ static void red_vmc_channel_port_init(RedVmcChannelPort *self)
}
G_DEFINE_TYPE(RedVmcChannelPort, red_vmc_channel_port, RED_TYPE_VMC_CHANNEL)
#define TYPE_VMC_CHANNEL_CLIENT vmc_channel_client_get_type()
#define VMC_CHANNEL_CLIENT(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_VMC_CHANNEL_CLIENT, VmcChannelClient))
#define VMC_CHANNEL_CLIENT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), TYPE_VMC_CHANNEL_CLIENT, VmcChannelClientClass))
#define COMMON_IS_GRAPHICS_CHANNEL_CLIENT(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), TYPE_VMC_CHANNEL_CLIENT))
#define COMMON_IS_GRAPHICS_CHANNEL_CLIENT_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), TYPE_VMC_CHANNEL_CLIENT))
#define VMC_CHANNEL_CLIENT_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), TYPE_VMC_CHANNEL_CLIENT, VmcChannelClientClass))
typedef struct VmcChannelClient VmcChannelClient;
typedef struct VmcChannelClientClass VmcChannelClientClass;
typedef struct VmcChannelClientPrivate VmcChannelClientPrivate;
struct VmcChannelClient {
RedChannelClient parent;
};
struct VmcChannelClientClass {
RedChannelClientClass parent_class;
};
GType vmc_channel_client_get_type(void) G_GNUC_CONST;
G_DEFINE_TYPE(VmcChannelClient, vmc_channel_client, RED_TYPE_CHANNEL_CLIENT)
static RedChannelClient *
vmc_channel_client_create(RedChannel *channel, RedClient *client,
RedsStream *stream,
RedChannelCapabilities *caps);
static void spicevmc_connect(RedChannel *channel, RedClient *client,
RedsStream *stream, int migration,
RedChannelCapabilities *caps);
@ -733,8 +769,6 @@ red_vmc_channel_class_init(RedVmcChannelClass *klass)
channel_class->on_disconnect = spicevmc_red_channel_client_on_disconnect;
channel_class->send_item = spicevmc_red_channel_send_item;
channel_class->alloc_recv_buf = spicevmc_red_channel_alloc_msg_rcv_buf;
channel_class->release_recv_buf = spicevmc_red_channel_release_msg_rcv_buf;
channel_class->handle_migrate_flush_mark = spicevmc_channel_client_handle_migrate_flush_mark;
channel_class->handle_migrate_data = spicevmc_channel_client_handle_migrate_data;
}
@ -786,7 +820,7 @@ static void spicevmc_connect(RedChannel *channel, RedClient *client,
return;
}
rcc = red_channel_client_create(channel, client, stream, FALSE, caps);
rcc = vmc_channel_client_create(channel, client, stream, caps);
if (!rcc) {
return;
}
@ -952,3 +986,36 @@ red_char_device_spicevmc_new(SpiceCharDeviceInstance *sin,
"channel", channel,
NULL);
}
static void
vmc_channel_client_init(VmcChannelClient *self)
{
}
static void
vmc_channel_client_class_init(VmcChannelClientClass *klass)
{
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
client_class->alloc_recv_buf = spicevmc_red_channel_alloc_msg_rcv_buf;
client_class->release_recv_buf = spicevmc_red_channel_release_msg_rcv_buf;
}
static RedChannelClient *
vmc_channel_client_create(RedChannel *channel, RedClient *client,
RedsStream *stream,
RedChannelCapabilities *caps)
{
RedChannelClient *rcc;
rcc = g_initable_new(TYPE_VMC_CHANNEL_CLIENT,
NULL, NULL,
"channel", channel,
"client", client,
"stream", stream,
"monitor-latency", FALSE,
"caps", caps,
NULL);
return rcc;
}