Re: [Spice-devel] 2K/4K resolutions not available?

2015-06-11 Thread Christophe Fergeau
Hey,

On Wed, Jun 10, 2015 at 03:37:09PM -0700, Mike wrote:
 I'm trying to get 2K+ resolutions to work with SPICE/QXL and QEMU 2.2
 (Ubuntu Vivid) on the host and Ubuntu Trusty on the guest. Currently the
 highest resolution is 1920x1200... I tried increasing the QXL video memory
 to 128MB from 64MB, but that didn't seem to make a difference, is there
 something simple I'm missing perhaps?

These resolutions are missing from the drm driver
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/qxl/qxl_display.c#n175
booting with nomodeset should make them 'appear' in the guest (but
better not to do that).

With remote-viewer/gnome-boxes, you should be able to resize the guest
window to any size you want, including the higher resolutions you are
looking for. Is this not working?

Christophe


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


[Spice-devel] [RFC PATCH] qemu: Use heads parameter for QXL driver

2015-06-11 Thread Frediano Ziglio
Allow to specify maximum number of head to QXL driver.

Signed-off-by: Frediano Ziglio fzig...@redhat.com
---
 src/qemu/qemu_capabilities.c |  2 ++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_command.c  | 11 +++
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_1.2.2-1.replies  |  8 
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.replies  |  8 
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.replies  |  8 
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.replies  |  8 
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.replies  |  8 
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps|  1 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.replies |  8 
 tests/qemucapabilitiesdata/caps_2.1.1-1.caps |  1 +
 tests/qemucapabilitiesdata/caps_2.1.1-1.replies  |  8 
 17 files changed, 77 insertions(+)

The patch to support the max_outputs in Qemu is still not merged but
I got agreement on the name of the argument.

Actually can be a compatiblity problem as heads in the XML configuration
was set by default to '1'.

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ca7a7c2..cdc2575 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -285,6 +285,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   dea-key-wrap,
   pci-serial,
   aarch64-off,
+  qxl-vga.max_outputs,
 );
 
 
