[Spice-devel] spice ssl live migration

2014-10-22 Thread yao xu
Hi all!

I am using spice and ovirt(a old version).

when  I use remote-viewer with correct ssl certifacate to connect the vm ,
and then live migrate the vm to another host ,

remote-viewer is dead .I must reconnect the vm .

Can I use remote-viewer continuous when the vm is migrating?  How to
configure the ssl certificate ?

Thank you .
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] win 7 terminal recognize usb as libusbx device when exiting usb redirect

2014-10-22 Thread Uri Lublin

On 10/22/2014 04:40 AM, 陈晴 wrote:

hi, all:
environment:
terminal: win 7
guest: win 7
usb redirect: usb clerk (provided by Cody Chan)
usb device: kinston data traveller 8G
teclast 16G (use correctly)
usb harddisk (use correctly)

following is my steps to use kinston usb storage:
 1.connect usb to terminal, recognize as: mass storage device
 2.use virt-viewer to connect to guest, usb device is successfully 
redirected

 3.disconnect from guest
 4.back to terminal, usb device recognize as universal serial bus 
device whose driver is libusbx, and oemxx.inf generated in 
windows/system32/inf
(something happened in this step make win 7 to choose libusbx as its 
driver)


Hi,

Seems like a usbclerk problem == not removing the WinUSB driver upon 
client distconnect

- What are the versions of usbclerk, virt-viewer ?
- Anything interesting in usbclerk's log (try at 
c:\windows\temp\usbclerk.log) ?
- Older versions of usbclerk did not remove the driver upon client 
disconnect, can
  you try un-redirect the usb device (from the remote-viewer menu) 
before disconnecting the client ?


Uri
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] Fwd: a question about Xspice

2014-10-22 Thread Hans de Goede
Hi,

Forwarding this to you guys from the xorg-devel list.

Regards,

Hans



 Forwarded Message 
Subject: a question about Xspice
Date: Tue, 21 Oct 2014 17:30:54 +0800 (CST)
From: cynthia cynthia_...@163.com
To: xorg-de...@lists.x.org, x...@lists.x.org

HI All,


  I am trying to build Xspice which is included in guest QXL driver, but one 
question confuses me a lot. As the Xspice's description in Readme, i get that 
Xspice is a X server and spice server in one, running in guest os, but our team 
has developed a set of windows virtual desktop in which the spiceserver is 
deployed in HOST os linked with QEMU, and i think that is coordinated with the 
spice protocol.,
  So, could anyone explain it for me if spiceserver is deployed in guest os or 
host os? I will be very very appreciated~



Best Regards
Cynthia

___
xorg-de...@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] Fwd: a question about Xspice

2014-10-22 Thread Alon Levy
On 10/22/2014 11:37 AM, Hans de Goede wrote:
 Hi,
 
 Forwarding this to you guys from the xorg-devel list.
 
 Regards,
 
 Hans
 
 
 
  Forwarded Message 
 Subject: a question about Xspice
 Date: Tue, 21 Oct 2014 17:30:54 +0800 (CST)
 From: cynthia cynthia_...@163.com
 To: xorg-de...@lists.x.org, x...@lists.x.org
 
 HI All,
 
 
   I am trying to build Xspice which is included in guest QXL driver, but one 
 question confuses me a lot. As the Xspice's description in Readme, i get that 
 Xspice is a X server and spice server in one, running in guest os, but our 
 team has developed a set of windows virtual desktop in which the spiceserver 
 is deployed in HOST os linked with QEMU, and i think that is coordinated with 
 the spice protocol.,
   So, could anyone explain it for me if spiceserver is deployed in guest os 
 or host os? I will be very very appreciated~

For your virtual machines spice server is running in the host, i.e. in
each qemu process.

For Xspice the spice server is Xspice - it's a different configuration,
there is no virtual machine, no host/guest distinction. Wherever Xspice
is running, there the server is.

 
 
 
 Best Regards
 Cynthia
 
 
 
 ___
 Spice-devel mailing list
 Spice-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/spice-devel
 

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] Fwd: a question about Xspice

2014-10-22 Thread Uri Lublin

On 10/22/2014 11:37 AM, Hans de Goede wrote:

Hi,

Forwarding this to you guys from the xorg-devel list.

Regards,

