[Spice-commits] 3 commits - server/reds.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 14 12:38:55 UTC 2019


 server/reds.c |   36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

New commits:
commit 818e44b5dfc9d9795fcde25bd26b76b1297093d3
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Feb 13 14:46:16 2019 +0000

    reds: Check QXL ID registering interface
    
    Avoid to register multiple interface with the same ID.
    This would result in issues as 2 channels would have the same
    (channel_type, channel_id) which must be unique.
    Qemu always allocates QXL interface with IDs starting from 0.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index fbc21f7b..2e5c69e6 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3378,6 +3378,14 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds,
         }
 
         qxl = SPICE_UPCAST(QXLInstance, sin);
+        if (qxl->id < 0) {
+            spice_warning("invalid QXL ID");
+            return -1;
+        }
+        if (reds_find_channel(reds, SPICE_CHANNEL_DISPLAY, qxl->id)) {
+            spice_warning("QXL ID already allocated");
+            return -1;
+        }
         red_qxl_init(reds, qxl);
         reds->qxl_instances = g_list_prepend(reds->qxl_instances, qxl);
 
commit d15382d9a737ce80908116044582ae888799645b
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Feb 12 22:09:48 2019 +0000

    reds: Reuse agent_dev local variable
    
    The field is only assigned in do_spice_init, surely won't change
    in the meanwhile.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index f27e28b9..fbc21f7b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -847,7 +847,7 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
             dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
             /* fall through */
         case VDI_PORT_READ_STATE_GET_BUFF: {
-            if (!(dev->priv->current_read_buf = vdi_port_get_read_buf(reds->agent_dev))) {
+            if (!(dev->priv->current_read_buf = vdi_port_get_read_buf(dev))) {
                 return NULL;
             }
             dev->priv->receive_pos = dev->priv->current_read_buf->data;
@@ -877,7 +877,7 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
             } else {
                 dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
             }
-            switch (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf)) {
+            switch (vdi_port_read_buf_process(dev, dispatch_buf)) {
             case AGENT_MSG_FILTER_OK:
                 agent_adjust_capabilities((VDAgentMessage *) dispatch_buf->data,
                                           reds->config->agent_copypaste,
@@ -1234,7 +1234,7 @@ void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf)
     spice_assert(buf == dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader));
     /* if we pushed the buffer the buffer is attached to the channel so don't free it */
     if (!dev->priv->recv_from_client_buf_pushed) {
-        red_char_device_write_buffer_release(RED_CHAR_DEVICE(reds->agent_dev),
+        red_char_device_write_buffer_release(RED_CHAR_DEVICE(dev),
                                              &dev->priv->recv_from_client_buf);
     }
     dev->priv->recv_from_client_buf = NULL;
@@ -1299,7 +1299,7 @@ void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void
     VDIChunkHeader *header;
     AgentMsgFilterResult res;
 
-    res = agent_msg_filter_process_data(&reds->agent_dev->priv->write_filter,
+    res = agent_msg_filter_process_data(&dev->priv->write_filter,
                                         message, size);
     switch (res) {
     case AGENT_MSG_FILTER_OK:
@@ -1314,8 +1314,8 @@ void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void
         return;
     }
 
-    spice_assert(reds->agent_dev->priv->recv_from_client_buf);
-    spice_assert(message == reds->agent_dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader));
+    spice_assert(dev->priv->recv_from_client_buf);
+    spice_assert(message == dev->priv->recv_from_client_buf->buf + sizeof(VDIChunkHeader));
     // TODO - start tracking agent data per channel
     header =  (VDIChunkHeader *)dev->priv->recv_from_client_buf->buf;
     header->port = VDP_CLIENT_PORT;
@@ -1323,7 +1323,7 @@ void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void
     dev->priv->recv_from_client_buf->buf_used = sizeof(VDIChunkHeader) + size;
 
     dev->priv->recv_from_client_buf_pushed = TRUE;
-    red_char_device_write_buffer_add(RED_CHAR_DEVICE(reds->agent_dev), dev->priv->recv_from_client_buf);
+    red_char_device_write_buffer_add(RED_CHAR_DEVICE(dev), dev->priv->recv_from_client_buf);
 }
 
 void reds_on_main_migrate_connected(RedsState *reds, int seamless)
@@ -1378,7 +1378,7 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc)
                     !agent_dev->priv->read_filter.msg_data_to_read);
 
         read_buf->len = read_data_len;
-        switch (vdi_port_read_buf_process(reds->agent_dev, read_buf)) {
+        switch (vdi_port_read_buf_process(agent_dev, read_buf)) {
         case AGENT_MSG_FILTER_OK:
             agent_adjust_capabilities((VDAgentMessage *)read_buf->data,
                                       reds->config->agent_copypaste,
@@ -1435,8 +1435,8 @@ void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m)
         return;
     }
 
-    red_char_device_migrate_data_marshall(RED_CHAR_DEVICE(reds->agent_dev), m);
-    spice_marshaller_add_uint8(m, reds->agent_dev->priv->client_agent_started);
+    red_char_device_migrate_data_marshall(RED_CHAR_DEVICE(agent_dev), m);
+    spice_marshaller_add_uint8(m, agent_dev->priv->client_agent_started);
 
     mig_data.agent2client.chunk_header = agent_dev->priv->vdi_chunk_header;
 
@@ -1514,7 +1514,7 @@ static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_d
             uint32_t cur_buf_size;
 
             agent_dev->priv->read_state = VDI_PORT_READ_STATE_READ_DATA;
-            agent_dev->priv->current_read_buf = vdi_port_get_read_buf(reds->agent_dev);
+            agent_dev->priv->current_read_buf = vdi_port_get_read_buf(agent_dev);
             spice_assert(agent_dev->priv->current_read_buf);
             partial_msg_header = (uint8_t *)mig_data + mig_data->agent2client.msg_header_ptr -
                 sizeof(SpiceMiniDataHeader);
commit 9fec0306f2a97603098fa4e6a73f7bfb9f311e1e
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Feb 12 22:06:07 2019 +0000

    reds: Use proper enumeration for read_state field
    
    Allows the compiler to catch some additional errors.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 306bb7c6..f27e28b9 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -224,11 +224,11 @@ typedef struct RedVDIReadBuf {
     uint8_t data[SPICE_AGENT_MAX_DATA_SIZE];
 } RedVDIReadBuf;
 
-enum {
+typedef enum {
     VDI_PORT_READ_STATE_READ_HEADER,
     VDI_PORT_READ_STATE_GET_BUFF,
     VDI_PORT_READ_STATE_READ_DATA,
-};
+} VDIPortReadStates;
 
 struct RedCharDeviceVDIPortPrivate {
     gboolean agent_attached;
@@ -242,7 +242,7 @@ struct RedCharDeviceVDIPortPrivate {
 
     /* read from agent */
     uint32_t num_read_buf;
-    uint32_t read_state;
+    VDIPortReadStates read_state;
     uint32_t message_receive_len;
     uint8_t *receive_pos;
     uint32_t receive_len;


More information about the Spice-commits mailing list