Re: [Spice-devel] Patch to support LZ4 compression algorithm‏‏

2015-01-08 Thread Fabio Fantoni
Il 07/01/2015 10:13, LgDoor ha scritto:
> I think the cause of this problem is the unnecessary step of flipping the 
> bitmap buffer lines when encoding, since the surface in the client will be 
> created with the top-down param. 
> this patch just works.

I tried your patch in attachment removing 2 parts (see below) and I can
confirm that it partially solves critical lz4 bug.
I'll post details with backtrace tomorrow.

I had this error on compile:
red_worker.c:264:1: error: 'inline' is not at beginning of declaration
[-Werror=old-style-declaration]
red_worker.c: In function 'print_compress_stats':
red_worker.c:1172:5: error: 'CommonChannel' has no member named 'id'
Solved removing this part of patch:
> -//#define COMPRESS_STAT
> +#define COMPRESS_STAT

I think should be posted to mailing list for better review and add in
upstream.
Before post it I think that 2 changes should be remove, first the
mentioned above and this:
> -if (image_compression == SPICE_IMAGE_COMPRESS_LZ4 &&
> +if (true &&

Thanks for any reply and sorry for my bad english.


> 
>> From: javier.cel...@flexvm.es
>> To: spice-devel@lists.freedesktop.org
>> Date: Wed, 7 Jan 2015 09:22:52 +0100
>> Subject: Re: [Spice-devel] Patch to support LZ4 compression algorithm‏‏
>>
>> Hello
>>
>> To enable LZ4 from the qemu command line, you have to add this to ui/spice-
>> core.c:
>>
>> static const char *compression_names[] = {
>> [ SPICE_IMAGE_COMPRESS_OFF ] = "off",
>> [ SPICE_IMAGE_COMPRESS_AUTO_GLZ ] = "auto_glz",
>> [ SPICE_IMAGE_COMPRESS_AUTO_LZ ] = "auto_lz",
>> [ SPICE_IMAGE_COMPRESS_QUIC ] = "quic",
>> [ SPICE_IMAGE_COMPRESS_GLZ ] = "glz",
>> [ SPICE_IMAGE_COMPRESS_LZ ] = "lz",
>> + [ SPICE_IMAGE_COMPRESS_LZ4 ] = "lz4",
>> };
>>
>> Build qemu, and then you can use --spice image-compression=lz4.
>>
>> About the problem with SPICE_BITMAP_FLAGS_TOP_DOWN, I'll have a look at it
>> ASAP.
>>
>> Thanks for your feedback.
>>
>> El Miércoles, 7 de enero de 2015 15:48:43 LgDoor escribió:
>>> i'm not sure but it seems lz4 won't be enabled unless adding a new value of
>>> the image_compress parameter in QEMU.
>>> so i just replace lz with lz4, at red_compress_image() in red_worker.c,
>> 6680:
 if (image_compression == SPICE_IMAGE_COMPRESS_LZ4 &&
 red_channel_client_test_remote_cap(&dcc->common.base,
 SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
>>> changes to
>>>
 if (true && ...
>>> and launch qemu with --spice image-compression=auto_lz.
>>>
>>> 
>>>
 Date: Wed, 7 Jan 2015 08:15:07 +0100
 From: fantonifa...@tiscali.it
 To: lgd...@outlook.com; spice-devel@lists.freedesktop.org
 Subject: Re: [Spice-devel] Patch to support LZ4 compression algorithm‏‏

 Il 07/01/2015 08:01, LgDoor ha scritto:
> has anybody tried this feature and encountered the displaying problems?
>
> I just made a small change to enable lz4, but the image turns out to be
> broken (see the screenshots). And I observed that it goes wrong only for
> the SpiceBitmap w/o SPICE_BITMAP_FLAGS_TOP_DOWN flag in the
> red_compress_image() function from red_worker.c .>
 What change you did?
 I tried it only using both server and client compiled with it and FWIK
 should be used automatically if no image compression specified.

> 2014-11-14 0:11 GMT+08:00 Javier Celaya :
>> Hello
>>
>> There they go.
>>
>> However, don't forget that, since spice-protocol is a submodule of
>> spice-
>> common, once you push the commit for spice-protocol, the commit for
>> spice-
>> common should point to it. The same with spice and spice-gtk in relation
>> to
>> spice-common.
>>
>> Regards
>>
>> El Jueves, 13 de noviembre de 2014 16:04:00 Christophe Fergeau escribió:
>>> Hey,
>>>
>>> On Fri, Nov 07, 2014 at 10:17:11AM +0100, Javier Celaya wrote:
 Hello

 I resend the patch for the spice repository. I just realized I forgot
 to
 remove a debug message from red_worker.c, sorry.
>>> Thanks for the updated patches, they look good to me. There are 2 blank
>>> lines at the end of lz4_encoder.[ch] which should be removed.
>>> Can you resend these patches generated with git-format-patch so that
>>> they contain a commit log, and an author name/address? Then they can be
>>> pushed upstream.
>>>
>>> Christophe
>> ___
>> Spice-devel mailing list
>> Spice-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>>>




smime.p7s
Description: Firma crittografica S/MIME
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-html5] Report SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS capability

2015-01-08 Thread Pavel Grunt
We should report that we handle the connected tokens message
by setting the SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS capability.
---
Depends on 
http://lists.freedesktop.org/archives/spice-devel/2015-January/018538.html
---
 enums.js | 5 +
 spiceconn.js | 4 
 2 files changed, 9 insertions(+)

diff --git a/enums.js b/enums.js
index fe08d42..07aa343 100644
--- a/enums.js
+++ b/enums.js
@@ -166,6 +166,11 @@ var SPICE_PLAYBACK_CAP_VOLUME   = 1;
 var SPICE_PLAYBACK_CAP_LATENCY  = 2;
 var SPICE_PLAYBACK_CAP_OPUS = 3;
 
+var SPICE_MAIN_CAP_SEMI_SEAMLESS_MIGRATE  = 0;
+var SPICE_MAIN_CAP_NAME_AND_UUID  = 1;
+var SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS = 2;
+var SPICE_MAIN_CAP_SEAMLESS_MIGRATE   = 3;
+
 var SPICE_AUDIO_DATA_MODE_INVALID   = 0;
 var SPICE_AUDIO_DATA_MODE_RAW   = 1;
 var SPICE_AUDIO_DATA_MODE_CELT_0_5_1= 2;
diff --git a/spiceconn.js b/spiceconn.js
index ceebd5d..ec42d8d 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -129,6 +129,10 @@ SpiceConn.prototype =
 msg.channel_caps.push(
 (1 << SPICE_PLAYBACK_CAP_OPUS)
 );
+else if (msg.channel_type == SPICE_CHANNEL_MAIN)
+msg.channel_caps.push(
+(1 << SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)
+);
 
 hdr.size = msg.buffer_size();
 
-- 
1.9.3

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


Re: [Spice-devel] [PATCH spice-html5 1/4] Handle agent tokens

2015-01-08 Thread Pavel Grunt
> 
> As far as I know, the server will only use the conencted_tokens
> message
> is we report SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS.  But we do not
> report that cap (or any main channel caps).
> 
> You could readily do it using the same logic that is found in pushing
> CAP_OPUS.
> 
> Cheers,
> 
> Jeremy
> 
Thanks for the explanation.

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


Re: [Spice-devel] [xf86-video-qxl v6] Enable smartcard support for XSpice.

2015-01-08 Thread Jeremy White

2. What happens if h->length == 0 ?


Note that I believe that could only occur in the case of a malicious or
buggy packet.  By inspection, I believe the code will all function
correctly; passing a 0 length atr along.


Is this to the card (hardware) or back? if to, can't this be used by a
driver to wakeup a card (i.e. dropping it will have adverse affects)?


I believe that the VSC_ATR is sent at only one place, from the gtk 
client to the remote side  (I believe it's both for power on and reset). 
 But my inspection suggests the code path (through vreader_power_on) 
always retrieves the atr before sending it.  So I'm pretty sure that the 
atr is always non zero length.


Cheers,

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


Re: [Spice-devel] [PATCH spice-html5 1/4] Handle agent tokens

2015-01-08 Thread Jeremy White

On 01/08/2015 03:48 AM, Pavel Grunt wrote:




Since you're genuinely using this message, shouldn't we now advertise
the connected token CAP?



I am not sure what CAP you mean. We send the SPICE_MSGC_MAIN_AGENT_START 
message when the SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS message is received.


As far as I know, the server will only use the conencted_tokens message 
is we report SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS.  But we do not 
report that cap (or any main channel caps).


You could readily do it using the same logic that is found in pushing 
CAP_OPUS.


Cheers,

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


[Spice-devel] [PATCH spice-html5 2/5] Send agent messages only when have agent tokens

2015-01-08 Thread Pavel Grunt
Messages that were not sent are stored in the queue.
They will be sent later when the client receives more agent tokens.
---
 main.js | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/main.js b/main.js
index d9c9f75..d10b594 100644
--- a/main.js
+++ b/main.js
@@ -55,6 +55,7 @@ function SpiceMainConn()
 
 SpiceConn.apply(this, arguments);
 
+this.agent_msg_queue = [];
 }
 
 SpiceMainConn.prototype = Object.create(SpiceConn.prototype);
@@ -161,6 +162,7 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 {
 var tokens = new SpiceMsgMainAgentTokens(msg.data);
 this.agent_tokens += tokens.num_tokens;
+this.send_agent_message_queue();
 return true;
 }
 
@@ -204,18 +206,36 @@ SpiceMainConn.prototype.stop = function(msg)
 this.extra_channels = undefined;
 }
 
-SpiceMainConn.prototype.resize_window = function(flags, width, height, depth, 
x, y)
+SpiceMainConn.prototype.send_agent_message_queue = function(message)
 {
-if (this.agent_connected > 0)
+if (!this.agent_connected)
+return;
+
+if (message)
+this.agent_msg_queue.push(message);
+
+while (this.agent_tokens > 0 && this.agent_msg_queue.length > 0)
 {
-var monitors_config = new VDAgentMonitorsConfig(flags, width, height, 
depth, x, y);
-var agent_data = new SpiceMsgcMainAgentData(VD_AGENT_MONITORS_CONFIG, 
monitors_config);
-var mr = new SpiceMiniData();
-mr.build_msg(SPICE_MSGC_MAIN_AGENT_DATA, agent_data);
+var mr = this.agent_msg_queue.shift();
 this.send_msg(mr);
+this.agent_tokens--;
 }
 }
 
+SpiceMainConn.prototype.send_agent_message = function(type, message)
+{
+var agent_data = new SpiceMsgcMainAgentData(type, message);
+var mr = new SpiceMiniData();
+mr.build_msg(SPICE_MSGC_MAIN_AGENT_DATA, agent_data);
+this.send_agent_message_queue(mr);
+}
+
+SpiceMainConn.prototype.resize_window = function(flags, width, height, depth, 
x, y)
+{
+var monitors_config = new VDAgentMonitorsConfig(flags, width, height, 
depth, x, y);
+this.send_agent_message(VD_AGENT_MONITORS_CONFIG, monitors_config);
+}
+
 SpiceMainConn.prototype.connect_agent = function()
 {
 this.agent_connected = true;
-- 
1.9.3

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


[Spice-devel] [PATCH spice-html5 5/5] Read file only when have agent tokens

2015-01-08 Thread Pavel Grunt
Stop reading file when there are no tokens,
continue reading it when tokens arrive.
---
 main.js | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/main.js b/main.js
index 5c4a470..7c36342 100644
--- a/main.js
+++ b/main.js
@@ -58,6 +58,7 @@ function SpiceMainConn()
 this.agent_msg_queue = [];
 this.file_xfer_tasks = {};
 this.file_xfer_task_id = 0;
+this.file_xfer_read_queue = [];
 }
 
 SpiceMainConn.prototype = Object.create(SpiceConn.prototype);
@@ -162,9 +163,17 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 
 if (msg.type == SPICE_MSG_MAIN_AGENT_TOKEN)
 {
-var tokens = new SpiceMsgMainAgentTokens(msg.data);
+var remaining_tokens, tokens = new SpiceMsgMainAgentTokens(msg.data);
 this.agent_tokens += tokens.num_tokens;
 this.send_agent_message_queue();
+
+remaining_tokens = this.agent_tokens;
+while (remaining_tokens > 0 && this.file_xfer_read_queue.length > 0)
+{
+var xfer_task = this.file_xfer_read_queue.shift();
+this.file_xfer_read(xfer_task, xfer_task.read_bytes);
+remaining_tokens--;
+}
 return true;
 }
 
@@ -306,6 +315,13 @@ SpiceMainConn.prototype.file_xfer_read = 
function(file_xfer_task, start_byte)
 sb = start_byte || 0,
 eb = Math.min(sb + FILE_XFER_CHUNK_SIZE, file_xfer_task.file.size);
 
+if (!this.agent_tokens)
+{
+file_xfer_task.read_bytes = sb;
+this.file_xfer_read_queue.push(file_xfer_task);
+return;
+}
+
 reader = new FileReader();
 reader.onload = function(e)
 {
-- 
1.9.3

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


[Spice-devel] [PATCH spice-html5 v2 4/5] Use drag and drop for transfering files from client to guest

2015-01-08 Thread Pavel Grunt
---
v2:
 - adds missing removeEventListeners
---
 filexfer.js | 22 ++
 spice.html  | 15 +++
 spice_auto.html | 15 +++
 3 files changed, 52 insertions(+)

diff --git a/filexfer.js b/filexfer.js
index d472240..2ba0671 100644
--- a/filexfer.js
+++ b/filexfer.js
@@ -23,3 +23,25 @@ function SpiceFileXferTask(id, file)
 this.id = id;
 this.file = file;
 }
+
+function handle_file_dragover(e)
+{
+e.stopPropagation();
+e.preventDefault();
+e.dataTransfer.dropEffect = 'copy';
+}
+
+function handle_file_drop(e)
+{
+var sc = window.spice_connection;
+var files = e.dataTransfer.files;
+
+e.stopPropagation();
+e.preventDefault();
+for (var i = files.length - 1; i >= 0; i--)
+{
+if (files[i].type); // do not copy a directory
+sc.file_xfer_start(files[i]);
+}
+
+}
diff --git a/spice.html b/spice.html
index fc53a2a..000f23d 100644
--- a/spice.html
+++ b/spice.html
@@ -111,6 +111,11 @@
 }
 document.getElementById('connectButton').innerHTML = "Start";
 document.getElementById('connectButton').onclick = connect;
+if (window.File && window.FileReader && window.FileList && 
window.Blob)
+{
+
document.getElementById('spice-area').removeEventListener('dragover', 
handle_file_dragover, false);
+
document.getElementById('spice-area').removeEventListener('drop', 
handle_file_drop, false);
+}
 console.log("<< disconnect");
 }
 
@@ -120,6 +125,16 @@
 window.spice_connection = this;
 
 resize_helper(this);
+
+if (window.File && window.FileReader && window.FileList && 
window.Blob)
+{
+
document.getElementById('spice-area').addEventListener('dragover', 
handle_file_dragover, false);
+
document.getElementById('spice-area').addEventListener('drop', 
handle_file_drop, false);
+}
+else
+{
+console.log("File API is not supported");
+}
 }
 
 