Hans



 Forwarded Message 
Subject: a question about Xspice
Date: Tue, 21 Oct 2014 17:30:54 +0800 (CST)
From: cynthia cynthia_...@163.com
To: xorg-de...@lists.x.org, x...@lists.x.org

HI All,


   I am trying to build Xspice which is included in guest QXL driver, but one 
question confuses me a lot. As the Xspice's description in Readme, i get that 
Xspice is a X server and spice server in one, running in guest os, but our team 
has developed a set of windows virtual desktop in which the spiceserver is 
deployed in HOST os linked with QEMU, and i think that is coordinated with the 
spice protocol.,
   So, could anyone explain it for me if spiceserver is deployed in guest os or 
host os? I will be very very appreciated~



Hi Cynthia,

Xspice was developed with the (Linux) server/host in mind, not the guest.
Running on a server, it enable remote access to a physical machine using 
Spice.


Of course, it can instead run on the guest, but that was not its purpose.
We already had a solution for the guest that uses Spice, as you've 
mentioned.


Hope that helps,
Uri.

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] spice ssl live migration

2014-10-22 Thread David Jaša
Hi,

On St, 2014-10-22 at 12:03 +0800, yao xu wrote:
 Hi all!
 
 
 I am using spice and ovirt(a old version). 
 
 
 when  I use remote-viewer with correct ssl certifacate to connect the
 vm , and then live migrate the vm to another host ,

The certificates for both hosts have to be issued by the same CA.

 
 
 remote-viewer is dead .I must reconnect the vm .
 
 
 Can I use remote-viewer continuous when the vm is migrating?  How to
 configure the ssl certificate ?

Yes, you can. Configuration may be different based on the way you launch
the VMs: e.g. when you use oVirt/RHEV, it will take care of correct TLS
setup automatically. Libvirt can do most of the tasks for you but you
still have to set up certificates correctly yourself and when you use
plain qemu, you have to feed correct configuration even to qemu monitor.

So: how do you manage your VMs?

David

 
 
 Thank you .
 ___
 Spice-devel mailing list
 Spice-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/spice-devel


___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH xf86-video-qxl v2] Revise the XSpice audio processing to avoid the use of pthreads.

2014-10-22 Thread Christophe Fergeau
Hey,

There are a bunch of calloc/malloc throughout the patch with no check
for a NULL return, would be nice to add that.
This also adds inotify monitoring, do we need to add a check for it to
configure.ac? (eg a check for sys/inotify.h)

One small note below for a typo, looks good to me apart from this.

Christophe

