diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2017-02-03 17:00:13 +0100 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2017-02-03 17:23:29 +0100 |
commit | c06283df3f9eceaa9df21936511d33be8f998ce7 (patch) | |
tree | fbaf10cc8c519a49513c1d80367f5b592f4c7f80 | |
parent | efa2fe8572b0f3989e3b9be9b8e9914d192ada67 (diff) |
RedCharDeviceVDIPort: Move private data to .c filechar-device-vdi-port
Only mig_data and plug_generation are still used outside of
red-char-device-vdi-port.c, so they were moved to the public
RedCharDeviceVDIPort struct instead. All the other fields are only
accessed from red-char-device-vdi-port.c, so the whole
RedCharDeviceVDIPortPrivate struct can be moved to the .c file too to
make it opaque to the rest of the code.
-rw-r--r-- | server/red-char-device-vdi-port.c | 30 | ||||
-rw-r--r-- | server/red-char-device-vdi-port.h | 32 | ||||
-rw-r--r-- | server/reds.c | 24 |
3 files changed, 43 insertions, 43 deletions
diff --git a/server/red-char-device-vdi-port.c b/server/red-char-device-vdi-port.c index aaab6454..0d964aa2 100644 --- a/server/red-char-device-vdi-port.c +++ b/server/red-char-device-vdi-port.c @@ -26,6 +26,30 @@ #define REDS_TOKENS_TO_SEND 5 +struct RedCharDeviceVDIPortPrivate { + int client_agent_started; + + /* write to agent */ + RedCharDeviceWriteBuffer *recv_from_client_buf; + int recv_from_client_buf_pushed; + AgentMsgFilter write_filter; + + /* read from agent */ + GList *read_bufs; + uint32_t read_state; + uint32_t message_receive_len; + uint8_t *receive_pos; + uint32_t receive_len; + RedVDIReadBuf *current_read_buf; + AgentMsgFilter read_filter; + + VDIChunkHeader vdi_chunk_header; + + gboolean copypaste; /* Whether client/guest copy&paste is allowed */ + gboolean file_xfer; /* Whether client/guest file transfers are allowed */ + gboolean use_client_monitors_config; /* Whether to use client monitors config */ +}; + G_DEFINE_TYPE(RedCharDeviceVDIPort, red_char_device_vdi_port, RED_TYPE_CHAR_DEVICE) #define RED_CHAR_DEVICE_VDIPORT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RED_TYPE_CHAR_DEVICE_VDIPORT, RedCharDeviceVDIPortPrivate)) @@ -115,8 +139,8 @@ void red_char_device_vdi_port_disconnect_client(RedCharDeviceVDIPort *dev, gbool * messages read from the agent */ dev->priv->read_filter.result = AGENT_MSG_FILTER_DISCARD; dev->priv->read_filter.discard_all = TRUE; - free(dev->priv->mig_data); - dev->priv->mig_data = NULL; + free(dev->mig_data); + dev->mig_data = NULL; } static void vdi_port_read_buf_release(uint8_t *data, void *opaque) @@ -636,7 +660,7 @@ red_char_device_vdi_port_finalize(GObject *object) { RedCharDeviceVDIPort *dev = RED_CHAR_DEVICE_VDIPORT(object); - free(dev->priv->mig_data); + free(dev->mig_data); /* FIXME: need to free the RedVDIReadBuf allocated previously */ } diff --git a/server/red-char-device-vdi-port.h b/server/red-char-device-vdi-port.h index 5ae64ec2..a6a2f736 100644 --- a/server/red-char-device-vdi-port.h +++ b/server/red-char-device-vdi-port.h @@ -38,34 +38,6 @@ enum { VDI_PORT_READ_STATE_READ_DATA, }; -struct RedCharDeviceVDIPortPrivate { - uint32_t plug_generation; - int client_agent_started; - - /* write to agent */ - RedCharDeviceWriteBuffer *recv_from_client_buf; - int recv_from_client_buf_pushed; - AgentMsgFilter write_filter; - - /* read from agent */ - GList *read_bufs; - uint32_t read_state; - uint32_t message_receive_len; - uint8_t *receive_pos; - uint32_t receive_len; - RedVDIReadBuf *current_read_buf; - AgentMsgFilter read_filter; - - VDIChunkHeader vdi_chunk_header; - - SpiceMigrateDataMain *mig_data; /* storing it when migration data arrives - before agent is attached */ - - gboolean copypaste; /* Whether client/guest copy&paste is allowed */ - gboolean file_xfer; /* Whether client/guest file transfers are allowed */ - gboolean use_client_monitors_config; /* Whether to use client monitors config */ -}; - #define RED_TYPE_CHAR_DEVICE_VDIPORT red_char_device_vdi_port_get_type() #define RED_CHAR_DEVICE_VDIPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), RED_TYPE_CHAR_DEVICE_VDIPORT, RedCharDeviceVDIPort)) @@ -81,6 +53,10 @@ struct RedCharDeviceVDIPort { RedCharDevice parent; + uint32_t plug_generation; + SpiceMigrateDataMain *mig_data; /* storing it when migration data arrives + before agent is attached */ + RedCharDeviceVDIPortPrivate *priv; }; diff --git a/server/reds.c b/server/reds.c index 14130802..ad8e6efa 100644 --- a/server/reds.c +++ b/server/reds.c @@ -827,11 +827,11 @@ int reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc, if (reds_has_vdagent(reds)) { // agent was attached before migration data has arrived if (!reds_has_vdagent(reds)) { /* FIXME: DEAD CODE */ - spice_assert(agent_dev->priv->plug_generation > 0); + spice_assert(agent_dev->plug_generation > 0); main_channel_push_agent_disconnected(reds->main_channel); spice_debug("agent is no longer connected"); } else { - if (agent_dev->priv->plug_generation > 1) { + if (agent_dev->plug_generation > 1) { /* red_char_device_state_reset takes care of not making the device wait for migration data */ spice_debug("agent has been detached and reattached before receiving migration data"); main_channel_push_agent_disconnected(reds->main_channel); @@ -844,8 +844,8 @@ int reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc, } else { /* restore agent starte when the agent gets attached */ spice_debug("saving mig_data"); - spice_assert(agent_dev->priv->plug_generation == 0); - agent_dev->priv->mig_data = spice_memdup(mig_data, size); + spice_assert(agent_dev->plug_generation == 0); + agent_dev->mig_data = spice_memdup(mig_data, size); } } else { spice_debug("agent was not attached on the source host"); @@ -1177,7 +1177,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link) "client-monitors-config", reds_use_client_monitors_config(reds), NULL); red_char_device_vdi_port_set_read_discard_all(reds->agent_dev, FALSE); - reds->agent_dev->priv->plug_generation++; + reds->agent_dev->plug_generation++; } if (!mig_target) { @@ -2479,9 +2479,9 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan } red_char_device_vdi_port_set_read_discard_all(dev, FALSE); - dev->priv->plug_generation++; + dev->plug_generation++; - if (dev->priv->mig_data || + if (dev->mig_data || red_channel_is_waiting_for_migrate_data(RED_CHANNEL(reds->main_channel))) { /* Migration in progress (code is running on the destination host): * 1. Add the client to spice char device, if it was not already added. @@ -2507,12 +2507,12 @@ static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan } } - if (dev->priv->mig_data) { + if (dev->mig_data) { spice_debug("restoring dev from stored migration data"); - spice_assert(dev->priv->plug_generation == 1); - red_char_device_vdi_port_state_restore(reds->agent_dev, dev->priv->mig_data); - free(dev->priv->mig_data); - dev->priv->mig_data = NULL; + spice_assert(dev->plug_generation == 1); + red_char_device_vdi_port_state_restore(reds->agent_dev, dev->mig_data); + free(dev->mig_data); + dev->mig_data = NULL; } else { spice_debug("waiting for migration data"); |