diff --git a/spice_auto.html b/spice_auto.html
index 48dcae1..689b066 100644
--- a/spice_auto.html
+++ b/spice_auto.html
@@ -147,6 +147,11 @@
 if (sc) {
 sc.stop();
 }
+if (window.File && window.FileReader && window.FileList && 
window.Blob)
+{
+
document.getElementById('spice-area').removeEventListener('dragover', 
handle_file_dragover, false);
+
document.getElementById('spice-area').removeEventListener('drop', 
handle_file_drop, false);
+}
 console.log("<< disconnect");
 }
 
@@ -156,6 +161,16 @@
 window.spice_connection = this;
 
 resize_helper(this);
+
+if (window.File && window.FileReader && window.FileList && 
window.Blob)
+{
+
document.getElementById('spice-area').addEventListener('dragover', 
handle_file_dragover, false);
+
document.getElementById('spice-area').addEventListener('drop', 
handle_file_drop, false);
+}
+else
+{
+console.log("File API is not supported");
+}
 }
 
 connect();
-- 
1.9.3

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


[Spice-devel] [PATCH spice-html5 1/5] Handle agent tokens

2015-01-08 Thread Pavel Grunt
---
 main.js | 20 ++--
 spicemsg.js | 15 +++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/main.js b/main.js
