/* Must be called from RedClient handling thread. */ void spicevmc_device_disconnect(SpiceCharDeviceInstance *sin) { SpiceVmcState *state; state = (SpiceVmcState *)spice_char_device_state_opaque_get(sin->st); if (state->recv_from_client_buf) { spice_char_device_write_buffer_release(state->chardev_st, state->recv_from_client_buf); } spice_char_device_state_destroy(sin->st); state->chardev_st = NULL; reds_unregister_channel(&state->channel); free(state->pipe_item); red_channel_destroy(&state->channel); }
static void spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size, uint8_t *msg) { SpiceVmcState *state; state = SPICE_CONTAINEROF(rcc->channel, SpiceVmcState, channel); switch (type) { case SPICE_MSGC_SPICEVMC_DATA: if (state->recv_from_client_buf) { /* buffer wasn't pushed to device */ spice_char_device_write_buffer_release(state->chardev_st, state->recv_from_client_buf); state->recv_from_client_buf = NULL; } break; default: free(msg); } }
static void smartcard_channel_release_msg_rcv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size, uint8_t *msg) { SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base); /* todo: only one reader is actually supported. When we fix the code to support * multiple readers, we will porbably associate different devices to * differenc channels */ if (!scc->msg_in_write_buf) { spice_assert(!scc->write_buf); free(msg); } else { SpiceCharDeviceState *dev_st; if (scc->write_buf) { /* msg hasn't been pushed to the guest */ spice_assert(scc->write_buf->buf == msg); dev_st = scc->smartcard_state ? scc->smartcard_state->chardev_st : NULL; spice_char_device_write_buffer_release(dev_st, scc->write_buf); scc->write_buf = NULL; } } }