On Tue, Oct 21, 2014 at 04:00:08PM -0500, Jeremy White wrote:
 The initial implementation used a separate thread to drive the audio
 playback channel.  But if you have adaptive streaming turned on,
 you will eventually get a update_client_playback_latency message on the
 display channel (which in the Xspice case is being driven by the main,
 Xorg, thread).
 
 After enough time you would get a thread collision and bad things
 would result.  I saw this manifest as infinite spin loops in snd_send_data.
 
 This patch eliminates the use of threading altogether, making everything
 run in the main Xorg thread using watches and timers, eliminating the
 possibility of thread collision.
 
 Signed-off-by: Jeremy White jwh...@codeweavers.com
 ---
  src/qxl.h|3 +-
  src/spiceqxl_audio.c |  564 
 +++---
  2 files changed, 352 insertions(+), 215 deletions(-)
 
 diff --git a/src/qxl.h b/src/qxl.h
 index fa9b13f..603faca 100644
 --- a/src/qxl.h
 +++ b/src/qxl.h
 @@ -334,8 +334,6 @@ struct _qxl_screen_t
  /* XSpice specific, dragged from the Device */
  QXLReleaseInfo *last_release;
  
 -pthread_t audio_thread;
 -
  uint32_t   cmdflags;
  uint32_t   oom_running;
  uint32_t   num_free_res; /* is having a release ring effective
 @@ -353,6 +351,7 @@ struct _qxl_screen_t
  } guest_primary;
  
  char playback_fifo_dir[PATH_MAX];
 +void *playback_opaque;
  #endif /* XSPICE */
  
  uint32_t deferred_fps;
 diff --git a/src/spiceqxl_audio.c b/src/spiceqxl_audio.c
 index 02859ee..9012f27 100644
 --- a/src/spiceqxl_audio.c
 +++ b/src/spiceqxl_audio.c
 @@ -20,6 +20,10 @@
   * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   */
  
 +/* XSpice based audio feed; reads from files (presumably fifos) in a 
 configured directory,
 +   and mixes their raw data on to the spice playback channel.  */
 +
 +
  #ifdef HAVE_CONFIG_H
  #include config.h
  #endif
 @@ -32,283 +36,375 @@
  #include sys/time.h
  #include unistd.h
  #include dirent.h
 +#include sys/inotify.h
 +
 +/* mplayer + pulse will write data to the fifo as fast as we can read it.
 +   So we need to pace both how quickly we consume the data and how 
 quickly
 +   we feed the data in to Spice.  We will read ahead (up to 
 READ_BUFFER_PERIODS),
 +   and feed ahead into the Spice server (up to FEED_BUFFER_PERIODS).
 +*/
 +
 +#define PERIOD_MS10
 +#define READ_BUFFER_PERIODS  2
 +#define FEED_BUFFER_PERIODS  8
  
 -#define BUFFER_PERIODS 10
 -#define PERIOD_MS 10
  #define MAX_FIFOS 16
  
 +struct fifo_data {
 +char *buffer;
 +int   size;
 +int   len;
 +int   add_to;
 +int   fd;
 +SpiceWatch *watch;
 +};
 +
  struct audio_data {
 -int fifo_fds[MAX_FIFOS];
 -ino_t inodes[MAX_FIFOS];
 -uint32_t valid_bytes, write_offs;
 -char *buffer, *spice_buffer;
 -int period_frames;
 -uint32_t spice_write_offs, spice_buffer_bytes;
 -uint32_t frame_bytes, period_bytes, fed, buffer_bytes;
 -struct timeval last_read_time;
 +struct fifo_data fifos[MAX_FIFOS];
 +uint32_t *spice_buffer;
 +int spice_buffer_bytes;
 +int period_bytes;
 +struct timeval fed_through_time;
 +int remainder;
 +int fifo_count;
 +SpiceTimer *wall_timer;
 +int wall_timer_live;
 +int dir_watch;
 +int fifo_dir_watch;
 +SpiceWatch *fifo_dir_qxl_watch;
  };
  
 -static ssize_t
 -read_from_fifos (struct audio_data *data)
 +/* We maintain a ring buffer for each file we are reading from;
 +   these helper functions faciliate adding data to the buffer,


Typo here, 'facilitate'

 +   and removing it.  */
 +static inline void fifo_data_added(struct fifo_data *f, int n)
  {
 -size_t to_read_bytes = min(data-period_bytes, data-buffer_bytes - 
 data-write_offs);
 -int i;
 -ssize_t max_readed = 0;
 -int16_t *out_buf = (int16_t*)(data-buffer + data-write_offs), *buf;
 +f-add_to = (f-add_to + n) % f-size;
 +f-len += n;
 +}
  
 -buf = malloc(to_read_bytes);
 -if (!buf)
 -{
 -ErrorF(playback: malloc failed: %s\n, strerror(errno));
 -return 0;
 +static inline int fifo_read(struct fifo_data *f)
 +{
 +int rc;
 +int len = min(f-size - f-len, f-size - f-add_to);
 +rc = read(f-fd, f-buffer + f-add_to, len);
 +if (rc  0)
 +fifo_data_added(f, rc);
 +
 +if (rc  0  rc == len  f-size - f-len  0) {
 +rc = read(f-fd, f-buffer + f-add_to, f-size - f-len);
 +if (rc  0)
 +fifo_data_added(f, rc);
  }
  
 -memset(out_buf, 0, to_read_bytes);
 -
 -for (i = 0; i  

[Spice-devel] [PATCH] drmmode: Fix compilation warning

2014-10-22 Thread Christophe Fergeau
One recent change introduced a gcc compilation warning:

  CC   qxl_drmmode.lo
qxl_drmmode.c: In function 'drmmode_set_mode_major':
qxl_drmmode.c:251:9: error: ISO C90 forbids mixed declarations and code 
[-Werror=declaration-after-statement]
 CursorPtr cursor = xf86_config-cursor;

This commit moves the CursorPtr declaration to the top of the
drmmode_set_mode_major function in order to fix that warning.
---
 src/qxl_drmmode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qxl_drmmode.c b/src/qxl_drmmode.c
index e9d6436..f8d5369 100644
--- a/src/qxl_drmmode.c
+++ b/src/qxl_drmmode.c
@@ -132,6 +132,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr 
mode,
 Rotation rotation, int x, int y)
 {
ScrnInfoPtr pScrn = crtc-scrn;
+   CursorPtr cursor;
xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc-scrn);
drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private;
drmmode_ptr drmmode = drmmode_crtc-drmmode;
@@ -248,7 +249,7 @@ done:
crtc-active = TRUE;
 #endif
 
-CursorPtr cursor = xf86_config-cursor;
+cursor = xf86_config-cursor;
 if (cursor)
 drmmode_show_cursor(crtc);
 
-- 
2.1.0

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] drmmode: Fix compilation warning

2014-10-22 Thread Marc-André Lureau
ack, 

- Original Message -
 One recent change introduced a gcc compilation warning:
 
   CC   qxl_drmmode.lo
 qxl_drmmode.c: In function 'drmmode_set_mode_major':
 qxl_drmmode.c:251:9: error: ISO C90 forbids mixed declarations and code
 [-Werror=declaration-after-statement]
  CursorPtr cursor = xf86_config-cursor;
 
 This commit moves the CursorPtr declaration to the top of the
 drmmode_set_mode_major function in order to fix that warning.
 ---
  src/qxl_drmmode.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/qxl_drmmode.c b/src/qxl_drmmode.c
 index e9d6436..f8d5369 100644
 --- a/src/qxl_drmmode.c
 +++ b/src/qxl_drmmode.c
 @@ -132,6 +132,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr
 mode,
Rotation rotation, int x, int y)
  {
   ScrnInfoPtr pScrn = crtc-scrn;
 + CursorPtr cursor;
   xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc-scrn);
   drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private;
   drmmode_ptr drmmode = drmmode_crtc-drmmode;
 @@ -248,7 +249,7 @@ done:
   crtc-active = TRUE;
  #endif
  
 -CursorPtr cursor = xf86_config-cursor;
 +cursor = xf86_config-cursor;
  if (cursor)
  drmmode_show_cursor(crtc);
  
 --
 2.1.0
 
 ___
 Spice-devel mailing list
 Spice-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/spice-devel
 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] drmmode: Fix compilation warning

