[Spice-devel] Read data out of the Virtqueue

Alon Levy alevy at redhat.com
Tue Apr 3 00:53:34 PDT 2012


On Mon, Apr 02, 2012 at 07:44:46AM +0000, Charles.Tsai-蔡清海-研究發展部 wrote:
> Alon,
> 
> 	In spice client, the creation of the channel is based on "init->num_of_channels" that is returned from  the spice server.
> 	Please see the following  function to create the spice channel from the client
> 
> void RedClient::handle_channels(RedPeer::InMessage* message)
> {
>     SpiceMsgChannels *init = (SpiceMsgChannels *)message->data();
>     SpiceChannelId* channels = init->channels;
>     for (unsigned int i = 0; i < init->num_of_channels; i++) {
>         create_channel(channels[i].type, channels[i].id);
>     }
> }
> 
> For the printing channel, it is created and registered by function spicevmc_device_connect(char_device, SPICE_CHANNEL_PRINT); (see in reds.c file)
> Because the printing channel is registered and created in spice server lately after spice client is up, the creation of the printing channel is thus skipped by the spice client.

Two things: First, you are using the old client code base as an example.
All well and good, but if possible it's better to use spice-gtk as a
base for new features, because that's the client we are going with
forwward (or actually the client enabling library, with remote-viewer
being the preffered client).
Second, what do you mean registered after the spice client is up? If
there is some race window where the server is already listening to
clients but the printing channel is not registered, that is bad and
needs fixing, but in general the server is initialized *before* the
client is connected. The right order is
1. server channels are registered
2. server starts listening
3. client connects

#3 cannot come before #2 so in general there is no way to have the
situation you describe (unless there is a race and #1 happens after #2
and then both orders with respect to #3 are possible).

> Can you tell me how to resolve this problem based on the spice architecture? Thanks.
> 
> 
> -----Original Message-----
> From: Charles.Tsai-蔡清海-研究發展部 
> Sent: Friday, March 30, 2012 9:27 AM
> To: 'Alon Levy'
> Cc: spice-devel at lists.freedesktop.org
> Subject: RE: Read data out of the Virtqueue
> 
> Alon,
> 
> It is a bug that I modified for printing channel. BTW, can a spice channel be brought up or down based on a request from a spice client?
> The reason that I am asking for such a question is because the printing channel might be brought up based on a configuration policy. I would like to know if a spice channel can be brought up dynamically during the run time.
> 
> 
> -----Original Message-----
> From: Alon Levy [mailto:alevy at redhat.com]
> Sent: Friday, March 30, 2012 4:16 AM
> To: Charles.Tsai-蔡清海-研究發展部
> Cc: spice-devel at lists.freedesktop.org
> Subject: Re: Read data out of the Virtqueue
> 
> On Thu, Mar 29, 2012 at 09:42:32AM +0000, Charles.Tsai-蔡清海-研究發展部 wrote:
> > Alon,
> > 
> > Forget my previous mail. When I dig into the vdservice, I found there was one bug to check the overlay I/O status after calling the VirtIO write function.
> > After I fixed the bug, I can see more printing raw data inside the Qemu now. Although I still find some issues, hopefully I can fix it as I debug more codes in both spice client and spice server. Thank you for your time.
> 
> Great that you managed to progress. Can you send a patch for the vdservice issue? Is it a bug in the original or just in the one you modified for printer channel?
> 
> > 
> > -----Original Message-----
> > From: Charles.Tsai-蔡清海-研究發展部
> > Sent: Wednesday, March 28, 2012 6:07 PM
> > To: 'Alon Levy'
> > Cc: spice-devel at lists.freedesktop.org
> > Subject: Read data out of the Virtqueue
> > 
> > Alon,
> > 
> > My printer driver can write the printing raw data into virtIO driver. But I cannot see the found the printing raw data in the spice server. For the vdagent, I found the following code segment which is a callback to read the data from the vdi_port. Do I need to add a similar code to read the data from the Virtio?
> > 
> > In Qemu, I do see vmc_write is called when the printer driver writes the printing raw data into the  virtIOdevice.
> > Consequently, function "spicevmc_red_channel_send_item" should be called to send the payload to the spice client. But I did not see function "spicevmc_red_channel_send_item" is called either. It looks like the printing rawa data is still inside the VirtIO queue. What function I need to add so as to pull the data out of the VirtIO queue?
> > 
> > ======================================================================
> > ================= struct SpiceCharDeviceState 
> > vdagent_char_device_state = {
> >     .wakeup = &vdagent_char_device_wakeup, };
> > 
> > 
> > void vdagent_char_device_wakeup(SpiceCharDeviceInstance *sin) {
> >     while (read_from_vdi_port());
> > }


More information about the Spice-devel mailing list