Re: [Spice-devel] [PATCHv3 spice-gtk 00/14] Add https + basic auth proxy support

2014-02-20 Thread Christophe Fergeau
Hey,

On Mon, Feb 17, 2014 at 10:35:39PM +0100, Marc-André Lureau wrote:
> Hi,
> 
> The following series allows to connect to an HTTPS proxy, with Basic
> authentication.

Meant to send an "ACK series" yesterday (with just minor nits on a few
patches), and totally forgot to send that mail after going through the
patches ;)

Christophe


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


[Spice-devel] Connect Windows 2003 VM remotely through Spice protocol

2014-02-20 Thread Rohit Kakar
Hi Team,

I have windows 2003 server virtual machine which is running on ESXi host, i
want to connect remotely through spice protocol instead of RDP protocol.

is it possible to connect if yes, which software i have to install on
windows 2003 server and which software require on client side to connect
this.

Thanks on Advance.
-- 
Thanks & Regards
Rohit kakkar
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-gtk] pulse: sync volume and mute upon stream creation

2014-02-20 Thread Marc-André Lureau
Whenever a stream is created, it should have current guest volume.
Otherwise, a 100% volume guest will have current client volume, and
when changing guest volume slightly, the volume will jump abruptly.

https://bugzilla.redhat.com/show_bug.cgi?id=1012868#c10
---
 gtk/spice-pulse.c | 253 +-
 1 file changed, 155 insertions(+), 98 deletions(-)

diff --git a/gtk/spice-pulse.c b/gtk/spice-pulse.c
index c4241d0..14e32f5 100644
--- a/gtk/spice-pulse.c
+++ b/gtk/spice-pulse.c
@@ -327,11 +327,82 @@ static void stream_update_latency_callback(pa_stream *s, 
void *userdata)
 }
 }
 
+static gboolean get_playback_mute(SpicePulse *pulse)
+{
+SpicePulsePrivate *p = pulse->priv;
+gboolean mute;
+
+g_object_get(p->pchannel, "mute", &mute, NULL);
+return mute;
+}
+
+static void set_playback_mute(SpicePulse *pulse)
+{
+SpicePulsePrivate *p = pulse->priv;
+gboolean mute = get_playback_mute(pulse);
+pa_operation *op;
+
+if (!p->playback.stream ||
+pa_stream_get_index(p->playback.stream) == PA_INVALID_INDEX)
+return;
+
+op = pa_context_set_sink_input_mute(p->context,
+
pa_stream_get_index(p->playback.stream),
+mute, NULL, NULL);
+if (!op)
+g_warning("set_sink_input_mute() failed: %s",
+  pa_strerror(pa_context_errno(p->context)));
+else
+pa_operation_unref(op);
+}
+
+static void get_playback_volume(SpicePulse *pulse, pa_cvolume *v)
+{
+SpicePulsePrivate *p = pulse->priv;
+guint16 *volume;
+guint nchannels;
+guint i;
+
+g_object_get(p->pchannel,
+ "volume", &volume,
+ "nchannels", &nchannels,
+ NULL);
+
+pa_cvolume_init(v);
+v->channels = p->playback.spec.channels;
+for (i = 0; i < nchannels; ++i) {
+v->values[i] = (PA_VOLUME_NORM - PA_VOLUME_MUTED) * volume[i] / 
G_MAXUINT16;
+SPICE_DEBUG("playback volume changed %u", v->values[i]);
+}
+}
+
+static void set_playback_volume(SpicePulse *pulse)
+{
+SpicePulsePrivate *p = pulse->priv;
+pa_operation *op;
+pa_cvolume v;
+
+if (!p->playback.stream ||
+pa_stream_get_index(p->playback.stream) == PA_INVALID_INDEX)
+return;
+
+get_playback_volume(pulse, &v);
+op = pa_context_set_sink_input_volume(p->context,
+  
pa_stream_get_index(p->playback.stream),
+  &v, NULL, NULL);
+if (!op)
+g_warning("set_sink_input_volume() failed: %s",
+  pa_strerror(pa_context_errno(p->context)));
+else
+pa_operation_unref(op);
+}
+
 static void create_playback(SpicePulse *pulse)
 {
 SpicePulsePrivate *p = SPICE_PULSE_GET_PRIVATE(pulse);
 pa_stream_flags_t flags;
 pa_buffer_attr buffer_attr = { 0, };
+pa_cvolume volume;
 
 g_return_if_fail(p != NULL);
 g_return_if_fail(p->context != NULL);
@@ -350,9 +421,12 @@ static void create_playback(SpicePulse *pulse)
 buffer_attr.prebuf = -1;
 buffer_attr.minreq = -1;
 flags = PA_STREAM_ADJUST_LATENCY | PA_STREAM_AUTO_TIMING_UPDATE;
+if (get_playback_mute(pulse))
+flags |= PA_STREAM_START_MUTED;
+get_playback_volume(pulse, &volume);
 
 if (pa_stream_connect_playback(p->playback.stream,
-   NULL, &buffer_attr, flags, NULL, NULL) < 0) 
{
+   NULL, &buffer_attr, flags, &volume, NULL) < 
0) {
 g_warning("pa_stream_connect_playback() failed: %s",
   pa_strerror(pa_context_errno(p->context)));
 }