2014-10-22 Thread Christophe Fergeau
On Wed, Oct 22, 2014 at 10:45:47AM -0400, Marc-André Lureau wrote:
 ack, 

Fwiw, I don't think I have write access to qxl git repository (or maybe
I'm having the same issue as the one you are having)

Christophe


pgpU5B67bD9OF.pgp
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-gtk] Fix SndCodec leak in playback_handle_start()

2014-10-22 Thread Christophe Fergeau
An audio SpiceChannel can get several times the 'start' message during
its lifetime. If received multiple times (for example when rebooting a
VM), this would lead to a SndCodec leak as reported by valgrind:

==7749== 27,036 (48 direct, 26,988 indirect) bytes in 1 blocks are definitely 
lost in loss record 11,418 of 11,440
==7749==at 0x4A08946: calloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7749==by 0x5772A9A: spice_malloc0 (mem.c:109)
==7749==by 0x5772D42: spice_malloc0_n (mem.c:173)
==7749==by 0x57FB3E2: snd_codec_create (snd_codec.c:267)
==7749==by 0x573774C: playback_handle_start (channel-playback.c:380)
==7749==by 0x5721E44: spice_channel_handle_msg (spice-channel.c:2859)
==7749==by 0x571ECB3: spice_channel_recv_msg (spice-channel.c:1877)
==7749==by 0x571F402: spice_channel_iterate_read (spice-channel.c:2114)
==7749==by 0x571F614: spice_channel_iterate (spice-channel.c:2152)
==7749==by 0x5720411: spice_channel_coroutine (spice-channel.c:2429)
==7749==by 0x575CD3A: coroutine_trampoline (coroutine_ucontext.c:63)
==7749==by 0x575C9F4: continuation_trampoline (continuation.c:55)
==7749==by 0x3898E47FEF: ??? (in /usr/lib64/libc-2.20.so)
==7749==by 0xAED547666C92C2FF: ???
==7749==by 0xFFEFFF92F: ???
---
 gtk/channel-playback.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
