Re: [PATCH 5/6] spicevmc: do not use recv_device_from_client_buf sending compressed data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Hi,
> 
> On 05/17/2016 01:04 PM, Frediano Ziglio wrote:
> > Allocate buffer directly from RedCharDevice.
> > This avoids to attach a buffer to SpiceVmsState just for detaching in
> > the same function.
> > RedCharDevice already use pooling on RedCharDeviceWriteBuffer.
> >
> > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > ---
> >   server/spicevmc.c | 37 +++++++++++++++----------------------
> >   1 file changed, 15 insertions(+), 22 deletions(-)
> >
> > diff --git a/server/spicevmc.c b/server/spicevmc.c
> > index 97eb04c..0c8ba51 100644
> > --- a/server/spicevmc.c
> > +++ b/server/spicevmc.c
> > @@ -111,10 +111,6 @@ enum {
> >       RED_PIPE_ITEM_TYPE_PORT_EVENT,
> >   };
> >   
> > -static uint8_t *spicevmc_red_channel_alloc_msg_rcv_buf(RedChannelClient
> > *rcc,
> > -                                                       uint16_t type,
> > -                                                       uint32_t size);
> > -
> >   static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient
> >   *rcc,
> >                                                        uint16_t type,
> >                                                        uint32_t size,
> > @@ -338,16 +334,21 @@ static int
> > spicevmc_channel_client_handle_migrate_data(RedChannelClient *rcc,
> >       return red_char_device_restore(state->chardev, &mig_data->base);
> >   }
> >   
> > -static int try_handle_compressed_msg(RedChannelClient *rcc,
> > SpiceMsgCompressedData *compressed_data_msg)
> > +static int handle_compressed_msg(SpiceVmcState *state, RedChannelClient
> > *rcc,
> > +                                 SpiceMsgCompressedData
> > *compressed_data_msg)
> >   {
> >       /* NOTE: *decompressed is free by the char-device */
> > -    SpiceVmcState *state;
> >       uint32_t decompressed_size;
> >       uint8_t *decompressed;
> > +    RedCharDeviceWriteBuffer *write_buf;
> > +
> > +    write_buf = red_char_device_write_buffer_get(state->chardev,
> > rcc->client,
> > +
> > compressed_data_msg->uncompressed_size);
> > +    if (!write_buf) {
> > +        return FALSE;
> > +    }
> > +    decompressed = write_buf->buf;
> >   
> > -    state = spicevmc_red_channel_client_get_state(rcc);
> > -    decompressed =
> > spicevmc_red_channel_alloc_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_DATA,
> > -
> > compressed_data_msg->uncompressed_size);
> >       switch (compressed_data_msg->type) {
> >   #ifdef USE_LZ4
> >       case SPICE_DATA_COMPRESSION_TYPE_LZ4:
> > @@ -359,22 +360,16 @@ static int try_handle_compressed_msg(RedChannelClient
> > *rcc, SpiceMsgCompressedDa
> >   #endif
> >       default:
> >           spice_warning("Invalid Compression Type");
> > -
> > spicevmc_red_channel_release_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_DATA,
> > -
> > compressed_data_msg->uncompressed_size,
> > -                                                 decompressed);
> > +        red_char_device_write_buffer_release(state->chardev, &write_buf);
> 
> &write_buf should be just write_buf
> 

No, was changed quite recently to make easier not forgetting to reset the pointer.

> >           return FALSE;
> >       }
> >       if (decompressed_size != compressed_data_msg->uncompressed_size) {
> >           spice_warning("Decompression Error");
> > -        spicevmc_red_channel_release_msg_rcv_buf(rcc,
> > SPICE_MSGC_SPICEVMC_DATA,
> > -
> > compressed_data_msg->uncompressed_size,
> > -                                                 decompressed);
> > +        red_char_device_write_buffer_release(state->chardev, &write_buf);
> same
> >           return FALSE;
> >       }
> > -    spice_assert(state->recv_from_client_buf->buf == decompressed);
> > -    state->recv_from_client_buf->buf_used = decompressed_size;
> > -    red_char_device_write_buffer_add(state->chardev,
> > state->recv_from_client_buf);
> > -    state->recv_from_client_buf = NULL;
> > +    write_buf->buf_used = decompressed_size;
> > +    red_char_device_write_buffer_add(state->chardev, write_buf);
> >       return TRUE;
> >   }
> >   
> > @@ -399,9 +394,7 @@ static int
> > spicevmc_red_channel_client_handle_message_parsed(RedChannelClient *r
> >           state->recv_from_client_buf = NULL;
> >           break;
> >       case SPICE_MSGC_SPICEVMC_COMPRESSED_DATA:
> > -        if (!try_handle_compressed_msg(rcc, (SpiceMsgCompressedData*)msg))
> > {
> > -            return FALSE;
> > -        }
> > +        return handle_compressed_msg(state, rcc,
> > (SpiceMsgCompressedData*)msg);
> >           break;
> >       case SPICE_MSGC_PORT_EVENT:
> >           if (size != sizeof(uint8_t)) {
> Thanks
> 

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]