[Spice-devel] Fwd: [PATCH 2/3] server: fix race when data arrives from guest through vdi interface

Alon Levy alevy at redhat.com
Wed Aug 25 05:21:09 PDT 2010


----- "Alexander Larsson" <alexl at redhat.com> wrote:

> On Wed, 2010-08-25 at 06:28 -0400, Alon Levy wrote:
> > ----- Forwarded Message -----
> > From: "Alon Levy" <alevy at redhat.com>
> > To: alevy at redhat.com
> > Sent: Sunday, August 22, 2010 10:28:37 PM (GMT+0200) Auto-Detected
> > Subject: [PATCH 2/3] server: fix race when data arrives from guest
> through vdi interface
> > 
> > The call chains that could lead to write_to_vdi_port from two
> threads:
> > 
> > guest paste:
> >  per cpu thread:
> >  kvm_main_loop_cpu..vmc_have_data..spice_server_vdi_port_wakeup
> >   ..write_to_vdi_port
> 
> Is this enough though?
> 
> It seems to me that read_from_vdi_port() is not threadsafe either. It
> changes some state and does not seem to have any locking or anything.

Yes, that's true. Experimentally the patch provided fixes the problems we
had, (driver stuck on read, agent crash) but you're right that read_from_vdi_port
is being called from two threads. It could be fixed by adding a notification to get
the parsing (and all state changing code) to run in the main thread, and buffering
it only in the callback from the cpu thread.


More information about the Spice-devel mailing list