@@ -1643,6 +1644,7 @@ static struct virQEMUCapsStringFlags 
virQEMUCapsObjectPropsQxl[] = {
 
 static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = {
 { vgamem_mb, QEMU_CAPS_QXL_VGA_VGAMEM },
+{ max_outputs, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS },
 };
 
 struct virQEMUCapsObjectTypeProps {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index b5a7770..a2ea84b 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -229,6 +229,7 @@ typedef enum {
 QEMU_CAPS_DEA_KEY_WRAP   = 187, /* -machine dea_key_wrap */
 QEMU_CAPS_DEVICE_PCI_SERIAL  = 188, /* -device pci-serial */
 QEMU_CAPS_CPU_AARCH64_OFF= 189, /* -cpu ...,aarch64=off */
+QEMU_CAPS_QXL_VGA_MAX_OUTPUTS = 190, /* qxl-vga.max_outputs */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0a6d92f..2bd63e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5610,6 +5610,11 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
 /* QEMU accepts mebibytes for vgamem_mb. */
 virBufferAsprintf(buf, ,vgamem_mb=%u, video-vgamem / 1024);
 }
+
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) 
+video-heads  0) {
+virBufferAsprintf(buf, ,max_outputs=%u, video-heads);
+}
 } else if (video-vram 
 ((video-type == VIR_DOMAIN_VIDEO_TYPE_VGA 
   virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
@@ -10234,6 +10239,7 @@ qemuBuildCommandLine(virConnectPtr conn,
 unsigned int ram = def-videos[0]-ram;
 unsigned int vram = def-videos[0]-vram;
 unsigned int vgamem = def-videos[0]-vgamem;
+unsigned int heads = def-videos[0]-heads;
 
 if (vram  (UINT_MAX / 1024)) {
 virReportError(VIR_ERR_OVERFLOW,
@@ -10264,6 +10270,11 @@ qemuBuildCommandLine(virConnectPtr conn,
 virCommandAddArgFormat(cmd, %s.vgamem_mb=%u,
dev, vgamem / 1024);
 }
+if (virQEMUCapsGet(qemuCaps, 
QEMU_CAPS_QXL_VGA_MAX_OUTPUTS)  heads  0) {
+virCommandAddArg(cmd, -global);
+virCommandAddArgFormat(cmd, %s.max_outputs=%u,
+   dev, heads);
+}
 }
 
 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) 
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps 
b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index 30239df..7791e42 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -120,4 +120,5 @@
 flag name='vmware-svga.vgamem_mb'/
 flag name='qxl.vgamem_mb'/
 flag name='qxl-vga.vgamem_mb'/
+flag name='qxl-vga.max_outputs'/
   /qemuCaps
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies 
b/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
index f501218..aa1d3f9 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.replies
+++ 

Re: [Spice-devel] [PATCH spice-gtk] channel-main: Notify about existence of monitor

2015-06-11 Thread Marc-André Lureau
Hi Pavel

- Original Message -
 SpiceMainChannel should be notify about existence of monitors
 assigned to a SpiceDisplayChannel, even when the SpiceDisplayChannel
 is not connected to a SpiceDisplay widget. Otherwise the automatic
 resizing (the resize-guest property) of SpiceDisplay will not work
 when there is more display channels than SpiceDisplays.
 
 Fixes:
 https://bugs.freedesktop.org/show_bug.cgi?id=90914
 ---
  src/channel-main.c | 21 -
  1 file changed, 20 insertions(+), 1 deletion(-)
 
 diff --git a/src/channel-main.c b/src/channel-main.c
 index c55d097..fbc41da 100644
 --- a/src/channel-main.c
 +++ b/src/channel-main.c
 @@ -1580,18 +1580,36 @@ static void main_handle_mm_time(SpiceChannel
 *channel, SpiceMsgIn *in)
  spice_session_set_mm_time(session, msg-time);
  }
  
 +static void main_enable_monitor(SpiceChannel *channel, GParamSpec *pspec
 G_GNUC_UNUSED,
 +SpiceMainChannel *main_channel)
 +{
 +gint channel_id = spice_channel_get_channel_id(channel);
 +
 +g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
 +g_return_if_fail(channel_id  MAX_DISPLAY);
 +g_return_if_fail(main_channel != NULL  main_channel-priv != NULL);
 +
 +main_channel-priv-display[channel_id].enabled_set = TRUE;
 +}
 +

- enabled_set is a boolean used to indicate that the display enabled is 
set... To make this more clear, I think it should be changed for an enum 
instead: UNDEFINED, DISABLED, ENABLED.
- enabled_set is set, but what about the rest of the monitor config 
(enabled/x/y/w/h)
- this may overwrite user monitor config, and may be annoying in some racy 
situation: user start with a 2 monitors config, connects to a 1 monitor enabled 
guest, and reconfigure/resizes while the guest second monitor is not yet 
enabled: it will flip config back to disable 2nd monitor. Although this race 
already exists today with spice-gtk, I think it's worth mentioning again since 
it introduces again the same issue 
- the nth display is not necessarily the nth monitor, channel 0 can have 
multiple monitors

  typedef struct channel_new {
  SpiceSession *session;
  int type;
  int id;
 +SpiceMainChannel *main_channel;
  } channel_new_t;
  
  /* main context */
  static gboolean _channel_new(channel_new_t *c)
  {
 +SpiceChannel *channel;
  g_return_val_if_fail(c != NULL, FALSE);
  
 -spice_channel_new(c-session, c-type, c-id);
 +channel = spice_channel_new(c-session, c-type, c-id);
 +if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
 +spice_g_signal_connect_object(channel, notify::monitors,
 +  G_CALLBACK(main_enable_monitor),
 c-main_channel, 0);
 +}
  
  g_object_unref(c-session);
  g_free(c);
 @@ -1619,6 +1637,7 @@ static void main_handle_channels_list(SpiceChannel
 *channel, SpiceMsgIn *in)
  c-session = g_object_ref(session);
  c-type = msg-channels[i].type;
  c-id = msg-channels[i].id;
 +c-main_channel = SPICE_MAIN_CHANNEL(channel);
  /* no need to explicitely switch to main context, since
 synchronous call is not needed. */
  /* no need to track idle, session is refed */
 --
 2.4.3
 
 ___
 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 spice-gtk] Send monitor config when enough display channels are connected

2015-06-11 Thread Marc-André Lureau
Hi Pavel,

The previous approach is better, since it waits until the monitor config is 
received. Just waiting for channels to be connected would be racy.

- Original Message -
 Fixes:
 https://bugs.freedesktop.org/show_bug.cgi?id=90914
 ---
  src/channel-main.c   |  2 +-
  src/spice-session-priv.h |  1 +
  src/spice-session.c  | 25 +
  3 files changed, 27 insertions(+), 1 deletion(-)
 
 diff --git a/src/channel-main.c b/src/channel-main.c
 index fbc41da..6344d0c 100644
 --- a/src/channel-main.c
 +++ b/src/channel-main.c
 @@ -1425,7 +1425,7 @@ static gboolean timer_set_display(gpointer data)
  
  /* ensure we have an explicit monitor configuration at least for
 number of display channels */
 -for (i = 0; i  spice_session_get_n_display_channels(session); i++)
 +for (i = 0; i  spice_session_get_n_connected_display_channels(session);
 i++)
  if (!c-display[i].enabled_set) {
  SPICE_DEBUG(Not sending monitors config, missing monitors);
  return FALSE;
 diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
 index 049973a..203bbc0 100644
 --- a/src/spice-session-priv.h
 +++ b/src/spice-session-priv.h
 @@ -96,6 +96,7 @@ const guint8* spice_session_get_webdav_magic(SpiceSession
 *session);
  PhodavServer *spice_session_get_webdav_server(SpiceSession *session);
  PhodavServer* channel_webdav_server_new(SpiceSession *session);
  guint spice_session_get_n_display_channels(SpiceSession *session);
 +guint spice_session_get_n_connected_display_channels(SpiceSession *session);
  void spice_session_set_main_channel(SpiceSession *session, SpiceChannel
  *channel);
  gboolean spice_session_set_migration_session(SpiceSession *session,
  SpiceSession *mig_session);
  SpiceAudio *spice_audio_get(SpiceSession *session, GMainContext *context);
 diff --git a/src/spice-session.c b/src/spice-session.c
 index 778d82a..5154bcc 100644
 --- a/src/spice-session.c
 +++ b/src/spice-session.c
 @@ -2452,6 +2452,31 @@ guint
 spice_session_get_n_display_channels(SpiceSession *session)
  }
  
  G_GNUC_INTERNAL
 +guint spice_session_get_n_connected_display_channels(SpiceSession *session)
 +{
 +SpiceSessionPrivate *s;
 +struct channel *item;
 +RingItem *ring;
 +guint channels = 0;
 +
 +g_return_val_if_fail(SPICE_IS_SESSION(session), 0);
 +g_return_val_if_fail(session-priv != NULL, 0);
 +
 +s = session-priv;
 +
 +for (ring = ring_get_head(s-channels);
 + ring != NULL;
 + ring = ring_next(s-channels, ring)) {
 +item = SPICE_CONTAINEROF(ring, struct channel, link);
 +if (SPICE_IS_DISPLAY_CHANNEL(item-channel) 
 +spice_channel_get_state(item-channel) !=
 SPICE_CHANNEL_STATE_UNCONNECTED) {
 +channels++;
 +}
 +}
 +return channels;
 +}
 +
 +G_GNUC_INTERNAL
  void spice_session_set_uuid(SpiceSession *session, guint8 uuid[16])
  {
  g_return_if_fail(SPICE_IS_SESSION(session));
 --
 2.4.3
 
 ___
 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


[Spice-devel] [PATCH spice-gtk] Send monitor config when enough display channels are connected

2015-06-11 Thread Pavel Grunt
Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=90914
---
 src/channel-main.c   |  2 +-
 src/spice-session-priv.h |  1 +
 src/spice-session.c  | 25 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index fbc41da..6344d0c 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1425,7 +1425,7 @@ static gboolean timer_set_display(gpointer data)
 
 /* ensure we have an explicit monitor configuration at least for
number of display channels */
-for (i = 0; i  spice_session_get_n_display_channels(session); i++)
+for (i = 0; i  spice_session_get_n_connected_display_channels(session); 
i++)
 if (!c-display[i].enabled_set) {
 SPICE_DEBUG(Not sending monitors config, missing monitors);
 return FALSE;
diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
index 049973a..203bbc0 100644
--- a/src/spice-session-priv.h
+++ b/src/spice-session-priv.h
@@ -96,6 +96,7 @@ const guint8* spice_session_get_webdav_magic(SpiceSession 
*session);
 PhodavServer *spice_session_get_webdav_server(SpiceSession *session);
 PhodavServer* channel_webdav_server_new(SpiceSession *session);
 guint spice_session_get_n_display_channels(SpiceSession *session);
+guint spice_session_get_n_connected_display_channels(SpiceSession *session);
 void spice_session_set_main_channel(SpiceSession *session, SpiceChannel 
*channel);
 gboolean spice_session_set_migration_session(SpiceSession *session, 
SpiceSession *mig_session);
 SpiceAudio *spice_audio_get(SpiceSession *session, GMainContext *context);
diff --git a/src/spice-session.c b/src/spice-session.c
index 778d82a..5154bcc 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2452,6 +2452,31 @@ guint spice_session_get_n_display_channels(SpiceSession 
*session)
 }
 
 G_GNUC_INTERNAL
+guint spice_session_get_n_connected_display_channels(SpiceSession *session)
+{
+SpiceSessionPrivate *s;
+struct channel *item;
+RingItem *ring;
+guint channels = 0;
+
+g_return_val_if_fail(SPICE_IS_SESSION(session), 0);
+g_return_val_if_fail(session-priv != NULL, 0);
+
+s = session-priv;
+
+for (ring = ring_get_head(s-channels);
+ ring != NULL;
+ ring = ring_next(s-channels, ring)) {
+item = SPICE_CONTAINEROF(ring, struct channel, link);
+if (SPICE_IS_DISPLAY_CHANNEL(item-channel) 
+spice_channel_get_state(item-channel) != 
SPICE_CHANNEL_STATE_UNCONNECTED) {
+channels++;
+}
+}
+return channels;
+}
+
+G_GNUC_INTERNAL
 void spice_session_set_uuid(SpiceSession *session, guint8 uuid[16])
 {
 g_return_if_fail(SPICE_IS_SESSION(session));
-- 
2.4.3

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


Re: [Spice-devel] [PATCH v2] RFC: qxl: allow to specify head limit to qxl driver

2015-06-11 Thread Gerd Hoffmann
On Do, 2015-06-11 at 10:38 +0100, Frediano Ziglio wrote:
 libvirt has this as a video card parameter (actually set to 1 but not
 used). This parameter will allow to limit setting a use can do (which
 could be confusing).

Hmm.  So heads is '1' by default but ignored today.  When this starts to
be actually applied that will break existing multihead setups I suspect.

 This patch rely on some change in spice-protocol which are not still
 accepted. See
 http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html.

Spice-server changes, right?
Needs #ifdefs so qemu continues to build with old spice-server versions.
The spice-server changes need to be upstream first.

Also: when we pass on the limit to spice-server anyway spice-server can
take care to apply the limit both ways and not call the
-client_monitors_config() callback with more than $limit monitors.  Has
the advantage to reduce the test matrix:  Limit either works or doesn't.
There will be no spice-server/qemu version combination where the limit
is applied one way only.

  Gerd


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


[Spice-devel] [PATCH v2] RFC: qxl: allow to specify head limit to qxl driver

2015-06-11 Thread Frediano Ziglio
This patch allow to limit number of heads using qxl driver. By default
qxl driver is not limited on any kind on head use so can decide to use
as much heads.

libvirt has this as a video card parameter (actually set to 1 but not
used). This parameter will allow to limit setting a use can do (which
could be confusing).

This patch rely on some change in spice-protocol which are not still
accepted. See
http://lists.freedesktop.org/archives/spice-devel/2015-June/020221.html.

Signed-off-by: Frediano Ziglio fzig...@redhat.com
---
 hw/display/qxl.c | 20 +++-
 hw/display/qxl.h |  1 +
 2 files changed, 16 insertions(+), 5 deletions(-)

This version change the way limit is set. It came from Gerd Hoffmann
suggestion.

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index b220e2d..678fde5 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -272,6 +272,10 @@ static void qxl_spice_monitors_config_async(PCIQXLDevice 
*qxl, int replay)
 QXL_COOKIE_TYPE_POST_LOAD_MONITORS_CONFIG,
 0));
 } else {
+if (qxl-max_outputs) {
+spice_qxl_set_monitors_config_limit(qxl-ssd.qxl,
+qxl-max_outputs);
+}
 qxl-guest_monitors_config = qxl-ram-monitors_config;
 spice_qxl_monitors_config_async(qxl-ssd.qxl,
 qxl-ram-monitors_config,
@@ -992,6 +996,7 @@ static int interface_client_monitors_config(QXLInstance 
*sin,
 PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
 QXLRom *rom = memory_region_get_ram_ptr(qxl-rom_bar);
 int i;
+unsigned max_outputs = ARRAY_SIZE(rom-client_monitors_config.heads);
 
 if (qxl-revision  4) {
 trace_qxl_client_monitors_config_unsupported_by_device(qxl-id,
@@ -1014,17 +1019,21 @@ static int interface_client_monitors_config(QXLInstance 
*sin,
 if (!monitors_config) {
 return 1;
 }
+
+/* limit number of outputs based on setting limit */
+if (qxl-max_outputs  qxl-max_outputs = max_outputs) {
+max_outputs = qxl-max_outputs;
+}
+
 memset(rom-client_monitors_config, 0,
sizeof(rom-client_monitors_config));
 rom-client_monitors_config.count = monitors_config-num_of_monitors;
 /* monitors_config-flags ignored */
-if (rom-client_monitors_config.count =
-ARRAY_SIZE(rom-client_monitors_config.heads)) {
+if (rom-client_monitors_config.count = max_outputs) {
 trace_qxl_client_monitors_config_capped(qxl-id,
 monitors_config-num_of_monitors,
-ARRAY_SIZE(rom-client_monitors_config.heads));
-rom-client_monitors_config.count =
-ARRAY_SIZE(rom-client_monitors_config.heads);
+max_outputs);
+rom-client_monitors_config.count = max_outputs;
 }
 for (i = 0 ; i  rom-client_monitors_config.count ; ++i) {
 VDAgentMonConfig *monitor = monitors_config-monitors[i];
@@ -2278,6 +2287,7 @@ static Property qxl_properties[] = {
 DEFINE_PROP_UINT32(vram64_size_mb, PCIQXLDevice, vram_size_mb, -1),
 DEFINE_PROP_UINT32(vgamem_mb, PCIQXLDevice, vgamem_size_mb, 16),
 DEFINE_PROP_INT32(surfaces, PCIQXLDevice, ssd.num_surfaces, 1024),
+DEFINE_PROP_UINT16(max_outputs, PCIQXLDevice, max_outputs, 0),
 DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index deddd54..d045f59 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -99,6 +99,7 @@ typedef struct PCIQXLDevice {
 QXLModes   *modes;
 uint32_t   rom_size;
 MemoryRegion   rom_bar;
+uint16_t   max_outputs;
 
 /* vram pci bar */
 uint32_t   vram_size;
-- 
2.1.0

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


Re: [Spice-devel] [PATCH] server: allow to set maximum monitors

2015-06-11 Thread Marc-André Lureau
looks good to me, ACK

On Wed, Jun 10, 2015 at 1:54 PM, Frediano Ziglio fzig...@redhat.com wrote:

 spice-server will attempt to limit number of monitors.
 Guest machine can send monitor list it accepts. Limiting the number sent
 by guest will limit the number of monitors client will try to enable.
 The guest usually see client monitors enabled and start using it so
 not seeing client monitor won't try to enable more monitor.
 In this case the additional monitor guest can support will always be
 seen as heads with no attached monitors.
 This allows limiting monitors number without changing guest drivers.

 Signed-off-by: Frediano Ziglio fzig...@redhat.com
 ---
  server/red_dispatcher.c  | 11 +++
  server/red_dispatcher.h  |  1 +
  server/red_worker.c  | 12 +++-
  server/spice-qxl.h   |  3 +++
  server/spice-server.syms |  5 +
  5 files changed, 27 insertions(+), 5 deletions(-)

 diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
 index f5f3e52..3838bbb 100644
 --- a/server/red_dispatcher.c
 +++ b/server/red_dispatcher.c
 @@ -66,6 +66,7 @@ struct RedDispatcher {
  Ring async_commands;
  pthread_mutex_t  async_lock;
  QXLDevSurfaceCreate surface_create;
 +unsigned max_monitors;
  };

  extern uint32_t streaming_video;
 @@ -693,6 +694,7 @@ static void
 red_dispatcher_monitors_config_async(RedDispatcher *dispatcher,
  payload.base.cmd = async_command_alloc(dispatcher, message, cookie);
  payload.monitors_config = monitors_config;
  payload.group_id = group_id;
 +payload.max_monitors = dispatcher-max_monitors;

  dispatcher_send_message(dispatcher-dispatcher, message, payload);
  }
 @@ -987,6 +989,13 @@ void spice_qxl_monitors_config_async(QXLInstance
 *instance, QXLPHYSICAL monitors
  }

  SPICE_GNUC_VISIBLE
 +void spice_qxl_set_monitors_config_limit(QXLInstance *instance,
 + unsigned max_monitors)
 +{
 +instance-st-dispatcher-max_monitors = MAX(1u, max_monitors);
 +}
 +
 +SPICE_GNUC_VISIBLE
  void spice_qxl_driver_unload(QXLInstance *instance)
  {
  red_dispatcher_driver_unload(instance-st-dispatcher);
 @@ -1110,6 +1119,8 @@ void red_dispatcher_init(QXLInstance *qxl)
  red_dispatcher-base.destroy_surface_wait =
 qxl_worker_destroy_surface_wait;
  red_dispatcher-base.loadvm_commands = qxl_worker_loadvm_commands;

 +red_dispatcher-max_monitors = UINT16_MAX;
 +
  qxl-st-qif-get_init_info(qxl, init_info);

  init_data.memslot_id_bits = init_info.memslot_id_bits;
 diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h
 index 907b7c7..70b8a62 100644
 --- a/server/red_dispatcher.h
 +++ b/server/red_dispatcher.h
 @@ -200,6 +200,7 @@ typedef struct RedWorkerMessageMonitorsConfigAsync {
  RedWorkerMessageAsync base;
  QXLPHYSICAL monitors_config;
  int group_id;
 +unsigned int max_monitors;
  } RedWorkerMessageMonitorsConfigAsync;

  typedef struct RedWorkerMessageDriverUnload {
 diff --git a/server/red_worker.c b/server/red_worker.c
 index 5deb30b..564bfba 100644
 --- a/server/red_worker.c
 +++ b/server/red_worker.c
 @@ -11234,11 +11234,13 @@ static inline void
 red_monitors_config_item_add(DisplayChannelClient *dcc)
  }

  static void worker_update_monitors_config(RedWorker *worker,
 -  QXLMonitorsConfig
 *dev_monitors_config)
 +  QXLMonitorsConfig
 *dev_monitors_config,
 +  unsigned max_monitors)
  {
  int heads_size;
  MonitorsConfig *monitors_config;
  int i;
 +unsigned count = MIN(dev_monitors_config-count, max_monitors);

  monitors_config_decref(worker-monitors_config);

 @@ -11252,13 +11254,13 @@ static void
 worker_update_monitors_config(RedWorker *worker,
  dev_monitors_config-heads[i].width,
  dev_monitors_config-heads[i].height);
  }
 -heads_size = dev_monitors_config-count * sizeof(QXLHead);
 +heads_size = count * sizeof(QXLHead);
  worker-monitors_config = monitors_config =
  spice_malloc(sizeof(*monitors_config) + heads_size);
  monitors_config-refs = 1;
  monitors_config-worker = worker;
 -monitors_config-count = dev_monitors_config-count;
 -monitors_config-max_allowed = dev_monitors_config-max_allowed;
 +monitors_config-count = count;
 +monitors_config-max_allowed = MIN(dev_monitors_config-max_allowed,
 max_monitors);
  memcpy(monitors_config-heads, dev_monitors_config-heads,
 heads_size);
  }

 @@ -11668,7 +11670,7 @@ static void handle_dev_monitors_config_async(void
 *opaque, void *payload)
dev_monitors_config-max_allowed);
  return;
  }
 -worker_update_monitors_config(worker, dev_monitors_config);
 +worker_update_monitors_config(worker, dev_monitors_config,
 msg-max_monitors);
  red_worker_push_monitors_config(worker);
  }

 diff --git a/server/spice-qxl.h 

Re: [Spice-devel] 2K/4K resolutions not available?

2015-06-11 Thread Gerd Hoffmann
On Do, 2015-06-11 at 12:04 +0200, Christophe Fergeau wrote:
 Hey,
 
 On Wed, Jun 10, 2015 at 03:37:09PM -0700, Mike wrote:
  I'm trying to get 2K+ resolutions to work with SPICE/QXL and QEMU 2.2
  (Ubuntu Vivid) on the host and Ubuntu Trusty on the guest. Currently the
  highest resolution is 1920x1200... I tried increasing the QXL video memory
  to 128MB from 64MB, but that didn't seem to make a difference, is there
  something simple I'm missing perhaps?
 
 These resolutions are missing from the drm driver
 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/qxl/qxl_display.c#n175
 booting with nomodeset should make them 'appear' in the guest (but
 better not to do that).
 
 With remote-viewer/gnome-boxes, you should be able to resize the guest
 window to any size you want, including the higher resolutions you are
 looking for. Is this not working?

Also you can set pretty much any mode via xrandr (doesn't mix well with
the auto-resize done by spice vdagent though).

cheers,
  Gerd

== [ cut here ] ==
#!/bin/sh

width=$1
height=$2

if test $width =  -o $height = ; then
echo usage: $0 width height
exit 1
fi

output=$(xrandr --query | awk '/ connected/ { print $1; exit }')
mode=${width}x${height}
echo # setting mode $mode on output $output

if xrandr --query | grep -q -e  $mode ; then
true # mode already there
else
modeline=$(cvt $width $height | grep Modeline | cut -d  -f3-)
(set -x; xrandr --newmode $mode $modeline;
 xrandr --addmode $output $mode)
fi
(set -x; xrandr --output $output --mode $mode)


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


Re: [Spice-devel] [RFC PATCH] qemu: Use heads parameter for QXL driver

2015-06-11 Thread Christophe Fergeau
On Thu, Jun 11, 2015 at 12:39:50PM +0100, Frediano Ziglio wrote:
 
 Actually can be a compatiblity problem as heads in the XML configuration
 was set by default to '1'.

Yes, this bit is worrying, the old behaviour could be considered as
buggy as the XML contained '1' but the number of heads was not enforced.
Suddenly enforcing the heads='1' (which libvirt will add by default to
domain definitions which don't have it) will cause a change of behaviour
for old guests though.

Something like the patch below changes libvirt so that we don't always
append heads='1' to domain XML, but I don't know if this interacts
correctly with parallels and vmx which force it to be 1 (this probably should
not be an issue, but maybe there are latent bugs). Also this is part of the 
things
which are checked as part of virDomainVideoDefCheckABIStability() , so I
suspect we'll need to be extra careful there too :(

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 36de844..43067e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11421,7 +11421,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
 goto error;
 }
 } else {
-def-heads = 1;
+def-heads = 0;
 }

 if (virDomainDeviceInfoParseXML(node, NULL, def-info, flags)  0)
@@ -15507,7 +15507,6 @@ virDomainDefParseXML(xmlDocPtr xml,
 goto error;
 }
 video-vram = virDomainVideoDefaultRAM(def, video-type);
-video-heads = 1;
 if (VIR_ALLOC_N(def-videos, 1)  0) {
 virDomainVideoDefFree(video);
 goto error;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2bd63e1..03a0458 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -13411,7 +13411,6 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
 vid-ram = 0;
 vid-vgamem = 0;
 }
-vid-heads = 1;

 if (VIR_APPEND_ELEMENT(def-videos, def-nvideos, vid)  0) {
 virDomainVideoDefFree(vid);


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


Re: [Spice-devel] [PATCH v2] Use spice_malloc instead of malloc

2015-06-11 Thread Christophe Fergeau
On Wed, Jun 10, 2015 at 02:53:05PM +0100, Frediano Ziglio wrote:
 Do not just check and give warning before crashing the program
 accessing a NULL pointer but use spice_malloc which exits with a
 proper message.
 
 Signed-off-by: Frediano Ziglio fzig...@redhat.com
 ---
  server/red_worker.c | 6 ++
  1 file changed, 2 insertions(+), 4 deletions(-)
 
 Change from v1:
 - fix type in patch comment
 
 diff --git a/server/red_worker.c b/server/red_worker.c
 index 1871e13..03d07e2 100644
 --- a/server/red_worker.c
 +++ b/server/red_worker.c
 @@ -1664,8 +1664,7 @@ static SurfaceDestroyItem 
 *get_surface_destroy_item(RedChannel *channel,
  {
  SurfaceDestroyItem *destroy;
  
 -destroy = (SurfaceDestroyItem *)malloc(sizeof(SurfaceDestroyItem));
 -spice_warn_if(!destroy);
 +destroy = (SurfaceDestroyItem *)spice_malloc(sizeof(SurfaceDestroyItem));
  
  destroy-surface_destroy.surface_id = surface_id;
  
 @@ -9399,8 +9398,7 @@ static SurfaceCreateItem *get_surface_create_item(
  {
  SurfaceCreateItem *create;
  
 -create = (SurfaceCreateItem *)malloc(sizeof(SurfaceCreateItem));
 -spice_warn_if(!create);
 +create = (SurfaceCreateItem *)spice_malloc(sizeof(SurfaceCreateItem));

Actually the cast is unnecessary, I'll drop it too (I've already made the
change locally, no need to resend a v3 for that).

Christophe


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


Re: [Spice-devel] [PATCH spice 10/12] server: Add GStreamer 1.0 support.

2015-06-11 Thread Fabio Fantoni
Il 10/06/2015 17:38, Francois Gouget ha scritto:
 Signed-off-by: Francois Gouget fgou...@codeweavers.com
 ---

 This adds GStreamer 1.0 support!

 By default GStreamer 1.0 is used if available, otherwise GStreamer 0.10 
 is used and Spice is compiled without GStreamer support as a last 
 resort. It's possible to explicitly require a specific Gstreamer version 
 with --enable-gstreamer=1.0 and --enable-gstreamer=0.10, or for any 
 version with --enable-gstreamer=yes.

 If you get an error while building the pipeline for MJPEG, then it 
 probably means you need the fix for this bug:
 https://bugzilla.gnome.org/show_bug.cgi?id=750398

Probably another change in configure is needed to avoid this:
 /bin/bash ../../libtool  --tag=CC   --mode=link gcc -std=gnu99  -g -O2
 -fstack-protector --param=ssp-buffer-size=4 -Wformat
 -Werror=format-security  -Wl,-z,relro -lm -o test_display_no_ssl
 basic_event_loop.o  test_display_base.o test_display_no_ssl.o 
 ../../spice-common/common/libspice-common.la
 ../../server/libspice-server.la -lglib-2.0
 libtool: link: gcc -std=gnu99 -g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wl,-z
 -Wl,relro -o .libs/test_display_no_ssl basic_event_loop.o
 test_display_base.o test_display_no_ssl.o 
 ../../spice-common/common/.libs/libspice-common.a -lm -lpixman-1
 -lopus ../../server/.libs/libspice-server.so -lglib-2.0 -pthread
 ../../server/.libs/libspice-server.so: undefined reference to
 `g_get_num_processors'

toso in spice chat told that was added in glib 2.36check pkg-config
--modversion glib-2.0 (this should probably bump the configure version
for glib tho)



  configure.ac   | 35 +
  server/Makefile.am | 12 ++--
  server/gstreamer_encoder.c | 77 
 --
  server/red_dispatcher.c|  2 +-
  4 files changed, 108 insertions(+), 18 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index 34e1a4a..3fc46f9 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -92,14 +92,32 @@ if test x$enable_smartcard = xyes; then
  fi
  
  AC_ARG_ENABLE(gstreamer,
 -  AS_HELP_STRING([--enable-gstreamer=@:@auto/yes/no@:@],
 - [Enable GStreamer 0.10 support]),
 +  
 AS_HELP_STRING([--enable-gstreamer=@:@auto/0.10/1.0/yes/no@:@],
 + [Enable GStreamer support]),
[],
[enable_gstreamer=auto])
  
 -if test x$enable_gstreamer != xno; then
 +if test x$enable_gstreamer != xno  test x$enable_gstreamer != 
 x0.10; then
 +PKG_CHECK_MODULES(GSTREAMER_1_0, [gstreamer-1.0, gstreamer-app-1.0],
 +  [enable_gstreamer=1.0
 +   have_gstreamer_1_0=yes],
 +  [have_gstreamer_1_0=no])
 +if test x$have_gstreamer_1_0 = xyes; then
 +AC_SUBST(GSTREAMER_1_0_CFLAGS)
 +AC_SUBST(GSTREAMER_1_0_LIBS)
 +AS_VAR_APPEND([SPICE_REQUIRES], [ gstreamer-1.0 gstreamer-app-1.0])
 +AC_DEFINE([HAVE_GSTREAMER_1_0], [1], [Define if supporting GStreamer 
 1.0])
 +elif test x$enable_gstreamer = x1.0; then
 +AC_MSG_ERROR([GStreamer 1.0 support requested but not found. You may 
 set GSTREAMER_1_0_CFLAGS and GSTREAMER_1_0_LIBS to avoid the need to call 
 pkg-config.])
 +fi
 +else
 +have_gstreamer_1_0=no
 +fi
 +AM_CONDITIONAL(SUPPORT_GSTREAMER_1_0, test x$have_gstreamer_1_0 = xyes)
 +
 +if test x$enable_gstreamer != xno  test x$enable_gstreamer != 
 x1.0; then
  PKG_CHECK_MODULES(GSTREAMER_0_10, [gstreamer-0.10, gstreamer-app-0.10],
 -  [enable_gstreamer=yes
 +  [enable_gstreamer=0.10
 have_gstreamer_0_10=yes],
[have_gstreamer_0_10=no])
  if test x$have_gstreamer_0_10 = xyes; then
 @@ -107,7 +125,7 @@ if test x$enable_gstreamer != xno; then
  AC_SUBST(GSTREAMER_0_10_LIBS)
  AS_VAR_APPEND([SPICE_REQUIRES], [ gstreamer-0.10 
 gstreamer-app-0.10])
  AC_DEFINE([HAVE_GSTREAMER_0_10], [1], [Define if supporting 
 GStreamer 0.10])
 -elif test x$enable_gstreamer = xyes; then
 +elif test x$enable_gstreamer = x0.10; then
  AC_MSG_ERROR([GStreamer 0.10 support requested but not found. You 
 may set GSTREAMER_0_10_CFLAGS and GSTREAMER_0_10_LIBS to avoid the need to 
 call pkg-config.])
  fi
  else
 @@ -115,6 +133,11 @@ else
  fi
  AM_CONDITIONAL(SUPPORT_GSTREAMER_0_10, test x$have_gstreamer_0_10 = xyes)
  
 +if test x$enable_gstreamer = xyes; then
 +AC_MSG_ERROR(GStreamer support requested but not found)
 +fi
 +AS_IF([test x$enable_gstreamer = xauto], [enable_gstreamer=no])
 +
  AC_ARG_ENABLE(automated_tests,
  [  --enable-automated-tests Enable automated tests using 
 spicy-screenshot (part of spice--gtk)],,
  [enable_automated_tests=no])
 @@ -382,7 +405,7 @@ echo 
  
  Smartcard:${enable_smartcard}
  
 -GStreamer 0.10:

Re: [Spice-devel] [PATCH spice-server v2 1/2] Use image compress constants from spice-protocol

2015-06-11 Thread Javier Celaya
El Jueves, 11 de junio de 2015 16:44:51 Christophe Fergeau escribió:
 On Mon, Jun 01, 2015 at 04:48:15PM +0200, Javier Celaya wrote:
  diff --git a/server/spice-server.h b/server/spice-server.h
  index bca0da6..5880ff0 100644
  --- a/server/spice-server.h
  +++ b/server/spice-server.h
  @@ -67,20 +67,9 @@ int spice_server_add_interface(SpiceServer *s,
  
  SpiceBaseInstance *sin);
   
   int spice_server_remove_interface(SpiceBaseInstance *sin);
  
  -typedef enum {
  -SPICE_IMAGE_COMPRESS_INVALID  = 0,
  -SPICE_IMAGE_COMPRESS_OFF  = 1,
  -SPICE_IMAGE_COMPRESS_AUTO_GLZ = 2,
  -SPICE_IMAGE_COMPRESS_AUTO_LZ  = 3,
  -SPICE_IMAGE_COMPRESS_QUIC = 4,
  -SPICE_IMAGE_COMPRESS_GLZ  = 5,
  -SPICE_IMAGE_COMPRESS_LZ   = 6,
  -SPICE_IMAGE_COMPRESS_LZ4  = 7,
  -} spice_image_compression_t;
 
 Removing spice_image_compression_t from spice-server.h which is a public
 header is going to break compilation of applications using it (eg QEMU),
 this needs to be replaced with
 
 typedef SpiceImageCompress spice_image_compression_t;
 
 I'll squash that in my local version.
 
 Christophe

Ooops, thanks.-- 


[1] [2]
*Javier Celaya *
/Software Engineer /
[3] j[4]_avier.celaya@flexvdi.com_ 
[5] +34 976 512 433 
[6] @j_celaya 



[1] http://www.flexvdi.com/img/general/logo.flexvdi.png
[2] http://flexvdi.com
[3] http://flexvdi.com/signature/mail.png
[4] mailto:javier.cel...@flexvdi.com
[5] http://flexvdi.com/signature/phone.png
[6] http://flexvdi.com/signature/skype.png
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [RFC PATCH] qemu: Use heads parameter for QXL driver

2015-06-11 Thread Christophe Fergeau
Hey,

On Thu, Jun 11, 2015 at 12:39:50PM +0100, Frediano Ziglio wrote:
 Allow to specify maximum number of head to QXL driver.

I've tested this with an older qemu without qxl-vga.max_outputs, and
with a newer one with support for it, and in both cases this is doing
the right thing.

 
 Signed-off-by: Frediano Ziglio fzig...@redhat.com
 ---
  src/qemu/qemu_capabilities.c |  2 ++
  src/qemu/qemu_capabilities.h |  1 +
  src/qemu/qemu_command.c  | 11 +++
  tests/qemucapabilitiesdata/caps_1.2.2-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_1.2.2-1.replies  |  8 
  tests/qemucapabilitiesdata/caps_1.3.1-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_1.3.1-1.replies  |  8 
  tests/qemucapabilitiesdata/caps_1.4.2-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_1.4.2-1.replies  |  8 
  tests/qemucapabilitiesdata/caps_1.5.3-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_1.5.3-1.replies  |  8 
  tests/qemucapabilitiesdata/caps_1.6.0-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_1.6.0-1.replies  |  8 
  tests/qemucapabilitiesdata/caps_1.6.50-1.caps|  1 +
  tests/qemucapabilitiesdata/caps_1.6.50-1.replies |  8 
  tests/qemucapabilitiesdata/caps_2.1.1-1.caps |  1 +
  tests/qemucapabilitiesdata/caps_2.1.1-1.replies  |  8 
  17 files changed, 77 insertions(+)
 
 The patch to support the max_outputs in Qemu is still not merged but
 I got agreement on the name of the argument.
 
 Actually can be a compatiblity problem as heads in the XML configuration
 was set by default to '1'.
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index ca7a7c2..cdc2575 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -285,6 +285,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
dea-key-wrap,
pci-serial,
aarch64-off,
 +  qxl-vga.max_outputs,
  );


In order to be consistent with the rest of the file, this should be

+
+  qxl-vga.max_outputs, /* 190 */
 

  
  
 @@ -1643,6 +1644,7 @@ static struct virQEMUCapsStringFlags 
 virQEMUCapsObjectPropsQxl[] = {
  
  static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxlVga[] = {
  { vgamem_mb, QEMU_CAPS_QXL_VGA_VGAMEM },
 +{ max_outputs, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS },
  };
  
  struct virQEMUCapsObjectTypeProps {
 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
 index b5a7770..a2ea84b 100644
 --- a/src/qemu/qemu_capabilities.h
 +++ b/src/qemu/qemu_capabilities.h
 @@ -229,6 +229,7 @@ typedef enum {
  QEMU_CAPS_DEA_KEY_WRAP   = 187, /* -machine dea_key_wrap */
  QEMU_CAPS_DEVICE_PCI_SERIAL  = 188, /* -device pci-serial */
  QEMU_CAPS_CPU_AARCH64_OFF= 189, /* -cpu ...,aarch64=off */
 +QEMU_CAPS_QXL_VGA_MAX_OUTPUTS = 190, /* qxl-vga.max_outputs */
  
  QEMU_CAPS_LAST,   /* this must always be the last item */
  } virQEMUCapsFlags;
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 0a6d92f..2bd63e1 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -5610,6 +5610,11 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
  /* QEMU accepts mebibytes for vgamem_mb. */
  virBufferAsprintf(buf, ,vgamem_mb=%u, video-vgamem / 1024);
  }
 +
 +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) 
 +video-heads  0) {
 +virBufferAsprintf(buf, ,max_outputs=%u, video-heads);
 +}
  } else if (video-vram 
  ((video-type == VIR_DOMAIN_VIDEO_TYPE_VGA 
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
 @@ -10234,6 +10239,7 @@ qemuBuildCommandLine(virConnectPtr conn,
  unsigned int ram = def-videos[0]-ram;
  unsigned int vram = def-videos[0]-vram;
  unsigned int vgamem = def-videos[0]-vgamem;
 +unsigned int heads = def-videos[0]-heads;
  
  if (vram  (UINT_MAX / 1024)) {
  virReportError(VIR_ERR_OVERFLOW,
 @@ -10264,6 +10270,11 @@ qemuBuildCommandLine(virConnectPtr conn,
  virCommandAddArgFormat(cmd, %s.vgamem_mb=%u,
 dev, vgamem / 1024);
  }
 +if (virQEMUCapsGet(qemuCaps, 
 QEMU_CAPS_QXL_VGA_MAX_OUTPUTS)  heads  0) {
 +virCommandAddArg(cmd, -global);
 +virCommandAddArgFormat(cmd, %s.max_outputs=%u,
 +   dev, heads);
 +}

This part of the code is a fallback for QEMU not supporting -device. As
the max_outputs option is new, I'm not sure this will ever be triggered.

  }
  
  if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) 
 diff --git 

Re: [Spice-devel] [PATCHv2] LZ4: warn if trying to set lz4 but not supported

2015-06-11 Thread Christophe Fergeau
On Tue, Jan 27, 2015 at 05:26:41PM +0100, Christophe Fergeau wrote:
 ACK.


I had this in my local tree but never pushed it, this is now done.

Christophe


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


[Spice-devel] 3D Support

2015-06-11 Thread Chris Harvey
Hey,

I currently use spice in my home. I have a server in my attic which has several 
virtual machines running on it (Windows  Linux). I then have some really low 
spec laptops and Raspberry Pi's which I use as thin clients to connect to the 
virtual machines through spice.

Pretty weird setup, but it works pretty well with HD video etc.

The only thing missing is support for 3D, primarily for desktop effects such as 
Aero or gnome shell.

Has there been much progress with 3D support, if so, is there any experimental 
spice build that I could try out? Do you think we'll ever see gaming through 
spice?

I'm really looking forward to the future of spice, it truly is an amazing 
protocol.

Anyway, apologies for the random email with questions you're probably tired of 
reading. Just figured I'd say hi and if there is anything I can do to help out 
with the development of spice then I'm very happy to.

Thanks,

Chris

Sent from my iPhone 6
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH v2 0/2] Support UsbDk backend

2015-06-11 Thread Kirill Moizik
 Hi,
What do you think about those patches, guys ?
Kirill

On Tue, Jun 9, 2015 at 3:53 PM, Kirill Moizik kir...@daynix.com wrote:

 From: Kirill Moizik kiri...@daynix.com

 UsbDk (USB Development Kit) is a set of software components meant to
 provide
 Windows user mode applications with direct and exclusive access to USB
 devices.

 Some distinctive UsbDk properties are:

 1. UsbDk supports all types of devices and interfaces - bulk, isochronous,
composite, HID etc.
 2. Device capture process is totally dynamic, i.e. no inf files and
self-signing needed, any device can be captured.
 3. UsbDk co-exists with original device driver, when the device is not
captured original driver is loaded by the system automatically.
 4. If user mode client terminates unexpectedly for any reason system
 reverts
to original device driver immediately.
 5. Being USB filter driver UsbDk doesn't require WHQL-ing
as per Microsoft requirements.

 UsbDk supports all Windows OS versions staring from Windows XP,
 i.e. XP/Vista/7/8/8.1/2003/2008/2008R2/2012/2012R2.
 Both 32 and 64 bit architectures are supported.

 UsbDk is fully open source and distributed under Apache 2.0 license.

 UsbDk project is hosted at spice-space.org, source code repository
 available at:
 http://cgit.freedesktop.org/spice/win32/usbdk

 Latest source tarball is at: \

 http://www.spice-space.org/download/windows/usbdk/spice-usbdk-win-1.0-4-sources.zip

 UsbDk releases come with precompiled and signed by Red Hat binaries:
 1. 32 bit:
 http://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.4_x86.msi
 2. 64 bit:
 http://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.4_x64.msi

 UsbDk documentation:
 1. Short presentation:
 http://www.spice-space.org/docs/usbdk/UsbDk_at_a_Glance.pdf
 2. SDM:
 http://www.spice-space.org/docs/usbdk/UsbDk_Software_Development_Manual.pdf
 3. UsbDk architecture specificatin (part of source tree):
http://cgit.freedesktop.org/spice/win32/usbdk/tree/ARCHITECTURE

 UsbDk is maintained by Dmitry Fleytman (dfley...@redhat.com) and
 Kirill Moizik (kmoi...@redhat.com) we'll be glad to answer your questions
 sent
 to us directly or via this mailing list.

  This set of patches add UsbDk backend support to spice-gtk. This series
 currently cannot be applied since it require next patches series in libusb
 http://marc.info/?l=libusb-develm=142532078226137w=2 .
 We are waiting for this patches to be commited to libusb soon and then
 this series can be applied.


 V2 changeset :
 -opaque usbdk wrapper
 -use_usbclerk instead of use_usbdk
 -use_usbclerk is DeviceManager member, not global variable
 -all v1 suggestions were applied


 Kirill Moizik (2):
   UsbDk: Add UsbDk wrapper
   UsbDk: Add UsbDk as a default backend

  src/Makefile.am  |   2 +
  src/usb-device-manager.c | 297
 +--
  src/usbdk_api.c  | 166 ++
  src/usbdk_api.h  |  34 ++
  4 files changed, 410 insertions(+), 89 deletions(-)
  create mode 100644 src/usbdk_api.c
  create mode 100644 src/usbdk_api.h

 --
 2.1.0


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


[Spice-devel] [PATCH] Add 'Send Ctrl-Alt-Delete' button to spice_auto.html

2015-06-11 Thread Felipe Reyes
This patch adds a new button aligned to the right in the top header.

OpenStack Horizon embeds spice-html5 in an iframe, but it doesn't
include this button, this is because it uses novnc as well which it
does include an equivalent button as part of its UI. Also when
loading spice_auto.html directly the lack of a button is a problem.

Fixes-Bug: #89613

Signed-off-by: Felipe Reyes felipe.re...@canonical.com
---
 spice.css   | 8 +++-
 spice_auto.html | 5 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/spice.css b/spice.css
index 5d092ba..831b4c9 100644
--- a/spice.css
+++ b/spice.css
@@ -31,6 +31,7 @@ body
 font-size: 20px;
 font-weight: bolder;
 text-shadow: #efefef 1px 1px 0px;
+float: left;
 }
 #login label { color: #ff; text-shadow: 1px 1px 0px rgba(175, 210, 220, 
0.8); }
 #login input
@@ -115,4 +116,9 @@ body
 .spice-message-error {
 color: red;
 }
-
+.spice-send-ctrl-alt-del {
+width: 650px;
+margin-left: 100px;
+margin-right: 0px;
+text-align: right;
+}
diff --git a/spice_auto.html b/spice_auto.html
index d374054..f26dbb6 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -186,6 +186,11 @@
 
 div id=login
 span class=logoSPICE/span
+div class=spice-send-ctrl-alt-del
+button type=button onclick=sendCtrlAltDel()
+Send Ctrl-Alt-Delete
+/button
+/div
 /div
 
 div id=spice-area
-- 
2.1.4

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


[Spice-devel] [PATCH] Use AS_HELP_STRING for configure options

2015-06-11 Thread Jonathon Jongsma
---
 configure.ac | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7a9fc4b..1802ff1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,30 +70,31 @@ esac
 
 dnl =
 dnl Check optional features
-AC_ARG_ENABLE(opengl,
-[  --enable-opengl Enable opengl requirement / support (not 
recommended)],,
-[enable_opengl=no])
+AC_ARG_ENABLE([opengl],
+  AS_HELP_STRING([--enable-opengl],
+  [Enable opengl requirement / support (not recommended)]),,
+  [enable_opengl=no])
 AS_IF([test x$enable_opengl != xno], [enable_opengl=yes])
 AM_CONDITIONAL(SUPPORT_GL, test x$enable_opengl = xyes)
 
-AC_ARG_ENABLE(lz4,
-[  --enable-lz4 Enable lz4 compression algorithm],,
-[enable_lz4=no])
+AC_ARG_ENABLE([lz4],
+  AS_HELP_STRING([--enable-lz4],[Enable lz4 compression 
algorithm]),,
+  [enable_lz4=no])
 AS_IF([test x$enable_lz4 != xno], [enable_lz4=yes])
 AM_CONDITIONAL(SUPPORT_LZ4, test x$enable_lz4 = xyes)
 
-AC_ARG_ENABLE(smartcard,
-[  --enable-smartcard Enable network redirection],,
-[enable_smartcard=no])
+AC_ARG_ENABLE([smartcard],
+  AS_HELP_STRING([--enable-smartcard], [Enable network 
redirection]),,
+  [enable_smartcard=no])
 AS_IF([test x$enable_smartcard != xno], [enable_smartcard=yes])
 AM_CONDITIONAL(SUPPORT_SMARTCARD, test x$enable_smartcard != xno)
 if test x$enable_smartcard = xyes; then
AC_DEFINE([USE_SMARTCARD], [1], [Define if supporting smartcard proxying])
 fi
 
-AC_ARG_ENABLE(automated_tests,
-[  --enable-automated-tests Enable automated tests using spicy-screenshot 
(part of spice--gtk)],,
-[enable_automated_tests=no])
+AC_ARG_ENABLE([automated_tests],
+  AS_HELP_STRING([--enable-automated-tests], [Enable automated 
tests using spicy-screenshot (part of spice--gtk)]),,
+  [enable_automated_tests=no])
 AS_IF([test x$enable_automated_tests != xno], 
[enable_automated_tests=yes])
 AM_CONDITIONAL(SUPPORT_AUTOMATED_TESTS, test x$enable_automated_tests != 
xno)
 
@@ -136,9 +137,9 @@ AC_SUBST(PIXMAN_CFLAGS)
 AC_SUBST(PIXMAN_LIBS)
 AS_VAR_APPEND([SPICE_REQUIRES], [ pixman-1 = 0.17.7])
 
-AC_ARG_ENABLE(celt051,
-[  --disable-celt051   Disable celt051 audio codec (enabled by 
default)],,
-[enable_celt051=yes])
+AC_ARG_ENABLE([celt051],
+  AS_HELP_STRING([--disable-celt051], [Disable celt051 audio codec 
(enabled by default)]),,
+  [enable_celt051=yes])
 
 if test x$enable_celt051 = xyes; then
 PKG_CHECK_MODULES(CELT051, celt051 = 0.5.1.1, 
AS_VAR_APPEND([SPICE_REQUIRES], [ celt051 = 0.5.1.1]))
-- 
2.1.0

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


[Spice-devel] [PATCH spice 12/12] server: Add h264 support to the GStreamer video encoder. (take 3b)

2015-06-11 Thread Francois Gouget
Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

Updated so it applies after the VP8 'take 3b' patch.


diff --git a/server/gstreamer_encoder.c b/server/gstreamer_encoder.c
index c638c3e..58c4c7e 100644
--- a/server/gstreamer_encoder.c
+++ b/server/gstreamer_encoder.c
@@ -206,6 +206,9 @@ static gboolean construct_pipeline(GstEncoder *encoder, 
const SpiceBitmap *bitma
 case SPICE_VIDEO_CODEC_TYPE_VP8:
 gstenc_name = vp8enc;
 break;
+case SPICE_VIDEO_CODEC_TYPE_H264:
+gstenc_name = x264enc;
+break;
 default:
 spice_warning(unsupported codec type %d, encoder-base.codec_type);
 return FALSE;
@@ -262,6 +265,17 @@ static gboolean construct_pipeline(GstEncoder *encoder, 
const SpiceBitmap *bitma
  NULL);
 break;
 }
+case SPICE_VIDEO_CODEC_TYPE_H264:
+g_object_set(G_OBJECT(encoder-gstenc),
+ bitrate, encoder-bit_rate / 1024,
+ byte-stream, TRUE,
+ aud, FALSE,
+ tune, 4, /* Zero latency */
+ intra-refresh, TRUE,
+ sliced-threads, TRUE,
+ speed-preset, 1, /* ultrafast */
+ NULL);
+break;
 default:
 spice_warning(unknown encoder type %d, encoder-base.codec_type);
 reset_pipeline(encoder);
@@ -601,7 +615,8 @@ GstEncoder *create_gstreamer_encoder(SpiceVideoCodecType 
codec_type, uint64_t st
 
 spice_assert(!cbs || (cbs  cbs-get_roundtrip_ms  
cbs-get_source_fps));
 if (codec_type != SPICE_VIDEO_CODEC_TYPE_MJPEG 
-codec_type != SPICE_VIDEO_CODEC_TYPE_VP8) {
+codec_type != SPICE_VIDEO_CODEC_TYPE_VP8 
+codec_type != SPICE_VIDEO_CODEC_TYPE_H264) {
 spice_warning(unsupported codec type %d, codec_type);
 return NULL;
 }
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 08623e2..a034949 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -267,12 +267,14 @@ static create_video_encoder_proc video_encoder_procs[] = {
 static const EnumNames video_codec_names[] = {
 {SPICE_VIDEO_CODEC_TYPE_MJPEG, mjpeg},
 {SPICE_VIDEO_CODEC_TYPE_VP8, vp8},
+{SPICE_VIDEO_CODEC_TYPE_H264, h264},
 {0, NULL},
 };
 
 static const EnumNames video_cap_names[] = {
 {SPICE_DISPLAY_CAP_CODEC_MJPEG, mjpeg},
 {SPICE_DISPLAY_CAP_CODEC_VP8, vp8},
+{SPICE_DISPLAY_CAP_CODEC_H264, h264},
 {0, NULL},
 };
 
-- 
2.1.4
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice 1/2] server: Refresh the input fps every 5 second, without a timer.

2015-06-11 Thread Marc-André Lureau
Hi

On Thu, Jun 11, 2015 at 7:39 PM, Francois Gouget fgou...@codeweavers.com
wrote:

 Signed-off-by: Francois Gouget fgou...@codeweavers.com
 ---

 This implements Marc-André Lureau's suggestion:
 http://lists.freedesktop.org/archives/spice-devel/2015-June/020202.html

 And supersedes the input-fps rounding patch.
 http://lists.freedesktop.org/archives/spice-devel/2015-June/020176.html


  server/red_worker.c | 45 +++--
  1 file changed, 15 insertions(+), 30 deletions(-)

 diff --git a/server/red_worker.c b/server/red_worker.c
 index 5deb30b..a07a78a 100644
 --- a/server/red_worker.c
 +++ b/server/red_worker.c
 @@ -120,7 +120,7 @@
  #define RED_STREAM_GRADUAL_FRAMES_START_CONDITION 0.2
  #define RED_STREAM_FRAMES_RESET_CONDITION 100
  #define RED_STREAM_MIN_SIZE (96 * 96)
 -#define RED_STREAM_INPUT_FPS_TIMEOUT (5 * 1000) // 5 sec
 +#define RED_STREAM_INPUT_FPS_TIMEOUT ((uint64_t)5 * 1000 * 1000 * 1000)
 // 5 sec
  #define RED_STREAM_CHANNEL_CAPACITY 0.8
  /* the client's stream report frequency is the minimum of the 2 values
 below */
  #define RED_STREAM_CLIENT_REPORT_WINDOW 5 // #frames
 @@ -450,9 +450,8 @@ struct Stream {
  Stream *next;
  RingItem link;

 -SpiceTimer *input_fps_timer;
  uint32_t num_input_frames;
 -uint64_t input_fps_timer_start;
 +uint64_t input_fps_start_time;
  uint32_t input_fps;
  };

 @@ -2532,9 +2531,6 @@ static int is_same_drawable(RedWorker *worker,
 Drawable *d1, Drawable *d2)

  static inline void red_free_stream(RedWorker *worker, Stream *stream)
  {
 -if (stream-input_fps_timer) {
 -spice_timer_remove(stream-input_fps_timer);
 -}
  stream-next = worker-free_streams;
  worker-free_streams = stream;
  }
 @@ -2613,7 +2609,17 @@ static void red_attach_stream(RedWorker *worker,
 Drawable *drawable, Stream *str
  stream-current = drawable;
  drawable-stream = stream;
  stream-last_time = drawable-creation_time;
 -stream-num_input_frames++;
 +
 +uint64_t duration = drawable-creation_time -
 stream-input_fps_start_time;
 +if (duration = RED_STREAM_INPUT_FPS_TIMEOUT) {
 +/* Round to the nearest integer, for instance 24 for 23.976 */
 +stream-input_fps = ((uint64_t)stream-num_input_frames * 1000 *
 1000 * 1000 + duration / 2) / duration;
 +spice_debug(input-fps=%u, stream-input_fps);
 +stream-num_input_frames = 0;
 +stream-input_fps_start_time = drawable-creation_time;


Every time RED_STREAM_INPUT_FPS_TIMEOUT elpased and a new frame comes,
input_fps is updated.

Patch looks good to me, I haven't tested it though.

+} else {
 +stream-num_input_frames++;
 +}

  WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
  StreamAgent *agent;
 @@ -3123,24 +3129,6 @@ static void
 red_display_create_stream(DisplayChannelClient *dcc, Stream *stream)
  #endif
  }

 -static void red_stream_input_fps_timer_cb(void *opaque)
 -{
 -Stream *stream = opaque;
 -uint64_t now = red_now();
 -double duration_sec;
 -
 -spice_assert(opaque);
 -if (now == stream-input_fps_timer_start) {
 -spice_warning(timer start and expiry time are equal);
 -return;
 -}
 -duration_sec = (now -
 stream-input_fps_timer_start)/(1000.0*1000*1000);
 -stream-input_fps = stream-num_input_frames / duration_sec;
 -spice_debug(input-fps=%u, stream-input_fps);
 -stream-num_input_frames = 0;
 -stream-input_fps_timer_start = now;
 -}
 -
  static void red_create_stream(RedWorker *worker, Drawable *drawable)
  {
  DisplayChannelClient *dcc;
 @@ -3167,12 +3155,9 @@ static void red_create_stream(RedWorker *worker,
 Drawable *drawable)
  SpiceBitmap *bitmap =
 drawable-red_drawable-u.copy.src_bitmap-u.bitmap;
  stream-top_down = !!(bitmap-flags  SPICE_BITMAP_FLAGS_TOP_DOWN);
  drawable-stream = stream;
 -stream-input_fps_timer =
 spice_timer_queue_add(red_stream_input_fps_timer_cb, stream);
 -spice_assert(stream-input_fps_timer);
 -spice_timer_set(stream-input_fps_timer,
 RED_STREAM_INPUT_FPS_TIMEOUT);
 -stream-num_input_frames = 0;
 -stream-input_fps_timer_start = red_now();
  stream-input_fps = MAX_FPS;
 +stream-num_input_frames = 0;
 +stream-input_fps_start_time = drawable-creation_time;
  worker-streams_size_total += stream-width * stream-height;
  worker-stream_count++;
  WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
 --
 2.1.4
 ___
 Spice-devel mailing list
 Spice-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/spice-devel




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


[Spice-devel] [PATCH spice 7/12] server: Add VP8 support, a video codec preference list and compatibility checks with the Spice client. (take 3b)

2015-06-11 Thread Francois Gouget
The video encoder preferences can be expressed by building a semi-colon 
separated list of
encoder:codec pairs. For instance 'gstreamer:vp8;spice:mjpeg' to pick first the 
GStreamer VP8
video encoder first and used the original MJPEG video encoder one as a fallback.
The server has a default preference list which can also be selected by 
specifying 'auto' as the
preferences list.
The client compatibility check relies on the following new capabilities:
 * SPICE_DISPLAY_CAP_MULTI_CODEC which denotes a recent client that supports 
multiple codecs.
This capability is needed to not have to hardcode that MJPEG is supported. This 
makes it possible
to write clients that don't support MJPEG.
 * SPICE_DISPLAY_CAP_CODEC_XXX, where XXX is a supported codec, for now MJPEG 
and VP8.

Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

On Thu, 11 Jun 2015, Fabio Fantoni wrote:
[...]
  ../../server/.libs/libspice-server.so: undefined reference to
  `g_get_num_processors'

 toso in spice chat told that was added in glib 2.36check 
pkg-config
 --modversion glib-2.0 (this should probably bump the configure version
 for glib tho)

I think it's better to check directly for the presence of 
g_get_num_processors(). That way it works even if some distribution 
decides to backport it or removes it later on. Here is an updated patch. 
Note that this will impact the GStreamer 1.0 and h264 patches that 
follow.


diff --git a/configure.ac b/configure.ac
index 34e1a4a..ed3a337 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,10 @@ fi
 PKG_CHECK_MODULES([GLIB2], [glib-2.0 = 2.22])
 AS_VAR_APPEND([SPICE_REQUIRES], [ glib-2.0 = 2.22])
 
+AC_CHECK_LIB(glib-2.0, g_get_num_processors,
+ AC_DEFINE([HAVE_G_GET_NUMPROCESSORS], 1, [Defined if we have 
g_get_num_processors()]),,
+ $GLIB2_LIBS)
+
 PKG_CHECK_MODULES(PIXMAN, pixman-1 = 0.17.7)
 AC_SUBST(PIXMAN_CFLAGS)
 AC_SUBST(PIXMAN_LIBS)
diff --git a/server/gstreamer_encoder.c b/server/gstreamer_encoder.c
index 3600b1b..8fa9071 100644
--- a/server/gstreamer_encoder.c
+++ b/server/gstreamer_encoder.c
@@ -178,10 +178,27 @@ static gboolean set_appsrc_caps(GstEncoder *encoder)
 
 static gboolean construct_pipeline(GstEncoder *encoder, const SpiceBitmap 
*bitmap)
 {
+gboolean no_clock = FALSE;
+const gchar* gstenc_name;
+switch (encoder-base.codec_type)
+{
+case SPICE_VIDEO_CODEC_TYPE_MJPEG:
+gstenc_name = ffenc_mjpeg;
+no_clock = TRUE;
+break;
+case SPICE_VIDEO_CODEC_TYPE_VP8:
+gstenc_name = vp8enc;
+break;
+default:
+spice_warning(unsupported codec type %d, encoder-base.codec_type);
+return FALSE;
+}
+
 GError *err = NULL;
-const gchar* desc = appsrc name=src format=2 do-timestamp=true ! 
ffmpegcolorspace ! ffenc_mjpeg name=encoder ! appsink name=sink;
+gchar *desc = g_strdup_printf(appsrc name=src format=2 do-timestamp=true 
! ffmpegcolorspace ! %s name=encoder ! appsink name=sink, gstenc_name);
 spice_debug(GStreamer pipeline: %s, desc);
 encoder-pipeline = gst_parse_launch_full(desc, NULL, 
GST_PARSE_FLAG_FATAL_ERRORS, err);
+g_free(desc);
 if (!encoder-pipeline) {
 spice_warning(GStreamer error: %s, err-message);
 g_clear_error(err);
@@ -191,19 +208,36 @@ static gboolean construct_pipeline(GstEncoder *encoder, 
const SpiceBitmap *bitma
 encoder-gstenc = gst_bin_get_by_name(GST_BIN(encoder-pipeline), 
encoder);
 encoder-appsink = 
GST_APP_SINK(gst_bin_get_by_name(GST_BIN(encoder-pipeline), sink));
 
+/* Set the encoder initial bit rate, and ask for a low latency */
+adjust_bit_rate(encoder);
+g_object_set(G_OBJECT(encoder-gstenc), bitrate, encoder-bit_rate, 
NULL);
+if (encoder-base.codec_type == SPICE_VIDEO_CODEC_TYPE_VP8) {
+/* See http://www.webmproject.org/docs/encoder-parameters/ */
+#ifdef HAVE_G_GET_NUMPROCESSORS
+int core_count = g_get_num_processors();
+#else
+int core_count = 1;
+#endif
+g_object_set(G_OBJECT(encoder-gstenc),
+ mode, 1, /* CBR */
+ max-latency, 0,
+ speed, 7,
+ resize-allowed, TRUE,
+ threads, core_count - 1,
+ NULL);
+   }
+
 /* Set the source caps */
 encoder-src_caps = NULL;
 if (!set_appsrc_caps(encoder)) {
 return FALSE;
 }
 
-/* Set the encoder initial bit rate */
-adjust_bit_rate(encoder);
-g_object_set(G_OBJECT(encoder-gstenc), bitrate, encoder-bit_rate, 
NULL);
-
 /* Start playing */
-spice_debug(removing the pipeline clock);
-gst_pipeline_use_clock(GST_PIPELINE(encoder-pipeline), NULL);
+if (no_clock) {
+spice_debug(removing the pipeline clock);
+gst_pipeline_use_clock(GST_PIPELINE(encoder-pipeline), NULL);
+}
 spice_debug(setting state to PLAYING);
 if (gst_element_set_state(encoder-pipeline, GST_STATE_PLAYING) == 

[Spice-devel] [PATCH spice 10/12] server: Add GStreamer 1.0 support. (take 3b)

2015-06-11 Thread Francois Gouget
Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

Updated so it applies after the new VP8 patch.

diff --git a/configure.ac b/configure.ac
index ed3a337..6a5ddb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,14 +92,32 @@ if test x$enable_smartcard = xyes; then
 fi
 
 AC_ARG_ENABLE(gstreamer,
-  AS_HELP_STRING([--enable-gstreamer=@:@auto/yes/no@:@],
- [Enable GStreamer 0.10 support]),
+  AS_HELP_STRING([--enable-gstreamer=@:@auto/0.10/1.0/yes/no@:@],
+ [Enable GStreamer support]),
   [],
   [enable_gstreamer=auto])
 
-if test x$enable_gstreamer != xno; then
+if test x$enable_gstreamer != xno  test x$enable_gstreamer != x0.10; 
then
+PKG_CHECK_MODULES(GSTREAMER_1_0, [gstreamer-1.0, gstreamer-app-1.0],
+  [enable_gstreamer=1.0
+   have_gstreamer_1_0=yes],
+  [have_gstreamer_1_0=no])
+if test x$have_gstreamer_1_0 = xyes; then
+AC_SUBST(GSTREAMER_1_0_CFLAGS)
+AC_SUBST(GSTREAMER_1_0_LIBS)
+AS_VAR_APPEND([SPICE_REQUIRES], [ gstreamer-1.0 gstreamer-app-1.0])
+AC_DEFINE([HAVE_GSTREAMER_1_0], [1], [Define if supporting GStreamer 
1.0])
+elif test x$enable_gstreamer = x1.0; then
+AC_MSG_ERROR([GStreamer 1.0 support requested but not found. You may 
set GSTREAMER_1_0_CFLAGS and GSTREAMER_1_0_LIBS to avoid the need to call 
pkg-config.])
+fi
+else
+have_gstreamer_1_0=no
+fi
+AM_CONDITIONAL(SUPPORT_GSTREAMER_1_0, test x$have_gstreamer_1_0 = xyes)
+
+if test x$enable_gstreamer != xno  test x$enable_gstreamer != x1.0; 
then
 PKG_CHECK_MODULES(GSTREAMER_0_10, [gstreamer-0.10, gstreamer-app-0.10],
-  [enable_gstreamer=yes
+  [enable_gstreamer=0.10
have_gstreamer_0_10=yes],
   [have_gstreamer_0_10=no])
 if test x$have_gstreamer_0_10 = xyes; then
@@ -107,7 +125,7 @@ if test x$enable_gstreamer != xno; then
 AC_SUBST(GSTREAMER_0_10_LIBS)
 AS_VAR_APPEND([SPICE_REQUIRES], [ gstreamer-0.10 gstreamer-app-0.10])
 AC_DEFINE([HAVE_GSTREAMER_0_10], [1], [Define if supporting GStreamer 
0.10])
-elif test x$enable_gstreamer = xyes; then
+elif test x$enable_gstreamer = x0.10; then
 AC_MSG_ERROR([GStreamer 0.10 support requested but not found. You may 
set GSTREAMER_0_10_CFLAGS and GSTREAMER_0_10_LIBS to avoid the need to call 
pkg-config.])
 fi
 else
@@ -115,6 +133,11 @@ else
 fi
 AM_CONDITIONAL(SUPPORT_GSTREAMER_0_10, test x$have_gstreamer_0_10 = xyes)
 
+if test x$enable_gstreamer = xyes; then
+AC_MSG_ERROR(GStreamer support requested but not found)
+fi
+AS_IF([test x$enable_gstreamer = xauto], [enable_gstreamer=no])
+
 AC_ARG_ENABLE(automated_tests,
 [  --enable-automated-tests Enable automated tests using spicy-screenshot 
(part of spice--gtk)],,
 [enable_automated_tests=no])
@@ -386,7 +409,7 @@ echo 
 
 Smartcard:${enable_smartcard}
 
-GStreamer 0.10:   ${have_gstreamer_0_10}
+GStreamer:${enable_gstreamer}
 
 SASL support: ${enable_sasl}
 
diff --git a/server/Makefile.am b/server/Makefile.am
index 4921bc3..9fb0c8e 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -12,6 +12,7 @@ AM_CPPFLAGS = \
$(SLIRP_CFLAGS) \
$(SMARTCARD_CFLAGS) \
$(GSTREAMER_0_10_CFLAGS)\
+   $(GSTREAMER_1_0_CFLAGS) \
$(SSL_CFLAGS)   \
$(VISIBILITY_HIDDEN_CFLAGS) \
$(WARN_CFLAGS)  \
@@ -42,7 +43,8 @@ libspice_server_la_LIBADD =   
\
$(PIXMAN_LIBS)  \
$(SASL_LIBS)\
$(SLIRP_LIBS)   \
-   $(GSTREAMER_0_10_LIBS)  
\
+   $(GSTREAMER_0_10_LIBS)  \
+   $(GSTREAMER_1_0_LIBS)   \
$(SSL_LIBS) \
$(Z_LIBS)   \
$(SPICE_NONPKGCONFIG_LIBS)  \
@@ -142,7 +144,13 @@ endif
 
 if SUPPORT_GSTREAMER_0_10
 libspice_server_la_SOURCES +=  \
-   gstreamer_encoder.c \
+   gstreamer_encoder.c \
+   $(NULL)
+endif
+
+if SUPPORT_GSTREAMER_1_0
+libspice_server_la_SOURCES +=  \
+   gstreamer_encoder.c \
$(NULL)
 endif
 
diff --git a/server/gstreamer_encoder.c b/server/gstreamer_encoder.c
index 8fa9071..0743879 100644
--- 

[Spice-devel] [PATCH spice-gtk] channel-main: Notify about existence of monitor

2015-06-11 Thread Pavel Grunt
SpiceMainChannel should be notify about existence of monitors
assigned to a SpiceDisplayChannel, even when the SpiceDisplayChannel
is not connected to a SpiceDisplay widget. Otherwise the automatic
resizing (the resize-guest property) of SpiceDisplay will not work
when there is more display channels than SpiceDisplays.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=90914
---
 src/channel-main.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index c55d097..fbc41da 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1580,18 +1580,36 @@ static void main_handle_mm_time(SpiceChannel *channel, 
SpiceMsgIn *in)
 spice_session_set_mm_time(session, msg-time);
 }
 
+static void main_enable_monitor(SpiceChannel *channel, GParamSpec *pspec 
G_GNUC_UNUSED,
+SpiceMainChannel *main_channel)
+{
+gint channel_id = spice_channel_get_channel_id(channel);
+
+g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
+g_return_if_fail(channel_id  MAX_DISPLAY);
+g_return_if_fail(main_channel != NULL  main_channel-priv != NULL);
+
+main_channel-priv-display[channel_id].enabled_set = TRUE;
+}
+
 typedef struct channel_new {
 SpiceSession *session;
 int type;
 int id;
+SpiceMainChannel *main_channel;
 } channel_new_t;
 
 /* main context */
 static gboolean _channel_new(channel_new_t *c)
 {
+SpiceChannel *channel;
 g_return_val_if_fail(c != NULL, FALSE);
 
-spice_channel_new(c-session, c-type, c-id);
+channel = spice_channel_new(c-session, c-type, c-id);
+if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
+spice_g_signal_connect_object(channel, notify::monitors,
+  G_CALLBACK(main_enable_monitor), 
c-main_channel, 0);
+}
 
 g_object_unref(c-session);
 g_free(c);
@@ -1619,6 +1637,7 @@ static void main_handle_channels_list(SpiceChannel 
*channel, SpiceMsgIn *in)
 c-session = g_object_ref(session);
 c-type = msg-channels[i].type;
 c-id = msg-channels[i].id;
+c-main_channel = SPICE_MAIN_CHANNEL(channel);
 /* no need to explicitely switch to main context, since
synchronous call is not needed. */
 /* no need to track idle, session is refed */
-- 
2.4.3

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


Re: [Spice-devel] 2K/4K resolutions not available?

2015-06-11 Thread Mike

Hi Christophe,

	I was using just spicec as the viewer in full screen mode, but trying 
remote-viewer doesn't seem to make any difference (full-screen or 
windowed mode), it just scales the guest display (and results in blurry 
text) and doesn't actually change the resolution on the guest side. I 
checked and spice-vdagent/spice-vdagentd are running in the guest as 
well and the log shows connections to it being made...


Using the script Gerd posted to force xrandr to change the resolution 
does work for a few minutes, but as soon as I try to launch some 
applications like Libreoffice Writer it crashes X immediately. It also 
seems to cause all sorts of other strange issues with the window manager 
(title bars disappear and reappear, etc...)




On 06/11/2015 03:04 AM, Christophe Fergeau wrote:

Hey,

On Wed, Jun 10, 2015 at 03:37:09PM -0700, Mike wrote:

I'm trying to get 2K+ resolutions to work with SPICE/QXL and QEMU 2.2
(Ubuntu Vivid) on the host and Ubuntu Trusty on the guest. Currently the
highest resolution is 1920x1200... I tried increasing the QXL video memory
to 128MB from 64MB, but that didn't seem to make a difference, is there
something simple I'm missing perhaps?


These resolutions are missing from the drm driver
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/qxl/qxl_display.c#n175
booting with nomodeset should make them 'appear' in the guest (but
better not to do that).

With remote-viewer/gnome-boxes, you should be able to resize the guest
window to any size you want, including the higher resolutions you are
looking for. Is this not working?

Christophe



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


Re: [Spice-devel] [PATCH v2 1/2] UsbDk: Add UsbDk wrapper

2015-06-11 Thread Christophe Fergeau
Hey,

I think I forgot to mention this in the initial review, but GModule
might probably have been useful as a wrapper for the GetProcAddress
calls. As we only need to do that on Windows, GModule VS direct win32
API calls do not bring us much.

I'd squash the attached patch in with just some cosmetic changes,
SPICE_DEBUG changed to g_warning in unexpected error cases, and
a licence header more in line with the rest of the code (I picked (C)
2014-2015, let me know if this should be adjusted). One question below:

On Tue, Jun 09, 2015 at 03:53:01PM +0300, Kirill Moizik wrote:
 +void usbdk_api_set_hide_rules(usbdk_api_wrapper *usbdk_api, HANDLE 
 hider_handle, gchar *redirect_on_connect)
 +{
 +struct usbredirfilter_rule *rules;
 +int r, count;
 +
 +r = usbredirfilter_string_to_rules(redirect_on_connect, ,, |, 
 rules, count);
 +if (r) {
 +SPICE_DEBUG(auto-connect rules parsing failed with error %d, r);
 +return;
 +}
 +
 +for (int i = 0; i  count; i++) {
 +USB_DK_HIDE_RULE rule;
 +rule.Hide  = (uint64_t)rules[i].allow;
 +rule.Class = (uint64_t)rules[i].device_class;
 +rule.VID   = (uint64_t)rules[i].vendor_id;
 +rule.PID   = (uint64_t)rules[i].product_id;
 +rule.BCD   = (uint64_t)rules[i].device_version_bcd;

Some of the int values stored in the usbredirfilter_rule can be -1, is
usbdk able to cope with these values?

Christophe
diff --git a/spice-common b/spice-common
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit fec803156b1844a2deb705cf55933294ca60a5ea
+Subproject commit fec803156b1844a2deb705cf55933294ca60a5ea-dirty
diff --git a/src/usbdk_api.c b/src/usbdk_api.c
index f71dee5..f514825 100644
--- a/src/usbdk_api.c
+++ b/src/usbdk_api.c
@@ -1,24 +1,25 @@
 /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
-Copyright (C) 2011, 2012 Red Hat, Inc.
+   Copyright (C) 2014-2015 Red Hat, Inc.
 
-* Authors:
-* Dmitry Fleytman dmi...@daynix.com
-* Kirill Moizik kir...@daynix.com
-his library is free software; you can redistribute it and/or
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, see http://www.gnu.org/licenses/.
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see http://www.gnu.org/licenses/.
+
+  Authors:
+Dmitry Fleytman dmi...@daynix.com
+Kirill Moizik kir...@daynix.com
 */
+#include config.h
 
 #include windows.h
 #include glib-object.h
@@ -70,20 +71,17 @@ BOOL usbdk_is_driver_installed(void) {
 void usbdk_api_unload(usbdk_api_wrapper *usbdk_api) {
 SPICE_DEBUG(Unloading UsbDk API DLL);
 FreeLibrary(usbdk_api-module);
-free(usbdk_api);
+g_free(usbdk_api);
 }
 
 int usbdk_api_load(usbdk_api_wrapper **usbdk_api) {
 SPICE_DEBUG(Loading UsbDk API DLL);
-*usbdk_api = (usbdk_api_wrapper *) malloc(sizeof(usbdk_api_wrapper));
-if(*usbdk_api == NULL) {
-return -1;
-}
 
+*usbdk_api = g_new0(usbdk_api_wrapper, 1);
 (*usbdk_api)-module = LoadLibraryA(UsbDkHelper);
 if ((*usbdk_api)-module == NULL) {
-usbdk_api_unload(*usbdk_api);
 DWORD err = GetLastError();
+usbdk_api_unload(*usbdk_api);
 SPICE_DEBUG(Failed to load UsbDkHelper.dll, error %lu, err);
 return -1 ;
 }
@@ -91,21 +89,21 @@ int usbdk_api_load(usbdk_api_wrapper **usbdk_api) {
 (*usbdk_api)-CreateHandle = (USBDK_CREATEHIDERHANDLE)
 GetProcAddress((*usbdk_api)-module, UsbDk_CreateHiderHandle);
 if ((*usbdk_api)-CreateHandle == NULL) {
-SPICE_DEBUG(CreateHandle);
+g_warning(Failed to find CreateHandle entry point);
 goto error_unload;
 }
 
 (*usbdk_api)-AddRule = (USBDK_ADDHIDERULE)
 GetProcAddress((*usbdk_api)-module, UsbDk_AddHideRule);
 if ((*usbdk_api)-AddRule == NULL) {
-SPICE_DEBUG(AddRule);
+g_warning(Failed to find AddRule 

[Spice-devel] [PATCH spice] HAVE_CLOCK_GETTIME is not used so remove it.

2015-06-11 Thread Francois Gouget
Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

Maybe we should actually use it but currently clock_gettime() uses are 
all over the place and this macro was only used in the client code 
anyway (see 18769714 and 3f3283ee).

 configure.ac | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7a9fc4b..62c714e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,10 +108,7 @@ AC_SUBST(COMMON_CFLAGS)
 AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
-AC_CHECK_LIB(rt, clock_gettime,
-   AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [Defined if we have clock_gettime()])
-   LIBRT=-lrt
-   )
+AC_CHECK_LIB(rt, clock_gettime, LIBRT=-lrt)
 AC_SUBST(LIBRT)
 
 AS_VAR_APPEND([SPICE_NONPKGCONFIG_LIBS], [ -pthread $LIBM $LIBRT])
-- 
2.1.4

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


[Spice-devel] [PATCH spice 1/2] server: Refresh the input fps every 5 second, without a timer.

2015-06-11 Thread Francois Gouget
Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

This implements Marc-André Lureau's suggestion:
http://lists.freedesktop.org/archives/spice-devel/2015-June/020202.html

And supersedes the input-fps rounding patch.
http://lists.freedesktop.org/archives/spice-devel/2015-June/020176.html


 server/red_worker.c | 45 +++--
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index 5deb30b..a07a78a 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -120,7 +120,7 @@
 #define RED_STREAM_GRADUAL_FRAMES_START_CONDITION 0.2
 #define RED_STREAM_FRAMES_RESET_CONDITION 100
 #define RED_STREAM_MIN_SIZE (96 * 96)
-#define RED_STREAM_INPUT_FPS_TIMEOUT (5 * 1000) // 5 sec
+#define RED_STREAM_INPUT_FPS_TIMEOUT ((uint64_t)5 * 1000 * 1000 * 1000) // 5 
sec
 #define RED_STREAM_CHANNEL_CAPACITY 0.8
 /* the client's stream report frequency is the minimum of the 2 values below */
 #define RED_STREAM_CLIENT_REPORT_WINDOW 5 // #frames
@@ -450,9 +450,8 @@ struct Stream {
 Stream *next;
 RingItem link;
 
-SpiceTimer *input_fps_timer;
 uint32_t num_input_frames;
-uint64_t input_fps_timer_start;
+uint64_t input_fps_start_time;
 uint32_t input_fps;
 };
 
@@ -2532,9 +2531,6 @@ static int is_same_drawable(RedWorker *worker, Drawable 
*d1, Drawable *d2)
 
 static inline void red_free_stream(RedWorker *worker, Stream *stream)
 {
-if (stream-input_fps_timer) {
-spice_timer_remove(stream-input_fps_timer);
-}
 stream-next = worker-free_streams;
 worker-free_streams = stream;
 }
@@ -2613,7 +2609,17 @@ static void red_attach_stream(RedWorker *worker, 
Drawable *drawable, Stream *str
 stream-current = drawable;
 drawable-stream = stream;
 stream-last_time = drawable-creation_time;
-stream-num_input_frames++;
+
+uint64_t duration = drawable-creation_time - stream-input_fps_start_time;
+if (duration = RED_STREAM_INPUT_FPS_TIMEOUT) {
+/* Round to the nearest integer, for instance 24 for 23.976 */
+stream-input_fps = ((uint64_t)stream-num_input_frames * 1000 * 1000 
* 1000 + duration / 2) / duration;
+spice_debug(input-fps=%u, stream-input_fps);
+stream-num_input_frames = 0;
+stream-input_fps_start_time = drawable-creation_time;
+} else {
+stream-num_input_frames++;
+}
 
 WORKER_FOREACH_DCC_SAFE(worker, item, next, dcc) {
 StreamAgent *agent;
@@ -3123,24 +3129,6 @@ static void 
red_display_create_stream(DisplayChannelClient *dcc, Stream *stream)
 #endif
 }
 
-static void red_stream_input_fps_timer_cb(void *opaque)
-{
-Stream *stream = opaque;
-uint64_t now = red_now();
-double duration_sec;
-
-spice_assert(opaque);
-if (now == stream-input_fps_timer_start) {
-spice_warning(timer start and expiry time are equal);
-return;
-}
-duration_sec = (now - stream-input_fps_timer_start)/(1000.0*1000*1000);
-stream-input_fps = stream-num_input_frames / duration_sec;
-spice_debug(input-fps=%u, stream-input_fps);
-stream-num_input_frames = 0;
-stream-input_fps_timer_start = now;
-}
-
 static void red_create_stream(RedWorker *worker, Drawable *drawable)
 {
 DisplayChannelClient *dcc;
@@ -3167,12 +3155,9 @@ static void red_create_stream(RedWorker *worker, 
Drawable *drawable)
 SpiceBitmap *bitmap = drawable-red_drawable-u.copy.src_bitmap-u.bitmap;
 stream-top_down = !!(bitmap-flags  SPICE_BITMAP_FLAGS_TOP_DOWN);
 drawable-stream = stream;
-stream-input_fps_timer = 
spice_timer_queue_add(red_stream_input_fps_timer_cb, stream);
-spice_assert(stream-input_fps_timer);
-spice_timer_set(stream-input_fps_timer, RED_STREAM_INPUT_FPS_TIMEOUT);
-stream-num_input_frames = 0;
-stream-input_fps_timer_start = red_now();
 stream-input_fps = MAX_FPS;
+stream-num_input_frames = 0;
+stream-input_fps_start_time = drawable-creation_time;
 worker-streams_size_total += stream-width * stream-height;
 worker-stream_count++;
 WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
-- 
2.1.4___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice 2/2] server: Provide a framerate estimate based on the frames that lead to the stream creation.

2015-06-11 Thread Francois Gouget
This way the video encoder can actually count on a real estimate when it is 
initializing.

Signed-off-by: Francois Gouget fgou...@codeweavers.com
---

Initialisation time is when video encoders need an fps most since they 
have no other information at that point. Yet, all they were getting is 
MAX_FPS (30).

This patch takes advantage of the fact that Spice needs to keep track of 
the related drawables in order to determine whether creating a video 
stream makes sense. So it stores the time of the first drawable and then 
propagates it. So when the time comes to create the stream we can 
provide a framerate estimate based on the first 20 frames. In my tests 
the result falls within one 1 fps of the later estimates and thus is 
much more useful than MAX_FPS.

 server/red_worker.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/server/red_worker.c b/server/red_worker.c
index a07a78a..8374f54 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -844,6 +844,7 @@ struct Drawable {
 Ring glz_ring;
 
 red_time_t creation_time;
+red_time_t first_frame_time;
 int frames_count;
 int gradual_frames_count;
 int last_gradual_frame;
@@ -915,6 +916,7 @@ typedef struct RedSurface {
 
 typedef struct ItemTrace {
 red_time_t time;
+red_time_t first_frame_time;
 int frames_count;
 int gradual_frames_count;
 int last_gradual_frame;
@@ -1926,6 +1928,7 @@ static inline void red_add_item_trace(RedWorker *worker, 
Drawable *item)
 
 trace = worker-items_trace[worker-next_item_trace++  ITEMS_TRACE_MASK];
 trace-time = item-creation_time;
+trace-first_frame_time = item-first_frame_time;
 trace-frames_count = item-frames_count;
 trace-gradual_frames_count = item-gradual_frames_count;
 trace-last_gradual_frame = item-last_gradual_frame;
@@ -3155,7 +3158,12 @@ static void red_create_stream(RedWorker *worker, 
Drawable *drawable)
 SpiceBitmap *bitmap = drawable-red_drawable-u.copy.src_bitmap-u.bitmap;
 stream-top_down = !!(bitmap-flags  SPICE_BITMAP_FLAGS_TOP_DOWN);
 drawable-stream = stream;
-stream-input_fps = MAX_FPS;
+/* Provide an fps estimate the video encoder can use when initializing
+ * based on the frames that lead to the creation of the stream. Round to
+ * the nearest integer, for instance 24 for 23.976.
+ */
+uint64_t duration = drawable-creation_time - drawable-first_frame_time;
+stream-input_fps = ((uint64_t)drawable-frames_count * 1000 * 1000 * 1000 
+ duration / 2) / duration;
 stream-num_input_frames = 0;
 stream-input_fps_start_time = drawable-creation_time;
 worker-streams_size_total += stream-width * stream-height;
@@ -3163,9 +3171,9 @@ static void red_create_stream(RedWorker *worker, Drawable 
*drawable)
 WORKER_FOREACH_DCC_SAFE(worker, dcc_ring_item, next, dcc) {
 red_display_create_stream(dcc, stream);
 }
-spice_debug(stream %d %dx%d (%d, %d) (%d, %d), (int)(stream - 
worker-streams_buf), stream-width,
+spice_debug(stream %d %dx%d (%d, %d) (%d, %d) %u fps, (int)(stream - 
worker-streams_buf), stream-width,
 stream-height, stream-dest_area.left, stream-dest_area.top,
-stream-dest_area.right, stream-dest_area.bottom);
+stream-dest_area.right, stream-dest_area.bottom, 
stream-input_fps);
 return;
 }
 
@@ -3419,11 +3427,13 @@ static inline int red_is_stream_start(Drawable 
*drawable)
 // returns whether a stream was created
 static int red_stream_add_frame(RedWorker *worker,
 Drawable *frame_drawable,
+red_time_t first_frame_time,
 int frames_count,
 int gradual_frames_count,
 int last_gradual_frame)
 {
 red_update_copy_graduality(worker, frame_drawable);
+frame_drawable-first_frame_time = first_frame_time;
 frame_drawable-frames_count = frames_count + 1;
 frame_drawable-gradual_frames_count  = gradual_frames_count;
 
@@ -3477,6 +3487,7 @@ static inline void red_stream_maintenance(RedWorker 
*worker, Drawable *candidate
 } else {
 if (red_is_next_stream_frame(worker, candidate, prev) != 
STREAM_FRAME_NONE) {
 red_stream_add_frame(worker, candidate,
+ prev-first_frame_time,
  prev-frames_count,
  prev-gradual_frames_count,
  prev-last_gradual_frame);
@@ -3638,6 +3649,7 @@ static inline void red_use_stream_trace(RedWorker 
*worker, Drawable *drawable)
trace-dest_area, trace-time, NULL, 
FALSE) !=
STREAM_FRAME_NONE) {
 if (red_stream_add_frame(worker, drawable,
+ trace-first_frame_time,