index e5b9658..40e01ba 100644
--- a/gtk/channel-playback.c
+++ b/gtk/channel-playback.c
@@ -375,6 +375,7 @@ static void playback_handle_start(SpiceChannel *channel, 
SpiceMsgIn *in)
 c-codec = NULL;
 
 if (c-mode != SPICE_AUDIO_DATA_MODE_RAW) {
+snd_codec_destroy(c-codec);
 if (snd_codec_create(c-codec, c-mode, start-frequency, 
SND_CODEC_DECODE) != SND_CODEC_OK) {
 g_warning(create decoder failed);
 return;
-- 
2.1.0

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-gtk] Fix SndCodec leak in playback_handle_start()

2014-10-22 Thread Marc-André Lureau
ack

- Original Message -
 An audio SpiceChannel can get several times the 'start' message during
 its lifetime. If received multiple times (for example when rebooting a
 VM), this would lead to a SndCodec leak as reported by valgrind:
 
 ==7749== 27,036 (48 direct, 26,988 indirect) bytes in 1 blocks are definitely
 lost in loss record 11,418 of 11,440
 ==7749==at 0x4A08946: calloc (in
 /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==7749==by 0x5772A9A: spice_malloc0 (mem.c:109)
 ==7749==by 0x5772D42: spice_malloc0_n (mem.c:173)
 ==7749==by 0x57FB3E2: snd_codec_create (snd_codec.c:267)
 ==7749==by 0x573774C: playback_handle_start (channel-playback.c:380)
 ==7749==by 0x5721E44: spice_channel_handle_msg (spice-channel.c:2859)
 ==7749==by 0x571ECB3: spice_channel_recv_msg (spice-channel.c:1877)
 ==7749==by 0x571F402: spice_channel_iterate_read (spice-channel.c:2114)
 ==7749==by 0x571F614: spice_channel_iterate (spice-channel.c:2152)
 ==7749==by 0x5720411: spice_channel_coroutine (spice-channel.c:2429)
 ==7749==by 0x575CD3A: coroutine_trampoline (coroutine_ucontext.c:63)
 ==7749==by 0x575C9F4: continuation_trampoline (continuation.c:55)
 ==7749==by 0x3898E47FEF: ??? (in /usr/lib64/libc-2.20.so)
 ==7749==by 0xAED547666C92C2FF: ???
 ==7749==by 0xFFEFFF92F: ???
 ---
  gtk/channel-playback.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/gtk/channel-playback.c b/gtk/channel-playback.c
 index e5b9658..40e01ba 100644
 --- a/gtk/channel-playback.c
 +++ b/gtk/channel-playback.c
 @@ -375,6 +375,7 @@ static void playback_handle_start(SpiceChannel *channel,
 SpiceMsgIn *in)
  c-codec = NULL;
  
  if (c-mode != SPICE_AUDIO_DATA_MODE_RAW) {
 +snd_codec_destroy(c-codec);
  if (snd_codec_create(c-codec, c-mode, start-frequency,
  SND_CODEC_DECODE) != SND_CODEC_OK) {
  g_warning(create decoder failed);
  return;
 --
 2.1.0
 
 ___
 Spice-devel mailing list
 Spice-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/spice-devel
 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH xf86-video-qxl v2] Revise the XSpice audio processing to avoid the use of pthreads.

2014-10-22 Thread Jeremy White

On 10/22/2014 09:38 AM, Christophe Fergeau wrote:

Hey,

There are a bunch of calloc/malloc throughout the patch with no check
for a NULL return, would be nice to add that.


Hmm.  I've seen this argued both ways.  One side argues that if an 
allocation is never expected to fail, that it's best to just trigger the 
resulting crash as a diagnostic.  Trying to 'handle' an error where 
there is no reasonable response can just mask the problem, or so goes 
the rationale.  And these are all small allocs that really should never 
fail.


The code base is unclear; it seems that allocs are sometimes checked, 
and sometimes not.  It's easy to add; if you feel it's the preferred 
Spice standard, I'll add the checks.




This also adds inotify monitoring, do we need to add a check for it to
configure.ac? (eg a check for sys/inotify.h)


I don't see how it could hurt; I'll add a check tot he XSpice section.



One small note below for a typo, looks good to me apart from this.


Great, thanks.

Cheers,

Jeremy

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] Fwd: a question about Xspice

2014-10-22 Thread cynthia
At 2014-10-22 19:26:20, Uri Lublin u...@redhat.com wrote:
On 10/22/2014 11:37 AM, Hans de Goede wrote:
 Hi,

 Forwarding this to you guys from the xorg-devel list.

 Regards,

 Hans



  Forwarded Message 
 Subject: a question about Xspice
 Date: Tue, 21 Oct 2014 17:30:54 +0800 (CST)
 From: cynthia cynthia_...@163.com
 To: xorg-de...@lists.x.org, x...@lists.x.org

 HI All,


I am trying to build Xspice which is included in guest QXL driver, but 
 one question confuses me a lot. As the Xspice's description in Readme, i get 
 that Xspice is a X server and spice server in one, running in guest os, but 
 our team has developed a set of windows virtual desktop in which the 
 spiceserver is deployed in HOST os linked with QEMU, and i think that is 
 coordinated with the spice protocol.,
So, could anyone explain it for me if spiceserver is deployed in guest os 
 or host os? I will be very very appreciated~


Hi Cynthia,

Xspice was developed with the (Linux) server/host in mind, not the guest.
Running on a server, it enable remote access to a physical machine using 
Spice.

Of course, it can instead run on the guest, but that was not its purpose.
We already had a solution for the guest that uses Spice, as you've 
mentioned.



Dear Uri,


Thank you so so much for your mail , it's very important.


I started to learn Xspice because Our team are trying to find a solution to 
Linux virtual desktop. Today I created a Fedora guest OS and found there are 
already pre-installed vdagent and qxl driver in it. My spice client can connect 
to the server and logged into the guest, the most important part is the qxl 
dirver in guest is working, I think the Linux virtual desktop works, but i 
didn't do any Xspice thing,  i use the host used to hosting Windows guest. In 
my opinion spice client will be able to access to physical machine when an 
spice server package is installed, but what do we use Xspice for?  and what 
will setting environment variables for X server in the host and enabling video, 
mouse and keyboard driver(libspiceqxl_drv.so) help for?


It's a little long mail, many questions in my head. Anyway ,thank you Uri 
again:)


B R
Cynthia___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH xf86-video-qxl v2] Revise the XSpice audio processing to avoid the use of pthreads.