@@ -489,6 +563,77 @@ static void stream_read_callback(pa_stream *s, size_t 
length, void *data)
 }
 }
 
+static gboolean get_record_mute(SpicePulse *pulse)
+{
+SpicePulsePrivate *p = pulse->priv;
+gboolean mute;
+
+g_object_get(p->rchannel, "mute", &mute, NULL);
+return mute;
+}
+
+static void set_record_mute(SpicePulse *pulse)
+{
+SpicePulsePrivate *p = pulse->priv;
+gboolean mute = get_record_mute(pulse);
+pa_operation *op;
+
+if (!p->record.stream ||
+pa_stream_get_device_index(p->record.stream) == PA_INVALID_INDEX)
+return;
+
+op = pa_context_set_source_mute_by_index(p->context,
+ 
pa_stream_get_device_index(p->record.stream),
+ mute, NULL, NULL);
+if (!op)
+g_warning("set_source_mute() failed: %s",
+  pa_strerror(pa_context_errno(p->context)));
+else
+pa_operation_unref(op);
+}
+
+static void get_record_volume(SpicePulse *pulse, pa_cvolume *v)
+{
+SpicePulsePrivate *p = pulse->priv;
+guint16 *volume;
+guint nchannels;
+guint i;
+
+g_object_get(p->rchannel,
+ "volume", &volume,
+ "nchannels", &nchannels,
+ NUL

Re: [Spice-devel] [PATCH v2] randr: Make resolution changing more robust

2014-02-20 Thread Marc-André Lureau
ack

On Thu, Feb 20, 2014 at 3:15 PM, Christophe Fergeau  wrote:
> Ping?
>
> On Tue, Jan 21, 2014 at 10:30:35AM +0100, Christophe Fergeau wrote:
>> When running a guest using a KMS QXL driver on a RHEL6 hypervisor,
>> spice_vdagent would crash on resolution changes with:
>> X Error of failed request:  BadValue (integer parameter out of range for 
>> operation)
>>   Major opcode of failed request:  139 (RANDR)
>>   Minor opcode of failed request:  21 (RRSetCrtcConfig)
>>   Value in failed request:  0x0
>>   Serial number of failed request:  75
>>   Current serial number in output stream:  75
>>
>> (if using a newer QEMU, this will not crash as the resolution codepath is
>> totally different, see red_dispatcher_use_client_monitors_config() in
>> spice-server, when using the UMS QXL driver, the crash will not happen
>> because of
>> http://cgit.freedesktop.org/xorg/driver/xf86-video-qxl/commit/?id=907d0ff0
>> ).
>>
>> This crash happens in vdagent_x11_set_monitor_config() because the X server
>> rejects the request because we are trying to set a CRTC to a size which is
>> bigger than the current screen (using 'screen' and 'CRTC' as in the RandR
>> spec at http://www.x.org/releases/X11R7.5/doc/randrproto/randrproto.txt ).
>>
>> If we resize the screen before changing the CRTCs resolution, then this
>> error will no longer happen. However, if we first call XRRSetScreenSize()
>> and then XRRSetCrtcConfig(), the call to XRRSetScreeSize() will fail when
>> we try to make the screen smaller as there will be active CRTCs which would
>> be bigger than the screen.
>>
>> In order to solve these issues, we follow the same process as what mutter
>> does in meta_monitor_manager_xrandr_apply_configuration()
>> https://git.gnome.org/browse/mutter/tree/src/core/monitor-xrandr.c#n689:
>>
>> 1. we disable the CRTCs which are off and the ones which are bigger than the
>>size we want to set the screen to.
>> 2. we resize the screen with a call to XRRSetScreenSize().
>> 3. we set each CRTCs to their new resolution.
>> ---
>>
>> Changes since v1:
>> - remove 2 useless 'continue;' statements
>> - fix debug log when disabling a monitor, and make it closer to xrandr
>>   output (width x height + x + y)
>>
>>  src/vdagent-x11-randr.c | 61 
>> +
>>  1 file changed, 47 insertions(+), 14 deletions(-)
>>
>> diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c
>> index 5223f88..5fcfcc8 100644
>> --- a/src/vdagent-x11-randr.c
>> +++ b/src/vdagent-x11-randr.c
>> @@ -688,8 +688,6 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
>> *x11,
>>  VDAgentMonitorsConfig *mon_config,
>>  int fallback)
>>  {
>> -int width, height;
>> -int x, y;
>>  int primary_w, primary_h;
>>  int i, real_num_of_monitors = 0;
>>  VDAgentMonitorsConfig *curr = NULL;
>> @@ -748,24 +746,38 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
>> *x11,
>>  for (i = mon_config->num_of_monitors; i < x11->randr.res->noutput; i++)
>>  xrandr_disable_output(x11, i);
>>
>> +/* First, disable disabled CRTCs... */
>>  for (i = 0; i < mon_config->num_of_monitors; ++i) {
>>  if (!monitor_enabled(&mon_config->monitors[i])) {
>>  xrandr_disable_output(x11, i);
>> -continue;
>>  }
>> -/* Try to create the requested resolution */
>> -width = mon_config->monitors[i].width;
>> -height = mon_config->monitors[i].height;
>> -x = mon_config->monitors[i].x;
>> -y = mon_config->monitors[i].y;
>> -if (!xrandr_add_and_set(x11, i, x, y, width, height) &&
>> -enabled_monitors(mon_config) == 1) {
>> -set_screen_to_best_size(x11, width, height,
>> -&primary_w, &primary_h);
>> -goto update;
>> +}
>> +
>> +/* ... and disable the ones that would be bigger than
>> + * the new RandR screen once it is resized. If they are enabled the
>> + * XRRSetScreenSize call will fail with BadMatch. They will be
>> + * reenabled after hanging the screen size.
>> + */
>> +for (i = 0; i < curr->num_of_monitors; ++i) {
>> +int width, height;
>> +int x, y;
>> +
>> +width = curr->monitors[i].width;
>> +height = curr->monitors[i].height;
>> +x = curr->monitors[i].x;
>> +y = curr->monitors[i].y;
>> +
>> +if ((x + width > primary_w) || (y + height > primary_h)) {
>> +if (x11->debug)
>> +syslog(LOG_DEBUG, "Disabling monitor %d: "
>> +   "%dx%d+%d+%d > (%d,%d)",
>> +   i, width, height, x, y, primary_w, primary_h);
>> +
>> +xrandr_disable_output(x11, i);
>>  }
>>  }
>>
>> +/* Then we can resize the RandR screen. */
>>  if (primary_w != x11->width[0] || primary_h != x11->height[0]) {
>>  if (x1

[Spice-devel] [PATCH spice-gtk] RFC: populate all clipboards

2014-02-20 Thread Marc-André Lureau
Some users want all the clipboards to be populated when doing copy.  I
wonder if there isn't a better solution than to have this hack in
spice-gtk, in particular, if a small X daemon/tools could do that
automatically? That would be a cleaner and more future-proof approach
imho.

Nevertheless, this is a proof of concept, when setting
SPICE_CLIPBOARD_FILL_ALL=1, all implemented clipboards will be
populated by spice-gtk.

https://bugzilla.redhat.com/show_bug.cgi?id=967077
---
 gtk/channel-main.c  | 74 -
 gtk/spice-gtk-session.c |  3 +-
 gtk/spice-util-priv.h   |  3 ++
 3 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index d44ac23..c83233e 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -107,6 +107,8 @@ struct _SpiceMainChannelPrivate  {
 guint   migrate_delayed_id;
 spice_migrate   *migrate_data;
 int max_clipboard;
+gintlast_selection;
+gintlast_selection_request;
 };
 
 struct spice_migrate {
@@ -229,6 +231,8 @@ static void spice_main_channel_init(SpiceMainChannel 
*channel)
 c = channel->priv = SPICE_MAIN_CHANNEL_GET_PRIVATE(channel);
 c->agent_msg_queue = g_queue_new();
 c->file_xfer_tasks = g_hash_table_new(g_direct_hash, g_direct_equal);
+c->last_selection = -1;
+c->last_selection_request = -1;
 
 spice_main_channel_reset_capabilties(SPICE_CHANNEL(channel));
 }
@@ -1306,6 +1310,11 @@ static void agent_clipboard_notify(SpiceMainChannel 
*self, guint selection,
 size_t msgsize;
 gint max_clipboard = spice_main_get_max_clipboard(self);
 
+if (c->last_selection_request != -1) {
+selection = c->last_selection_request;
+c->last_selection_request = -1;
+}
+
 g_return_if_fail(c->agent_connected);
 g_return_if_fail(test_agent_cap(self, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
 g_return_if_fail(max_clipboard == -1 || size < max_clipboard);
@@ -1916,6 +1925,10 @@ static void main_agent_handle_msg(SpiceChannel *channel,
 case VD_AGENT_CLIPBOARD:
 {
 VDAgentClipboard *cb = payload;
+
+if (g_getenv("SPICE_CLIPBOARD_FILL_ALL"))
+selection = c->last_selection;
+
 emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION, selection,
   cb->type, cb->data, msg->size - 
sizeof(VDAgentClipboard));
 
@@ -1927,17 +1940,38 @@ static void main_agent_handle_msg(SpiceChannel *channel,
 case VD_AGENT_CLIPBOARD_GRAB:
 {
 gboolean ret;
-emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_GRAB, selection,
-  (guint8*)payload, msg->size / sizeof(uint32_t), 
&ret);
-if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
+
+if (g_getenv("SPICE_CLIPBOARD_FILL_ALL")) {
+c->last_selection = selection;
+
+for (selection = 0; selection <= CLIPBOARD_ALL; selection++) {
+emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_GRAB, 
selection,
+  (guint8*)payload, msg->size / 
sizeof(uint32_t), &ret);
+}
+
 emit_main_context(self, SPICE_MAIN_CLIPBOARD_GRAB,
   payload, msg->size / sizeof(uint32_t), &ret);
+} else {
+emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_GRAB, 
selection,
+  (guint8*)payload, msg->size / sizeof(uint32_t), 
&ret);
+
+if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
+emit_main_context(self, SPICE_MAIN_CLIPBOARD_GRAB,
+  payload, msg->size / sizeof(uint32_t), &ret);
+}
 break;
 }
 case VD_AGENT_CLIPBOARD_REQUEST:
 {
 gboolean ret;
 VDAgentClipboardRequest *req = payload;
+
+if (g_getenv("SPICE_CLIPBOARD_FILL_ALL")) {
+g_return_if_fail(c->last_selection_request == -1);
+c->last_selection_request = selection;
+selection = c->last_selection;
+}
+
 emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_REQUEST, 
selection,
   req->type, &ret);
 
@@ -1948,10 +1982,19 @@ static void main_agent_handle_msg(SpiceChannel *channel,
 }
 case VD_AGENT_CLIPBOARD_RELEASE:
 {
-emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_RELEASE, 
selection);
+if (g_getenv("SPICE_CLIPBOARD_FILL_ALL")) {
+for (selection = 0; selection <= CLIPBOARD_ALL; selection++) {
+emit_main_context(self, 
SPICE_MAIN_CLIPBOARD_SELECTION_RELEASE, selection);
+}
 
-if (selection == VD_AGENT_CLIPBOARD_SELECTION_CLIPBOARD)
 emit_main_context(self, SPICE_MAIN_CLIPBOARD_RELEASE);
+} else {
+emit_main_context(self, SPICE_MAIN_CLIPBOARD_SELECTION_RELEASE, 
sel

Re: [Spice-devel] [PATCHv3 spice-gtk 01/14] compat: add strtok_r fallback

2014-02-20 Thread Christophe Fergeau
On Thu, Feb 20, 2014 at 09:41:32AM -0500, Marc-André Lureau wrote:
> > > @@ -14,6 +17,7 @@
> > > License along with this library; if not, see
> > > .
> > >  */
> > >  
> > > +#include 
> > >  #include "glib-compat.h"
> > 
> > and glib-compat.h needs to go before string.h here.
> 
> why?

The doc says so
http://nondot.org/sabre/Mirrored/autoconf-2.12/autoconf_3.html#SEC15
I've for example had very unpleasant experience with this when this file
defines _FILE_OFFSET_BITS which changes the size of some structs in
system headers, and causes very weird bugs if different files expects
different layouts for these structs.

(half of the C files are missing config.h includes anyway, I'll send a
patch)

Christophe


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


Re: [Spice-devel] Potential New Development for SPICE

2014-02-20 Thread Daniel P. Berrange
On Wed, Feb 19, 2014 at 11:47:43AM -0600, adaptent wrote:
> Dear Sirs,
> 
> I have been utilizing SPICE to analyze atoms, which I believe may be
> the first time this has ever been done.

I'd certainly be impressed if our SPICE program had been used
to analyse atoms! Unfortunately I think you might have mixed us
up with a different software program

This mailing list is about the remote desktop display protocol
called SPICE:

   http://en.wikipedia.org/wiki/SPICE_%28protocol%29


It sounds like you're possibly talking about the SPICE electrical
circuit simulator:

   http://en.wikipedia.org/wiki/SPICE

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCHv3 spice-gtk 01/14] compat: add strtok_r fallback

2014-02-20 Thread Marc-André Lureau


- Original Message -
> On Mon, Feb 17, 2014 at 10:35:40PM +0100, Marc-André Lureau wrote:
> > diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
> > index c30a735..62580e2 100644
> > --- a/gtk/glib-compat.h
> > +++ b/gtk/glib-compat.h
> > @@ -1,5 +1,8 @@
> >  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> >  /*
> > +   Copyright (C) 2012-2014 Red Hat, Inc.
> > +   Copyright © 1998-2009 VLC authors and VideoLAN
> > +
> > 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
> > @@ -18,6 +21,7 @@
> >  
> >  #include 
> >  #include 
> > +#include "config.h"
> 
> If you add config.h here, it has to go as the very first include.

well, if you don't need any of its define, that's not really required..

> 
> >  
> >  #if !GLIB_CHECK_VERSION(2,26,0)
> >  #define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func)
> >  G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func,
> >  {})
> 
> > diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
> > index 9ffadbb..5714173 100644
> > --- a/gtk/glib-compat.c
> > +++ b/gtk/glib-compat.c
> > @@ -1,5 +1,8 @@
> >  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
> >  /*
> > +   Copyright (C) 2012-2014 Red Hat, Inc.
> > +   Copyright © 1998-2009 VLC authors and VideoLAN
> > +
> > 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
> > @@ -14,6 +17,7 @@
> > License along with this library; if not, see
> > .
> >  */
> >  
> > +#include 
> >  #include "glib-compat.h"
> 
> and glib-compat.h needs to go before string.h here.

why?

> 
> Christophe
> 
> ___
> 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] Potential New Development for SPICE

2014-02-20 Thread adaptent

Dear Sirs,

I have been utilizing SPICE to analyze atoms, which I believe may be the 
first time this has ever been done. My first paper: "Analyzing Atoms Using 
the SPICE Computer Program" was published in the May/June 2012 issue of 
"Computing in Science and Engineering" (CSE.aip.org). I believe this could 
be a new an important method to analyze the actions of atoms and molecules 
in the future. In a forthcoming article, this effort will be extended to the 
analysis of multiple atoms and other analogs that are beyond the present 
capability of SPICE, so I expect that there must eventually be a new and 
different type of SPICE program required to handle these new capabilities.


If you have those in your group who would like to collaborate in the 
development of a new and greater SPICE program capability, please contact 
me. Developers with additional capabilities in mechanics, math and physics 
would be most suited to this application. My background is mostly in 
electronics, but with additional study and experience in the fields of math, 
physics, mechanics, network theory, transistors, servomechanisms, 
ultrasonics, electromagnetics, electrooptics, and microelectronics. I am 
presently retired and performing my own studies.


Sincerely yours,

Dr.Weldon Vlasak
9099 West Hwy 41
Clatonia, NE 68328
(402) 989-6225 


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


Re: [Spice-devel] [Qemu-devel] [PATCH] qxl: add sanity check

2014-02-20 Thread Laszlo Ersek
On 02/19/14 11:40, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann 
> ---
>  hw/display/qxl.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/display/qxl.c b/hw/display/qxl.c
> index 1471cc0..2a559eb 100644
> --- a/hw/display/qxl.c
> +++ b/hw/display/qxl.c
> @@ -1429,7 +1429,7 @@ static int qxl_destroy_primary(PCIQXLDevice *d, 
> qxl_async_io async)
>  return 1;
>  }
>  
> -static void qxl_set_mode(PCIQXLDevice *d, int modenr, int loadvm)
> +static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm)
>  {
>  pcibus_t start = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
>  pcibus_t end   = d->pci.io_regions[QXL_RAM_RANGE_INDEX].size + start;
> @@ -1439,6 +1439,12 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr, 
> int loadvm)
>  .mem_start = start,
>  .mem_end = end
>  };
> +
> +if (modenr >= d->modes->n_modes) {
> +qxl_set_guest_bug(d, "mode number out of range");
> +return;
> +}
> +
>  QXLSurfaceCreate surface = {
>  .width  = mode->x_res,
>  .height = mode->y_res,
> 

Well, if I want to obsess about standards conformance, this is too late,
because the initialization of the "mode" pointer a bit higher up:

QXLMode *mode = d->modes->modes + modenr;

already invokes undefined behavior, when modenr is out of range.

In practice, meh -- the check is done early enough to prevent
dereferencing the (already undefined) pointer.

I also guess gcc is *not* smart enough to derive the undefined-ness as
soon as we do the wrong initialization. (Because if it were smart enough
to see that, then it would compile the check you're adding into
"constant false".)

Also, isn't this CVE material?...

Reviewed-by: Laszlo Ersek 

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


Re: [Spice-devel] [PATCHv3 spice-gtk 04/14] proxy: parse user and pass from uri

2014-02-20 Thread Christophe Fergeau
On Mon, Feb 17, 2014 at 10:35:43PM +0100, Marc-André Lureau wrote:
> ---
>  gtk/spice-proxy.c | 22 +-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/gtk/spice-proxy.c b/gtk/spice-proxy.c
> index 7711e83..8613469 100644
> --- a/gtk/spice-proxy.c
> +++ b/gtk/spice-proxy.c
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  
> +#include "glib-compat.h"
>  #include "spice-client.h"
>  #include "spice-proxy.h"
>  
> @@ -78,6 +79,18 @@ gboolean spice_proxy_parse(SpiceProxy *self, const gchar 
> *proxyuri, GError **err
>  spice_proxy_set_protocol(self, "http");
>  spice_proxy_set_port(self, 3128);
>  
> +/* yes, that parser is bad, we need GUri... */
> +if (strstr(uri, "@")) {
> +gchar *saveptr, *saveptr2;
> +gchar *next = strstr(uri, "@") + 1;
> +gchar *auth = strtok_r(uri, "@", &saveptr);
> +const gchar *user = strtok_r(auth, ":", &saveptr2);
> +const gchar *pass = strtok_r(NULL, ":", &saveptr2);
> +spice_proxy_set_user(self, user);
> +spice_proxy_set_password(self, pass);
> +uri = next;
> +}
> +
>  /* max 2 parts, host:port */
>  gchar **proxyv = g_strsplit(uri, ":", 2);
>  const gchar *proxy_port = NULL;
> @@ -303,7 +316,14 @@ gchar* spice_proxy_to_string(SpiceProxy* self)
>  if (p->protocol == NULL || p->hostname == NULL)
>  return NULL;
>  
> -return g_strdup_printf("%s://%s:%u", p->protocol, p->hostname, p->port);
> +if (p->user || p->password)
> +return g_strdup_printf("%s://%s:%s@%s:%u",
> +   p->protocol,
> +   p->user, p->password,
> +   p->hostname, p->port);
> +else
> +return g_strdup_printf("%s://%s:%u",
> +   p->protocol, p->hostname, p->port);
>  }

I would have expected this hunk to be in the previous patch (the one
introducing the password/username properties), but I can live with it being
part of this patch.
ACK

Christophe


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


Re: [Spice-devel] [PATCHv3 spice-gtk 01/14] compat: add strtok_r fallback

2014-02-20 Thread Christophe Fergeau
On Mon, Feb 17, 2014 at 10:35:40PM +0100, Marc-André Lureau wrote:
> diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
> index c30a735..62580e2 100644
> --- a/gtk/glib-compat.h
> +++ b/gtk/glib-compat.h
> @@ -1,5 +1,8 @@
>  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
>  /*
> +   Copyright (C) 2012-2014 Red Hat, Inc.
> +   Copyright © 1998-2009 VLC authors and VideoLAN
> +
> 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
> @@ -18,6 +21,7 @@
>  
>  #include 
>  #include 
> +#include "config.h"

If you add config.h here, it has to go as the very first include.

>  
>  #if !GLIB_CHECK_VERSION(2,26,0)
>  #define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) 
> G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {})

> diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
> index 9ffadbb..5714173 100644
> --- a/gtk/glib-compat.c
> +++ b/gtk/glib-compat.c
> @@ -1,5 +1,8 @@
>  /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
>  /*
> +   Copyright (C) 2012-2014 Red Hat, Inc.
> +   Copyright © 1998-2009 VLC authors and VideoLAN
> +
> 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
> @@ -14,6 +17,7 @@
> License along with this library; if not, see 
> .
>  */
>  
> +#include 
>  #include "glib-compat.h"

and glib-compat.h needs to go before string.h here.

Christophe


pgpVvm5KfNgdu.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] randr: Make resolution changing more robust

2014-02-20 Thread Christophe Fergeau
Ping? 

On Tue, Jan 21, 2014 at 10:30:35AM +0100, Christophe Fergeau wrote:
> When running a guest using a KMS QXL driver on a RHEL6 hypervisor,
> spice_vdagent would crash on resolution changes with:
> X Error of failed request:  BadValue (integer parameter out of range for 
> operation)
>   Major opcode of failed request:  139 (RANDR)
>   Minor opcode of failed request:  21 (RRSetCrtcConfig)
>   Value in failed request:  0x0
>   Serial number of failed request:  75
>   Current serial number in output stream:  75
> 
> (if using a newer QEMU, this will not crash as the resolution codepath is
> totally different, see red_dispatcher_use_client_monitors_config() in
> spice-server, when using the UMS QXL driver, the crash will not happen
> because of
> http://cgit.freedesktop.org/xorg/driver/xf86-video-qxl/commit/?id=907d0ff0
> ).
> 
> This crash happens in vdagent_x11_set_monitor_config() because the X server
> rejects the request because we are trying to set a CRTC to a size which is
> bigger than the current screen (using 'screen' and 'CRTC' as in the RandR
> spec at http://www.x.org/releases/X11R7.5/doc/randrproto/randrproto.txt ).
> 
> If we resize the screen before changing the CRTCs resolution, then this
> error will no longer happen. However, if we first call XRRSetScreenSize()
> and then XRRSetCrtcConfig(), the call to XRRSetScreeSize() will fail when
> we try to make the screen smaller as there will be active CRTCs which would
> be bigger than the screen.
> 
> In order to solve these issues, we follow the same process as what mutter
> does in meta_monitor_manager_xrandr_apply_configuration()
> https://git.gnome.org/browse/mutter/tree/src/core/monitor-xrandr.c#n689:
> 
> 1. we disable the CRTCs which are off and the ones which are bigger than the
>size we want to set the screen to.
> 2. we resize the screen with a call to XRRSetScreenSize().
> 3. we set each CRTCs to their new resolution.
> ---
> 
> Changes since v1:
> - remove 2 useless 'continue;' statements
> - fix debug log when disabling a monitor, and make it closer to xrandr
>   output (width x height + x + y)
> 
>  src/vdagent-x11-randr.c | 61 
> +
>  1 file changed, 47 insertions(+), 14 deletions(-)
> 
> diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c
> index 5223f88..5fcfcc8 100644
> --- a/src/vdagent-x11-randr.c
> +++ b/src/vdagent-x11-randr.c
> @@ -688,8 +688,6 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
> *x11,
>  VDAgentMonitorsConfig *mon_config,
>  int fallback)
>  {
> -int width, height;
> -int x, y;
>  int primary_w, primary_h;
>  int i, real_num_of_monitors = 0;
>  VDAgentMonitorsConfig *curr = NULL;
> @@ -748,24 +746,38 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
> *x11,
>  for (i = mon_config->num_of_monitors; i < x11->randr.res->noutput; i++)
>  xrandr_disable_output(x11, i);
>  
> +/* First, disable disabled CRTCs... */
>  for (i = 0; i < mon_config->num_of_monitors; ++i) {
>  if (!monitor_enabled(&mon_config->monitors[i])) {
>  xrandr_disable_output(x11, i);
> -continue;
>  }
> -/* Try to create the requested resolution */
> -width = mon_config->monitors[i].width;
> -height = mon_config->monitors[i].height;
> -x = mon_config->monitors[i].x;
> -y = mon_config->monitors[i].y;
> -if (!xrandr_add_and_set(x11, i, x, y, width, height) &&
> -enabled_monitors(mon_config) == 1) {
> -set_screen_to_best_size(x11, width, height,
> -&primary_w, &primary_h);
> -goto update;
> +}
> +
> +/* ... and disable the ones that would be bigger than
> + * the new RandR screen once it is resized. If they are enabled the
> + * XRRSetScreenSize call will fail with BadMatch. They will be
> + * reenabled after hanging the screen size.
> + */
> +for (i = 0; i < curr->num_of_monitors; ++i) {
> +int width, height;
> +int x, y;
> +
> +width = curr->monitors[i].width;
> +height = curr->monitors[i].height;
> +x = curr->monitors[i].x;
> +y = curr->monitors[i].y;
> +
> +if ((x + width > primary_w) || (y + height > primary_h)) {
> +if (x11->debug)
> +syslog(LOG_DEBUG, "Disabling monitor %d: "
> +   "%dx%d+%d+%d > (%d,%d)",
> +   i, width, height, x, y, primary_w, primary_h);
> +
> +xrandr_disable_output(x11, i);
>  }
>  }
>  
> +/* Then we can resize the RandR screen. */
>  if (primary_w != x11->width[0] || primary_h != x11->height[0]) {
>  if (x11->debug)
>  syslog(LOG_DEBUG, "Changing screen size to %dx%d",
> @@ -793,7 +805,28 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
> *x11,
>

Re: [Spice-devel] Can the QXL drivers be install on Windows 8/8.1?

2014-02-20 Thread Lindsay Mathieson
On Thu, 20 Feb 2014 09:10:21 AM Martin wrote:
> Lindsay,
> NONE of the currently (FEB 2014) available qxl drivers works for Windows 8 -
> 8.1 guests because these OS require a WDDM driver and someone has to
> develop this driver. See also:
> https://www.mail-archive.com/spice-devel@lists.freedesktop.org/msg09014.html
> http://www.spice-space.org/page/WDDM
> 
> Martin


Thanks Martin
-- 
Lindsay

signature.asc
Description: This is a digitally signed message part.
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] qxl: add sanity check

2014-02-20 Thread Christophe Fergeau
Looks good, ACK.

Christophe

On Wed, Feb 19, 2014 at 11:40:50AM +0100, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann 
> ---
>  hw/display/qxl.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/display/qxl.c b/hw/display/qxl.c
> index 1471cc0..2a559eb 100644
> --- a/hw/display/qxl.c
> +++ b/hw/display/qxl.c
> @@ -1429,7 +1429,7 @@ static int qxl_destroy_primary(PCIQXLDevice *d, 
> qxl_async_io async)
>  return 1;
>  }
>  
> -static void qxl_set_mode(PCIQXLDevice *d, int modenr, int loadvm)
> +static void qxl_set_mode(PCIQXLDevice *d, unsigned int modenr, int loadvm)
>  {
>  pcibus_t start = d->pci.io_regions[QXL_RAM_RANGE_INDEX].addr;
>  pcibus_t end   = d->pci.io_regions[QXL_RAM_RANGE_INDEX].size + start;
> @@ -1439,6 +1439,12 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr, 
> int loadvm)
>  .mem_start = start,
>  .mem_end = end
>  };
> +
> +if (modenr >= d->modes->n_modes) {
> +qxl_set_guest_bug(d, "mode number out of range");
> +return;
> +}
> +
>  QXLSurfaceCreate surface = {
>  .width  = mode->x_res,
>  .height = mode->y_res,
> -- 
> 1.8.3.1
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


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


Re: [Spice-devel] Can the QXL drivers be install on Windows 8/8.1?

2014-02-20 Thread Martin
Lindsay Mathieson  gmail.com> writes:

> 
> As per the subject :)
> 
> I know the guest installer won't do it, but can they be installed
manually? or 
> are they just not compatible?
> 
> Its starting to become a problem for me at work - we use VM's for a lot of 
> development and testing  and its increasingly difficult to avoid using
windows 
> 8.
> 
> thanks,

Lindsay,
NONE of the currently (FEB 2014) available qxl drivers works for Windows 8 -
8.1 guests because these OS require a WDDM driver and someone has to develop
this driver. See also:
https://www.mail-archive.com/spice-devel@lists.freedesktop.org/msg09014.html
http://www.spice-space.org/page/WDDM

Martin


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