index e487551..d9c9f75 100644
--- a/main.js
+++ b/main.js
@@ -87,6 +87,8 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 if (this.main_init.agent_connected)
 this.connect_agent();
 
+this.agent_tokens = this.main_init.agent_tokens;
+
 var attach = new SpiceMiniData;
 attach.type = SPICE_MSGC_MAIN_ATTACH_CHANNELS;
 attach.size = attach.buffer_size();
@@ -141,13 +143,27 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 return true;
 }
 
-if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED ||
-msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS)
+if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED)
+{
+this.connect_agent();
+return true;
+}
+
+if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS)
 {
+var connected_tokens = new SpiceMsgMainAgentTokens(msg.data);
+this.agent_tokens = connected_tokens.num_tokens;
 this.connect_agent();
 return true;
 }
 
+if (msg.type == SPICE_MSG_MAIN_AGENT_TOKEN)
+{
+var tokens = new SpiceMsgMainAgentTokens(msg.data);
+this.agent_tokens += tokens.num_tokens;
+return true;
+}
+
 if (msg.type == SPICE_MSG_MAIN_AGENT_DISCONNECTED)
 {
 this.agent_connected = false;
diff --git a/spicemsg.js b/spicemsg.js
index c64f5a3..0983ae7 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -348,6 +348,21 @@ SpiceMsgMainMouseMode.prototype =
 },
 }
 