2014-10-22 Thread Jeremy White


Forgot to mention that there are more error situations in this function
where it looks like data would be leaked.


Sure, added a few more checks.  v3 with configure checking, the typo 
fix, and those checks inbound shortly.


Cheers,

Jeremy
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH xf86-video-qxl v3] Revise the XSpice audio processing to avoid the use of pthreads.

2014-10-22 Thread Jeremy White
The initial implementation used a separate thread to drive the audio
playback channel.  But if you have adaptive streaming turned on,
you will eventually get a update_client_playback_latency message on the
display channel (which in the Xspice case is being driven by the main,
Xorg, thread).

After enough time you would get a thread collision and bad things
would result.  I saw this manifest as infinite spin loops in snd_send_data.

This patch eliminates the use of threading altogether, making everything
run in the main Xorg thread using watches and timers, eliminating the
possibility of thread collision.

Signed-off-by: Jeremy White jwh...@codeweavers.com
---
 configure.ac |2 +
 src/qxl.h|3 +-
 src/spiceqxl_audio.c |  581 +++---
 3 files changed, 368 insertions(+), 218 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3ca32b6..119340a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,8 @@ AC_ARG_ENABLE(xspice,
 ])
 
 if test x$enable_xspice = xyes; then
+AC_CHECK_HEADERS(sys/inotify.h)
+AC_CHECK_FUNCS(inotify_init1)
 PKG_CHECK_MODULES([SPICE], [spice-server = 0.6.3],
 [
 AC_SUBST(SPICE_CFLAGS)
diff --git a/src/qxl.h b/src/qxl.h
index fa9b13f..603faca 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -334,8 +334,6 @@ struct _qxl_screen_t
 /* XSpice specific, dragged from the Device */
 QXLReleaseInfo *last_release;
 
-pthread_t audio_thread;
-
 uint32_t   cmdflags;
 uint32_t   oom_running;
 uint32_t   num_free_res; /* is having a release ring effective
@@ -353,6 +351,7 @@ struct _qxl_screen_t
 } guest_primary;
 
 char playback_fifo_dir[PATH_MAX];
+void *playback_opaque;
 #endif /* XSPICE */
 
 uint32_t deferred_fps;
diff --git a/src/spiceqxl_audio.c b/src/spiceqxl_audio.c
index 02859ee..086b943 100644
--- a/src/spiceqxl_audio.c
+++ b/src/spiceqxl_audio.c
@@ -20,6 +20,10 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+/* XSpice based audio feed; reads from files (presumably fifos) in a 
configured directory,
+   and mixes their raw data on to the spice playback channel.  */
+
+
 #ifdef HAVE_CONFIG_H
 #include config.h
 #endif
@@ -32,283 +36,379 @@
 #include sys/time.h
 #include unistd.h
 #include dirent.h
+#if defined(HAVE_SYS_INOTIFY_H)
+#include sys/inotify.h
+#endif
+
+/* mplayer + pulse will write data to the fifo as fast as we can read it.
+   So we need to pace both how quickly we consume the data and how quickly
+   we feed the data in to Spice.  We will read ahead (up to 
READ_BUFFER_PERIODS),
+   and feed ahead into the Spice server (up to FEED_BUFFER_PERIODS).
+*/
+
+#define PERIOD_MS10
+#define READ_BUFFER_PERIODS  2
+#define FEED_BUFFER_PERIODS  8
 
-#define BUFFER_PERIODS 10
-#define PERIOD_MS 10
 #define MAX_FIFOS 16
 
+struct fifo_data {
+char *buffer;
+int   size;
+int   len;
+int   add_to;
+int   fd;
+SpiceWatch *watch;
+};
+
 struct audio_data {
-int fifo_fds[MAX_FIFOS];
-ino_t inodes[MAX_FIFOS];
-uint32_t valid_bytes, write_offs;
-char *buffer, *spice_buffer;
-int period_frames;
-uint32_t spice_write_offs, spice_buffer_bytes;
-uint32_t frame_bytes, period_bytes, fed, buffer_bytes;
-struct timeval last_read_time;
+struct fifo_data fifos[MAX_FIFOS];
+uint32_t *spice_buffer;
+int spice_buffer_bytes;
+int period_bytes;
+struct timeval fed_through_time;
+int remainder;
+int fifo_count;
+SpiceTimer *wall_timer;
+int wall_timer_live;
+int dir_watch;
+int fifo_dir_watch;
+SpiceWatch *fifo_dir_qxl_watch;
 };
 
-static ssize_t
-read_from_fifos (struct audio_data *data)
+/* We maintain a ring buffer for each file we are reading from;
+   these helper functions facilitate adding data to the buffer,
+   and removing it.  */
+static inline void fifo_data_added(struct fifo_data *f, int n)
 {
-size_t to_read_bytes = min(data-period_bytes, data-buffer_bytes - 
data-write_offs);
-int i;
-ssize_t max_readed = 0;
-int16_t *out_buf = (int16_t*)(data-buffer + data-write_offs), *buf;
+f-add_to = (f-add_to + n) % f-size;
+f-len += n;
+}
 
-buf = malloc(to_read_bytes);
-if (!buf)
-{
-ErrorF(playback: malloc failed: %s\n, strerror(errno));
-return 0;
+static inline int fifo_read(struct fifo_data *f)
+{
+int rc;
+int len = min(f-size - f-len, f-size - f-add_to);
+rc = read(f-fd, f-buffer + f-add_to, len);
+if (rc  0)
+fifo_data_added(f, rc);
+
+if (rc  0  rc == len  f-size - f-len  0) {
+rc = read(f-fd, f-buffer + f-add_to, f-size - f-len);
+if (rc  0)
+fifo_data_added(f, rc);
 }
 
-memset(out_buf, 0, to_read_bytes);
-
-for (i = 0; i  MAX_FIFOS; ++i)
-{
-unsigned int s;
-ssize_t readed;
-
-if (data-fifo_fds[i]  0)
-