+function SpiceMsgMainAgentTokens(a, at)
+{
+this.from_buffer(a, at);
+}
+
+SpiceMsgMainAgentTokens.prototype =
+{
+from_buffer: function(a, at)
+{
+at = at || 0;
+var dv = new SpiceDataView(a);
+this.num_tokens = dv.getUint32(at, true); at += 4;
+},
+}
+
 function SpiceMsgSetAck(a, at)
 {
 this.from_buffer(a, at);
-- 
1.9.3

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


[Spice-devel] [PATCH spice-html5 v2 3/5] Implement methods for transfering files from client to guest

2015-01-08 Thread Pavel Grunt
It is possible to transfer files from the client to the guest
using File API [0] when a spice vd agent is connected.

Methods for the transfer are based on spice-gtk implementation.

[0] http://www.w3.org/TR/file-upload/
---
v2:
 - adds task counter, missing check for the task existence, 
SpiceMsgMainAgentData
---
 enums.js|   6 
 filexfer.js |  25 +
 main.js |  95 +
 spice.html  |   1 +
 spice_auto.html |   1 +
 spicemsg.js | 107 +++-
 6 files changed, 234 insertions(+), 1 deletion(-)
 create mode 100644 filexfer.js

diff --git a/enums.js b/enums.js
index d99b38e..fe08d42 100644
--- a/enums.js
+++ b/enums.js
@@ -307,6 +307,7 @@ var SPICE_CURSOR_TYPE_ALPHA = 0,
 var SPICE_VIDEO_CODEC_TYPE_MJPEG = 1;
 
 var VD_AGENT_PROTOCOL = 1;
+var VD_AGENT_MAX_DATA_SIZE = 2048;
 
 var VD_AGENT_MOUSE_STATE= 1,
 VD_AGENT_MONITORS_CONFIG= 2,
@@ -322,3 +323,8 @@ var VD_AGENT_MOUSE_STATE= 1,
 VD_AGENT_FILE_XFER_DATA =12,
 VD_AGENT_CLIENT_DISCONNECTED=13,
 VD_AGENT_MAX_CLIPBOARD  =14;
+
+var VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA = 0,
+VD_AGENT_FILE_XFER_STATUS_CANCELLED = 1,
+VD_AGENT_FILE_XFER_STATUS_ERROR = 2,
+VD_AGENT_FILE_XFER_STATUS_SUCCESS   = 3;
diff --git a/filexfer.js b/filexfer.js
new file mode 100644
index 000..d472240
--- /dev/null
+++ b/filexfer.js
@@ -0,0 +1,25 @@
+"use strict";
+/*
+   Copyright (C) 2014 Red Hat, Inc.
+
+   This file is part of spice-html5.
+
+   spice-html5 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 3 of the License, or
+   (at your option) any later version.
+
+   spice-html5 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 spice-html5.  If not, see .
+*/
+
+function SpiceFileXferTask(id, file)
+{
+this.id = id;
+this.file = file;
+}
diff --git a/main.js b/main.js
index d10b594..5c4a470 100644
--- a/main.js
+++ b/main.js
@@ -56,6 +56,8 @@ function SpiceMainConn()
 SpiceConn.apply(this, arguments);
 
 this.agent_msg_queue = [];
+this.file_xfer_tasks = {};
+this.file_xfer_task_id = 0;
 }
 
 SpiceMainConn.prototype = Object.create(SpiceConn.prototype);
@@ -172,6 +174,18 @@ SpiceMainConn.prototype.process_channel_message = 
function(msg)
 return true;
 }
 
+if (msg.type == SPICE_MSG_MAIN_AGENT_DATA)
+{
+var agent_data = new SpiceMsgMainAgentData(msg.data);
+if (agent_data.type == VD_AGENT_FILE_XFER_STATUS)
+{
+this.handle_file_xfer_status(new 
VDAgentFileXferStatusMessage(agent_data.data));
+return true;
+}
+
+return false;
+}
+
 return false;
 }
 
@@ -236,6 +250,87 @@ SpiceMainConn.prototype.resize_window = function(flags, 
width, height, depth, x,
 this.send_agent_message(VD_AGENT_MONITORS_CONFIG, monitors_config);
 }
 
+SpiceMainConn.prototype.file_xfer_start = function(file)
+{
+var task_id, xfer_start, task;
+
+task_id = this.file_xfer_task_id++;
+task = new SpiceFileXferTask(task_id, file);
+this.file_xfer_tasks[task_id] = task;
+xfer_start = new VDAgentFileXferStartMessage(task_id, file.name, 
file.size);
+this.send_agent_message(VD_AGENT_FILE_XFER_START, xfer_start);
+}
+
+SpiceMainConn.prototype.handle_file_xfer_status = function(file_xfer_status)
+{
+var xfer_error, xfer_task;
+if (!this.file_xfer_tasks[file_xfer_status.id])
+{
+this.log_err("do not have file task id "+file_xfer_status.id);
+return;
+}
+xfer_task = this.file_xfer_tasks[file_xfer_status.id];
+switch (file_xfer_status.result)
+{
+case VD_AGENT_FILE_XFER_STATUS_CAN_SEND_DATA:
+this.file_xfer_read(xfer_task);
+return;
+case VD_AGENT_FILE_XFER_STATUS_CANCELLED:
+xfer_error = "transfer is cancelled by spice agent";
+break;
+case VD_AGENT_FILE_XFER_STATUS_ERROR:
+xfer_error = "some errors occurred in the spice agent";
+break;
+case VD_AGENT_FILE_XFER_STATUS_SUCCESS:
+break;
+default:
+xfer_error = "unhandled status type: " + file_xfer_status.result;
+break;
+}
+
+this.file_xfer_completed(xfer_task, xfer_error)
+}
+
+SpiceMainConn.prototype.file_xfer_read = function(file_xfer_task, start_byte)
+{
+var FILE_XFER_CHUNK_SIZE = VD_AGENT_MAX_DATA_SIZE
+   - SpiceMsgcMai

[Spice-devel] [PATCH spice-html5 v2 0/5] Enable file transfer from client to guest

2015-01-08 Thread Pavel Grunt
Hi, the intetion of this series is to add the ability to transfer files from 
the client to the guest.

To make it work it was convenient to start using agent tokens (PATCH 1/5 & 2/5) 
because there can be a lot of agent messages when sending a file.
Methods for the transfer are based on relevant methods in spice-gtk.

v2: Files are read only when tokens are available.

Pavel Grunt (5):
  Handle agent tokens
  Send agent messages only when have agent tokens
  Implement methods for transfering files from client to guest
  Use drag and drop for transfering files from client to guest
  Read file only when have agent tokens

 enums.js|   6 +++
 filexfer.js |  47 
 main.js | 163 +---
 spice.html  |  16 ++
 spice_auto.html |  16 ++
 spicemsg.js | 122 +-
 6 files changed, 361 insertions(+), 9 deletions(-)
 create mode 100644 filexfer.js

-- 
1.9.3

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


Re: [Spice-devel] [xf86-video-qxl v6] Enable smartcard support for XSpice.

2015-01-08 Thread Alon Levy
On 01/08/2015 04:10 PM, Jeremy White wrote:
> On 01/08/2015 03:53 AM, Uri Lublin wrote:
>> Hi Jeremy,
>>
>> Ack.
> 
> Thanks.
> 
>>
>> h->length is unsigned.
>> 1. Why is there a need to check that h->length > 0 ?
> 
> There is no need, changed.
> 
>> 2. What happens if h->length == 0 ?
> 
> Note that I believe that could only occur in the case of a malicious or
> buggy packet.  By inspection, I believe the code will all function
> correctly; passing a 0 length atr along.

Is this to the card (hardware) or back? if to, can't this be used by a
driver to wakeup a card (i.e. dropping it will have adverse affects)?

> 
>>> +static void process_apdu(smartcard_ccid_t *ccid, VSCMsgHeader *h,
>>> char *data)
>>> +{
>>> +if (ccid->state & STATE_READER_ADDED)
>>> +push_apdu(ccid, data, h->length);
>>
>> Maybe add: else { fprintf(stderr, "warning ..." }
> 
> Sure.
> 
> Cheers,
> 
> Jeremy
> ___
> 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] [xf86-video-qxl v6] Enable smartcard support for XSpice.

2015-01-08 Thread Jeremy White

On 01/08/2015 03:53 AM, Uri Lublin wrote:

Hi Jeremy,

Ack.


Thanks.



h->length is unsigned.
1. Why is there a need to check that h->length > 0 ?


There is no need, changed.


2. What happens if h->length == 0 ?


Note that I believe that could only occur in the case of a malicious or 
buggy packet.  By inspection, I believe the code will all function 
correctly; passing a 0 length atr along.



+static void process_apdu(smartcard_ccid_t *ccid, VSCMsgHeader *h,
char *data)
+{
+if (ccid->state & STATE_READER_ADDED)
+push_apdu(ccid, data, h->length);


Maybe add: else { fprintf(stderr, "warning ..." }


Sure.

Cheers,

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


Re: [Spice-devel] [PATCH] [RFC] LZ4 compression option for SPICE

2015-01-08 Thread Javier Celaya
Sure, for the help text of the image-compression option, thanks.

El Jueves, 8 de enero de 2015 12:48:57 Fabio Fantoni escribió:
> Il 08/01/2015 11:50, Javier Celaya ha scritto:
> > Hello
> > 
> > Recently, SPICE included the lz4 compression algorithm. This patch adds
> > a command line option to select it. However, SPICE_IMAGE_COMPRESS_LZ4 did
> > not exist before the commit that added this compression algorithm, so it
> > should be guarded with conditional compilation. How do you think this
> > should be done? Wait for the next stable version of spice-server and
> > check for
> > SPICE_SERVER_VERSION? Or add a specific flag?
> > 
> > Thank you
> > ---
> > 
> >  ui/spice-core.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/ui/spice-core.c b/ui/spice-core.c
> > index 6467fa4..fb6534e 100644
> > --- a/ui/spice-core.c
> > +++ b/ui/spice-core.c
> > @@ -359,6 +359,7 @@ static const char *compression_names[] = {
> > 
> >  [ SPICE_IMAGE_COMPRESS_QUIC ] = "quic",
> >  [ SPICE_IMAGE_COMPRESS_GLZ ]  = "glz",
> >  [ SPICE_IMAGE_COMPRESS_LZ ]   = "lz",
> > 
> > +[ SPICE_IMAGE_COMPRESS_LZ4 ]  = "lz4",
> > 
> >  };
> >  #define parse_compression(_name)\
> >  
> >  parse_name(_name, "image compression",  \
> > 
> > --
> > 1.9.3
> 
> I did a small search now and seems that also other small change to
> qemu-options.hx file should be done, search this line:
> @item image-compression=[auto_glz|auto_lz|quic|glz|lz|off]
> 
> > ___
> > 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] [RFC] LZ4 compression option for SPICE

2015-01-08 Thread Fabio Fantoni
Il 08/01/2015 11:50, Javier Celaya ha scritto:
> Hello
>
> Recently, SPICE included the lz4 compression algorithm. This patch adds
> a command line option to select it. However, SPICE_IMAGE_COMPRESS_LZ4 did not 
> exist before the commit that added this compression algorithm, so it should 
> be 
> guarded with conditional compilation. How do you think this should be done? 
> Wait for the next stable version of spice-server and check for 
> SPICE_SERVER_VERSION? Or add a specific flag?
>
> Thank you
> ---
>  ui/spice-core.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/ui/spice-core.c b/ui/spice-core.c
> index 6467fa4..fb6534e 100644
> --- a/ui/spice-core.c
> +++ b/ui/spice-core.c
> @@ -359,6 +359,7 @@ static const char *compression_names[] = {
>  [ SPICE_IMAGE_COMPRESS_QUIC ] = "quic",
>  [ SPICE_IMAGE_COMPRESS_GLZ ]  = "glz",
>  [ SPICE_IMAGE_COMPRESS_LZ ]   = "lz",
> +[ SPICE_IMAGE_COMPRESS_LZ4 ]  = "lz4",
>  };
>  #define parse_compression(_name)\
>  parse_name(_name, "image compression",  \
> --
> 1.9.3

I did a small search now and seems that also other small change to
qemu-options.hx file should be done, search this line:
@item image-compression=[auto_glz|auto_lz|quic|glz|lz|off]

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




smime.p7s
Description: Firma crittografica S/MIME
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH] [RFC] LZ4 compression option for SPICE

2015-01-08 Thread Gerd Hoffmann
On Do, 2015-01-08 at 11:50 +0100, Javier Celaya wrote:
> Hello
> 
> Recently, SPICE included the lz4 compression algorithm. This patch adds
> a command line option to select it. However, SPICE_IMAGE_COMPRESS_LZ4 did not 
> exist before the commit that added this compression algorithm, so it should 
> be 
> guarded with conditional compilation. How do you think this should be done? 
> Wait for the next stable version of spice-server and check for 
> SPICE_SERVER_VERSION? Or add a specific flag?

Given that SPICE_IMAGE_COMPRESS_LZ4 is a enum not define (so you can't
just #ifdef SPICE_IMAGE_COMPRESS_LZ4) using SPICE_SERVER_VERSION looks
best to me.

cheers,
  Gerd


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


[Spice-devel] [PATCH] [RFC] LZ4 compression option for SPICE

2015-01-08 Thread Javier Celaya
Hello

Recently, SPICE included the lz4 compression algorithm. This patch adds
a command line option to select it. However, SPICE_IMAGE_COMPRESS_LZ4 did not 
exist before the commit that added this compression algorithm, so it should be 
guarded with conditional compilation. How do you think this should be done? 
Wait for the next stable version of spice-server and check for 
SPICE_SERVER_VERSION? Or add a specific flag?

Thank you
---
 ui/spice-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6467fa4..fb6534e 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -359,6 +359,7 @@ static const char *compression_names[] = {
 [ SPICE_IMAGE_COMPRESS_QUIC ] = "quic",
 [ SPICE_IMAGE_COMPRESS_GLZ ]  = "glz",
 [ SPICE_IMAGE_COMPRESS_LZ ]   = "lz",
+[ SPICE_IMAGE_COMPRESS_LZ4 ]  = "lz4",
 };
 #define parse_compression(_name)\
 parse_name(_name, "image compression",  \
--
1.9.3

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


Re: [Spice-devel] [PATCH spice-html5 3/4] Implement methods for transfering files from client to guest

2015-01-08 Thread Pavel Grunt

> 
> > +if (msg.type == SPICE_MSG_MAIN_AGENT_DATA)
> > +{
> > +var agent_data = new SpiceMsgcMainAgentData(0, msg.data);
> 
> This should be a separate type; SpiceMsgMainAgentData, not Msgc.
> 
> > +SpiceMainConn.prototype.file_xfer_start = function(file)
> > +{
> > +var task_id, xfer_start, task;
> > +
> > +if (typeof this.file_xfer_tasks === "undefined")
> > +this.file_xfer_tasks = {};
> 
> Isn't that redundant to the initialization above?
> 
Yes, it is.
> > +
> > +task_id = Object.keys(this.file_xfer_tasks).length;
> 
> Aren't you running a risk of reusing task ids and running into
> possible
> collisions with this approach?
>

The task id is removed on the guest side as well when the task is completed, so 
there should be no problem. I can add the task counter.

>
>  > +if (!this.file_xfer_tasks[file_xfer_status.id]) {
> 
> This code base is mostly not K&R brace style; if you could follow
> that,
> I'd appreciate it.
> 
> 
> > +case VD_AGENT_FILE_XFER_STATUS_CANCELLED:
> > +xfer_error = "transfer is cancelled by spice agent";
> > +break;
> 
> How common is this case?  If it happens with any frequency, we may
> want
> to plan for some better clean up.  (e.g. don't uselessly read +
> transmit
> a huge file after it's been canceled).  You file onload callback
> could
> check for the existence of the task and abort if it vanishes.
> 
It didn't happened during my tests, but the check should be there.


Thanks for the review, I will send v2.

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


Re: [Spice-devel] [xf86-video-qxl v6] Enable smartcard support for XSpice.

2015-01-08 Thread Uri Lublin

Hi Jeremy,

Ack.

Please see two minor comments below.

Thanks,
Uri.


On 12/16/2014 12:24 AM, Jeremy White wrote:

This is done by creating a Unix domain socket to which smartcard
messages are transferred, using the vscard protocol.

A further system library, spiceccid, is used to provide an interface into
pcsc-lite, specifically the pcsc-lite daemon, so that regular Unix applications
can access the passed through smartcard information.

Signed-off-by: Jeremy White
---
  configure.ac   |   25 ++
  examples/spiceqxl.xorg.conf.example|3 +
  src/Makefile.am|3 +-
  src/qxl.h  |2 +
  src/qxl_driver.c   |   14 +-
  src/spiceccid/Makefile.am  |   29 ++
  src/spiceccid/spice.pcsc.conf.template |7 +
  src/spiceccid/spiceccid.c  |  477 
  src/spiceqxl_smartcard.c   |  193 +
  src/spiceqxl_smartcard.h   |   31 +++
  10 files changed, 782 insertions(+), 2 deletions(-)
  create mode 100644 src/spiceccid/Makefile.am
  create mode 100644 src/spiceccid/spice.pcsc.conf.template
  create mode 100644 src/spiceccid/spiceccid.c
  create mode 100644 src/spiceqxl_smartcard.c
  create mode 100644 src/spiceqxl_smartcard.h

+++ b/src/spiceccid/spiceccid.c
@@ -0,0 +1,477 @@
+/*
+ * Copyright (C) 2014 CodeWeavers, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *Jeremy White
+ */
+
+/*
+  Chip/Smart Card Interface Devices driver for Spice
+
+This driver is built to interface to pcsc-lite as a serial smartcard
+  device.
+It translates the IFD (Interface device) ABI into the Spice protocol.
+*/
+



+
+static void process_atr(smartcard_ccid_t *ccid, VSCMsgHeader *h, char *data)
+{
+ccid->atr_len = h->length;
+if (h->length > 0 && h->length > sizeof(ccid->atr)) {


h->length is unsigned.
1. Why is there a need to check that h->length > 0 ?
2. What happens if h->length == 0 ?


+fprintf(stderr, "Supplied ATR of length %d exceeds %d maximum\n",
+h->length, sizeof(ccid->atr));
+send_reply(ccid, VSC_GENERAL_ERROR);
+return;
+}
+
+memset(ccid->atr, 0, sizeof(ccid->atr));
+memcpy(ccid->atr, data, ccid->atr_len);
+
+send_reply(ccid, VSC_SUCCESS);
+}
+
+static void process_apdu(smartcard_ccid_t *ccid, VSCMsgHeader *h, char *data)
+{
+if (ccid->state & STATE_READER_ADDED)
+push_apdu(ccid, data, h->length);


Maybe add: else { fprintf(stderr, "warning ..." }


+}
+
+static void process_card_remove(smartcard_ccid_t *ccid, VSCMsgHeader *h)
+{
+ccid->atr_len = 0;
+memset(ccid->atr, 0, sizeof(ccid->atr));
+send_reply(ccid, VSC_SUCCESS);
+}
+

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


Re: [Spice-devel] [PATCH spice-html5 1/4] Handle agent tokens

2015-01-08 Thread Pavel Grunt

> 
> Since you're genuinely using this message, shouldn't we now advertise
> the connected token CAP?
> 

I am not sure what CAP you mean. We send the SPICE_MSGC_MAIN_AGENT_START 
message when the SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS message is received.

Best regards,

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


Re: [Spice-devel] [PATCH spice-html5 0/4] Enable file transfer from client to guest

2015-01-08 Thread Pavel Grunt
Hi Jeremy,

Thanks a lot for your feedback.

> 
> Hi Pavel,
> 
> 
> This looks like a great addition; thanks for doing this work.
> 
> I've got a few general questions, and then some specific comments on
> some of the patches.
> 
> General questions:  what browsers have you tested this with?
> Ostensibly, spice-html5 works with IE, Firefox and Google, and I'd
> like
> to maintain that.
> 

It worked in Firefox and Google Chrome, but I was unable to run spice-html5 in 
IE11 (I guess it was because IE11 does not support MediaSource API).

> Also, what file sizes have you tried?  I have some concern that the
> implementation appears to need to read the whole file into memory.
>  Do I
> read that right?  That is, it looks like you read all the slices in,
> and
> then send when tokens are available.  Did you consider an
> implementation
> that only reads when tokens are available?
> 

I have tried file sizes from few bytes up to 300MB. The approach you described 
is probably better, I can rewrite it that way.

Best regards,

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