[Spice-devel] [PATCH linux vdagent v3 9/9] Send display IDs to daemon when device info changes

2019-01-07 Thread Jonathon Jongsma
When the agent gets a new device info message (from the daemon), we need
to re-calculate the guest output map and send that information back down
to the daemon so that it can handle mouse input events correctly.
---
 src/vdagent/x11-randr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 0fe2056..ed30b44 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -860,6 +860,9 @@ void vdagent_x11_handle_graphics_device_info(struct 
vdagent_x11 *x11, uint8_t *d
 device_display_info = (VDAgentDeviceDisplayInfo*) ((char*) 
device_display_info +
 sizeof(VDAgentDeviceDisplayInfo) + 
device_display_info->device_address_len);
 }
+
+// make sure daemon is up-to-date with (possibly updated) device IDs
+vdagent_x11_send_daemon_guest_xorg_res(x11, 1);
 }
 
 static int get_output_index_for_display_id(struct vdagent_x11 *x11, int 
display_id)
-- 
2.17.2

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


[Spice-devel] [PATCH linux vdagent v3 7/9] Use new function in vdagent_x11_send_daemon_guest_xorg_res()

2019-01-07 Thread Jonathon Jongsma
Rather than getting the current guest resolution in a
VDAgentMonitorsConfig struct and then translating it to a new struct
type for sending down to the daemon, simply use the new function that
was factored out in a previous commit and populate the message struct
directly.
---
 src/vdagent/x11-randr.c | 20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index fc7c30f..09b27c7 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -1061,25 +1061,21 @@ void vdagent_x11_send_daemon_guest_xorg_res(struct 
vdagent_x11 *x11, int update)
 int i, width = 0, height = 0, screen_count = 0;
 
 if (x11->has_xrandr) {
-VDAgentMonitorsConfig *curr;
-
 if (update)
 update_randr_res(x11, 0);
 
-curr = get_current_mon_config(x11);
-if (!curr)
-goto no_info;
-
-screen_count = curr->num_of_monitors;
+screen_count = x11->randr.res->noutput;
 res = g_new(struct vdagentd_guest_xorg_resolution, screen_count);
 
 for (i = 0; i < screen_count; i++) {
-res[i].width  = curr->monitors[i].width;
-res[i].height = curr->monitors[i].height;
-res[i].x = curr->monitors[i].x;
-res[i].y = curr->monitors[i].y;
+struct vdagentd_guest_xorg_resolution *curr = [i];
+if (!get_monitor_info_for_output_index(x11, i, >x, >y,
+   >width, >height)
+{
+g_free(res);
+goto no_info;
+}
 }
-g_free(curr);
 width  = x11->width[0];
 height = x11->height[0];
 } else if (x11->has_xinerama) {
-- 
2.17.2

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


[Spice-devel] [PATCH linux vdagent v3 6/9] Factor a function out of get_current_mon_config()

2019-01-07 Thread Jonathon Jongsma
When sending the guest xorg resolution to the vdagentd daemon, we get
the current resolution with this function, which returns a
VDAgentMonitorsConfig structure that must then be converted to the
structure that we send to the daemon. Rather than re-using this function
that returns the wrong type, factor out most of the functionality into a
separate function. This function can be used by a new function to return
a type appropriate for sending the xorg resolution to the daemon.

This is necessary because in the next few commits I'll be changing the
vdagentd protocol to send an additional display_id parameter to the
daemon.
---
 src/vdagent/x11-randr.c | 73 +
 1 file changed, 52 insertions(+), 21 deletions(-)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 747dd9d..fc7c30f 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -688,38 +688,69 @@ static int config_size(int num_of_monitors)
num_of_monitors * sizeof(VDAgentMonConfig);
 }
 
+
+// gets monitor information about the specified output index and returns true 
if there was no error
+static bool get_monitor_info_for_output_index(struct vdagent_x11 *x11, int 
output_index, int *x, int *y, int *width, int *height)
+{
+g_return_val_if_fail (output_index < x11->randr.res->noutput, false);
+g_return_val_if_fail (x != NULL, false);
+g_return_val_if_fail (y != NULL, false);
+g_return_val_if_fail (width != NULL, false);
+g_return_val_if_fail (height != NULL, false);
+
+int j;
+XRRCrtcInfo *crtc = NULL;
+XRRModeInfo *mode;
+
+if (x11->randr.outputs[output_index]->ncrtc == 0)
+goto zeroed; /* Monitor disabled */
+
+for (j = 0; crtc == NULL && j < x11->randr.outputs[output_index]->ncrtc; 
j++) {
+crtc = crtc_from_id(x11, x11->randr.outputs[output_index]->crtcs[j]);
+}
+if (!crtc) {
+// error. stale xrandr info?
+return false;
+}
+
+mode = mode_from_id(x11, crtc->mode);
+if (!mode)
+goto zeroed; /* monitor disabled */
+
+*x = crtc->x;
+*y = crtc->y;
+*width = mode->width;
+*height = mode->height;
+return true;
+
+zeroed:
+*x = 0;
+*y = 0;
+*width = 0;
+*height = 0;
+return true;
+}
+
 static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11)
 {
 int i, num_of_monitors = 0;
-XRRModeInfo *mode;
 XRRScreenResources *res = x11->randr.res;
 VDAgentMonitorsConfig *mon_config;
 
 mon_config = g_malloc0(config_size(res->noutput));
 
 for (i = 0 ; i < res->noutput; i++) {
-int j;
-XRRCrtcInfo *crtc = NULL;
-
-if (x11->randr.outputs[i]->ncrtc == 0)
-continue; /* Monitor disabled, already zero-ed by calloc */
-if (x11->randr.outputs[i]->crtc == 0)
-continue; /* Monitor disabled */
-
-for (j = 0; crtc == NULL && j < x11->randr.outputs[i]->ncrtc; j++) {
-crtc = crtc_from_id(x11, x11->randr.outputs[i]->crtcs[j]);
-}
-if (!crtc)
+int x, y, width, height;
+if (!get_monitor_info_for_output_index(x11, i, , , , 
)) {
+syslog(LOG_WARNING, "Unable to get monitor info for output id %d", 
i);
 goto error;
+}
 
-mode = mode_from_id(x11, crtc->mode);
-if (!mode)
-continue; /* Monitor disabled, already zero-ed by calloc */
-
-mon_config->monitors[i].x  = crtc->x;
-mon_config->monitors[i].y  = crtc->y;
-mon_config->monitors[i].width  = mode->width;
-mon_config->monitors[i].height = mode->height;
+VDAgentMonConfig *mon = _config->monitors[i];
+mon->x = x;
+mon->y = y;
+mon->width = width;
+mon->height = height;
 num_of_monitors = i + 1;
 }
 mon_config->num_of_monitors = num_of_monitors;
-- 
2.17.2

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


[Spice-devel] [PATCH linux vdagent v3 8/9] Send display_id down to the vdagentd daemon

2019-01-07 Thread Jonathon Jongsma
Add a display_id field to the structure that we use to send down the
list of guest display resolutions to the vdagentd daemon. This allows us
to map the spice display id to the proper X display for determining
mouse locations, etc.
---
 src/vdagent/x11-randr.c | 35 ---
 src/vdagentd-proto.h|  1 +
 src/vdagentd/uinput.c   | 23 ++-
 3 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 09b27c7..0fe2056 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -688,6 +688,34 @@ static int config_size(int num_of_monitors)
num_of_monitors * sizeof(VDAgentMonConfig);
 }
 
+static int get_display_id_for_output_index(struct vdagent_x11 *x11, int 
output_index)
+{
+// invalid output index
+if (output_index >= x11->randr.res->noutput) {
+syslog(LOG_WARNING, "Invalid output index %d (>%d)", output_index, 
x11->randr.res->noutput);
+return -1;
+}
+
+if (g_hash_table_size(x11->guest_output_map) == 0) {
+syslog(LOG_DEBUG, "No guest output map, using output index as display 
id");
+return output_index;
+}
+
+int display_id = -1;
+RROutput output_id = x11->randr.res->outputs[output_index];
+GHashTableIter iter;
+gpointer key, value;
+g_hash_table_iter_init(, x11->guest_output_map);
+while (g_hash_table_iter_next(, , )) {
+gint64 *other_id = value;
+if (*other_id == output_id) {
+return GPOINTER_TO_INT(key);
+}
+}
+
+syslog(LOG_WARNING, "Unable to find a display id for output index %d)", 
output_index);
+return display_id;
+}
 
 // gets monitor information about the specified output index and returns true 
if there was no error
 static bool get_monitor_info_for_output_index(struct vdagent_x11 *x11, int 
output_index, int *x, int *y, int *width, int *height)
@@ -1070,11 +1098,12 @@ void vdagent_x11_send_daemon_guest_xorg_res(struct 
vdagent_x11 *x11, int update)
 for (i = 0; i < screen_count; i++) {
 struct vdagentd_guest_xorg_resolution *curr = [i];
 if (!get_monitor_info_for_output_index(x11, i, >x, >y,
-   >width, >height)
+   >width, 
>height))
 {
 g_free(res);
 goto no_info;
 }
+curr->display_id = get_display_id_for_output_index(x11, i);
 }
 width  = x11->width[0];
 height = x11->height[0];
@@ -1126,8 +1155,8 @@ no_info:
 if (x11->debug) {
 syslog(LOG_DEBUG, "Sending guest screen resolutions to vdagentd:");
 for (i = 0; i < screen_count; i++) {
-syslog(LOG_DEBUG, "   screen %d %dx%d%+d%+d", i,
-   res[i].width, res[i].height, res[i].x, res[i].y);
+syslog(LOG_DEBUG, "   screen %d %dx%d%+d%+d, id=%d", i,
+   res[i].width, res[i].height, res[i].x, res[i].y, 
res[i].display_id);
 }
 }
 
diff --git a/src/vdagentd-proto.h b/src/vdagentd-proto.h
index 243a9c6..7eff71d 100644
--- a/src/vdagentd-proto.h
+++ b/src/vdagentd-proto.h
@@ -53,6 +53,7 @@ struct vdagentd_guest_xorg_resolution {
 int height;
 int x;
 int y;
+int display_id;
 };
 
 #endif
diff --git a/src/vdagentd/uinput.c b/src/vdagentd/uinput.c
index 4f854bf..ff37e1e 100644
--- a/src/vdagentd/uinput.c
+++ b/src/vdagentd/uinput.c
@@ -175,6 +175,18 @@ static void uinput_send_event(struct vdagentd_uinput 
**uinputp,
 }
 }
 
+static struct vdagentd_guest_xorg_resolution* lookup_screen_info(struct 
vdagentd_uinput *uinput, int display_id)
+{
+int i;
+for (i = 0; i < uinput->screen_count; i++) {
+if (uinput->screen_info[i].display_id == display_id) {
+return >screen_info[i];
+}
+}
+syslog(LOG_WARNING, "Unable to find output index for display id %d", 
display_id);
+return NULL;
+}
+
 void vdagentd_uinput_do_mouse(struct vdagentd_uinput **uinputp,
 VDAgentMouseState *mouse)
 {
@@ -196,16 +208,17 @@ void vdagentd_uinput_do_mouse(struct vdagentd_uinput 
**uinputp,
 int i, down;
 
 if (*uinputp) {
-if (mouse->display_id >= uinput->screen_count) {
-syslog(LOG_WARNING, "mouse event for unknown monitor (%d >= %d)",
-   mouse->display_id, uinput->screen_count);
+struct vdagentd_guest_xorg_resolution *screen_info = 
lookup_screen_info(uinput, mouse->display_id);
+if (screen_info == NULL) {
+syslog(LOG_WARNING, "mouse event for unknown monitor %d",
+   mouse->display_id);
 return;
 }
 if (uinput->debug)
 syslog(LOG_DEBUG, "mouse-event: mon %d %dx%d", mouse->display_id,
mouse->x, mouse->y);
-mouse->x += uinput->screen_info[mouse->display_id].x;
-mouse->y += 

[Spice-devel] [PATCH linux vdagent v3 3/9] Look up and store xrandr output in display map

2019-01-07 Thread Jonathon Jongsma
Instead of storing each device address and device display ID in the hash
table, simply use the lookup_xrandr_output_for_device_info() function to
look up the ID of the xrandr output and store that in the hash table.
---
 src/vdagent/x11-priv.h  |  2 +-
 src/vdagent/x11-randr.c | 47 +++--
 src/vdagent/x11.c   | 20 ++
 3 files changed, 30 insertions(+), 39 deletions(-)

diff --git a/src/vdagent/x11-priv.h b/src/vdagent/x11-priv.h
index 0e954cf..e487aa2 100644
--- a/src/vdagent/x11-priv.h
+++ b/src/vdagent/x11-priv.h
@@ -139,7 +139,7 @@ struct vdagent_x11 {
 int xrandr_minor;
 int has_xinerama;
 int dont_send_guest_xorg_res;
-GHashTable *graphics_display_infos;
+GHashTable *guest_output_map;
 };
 
 extern int (*vdagent_x11_prev_error_handler)(Display *, XErrorEvent *);
diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 4fed458..4daacc6 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -728,11 +728,6 @@ static void dump_monitors_config(struct vdagent_x11 *x11,
 }
 }
 
-typedef struct GraphicsDisplayInfo {
-char device_address[256];
-uint32_t device_display_id;
-} GraphicsDisplayInfo;
-
 // handle the device info message from the server. This will allow us to
 // maintain a mapping from spice display id to xrandr output
 void vdagent_x11_handle_graphics_device_info(struct vdagent_x11 *x11, uint8_t 
*data, size_t size)
@@ -753,31 +748,33 @@ void vdagent_x11_handle_graphics_device_info(struct 
vdagent_x11 *x11, uint8_t *d
 break;
 }
 
-GraphicsDisplayInfo *value = g_malloc(sizeof(GraphicsDisplayInfo));
-
-size_t device_address_len = device_display_info->device_address_len;
-if (device_address_len > sizeof(value->device_address)) {
-syslog(LOG_ERR, "Received a device address longer than %lu, "
-   "will be truncated!", device_address_len);
-device_address_len = sizeof(value->device_address);
-}
+// make sure the string is terminated:
+
device_display_info->device_address[device_display_info->device_address_len] = 
'\0';
 
-strncpy(value->device_address,
-(char*) device_display_info->device_address,
-device_address_len);
-value->device_address[device_address_len] = '\0';  // make sure the 
string is terminated
-value->device_display_id = device_display_info->device_display_id;
+RROutput x_output;
+if (lookup_xrandr_output_for_device_info(device_display_info, 
x11->display, x11->randr.res, _output)) {
+gint64 *value = g_new(gint64, 1);
+*value = x_output;
 
-syslog(LOG_INFO, "   channel_id: %u monitor_id: %u device_address: %s, 
"
-   "device_display_id: %u",
-   device_display_info->channel_id,
-   device_display_info->monitor_id,
-   value->device_address,
-   value->device_display_id);
+syslog(LOG_INFO, "   channel_id: %u monitor_id: %u device_address: 
%s, "
+   "device_display_id: %u xrandr output ID: %lu",
+   device_display_info->channel_id,
+   device_display_info->monitor_id,
+   device_display_info->device_address,
+   device_display_info->device_display_id,
+   x_output);
 
-g_hash_table_insert(x11->graphics_display_infos,
+g_hash_table_insert(x11->guest_output_map,
 GUINT_TO_POINTER(device_display_info->channel_id + 
device_display_info->monitor_id),
 value);
+} else {
+syslog(LOG_INFO, "   channel_id: %u monitor_id: %u device_address: 
%s, "
+   "device_display_id: %u xrandr output ID NOT FOUND",
+   device_display_info->channel_id,
+   device_display_info->monitor_id,
+   device_display_info->device_address,
+   device_display_info->device_display_id);
+}
 
 device_display_info = (VDAgentDeviceDisplayInfo*) ((char*) 
device_display_info +
 sizeof(VDAgentDeviceDisplayInfo) + 
device_display_info->device_address_len);
diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
index 2473383..a456678 100644
--- a/src/vdagent/x11.c
+++ b/src/vdagent/x11.c
@@ -196,12 +196,6 @@ static gchar *vdagent_x11_get_wm_name(struct vdagent_x11 
*x11)
 #endif
 }
 
-static void graphics_display_info_destroy(gpointer gdi)
-{
-g_free(gdi);
-}
-
-
 struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd,
 int debug, int sync)
 {
@@ -218,6 +212,12 @@ struct vdagent_x11 *vdagent_x11_create(struct 
udscs_connection *vdagentd,
 x11->vdagentd = vdagentd;
 x11->debug = debug;
 
+x11->guest_output_map = g_hash_table_new_full(_direct_hash,
+  _direct_equal,
+ 

[Spice-devel] [PATCH linux vdagent v3 0/9] Use the PCI addr and display ID

2019-01-07 Thread Jonathon Jongsma
This is a patch set that handles the PCI address and device dispay ID
sent down to the agent by the server, and uses that to maintain a map
for looking up a particular xrandr output for a given spice display id.

This patch series builds on the patch from Lukas titled "Receive the
graphics_device_info message". It incorporates a lot of the code from my
previous POC patch series but reorganizes and restructures it.

Several of the patches in the series are semi-related cleanups that I
ran across while working on the feature.

Changes in v3:
 - Fixed a bug where the X Display was not set properly and caused a
   crash
 - moved call to vdagent_x11_send_daemon_guest_xorg_res() to outside the
   loop to avoid sending multiple times when more than one device is
   received. (Patch 9)

Changes in v2:
 - Removed some ACKed and merged patches
   - Fix typo in comment
   - Fix confusion between output index and crtc index
 - added a patch to send new display IDs when device info changes
 - multiple changes from review
   - factored out function find_device_at_pci_address()
   - No more initializing X/XRandr
   - removed goto
   - improved logging
   - etc.

Jonathon Jongsma (9):
  Add lookup_xrand_output_for_device_info()
  Move handling of DeviceInfo to vdagent_x11
  Look up and store xrandr output in display map
  Make clearer distinctions between output ids
  Use guest output map to determine xrandr output
  Factor a function out of get_current_mon_config()
  Use new function in vdagent_x11_send_daemon_guest_xorg_res()
  Send display_id down to the vdagentd daemon
  Send display IDs to daemon when device info changes

 Makefile.am   |  14 ++
 configure.ac  |   1 +
 src/vdagent/device-info.c | 490 ++
 src/vdagent/device-info.h |  27 +++
 src/vdagent/vdagent.c |  68 +-
 src/vdagent/x11-priv.h|   1 +
 src/vdagent/x11-randr.c   | 306 +++-
 src/vdagent/x11.c |   7 +
 src/vdagent/x11.h |   1 +
 src/vdagentd-proto.h  |   1 +
 src/vdagentd/uinput.c |  23 +-
 tests/test-device-info.c  | 262 
 12 files changed, 1063 insertions(+), 138 deletions(-)
 create mode 100644 src/vdagent/device-info.c
 create mode 100644 src/vdagent/device-info.h
 create mode 100644 tests/test-device-info.c

-- 
2.17.2

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


[Spice-devel] [PATCH linux vdagent v3 2/9] Move handling of DeviceInfo to vdagent_x11

2019-01-07 Thread Jonathon Jongsma
---
 src/vdagent/vdagent.c   | 68 +
 src/vdagent/x11-priv.h  |  1 +
 src/vdagent/x11-randr.c | 58 +++
 src/vdagent/x11.c   | 13 
 src/vdagent/x11.h   |  1 +
 5 files changed, 74 insertions(+), 67 deletions(-)

diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index e982a1f..aa52ee9 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -50,7 +50,6 @@ typedef struct VDAgent {
 struct vdagent_file_xfers *xfers;
 struct udscs_connection *conn;
 GIOChannel *x11_channel;
-GHashTable *graphics_display_infos;
 
 GMainLoop *loop;
 } VDAgent;
@@ -93,16 +92,6 @@ static GOptionEntry entries[] = {
 { NULL }
 };
 
-typedef struct GraphicsDisplayInfo {
-char device_address[256];
-uint32_t device_display_id;
-} GraphicsDisplayInfo;
-
-static void graphics_display_info_destroy(gpointer gdi)
-{
-g_free(gdi);
-}
-
 /**
  * xfer_get_download_directory
  *
@@ -167,55 +156,6 @@ static gboolean vdagent_finalize_file_xfer(VDAgent *agent)
 return TRUE;
 }
 
-static void vdagent_handle_graphics_device_info(VDAgent *agent, uint8_t *data, 
size_t size)
-{
-VDAgentGraphicsDeviceInfo *graphics_device_info = 
(VDAgentGraphicsDeviceInfo *)data;
-VDAgentDeviceDisplayInfo *device_display_info = 
graphics_device_info->device_info;
-
-void *buffer_end = data + size;
-
-syslog(LOG_INFO, "Received Graphics Device Info:");
-
-for (size_t i = 0; i < graphics_device_info->count; ++i) {
-if ((void*) device_display_info > buffer_end ||
-(void*) (_display_info->device_address +
-device_display_info->device_address_len) > buffer_end) {
-syslog(LOG_ERR, "Malformed graphics_display_info message, "
-   "extends beyond the end of the buffer");
-break;
-}
-
-GraphicsDisplayInfo *value = g_malloc(sizeof(GraphicsDisplayInfo));
-
-size_t device_address_len = device_display_info->device_address_len;
-if (device_address_len > sizeof(value->device_address)) {
-syslog(LOG_ERR, "Received a device address longer than %lu, "
-   "will be truncated!", device_address_len);
-device_address_len = sizeof(value->device_address);
-}
-
-strncpy(value->device_address,
-(char*) device_display_info->device_address,
-device_address_len);
-value->device_address[device_address_len] = '\0';  // make sure the 
string is terminated
-value->device_display_id = device_display_info->device_display_id;
-
-syslog(LOG_INFO, "   channel_id: %u monitor_id: %u device_address: %s, 
"
-   "device_display_id: %u",
-   device_display_info->channel_id,
-   device_display_info->monitor_id,
-   value->device_address,
-   value->device_display_id);
-
-g_hash_table_insert(agent->graphics_display_infos,
-GUINT_TO_POINTER(device_display_info->channel_id + 
device_display_info->monitor_id),
-value);
-
-device_display_info = (VDAgentDeviceDisplayInfo*) ((char*) 
device_display_info +
-sizeof(VDAgentDeviceDisplayInfo) + 
device_display_info->device_address_len);
-}
-}
-
 static void vdagent_quit_loop(VDAgent *agent)
 {
 /* other GMainLoop(s) might be running, quit them before agent->loop */
@@ -301,7 +241,7 @@ static void daemon_read_complete(struct udscs_connection 
**connp,
 }
 break;
 case VDAGENTD_GRAPHICS_DEVICE_INFO:
-vdagent_handle_graphics_device_info(agent, data, header->size);
+vdagent_x11_handle_graphics_device_info(agent->x11, data, 
header->size);
 break;
 case VDAGENTD_CLIENT_DISCONNECTED:
 vdagent_clipboards_release_all(agent->clipboards);
@@ -409,11 +349,6 @@ static VDAgent *vdagent_new(void)
 g_unix_signal_add(SIGHUP, vdagent_signal_handler, agent);
 g_unix_signal_add(SIGTERM, vdagent_signal_handler, agent);
 
-agent->graphics_display_infos = g_hash_table_new_full(_direct_hash,
-  _direct_equal,
-  NULL,
-  
_display_info_destroy);
-
 return agent;
 }
 
@@ -428,7 +363,6 @@ static void vdagent_destroy(VDAgent *agent)
 
 g_clear_pointer(>x11_channel, g_io_channel_unref);
 g_clear_pointer(>loop, g_main_loop_unref);
-g_hash_table_destroy(agent->graphics_display_infos);
 g_free(agent);
 }
 
diff --git a/src/vdagent/x11-priv.h b/src/vdagent/x11-priv.h
index b31b0a5..0e954cf 100644
--- a/src/vdagent/x11-priv.h
+++ b/src/vdagent/x11-priv.h
@@ -139,6 +139,7 @@ struct vdagent_x11 {
 int xrandr_minor;
 int has_xinerama;
 int dont_send_guest_xorg_res;
+GHashTable *graphics_display_infos;
 };
 
 extern int 

[Spice-devel] [PATCH linux vdagent v3 1/9] Add lookup_xrand_output_for_device_info()

2019-01-07 Thread Jonathon Jongsma
Add a function to look up an xrandr output for a given device display
id. This uses sysfs and the drm subsystem to lookup information about a
graphics device output. It then compares the drm output name to xrandr
output names to try to match that device output to an xrandr output.
This is necesary for guests that have multiple graphics devices.
---
 Makefile.am   |  14 ++
 configure.ac  |   1 +
 src/vdagent/device-info.c | 490 ++
 src/vdagent/device-info.h |  27 +++
 tests/test-device-info.c  | 262 
 5 files changed, 794 insertions(+)
 create mode 100644 src/vdagent/device-info.c
 create mode 100644 src/vdagent/device-info.h
 create mode 100644 tests/test-device-info.c

diff --git a/Makefile.am b/Makefile.am
index 3e405bc..d2f2258 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,7 @@ common_sources =  \
$(NULL)
 
 src_spice_vdagent_CFLAGS = \
+   $(DRM_CFLAGS)   \
$(X_CFLAGS) \
$(SPICE_CFLAGS) \
$(GLIB2_CFLAGS) \
@@ -22,6 +23,7 @@ src_spice_vdagent_CFLAGS =\
$(NULL)
 
 src_spice_vdagent_LDADD =  \
+   $(DRM_LIBS) \
$(X_LIBS)   \
$(SPICE_LIBS)   \
$(GLIB2_LIBS)   \
@@ -35,6 +37,8 @@ src_spice_vdagent_SOURCES =   \
src/vdagent/audio.h \
src/vdagent/clipboard.c \
src/vdagent/clipboard.h \
+   src/vdagent/device-info.c   \
+   src/vdagent/device-info.h   \
src/vdagent/file-xfers.c\
src/vdagent/file-xfers.h\
src/vdagent/x11-priv.h  \
@@ -137,3 +141,13 @@ EXTRA_DIST =   \
 DISTCHECK_CONFIGURE_FLAGS =\
--with-init-script=redhat   \
$(NULL)
+
+tests_test_device_info_LDADD = $(src_spice_vdagent_LDADD)
+tests_test_device_info_CFLAGS = $(src_spice_vdagent_CFLAGS)
+
+check_PROGRAMS =   \
+   tests/test-device-info  \
+   $(NULL)
+
+TESTS = $(check_PROGRAMS)
+
diff --git a/configure.ac b/configure.ac
index 7cb44db..55b031e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,7 @@ PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
 PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.13])
 PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
 PKG_CHECK_MODULES([DBUS], [dbus-1])
+PKG_CHECK_MODULES([DRM], [libdrm])
 
 if test "$with_session_info" = "auto" || test "$with_session_info" = 
"systemd"; then
 PKG_CHECK_MODULES([LIBSYSTEMD_LOGIN],
diff --git a/src/vdagent/device-info.c b/src/vdagent/device-info.c
new file mode 100644
index 000..5936432
--- /dev/null
+++ b/src/vdagent/device-info.c
@@ -0,0 +1,490 @@
+/*  device-info.c utility function for looking up the xrandr output id for a
+ *  given device address and display id
+ *
+ * Copyright 2018 Red Hat, Inc.
+ *
+ * Red Hat Authors:
+ * Jonathon Jongsma 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "device-info.h"
+
+#define PCI_VENDOR_ID_REDHAT 0x1b36
+#define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4 // virtio-gpu
+#define PCI_VENDOR_ID_INTEL 0x8086
+#define PCI_VENDOR_ID_NVIDIA 0x10de
+
+#define PCI_DEVICE_ID_QXL 0x0100
+#define PCI_DEVICE_ID_VIRTIO_GPU 0x1050
+
+typedef struct PciDevice {
+int domain;
+uint8_t bus;
+uint8_t slot;
+uint8_t function;
+} PciDevice;
+
+typedef struct PciAddress {
+int domain;
+GList *devices; /* PciDevice */
+} PciAddress;
+
+static PciAddress* pci_address_new()
+{
+return g_new0(PciAddress, 1);
+}
+
+static void pci_address_free(PciAddress *addr)
+{
+g_list_free_full(addr->devices, g_free);
+g_free(addr);
+}
+
+
+static int read_next_hex_number(const char *input, char delim, char **endptr)
+{
+assert(input != NULL);
+assert(endptr != NULL);
+
+

[Spice-devel] [PATCH linux vdagent v3 5/9] Use guest output map to determine xrandr output

2019-01-07 Thread Jonathon Jongsma
instead of using the spice display id directly as the xrandr output,
look it up using our new guest output map
---
 src/vdagent/x11-randr.c | 78 -
 1 file changed, 69 insertions(+), 9 deletions(-)

diff --git a/src/vdagent/x11-randr.c b/src/vdagent/x11-randr.c
index 6cb3923..747dd9d 100644
--- a/src/vdagent/x11-randr.c
+++ b/src/vdagent/x11-randr.c
@@ -399,6 +399,28 @@ static int xrandr_add_and_set(struct vdagent_x11 *x11, int 
output_index, int x,
 return 1;
 }
 
+// Looks up the xrandr output id associated with the given spice display id
+static RROutput get_xrandr_output_for_display_id(struct vdagent_x11 *x11, int 
display_id)
+{
+guint map_size = g_hash_table_size(x11->guest_output_map);
+if (map_size == 0) {
+// we never got a device info message from the server, so just use old
+// assumptions that the spice display id is equal to the index into the
+// array of xrandr outputs
+if (display_id < x11->randr.res->noutput) {
+return x11->randr.res->outputs[display_id];
+}
+} else {
+gpointer value;
+if (g_hash_table_lookup_extended(x11->guest_output_map, 
GINT_TO_POINTER(display_id), NULL, )) {
+return *(gint64*)value;
+}
+}
+
+// unable to find a valid output id
+return -1;
+}
+
 static void xrandr_disable_nth_output(struct vdagent_x11 *x11, int 
output_index)
 {
 Status s;
@@ -781,6 +803,16 @@ void vdagent_x11_handle_graphics_device_info(struct 
vdagent_x11 *x11, uint8_t *d
 }
 }
 
+static int get_output_index_for_display_id(struct vdagent_x11 *x11, int 
display_id)
+{
+RROutput oid = get_xrandr_output_for_display_id(x11, display_id);
+for (int i = 0; i < x11->randr.res->noutput; i++) {
+if (oid == x11->randr.res->outputs[i]) {
+return i;
+}
+}
+return -1;
+}
 
 /*
  * Set monitor configuration according to client request.
@@ -857,13 +889,32 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
*x11,
 g_unlink(config);
 g_free(config);
 
-for (i = mon_config->num_of_monitors; i < x11->randr.res->noutput; i++)
-xrandr_disable_nth_output(x11, i);
+// disable all outputs that don't have associated entries in the 
MonitorConfig
+for (i = 0; i < x11->randr.res->noutput; i++) {
+bool disable = true;
+// check if this xrandr output is represented by an item in mon_config
+for (int j = 0; j < mon_config->num_of_monitors; j++) {
+// j represents the display id of an enabled monitor. Check whether
+// an enabled xrandr output is represented by this id.
+RROutput oid = get_xrandr_output_for_display_id(x11, j);
+if (oid == x11->randr.res->outputs[i]) {
+disable = false;
+}
+}
+if (disable) {
+xrandr_disable_nth_output(x11, i);
+}
+}
 
-/* First, disable disabled CRTCs... */
+/* disable CRTCs that are present but explicitly disabled in the
+ * MonitorConfig */
 for (i = 0; i < mon_config->num_of_monitors; ++i) {
 if (!monitor_enabled(_config->monitors[i])) {
-xrandr_disable_nth_output(x11, i);
+int output_index = get_output_index_for_display_id(x11, i);
+if (output_index != -1)
+xrandr_disable_nth_output(x11, output_index);
+else
+syslog(LOG_WARNING, "Unable to find a guest output index for 
spice display %i", i);
 }
 }
 
@@ -886,7 +937,11 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
*x11,
 syslog(LOG_DEBUG, "Disabling monitor %d: %dx%d+%d+%d > 
(%d,%d)",
i, width, height, x, y, primary_w, primary_h);
 
-xrandr_disable_nth_output(x11, i);
+int output_index = get_output_index_for_display_id(x11, i);
+if (output_index != -1)
+xrandr_disable_nth_output(x11, output_index);
+else
+syslog(LOG_WARNING, "Unable to find a guest output index for 
spice display %i", i);
 }
 }
 
@@ -938,11 +993,16 @@ void vdagent_x11_set_monitor_config(struct vdagent_x11 
*x11,
i, width, height, x, y);
 }
 
-if (!xrandr_add_and_set(x11, i, x, y, width, height) &&
+int output_index = get_output_index_for_display_id(x11, i);
+if (output_index != -1) {
+if (!xrandr_add_and_set(x11, output_index, x, y, width, height) &&
 enabled_monitors(mon_config) == 1) {
-set_screen_to_best_size(x11, width, height,
-_w, _h);
-break;
+set_screen_to_best_size(x11, width, height,
+_w, _h);
+break;
+}
+} else {
+syslog(LOG_WARNING, "Unable to find a guest output index for spice 
display %i", 

Re: [Spice-devel] [spice-gtk v2] gtk-session: do not request guest's clipboard data unnecessarily

2019-01-07 Thread Jakub Janku
Hi,

On Mon, Jan 7, 2019 at 1:41 PM Victor Toso  wrote:
>
> From: Victor Toso 
>
> If SpiceGtkSession is holding the keyboard, that's huge indication
> that the client should not be requesting guest's clipboard data yet.
>
> This patch adds a check in clipboard_get() callback, to avoid such
> requests. In Linux, this only happens with X11 backend.
>
> This patch helps to handle a possible state race between who owns the
> grab between client and agent which could lead to agent clipboard
> failing or getting stuck, see:
>
> Linux guest:
> https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9
>
> Windows guest:
> https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6
>
> The way to reproduce the race might depend on guest system and
> applications but it is connected to amount of VDAGENTD_CLIPBOARD_GRAB
> sent by the agent which depends on the amount of clipboard changes in
> the guest. Simple example is on RHEL 6.10, with Gedit, select a text
> char by char; Client receives VDAGENTD_CLIPBOARD_GRAB every time a new
> char is selected instead of once when the full message is selected.
>
> v1 -> v2:
> * Moved the check to the right place, otherwise the patch would not
>   work on Wayland (Christophe, Jakub)
> * Improve commit log (Jakub)

Now I get it, thanks :)
>
> Related: https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6
> Related: https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9
> Related: https://bugzilla.redhat.com/show_bug.cgi?id=1594876
>
> Signed-off-by: Victor Toso 
> ---
>  src/spice-gtk-session.c | 26 ++
>  1 file changed, 26 insertions(+)
>
> diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> index 1ccae07..a78f619 100644
> --- a/src/spice-gtk-session.c
> +++ b/src/spice-gtk-session.c
> @@ -59,6 +59,7 @@ struct _SpiceGtkSessionPrivate {
>  gbooleanclip_hasdata[CLIPBOARD_LAST];
>  gbooleanclip_grabbed[CLIPBOARD_LAST];
>  gbooleanclipboard_by_guest[CLIPBOARD_LAST];
> +gbooleanclipboard_by_guest_released[CLIPBOARD_LAST];
>  /* auto-usbredir related */
>  gbooleanauto_usbredir_enable;
>  int auto_usbredir_reqs;
> @@ -634,6 +635,12 @@ static void clipboard_owner_change(GtkClipboard
> *clipboard,
>  if (s->main == NULL)
>  return;
>
> +if (s->clipboard_by_guest_released[selection]) {
> +/* Ignore owner-change event if this is just about agent releasing 
> grab */
> +s->clipboard_by_guest_released[selection] = FALSE;
> +return;
> +}
> +
>  if (s->clip_grabbed[selection]) {
>  s->clip_grabbed[selection] = FALSE;
>  if (spice_main_channel_agent_test_capability(s->main, 
> VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
> @@ -728,6 +735,14 @@ static void clipboard_get(GtkClipboard *clipboard,
>  g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
>  g_return_if_fail(s->main != NULL);
>
> +/* No real need to set clipboard data while no client application will
> + * be requested. This is useful for clients on X11 as in Wayland, this
> + * callback is only called when SpiceGtkSession:keyboard-focus is false 
> */
> +if (spice_gtk_session_get_keyboard_has_focus(self)) {
> +SPICE_DEBUG("Do not request clipboard data while holding the 
> keyboard focus");
> +return;
> +}

Have you tested this with some clipboard managers? I would expect them
to request the clipboard data as soon as they receive a new
owner-change event. So this patch may potentially cripple them, but I
might be wrong. Not sure whether this is a use-case we need to support
but it might be good to know the consequences of this patch.
> +
>  ri.selection_data = selection_data;
>  ri.info = info;
>  ri.loop = g_main_loop_new(NULL, FALSE);
> @@ -769,6 +784,15 @@ cleanup:
>
>  static void clipboard_clear(GtkClipboard *clipboard, gpointer user_data)
>  {
> +SpiceGtkSession *self = user_data;
> +SpiceGtkSessionPrivate *s = self->priv;
> +gint selection = get_selection_from_clipboard(s, clipboard);
> +
> +g_return_if_fail(selection != -1);
> +
> +if (s->clipboard_by_guest_released[selection])
> +return;
> +
This gave me a pause for a while. It seems rather weird to me that
only part of the clipboard code logs debug messages (e.g.
clipboard_get_targets() prints all the atoms but there's no logging in
clipboard_grab()). By bypassing the SPICE_DEBUG below, we would lose
track of the guest's clipboard release event as there's no log in
clipboard_release() either.

Maybe it would be useful to add some logging to the other functions as
well? (clipboard_{grab, request, release})

>  SPICE_DEBUG("clipboard_clear");
>  /* We watch for clipboard ownership changes and act on those, so we
> don't need to do anything here */
> @@ -1035,6 +1059,8 @@ static void clipboard_release(SpiceMainChannel *main, 

Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 5:46 PM Frediano Ziglio  wrote:
>
> > Hi
> >
> > On Mon, Jan 7, 2019 at 3:44 PM Frediano Ziglio  wrote:
> > >
> > > > Hi
> > > >
> > > > On Sat, Jan 5, 2019 at 9:00 PM Frediano Ziglio 
> > > > wrote:
> > > > >
> > > > > >
> > > > > > Hi
> > > > > >
> > > > > > On Sat, Jan 5, 2019 at 1:59 PM Victor Toso 
> > > > > > wrote:
> > > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > On Fri, Jan 04, 2019 at 04:48:21PM +0400,
> > > > > > > marcandre.lur...@redhat.com
> > > > > > > wrote:
> > > > > > > > From: Marc-André Lureau 
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > The series drops support for optional GStreamer dependency. 
> > > > > > > > Spice
> > > > > > > > increasingly require GStreamer for audio and video support.
> > > > > > > > GStreamer
> > > > > > > > is widely available, including in embedded space.
> > > > > > >
> > > > > > > I think this is fine indeed, not 100% sure if we shouldn't do a
> > > > > > > last release without this first. Another question is about
> > > > > >
> > > > > > As long as we don't require a too recent GStreamer (only 1.0
> > > > > > apparently, the rest is checked with GST_CHECK_VERSION), I think it
> > > > > > should be fine.
> > > > > >
> > > > > > > pulseaudio backend. If gstreamer is always enabled, I don't see
> > > > > > > why we need pulseaudio..
> > > > > >
> > > > > > Good point, I thought the the gst backend was inferior to the pulse
> > > > > > backend wrt volume handling, but you pointed out in commit message
> > > > > > 808ac1d9b3fd926f660231776d5c66946fda5664 that gst now implements it
> > > > > > for various elements.
> > > > > >
> > > > > > And with pipewire plan to replace pulseaudio (and using the 
> > > > > > gstreamer
> > > > > > elements), I think this is the path forward.
> > > > > >
> > > > >
> > > > > Is pipewire stable and cross platform? From the website I cannot find
> > > > > these
> > > > > information. Before removing some support we should make sure we have 
> > > > > a
> > > > > good
> > > > > replacement.
> > > >
> > > > There are several reasons I mentionned pipewire:
> > > > - it uses the gstreamer audio elements, which means they have to be 
> > > > quite
> > > > solid
> > >
> > > It's not true, plugins are written because is important to interact, it's
> > > not a proof that one technology us solid, just that is used.
> >
> > It has to be solid to be the core audio stack of Gnome & Fedora, and
> > replace pulseaudio.
> >
>
> It seems you are speaking of the future using a past tense. I opened
> some programs under Fedora 29 and they are using pulseaudio or alsa.
>
> > > > - spice-gtk audio should use pipewire, and GStreamer backend is a good
> > > > to do that
> > >
> > > I don't understand what you mean here. Your patch is embedding gstreamer
> > > as a requirement removing the possibility to switch multimedia framework
> > > in the future (will require to undo part of your patches).
> > > The current code allow multiple implementation, I would like to keep this
> > > possibility. I'm not saying that we cannot require gstreamer, just that
> > > should not became a design requirement.
> >
> > spice-gtk should use pipewire when available, and the GStreamer
> > backend is the way to to that.
> >
>
> Agree, or any other framework suitable.
>
> > There is no need to keep modularity if we have single backend.
> >
>
> But as we already have it I don't see the reason to remove it.
>
> > It is fairly easy to bring back modularity when we have it again.
> >
>
> Yes, at the present, but I would like to keep it keeping the
> modularity.
>
> > >
> > > >
> > > > Don't get me wrong, pipewire is not going to be a spice-gtk dependency.
> > > >
> > >
> > > Than what do you mean with "spice-gtk audio should use pipewire"?
> > > If it should use pipewire through gstreamer should be up to gstreamer
> > > to choose the best output.
> >
> > yes
> >
> > >
> > > > >
> > > > > Honestly I'm not really fun of needing GStreamer, if any platform have
> > > > > a different streaming library I'd like to be able to use it, making
> > > > > GStreamer a need is going the other direction.
> > > >
> > > > As long as we support only GStreamer for audio/video, I don't see the
> > > > point in having a switch to disable it.
> > > >
> > >
> > > Not saying to have a switch to disable, but is good to keep the
> > > possibility to switch implementation in the future.
> >
> > Again, it's really not that big of a deal. Let's not have unnecessary
> > fake modularity for a potential future backend.
> >
>
> I disagree. You are already talking about different backend.
>
> > >
> > > > >
> > > > > > I'll work on a patch to remove pulse.
> > > > > >
> > > > >
> > > > > It seems too soon.
> > > >
> > > > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > > > The recording path at least fails very often for me due to a race:
> > > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> > 

Re: [Spice-devel] [PATCH spice-gtk 20/34] meson: switch lz4 option to auto feature

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 7:58 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:49PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Contrary to spice server dependency, spice-gtk doesn't have a known
> > minimum version requirement.
>
> Ideally, we'd still check for some not very old liblz4 to avoid compile
> time failures, but the weird versioning does not make that easy :(

Indeed, so do you ack that patch or you have more concerns about it?

>
> Christophe
>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  .gitlab-ci.yml|  1 -
> >  meson.build   | 10 +++---
> >  meson_options.txt |  3 +--
> >  3 files changed, 4 insertions(+), 10 deletions(-)
> >
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index 125dbd7..692374a 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -45,7 +45,6 @@ makecheck_simple:
> >  makecheck_simple-meson:
> >script:
> >- meson build -Dauto_features=disabled
> > --Dlz4=false
> >  -Dsasl=false
> >  -Dsmartcard=false
> >  -Ddbus=false || (cat build/meson-logs/meson-log.txt && 
> > exit 1)
> > diff --git a/meson.build b/meson.build
> > index 4c9c05c..a5d584d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -287,13 +287,9 @@ endif
> >
> >  # lz4
> >  spice_gtk_has_lz4 = false
> > -if get_option('lz4')
> > -  lz4_dep = dependency('liblz4', required : false, version : '>= 129')
> > -  if not lz4_dep.found()
> > -lz4_dep = dependency('liblz4', version : '>= 1.7.3')
> > -  endif
> > -
> > -  spice_glib_deps += lz4_dep
> > +d = dependency('liblz4', required : get_option('lz4'))
> > +if d.found()
> > +  spice_glib_deps += d
> >spice_gtk_config_data.set('USE_LZ4', '1')
> >spice_gtk_has_lz4 = true
> >  endif
> > diff --git a/meson_options.txt b/meson_options.txt
> > index e92f931..abd0b0f 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -63,8 +63,7 @@ option('alignment-checks',
> >  description : 'Enable runtime checks for cast alignment')
> >
> >  option('lz4',
> > -type : 'boolean',
> > -value : true,
> > +type : 'feature',
> >  description: 'Enable lz4 compression support')
> >
> >  option('sasl',
> > --
> > 2.20.1.2.gb21ebb671b
> >
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 23/34] build-sys: remove dbus option

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 8:06 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:52PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > The desktop-integration code works by attempting to connect to GNOME
> > Session Manager. If it is absent, it will print a "Warning no
> > automount-inhibiting implementation available" message.
> >
> > Tested on win32 as well.
>
> What happens on win32? Is it showing a warning which was not there
> before?

It is showing a warning that was there before if dbus is enabled,
which apparently happens:
https://gitlab.freedesktop.org/spice/spice-gtk/issues/81

I'll add a patch to avoid the GNOME session warning on win32.

>
> Christophe
>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  .gitlab-ci.yml|  4 +---
> >  configure.ac  | 15 ---
> >  meson.build   |  7 ---
> >  meson_options.txt |  5 -
> >  src/desktop-integration.c | 18 +++---
> >  5 files changed, 4 insertions(+), 45 deletions(-)
> >
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index 750e801..74280e9 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -38,14 +38,12 @@ makecheck_simple:
> >  --enable-pulse=no
> >  --enable-smartcard=no
> >  --enable-usbredir=no
> > ---enable-dbus=no
> >- make -j4
> >- make check
> >
> >  makecheck_simple-meson:
> >script:
> > -  - meson build -Dauto_features=disabled
> > --Ddbus=false || (cat build/meson-logs/meson-log.txt && 
> > exit 1)
> > +  - meson build -Dauto_features=disabled || (cat 
> > build/meson-logs/meson-log.txt && exit 1)
> >- ninja -C build
> >- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 
> > 1)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 70587ef..a23f861 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -476,20 +476,6 @@ AM_CONDITIONAL(WITH_VALA, [test "x$enable_vala" = 
> > "xyes"])
> >  VAPIDIR="${datadir}/vala/vapi"
> >  AC_SUBST(VAPIDIR)
> >
> > -AC_ARG_ENABLE([dbus],
> > -  AS_HELP_STRING([--enable-dbus=@<:@auto/yes/no@:>@],
> > - [Enable dbus support for desktop integration (disabling 
> > automount) @<:@default=auto@:>@]),
> > -  [],
> > -  [enable_dbus="auto"])
> > -
> > -have_dbus=no
> > -if test "x$enable_dbus" != "xno"; then
> > -  AC_DEFINE([USE_GDBUS], [1], [Define if supporting gdbus])
> > -  have_dbus=yes
> > -else
> > -  SPICE_WARNING([No D-Bus support, desktop integration and USB redirection 
> > may not work properly])
> > -fi
> > -
> >  AC_ARG_ENABLE([alignment-checks],
> >AS_HELP_STRING([--enable-alignment-checks],
> >   [Enable runtime checks for cast alignment 
> > @<:@default=no@:>@]),
> > @@ -556,7 +542,6 @@ AC_MSG_NOTICE([
> >  SASL support: ${have_sasl}
> >  Smartcard support:${have_smartcard}
> >  USB redirection support:  ${have_usbredir} ${with_usbredir_hotplug}
> > -DBus: ${have_dbus}
> >  WebDAV support:   ${have_phodav}
> >  LZ4 support:  ${have_lz4}
> >
> > diff --git a/meson.build b/meson.build
> > index 26d19ed..cb37056 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -278,13 +278,6 @@ if spice_gtk_has_introspection and get_option('vapi')
> >spice_gtk_has_vala = true
> >  endif
> >
> > -# dbus
> > -if get_option('dbus')
> > -  spice_gtk_config_data.set('USE_GDBUS', '1')
> > -else
> > -  warning('No D-Bus support, desktop integration and USB redirection may 
> > not work properly')
> > -endif
> > -
> >  # lz4
> >  spice_gtk_has_lz4 = false
> >  d = dependency('liblz4', required : get_option('lz4'))
> > diff --git a/meson_options.txt b/meson_options.txt
> > index a3995f8..8dcded2 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -52,11 +52,6 @@ option('vapi',
> >  value : true,
> >  description: 'Check for vala requirements')
> >
> > -option('dbus',
> > -type : 'boolean',
> > -value : true,
> > -description: 'Enable dbus support for desktop integration (disabling 
> > automount)')
> > -
> >  option('alignment-checks',
> >  type : 'boolean',
> >  value : false,
> > diff --git a/src/desktop-integration.c b/src/desktop-integration.c
> > index 7c433bb..d5924c0 100644
> > --- a/src/desktop-integration.c
> > +++ b/src/desktop-integration.c
> > @@ -31,11 +31,7 @@
> >  #define GNOME_SESSION_INHIBIT_AUTOMOUNT 16
> >
> >  struct _SpiceDesktopIntegrationPrivate {
> > -#if defined(USE_GDBUS)
> >  GDBusProxy *gnome_session_proxy;
> > -#else
> > -GObject *gnome_session_proxy; /* dummy */
> > -#endif
> >  guint gnome_automount_inhibit_cookie;
> >  };
> >
> > @@ -55,12 +51,11 @@ static void handle_dbus_call_error(const char *call, 
> > GError **_error)
> >
> >  static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
> >  {
> > -G_GNUC_UNUSED 

Re: [Spice-devel] [PATCH spice-gtk 28/34] meson: switch vapi to auto feature

2019-01-07 Thread Marc-André Lureau
On Mon, Jan 7, 2019 at 8:21 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:57PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Removed unused vapigen/vapidir variables as well.
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  meson.build   | 9 +
> >  meson_options.txt | 3 +--
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index 9896151..7e0c68d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -279,10 +279,11 @@ endif
> >
> >  # vala (depends on introspection)
> >  spice_gtk_has_vala = false
> > -if spice_gtk_has_introspection and get_option('vapi')
> > -  vapigen_dep = dependency('vapigen')
> > -  vapidir = vapigen_dep.get_pkgconfig_variable('vapidir')
> > -  vapigen = dependency('vapigen').get_pkgconfig_variable('vapigen')
> > +d = dependency('vapigen', required : get_option('vapi'))
> > +if d.found()
> > +  if not spice_gtk_has_introspection
> > +error('VAPI support requested without introspection')
> > +  endif
>
> I'd be a bit more sophisticated here in order to handle 'auto', maybe
> something like this:
>
> if not spice_gtk_has_introspection:
> if get_option('vapi').enabled()
> error('VAPI support requested without introspection')
> endif
> spice_gtk_has_vala = false
> endif
> spice_gtk_has_vala = true

That wouldn't work if vapi is enabled and introspection is disabled.

I don't think the build-sys needs to be that smart for "auto"
features. Or it could be improved later.

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



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


Re: [Spice-devel] [PATCH spice-gtk 18/34] meson: switch polkit option to auto feature

2019-01-07 Thread Marc-André Lureau
On Mon, Jan 7, 2019 at 6:24 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:47PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  meson.build   | 32 +++-
> >  meson_options.txt |  3 +--
> >  2 files changed, 16 insertions(+), 19 deletions(-)
> >
> > diff --git a/meson.build b/meson.build
> > index 18e330f..07e8227 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -186,26 +186,24 @@ endif
> >
> >  # polkit
> >  spice_gtk_has_polkit = false
> > -if get_option('polkit')
> > -  polkit_dep = dependency('polkit-gobject-1', version : '>= 0.96')# 
> > ,required : false)
> > -  if polkit_dep.found()
> > -spice_gtk_policy_dir = polkit_dep.get_pkgconfig_variable('policydir')
> > -foreach func : ['polkit_authority_get_sync', 
> > 'polkit_authorization_result_get_dismissed']
> > -  if compiler.has_function(func, dependencies : polkit_dep)
> > -spice_gtk_config_data.set('HAVE_@0@'.format(func.to_upper()), '1')
> > -  endif
> > -endforeach
> > -
> > -if not compiler.has_function('acl_get_file')
> > -  acl_dep = compiler.find_library('acl')
> > -  if not compiler.has_function('acl_get_file', dependencies : acl_dep)
> > -error('PolicyKit support requested, but some required packages are 
> > not available')
> > -  endif
> > -  spice_acl_deps += acl_dep
> > +d = dependency('polkit-gobject-1', version : '>= 0.96', required : 
> > get_option('polkit'))
> > +if d.found()
> > +  spice_gtk_policy_dir = d.get_pkgconfig_variable('policydir')
> > +  foreach func : ['polkit_authority_get_sync', 
> > 'polkit_authorization_result_get_dismissed']
> > +if compiler.has_function(func, dependencies : d)
> > +  spice_gtk_config_data.set('HAVE_@0@'.format(func.to_upper()), '1')
> > +endif
> > +  endforeach
> > +
> > +  if not compiler.has_function('acl_get_file')
> > +acl_dep = compiler.find_library('acl')
> > +if not compiler.has_function('acl_get_file', dependencies : acl_dep)
> > +  error('PolicyKit support requested, but some required packages are 
> > not available')
>
> With 'auto', we should just disable polkit support if this is missing.

Does it have to be that smart? Imho, it's unnecessarily complicated.
It could be changed later if needed.


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



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


Re: [Spice-devel] [PATCH spice-gtk 17/34] meson: switch usbredir option to auto feature

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 6:22 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:46PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  .gitlab-ci.yml|  1 -
> >  meson.build   | 15 +--
> >  meson_options.txt |  3 +--
> >  3 files changed, 6 insertions(+), 13 deletions(-)
> >
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index fabe29e..125dbd7 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -48,7 +48,6 @@ makecheck_simple-meson:
> >  -Dlz4=false
> >  -Dsasl=false
> >  -Dsmartcard=false
> > --Dusbredir=false
> >  -Ddbus=false || (cat build/meson-logs/meson-log.txt && 
> > exit 1)
> >- ninja -C build
> >- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 
> > 1)
> > diff --git a/meson.build b/meson.build
> > index 69f7e1f..18e330f 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -175,16 +175,11 @@ endif
> >
> >  # usbredir
> >  spice_gtk_has_usbredir = false
> > -if get_option('usbredir')
> > -  deps = {'libusbredirparser-0.5': '>= 0.5',
> > -  'libusbredirhost' : '>= 0.4.2',
> > -  'libusb-1.0' : '>= 1.0.16'}
> > -
> > -  foreach dep, version : deps
> > -usb_dep = dependency(dep, version : version)
> > -spice_glib_deps += usb_dep
> > -  endforeach
> > -
> > +d = dependency('libusbredirparser-0.5', required : get_option('usbredir'))
> > +if d.found()
> > +  spice_glib_deps += d
> > +  spice_glib_deps += dependency('libusbredirhost', version : '>= 0.4.2')
> > +  spice_glib_deps += dependency('libusb-1.0', version : '>= 1.0.16')
>
> Thinking of the behaviour that we want with 'auto', shouldn't it be
> something like (pseudo-code) this?
>
> d1 = dependency('libusbredirparser-0.5', required : get_option('usbredir'))
> d2 = dependency('libusbredirhost', version : '>= 0.4.2', required : 
> get_option('usbredir')))
> d3 = dependency('libusb-1.0', version : '>= 1.0.16', required : 
> get_option('usbredir')))
> if d1.found() and d2.found() and d3.found():
>   spice_glib_deps += [ d1, d2, d3 ]

Yes, that should work too, although I don't like much the multiple
get_option('usbredir')
I might just not be used to that, or the lack of better support for
multiple feature dependency with meson.

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



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


Re: [Spice-devel] [PATCH spice-gtk 16/34] meson: switch pulse option to auto feature

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 6:15 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:45PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  .gitlab-ci.yml| 1 -
> >  meson.build   | 8 +++-
> >  meson_options.txt | 3 +--
> >  3 files changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index e913da4..fabe29e 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -47,7 +47,6 @@ makecheck_simple-meson:
> >- meson build -Dauto_features=disabled
> >  -Dlz4=false
> >  -Dsasl=false
> > --Dpulse=false
> >  -Dsmartcard=false
> >  -Dusbredir=false
> >  -Ddbus=false || (cat build/meson-logs/meson-log.txt && 
> > exit 1)
> > diff --git a/meson.build b/meson.build
> > index 9bb56c3..69f7e1f 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -154,11 +154,9 @@ endif
> >
> >  # pulse
> >  spice_gtk_has_pulse = false
> > -if get_option('pulse')
> > -  deps = ['libpulse', 'libpulse-mainloop-glib']
> > -  foreach dep : deps
> > -spice_glib_deps += dependency(dep)
> > -  endforeach
> > +d = dependency('libpulse-mainloop-glib', required: get_option('pulse'))
>
> There were 2 deps, one for 'libpulse' the other for
> 'libpulse-mainloop-glib', did you intentionally drop one?

Yes, libpulse-mainloop-glib depends on libpulse.

Checking for both dependency with meson is unfortunately unnecessarily
complicated.
Ack with commit message updated?

thanks

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



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


Re: [Spice-devel] [PATCH spice-gtk 13/34] .gitlab-ci: disable meson auto-features in makecheck_simple-meson

2019-01-07 Thread Marc-André Lureau
On Mon, Jan 7, 2019 at 6:06 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:42PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > Let's turn explicit true/false option into features which can be
> > autodetected and turned all enabled/disabled at once.
>
> Is this saying that after the following commits which will turn most of
> the options into autodetected features, then we will be able to disable
> everything at once using -Dauto_features=disabled?
> The log is not very easy to parse :)

Yes, I'll update the commit message with your comment :)
thanks

>
> Reviewed-by: Christophe Fergeau 
>
> Christophe
>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  .gitlab-ci.yml | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> > index 260d55d..5d4da85 100644
> > --- a/.gitlab-ci.yml
> > +++ b/.gitlab-ci.yml
> > @@ -44,7 +44,8 @@ makecheck_simple:
> >
> >  makecheck_simple-meson:
> >script:
> > -  - meson build -Dlz4=false
> > +  - meson build -Dauto_features=disabled
> > +-Dlz4=false
> >  -Dwebdav=false
> >  -Dsasl=false
> >  -Dpulse=false
> > --
> > 2.20.1.2.gb21ebb671b
> >
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 33/34] audio: use gstreamer by default

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 8:22 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:01:02PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > The pulse backend is getting deprecated.
>
> Not sure this is something we should do right before a release rather
> than right after the release so that the gstreamer backend on linux gets
> a bit more testing than usual.

Imho, the gstreamer backend is quite mature. It is a bit unfortunate
that it has some issues with recording and pulsesrc, but this is not
really our fault, and we will lower the rank of the pulse elements.

Not a big deal if we decide to postpone it after v0.36 though

> Christophe
>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  src/spice-audio.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/spice-audio.c b/src/spice-audio.c
> > index daf62df..a03c80b 100644
> > --- a/src/spice-audio.c
> > +++ b/src/spice-audio.c
> > @@ -236,11 +236,11 @@ SpiceAudio *spice_audio_new_priv(SpiceSession 
> > *session, GMainContext *context,
> >  if (name == NULL)
> >  name = g_get_application_name();
> >
> > +self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
> >  #ifdef HAVE_PULSE
> > -self = SPICE_AUDIO(spice_pulse_new(session, context, name));
> > -#endif
> >  if (!self)
> > -self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
> > +self = SPICE_AUDIO(spice_pulse_new(session, context, name));
> > +#endif
> >  if (!self)
> >  return NULL;
> >
> > --
> > 2.20.1.2.gb21ebb671b
> >
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


[Spice-devel] [PATCH] spice: Remove unused include

2019-01-07 Thread Frediano Ziglio
The definitions in the header are not  used.
Also this fixes porting SPICE to Windows where the header is not
available.

Signed-off-by: Frediano Ziglio 
---
 ui/spice-core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 525e0929b9..fb87944a24 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -18,7 +18,6 @@
 #include "qemu/osdep.h"
 #include 
 
-#include 
 #include "sysemu/sysemu.h"
 
 #include "ui/qemu-spice.h"
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 29/32] Disable recording filtering for Windows

2019-01-07 Thread Frediano Ziglio
Although this feature can be ported to Windows doing so would
require the usage of g_spawn_async_with_fds, which is only available
in GLib 2.58 or some specific Win32 code.

Signed-off-by: Frediano Ziglio 
---
 server/red-record-qxl.c| 7 +++
 server/tests/test-record.c | 7 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/server/red-record-qxl.c b/server/red-record-qxl.c
index 30a3b0da..f3a2dc39 100644
--- a/server/red-record-qxl.c
+++ b/server/red-record-qxl.c
@@ -817,6 +817,7 @@ void red_record_qxl_command(RedRecord *record, 
RedMemSlotInfo *slots,
 pthread_mutex_unlock(>lock);
 }
 
+#ifndef _WIN32
 /**
  * Redirects child output to the file specified
  */
@@ -829,6 +830,7 @@ static void child_output_setup(gpointer user_data)
 }
 close(fd);
 }
+#endif
 
 RedRecord *red_record_new(const char *filename)
 {
@@ -845,6 +847,7 @@ RedRecord *red_record_new(const char *filename)
 
 filter = getenv("SPICE_WORKER_RECORD_FILTER");
 if (filter) {
+#ifndef _WIN32
 gint argc;
 gchar **argv = NULL;
 GError *error = NULL;
@@ -870,6 +873,10 @@ RedRecord *red_record_new(const char *filename)
 }
 close(fd_in);
 g_spawn_close_pid(child_pid);
+#else
+// TODO
+spice_warning("recorder filter not supported under Windows");
+#endif
 }
 
 if (fwrite(header, sizeof(header)-1, 1, f) != 1) {
diff --git a/server/tests/test-record.c b/server/tests/test-record.c
index de3c6f5b..8ee36ceb 100644
--- a/server/tests/test-record.c
+++ b/server/tests/test-record.c
@@ -35,9 +35,9 @@ test_record(bool compress)
 RedRecord *rec;
 const char *fn = OUTPUT_FILENAME;
 
-unsetenv("SPICE_WORKER_RECORD_FILTER");
+g_unsetenv("SPICE_WORKER_RECORD_FILTER");
 if (compress) {
-setenv("SPICE_WORKER_RECORD_FILTER", "gzip", 1);
+g_setenv("SPICE_WORKER_RECORD_FILTER", "gzip", 1);
 }
 
 // delete possible stale test output
@@ -95,6 +95,9 @@ int
 main(void)
 {
 test_record(false);
+// TODO implement on Windows
+#ifndef _WIN32
 test_record(true);
+#endif
 return 0;
 }
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 31/32] Use structure for socket_t type instead of just a typedef

2019-01-07 Thread Frediano Ziglio
Allows the compiler to catch errors mixing int and sockets.
Make easier to keep Windows port working.
This technique was used to port SPICE server to Windows.

Signed-off-by: Frediano Ziglio 
---
 server/sys-socket.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/sys-socket.h b/server/sys-socket.h
index eea0b443..09b0a3d3 100644
--- a/server/sys-socket.h
+++ b/server/sys-socket.h
@@ -23,7 +23,7 @@
 
 #include 
 
-#if 0
+#if ENABLE_EXTRA_CHECKS
 typedef struct {
 int fd;
 } socket_t;
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 32/32] Add some notes for the Windows port

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 README.Windows | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 README.Windows

diff --git a/README.Windows b/README.Windows
new file mode 100644
index ..a953813d
--- /dev/null
+++ b/README.Windows
@@ -0,0 +1,18 @@
+SPICE server Windows support
+
+
+SPICE server was ported from Unix/Linux to Windows.
+
+Most features are present, with some exceptions:
+- Unix sockets;
+- signal handling;
+- CLOEXEC flag (completely different handling on Windows);
+- IPTOS_LOWDELAY flag (Linux specific);
+- TCP_CORK (Linux/*BSD specific).
+
+Some features could be ported but currently are not:
+- statistics exported through mapped files. Disabled by default and mainly
+  used for development;
+- filtering while recording (SPICE_WORKER_RECORD_FILTER environment).
+  Recording is used for debugging or development work;
+- TCP_KEEPIDLE setting. Default is used.
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 30/32] replay: Port to Windows

2019-01-07 Thread Frediano Ziglio
Client process termination did not work for Windows, used Win32
APIs.

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/tests/replay.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/server/tests/replay.c b/server/tests/replay.c
index b88c03c7..6367ce21 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -210,15 +210,22 @@ static int req_display_notification(QXLInstance *qin)
 
 static void end_replay(void)
 {
-int child_status;
-
 /* FIXME: wait threads and end cleanly */
 spice_replay_free(replay);
 
 if (client_pid) {
 g_debug("kill %" G_PID_FORMAT, client_pid);
+#ifndef _WIN32
+int child_status;
+
 kill(client_pid, SIGINT);
 waitpid(client_pid, _status, 0);
+#else
+TerminateProcess(client_pid, 0);
+WaitForSingleObject(client_pid, INFINITE);
+#endif
+g_spawn_close_pid(client_pid);
+client_pid = 0;
 }
 }
 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 28/32] reds: Explicitly include inttypes.h

2019-01-07 Thread Frediano Ziglio
MingW does not include this header while including stdint.h so
on Windows you need to include it.

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/reds.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/server/reds.h b/server/reds.h
index 8481d7c6..f192b563 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -19,6 +19,7 @@
 #define REDS_H_
 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 27/32] red-stream: Fix SSL connection for Windows

2019-01-07 Thread Frediano Ziglio
Set correctly errno to make callers handle correctly encrypted
traffic.

Signed-off-by: Frediano Ziglio 
---
 server/red-stream.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/server/red-stream.c b/server/red-stream.c
index a6da8385..687d6ca2 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -158,15 +158,37 @@ static ssize_t stream_read_cb(RedStream *s, void *buf, 
size_t size)
 return socket_read(s->socket, buf, size);
 }
 
+static ssize_t stream_ssl_error(RedStream *s, int return_code)
+{
+SPICE_GNUC_UNUSED int ssl_error;
+
+ssl_error = SSL_get_error(s->priv->ssl, return_code);
+
+// OpenSSL can to return SSL_ERROR_WANT_READ if we attempt to read
+// data and the socket did not receive all SSL packet.
+// Under Windows errno is not set so potentially caller can detect
+// the wrong error so we need to set errno.
+#ifdef _WIN32
+if (ssl_error == SSL_ERROR_WANT_READ || ssl_error == SSL_ERROR_WANT_WRITE) 
{
+errno = EAGAIN;
+} else {
+errno = EPIPE;
+}
+#endif
+
+// red_peer_receive is expected to receive -1 on errors while
+// OpenSSL documentation just state a <0 value
+return -1;
+}
+
 static ssize_t stream_ssl_write_cb(RedStream *s, const void *buf, size_t size)
 {
 int return_code;
-SPICE_GNUC_UNUSED int ssl_error;
 
 return_code = SSL_write(s->priv->ssl, buf, size);
 
 if (return_code < 0) {
-ssl_error = SSL_get_error(s->priv->ssl, return_code);
+return stream_ssl_error(s, return_code);
 }
 
 return return_code;
@@ -175,12 +197,11 @@ static ssize_t stream_ssl_write_cb(RedStream *s, const 
void *buf, size_t size)
 static ssize_t stream_ssl_read_cb(RedStream *s, void *buf, size_t size)
 {
 int return_code;
-SPICE_GNUC_UNUSED int ssl_error;
 
 return_code = SSL_read(s->priv->ssl, buf, size);
 
 if (return_code < 0) {
-ssl_error = SSL_get_error(s->priv->ssl, return_code);
+return stream_ssl_error(s, return_code);
 }
 
 return return_code;
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 26/32] test-stat: Adjust delay checks

2019-01-07 Thread Frediano Ziglio
usleep under Windows does not seem to have the required precision.
Use milliseconds and adjust check times according.

Signed-off-by: Frediano Ziglio 
---
 server/tests/stat-test.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/tests/stat-test.c b/server/tests/stat-test.c
index e4a83f4f..444ff7e3 100644
--- a/server/tests/stat-test.c
+++ b/server/tests/stat-test.c
@@ -57,13 +57,13 @@ void TEST_NAME(void)
 
 stat_init(, "test", CLOCK_MONOTONIC);
 stat_start_time_init(_time, );
-usleep(2);
+usleep(2000);
 stat_add(, start_time);
 
 #ifdef RED_WORKER_STAT
 g_assert_cmpuint(info.count, ==, 1);
 g_assert_cmpuint(info.min, ==, info.max);
-g_assert_cmpuint(info.min, >=, 2000);
+g_assert_cmpuint(info.min, >=, 200);
 g_assert_cmpuint(info.min, <, 1);
 #endif
 
@@ -71,17 +71,17 @@ void TEST_NAME(void)
 
 stat_compress_init(, "test", CLOCK_MONOTONIC);
 stat_start_time_init(_time, );
-usleep(2);
+usleep(2000);
 stat_compress_add(, start_time, 100, 50);
-usleep(1);
+usleep(1000);
 stat_compress_add(, start_time, 1000, 500);
 
 #ifdef COMPRESS_STAT
 g_assert_cmpuint(info.count, ==, 2);
 g_assert_cmpuint(info.min, !=, info.max);
-g_assert_cmpuint(info.min, >=, 2000);
+g_assert_cmpuint(info.min, >=, 200);
 g_assert_cmpuint(info.min, <, 1);
-g_assert_cmpuint(info.total, >=, 5000);
+g_assert_cmpuint(info.total, >=, 500);
 g_assert_cmpuint(info.orig_size, ==, 1100);
 g_assert_cmpuint(info.comp_size, ==, 550);
 #endif
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 25/32] tests: Exclude tests that cannot work on Windows

2019-01-07 Thread Frediano Ziglio
test-stream test is passing file descriptor using Unix socket.
test-stat-file needs some porting work of mmap feature.

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/tests/Makefile.am | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index 7668739f..c50826e6 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -53,11 +53,9 @@ check_PROGRAMS = \
test-codecs-parsing \
test-options\
test-stat   \
-   test-stream \
test-agent-msg-filter   \
test-loop   \
test-qxl-parsing\
-   test-stat-file  \
test-leaks  \
test-vdagent\
test-fail-on-null-core-interface\
@@ -68,6 +66,13 @@ check_PROGRAMS = \
test-record \
$(NULL)
 
+if !OS_WIN32
+check_PROGRAMS +=  \
+   test-stream \
+   test-stat-file  \
+   $(NULL)
+endif
+
 noinst_PROGRAMS =  \
test-display-no-ssl \
test-display-streaming  \
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 20/32] windows: Disable code not working on Windows

2019-01-07 Thread Frediano Ziglio
- global signals;
- CLOEXEC flag;
- mmap and statistics;
- IPTOS_LOWDELAY flag;
- Unix sockets;
- sharing file descriptors through Unix sockets;
- TCP_CORK flag.

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/red-channel-client.c |  2 ++
 server/red-stream.c | 11 ++-
 server/red-stream.h |  2 ++
 server/red-worker.c |  6 ++
 server/reds.c   |  4 
 server/sound.c  |  2 ++
 server/stat-file.c  |  2 ++
 server/tests/basic-event-loop.c |  2 ++
 server/tests/replay.c   |  2 ++
 tools/Makefile.am   |  2 ++
 10 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 07f1988d..ac67efbb 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -627,6 +627,7 @@ static void 
red_channel_client_restore_main_sender(RedChannelClient *rcc)
 
 static void red_channel_client_msg_sent(RedChannelClient *rcc)
 {
+#ifndef _WIN32
 int fd;
 
 if (spice_marshaller_get_fd(rcc->priv->send_data.marshaller, )) {
@@ -640,6 +641,7 @@ static void red_channel_client_msg_sent(RedChannelClient 
*rcc)
 if (fd != -1)
 close(fd);
 }
+#endif
 
 red_channel_client_clear_sent_item(rcc);
 
diff --git a/server/red-stream.c b/server/red-stream.c
index 33086d99..a6da8385 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -41,7 +41,7 @@
 #include "reds.h"
 
 // compatibility for *BSD systems
-#ifndef TCP_CORK
+#if !defined(TCP_CORK) && !defined(_WIN32)
 #define TCP_CORK TCP_NOPUSH
 #endif
 
@@ -102,6 +102,7 @@ struct RedStreamPrivate {
 SpiceCoreInterfaceInternal *core;
 };
 
+#ifndef _WIN32
 /**
  * Set TCP_CORK on socket
  */
@@ -111,6 +112,12 @@ static int socket_set_cork(socket_t socket, int enabled)
 SPICE_VERIFY(sizeof(enabled) == sizeof(int));
 return socket_setopt(socket, IPPROTO_TCP, TCP_CORK, , 
sizeof(enabled));
 }
+#else
+static inline int socket_set_cork(socket_t socket, int enabled)
+{
+return -1;
+}
+#endif
 
 static ssize_t stream_write_cb(RedStream *s, const void *buf, size_t size)
 {
@@ -318,6 +325,7 @@ int red_stream_get_no_delay(RedStream *stream)
 return red_socket_get_no_delay(stream->socket);
 }
 
+#ifndef _WIN32
 int red_stream_send_msgfd(RedStream *stream, int fd)
 {
 struct msghdr msgh = { 0, };
@@ -360,6 +368,7 @@ int red_stream_send_msgfd(RedStream *stream, int fd)
 
 return r;
 }
+#endif
 
 ssize_t red_stream_writev(RedStream *s, const struct iovec *iov, int iovcnt)
 {
diff --git a/server/red-stream.h b/server/red-stream.h
index 52082f68..5d8cbb05 100644
--- a/server/red-stream.h
+++ b/server/red-stream.h
@@ -67,7 +67,9 @@ int red_stream_get_family(const RedStream *stream);
 bool red_stream_is_plain_unix(const RedStream *stream);
 bool red_stream_set_no_delay(RedStream *stream, bool no_delay);
 int red_stream_get_no_delay(RedStream *stream);
+#ifndef _WIN32
 int red_stream_send_msgfd(RedStream *stream, int fd);
+#endif
 
 /**
  * Set auto flush flag.
diff --git a/server/red-worker.c b/server/red-worker.c
index f016943a..10cabf00 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1359,22 +1359,28 @@ static void *red_worker_main(void *arg)
 
 bool red_worker_run(RedWorker *worker)
 {
+#ifndef _WIN32
 sigset_t thread_sig_mask;
 sigset_t curr_sig_mask;
+#endif
 int r;
 
 spice_return_val_if_fail(worker, FALSE);
 spice_return_val_if_fail(!worker->thread, FALSE);
 
+#ifndef _WIN32
 sigfillset(_sig_mask);
 sigdelset(_sig_mask, SIGILL);
 sigdelset(_sig_mask, SIGFPE);
 sigdelset(_sig_mask, SIGSEGV);
 pthread_sigmask(SIG_SETMASK, _sig_mask, _sig_mask);
+#endif
 if ((r = pthread_create(>thread, NULL, red_worker_main, worker))) {
 spice_error("create thread failed %d", r);
 }
+#ifndef _WIN32
 pthread_sigmask(SIG_SETMASK, _sig_mask, NULL);
+#endif
 pthread_setname_np(worker->thread, "SPICE Worker");
 
 return r == 0;
diff --git a/server/reds.c b/server/reds.c
index e01c8511..df135d24 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2532,6 +2532,7 @@ static socket_t reds_init_socket(const char *addr, int 
portnr, int family)
 socket_t slisten;
 
 if (family == AF_UNIX) {
+#ifndef _WIN32
 int len;
 struct sockaddr_un local = { 0, };
 
@@ -2552,6 +2553,9 @@ static socket_t reds_init_socket(const char *addr, int 
portnr, int family)
 }
 
 goto listen;
+#else
+return SOCKET_INVALID;
+#endif
 }
 
 memset(,0, sizeof(ai));
diff --git a/server/sound.c b/server/sound.c
index 00b473a8..482f4bc6 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -790,6 +790,7 @@ static bool 
snd_channel_client_config_socket(RedChannelClient *rcc)
 }
 #endif
 
+#ifdef IPTOS_LOWDELAY
 int tos = IPTOS_LOWDELAY;
 if (socket_setopt(stream->socket, IPPROTO_IP, IP_TOS, (void*), 
sizeof(tos)) == -1) {
 if 

[Spice-devel] [PATCH spice-server v3 22/32] event-loop: Port to Windows

2019-01-07 Thread Frediano Ziglio
Use g_io_channel_win32_new_socket instead of g_io_channel_unix_new

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/event-loop.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/server/event-loop.c b/server/event-loop.c
index 56200ce5..72af9ab9 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -123,6 +123,7 @@ static gboolean watch_func(GIOChannel *source, GIOCondition 
condition,
gpointer data)
 {
 SpiceWatch *watch = data;
+// this works also under Windows despite the name
 int fd = g_io_channel_unix_get_fd(source);
 
 watch->func(fd, giocondition_to_spice_event(condition), watch->opaque);
@@ -162,7 +163,11 @@ static SpiceWatch *watch_add(const 
SpiceCoreInterfaceInternal *iface,
 
 watch = g_new0(SpiceWatch, 1);
 watch->context = iface->main_context;
+#ifndef _WIN32
 watch->channel = g_io_channel_unix_new(socket_get_raw(fd));
+#else
+watch->channel = g_io_channel_win32_new_socket(socket_get_raw(fd));
+#endif
 watch->func = func;
 watch->opaque = opaque;
 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 24/32] test-listen: Exclude Unix sockets part under Windows

2019-01-07 Thread Frediano Ziglio
Windows does not support Unix sockets.

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/tests/test-listen.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/server/tests/test-listen.c b/server/tests/test-listen.c
index 640e8f12..2fd4b5a3 100644
--- a/server/tests/test-listen.c
+++ b/server/tests/test-listen.c
@@ -27,7 +27,9 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
+#endif
 
 #include "test-glib-compat.h"
 
@@ -211,7 +213,11 @@ static GThread *fake_client_new(GThreadFunc thread_func,
 ThreadData *thread_data = g_new0(ThreadData, 1);
 
 if (port == -1) {
+#ifndef _WIN32
 thread_data->connectable = 
G_SOCKET_CONNECTABLE(g_unix_socket_address_new(hostname));
+#else
+g_assert_not_reached();
+#endif
 } else {
 g_assert_cmpuint(port, >, 0);
 g_assert_cmpuint(port, <, 65536);
@@ -317,6 +323,7 @@ static void test_connect_plain_and_tls(void)
 spice_server_destroy(server);
 }
 
+#ifndef _WIN32
 static void test_connect_unix(void)
 {
 GThread *thread;
@@ -342,6 +349,7 @@ static void test_connect_unix(void)
 test_event_loop_destroy(_loop);
 spice_server_destroy(server);
 }
+#endif
 
 static void test_connect_ko(void)
 {
@@ -365,7 +373,9 @@ int main(int argc, char **argv)
 g_test_add_func("/server/listen/connect_plain", test_connect_plain);
 g_test_add_func("/server/listen/connect_tls", test_connect_tls);
 g_test_add_func("/server/listen/connect_both", test_connect_plain_and_tls);
+#ifndef _WIN32
 g_test_add_func("/server/listen/connect_unix", test_connect_unix);
+#endif
 g_test_add_func("/server/listen/connect_ko", test_connect_ko);
 
 return g_test_run();
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 18/32] test-stream: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/tests/test-stream.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/tests/test-stream.c b/server/tests/test-stream.c
index d56109d1..54fbf259 100644
--- a/server/tests/test-stream.c
+++ b/server/tests/test-stream.c
@@ -113,9 +113,9 @@ int main(int argc, char *argv[])
 return -1;
 }
 
-st[0] = red_stream_new(server, sv[0]);
+st[0] = red_stream_new(server, SOCKET_FROM_INT(sv[0]));
 spice_assert(red_stream_is_plain_unix(st[0]));
-st[1] = red_stream_new(server, sv[1]);
+st[1] = red_stream_new(server, SOCKET_FROM_INT(sv[1]));
 spice_assert(red_stream_is_plain_unix(st[1]));
 
 /* send stdin, for the fun of it */
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 21/32] dispatcher: Port to Windows

2019-01-07 Thread Frediano Ziglio
Replace poll call with select.
As socket is set to non-blocking we must support it so if
we detect an EAGAIN error wait for data.

Signed-off-by: Frediano Ziglio 
---
 server/dispatcher.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 4cd91f11..9a55a4c9 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -197,6 +197,7 @@ static int read_safe(socket_t fd, uint8_t *buf, size_t 
size, int block)
 }
 
 if (!block) {
+#ifndef _WIN32
 struct pollfd pollfd = {.fd = socket_get_raw(fd), .events = POLLIN, 
.revents = 0};
 while ((ret = poll(, 1, 0)) == -1) {
 if (errno == EINTR) {
@@ -209,6 +210,15 @@ static int read_safe(socket_t fd, uint8_t *buf, size_t 
size, int block)
 if (!(pollfd.revents & POLLIN)) {
 return 0;
 }
+#else
+struct timeval tv = { 0, 0 };
+fd_set fds;
+FD_ZERO();
+FD_SET(socket_get_raw(fd), );
+if (select(1, , NULL, NULL, ) < 1) {
+return 0;
+}
+#endif
 }
 while (read_size < size) {
 ret = socket_read(fd, buf + read_size, size - read_size);
@@ -217,6 +227,16 @@ static int read_safe(socket_t fd, uint8_t *buf, size_t 
size, int block)
 spice_debug("EINTR in read");
 continue;
 }
+#ifdef _WIN32
+// Windows turns this socket not-blocking
+if (errno == EAGAIN) {
+fd_set fds;
+FD_ZERO();
+FD_SET(socket_get_raw(fd), );
+select(1, , NULL, NULL, NULL);
+continue;
+}
+#endif
 return -1;
 }
 if (ret == 0) {
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 17/32] test-channel: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/tests/test-channel.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/server/tests/test-channel.c b/server/tests/test-channel.c
index 1c9148df..fef295a3 100644
--- a/server/tests/test-channel.c
+++ b/server/tests/test-channel.c
@@ -152,7 +152,7 @@ 
red_test_channel_client_class_init(RedTestChannelClientClass *klass)
  * Main test part
  */
 typedef SpiceWatch *watch_add_t(const SpiceCoreInterfaceInternal *iface,
-int fd, int event_mask, SpiceWatchFunc func, 
void *opaque);
+socket_t fd, int event_mask, SpiceWatchFunc 
func, void *opaque);
 static watch_add_t *old_watch_add = NULL;
 static SpiceWatchFunc old_watch_func = NULL;
 
@@ -170,7 +170,7 @@ static void watch_func_inject(int fd, int event, void 
*opaque)
 
 static SpiceWatch *
 watch_add_inject(const SpiceCoreInterfaceInternal *iface,
- int fd, int event_mask, SpiceWatchFunc func, void *opaque)
+ socket_t fd, int event_mask, SpiceWatchFunc func, void 
*opaque)
 {
 g_assert_null(old_watch_func);
 old_watch_func = func;
@@ -178,9 +178,9 @@ watch_add_inject(const SpiceCoreInterfaceInternal *iface,
 return ret;
 }
 
-static int client_socket = -1;
+static socket_t client_socket = SOCKET_INVALID;
 
-static void send_ack_sync(int socket, uint32_t generation)
+static void send_ack_sync(socket_t socket, uint32_t generation)
 {
 struct {
 uint16_t dummy;
@@ -193,7 +193,7 @@ static void send_ack_sync(int socket, uint32_t generation)
 msg.len = GUINT32_TO_LE(sizeof(generation));
 msg.generation = GUINT32_TO_LE(generation);
 
-g_assert_cmpint(write(socket, , 10), ==, 10);
+g_assert_cmpint(socket_write(socket, , 10), ==, 10);
 }
 
 static SpiceTimer *waked_up_timer;
@@ -208,7 +208,7 @@ static void timer_wakeup(void *opaque)
 ssize_t len;
 alarm(1);
 char buffer[256];
-while ((len=recv(client_socket, buffer, sizeof(buffer), 0)) > 0)
+while ((len=socket_read(client_socket, buffer, sizeof(buffer))) > 0)
 got_data += len;
 alarm(0);
 
@@ -228,7 +228,7 @@ static void timeout_watch_count(void *opaque)
 // get all pending data
 alarm(1);
 char buffer[256];
-while (recv(client_socket, buffer, sizeof(buffer), 0) > 0)
+while (socket_read(client_socket, buffer, sizeof(buffer)) > 0)
 continue;
 alarm(0);
 
@@ -236,7 +236,7 @@ static void timeout_watch_count(void *opaque)
 watch_called_countdown = 20;
 
 // send ack reply, this should unblock data from RedChannelClient
-g_assert_cmpint(write(client_socket, "\2\0\0\0\0\0", 6), ==, 6);
+g_assert_cmpint(socket_write(client_socket, "\2\0\0\0\0\0", 6), ==, 6);
 
 // expect data soon
 waked_up_timer = core->timer_add(timer_wakeup, core);
@@ -244,10 +244,10 @@ static void timeout_watch_count(void *opaque)
 // TODO watch
 }
 
-static RedStream *create_dummy_stream(SpiceServer *server, int *p_socket)
+static RedStream *create_dummy_stream(SpiceServer *server, socket_t *p_socket)
 {
-int sv[2];
-g_assert_cmpint(socketpair(AF_LOCAL, SOCK_STREAM, 0, sv), ==, 0);
+socket_t sv[2];
+g_assert_cmpint(socket_newpair(SOCK_STREAM, 0, sv), ==, 0);
 if (p_socket) {
 *p_socket = sv[1];
 }
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 19/32] windows: Undefine some conflicting preprocessor macros

2019-01-07 Thread Frediano Ziglio
"interface" and "MAX_MONITORS" are defined in some Windows system
headers causing garbage code to be fed to the compiler.

Signed-off-by: Frediano Ziglio 
---
 server/red-qxl.c | 4 
 server/reds.c| 6 ++
 2 files changed, 10 insertions(+)

diff --git a/server/red-qxl.c b/server/red-qxl.c
index cec3eefb..60d61014 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -39,6 +39,10 @@
 
 #include "red-qxl.h"
 
+#ifdef _WIN32
+// undefine conflicting preprocessor macros
+#undef interface
+#endif
 
 struct QXLState {
 QXLWorker qxl_worker;
diff --git a/server/reds.c b/server/reds.c
index 0421fd76..e01c8511 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -79,6 +79,12 @@
 #include "net-utils.h"
 #include "red-stream-device.h"
 
+#ifdef _WIN32
+// undefine conflicting preprocessor macros
+#undef MAX_MONITORS
+#undef interface
+#endif
+
 #define REDS_MAX_STAT_NODES 100
 
 static void reds_client_monitors_config(RedsState *reds, VDAgentMonitorsConfig 
*monitors_config);
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 02/32] red-replay-qxl: Use PRIxPTR constant for string formatting

2019-01-07 Thread Frediano Ziglio
These constants are meant to be used in format string for pointers
types. Use them for portability.

Signed-off-by: Frediano Ziglio 
---
 server/red-replay-qxl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index 9b63d237..4884e97e 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -227,7 +227,7 @@ static replay_t read_binary(SpiceReplay *replay, const char 
*prefix, size_t *siz
 uint8_t *zlib_buffer;
 z_stream strm;
 
-snprintf(template, sizeof(template), "binary %%d %s %%ld:%%n", prefix);
+snprintf(template, sizeof(template), "binary %%d %s %%" PRIdPTR ":%%n", 
prefix);
 replay_fscanf_check(replay, template, _zlib, size, >end_pos);
 if (replay->error) {
 return REPLAY_ERROR;
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 06/32] sys-socket: Introduce some utility to make sockets more portable

2019-01-07 Thread Frediano Ziglio
Between Unix and Windows socket are quite different:
- on Windows sockets have a different namespace from C file
  descriptors so you can't use read/write/close or similar functions;
- errors are not stored in errno but you must be read/write the
  errors with specific function;
- sometimes sockets are put in non-blocking mode automatically
  calling some functions;
- SOCKET type is 64 bit on Windows 64 which does not fit technically
  in an int. Is however safe to assume them to fit in an int.

So encapsulate the socket APIs in some definition to make easier
and more safe to deal with them.
Where the portability to Windows would make to code more offuscated a Unix
style was preferred. For instance if errors are detected errno is set from
Windows socket error instead of changing all code handling.
Fortunately on Windows Qemu core interface accepts socket (but not
other types like C file descriptors!).

Signed-off-by: Frediano Ziglio 
---
 server/Makefile.am  |   2 +
 server/sys-socket.c | 212 
 server/sys-socket.h | 165 ++
 3 files changed, 379 insertions(+)
 create mode 100644 server/sys-socket.c
 create mode 100644 server/sys-socket.h

diff --git a/server/Makefile.am b/server/Makefile.am
index 34ec22ad..7f260612 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -166,6 +166,8 @@ libserver_la_SOURCES =  \
stat.h  \
stream-channel.c\
stream-channel.h\
+   sys-socket.h\
+   sys-socket.c\
red-stream-device.c \
red-stream-device.h \
sw-canvas.c \
diff --git a/server/sys-socket.c b/server/sys-socket.c
new file mode 100644
index ..7ce5dab1
--- /dev/null
+++ b/server/sys-socket.c
@@ -0,0 +1,212 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2018 Red Hat, Inc.
+
+   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.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see .
+*/
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifndef _WIN32
+#include 
+#include 
+#include 
+#include 
+#include 
+#endif
+
+#include 
+
+#include "sys-socket.h"
+
+#ifdef _WIN32
+// Map Windows socket errors to standard C ones
+// See 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
+void socket_win32_set_errno(void)
+{
+int err = EPIPE; // default
+switch (WSAGetLastError()) {
+case WSAEWOULDBLOCK:
+case WSAEINPROGRESS:
+err = EAGAIN;
+break;
+case WSAEINTR:
+err = EINTR;
+break;
+case WSAEBADF:
+err = EBADF;
+break;
+case WSA_INVALID_HANDLE:
+case WSA_INVALID_PARAMETER:
+case WSAEINVAL:
+err = EINVAL;
+break;
+case WSAENOTSOCK:
+err = ENOTSOCK;
+break;
+case WSA_NOT_ENOUGH_MEMORY:
+err = ENOMEM;
+break;
+case WSAEPROTONOSUPPORT:
+case WSAESOCKTNOSUPPORT:
+case WSAEOPNOTSUPP:
+case WSAEPFNOSUPPORT:
+case WSAEAFNOSUPPORT:
+case WSAVERNOTSUPPORTED:
+err = ENOTSUP;
+break;
+case WSAEFAULT:
+err = EFAULT;
+break;
+case WSAEACCES:
+err = EACCES;
+break;
+case WSAEMFILE:
+err = EMFILE;
+break;
+case WSAENAMETOOLONG:
+err = ENAMETOOLONG;
+break;
+case WSAENOTEMPTY:
+err = ENOTEMPTY;
+break;
+case WSA_OPERATION_ABORTED:
+case WSAECANCELLED:
+case WSA_E_CANCELLED:
+err = ECANCELED;
+break;
+case WSAEADDRINUSE:
+err = EADDRINUSE;
+break;
+case WSAENETDOWN:
+err = ENETDOWN;
+break;
+case WSAENETUNREACH:
+err = ENETUNREACH;
+break;
+case WSAENETRESET:
+err = ENETRESET;
+break;
+case WSAECONNABORTED:
+err = ECONNABORTED;
+break;
+case WSAECONNRESET:
+err = ECONNRESET;
+break;
+case WSAEISCONN:
+err = EISCONN;
+break;
+case WSAENOTCONN:
+err = ENOTCONN;
+break;
+case WSAETIMEDOUT:
+err = ETIMEDOUT;
+break;
+case 

[Spice-devel] [PATCH spice-server v3 05/32] Avoids %m in formatting for Windows

2019-01-07 Thread Frediano Ziglio
Not supported, %m is a GNU extension of sscanf.

Signed-off-by: Frediano Ziglio 
---
 server/reds.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 84e4bb8c..ec7fbc38 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3570,8 +3570,7 @@ static const int video_codec_caps[] = {
  * @codec: a location to return the parsed codec
  * @return the position of the next codec in the string
  */
-static const char* parse_next_video_codec(const char *codecs, char **encoder,
-  char **codec)
+static char* parse_next_video_codec(char *codecs, char **encoder, char **codec)
 {
 if (!codecs) {
 return NULL;
@@ -3580,14 +3579,15 @@ static const char* parse_next_video_codec(const char 
*codecs, char **encoder,
 if (!*codecs) {
 return NULL;
 }
-int n;
+int end_encoder, end_codec = -1;
 *encoder = *codec = NULL;
-if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, ) 
== 2) {
-// this avoids accepting "encoder:codec" followed by garbage like "$%*"
-if (codecs[n] != ';' && codecs[n] != '\0') {
-free(*codec);
-*codec = NULL;
-}
+if (sscanf(codecs, "%*[0-9a-zA-Z_]:%n%*[0-9a-zA-Z_];%n", _encoder, 
_codec) == 0
+&& end_codec > 0) {
+codecs[end_encoder - 1] = '\0';
+codecs[end_codec - 1] = '\0';
+*encoder = codecs;
+*codec = codecs + end_encoder;
+return codecs + end_codec;
 }
 return codecs + strcspn(codecs, ";");
 }
@@ -3604,7 +3604,8 @@ static void reds_set_video_codecs_from_string(RedsState 
*reds, const char *codec
 }
 
 video_codecs = g_array_new(FALSE, FALSE, sizeof(RedVideoCodec));
-const char *c = codecs;
+char *codecs_copy = g_strdup_printf("%s;", codecs);
+char *c = codecs_copy;
 while ( (c = parse_next_video_codec(c, _name, _name)) ) {
 uint32_t encoder_index, codec_index;
 if (!encoder_name || !codec_name) {
@@ -3627,11 +3628,9 @@ static void reds_set_video_codecs_from_string(RedsState 
*reds, const char *codec
 g_array_append_val(video_codecs, new_codec);
 }
 
-/* these are allocated by sscanf, do not use g_free */
-free(encoder_name);
-free(codec_name);
 codecs = c;
 }
+g_free(codecs_copy);
 
 if (video_codecs->len == 0) {
 spice_warning("Failed to set video codecs, input string: '%s'", 
codecs);
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 07/32] sys-socket: Add socket_newpair utility

2019-01-07 Thread Frediano Ziglio
Allows to easier port socketpair.
Windows does not have this function, we need to create a pair
using 2 internet sockets and connecting one to the other.

Signed-off-by: Frediano Ziglio 
---
 server/sys-socket.c | 75 +
 server/sys-socket.h |  7 +
 2 files changed, 82 insertions(+)

diff --git a/server/sys-socket.c b/server/sys-socket.c
index 7ce5dab1..af2f0b83 100644
--- a/server/sys-socket.c
+++ b/server/sys-socket.c
@@ -209,4 +209,79 @@ SPICE_CONSTRUCTOR_FUNC(socket_win32_init)
 WSADATA wsaData;
 WSAStartup(MAKEWORD(2, 2), );
 }
+
+int socket_newpair(int type, int protocol, socket_t sv[2])
+{
+struct sockaddr_in sa, sa2;
+socklen_t addrlen;
+SOCKET s, pairs[2];
+
+if (!sv) {
+return -1;
+}
+
+/* create a listener */
+s = socket(AF_INET, type, 0);
+if (s == INVALID_SOCKET) {
+return -1;
+}
+
+pairs[1] = INVALID_SOCKET;
+
+pairs[0] = socket(AF_INET, type, 0);
+if (pairs[0] == INVALID_SOCKET) {
+goto cleanup;
+}
+
+/* bind to a random port */
+sa.sin_family = AF_INET;
+sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+sa.sin_port = 0;
+if (bind(s, (struct sockaddr*) , sizeof(sa)) < 0) {
+goto cleanup;
+}
+if (listen(s, 1) < 0) {
+goto cleanup;
+}
+
+/* connect to kernel choosen port */
+addrlen = sizeof(sa);
+if (getsockname(s, (struct sockaddr*) , ) < 0) {
+goto cleanup;
+}
+if (connect(pairs[0], (struct sockaddr*) , sizeof(sa)) < 0) {
+goto cleanup;
+}
+addrlen = sizeof(sa2);
+pairs[1] = accept(s, (struct sockaddr*) , );
+if (pairs[1] == INVALID_SOCKET) {
+goto cleanup;
+}
+
+/* check proper connection */
+addrlen = sizeof(sa);
+if (getsockname(pairs[0], (struct sockaddr*) , ) < 0) {
+goto cleanup;
+}
+addrlen = sizeof(sa2);
+if (getpeername(pairs[1], (struct sockaddr*) , ) < 0) {
+goto cleanup;
+}
+if (sa.sin_family != sa2.sin_family || sa.sin_port != sa2.sin_port
+|| sa.sin_addr.s_addr != sa2.sin_addr.s_addr) {
+goto cleanup;
+}
+
+closesocket(s);
+sv[0] = SOCKET_FROM_INT(pairs[0]);
+sv[1] = SOCKET_FROM_INT(pairs[1]);
+return 0;
+
+cleanup:
+socket_win32_set_errno();
+closesocket(s);
+closesocket(pairs[0]);
+closesocket(pairs[1]);
+return -1;
+}
 #endif
diff --git a/server/sys-socket.h b/server/sys-socket.h
index c4487b79..eea0b443 100644
--- a/server/sys-socket.h
+++ b/server/sys-socket.h
@@ -56,6 +56,11 @@ static inline void socket_win32_set_errno(void)
 {
 }
 
+static inline int socket_newpair(int type, int protocol, socket_t sv[2])
+{
+return socketpair(AF_LOCAL, type, protocol, (int*) sv);
+}
+
 #define socket_read(sock, buf, len) read(socket_get_raw(sock), buf, len)
 #define socket_write(sock, buf, len) write(socket_get_raw(sock), buf, len)
 #define socket_writev(sock, iov, n) writev(socket_get_raw(sock), iov, n)
@@ -147,6 +152,8 @@ socket_listen(socket_t sock, int backlog)
 }
 return res;
 }
+
+int socket_newpair(int type, int protocol, socket_t sv[2]);
 #endif
 
 // common part
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 15/32] basic-event-loop: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/tests/basic-event-loop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/server/tests/basic-event-loop.c b/server/tests/basic-event-loop.c
index 607a5a5e..76b0580e 100644
--- a/server/tests/basic-event-loop.c
+++ b/server/tests/basic-event-loop.c
@@ -98,7 +98,8 @@ static void base_timer_remove(SpiceTimer *timer)
 
 static SpiceWatch *base_watch_add(int fd, int event_mask, SpiceWatchFunc func, 
void *opaque)
 {
-return base_core_interface.watch_add(_core_interface, fd, event_mask, 
func, opaque);
+return base_core_interface.watch_add(_core_interface, 
SOCKET_FROM_INT(fd), event_mask,
+ func, opaque);
 }
 
 static void base_watch_update_mask(SpiceWatch *watch, int event_mask)
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 08/32] net-utils: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/net-utils.c | 33 +
 server/net-utils.h | 10 ++
 2 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/server/net-utils.c b/server/net-utils.c
index 802509a4..8a5b62cb 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -43,11 +43,11 @@
  *
  * Returns: #true if the operation succeeded, #false otherwise.
  */
-bool red_socket_set_keepalive(int fd, bool enable, int timeout)
+bool red_socket_set_keepalive(socket_t sock, bool enable, int timeout)
 {
 int keepalive = !!enable;
 
-if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, , 
sizeof(keepalive)) == -1) {
+if (socket_setopt(sock, SOL_SOCKET, SO_KEEPALIVE,, 
sizeof(keepalive)) == -1) {
 if (errno != ENOTSUP) {
 g_warning("setsockopt for keepalive failed, %s", strerror(errno));
 return false;
@@ -59,7 +59,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int 
timeout)
 }
 
 #ifdef HAVE_TCP_KEEPIDLE
-if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, , sizeof(timeout)) 
== -1) {
+if (socket_setopt(sock, IPPROTO_TCP, TCP_KEEPIDLE, , 
sizeof(timeout)) == -1) {
 if (errno != ENOTSUP) {
 g_warning("setsockopt for keepalive timeout failed, %s", 
strerror(errno));
 return false;
@@ -77,12 +77,11 @@ bool red_socket_set_keepalive(int fd, bool enable, int 
timeout)
  *
  * Returns: #true if the operation succeeded, #false otherwise.
  */
-bool red_socket_set_no_delay(int fd, bool no_delay)
+bool red_socket_set_no_delay(socket_t sock, bool no_delay)
 {
 int optval = no_delay;
 
-if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
-   , sizeof(optval)) != 0) {
+if (socket_setopt(sock, IPPROTO_TCP, TCP_NODELAY, , sizeof(optval)) 
!= 0) {
 if (errno != ENOTSUP && errno != ENOPROTOOPT) {
 spice_warning("setsockopt failed, %s", strerror(errno));
 return false;
@@ -99,9 +98,11 @@ bool red_socket_set_no_delay(int fd, bool no_delay)
  *
  * Returns: #true if the operation succeeded, #false otherwise.
  */
-bool red_socket_set_non_blocking(int fd, bool non_blocking)
+bool red_socket_set_non_blocking(socket_t sock, bool non_blocking)
 {
+#ifndef _WIN32
 int flags;
+int fd = socket_get_raw(sock);
 
 if ((flags = fcntl(fd, F_GETFL)) == -1) {
 spice_warning("fnctl(F_GETFL) failed, %s", strerror(errno));
@@ -120,6 +121,15 @@ bool red_socket_set_non_blocking(int fd, bool non_blocking)
 }
 
 return true;
+#else
+u_long ioctl_nonblocking = 1;
+
+if (ioctlsocket(socket_get_raw(sock), FIONBIO, _nonblocking) != 0) {
+spice_warning("ioctlsocket(FIONBIO) failed, %d", WSAGetLastError());
+return false;
+}
+return true;
+#endif
 }
 
 /**
@@ -128,15 +138,14 @@ bool red_socket_set_non_blocking(int fd, bool 
non_blocking)
  *
  * Returns: The current value of TCP_NODELAY for @fd, -1 if an error occurred
  */
-int red_socket_get_no_delay(int fd)
+int red_socket_get_no_delay(socket_t sock)
 {
 int delay_val;
 socklen_t opt_size = sizeof(delay_val);
 
-if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, _val,
-   _size) == -1) {
-spice_warning("getsockopt failed, %s", strerror(errno));
-return -1;
+if (socket_getopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*) _val, 
_size) == -1) {
+spice_warning("getsockopt failed, %s", strerror(errno));
+return -1;
 }
 
 return delay_val;
diff --git a/server/net-utils.h b/server/net-utils.h
index f95d689a..89e48ea8 100644
--- a/server/net-utils.h
+++ b/server/net-utils.h
@@ -20,9 +20,11 @@
 
 #include 
 
-bool red_socket_set_keepalive(int fd, bool enable, int timeout);
-bool red_socket_set_no_delay(int fd, bool no_delay);
-int red_socket_get_no_delay(int fd);
-bool red_socket_set_non_blocking(int fd, bool non_blocking);
+#include "sys-socket.h"
+
+bool red_socket_set_keepalive(socket_t fd, bool enable, int timeout);
+bool red_socket_set_no_delay(socket_t fd, bool no_delay);
+int red_socket_get_no_delay(socket_t fd);
+bool red_socket_set_non_blocking(socket_t fd, bool non_blocking);
 
 #endif /* RED_NET_UTILS_H_ */
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 04/32] build: Detect Windows build and change some definitions

2019-01-07 Thread Frediano Ziglio
Windows needs some specific setting to use network.

Signed-off-by: Frediano Ziglio 
---
 configure.ac | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 96e4e66c..43224f8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,6 +68,20 @@ case $host_cpu in
 SPICE_WARNING([spice-server on non-x86_64 architectures has not been 
extensively tested])
 esac
 
+AC_MSG_CHECKING([for native Win32])
+case "$host_os" in
+ *mingw*|*cygwin*)
+os_win32=yes
+dnl AI_ADDRCONFIG and possibly some other code require at least Vista
+AC_DEFINE([_WIN32_WINNT], [0x600], [Minimal Win32 version])]
+;;
+ *)
+os_win32=no
+;;
+esac
+AC_MSG_RESULT([$os_win32])
+AM_CONDITIONAL([OS_WIN32],[test "$os_win32" = "yes"])
+
 dnl =
 dnl Check optional features
 SPICE_CHECK_SMARTCARD
@@ -153,6 +167,9 @@ AC_CHECK_LIB(rt, clock_gettime, LIBRT="-lrt")
 AC_SUBST(LIBRT)
 
 AS_VAR_APPEND([SPICE_NONPKGCONFIG_LIBS], [" -pthread $LIBM $LIBRT"])
+AS_IF([test "x$os_win32" = "xyes"], [
+AS_VAR_APPEND([SPICE_NONPKGCONFIG_LIBS], [" -lws2_32"])
+])
 
 SPICE_REQUIRES=""
 
@@ -175,7 +192,8 @@ PKG_CHECK_MODULES([GOBJECT2], [gobject-2.0 >= 
$GLIB2_REQUIRED])
 AS_VAR_APPEND([SPICE_REQUIRES], [" gobject-2.0 >= $GLIB2_REQUIRED"])
 
 #used only by tests
-PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= $GLIB2_REQUIRED])
+AS_IF([test "x$os_win32" != "xyes"],
+  PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= $GLIB2_REQUIRED]))
 
 PIXMAN_REQUIRED=0.17.7
 PKG_CHECK_MODULES(PIXMAN, pixman-1 >= $PIXMAN_REQUIRED)
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 16/32] test-leaks: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/tests/test-leaks.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
index 64130c22..98f9cb67 100644
--- a/server/tests/test-leaks.c
+++ b/server/tests/test-leaks.c
@@ -35,6 +35,7 @@
 #include "test-glib-compat.h"
 #include "basic-event-loop.h"
 #include "test-display-base.h"
+#include "sys-socket.h"
 
 #define PKI_DIR SPICE_TOP_SRCDIR "/server/tests/pki/"
 
@@ -43,7 +44,7 @@ static void server_leaks(void)
 int result;
 SpiceCoreInterface *core;
 SpiceServer *server = spice_server_new();
-int sv[2];
+socket_t sv[2];
 
 g_assert_nonnull(server);
 
@@ -69,12 +70,12 @@ static void server_leaks(void)
 /* spice_server_add_ssl_client should not leak when it's given a 
disconnected socket */
 g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
   "*SSL_accept failed*");
-g_assert_cmpint(socketpair(AF_LOCAL, SOCK_STREAM, 0, sv), ==, 0);
-close(sv[1]);
-result = spice_server_add_ssl_client(server, sv[0], 1);
+g_assert_cmpint(socket_newpair(SOCK_STREAM, 0, sv), ==, 0);
+socket_close(sv[1]);
+result = spice_server_add_ssl_client(server, socket_get_raw(sv[0]), 1);
 g_assert_cmpint(result, ==, -1);
 /* if the function fails, it should not close the socket */
-g_assert_cmpint(close(sv[0]), ==, 0);
+g_assert_cmpint(socket_close(sv[0]), ==, 0);
 
 spice_server_destroy(server);
 basic_event_loop_destroy();
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 09/32] reds: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/red-common.h   |  4 +-
 server/reds-private.h |  4 +-
 server/reds.c | 94 +++
 server/reds.h |  2 +-
 4 files changed, 56 insertions(+), 48 deletions(-)

diff --git a/server/red-common.h b/server/red-common.h
index 181ed283..eb2fef96 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -35,6 +35,7 @@
 
 #include "spice.h"
 #include "utils.h"
+#include "sys-socket.h"
 
 #define SPICE_UPCAST(type, ptr) \
 (verify_expr(SPICE_OFFSETOF(type, base) == 0,SPICE_CONTAINEROF(ptr, type, 
base)))
@@ -47,7 +48,8 @@ struct SpiceCoreInterfaceInternal {
 void (*timer_cancel)(const SpiceCoreInterfaceInternal *iface, SpiceTimer 
*timer);
 void (*timer_remove)(const SpiceCoreInterfaceInternal *iface, SpiceTimer 
*timer);
 
-SpiceWatch *(*watch_add)(const SpiceCoreInterfaceInternal *iface, int fd, 
int event_mask, SpiceWatchFunc func, void *opaque);
+SpiceWatch *(*watch_add)(const SpiceCoreInterfaceInternal *iface, socket_t 
fd, int event_mask,
+ SpiceWatchFunc func, void *opaque);
 void (*watch_update_mask)(const SpiceCoreInterfaceInternal *iface, 
SpiceWatch *watch, int event_mask);
 void (*watch_remove)(const SpiceCoreInterfaceInternal *iface, SpiceWatch 
*watch);
 
diff --git a/server/reds-private.h b/server/reds-private.h
index 920edc5c..17e45caf 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -75,8 +75,8 @@ typedef struct RedServerConfig RedServerConfig;
 
 struct RedsState {
 RedServerConfig *config;
-int listen_socket;
-int secure_listen_socket;
+socket_t listen_socket;
+socket_t secure_listen_socket;
 SpiceWatch *listen_watch;
 SpiceWatch *secure_listen_watch;
 RedCharDeviceVDIPort *agent_dev;
diff --git a/server/reds.c b/server/reds.c
index ec7fbc38..0421fd76 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -106,9 +106,10 @@ static void adapter_timer_remove(const 
SpiceCoreInterfaceInternal *iface, SpiceT
 }
 
 static SpiceWatch *adapter_watch_add(const SpiceCoreInterfaceInternal *iface,
- int fd, int event_mask, SpiceWatchFunc 
func, void *opaque)
+ socket_t fd, int event_mask, 
SpiceWatchFunc func, void *opaque)
 {
-return iface->public_interface->watch_add(fd, event_mask, func, opaque);
+// note: Qemu API is fine having a SOCKET on Windows
+return iface->public_interface->watch_add(socket_get_raw(fd), event_mask, 
func, opaque);
 }
 
 static void adapter_watch_update_mask(const SpiceCoreInterfaceInternal *iface, 
SpiceWatch *watch, int event_mask)
@@ -168,7 +169,7 @@ struct RedServerConfig {
 
 int spice_port;
 int spice_secure_port;
-int spice_listen_socket_fd;
+socket_t spice_listen_socket_fd;
 char spice_addr[256];
 int spice_family;
 TicketAuthentication taTicket;
@@ -2383,7 +2384,7 @@ static void reds_handle_ssl_accept(int fd, int event, 
void *data)
 
 #define KEEPALIVE_TIMEOUT (10*60)
 
-static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
+static RedLinkInfo *reds_init_client_connection(RedsState *reds, socket_t 
socket)
 {
 RedLinkInfo *link;
 
@@ -2414,7 +2415,7 @@ error:
 }
 
 
-static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, int 
socket)
+static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, socket_t 
socket)
 {
 RedLinkInfo *link;
 RedStreamSslStatus ssl_status;
@@ -2447,7 +2448,7 @@ static RedLinkInfo 
*reds_init_client_ssl_connection(RedsState *reds, int socket)
 error:
 /* close the stream but do not close the socket, this API is
  * supposed to not close it if it fails */
-link->stream->socket = -1;
+link->stream->socket = SOCKET_INVALID;
 reds_link_free(link);
 return NULL;
 }
@@ -2459,11 +2460,12 @@ static void reds_accept_ssl_connection(int fd, int 
event, void *data)
 int socket;
 
 if ((socket = accept(fd, NULL, 0)) == -1) {
+socket_win32_set_errno();
 spice_warning("accept failed, %s", strerror(errno));
 return;
 }
 
-if (!(link = reds_init_client_ssl_connection(reds, socket))) {
+if (!(link = reds_init_client_ssl_connection(reds, 
SOCKET_FROM_INT(socket {
 close(socket);
 return;
 }
@@ -2476,6 +2478,7 @@ static void reds_accept(int fd, int event, void *data)
 int socket;
 
 if ((socket = accept(fd, NULL, 0)) == -1) {
+socket_win32_set_errno();
 spice_warning("accept failed, %s", strerror(errno));
 return;
 }
@@ -2489,7 +2492,7 @@ SPICE_GNUC_VISIBLE int 
spice_server_add_client(SpiceServer *reds, int socket, in
 {
 RedLinkInfo *link;
 
-if (!(link = reds_init_client_connection(reds, socket))) {
+if (!(link = reds_init_client_connection(reds, SOCKET_FROM_INT(socket {
 spice_warning("accept failed");
 return -1;
 }
@@ -2505,7 +2508,7 @@ 

[Spice-devel] [PATCH spice-server v3 13/32] event-loop: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/event-loop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/server/event-loop.c b/server/event-loop.c
index 413102e8..56200ce5 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -153,16 +153,16 @@ static void watch_update_mask(const 
SpiceCoreInterfaceInternal *iface,
 }
 
 static SpiceWatch *watch_add(const SpiceCoreInterfaceInternal *iface,
- int fd, int event_mask, SpiceWatchFunc func, void 
*opaque)
+ socket_t fd, int event_mask, SpiceWatchFunc func, 
void *opaque)
 {
 SpiceWatch *watch;
 
-spice_return_val_if_fail(fd != -1, NULL);
+spice_return_val_if_fail(socket_is_valid(fd), NULL);
 spice_return_val_if_fail(func != NULL, NULL);
 
 watch = g_new0(SpiceWatch, 1);
 watch->context = iface->main_context;
-watch->channel = g_io_channel_unix_new(fd);
+watch->channel = g_io_channel_unix_new(socket_get_raw(fd));
 watch->func = func;
 watch->opaque = opaque;
 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 12/32] dispatcher: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/dispatcher.c | 26 +-
 server/dispatcher.h |  2 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 3e27f2c2..4cd91f11 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -50,8 +50,8 @@ G_DEFINE_TYPE(Dispatcher, dispatcher, G_TYPE_OBJECT)
 #define DISPATCHER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), 
TYPE_DISPATCHER, DispatcherPrivate))
 
 struct DispatcherPrivate {
-int recv_fd;
-int send_fd;
+socket_t recv_fd;
+socket_t send_fd;
 pthread_t thread_id;
 pthread_mutex_t lock;
 DispatcherMessage *messages;
@@ -109,8 +109,8 @@ dispatcher_finalize(GObject *object)
 {
 Dispatcher *self = DISPATCHER(object);
 g_free(self->priv->messages);
-close(self->priv->send_fd);
-close(self->priv->recv_fd);
+socket_close(self->priv->send_fd);
+socket_close(self->priv->recv_fd);
 pthread_mutex_destroy(>priv->lock);
 g_free(self->priv->payload);
 G_OBJECT_CLASS(dispatcher_parent_class)->finalize(object);
@@ -119,14 +119,14 @@ dispatcher_finalize(GObject *object)
 static void dispatcher_constructed(GObject *object)
 {
 Dispatcher *self = DISPATCHER(object);
-int channels[2];
+socket_t channels[2];
 
 G_OBJECT_CLASS(dispatcher_parent_class)->constructed(object);
 
 #ifdef DEBUG_DISPATCHER
 setup_dummy_signal_handler();
 #endif
-if (socketpair(AF_LOCAL, SOCK_STREAM, 0, channels) == -1) {
+if (socket_newpair(SOCK_STREAM, 0, channels) == -1) {
 spice_error("socketpair failed %s", strerror(errno));
 return;
 }
@@ -187,7 +187,7 @@ dispatcher_new(size_t max_message_type)
  *if 0 poll first, return immediately if no bytes available, otherwise
  * read size in blocking mode.
  */
-static int read_safe(int fd, uint8_t *buf, size_t size, int block)
+static int read_safe(socket_t fd, uint8_t *buf, size_t size, int block)
 {
 int read_size = 0;
 int ret;
@@ -197,7 +197,7 @@ static int read_safe(int fd, uint8_t *buf, size_t size, int 
block)
 }
 
 if (!block) {
-struct pollfd pollfd = {.fd = fd, .events = POLLIN, .revents = 0};
+struct pollfd pollfd = {.fd = socket_get_raw(fd), .events = POLLIN, 
.revents = 0};
 while ((ret = poll(, 1, 0)) == -1) {
 if (errno == EINTR) {
 spice_debug("EINTR in poll");
@@ -211,7 +211,7 @@ static int read_safe(int fd, uint8_t *buf, size_t size, int 
block)
 }
 }
 while (read_size < size) {
-ret = read(fd, buf + read_size, size - read_size);
+ret = socket_read(fd, buf + read_size, size - read_size);
 if (ret == -1) {
 if (errno == EINTR) {
 spice_debug("EINTR in read");
@@ -232,13 +232,13 @@ static int read_safe(int fd, uint8_t *buf, size_t size, 
int block)
  * write_safe
  * @return -1 for error, otherwise number of written bytes. may be zero.
  */
-static int write_safe(int fd, uint8_t *buf, size_t size)
+static int write_safe(socket_t fd, uint8_t *buf, size_t size)
 {
 int written_size = 0;
 int ret;
 
 while (written_size < size) {
-ret = write(fd, buf + written_size, size - written_size);
+ret = socket_write(fd, buf + written_size, size - written_size);
 if (ret == -1) {
 if (errno != EINTR) {
 return -1;
@@ -310,7 +310,7 @@ void dispatcher_send_message(Dispatcher *dispatcher, 
uint32_t message_type,
 {
 DispatcherMessage *msg;
 uint32_t ack;
-int send_fd = dispatcher->priv->send_fd;
+socket_t send_fd = dispatcher->priv->send_fd;
 
 assert(dispatcher->priv->max_message_type > message_type);
 assert(dispatcher->priv->messages[message_type].handler);
@@ -393,7 +393,7 @@ void dispatcher_set_opaque(Dispatcher *self, void *opaque)
 self->priv->opaque = opaque;
 }
 
-int dispatcher_get_recv_fd(Dispatcher *dispatcher)
+socket_t dispatcher_get_recv_fd(Dispatcher *dispatcher)
 {
 return dispatcher->priv->recv_fd;
 }
diff --git a/server/dispatcher.h b/server/dispatcher.h
index bb968e56..bbc88224 100644
--- a/server/dispatcher.h
+++ b/server/dispatcher.h
@@ -155,7 +155,7 @@ void dispatcher_handle_recv_read(Dispatcher *);
  *
  * @return: receive file descriptor of the dispatcher
  */
-int dispatcher_get_recv_fd(Dispatcher *);
+socket_t dispatcher_get_recv_fd(Dispatcher *);
 
 /* dispatcher_set_opaque
  *
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 10/32] red-stream: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/red-stream.c | 32 +---
 server/red-stream.h |  4 ++--
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/server/red-stream.c b/server/red-stream.c
index 57034a64..33086d99 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -106,15 +106,15 @@ struct RedStreamPrivate {
  * Set TCP_CORK on socket
  */
 /* NOTE: enabled must be int */
-static int socket_set_cork(int socket, int enabled)
+static int socket_set_cork(socket_t socket, int enabled)
 {
 SPICE_VERIFY(sizeof(enabled) == sizeof(int));
-return setsockopt(socket, IPPROTO_TCP, TCP_CORK, , 
sizeof(enabled));
+return socket_setopt(socket, IPPROTO_TCP, TCP_CORK, , 
sizeof(enabled));
 }
 
 static ssize_t stream_write_cb(RedStream *s, const void *buf, size_t size)
 {
-return write(s->socket, buf, size);
+return socket_write(s->socket, buf, size);
 }
 
 static ssize_t stream_writev_cb(RedStream *s, const struct iovec *iov, int 
iovcnt)
@@ -132,7 +132,7 @@ static ssize_t stream_writev_cb(RedStream *s, const struct 
iovec *iov, int iovcn
 for (i = 0; i < tosend; i++) {
 expected += iov[i].iov_len;
 }
-n = writev(s->socket, iov, tosend);
+n = socket_writev(s->socket, iov, tosend);
 if (n <= expected) {
 if (n > 0)
 ret += n;
@@ -148,7 +148,7 @@ static ssize_t stream_writev_cb(RedStream *s, const struct 
iovec *iov, int iovcn
 
 static ssize_t stream_read_cb(RedStream *s, void *buf, size_t size)
 {
-return read(s->socket, buf, size);
+return socket_read(s->socket, buf, size);
 }
 
 static ssize_t stream_ssl_write_cb(RedStream *s, const void *buf, size_t size)
@@ -274,7 +274,7 @@ int red_stream_get_family(const RedStream *s)
 {
 spice_return_val_if_fail(s != NULL, -1);
 
-if (s->socket == -1)
+if (!socket_is_valid(s->socket))
 return -1;
 
 return s->priv->info->laddr_ext.ss_family;
@@ -355,7 +355,7 @@ int red_stream_send_msgfd(RedStream *stream, int fd)
 }
 
 do {
-r = sendmsg(stream->socket, , MSG_NOSIGNAL);
+r = sendmsg(socket_get_raw(stream->socket), , MSG_NOSIGNAL);
 } while (r < 0 && (errno == EINTR || errno == EAGAIN));
 
 return r;
@@ -404,7 +404,7 @@ void red_stream_free(RedStream *s)
 }
 
 red_stream_remove_watch(s);
-close(s->socket);
+socket_close(s->socket);
 
 g_free(s);
 }
@@ -416,21 +416,23 @@ void red_stream_push_channel_event(RedStream *s, int 
event)
 main_dispatcher_channel_event(md, event, s->priv->info);
 }
 
-static void red_stream_set_socket(RedStream *stream, int socket)
+static void red_stream_set_socket(RedStream *stream, socket_t socket)
 {
 stream->socket = socket;
 /* deprecated fields. Filling them for backward compatibility */
 stream->priv->info->llen = sizeof(stream->priv->info->laddr);
 stream->priv->info->plen = sizeof(stream->priv->info->paddr);
-getsockname(stream->socket, (struct 
sockaddr*)(>priv->info->laddr), >priv->info->llen);
-getpeername(stream->socket, (struct 
sockaddr*)(>priv->info->paddr), >priv->info->plen);
+socket_getsockname(stream->socket, (struct 
sockaddr*)(>priv->info->laddr),
+   >priv->info->llen);
+socket_getpeername(stream->socket, (struct 
sockaddr*)(>priv->info->paddr),
+   >priv->info->plen);
 
 stream->priv->info->flags |= SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT;
 stream->priv->info->llen_ext = sizeof(stream->priv->info->laddr_ext);
 stream->priv->info->plen_ext = sizeof(stream->priv->info->paddr_ext);
-getsockname(stream->socket, (struct 
sockaddr*)(>priv->info->laddr_ext),
+socket_getsockname(stream->socket, (struct 
sockaddr*)(>priv->info->laddr_ext),
 >priv->info->llen_ext);
-getpeername(stream->socket, (struct 
sockaddr*)(>priv->info->paddr_ext),
+socket_getpeername(stream->socket, (struct 
sockaddr*)(>priv->info->paddr_ext),
 >priv->info->plen_ext);
 }
 
@@ -446,7 +448,7 @@ void red_stream_set_channel(RedStream *stream, int 
connection_id,
 }
 }
 
-RedStream *red_stream_new(RedsState *reds, int socket)
+RedStream *red_stream_new(RedsState *reds, socket_t socket)
 {
 RedStream *stream;
 
@@ -513,7 +515,7 @@ RedStreamSslStatus red_stream_enable_ssl(RedStream *stream, 
SSL_CTX *ctx)
 BIO *sbio;
 
 // Handle SSL handshaking
-if (!(sbio = BIO_new_socket(stream->socket, BIO_NOCLOSE))) {
+if (!(sbio = BIO_new_socket(socket_get_raw(stream->socket), BIO_NOCLOSE))) 
{
 spice_warning("could not allocate ssl bio socket");
 return RED_STREAM_SSL_STATUS_ERROR;
 }
diff --git a/server/red-stream.h b/server/red-stream.h
index 9a7cc617..52082f68 100644
--- a/server/red-stream.h
+++ b/server/red-stream.h
@@ -30,7 +30,7 @@ typedef struct RedStream RedStream;
 typedef struct RedStreamPrivate RedStreamPrivate;
 
 struct RedStream {
-int socket;
+socket_t 

[Spice-devel] [PATCH spice-server v3 14/32] sound: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/sound.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/server/sound.c b/server/sound.c
index 44b27dec..00b473a8 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -775,14 +775,13 @@ static void record_channel_send_item(RedChannelClient 
*rcc, G_GNUC_UNUSED RedPip
 
 static bool snd_channel_client_config_socket(RedChannelClient *rcc)
 {
-int tos;
 RedStream *stream = red_channel_client_get_stream(rcc);
 RedClient *red_client = red_channel_client_get_client(rcc);
 MainChannelClient *mcc = red_client_get_main(red_client);
 
 #ifdef SO_PRIORITY
 int priority = 6;
-if (setsockopt(stream->socket, SOL_SOCKET, SO_PRIORITY, (void*),
+if (socket_setopt(stream->socket, SOL_SOCKET, SO_PRIORITY, 
(void*),
sizeof(priority)) == -1) {
 if (errno != ENOTSUP) {
 red_channel_warning(red_channel_client_get_channel(rcc),
@@ -791,8 +790,8 @@ static bool 
snd_channel_client_config_socket(RedChannelClient *rcc)
 }
 #endif
 
-tos = IPTOS_LOWDELAY;
-if (setsockopt(stream->socket, IPPROTO_IP, IP_TOS, (void*), 
sizeof(tos)) == -1) {
+int tos = IPTOS_LOWDELAY;
+if (socket_setopt(stream->socket, IPPROTO_IP, IP_TOS, (void*), 
sizeof(tos)) == -1) {
 if (errno != ENOTSUP) {
 red_channel_warning(red_channel_client_get_channel(rcc),
 "setsockopt failed, %s",
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 11/32] red-channel-client: Use socket compatibility layer

2019-01-07 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 server/red-channel-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 375a60b3..07f1988d 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -697,7 +697,7 @@ static void red_channel_client_ping_timer(void *opaque)
 int so_unsent_size = 0;
 
 /* retrieving the occupied size of the socket's tcp snd buffer 
(unacked + unsent) */
-if (ioctl(rcc->priv->stream->socket, SIOCOUTQ, _unsent_size) == -1) 
{
+if (ioctl(socket_get_raw(rcc->priv->stream->socket), SIOCOUTQ, 
_unsent_size) == -1) {
 red_channel_warning(red_channel_client_get_channel(rcc),
 "ioctl(SIOCOUTQ) failed, %s", strerror(errno));
 }
@@ -1034,7 +1034,7 @@ void red_channel_client_shutdown(RedChannelClient *rcc)
 SpiceCoreInterfaceInternal *core = 
red_channel_get_core_interface(rcc->priv->channel);
 core->watch_remove(core, rcc->priv->stream->watch);
 rcc->priv->stream->watch = NULL;
-shutdown(rcc->priv->stream->socket, SHUT_RDWR);
+shutdown(socket_get_raw(rcc->priv->stream->socket), SHUT_RDWR);
 }
 }
 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 03/32] windows: Do not include headers not available on Windows

2019-01-07 Thread Frediano Ziglio
This is a preparatory patch for next portability patches

Signed-off-by: Frediano Ziglio 
Reviewed-by: Marc-André Lureau 
---
 server/dispatcher.c  |  2 ++
 server/net-utils.c   |  2 ++
 server/red-channel-client.c  |  6 --
 server/red-qxl.c |  1 -
 server/red-stream.c  |  6 --
 server/reds.c| 12 
 server/reds.h|  1 -
 server/sound.c   |  2 ++
 server/spice-core.h  |  6 ++
 server/tests/replay.c|  2 ++
 server/tests/test-display-base.c |  2 ++
 server/tests/test-playback.c |  1 -
 12 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 48dc915a..3e27f2c2 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -24,7 +24,9 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
+#endif
 
 #include "dispatcher.h"
 
diff --git a/server/net-utils.c b/server/net-utils.c
index ca8a4e7f..802509a4 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -24,11 +24,13 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
 #include 
 #include 
 #include 
 #include 
+#endif
 
 #include 
 
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index b3a6ec12..375a60b3 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -22,12 +22,14 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
+#ifndef _WIN32
+#include 
+#include 
 #include 
+#endif
 #ifdef HAVE_LINUX_SOCKIOS_H
 #include  /* SIOCOUTQ */
 #endif
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 97940611..cec3eefb 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
diff --git a/server/red-stream.c b/server/red-stream.c
index fd5b8cd1..57034a64 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -20,11 +20,13 @@
 #endif
 
 #include 
-#include 
 #include 
-#include 
 #include 
+#ifndef _WIN32
+#include 
+#include 
 #include 
+#endif
 
 #include 
 
diff --git a/server/reds.c b/server/reds.c
index 22198926..84e4bb8c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -22,16 +22,21 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#ifndef _WIN32
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
-#include 
+#include 
+#else
+#include 
+#endif
 
 #include 
 
@@ -40,7 +45,6 @@
 #endif
 
 #include 
-#include 
 
 #include 
 #include 
diff --git a/server/reds.h b/server/reds.h
index 9f17a5ec..106310eb 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -19,7 +19,6 @@
 #define REDS_H_
 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/server/sound.c b/server/sound.c
index 8cdb7d71..44b27dec 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -23,10 +23,12 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
 #include 
 #include 
 #include 
+#endif
 
 #include 
 #include 
diff --git a/server/spice-core.h b/server/spice-core.h
index 3d5c83bf..d77c4f9e 100644
--- a/server/spice-core.h
+++ b/server/spice-core.h
@@ -23,7 +23,13 @@
 #endif
 
 #include 
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+typedef int socklen_t;
+#endif
 #include 
 #include 
 #include 
diff --git a/server/tests/replay.c b/server/tests/replay.c
index 095b112e..efd67a3d 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -30,7 +30,9 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
+#endif
 #include 
 #include 
 #include 
diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c
index aa59b443..31d856ae 100644
--- a/server/tests/test-display-base.c
+++ b/server/tests/test-display-base.c
@@ -21,8 +21,10 @@
 #include 
 #include 
 #include 
+#ifndef _WIN32
 #include 
 #include 
+#endif
 #include 
 #include 
 #include 
diff --git a/server/tests/test-playback.c b/server/tests/test-playback.c
index acd085db..290c8609 100644
--- a/server/tests/test-playback.c
+++ b/server/tests/test-playback.c
@@ -17,7 +17,6 @@
 */
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.20.1

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


[Spice-devel] [PATCH spice-server v3 01/32] Use proper format strings for spice_log

2019-01-07 Thread Frediano Ziglio
Formatting string should be compatible with GLib.
GLib uses formatting types compatible with GNU.
For Linux this is not an issue as both systems (like a printf) and
GLib one uses the same formatting type.  However on Windows they
differs potentially causing issues.
This is also make worse as GLib 2.58 changed format attribute from
__printf__ to gnu_printf (Microsoft compatibility formats like %I64d
are still supported but you'll get warnings using GCC/Clang
compilers).

Signed-off-by: Frediano Ziglio 
---
 server/char-device.c | 3 ++-
 server/gstreamer-encoder.c   | 4 ++--
 server/main-channel-client.c | 6 +++---
 server/memslot.c | 2 +-
 server/mjpeg-encoder.c   | 6 --
 server/red-channel.c | 6 --
 server/red-client.c  | 6 --
 server/red-replay-qxl.c  | 9 +
 server/reds.c| 4 ++--
 subprojects/spice-common | 2 +-
 10 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/server/char-device.c b/server/char-device.c
index 64b41a94..c00e96ef 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -786,7 +786,8 @@ void red_char_device_client_remove(RedCharDevice *dev,
 }
 
 if (dev->priv->clients == NULL) {
-spice_debug("client removed, memory pool will be freed (%"PRIu64" 
bytes)", dev->priv->cur_pool_size);
+spice_debug("client removed, memory pool will be freed 
(%"G_GUINT64_FORMAT" bytes)",
+dev->priv->cur_pool_size);
 write_buffers_queue_free(>priv->write_bufs_pool);
 dev->priv->cur_pool_size = 0;
 }
diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
index 04f0c02f..972c86e6 100644
--- a/server/gstreamer-encoder.c
+++ b/server/gstreamer-encoder.c
@@ -1080,10 +1080,10 @@ static void set_gstenc_bitrate(SpiceGstEncoder *encoder)
 break;
 }
 default:
-spice_warning("the %s property has an unsupported type %zu",
+spice_warning("the %s property has an unsupported type %" 
G_GSIZE_FORMAT,
   prop, param->value_type);
 }
-spice_debug("setting the GStreamer %s to %"PRIu64, prop, gst_bit_rate);
+spice_debug("setting the GStreamer %s to %"G_GUINT64_FORMAT, prop, 
gst_bit_rate);
 }
 
 /* A helper for spice_gst_encoder_encode_frame() */
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 54be9934..3b6ae269 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -529,8 +529,8 @@ void main_channel_client_handle_pong(MainChannelClient 
*mcc, SpiceMsgPing *ping,
 if (roundtrip <= mcc->priv->latency) {
 // probably high load on client or server result with incorrect 
values
 red_channel_debug(red_channel_client_get_channel(rcc),
-  "net test: invalid values, latency %" PRIu64
-  " roundtrip %" PRIu64 ". assuming high"
+  "net test: invalid values, latency %" 
G_GUINT64_FORMAT
+  " roundtrip %"G_GUINT64_FORMAT". assuming high"
   "bandwidth", mcc->priv->latency, roundtrip);
 mcc->priv->latency = 0;
 mcc->priv->net_test_stage = NET_TEST_STAGE_INVALID;
@@ -542,7 +542,7 @@ void main_channel_client_handle_pong(MainChannelClient 
*mcc, SpiceMsgPing *ping,
 / (roundtrip - mcc->priv->latency);
 mcc->priv->net_test_stage = NET_TEST_STAGE_COMPLETE;
 red_channel_debug(red_channel_client_get_channel(rcc),
-  "net test: latency %f ms, bitrate %"PRIu64" bps (%f 
Mbps)%s",
+  "net test: latency %f ms, bitrate 
%"G_GUINT64_FORMAT" bps (%f Mbps)%s",
   (double)mcc->priv->latency / 1000,
   mcc->priv->bitrate_per_sec,
   (double)mcc->priv->bitrate_per_sec / 1024 / 1024,
diff --git a/server/memslot.c b/server/memslot.c
index c2931321..dae04d2f 100644
--- a/server/memslot.c
+++ b/server/memslot.c
@@ -105,7 +105,7 @@ void *memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL 
addr, uint32_t add_size
 slot_id = memslot_get_id(info, addr);
 if (slot_id > info->num_memslots) {
 print_memslots(info);
-spice_critical("slot_id %d too big, addr=%" PRIx64, slot_id, addr);
+spice_critical("slot_id %d too big, addr=%" G_GINT64_MODIFIER "x", 
slot_id, addr);
 return NULL;
 }
 
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index d4b5c6fc..d64fcfe0 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -614,7 +614,8 @@ static void 
mjpeg_encoder_adjust_params_to_bit_rate(MJpegEncoder *encoder)
 
 spice_debug("cur-fps=%u new-fps=%u (new/old=%.2f) |"
 "bit-rate=%.2f (Mbps) latency=%u (ms) quality=%d |"
-" new-size-avg %"PRIu64" , base-size %"PRIu64", (new/old=%.2f) 
",
+" new-size-avg %"G_GUINT64_FORMAT" 

[Spice-devel] [PATCH spice-server v3 00/32] Port SPICE server to Windows

2019-01-07 Thread Frediano Ziglio
Windows support is useful to use with Qemu under Windows as host or
to implement servers like Xspice.
Mainly SPICE server uses lot of libraries to expose a TCP protocol.
As TCP is implemented with socket library which is quite portable was
not that hard to port.
Beside some minor feature (see REAME.Windows) all was ported.
During porting was choosen to keep Unix as the main platform, if a
change would require too much changes some Windows wrapper is
preferred instead. Not too complicated stuff, the main "wrapper" is
that Windows errors from socket are written back into errno to avoid
to change lot of code handling errors.

Changes since v2:
- better %m replacement;
- many comments updates;
- typo and grammar fixes;
- use int to store socket descriptors/handles;
- merge all v2 updates into a single series;
- split formatting string patch.

Frediano Ziglio (32):
  Use proper format strings for spice_log
  red-replay-qxl: Use PRIxPTR constant for string formatting
  windows: Do not include headers not available on Windows
  build: Detect Windows build and change some definitions
  Avoids %m in formatting for Windows
  sys-socket: Introduce some utility to make sockets more portable
  sys-socket: Add socket_newpair utility
  net-utils: Use socket compatibility layer
  reds: Use socket compatibility layer
  red-stream: Use socket compatibility layer
  red-channel-client: Use socket compatibility layer
  dispatcher: Use socket compatibility layer
  event-loop: Use socket compatibility layer
  sound: Use socket compatibility layer
  basic-event-loop: Use socket compatibility layer
  test-leaks: Use socket compatibility layer
  test-channel: Use socket compatibility layer
  test-stream: Use socket compatibility layer
  windows: Undefine some conflicting preprocessor macros
  windows: Disable code not working on Windows
  dispatcher: Port to Windows
  event-loop: Port to Windows
  tests: Provide alarm replacement for Windows
  test-listen: Exclude Unix sockets part under Windows
  tests: Exclude tests that cannot work on Windows
  test-stat: Adjust delay checks
  red-stream: Fix SSL connection for Windows
  reds: Explicitly include inttypes.h
  Disable recording filtering for Windows
  replay: Port to Windows
  Use structure for socket_t type instead of just a typedef
  Add some notes for the Windows port

 README.Windows|  18 ++
 configure.ac  |  20 ++-
 server/Makefile.am|   2 +
 server/char-device.c  |   3 +-
 server/dispatcher.c   |  48 +++--
 server/dispatcher.h   |   2 +-
 server/event-loop.c   |  11 +-
 server/gstreamer-encoder.c|   4 +-
 server/main-channel-client.c  |   6 +-
 server/memslot.c  |   2 +-
 server/mjpeg-encoder.c|   6 +-
 server/net-utils.c|  35 ++--
 server/net-utils.h|  10 +-
 server/red-channel-client.c   |  12 +-
 server/red-channel.c  |   6 +-
 server/red-client.c   |   6 +-
 server/red-common.h   |   4 +-
 server/red-qxl.c  |   5 +-
 server/red-record-qxl.c   |   7 +
 server/red-replay-qxl.c   |  11 +-
 server/red-stream.c   |  78 +---
 server/red-stream.h   |   6 +-
 server/red-worker.c   |   6 +
 server/reds-private.h |   4 +-
 server/reds.c | 145 ---
 server/reds.h |   4 +-
 server/sound.c|  11 +-
 server/spice-core.h   |   6 +
 server/stat-file.c|   2 +
 server/sys-socket.c   | 287 ++
 server/sys-socket.h   | 172 ++
 server/tests/Makefile.am  |  11 +-
 server/tests/basic-event-loop.c   |   5 +-
 server/tests/replay.c |  15 +-
 server/tests/stat-test.c  |  12 +-
 server/tests/test-channel.c   |  23 +--
 server/tests/test-display-base.c  |   2 +
 server/tests/test-leaks.c |  11 +-
 server/tests/test-listen.c|  10 ++
 server/tests/test-loop.c  |   1 +
 server/tests/test-playback.c  |   1 -
 server/tests/test-record.c|   7 +-
 server/tests/test-stream-device.c |   1 +
 server/tests/test-stream.c|   4 +-
 server/tests/win-alarm.c  |  65 +++
 server/tests/win-alarm.h  |  26 +++
 subprojects/spice-common  |   2 +-
 tools/Makefile.am |   2 +
 48 files changed, 951 insertions(+), 186 deletions(-)
 create mode 100644 README.Windows
 create mode 100644 server/sys-socket.c
 create mode 100644 server/sys-socket.h
 create mode 100644 server/tests/win-alarm.c
 create mode 100644 server/tests/win-alarm.h

-- 
2.20.1

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


Re: [Spice-devel] [PATCH vd_agent_linux v3 2/2] Check errors setting standard file descriptors

2019-01-07 Thread Christophe Fergeau

Acked-by: Christophe Fergeau 

On Fri, Jan 04, 2019 at 10:56:24AM +, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
> ---
>  src/vdagent/vdagent.c   | 16 
>  src/vdagentd/vdagentd.c | 16 
>  2 files changed, 24 insertions(+), 8 deletions(-)
> 
> Changes since v2:
> - avoid long if chaining.
> 
> diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> index 9642a30..90247f9 100644
> --- a/src/vdagent/vdagent.c
> +++ b/src/vdagent/vdagent.c
> @@ -280,7 +280,6 @@ static void wait_and_exit(int s)
>  
>  static int daemonize(void)
>  {
> -int x;
>  int fd[2];
>  
>  if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fd)) {
> @@ -295,9 +294,18 @@ static int daemonize(void)
>  close(STDOUT_FILENO);
>  close(STDERR_FILENO);
>  setsid();
> -x = open("/dev/null", O_RDWR);
> -x = dup(x);
> -x = dup(x);
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (open("/dev/null", O_RDWR) != STDIN_FILENO) {
> +exit(1);
> +}
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (dup(STDIN_FILENO) != STDOUT_FILENO) {
> +exit(1);
> +}
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (dup(STDOUT_FILENO) != STDERR_FILENO) {
> +exit(1);
> +}
>  close(fd[0]);
>  return fd[1];
>  case -1:
> diff --git a/src/vdagentd/vdagentd.c b/src/vdagentd/vdagentd.c
> index 5ed29cc..f5ba3c2 100644
> --- a/src/vdagentd/vdagentd.c
> +++ b/src/vdagentd/vdagentd.c
> @@ -941,7 +941,6 @@ static void agent_read_complete(struct udscs_connection 
> **connp,
>  
>  static void daemonize(void)
>  {
> -int x;
>  FILE *pidfile;
>  
>  /* detach from terminal */
> @@ -951,9 +950,18 @@ static void daemonize(void)
>  close(STDOUT_FILENO);
>  close(STDERR_FILENO);
>  setsid();
> -x = open("/dev/null", O_RDWR);
> -x = dup(x);
> -x = dup(x);
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (open("/dev/null", O_RDWR) != STDIN_FILENO) {
> +exit(1);
> +}
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (dup(STDIN_FILENO) != STDOUT_FILENO) {
> +exit(1);
> +}
> +// coverity[leaked_handle] just opening standard file descriptors
> +if (dup(STDOUT_FILENO) != STDERR_FILENO) {
> +exit(1);
> +}
>  pidfile = fopen(pidfilename, "w");
>  if (pidfile) {
>  fprintf(pidfile, "%d\n", (int)getpid());
> -- 
> 2.20.1
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 1/33 v2] Use proper format strings for spice_log

2019-01-07 Thread Frediano Ziglio
> 
> On Wed, Jan 02, 2019 at 02:56:43PM +, Frediano Ziglio wrote:
> > Formatting string should be compatible with GLib.
> > GLib uses formatting types compatible with GNU.
> > For Linux this is not an issue as both systems (like a printf) and
> > GLib one uses the same formatting type.  However on Windows they
> > differs potentially causing issues.
> > This is also make worse as GLib 2.58 changed format attribute from
> > __printf__ to gnu_printf (Microsoft compatibility formats like %I64d
> > are still supported but you'll get warnings using GCC/Clang
> > compilers).
> > 
> > Signed-off-by: Frediano Ziglio 
> > ---
> >  server/char-device.c |  3 ++-
> >  server/gstreamer-encoder.c   |  4 ++--
> >  server/main-channel-client.c |  6 +++---
> >  server/memslot.c |  2 +-
> >  server/mjpeg-encoder.c   |  6 --
> >  server/red-channel.c |  6 --
> >  server/red-client.c  |  6 --
> >  server/red-replay-qxl.c  | 11 ++-
> >  server/reds.c|  4 ++--
> >  subprojects/spice-common |  2 +-
> >  10 files changed, 29 insertions(+), 21 deletions(-)
> > 
> > Changes since v1:
> > - update due to GLib changes and compatibility to use GLib format
> >   types.
> > 

...

> > diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
> > index 6958a495..4884e97e 100644
> > --- a/server/red-replay-qxl.c
> > +++ b/server/red-replay-qxl.c
> > @@ -227,7 +227,7 @@ static replay_t read_binary(SpiceReplay *replay, const
> > char *prefix, size_t *siz
> >  uint8_t *zlib_buffer;
> >  z_stream strm;
> >  
> > -snprintf(template, sizeof(template), "binary %%d %s %%ld:%%n",
> > prefix);
> > +snprintf(template, sizeof(template), "binary %%d %s %%" PRIdPTR
> > ":%%n", prefix);
> 
> This one introduces the use of PRIdPTR, might be worth moving it to a
> separate commit.
> 

Done

> >  replay_fscanf_check(replay, template, _zlib, size,
> >  >end_pos);
> >  if (replay->error) {
> >  return REPLAY_ERROR;
> > @@ -266,7 +266,8 @@ static replay_t read_binary(SpiceReplay *replay, const
> > char *prefix, size_t *siz
> >  exit(1);
> >  }
> >  if ((ret = inflate(, Z_NO_FLUSH)) != Z_STREAM_END) {
> > -spice_error("inflate error %d (disc: %ld)", ret, *size -
> > strm.total_out);
> > +spice_error("inflate error %d (disc: %" G_GSSIZE_FORMAT ")",
> > +ret, *size - strm.total_out);
> >  if (ret == Z_DATA_ERROR) {
> >  /* last operation may be wrong. since we do the recording
> >   * in red_worker, when there is a shutdown from the
> >   vcpu/io thread
> > @@ -475,7 +476,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay,
> > uint32_t flags)
> >  } else {
> >  size = red_replay_data_chunks(replay, "bitmap.data",
> >  (uint8_t**)>bitmap.data, 0);
> >  if (size != bitmap_size) {
> > -g_warning("bad image, %" PRIuPTR " != %" PRIuPTR, size,
> > bitmap_size);
> > +g_warning("bad image, %" G_GSIZE_FORMAT " != %"
> > G_GSIZE_FORMAT, size, bitmap_size);
> >  return NULL;
> >  }
> >  }
> > @@ -1137,7 +1138,7 @@ static QXLSurfaceCmd
> > *red_replay_surface_cmd(SpiceReplay *replay)
> >  if ((qxl->flags & QXL_SURF_FLAG_KEEP_DATA) != 0) {
> >  read_binary(replay, "data", _size,
> >  (uint8_t**)>u.surface_create.data, 0);
> >  if (read_size != size) {
> > -g_warning("mismatch %" PRIuPTR " != %" PRIuPTR, size,
> > read_size);
> > +g_warning("mismatch %" G_GSIZE_FORMAT " != %"
> > G_GSIZE_FORMAT, size, read_size);
> >  }
> >  } else {
> >  qxl->u.surface_create.data =
> >  QXLPHYSICAL_FROM_PTR(replay_malloc(replay, size));
> > @@ -1321,7 +1322,7 @@ SPICE_GNUC_VISIBLE QXLCommandExt*
> > spice_replay_next_cmd(SpiceReplay *replay,
> >  cmd = replay_malloc0(replay, sizeof(QXLCommandExt));
> >  cmd->cmd.type = type;
> >  cmd->group_id = 0;
> > -spice_debug("command %"SCNu64", %d", timestamp, cmd->cmd.type);
> > +spice_debug("command %"G_GUINT64_FORMAT", %d", timestamp,
> > cmd->cmd.type);
> >  switch (cmd->cmd.type) {
> >  case QXL_CMD_DRAW:
> >  cmd->flags = 0;
> > diff --git a/server/reds.c b/server/reds.c
> > index cdbb94cb..22198926 100644
> > --- a/server/reds.c
> > +++ b/server/reds.c
> > @@ -1149,7 +1149,7 @@ static void
> > reds_on_main_agent_monitors_config(RedsState *reds,
> >  }
> >  spice_buffer_append(cmc, message, size);
> >  if (sizeof(VDAgentMessage) > cmc->offset) {
> > -spice_debug("not enough data yet. %zd", cmc->offset);
> > +spice_debug("not enough data yet. %" G_GSSIZE_FORMAT,
> > cmc->offset);
> >  return;
> >  }
> >  msg_header = (VDAgentMessage *)cmc->buffer;
> > @@ -1157,7 +1157,7 

Re: [Spice-devel] [PATCH vd_agent_linux v3 1/2] Ignore some Coverity reports

2019-01-07 Thread Christophe Fergeau
On Fri, Jan 04, 2019 at 10:56:23AM +, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio 
> ---
>  src/udscs.c| 2 ++
>  src/vdagent/x11.c  | 2 ++
>  src/vdagentd/virtio-port.c | 1 +
>  3 files changed, 5 insertions(+)
> 
> diff --git a/src/udscs.c b/src/udscs.c
> index 05fe41b..32bd6e6 100644
> --- a/src/udscs.c
> +++ b/src/udscs.c
> @@ -341,12 +341,14 @@ static gboolean udscs_io_channel_cb(GIOChannel *source,
>  
>  if (condition & G_IO_IN) {
>  udscs_do_read();
> +// coverity[check_after_deref] previous function can change conn
>  if (conn == NULL)
>  return G_SOURCE_REMOVE;
>  return G_SOURCE_CONTINUE;
>  }
>  if (condition & G_IO_OUT) {
>  udscs_do_write();
> +// coverity[check_after_deref] previous function can change conn
>  if (conn == NULL)
>  return G_SOURCE_REMOVE;
>  if (conn->write_buf)
> diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
> index 53d3c48..02b4858 100644
> --- a/src/vdagent/x11.c
> +++ b/src/vdagent/x11.c
> @@ -393,6 +393,7 @@ static void vdagent_x11_set_clipboard_owner(struct 
> vdagent_x11 *x11,
>  x11->selection_req_data_size = 0;
>  x11->selection_req_atom = None;
>  } else {
> +// coverity[var_deref_op] if it is not the first there's a 
> previous

Not the easiest code to follow imo, not sure there's a better way to
write it though..


Acked-by: Christophe Fergeau 


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 33/34] audio: use gstreamer by default

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:01:02PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> The pulse backend is getting deprecated.

Not sure this is something we should do right before a release rather
than right after the release so that the gstreamer backend on linux gets
a bit more testing than usual.

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/spice-audio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/spice-audio.c b/src/spice-audio.c
> index daf62df..a03c80b 100644
> --- a/src/spice-audio.c
> +++ b/src/spice-audio.c
> @@ -236,11 +236,11 @@ SpiceAudio *spice_audio_new_priv(SpiceSession *session, 
> GMainContext *context,
>  if (name == NULL)
>  name = g_get_application_name();
>  
> +self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
>  #ifdef HAVE_PULSE
> -self = SPICE_AUDIO(spice_pulse_new(session, context, name));
> -#endif
>  if (!self)
> -self = SPICE_AUDIO(spice_gstaudio_new(session, context, name));
> +self = SPICE_AUDIO(spice_pulse_new(session, context, name));
> +#endif
>  if (!self)
>  return NULL;
>  
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 28/34] meson: switch vapi to auto feature

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:57PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Removed unused vapigen/vapidir variables as well.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build   | 9 +
>  meson_options.txt | 3 +--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 9896151..7e0c68d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -279,10 +279,11 @@ endif
>  
>  # vala (depends on introspection)
>  spice_gtk_has_vala = false
> -if spice_gtk_has_introspection and get_option('vapi')
> -  vapigen_dep = dependency('vapigen')
> -  vapidir = vapigen_dep.get_pkgconfig_variable('vapidir')
> -  vapigen = dependency('vapigen').get_pkgconfig_variable('vapigen')
> +d = dependency('vapigen', required : get_option('vapi'))
> +if d.found()
> +  if not spice_gtk_has_introspection
> +error('VAPI support requested without introspection')
> +  endif

I'd be a bit more sophisticated here in order to handle 'auto', maybe
something like this:

if not spice_gtk_has_introspection:
if get_option('vapi').enabled()
error('VAPI support requested without introspection')
endif
spice_gtk_has_vala = false
endif
spice_gtk_has_vala = true


Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 29/34] gstaudio: remove spice_gstaudio_finalize

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:58PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/spice-gstaudio.c | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
> index dcd0591..aff69d2 100644
> --- a/src/spice-gstaudio.c
> +++ b/src/spice-gstaudio.c
> @@ -59,11 +59,6 @@ static void 
> spice_gstaudio_get_record_volume_info_async(SpiceAudio *audio,
>  static gboolean spice_gstaudio_get_record_volume_info_finish(SpiceAudio 
> *audio,
>  GAsyncResult *res, gboolean *mute, guint8 *nchannels, guint16 
> **volume, GError **error);
>  
> -static void spice_gstaudio_finalize(GObject *obj)
> -{
> -G_OBJECT_CLASS(spice_gstaudio_parent_class)->finalize(obj);
> -}
> -
>  static void stream_dispose(struct stream *s)
>  {
>  if (s->pipe) {
> @@ -113,7 +108,6 @@ static void spice_gstaudio_class_init(SpiceGstaudioClass 
> *klass)
>  audio_class->get_record_volume_info_async = 
> spice_gstaudio_get_record_volume_info_async;
>  audio_class->get_record_volume_info_finish = 
> spice_gstaudio_get_record_volume_info_finish;
>  
> -gobject_class->finalize = spice_gstaudio_finalize;
>  gobject_class->dispose = spice_gstaudio_dispose;
>  }
>  
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 26/34] meson: don't alias meson host_machine.system()

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:55PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> It makes it non-obvious what that variable actually is.

Reviewed-by: Christophe Fergeau 

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build | 9 -
>  src/meson.build | 2 +-
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index b596a0f..bbfd8d0 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -34,7 +34,6 @@ spice_gtk_include = [include_directories('.')]
>  spice_glib_deps = []
>  spice_gtk_deps = []
>  spice_acl_deps = []
> -spice_gtk_host_system = host_machine.system()
>  
>  #
>  # Spice common subproject
> @@ -93,7 +92,7 @@ endforeach
>  # mandatory dependencies, without specific version requirement
>  # TODO: specify minimum version for cairo, jpeg and zlib?
>  deps = ['cairo', 'libjpeg', 'zlib', 'json-glib-1.0']
> -if spice_gtk_host_system == 'windows'
> +if host_machine.system() == 'windows'
>deps += 'gio-windows-2.0'
>  else
>deps += 'gio-unix-2.0'
> @@ -104,7 +103,7 @@ foreach dep : deps
>  endforeach
>  
>  deps = []
> -if spice_gtk_host_system == 'windows'
> +if host_machine.system() == 'windows'
>deps += ['libws2_32', 'libgdi32']
>  endif
>  
> @@ -132,7 +131,7 @@ d = dependency('gtk+-3.0', version : '>= 
> @0@'.format(gtk_version_required),
> required: get_option('gtk'))
>  if d.found()
>spice_gtk_deps += d
> -  if spice_gtk_host_system != 'windows'
> +  if host_machine.system() != 'windows'
>  spice_gtk_deps += dependency('epoxy')
>  spice_gtk_deps += dependency('x11')
>endif
> @@ -245,7 +244,7 @@ spice_gtk_coroutine = get_option('coroutine')
>  if spice_gtk_coroutine == 'ucontext'
>if compiler.has_function('makecontext') and 
> compiler.has_function('swapcontext') and compiler.has_function('getcontext')
>  spice_gtk_config_data.set('WITH_UCONTEXT', '1')
> -if spice_gtk_host_system == 'darwin'
> +if host_machine.system() == 'darwin'
>spice_gtk_config_data.set('_XOPEN_SOURCE', '1')
>  endif
>else
> diff --git a/src/meson.build b/src/meson.build
> index 0057dfc..d9614cb 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -154,7 +154,7 @@ elif spice_gtk_coroutine == 'winfiber'
>spice_client_glib_sources += 'coroutine_winfibers.c'
>  endif
>  
> -if spice_gtk_has_usbredir and spice_gtk_host_system == 'windows'
> +if spice_gtk_has_usbredir and host_machine.system() == 'windows'
>spice_client_glib_sources += ['usbdk_api.c',
>  'usbdk_api.h',
>  'win-usb-dev.c',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 25/34] meson: add gtk_doc option

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:54PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> This is based on similar meson code in GStreamer.
> (one of the core meson developer, Nirbheek, is also doing the GStreamer
> meson build support)
> 
> This allows me to install a meson-mingw64 build, with
> -Dgtk_doc=disabled, as it fails to build currently for other reasons
> which I don't have time to investigate yet.

Reviewed-by: Christophe Fergeau 

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build   | 10 +-
>  meson_options.txt |  4 
>  2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index cb37056..b596a0f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -326,7 +326,15 @@ 
> add_project_arguments(compiler.get_supported_arguments(spice_gtk_global_cflags),
>  subdir('src')
>  subdir('tools')
>  subdir('tests')
> -subdir('doc')
> +if build_machine.system() == 'windows'
> +  message('Disabling gtk-doc while building on Windows')
> +else
> +  if find_program('gtkdoc-scan', required : get_option('gtk_doc')).found()
> +subdir('doc')
> +  else
> +message('Not building documentation as gtk-doc was not found')
> +  endif
> +endif
>  subdir('data')
>  subdir('man')
>  subdir('po')
> diff --git a/meson_options.txt b/meson_options.txt
> index 8dcded2..ff4654d 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -76,3 +76,7 @@ option('opus',
>  option('smartcard',
>  type : 'feature',
>  description : 'Enable smartcard support')
> +
> +option('gtk_doc',
> +   type : 'feature',
> +   description : 'Generate API documentation with gtk-doc')
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 24/34] meson: remove some meson-spice-gtk-doc warnings

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:53PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> ../src/./spice-audio.h:22:2: warning: #warning "Only  can be 
> included directly" [-Wcpp]
>  #warning "Only  can be included directly"
>   ^~~
> ...
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  doc/reference/meson.build | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/doc/reference/meson.build b/doc/reference/meson.build
> index 7cb94f3..a121e66 100644
> --- a/doc/reference/meson.build
> +++ b/doc/reference/meson.build
> @@ -45,6 +45,7 @@ gnome.gtkdoc('spice-gtk',
>   gobject_typesfile : files('spice-gtk.types'),
>   ignore_headers : ignore_headers,
>   include_directories: spice_gtk_include,
> + c_args : '-DSPICE_COMPILATION',
>   install : true,
>   scan_args : ['--deprecated-guards="SPICE_DISABLE_DEPRECATED"', 
> '--ignore-decorators="G_GNUC_INTERNAL"'],
>   src_dir : join_paths(meson.source_root(), 'src'))
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 23/34] build-sys: remove dbus option

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:52PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> The desktop-integration code works by attempting to connect to GNOME
> Session Manager. If it is absent, it will print a "Warning no
> automount-inhibiting implementation available" message.
> 
> Tested on win32 as well.

What happens on win32? Is it showing a warning which was not there
before?

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml|  4 +---
>  configure.ac  | 15 ---
>  meson.build   |  7 ---
>  meson_options.txt |  5 -
>  src/desktop-integration.c | 18 +++---
>  5 files changed, 4 insertions(+), 45 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 750e801..74280e9 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -38,14 +38,12 @@ makecheck_simple:
>  --enable-pulse=no
>  --enable-smartcard=no
>  --enable-usbredir=no
> ---enable-dbus=no
>- make -j4
>- make check
>  
>  makecheck_simple-meson:
>script:
> -  - meson build -Dauto_features=disabled
> --Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
> +  - meson build -Dauto_features=disabled || (cat 
> build/meson-logs/meson-log.txt && exit 1)
>- ninja -C build
>- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
>  
> diff --git a/configure.ac b/configure.ac
> index 70587ef..a23f861 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -476,20 +476,6 @@ AM_CONDITIONAL(WITH_VALA, [test "x$enable_vala" = 
> "xyes"])
>  VAPIDIR="${datadir}/vala/vapi"
>  AC_SUBST(VAPIDIR)
>  
> -AC_ARG_ENABLE([dbus],
> -  AS_HELP_STRING([--enable-dbus=@<:@auto/yes/no@:>@],
> - [Enable dbus support for desktop integration (disabling 
> automount) @<:@default=auto@:>@]),
> -  [],
> -  [enable_dbus="auto"])
> -
> -have_dbus=no
> -if test "x$enable_dbus" != "xno"; then
> -  AC_DEFINE([USE_GDBUS], [1], [Define if supporting gdbus])
> -  have_dbus=yes
> -else
> -  SPICE_WARNING([No D-Bus support, desktop integration and USB redirection 
> may not work properly])
> -fi
> -
>  AC_ARG_ENABLE([alignment-checks],
>AS_HELP_STRING([--enable-alignment-checks],
>   [Enable runtime checks for cast alignment 
> @<:@default=no@:>@]),
> @@ -556,7 +542,6 @@ AC_MSG_NOTICE([
>  SASL support: ${have_sasl}
>  Smartcard support:${have_smartcard}
>  USB redirection support:  ${have_usbredir} ${with_usbredir_hotplug}
> -DBus: ${have_dbus}
>  WebDAV support:   ${have_phodav}
>  LZ4 support:  ${have_lz4}
>  
> diff --git a/meson.build b/meson.build
> index 26d19ed..cb37056 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -278,13 +278,6 @@ if spice_gtk_has_introspection and get_option('vapi')
>spice_gtk_has_vala = true
>  endif
>  
> -# dbus
> -if get_option('dbus')
> -  spice_gtk_config_data.set('USE_GDBUS', '1')
> -else
> -  warning('No D-Bus support, desktop integration and USB redirection may not 
> work properly')
> -endif
> -
>  # lz4
>  spice_gtk_has_lz4 = false
>  d = dependency('liblz4', required : get_option('lz4'))
> diff --git a/meson_options.txt b/meson_options.txt
> index a3995f8..8dcded2 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -52,11 +52,6 @@ option('vapi',
>  value : true,
>  description: 'Check for vala requirements')
>  
> -option('dbus',
> -type : 'boolean',
> -value : true,
> -description: 'Enable dbus support for desktop integration (disabling 
> automount)')
> -
>  option('alignment-checks',
>  type : 'boolean',
>  value : false,
> diff --git a/src/desktop-integration.c b/src/desktop-integration.c
> index 7c433bb..d5924c0 100644
> --- a/src/desktop-integration.c
> +++ b/src/desktop-integration.c
> @@ -31,11 +31,7 @@
>  #define GNOME_SESSION_INHIBIT_AUTOMOUNT 16
>  
>  struct _SpiceDesktopIntegrationPrivate {
> -#if defined(USE_GDBUS)
>  GDBusProxy *gnome_session_proxy;
> -#else
> -GObject *gnome_session_proxy; /* dummy */
> -#endif
>  guint gnome_automount_inhibit_cookie;
>  };
>  
> @@ -55,12 +51,11 @@ static void handle_dbus_call_error(const char *call, 
> GError **_error)
>  
>  static gboolean gnome_integration_init(SpiceDesktopIntegration *self)
>  {
> -G_GNUC_UNUSED SpiceDesktopIntegrationPrivate *priv = self->priv;
> +SpiceDesktopIntegrationPrivate *priv = self->priv;
>  GError *error = NULL;
>  gboolean success = TRUE;
> -
> -#if defined(USE_GDBUS)
>  gchar *name_owner = NULL;
> +
>  priv->gnome_session_proxy =
>  g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
>G_DBUS_PROXY_FLAGS_NONE,
> @@ -76,9 +71,6 @@ static gboolean 
> gnome_integration_init(SpiceDesktopIntegration *self)
>  success = FALSE;
>  }
>  g_free(name_owner);

Re: [Spice-devel] [PATCH spice-gtk 22/34] build-sys: switch smartcard option to auto feature

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:51PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml| 1 -
>  meson.build   | 5 +++--
>  meson_options.txt | 3 +--
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index a3cb6ad..750e801 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -45,7 +45,6 @@ makecheck_simple:
>  makecheck_simple-meson:
>script:
>- meson build -Dauto_features=disabled
> --Dsmartcard=false
>  -Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
>- ninja -C build
>- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
> diff --git a/meson.build b/meson.build
> index d2df33e..26d19ed 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -305,8 +305,9 @@ endif
>  
>  # smartcard check
>  spice_gtk_has_smartcard = false
> -if get_option('smartcard')
> -  spice_glib_deps += dependency('libcacard', version : '>= 2.5.1')
> +d = dependency('libcacard', version : '>= 2.5.1', required : 
> get_option('smartcard'))
> +if d.found()
> +  spice_glib_deps += d
>spice_gtk_config_data.set('USE_SMARTCARD', '1')
>  endif
>  
> diff --git a/meson_options.txt b/meson_options.txt
> index a16fe49..a3995f8 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -79,6 +79,5 @@ option('opus',
>  description: 'Enable Opus audio codec')
>  
>  option('smartcard',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description : 'Enable smartcard support')
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 21/34] meson: switch sasl option to auto feature

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:50PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml| 1 -
>  meson.build   | 5 +++--
>  meson_options.txt | 3 +--
>  3 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 692374a..a3cb6ad 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -45,7 +45,6 @@ makecheck_simple:
>  makecheck_simple-meson:
>script:
>- meson build -Dauto_features=disabled
> --Dsasl=false
>  -Dsmartcard=false
>  -Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
>- ninja -C build
> diff --git a/meson.build b/meson.build
> index a5d584d..d2df33e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -296,8 +296,9 @@ endif
>  
>  # sasl
>  spice_gtk_has_sasl = false
> -if get_option('sasl')
> -  spice_glib_deps += dependency('libsasl2')
> +d = dependency('libsasl2', required : get_option('sasl'))
> +if d.found()
> +  spice_glib_deps += d
>spice_gtk_config_data.set('HAVE_SASL', '1')
>spice_gtk_has_sasl = true
>  endif
> diff --git a/meson_options.txt b/meson_options.txt
> index abd0b0f..a16fe49 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -67,8 +67,7 @@ option('lz4',
>  description: 'Enable lz4 compression support')
>  
>  option('sasl',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description : 'Use cyrus SASL authentication')
>  
>  option('celt051',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 20/34] meson: switch lz4 option to auto feature

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:49PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Contrary to spice server dependency, spice-gtk doesn't have a known
> minimum version requirement.

Ideally, we'd still check for some not very old liblz4 to avoid compile
time failures, but the weird versioning does not make that easy :(

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml|  1 -
>  meson.build   | 10 +++---
>  meson_options.txt |  3 +--
>  3 files changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 125dbd7..692374a 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -45,7 +45,6 @@ makecheck_simple:
>  makecheck_simple-meson:
>script:
>- meson build -Dauto_features=disabled
> --Dlz4=false
>  -Dsasl=false
>  -Dsmartcard=false
>  -Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
> diff --git a/meson.build b/meson.build
> index 4c9c05c..a5d584d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -287,13 +287,9 @@ endif
>  
>  # lz4
>  spice_gtk_has_lz4 = false
> -if get_option('lz4')
> -  lz4_dep = dependency('liblz4', required : false, version : '>= 129')
> -  if not lz4_dep.found()
> -lz4_dep = dependency('liblz4', version : '>= 1.7.3')
> -  endif
> -
> -  spice_glib_deps += lz4_dep
> +d = dependency('liblz4', required : get_option('lz4'))
> +if d.found()
> +  spice_glib_deps += d
>spice_gtk_config_data.set('USE_LZ4', '1')
>spice_gtk_has_lz4 = true
>  endif
> diff --git a/meson_options.txt b/meson_options.txt
> index e92f931..abd0b0f 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -63,8 +63,7 @@ option('alignment-checks',
>  description : 'Enable runtime checks for cast alignment')
>  
>  option('lz4',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description: 'Enable lz4 compression support')
>  
>  option('sasl',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 07/34] build-sys: drop support for libusb < 1.0.16

2019-01-07 Thread Christophe Fergeau
Missed that one, but

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:36PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> libusb 1.0.16 was released on 11 Jul 2013, that should be long enough.
> 
> From the distro we care about, according to repology, CentOS 6 and
> Ubuntu 12.04 have too old libusb (1.0.9rc).
> 
> Fwiw, libusb 1.0.23 should hopefully see Windows hotplug
> support (https://github.com/libusb/libusb/issues/409).
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml   |  2 +-
>  configure.ac | 27 +--
>  meson.build  | 11 +--
>  src/usb-device-manager.c |  8 ++--
>  4 files changed, 5 insertions(+), 43 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 8a3fdea..260d55d 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -6,7 +6,7 @@ variables:
>  intltool gtk3-devel gtk-doc gobject-introspection-devel
>  cyrus-sasl-devel pulseaudio-libs-devel libjpeg-turbo-devel
>  libacl-devel gstreamer1-devel gstreamer1-plugins-base-devel
> -polkit-devel vala lz4-devel opus-devel libgudev-devel
> +polkit-devel vala lz4-devel opus-devel
>  pixman-devel libcacard-devel celt051-devel libphodav-devel
>  usbutils usbredir-devel libusbx-devel libsoup-devel
>  json-glib-devel
> diff --git a/configure.ac b/configure.ac
> index be172d5..a17af9c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -275,38 +275,13 @@ if test "x$enable_usbredir" = "xno"; then
>have_usbredir="no"
>  else
>PKG_CHECK_MODULES([USBREDIR],
> -[libusb-1.0 >= 1.0.9 libusbredirhost 
> libusbredirparser-0.5],
> +[libusb-1.0 >= 1.0.16 libusbredirhost 
> libusbredirparser-0.5],
>  [have_usbredir=yes],
>  [have_usbredir=no])
>if test "x$have_usbredir" = "xno" && test "x$enable_usbredir" = "xyes"; 
> then
>  AC_MSG_ERROR([usbredir support explicitly requested, but some required 
> packages are not available])
>fi
>  
> -  # On non windows we need either libusb hotplug support or gudev
> -  if test "x$have_usbredir" = "xyes" && test "x$os_win32" = "xno"; then
> -PKG_CHECK_MODULES([LIBUSB_HOTPLUG], [libusb-1.0 >= 1.0.16],
> -  [have_libusb_hotplug=yes], [have_libusb_hotplug=no])
> -if test "x$have_libusb_hotplug" = "xyes"; then
> -  AC_DEFINE([USE_LIBUSB_HOTPLUG], [1], [Define if libusb has hotplug 
> support])
> -  with_usbredir_hotplug="with libusb hotplug"
> -else
> -  PKG_CHECK_MODULES([GUDEV],
> -[gudev-1.0],
> -[have_gudev=yes],
> -[have_gudev=no])
> -
> -  if test "x$have_gudev" = "xno" && test "x$enable_usbredir" = "xyes"; 
> then
> -AC_MSG_ERROR([usbredir requested but required gudev is not 
> available])
> -  fi
> -  if test "x$have_gudev" = "xyes"; then
> -AC_DEFINE([USE_GUDEV], [1], [Define if supporting gudev])
> -with_usbredir_hotplug="with gudev hotplug"
> -  else
> -have_usbredir=no
> -  fi
> -fi
> -  fi
> -
>if test "x$have_usbredir" = "xyes"; then
>  AC_DEFINE([USE_USBREDIR], [1], [Define if supporting usbredir proxying])
>fi
> diff --git a/meson.build b/meson.build
> index 4a00b1c..13c1756 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -174,22 +174,13 @@ spice_gtk_has_usbredir = false
>  if get_option('usbredir')
>deps = {'libusbredirparser-0.5': '>= 0.5',
>'libusbredirhost' : '>= 0.4.2',
> -  'libusb-1.0' : '>= 1.0.9'}
> +  'libusb-1.0' : '>= 1.0.16'}
>  
>foreach dep, version : deps
>  usb_dep = dependency(dep, version : version)
>  spice_glib_deps += usb_dep
>endforeach
>  
> -  if spice_gtk_host_system != 'windows'
> -if usb_dep.version().version_compare('>= 1.0.16')
> -  spice_gtk_config_data.set('USE_LIBUSB_HOTPLUG', '1')
> -else
> -  spice_glib_deps += dependency('gudev-1.0')
> -  spice_gtk_config_data.set('USE_GUDEV', '1')
> -endif
> -  endif
> -
>spice_gtk_config_data.set('USE_USBREDIR', '1')
>spice_gtk_has_usbredir = true
>  endif
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 354038a..55b672b 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -31,13 +31,9 @@
>  #include "usbdk_api.h"
>  #endif
>  
> -#if defined(USE_GUDEV)
> -#include 
> -#elif defined(G_OS_WIN32)
> +#if defined(G_OS_WIN32)
>  #include "win-usb-dev.h"
>  #define USE_GUDEV /* win-usb-dev.h provides a fake gudev interface */
> -#elif !defined USE_LIBUSB_HOTPLUG
> -#error "Expecting one of USE_GUDEV or USE_LIBUSB_HOTPLUG to be defined"
>  #endif
>  
>  #include "channel-usbredir-priv.h"
> @@ -370,7 +366,7 @@ static void spice_usb_device_manager_dispose(GObject 
> *gobject)
>  SpiceUsbDeviceManager *self = 

Re: [Spice-devel] [PATCH spice-gtk 14/34] meson: switch gtk option to auto feature

2019-01-07 Thread Frediano Ziglio
> 
> Reviewed-by: Christophe Fergeau 
> 

Is it an ack or a nack?

> On Mon, Jan 07, 2019 at 12:00:43PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> > 
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  meson.build   | 6 --
> >  meson_options.txt | 3 +--
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 91d0742..ebc846e 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -128,8 +128,10 @@ endforeach
> >  # gtk
> >  spice_gtk_has_gtk = false
> >  gtk_version_required = '3.22'
> > -if get_option('gtk')
> > -  spice_gtk_deps += dependency('gtk+-3.0', version : '>=
> > @0@'.format(gtk_version_required))
> > +d = dependency('gtk+-3.0', version : '>=
> > @0@'.format(gtk_version_required),
> > +   required: get_option('gtk'))
> > +if d.found()
> > +  spice_gtk_deps += d
> >if spice_gtk_host_system != 'windows'
> >  spice_gtk_deps += dependency('epoxy')
> >  spice_gtk_deps += dependency('x11')
> > diff --git a/meson_options.txt b/meson_options.txt
> > index 515a86b..fc130dc 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -1,6 +1,5 @@
> >  option('gtk',
> > -type : 'boolean',
> > -value : true,
> > +type : 'feature',
> >  description: 'Enable gtk+')
> >  
> >  option('webdav',
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 19/34] meson: switch introspection option to auto feature

2019-01-07 Thread Christophe Fergeau

Acked-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:48PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build   | 5 +++--
>  meson_options.txt | 3 +--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 07e8227..4c9c05c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -263,8 +263,9 @@ endif
>  
>  # introspection
>  spice_gtk_has_introspection = false
> -if get_option('introspection')
> -  spice_glib_deps += dependency('gobject-introspection-1.0', version : '>= 
> 0.94')
> +d = dependency('gobject-introspection-1.0', version : '>= 0.94', required : 
> get_option('introspection'))
> +if d.found()
> +  spice_glib_deps += d
>spice_gtk_has_introspection = true
>  endif
>  
> diff --git a/meson_options.txt b/meson_options.txt
> index 889c976..e92f931 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -44,8 +44,7 @@ option('coroutine',
>  description : 'Use ucontext or GThread for coroutines')
>  
>  option('introspection',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description: 'Check for GObject instrospection requirements')
>  
>  option('vapi',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 18/34] meson: switch polkit option to auto feature

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:47PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build   | 32 +++-
>  meson_options.txt |  3 +--
>  2 files changed, 16 insertions(+), 19 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 18e330f..07e8227 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -186,26 +186,24 @@ endif
>  
>  # polkit
>  spice_gtk_has_polkit = false
> -if get_option('polkit')
> -  polkit_dep = dependency('polkit-gobject-1', version : '>= 0.96')# 
> ,required : false)
> -  if polkit_dep.found()
> -spice_gtk_policy_dir = polkit_dep.get_pkgconfig_variable('policydir')
> -foreach func : ['polkit_authority_get_sync', 
> 'polkit_authorization_result_get_dismissed']
> -  if compiler.has_function(func, dependencies : polkit_dep)
> -spice_gtk_config_data.set('HAVE_@0@'.format(func.to_upper()), '1')
> -  endif
> -endforeach
> -
> -if not compiler.has_function('acl_get_file')
> -  acl_dep = compiler.find_library('acl')
> -  if not compiler.has_function('acl_get_file', dependencies : acl_dep)
> -error('PolicyKit support requested, but some required packages are 
> not available')
> -  endif
> -  spice_acl_deps += acl_dep
> +d = dependency('polkit-gobject-1', version : '>= 0.96', required : 
> get_option('polkit'))
> +if d.found()
> +  spice_gtk_policy_dir = d.get_pkgconfig_variable('policydir')
> +  foreach func : ['polkit_authority_get_sync', 
> 'polkit_authorization_result_get_dismissed']
> +if compiler.has_function(func, dependencies : d)
> +  spice_gtk_config_data.set('HAVE_@0@'.format(func.to_upper()), '1')
> +endif
> +  endforeach
> +
> +  if not compiler.has_function('acl_get_file')
> +acl_dep = compiler.find_library('acl')
> +if not compiler.has_function('acl_get_file', dependencies : acl_dep)
> +  error('PolicyKit support requested, but some required packages are not 
> available')

With 'auto', we should just disable polkit support if this is missing.

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 17/34] meson: switch usbredir option to auto feature

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:46PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml|  1 -
>  meson.build   | 15 +--
>  meson_options.txt |  3 +--
>  3 files changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index fabe29e..125dbd7 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -48,7 +48,6 @@ makecheck_simple-meson:
>  -Dlz4=false
>  -Dsasl=false
>  -Dsmartcard=false
> --Dusbredir=false
>  -Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
>- ninja -C build
>- (cd build && meson test) || (cat build/meson-logs/testlog.txt && exit 1)
> diff --git a/meson.build b/meson.build
> index 69f7e1f..18e330f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -175,16 +175,11 @@ endif
>  
>  # usbredir
>  spice_gtk_has_usbredir = false
> -if get_option('usbredir')
> -  deps = {'libusbredirparser-0.5': '>= 0.5',
> -  'libusbredirhost' : '>= 0.4.2',
> -  'libusb-1.0' : '>= 1.0.16'}
> -
> -  foreach dep, version : deps
> -usb_dep = dependency(dep, version : version)
> -spice_glib_deps += usb_dep
> -  endforeach
> -
> +d = dependency('libusbredirparser-0.5', required : get_option('usbredir'))
> +if d.found()
> +  spice_glib_deps += d
> +  spice_glib_deps += dependency('libusbredirhost', version : '>= 0.4.2')
> +  spice_glib_deps += dependency('libusb-1.0', version : '>= 1.0.16')

Thinking of the behaviour that we want with 'auto', shouldn't it be
something like (pseudo-code) this?

d1 = dependency('libusbredirparser-0.5', required : get_option('usbredir'))
d2 = dependency('libusbredirhost', version : '>= 0.4.2', required : 
get_option('usbredir')))
d3 = dependency('libusb-1.0', version : '>= 1.0.16', required : 
get_option('usbredir')))
if d1.found() and d2.found() and d3.found():
  spice_glib_deps += [ d1, d2, d3 ]



signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 16/34] meson: switch pulse option to auto feature

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:45PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml| 1 -
>  meson.build   | 8 +++-
>  meson_options.txt | 3 +--
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index e913da4..fabe29e 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -47,7 +47,6 @@ makecheck_simple-meson:
>- meson build -Dauto_features=disabled
>  -Dlz4=false
>  -Dsasl=false
> --Dpulse=false
>  -Dsmartcard=false
>  -Dusbredir=false
>  -Ddbus=false || (cat build/meson-logs/meson-log.txt && exit 
> 1)
> diff --git a/meson.build b/meson.build
> index 9bb56c3..69f7e1f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -154,11 +154,9 @@ endif
>  
>  # pulse
>  spice_gtk_has_pulse = false
> -if get_option('pulse')
> -  deps = ['libpulse', 'libpulse-mainloop-glib']
> -  foreach dep : deps
> -spice_glib_deps += dependency(dep)
> -  endforeach
> +d = dependency('libpulse-mainloop-glib', required: get_option('pulse'))

There were 2 deps, one for 'libpulse' the other for
'libpulse-mainloop-glib', did you intentionally drop one?

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 14/34] meson: switch gtk option to auto feature

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:43PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build   | 6 --
>  meson_options.txt | 3 +--
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 91d0742..ebc846e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -128,8 +128,10 @@ endforeach
>  # gtk
>  spice_gtk_has_gtk = false
>  gtk_version_required = '3.22'
> -if get_option('gtk')
> -  spice_gtk_deps += dependency('gtk+-3.0', version : '>= 
> @0@'.format(gtk_version_required))
> +d = dependency('gtk+-3.0', version : '>= @0@'.format(gtk_version_required),
> +   required: get_option('gtk'))
> +if d.found()
> +  spice_gtk_deps += d
>if spice_gtk_host_system != 'windows'
>  spice_gtk_deps += dependency('epoxy')
>  spice_gtk_deps += dependency('x11')
> diff --git a/meson_options.txt b/meson_options.txt
> index 515a86b..fc130dc 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,6 +1,5 @@
>  option('gtk',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description: 'Enable gtk+')
>  
>  option('webdav',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 15/34] meson: switch webdav option to auto feature

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

On Mon, Jan 07, 2019 at 12:00:44PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml|  1 -
>  meson.build   | 14 +-
>  meson_options.txt |  3 +--
>  3 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 5d4da85..e913da4 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -46,7 +46,6 @@ makecheck_simple-meson:
>script:
>- meson build -Dauto_features=disabled
>  -Dlz4=false
> --Dwebdav=false
>  -Dsasl=false
>  -Dpulse=false
>  -Dsmartcard=false
> diff --git a/meson.build b/meson.build
> index ebc846e..9bb56c3 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -141,11 +141,15 @@ endif
>  
>  # webdav
>  spice_gtk_has_phodav = false
> -if get_option('webdav')
> -  spice_glib_deps += dependency('libphodav-2.0')
> -  spice_glib_deps += dependency('libsoup-2.4', version : '>= 2.49.91')
> -  spice_gtk_config_data.set('USE_PHODAV', '1')
> -  spice_gtk_has_phodav = true
> +d = dependency('libphodav-2.0', required: get_option('webdav'))
> +if d.found()
> +  spice_glib_deps += d
> +  d = dependency('libsoup-2.4', version : '>= 2.49.91', required: 
> get_option('webdav'))
> +  if d.found()
> +spice_glib_deps += d
> +spice_gtk_config_data.set('USE_PHODAV', '1')
> +spice_gtk_has_phodav = true
> +  endif
>  endif
>  
>  # pulse
> diff --git a/meson_options.txt b/meson_options.txt
> index fc130dc..3f1da89 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -3,8 +3,7 @@ option('gtk',
>  description: 'Enable gtk+')
>  
>  option('webdav',
> -type : 'boolean',
> -value : true,
> +type : 'feature',
>  description: 'Enable webdav support')
>  
>  option('pulse',
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 13/34] .gitlab-ci: disable meson auto-features in makecheck_simple-meson

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:42PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Let's turn explicit true/false option into features which can be
> autodetected and turned all enabled/disabled at once.

Is this saying that after the following commits which will turn most of
the options into autodetected features, then we will be able to disable
everything at once using -Dauto_features=disabled?
The log is not very easy to parse :)

Reviewed-by: Christophe Fergeau 

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  .gitlab-ci.yml | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
> index 260d55d..5d4da85 100644
> --- a/.gitlab-ci.yml
> +++ b/.gitlab-ci.yml
> @@ -44,7 +44,8 @@ makecheck_simple:
>  
>  makecheck_simple-meson:
>script:
> -  - meson build -Dlz4=false
> +  - meson build -Dauto_features=disabled
> +-Dlz4=false
>  -Dwebdav=false
>  -Dsasl=false
>  -Dpulse=false
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 10/34] win-usb-dev: fix snprintf warnings

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 5:37 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:39PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > [1/14] Compiling C object 
> > 'src/25a6634@@spice-client-glib-2.0@sha/win-usb-dev.c.obj'.
> > ../src/win-usb-dev.c: In function 'get_usb_dev_info':
> > ../src/win-usb-dev.c:376:5: warning: implicit declaration of function 
> > 'snprintf' [-Wimplicit-function-declaration]
> >  snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> > udevinfo->class);
> >  ^~~~
> > ../src/win-usb-dev.c:376:5: warning: incompatible implicit declaration of 
> > built-in function 'snprintf'
> > ../src/win-usb-dev.c:376:5: note: include '' or provide a 
> > declaration of 'snprintf'
> > ../src/win-usb-dev.c:31:1:
> > +#include 
> >
> > ../src/win-usb-dev.c:376:5:
> >  snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> > udevinfo->class);
> >  ^~~~
>
> A bit unexpected as this is a fallout from the #include  ->
> #include  change, but regardless of that,
>
> Reviewed-by: Christophe Fergeau 

I see, I'll update commit message and order.
thanks

>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  src/win-usb-dev.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
> > index 9a130a3..327976d 100644
> > --- a/src/win-usb-dev.c
> > +++ b/src/win-usb-dev.c
> > @@ -373,11 +373,11 @@ static gboolean get_usb_dev_info(libusb_device *dev, 
> > GUdevDeviceInfo *udevinfo)
> >  udevinfo->class = desc.bDeviceClass;
> >  udevinfo->vid   = desc.idVendor;
> >  udevinfo->pid   = desc.idProduct;
> > -snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> > udevinfo->class);
> > -snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", 
> > udevinfo->bus);
> > -snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", 
> > udevinfo->addr);
> > -snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", 
> > udevinfo->vid);
> > -snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", 
> > udevinfo->pid);
> > +g_snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> > udevinfo->class);
> > +g_snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", 
> > udevinfo->bus);
> > +g_snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", 
> > udevinfo->addr);
> > +g_snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", 
> > udevinfo->vid);
> > +g_snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", 
> > udevinfo->pid);
> >  return TRUE;
> >  }
> >
> > --
> > 2.20.1.2.gb21ebb671b
> >
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Frediano Ziglio
> Hi
> 
> On Mon, Jan 7, 2019 at 3:44 PM Frediano Ziglio  wrote:
> >
> > > Hi
> > >
> > > On Sat, Jan 5, 2019 at 9:00 PM Frediano Ziglio 
> > > wrote:
> > > >
> > > > >
> > > > > Hi
> > > > >
> > > > > On Sat, Jan 5, 2019 at 1:59 PM Victor Toso 
> > > > > wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > On Fri, Jan 04, 2019 at 04:48:21PM +0400,
> > > > > > marcandre.lur...@redhat.com
> > > > > > wrote:
> > > > > > > From: Marc-André Lureau 
> > > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > The series drops support for optional GStreamer dependency. Spice
> > > > > > > increasingly require GStreamer for audio and video support.
> > > > > > > GStreamer
> > > > > > > is widely available, including in embedded space.
> > > > > >
> > > > > > I think this is fine indeed, not 100% sure if we shouldn't do a
> > > > > > last release without this first. Another question is about
> > > > >
> > > > > As long as we don't require a too recent GStreamer (only 1.0
> > > > > apparently, the rest is checked with GST_CHECK_VERSION), I think it
> > > > > should be fine.
> > > > >
> > > > > > pulseaudio backend. If gstreamer is always enabled, I don't see
> > > > > > why we need pulseaudio..
> > > > >
> > > > > Good point, I thought the the gst backend was inferior to the pulse
> > > > > backend wrt volume handling, but you pointed out in commit message
> > > > > 808ac1d9b3fd926f660231776d5c66946fda5664 that gst now implements it
> > > > > for various elements.
> > > > >
> > > > > And with pipewire plan to replace pulseaudio (and using the gstreamer
> > > > > elements), I think this is the path forward.
> > > > >
> > > >
> > > > Is pipewire stable and cross platform? From the website I cannot find
> > > > these
> > > > information. Before removing some support we should make sure we have a
> > > > good
> > > > replacement.
> > >
> > > There are several reasons I mentionned pipewire:
> > > - it uses the gstreamer audio elements, which means they have to be quite
> > > solid
> >
> > It's not true, plugins are written because is important to interact, it's
> > not a proof that one technology us solid, just that is used.
> 
> It has to be solid to be the core audio stack of Gnome & Fedora, and
> replace pulseaudio.
> 

It seems you are speaking of the future using a past tense. I opened
some programs under Fedora 29 and they are using pulseaudio or alsa.

> > > - spice-gtk audio should use pipewire, and GStreamer backend is a good
> > > to do that
> >
> > I don't understand what you mean here. Your patch is embedding gstreamer
> > as a requirement removing the possibility to switch multimedia framework
> > in the future (will require to undo part of your patches).
> > The current code allow multiple implementation, I would like to keep this
> > possibility. I'm not saying that we cannot require gstreamer, just that
> > should not became a design requirement.
> 
> spice-gtk should use pipewire when available, and the GStreamer
> backend is the way to to that.
> 

Agree, or any other framework suitable.

> There is no need to keep modularity if we have single backend.
> 

But as we already have it I don't see the reason to remove it.

> It is fairly easy to bring back modularity when we have it again.
> 

Yes, at the present, but I would like to keep it keeping the
modularity.

> >
> > >
> > > Don't get me wrong, pipewire is not going to be a spice-gtk dependency.
> > >
> >
> > Than what do you mean with "spice-gtk audio should use pipewire"?
> > If it should use pipewire through gstreamer should be up to gstreamer
> > to choose the best output.
> 
> yes
> 
> >
> > > >
> > > > Honestly I'm not really fun of needing GStreamer, if any platform have
> > > > a different streaming library I'd like to be able to use it, making
> > > > GStreamer a need is going the other direction.
> > >
> > > As long as we support only GStreamer for audio/video, I don't see the
> > > point in having a switch to disable it.
> > >
> >
> > Not saying to have a switch to disable, but is good to keep the
> > possibility to switch implementation in the future.
> 
> Again, it's really not that big of a deal. Let's not have unnecessary
> fake modularity for a potential future backend.
> 

I disagree. You are already talking about different backend.

> >
> > > >
> > > > > I'll work on a patch to remove pulse.
> > > > >
> > > >
> > > > It seems too soon.
> > >
> > > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > > The recording path at least fails very often for me due to a race:
> > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> > >
> > > After fixing the pulsesrc element, I added a check in spice-gtk for
> > > pulseaudio plugin version. I don't see what else I could do.
> > >
> >
> > We can keep pulseaudio support. We have to consider also the various
> > distro. RHEL 7, for instance is using gstreamer 1.10.
> 
> Yes, as discussed, we keep the pulse backend for a while and detect
> 

Re: [Spice-devel] [PATCH spice-gtk 08/34] build-sys: drop support for libcacard < 2.5.1

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 5:22 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 12:00:37PM +0400, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > v2.5.1 was released the 2015-11-24.
> >
> > According to repology, from the distro we care about, CentOS 6,
> > openSUSE Leap 42.3 have too old version (0.1.2).
> >
> > I didn't bother updating SPICE_CHECK_SMARTCARD, since spice-gtk is
> > probably the only user, and we are slowly dropping autoconf build-sys.
>
> spice-server is also using it, I'd prefer that we don't duplicate these
> checks again with different behaviours.
> Apart from this, looks good to me.
>
> Christophe

Ok, I'll break it in spice-common + spice-gtk updates then.

>
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  configure.ac| 18 +-
> >  meson.build | 18 ++
> >  src/channel-smartcard.c |  4 
> >  src/smartcard-manager.c |  6 --
> >  tools/spicy.c   |  4 
> >  5 files changed, 19 insertions(+), 31 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index a17af9c..70587ef 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -262,7 +262,23 @@ AC_SUBST(JPEG_LIBS)
> >  AC_CHECK_LIB(z, deflate, Z_LIBS='-lz', AC_MSG_ERROR([zlib not found]))
> >  AC_SUBST(Z_LIBS)
> >
> > -SPICE_CHECK_SMARTCARD
> > +AC_ARG_ENABLE([smartcard],
> > +  AS_HELP_STRING([--enable-smartcard=@<:@yes/no/auto@:>@],
> > + [Enable smartcard support @<:@default=auto@:>@]),
> > +  [],
> > +  [enable_smartcard="auto"])
> > +
> > +if test "x$enable_smartcard" = "xno"; then
> > +  have_smartcard=no
> > +else
> > +  PKG_CHECK_MODULES([SMARTCARD], [libcacard >= 2.5.1], 
> > [have_smartcard=yes], [have_smartcard=no])
> > +  if test "x$enable_smartcard" = "xyes" && test "x$have_smartcard" = 
> > "xno"; then
> > +AC_MSG_ERROR([smarcard support explicitly requested, but some required 
> > packages are not available])
> > +  fi
> > +  if test "x$have_smartcard" = "xyes"; then
> > +AC_DEFINE(USE_SMARTCARD, [1], [Define if supporting smartcard 
> > proxying])
> > +  fi
> > +fi
> >  AM_CONDITIONAL([WITH_SMARTCARD], [test "x$have_smartcard" = "xyes"])
> >
> >  AC_ARG_ENABLE([usbredir],
> > diff --git a/meson.build b/meson.build
> > index 13c1756..42c18f0 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -311,22 +311,8 @@ endif
> >  # smartcard check
> >  spice_gtk_has_smartcard = false
> >  if get_option('smartcard')
> > -  smartcard_dep = dependency('libcacard', required : false, version : '>= 
> > 2.5.1')
> > -  if smartcard_dep.found()
> > -spice_glib_deps += smartcard_dep
> > -spice_gtk_config_data.set('USE_SMARTCARD', '1')
> > -  else
> > -smartcard012_dep = dependency('libcacard', required : false, version : 
> > '>= 0.1.2')
> > -if smartcard012_dep.found()
> > -  spice_glib_deps += smartcard012_dep
> > -  spice_gtk_config_data.set('USE_SMARTCARD_012', '1')
> > -endif
> > -  endif
> > -
> > -  spice_gtk_has_smartcard = smartcard_dep.found() or 
> > smartcard012_dep.found()
> > -  if not spice_gtk_has_smartcard
> > -error('Building with smartcard support but dependency not found')
> > -  endif
> > +  spice_glib_deps += dependency('libcacard', version : '>= 2.5.1')
> > +  spice_gtk_config_data.set('USE_SMARTCARD', '1')
> >  endif
> >
> >  #
> > diff --git a/src/channel-smartcard.c b/src/channel-smartcard.c
> > index 6d0facd..aad5f8f 100644
> > --- a/src/channel-smartcard.c
> > +++ b/src/channel-smartcard.c
> > @@ -17,10 +17,6 @@
> >  */
> >  #include "config.h"
> >
> > -#ifdef USE_SMARTCARD_012
> > -#include 
> > -#endif
> > -
> >  #include "spice-client.h"
> >  #include "spice-common.h"
> >
> > diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> > index 9c94f95..ceecfdc 100644
> > --- a/src/smartcard-manager.c
> > +++ b/src/smartcard-manager.c
> > @@ -20,15 +20,9 @@
> >  #include 
> >  #include 
> >
> > -#ifdef USE_SMARTCARD_012
> > -#include 
> > -#include 
> > -#include 
> > -#else
> >  #ifdef USE_SMARTCARD
> >  #include 
> >  #endif
> > -#endif
> >
> >  #include "spice-client.h"
> >  #include "smartcard-manager.h"
> > diff --git a/tools/spicy.c b/tools/spicy.c
> > index 3dca3dc..06af15e 100644
> > --- a/tools/spicy.c
> > +++ b/tools/spicy.c
> > @@ -24,10 +24,6 @@
> >  #include 
> >  #endif
> >
> > -#ifdef USE_SMARTCARD_012
> > -#include 
> > -#endif
> > -
> >  #include "spice-widget.h"
> >  #include "spice-gtk-session.h"
> >  #include "spice-audio.h"
> > --
> > 2.20.1.2.gb21ebb671b
> >
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



-- 
Marc-André Lureau
___
Spice-devel 

Re: [Spice-devel] [PATCH spice-gtk 12/34] meson: fix mingw build

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:41PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Remove rt/x11/m dependencies from Windows build.

librt/libm dependencies are even removed from all builds as far as I can
tell? This does not seem to make a difference on the build though.

Reviewed-by: Christophe Fergeau 

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  meson.build | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 42c18f0..91d0742 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -103,7 +103,7 @@ foreach dep : deps
>spice_glib_deps += dependency(dep)
>  endforeach
>  
> -deps = ['librt', 'libm']
> +deps = []
>  if spice_gtk_host_system == 'windows'
>deps += ['libws2_32', 'libgdi32']
>  endif
> @@ -130,9 +130,9 @@ spice_gtk_has_gtk = false
>  gtk_version_required = '3.22'
>  if get_option('gtk')
>spice_gtk_deps += dependency('gtk+-3.0', version : '>= 
> @0@'.format(gtk_version_required))
> -  spice_gtk_deps += dependency('x11')
>if spice_gtk_host_system != 'windows'
>  spice_gtk_deps += dependency('epoxy')
> +spice_gtk_deps += dependency('x11')
>endif
>spice_gtk_has_gtk = true
>  endif
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 10/34] win-usb-dev: fix snprintf warnings

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:39PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> [1/14] Compiling C object 
> 'src/25a6634@@spice-client-glib-2.0@sha/win-usb-dev.c.obj'.
> ../src/win-usb-dev.c: In function 'get_usb_dev_info':
> ../src/win-usb-dev.c:376:5: warning: implicit declaration of function 
> 'snprintf' [-Wimplicit-function-declaration]
>  snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> udevinfo->class);
>  ^~~~
> ../src/win-usb-dev.c:376:5: warning: incompatible implicit declaration of 
> built-in function 'snprintf'
> ../src/win-usb-dev.c:376:5: note: include '' or provide a 
> declaration of 'snprintf'
> ../src/win-usb-dev.c:31:1:
> +#include 
> 
> ../src/win-usb-dev.c:376:5:
>  snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> udevinfo->class);
>  ^~~~

A bit unexpected as this is a fallout from the #include  ->
#include  change, but regardless of that,

Reviewed-by: Christophe Fergeau 

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/win-usb-dev.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
> index 9a130a3..327976d 100644
> --- a/src/win-usb-dev.c
> +++ b/src/win-usb-dev.c
> @@ -373,11 +373,11 @@ static gboolean get_usb_dev_info(libusb_device *dev, 
> GUdevDeviceInfo *udevinfo)
>  udevinfo->class = desc.bDeviceClass;
>  udevinfo->vid   = desc.idVendor;
>  udevinfo->pid   = desc.idProduct;
> -snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> udevinfo->class);
> -snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", 
> udevinfo->bus);
> -snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", 
> udevinfo->addr);
> -snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", 
> udevinfo->vid);
> -snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", 
> udevinfo->pid);
> +g_snprintf(udevinfo->sclass, sizeof(udevinfo->sclass), "%d", 
> udevinfo->class);
> +g_snprintf(udevinfo->sbus,   sizeof(udevinfo->sbus),   "%d", 
> udevinfo->bus);
> +g_snprintf(udevinfo->saddr,  sizeof(udevinfo->saddr),  "%d", 
> udevinfo->addr);
> +g_snprintf(udevinfo->svid,   sizeof(udevinfo->svid),   "%d", 
> udevinfo->vid);
> +g_snprintf(udevinfo->spid,   sizeof(udevinfo->spid),   "%d", 
> udevinfo->pid);
>  return TRUE;
>  }
>  
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 09/34] win-usb-dev: don't include gtk, but gio header

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:38PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Gtk+ shouldn't be used by spice-client-glib. GIO is enough.
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/win-usb-dev.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/win-usb-dev.h b/src/win-usb-dev.h
> index b5c4fce..7f40197 100644
> --- a/src/win-usb-dev.h
> +++ b/src/win-usb-dev.h
> @@ -22,7 +22,7 @@
>  #ifndef __WIN_USB_DEV_H__
>  #define __WIN_USB_DEV_H__
>  
> -#include 
> +#include 

The .h even only needs glib-object.h, it's the .c file which is going to
need gio/gio.h

Reviewed-by: Christophe Fergeau 

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-gtk] gtk-session: do not request guest's clipboard data unnecessarily

2019-01-07 Thread Victor Toso
Hi,

On Thu, Jan 03, 2019 at 09:57:40AM +0100, Jakub Janku wrote: > Hi,
> 
> 
> On Wed, Jan 2, 2019, 5:31 PM Victor Toso  
> > Hi,
> >
> > Thanks for taking a look!
> >
> > On Sun, Dec 30, 2018 at 10:23:02PM +0100, Jakub Janku wrote:
> > > Hi,
> > >
> > > On Wed, Dec 19, 2018 at 3:30 PM Victor Toso 
> > wrote:
> > > >
> > > > From: Victor Toso 
> > > >
> > > > If SpiceGtkSession is holding the keyboard, that's huge indication
> > > > that we should not be requesting clipboard data yet. The proper time
> > > > to request it is when another application in the client machine is
> > > > asking for it, which means the user would switch to another
> > > > application to paste the guest's clipboard data.
> > > >
> >
> > > I'm having a rather hard time understanding this commit message.
> > > I read it the following way:
> > > "spice-gtk should not request clipboard data from vdagent, while
> > > spice-gtk holds the keyboard focus"
> > > However, what the patch actually does is that it makes sure that
> > > spice-gtk doesn't send clipboard grab to vdagent, while spice-gtk
> > > holds the keyboard focus.
> > >
> > > These 2 things seem rather unrelated. What am I missing?
> >
> > Client request for grab will make agent to look into clipboard
> > data in the guest which would lead to VD_AGENT_CLIPBOARD_REQUEST
> > being sent from agent to client.
> 
> Exactly! So it's the agent requesting the CLIENT's data. But in
> the commit message, you state "do not request GUEST's clipboard
> data unnecessarily".  Or isn't it?

Sorry, I got confused while replying earlier. I hope it is better
on v2

https://lists.freedesktop.org/archives/spice-devel/2019-January/046857.html

> > I can reproduce the client requesting guest's clipboard data on
> > X11/KDE multiple times while the user is just copy-paste between
> > applications in the guest. The idea of this patch was to avoid
> > those requests till the keyboard focus is lost, which means that
> > user is trying to paste guest's clipboard data into another
> > application in the client's OS.
> >
> > Let me know if it isn't clear!
> >
> 
> Makes sense to me to try to avoid such requests. But why are
> those requests causing the issues described?

See:
https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6#note_85246

Problem is the possible race in the state of grab.

The situation that I see this happening is caused due too many
requests to clipboard data of the guest. One fix is to avoid
doing that; Another is to improve the checks on both, client and
agent.

As mentioned earlier, we should only allow a client->agent data
request if another application in the client is asking for it.

There is probably different ways to get into a bad state but this
patch (well, v2) helps the use cases I've been trying.

Cheers,

> > > Cheers,
> > > Jakub
> >
> > Thanks again,
> > Victor
> >
> >
> > > >
> > > > Signed-off-by: Victor Toso 
> > > > Tested-by: James Harvey @jamespharvey20
> > > > ---
> > > >  src/spice-gtk-session.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
> > > > index 1ccae07..0d3438c 100644
> > > > --- a/src/spice-gtk-session.c
> > > > +++ b/src/spice-gtk-session.c
> > > > @@ -645,9 +645,11 @@ static void clipboard_owner_change(GtkClipboard
> >   *clipboard,
> > > >  if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(self))
> > > >  break;
> > > >
> > > > +
> > > >  s->clipboard_by_guest[selection] = FALSE;
> > > >  s->clip_hasdata[selection] = TRUE;
> > > > -if (s->auto_clipboard_enable && !read_only(self))
> > > > +if (s->auto_clipboard_enable && !read_only(self) &&
> > > > +!spice_gtk_session_get_keyboard_has_focus(self))
> > > >  gtk_clipboard_request_targets(clipboard,
> > clipboard_get_targets,
> > > >get_weak_ref(self));
> > > >  break;
> > > > --
> > > > 2.19.2
> > > >
> > > > ___
> > > > Spice-devel mailing list
> > > > Spice-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/spice-devel
> >


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 08/34] build-sys: drop support for libcacard < 2.5.1

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:37PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> v2.5.1 was released the 2015-11-24.
> 
> According to repology, from the distro we care about, CentOS 6,
> openSUSE Leap 42.3 have too old version (0.1.2).
> 
> I didn't bother updating SPICE_CHECK_SMARTCARD, since spice-gtk is
> probably the only user, and we are slowly dropping autoconf build-sys.

spice-server is also using it, I'd prefer that we don't duplicate these
checks again with different behaviours.
Apart from this, looks good to me.

Christophe

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  configure.ac| 18 +-
>  meson.build | 18 ++
>  src/channel-smartcard.c |  4 
>  src/smartcard-manager.c |  6 --
>  tools/spicy.c   |  4 
>  5 files changed, 19 insertions(+), 31 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index a17af9c..70587ef 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -262,7 +262,23 @@ AC_SUBST(JPEG_LIBS)
>  AC_CHECK_LIB(z, deflate, Z_LIBS='-lz', AC_MSG_ERROR([zlib not found]))
>  AC_SUBST(Z_LIBS)
>  
> -SPICE_CHECK_SMARTCARD
> +AC_ARG_ENABLE([smartcard],
> +  AS_HELP_STRING([--enable-smartcard=@<:@yes/no/auto@:>@],
> + [Enable smartcard support @<:@default=auto@:>@]),
> +  [],
> +  [enable_smartcard="auto"])
> +
> +if test "x$enable_smartcard" = "xno"; then
> +  have_smartcard=no
> +else
> +  PKG_CHECK_MODULES([SMARTCARD], [libcacard >= 2.5.1], [have_smartcard=yes], 
> [have_smartcard=no])
> +  if test "x$enable_smartcard" = "xyes" && test "x$have_smartcard" = "xno"; 
> then
> +AC_MSG_ERROR([smarcard support explicitly requested, but some required 
> packages are not available])
> +  fi
> +  if test "x$have_smartcard" = "xyes"; then
> +AC_DEFINE(USE_SMARTCARD, [1], [Define if supporting smartcard proxying])
> +  fi
> +fi
>  AM_CONDITIONAL([WITH_SMARTCARD], [test "x$have_smartcard" = "xyes"])
>  
>  AC_ARG_ENABLE([usbredir],
> diff --git a/meson.build b/meson.build
> index 13c1756..42c18f0 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -311,22 +311,8 @@ endif
>  # smartcard check
>  spice_gtk_has_smartcard = false
>  if get_option('smartcard')
> -  smartcard_dep = dependency('libcacard', required : false, version : '>= 
> 2.5.1')
> -  if smartcard_dep.found()
> -spice_glib_deps += smartcard_dep
> -spice_gtk_config_data.set('USE_SMARTCARD', '1')
> -  else
> -smartcard012_dep = dependency('libcacard', required : false, version : 
> '>= 0.1.2')
> -if smartcard012_dep.found()
> -  spice_glib_deps += smartcard012_dep
> -  spice_gtk_config_data.set('USE_SMARTCARD_012', '1')
> -endif
> -  endif
> -
> -  spice_gtk_has_smartcard = smartcard_dep.found() or smartcard012_dep.found()
> -  if not spice_gtk_has_smartcard
> -error('Building with smartcard support but dependency not found')
> -  endif
> +  spice_glib_deps += dependency('libcacard', version : '>= 2.5.1')
> +  spice_gtk_config_data.set('USE_SMARTCARD', '1')
>  endif
>  
>  #
> diff --git a/src/channel-smartcard.c b/src/channel-smartcard.c
> index 6d0facd..aad5f8f 100644
> --- a/src/channel-smartcard.c
> +++ b/src/channel-smartcard.c
> @@ -17,10 +17,6 @@
>  */
>  #include "config.h"
>  
> -#ifdef USE_SMARTCARD_012
> -#include 
> -#endif
> -
>  #include "spice-client.h"
>  #include "spice-common.h"
>  
> diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> index 9c94f95..ceecfdc 100644
> --- a/src/smartcard-manager.c
> +++ b/src/smartcard-manager.c
> @@ -20,15 +20,9 @@
>  #include 
>  #include 
>  
> -#ifdef USE_SMARTCARD_012
> -#include 
> -#include 
> -#include 
> -#else
>  #ifdef USE_SMARTCARD
>  #include 
>  #endif
> -#endif
>  
>  #include "spice-client.h"
>  #include "smartcard-manager.h"
> diff --git a/tools/spicy.c b/tools/spicy.c
> index 3dca3dc..06af15e 100644
> --- a/tools/spicy.c
> +++ b/tools/spicy.c
> @@ -24,10 +24,6 @@
>  #include 
>  #endif
>  
> -#ifdef USE_SMARTCARD_012
> -#include 
> -#endif
> -
>  #include "spice-widget.h"
>  #include "spice-gtk-session.h"
>  #include "spice-audio.h"
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 06/34] build-sys: drop support for usbredir < 0.5

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:35PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> It was release the 2012-09-07, should be enough time.
> 
> According to repology, all tracked distros have 0.5:
> https://repology.org/metapackage/usbredir/versions
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  configure.ac | 15 ---
>  meson.build  |  9 ++---
>  2 files changed, 6 insertions(+), 18 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index e87f79e..be172d5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -274,17 +274,10 @@ AC_ARG_ENABLE([usbredir],
>  if test "x$enable_usbredir" = "xno"; then
>have_usbredir="no"
>  else
> -  if ${PKG_CONFIG} libusbredirparser-0.5; then
> -PKG_CHECK_MODULES([USBREDIR],
> -  [libusb-1.0 >= 1.0.9 libusbredirhost 
> libusbredirparser-0.5],
> -  [have_usbredir=yes],
> -  [have_usbredir=no])
> -  else
> -PKG_CHECK_MODULES([USBREDIR],
> -  [libusb-1.0 >= 1.0.9 libusbredirhost >= 0.4.2 
> libusbredirparser >= 0.4],
> -  [have_usbredir=yes],
> -  [have_usbredir=no])
> -  fi
> +  PKG_CHECK_MODULES([USBREDIR],
> +[libusb-1.0 >= 1.0.9 libusbredirhost 
> libusbredirparser-0.5],
> +[have_usbredir=yes],
> +[have_usbredir=no])
>if test "x$have_usbredir" = "xno" && test "x$enable_usbredir" = "xyes"; 
> then
>  AC_MSG_ERROR([usbredir support explicitly requested, but some required 
> packages are not available])
>fi
> diff --git a/meson.build b/meson.build
> index dc3e260..4a00b1c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -172,13 +172,8 @@ endif
>  # usbredir
>  spice_gtk_has_usbredir = false
>  if get_option('usbredir')
> -  usb_dep = dependency('libusbredirparser-0.5', required : false)
> -  if not usb_dep.found()
> -usb_dep = dependency('libusbredirparser', version : '>= 0.4')
> -  endif
> -  spice_glib_deps += usb_dep
> -
> -  deps = {'libusbredirhost' : '>= 0.4.2',
> +  deps = {'libusbredirparser-0.5': '>= 0.5',
> +  'libusbredirhost' : '>= 0.4.2',

if libusbredirparser >= 0.5 is present, libusbredirhost will also be 0.5
or newer, so you can either remove the version as in the autotools
version, or set it to 0.5

Reviewed-by: Christophe Fergeau 



signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 05/34] build-sys: fix gir/vapi warnings with GstPipeline

2019-01-07 Thread Christophe Fergeau

Reviewed-by: Christophe Fergeau 

though they depend on the patches making gstreamer a hard dep which are
still under discussion.

Christophe

On Mon, Jan 07, 2019 at 12:00:34PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Add required dependency on gstreamer to fix unresolved GstPipeline
> type warning:
> 
> :: Warning: SpiceClientGLib: (Signal)gst-video-overlay: argument 
> pipeline: Unresolved type: 'GstPipeline'
> 
> Signed-off-by: Marc-André Lureau 
> ---
>  src/Makefile.am | 2 +-
>  src/meson.build | 2 +-
>  vapi/Makefile.am| 2 ++
>  vapi/meson.build| 4 ++--
>  vapi/spice-client-glib-2.0.deps | 1 +
>  5 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index b50c426..abc2f69 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -540,7 +540,7 @@ gtk_introspection_files = \
>   $(NULL)
>  
>  SpiceClientGLib-2.0.gir: libspice-client-glib-2.0.la
> -SpiceClientGLib_2_0_gir_INCLUDES = GObject-2.0 Gio-2.0
> +SpiceClientGLib_2_0_gir_INCLUDES = GObject-2.0 Gio-2.0 GstBase-1.0
>  SpiceClientGLib_2_0_gir_CFLAGS = $(SPICE_COMMON_CPPFLAGS)
>  SpiceClientGLib_2_0_gir_LIBS = libspice-client-glib-2.0.la
>  SpiceClientGLib_2_0_gir_FILES = $(glib_introspection_files)
> diff --git a/src/meson.build b/src/meson.build
> index a6f79bb..0057dfc 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -208,7 +208,7 @@ spice_client_glib_gir = 
> gnome.generate_gir(spice_client_glib_lib,
> export_packages : 
> 'spice-client-glib-2.0',
> extra_args : 
> ['--accept-unprefixed'],
> header : 'spice-client.h',
> -   includes : ['GObject-2.0', 
> 'Gio-2.0'],
> +   includes : ['GObject-2.0', 
> 'Gio-2.0', 'GstBase-1.0'],
> identifier_prefix : 'Spice',
> include_directories: 
> spice_gtk_include,
> link_with : spice_client_glib_lib,
> diff --git a/vapi/Makefile.am b/vapi/Makefile.am
> index 494ad83..3c6234d 100644
> --- a/vapi/Makefile.am
> +++ b/vapi/Makefile.am
> @@ -27,6 +27,7 @@ spice-client-glib-2.0.vapi: 
> $(top_builddir)/src/SpiceClientGLib-2.0.gir SpiceCli
>   --metadatadir=$(srcdir) \
>   --library spice-client-glib-2.0 \
>   --pkg gio-2.0   \
> + --pkg gstreamer-1.0 \
>   $<
>  
>  spice-client-gtk-3.0.vapi: $(top_builddir)/src/SpiceClientGtk-3.0.gir 
> spice-client-glib-2.0.vapi
> @@ -34,6 +35,7 @@ spice-client-gtk-3.0.vapi: 
> $(top_builddir)/src/SpiceClientGtk-3.0.gir spice-clie
>   --vapidir=$(builddir)   \
>   --girdir=$(top_builddir)/src\
>   --pkg spice-client-glib-2.0 \
> + --pkg gstreamer-1.0 \
>   --pkg gtk+-3.0  \
>   --library spice-client-gtk-3.0  \
>   $<
> diff --git a/vapi/meson.build b/vapi/meson.build
> index de9adb9..2c4caa0 100644
> --- a/vapi/meson.build
> +++ b/vapi/meson.build
> @@ -1,12 +1,12 @@
>  if spice_gtk_has_vala
>gnome.generate_vapi('spice-client-glib-2.0',
>install : true,
> -  packages : 'gio-2.0',
> +  packages : ['gio-2.0', 'gstreamer-1.0'],
>sources : spice_client_glib_gir[0])
>if spice_gtk_has_gtk
>  gnome.generate_vapi('spice-client-gtk-3.0',
>  install : true,
> -packages : ['gtk+-3.0', 'spice-client-glib-2.0'],
> +packages : ['gtk+-3.0', 'gstreamer-1.0', 
> 'spice-client-glib-2.0'],
>  gir_dirs : join_paths(meson.build_root(), 'src'),
>  vapi_dirs : meson.current_build_dir(),
>  sources : spice_client_gtk_gir[0])
> diff --git a/vapi/spice-client-glib-2.0.deps b/vapi/spice-client-glib-2.0.deps
> index cd10dfd..64e63d2 100644
> --- a/vapi/spice-client-glib-2.0.deps
> +++ b/vapi/spice-client-glib-2.0.deps
> @@ -1 +1,2 @@
>  gio-2.0
> +gstreamer-1.0
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 01/34] build-sys: remove autoconf --with-audio=..

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 12:00:30PM +0400, marcandre.lur...@redhat.com wrote:
> From: Marc-André Lureau 
> 
> Deprecated for several releases now (v0.31).

Ok, though it does not hurt either as it's going to be dropped when
autotools is dropped.

Reviewed-by: Christophe Fergeau 

> 
> Signed-off-by: Marc-André Lureau 
> ---
>  configure.ac | 10 --
>  1 file changed, 10 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 69c03da..ff5114e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -195,16 +195,6 @@ AS_IF([test "x$have_phodav" = "xyes"],
>  
>  AM_CONDITIONAL([WITH_PHODAV], [test "x$have_phodav" = "xyes"])
>  
> -AC_ARG_WITH([audio],
> -  AS_HELP_STRING([--with-audio=@<:@gstreamer/pulse/auto/no@:>@], [For legacy 
> compatibility only]),
> -  [SPICE_WARNING([--with-audio is deprecated. Use --enable-pulse and/or 
> --enable-gstaudio instead])
> -   case "$with_audio" in
> -   pulse) enable_pulse="yes"; enable_gstaudio="no" ;;
> -   gstreamer) enable_pulse="no";  enable_gstaudio="yes" ;;
> -   no)enable_pulse="no";  enable_gstaudio="no" ;;
> -   esac
> -])
> -
>  AC_ARG_ENABLE([pulse],
>AS_HELP_STRING([--enable-pulse=@<:@yes/auto/no@:>@], [Enable the 
> PulseAudio backend @<:@default=auto@:>@]),
>[],
> -- 
> 2.20.1.2.gb21ebb671b
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 32/34] gst: check pulseaudio plugin version >= 1.15

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 1:11 PM Snir Sheriber  wrote:
>
> Hi,
>
>
> On 1/7/19 10:01 AM, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > There is a racy bug in pulsesrc that we can't easily workaround:
> > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> >
> > It will hopefully be fixed with 1.15.
> >
> > In theory, pulseaudio may not be picked by autoaudiosink, but looking
> > up the actual sink or mimicking GstAutoDetect is unnecessarily complicated.
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >   src/spice-gstaudio.c | 19 +++
> >   1 file changed, 19 insertions(+)
> >
> > diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
> > index d0cfbc6..d7bfc97 100644
> > --- a/src/spice-gstaudio.c
> > +++ b/src/spice-gstaudio.c
> > @@ -527,7 +527,26 @@ SpiceGstaudio *spice_gstaudio_new(SpiceSession 
> > *session, GMainContext *context,
> > const char *name)
> >   {
> >   GError *err = NULL;
> > +
> >   if (gst_init_check(NULL, NULL, )) {
> > +GstPlugin *plugin;
> > +
> > +plugin = gst_registry_find_plugin(gst_registry_get(), 
> > "pulseaudio");
> > +if (plugin) {
> > +unsigned maj, min;
> > +if (sscanf(gst_plugin_get_version(plugin), "%u.%u", , 
> > ) != 2) {
> > +g_warn_if_reached();
> > +gst_object_unref(plugin);
> > +return NULL;
> > +}
> > +
> > +gst_object_unref(plugin);
> > +if (maj < 1 || min < 15) {
> > +g_warning("Disabling GStreamer audio: bad pulseaudio 
> > plugin version");
> > +return NULL;
> > +}
> > +}
>
>
> You can avoid using the plugin by changing its rank (as we did with
> vaapisink in channel-display-gst.c)

That's an interesting idea, we could make the alsa backend higher
priority than the pulse one with <1.15.

>
> Snir.
>
>
> > +
> >   return g_object_new(SPICE_TYPE_GSTAUDIO,
> >   "session", session,
> >   "main-context", context,
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 30/34] gstaudio: set state to NULL before unref

2019-01-07 Thread Marc-André Lureau
On Mon, Jan 7, 2019 at 1:06 PM Snir Sheriber  wrote:
>
> Hi,
>
> On 1/7/19 10:00 AM, marcandre.lur...@redhat.com wrote:
> > From: Marc-André Lureau 
> >
> > (lt-spicy:13097): GStreamer-CRITICAL **: 18:01:13.698:
> > Trying to dispose element pipeline1, but it is in READY instead of the NULL 
> > state.
> > You need to explicitly set elements to the NULL state before
> > dropping the final reference, to allow them to clean up.
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >   src/spice-gstaudio.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
> > index aff69d2..d0cfbc6 100644
> > --- a/src/spice-gstaudio.c
> > +++ b/src/spice-gstaudio.c
> > @@ -191,7 +191,7 @@ static void record_start(SpiceRecordChannel *channel, 
> > gint format, gint channels
> >   if (p->record.pipe &&
> >   (p->record.rate != frequency ||
> >p->record.channels != channels)) {
> > -record_stop(gstaudio);
> > +gst_element_set_state(p->record.pipe, GST_STATE_NULL);
>
>
> I'm not sure, but wouldn't be better to do it in record_stop? or stop
> means pause here?
>

Yes, record_stop is pause. We keep the pipeline around, to avoid
having to recreate it on spice play/stop messages.

>
> Snir.
>
>
> >   g_clear_pointer(>record.pipe, gst_object_unref);
> >   }
> >
>
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 3:44 PM Frediano Ziglio  wrote:
>
> > Hi
> >
> > On Sat, Jan 5, 2019 at 9:00 PM Frediano Ziglio  wrote:
> > >
> > > >
> > > > Hi
> > > >
> > > > On Sat, Jan 5, 2019 at 1:59 PM Victor Toso  
> > > > wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > On Fri, Jan 04, 2019 at 04:48:21PM +0400, marcandre.lur...@redhat.com
> > > > > wrote:
> > > > > > From: Marc-André Lureau 
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > The series drops support for optional GStreamer dependency. Spice
> > > > > > increasingly require GStreamer for audio and video support. 
> > > > > > GStreamer
> > > > > > is widely available, including in embedded space.
> > > > >
> > > > > I think this is fine indeed, not 100% sure if we shouldn't do a
> > > > > last release without this first. Another question is about
> > > >
> > > > As long as we don't require a too recent GStreamer (only 1.0
> > > > apparently, the rest is checked with GST_CHECK_VERSION), I think it
> > > > should be fine.
> > > >
> > > > > pulseaudio backend. If gstreamer is always enabled, I don't see
> > > > > why we need pulseaudio..
> > > >
> > > > Good point, I thought the the gst backend was inferior to the pulse
> > > > backend wrt volume handling, but you pointed out in commit message
> > > > 808ac1d9b3fd926f660231776d5c66946fda5664 that gst now implements it
> > > > for various elements.
> > > >
> > > > And with pipewire plan to replace pulseaudio (and using the gstreamer
> > > > elements), I think this is the path forward.
> > > >
> > >
> > > Is pipewire stable and cross platform? From the website I cannot find 
> > > these
> > > information. Before removing some support we should make sure we have a
> > > good
> > > replacement.
> >
> > There are several reasons I mentionned pipewire:
> > - it uses the gstreamer audio elements, which means they have to be quite
> > solid
>
> It's not true, plugins are written because is important to interact, it's
> not a proof that one technology us solid, just that is used.

It has to be solid to be the core audio stack of Gnome & Fedora, and
replace pulseaudio.

> > - spice-gtk audio should use pipewire, and GStreamer backend is a good
> > to do that
>
> I don't understand what you mean here. Your patch is embedding gstreamer
> as a requirement removing the possibility to switch multimedia framework
> in the future (will require to undo part of your patches).
> The current code allow multiple implementation, I would like to keep this
> possibility. I'm not saying that we cannot require gstreamer, just that
> should not became a design requirement.

spice-gtk should use pipewire when available, and the GStreamer
backend is the way to to that.

There is no need to keep modularity if we have single backend.

It is fairly easy to bring back modularity when we have it again.

>
> >
> > Don't get me wrong, pipewire is not going to be a spice-gtk dependency.
> >
>
> Than what do you mean with "spice-gtk audio should use pipewire"?
> If it should use pipewire through gstreamer should be up to gstreamer
> to choose the best output.

yes

>
> > >
> > > Honestly I'm not really fun of needing GStreamer, if any platform have
> > > a different streaming library I'd like to be able to use it, making
> > > GStreamer a need is going the other direction.
> >
> > As long as we support only GStreamer for audio/video, I don't see the
> > point in having a switch to disable it.
> >
>
> Not saying to have a switch to disable, but is good to keep the
> possibility to switch implementation in the future.

Again, it's really not that big of a deal. Let's not have unnecessary
fake modularity for a potential future backend.

>
> > >
> > > > I'll work on a patch to remove pulse.
> > > >
> > >
> > > It seems too soon.
> >
> > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > The recording path at least fails very often for me due to a race:
> > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> >
> > After fixing the pulsesrc element, I added a check in spice-gtk for
> > pulseaudio plugin version. I don't see what else I could do.
> >
>
> We can keep pulseaudio support. We have to consider also the various
> distro. RHEL 7, for instance is using gstreamer 1.10.

Yes, as discussed, we keep the pulse backend for a while and detect
broken GStreamer.

>
> > I propose to make GStreamer audio backend the default, and deprecate
> > the pulse backend.
> >
>
> "I'll work on a patch to remove pulse" is not deprecating, is removing it.
>
> > If the gst pulseaudio plugin is too old (<1.15), then fallback on
> > spice-gtk pulse backend for now.
> >
>
> So it's not clear if you want to remove or not.

In the future, yes! For now, use GStreamer by default if possible, and
fallback on pulse.

See also proposed implementation:
"[PATCH spice-gtk 32/34] gst: check pulseaudio plugin version >= 1.15"
"[PATCH spice-gtk 33/34] audio: use gstreamer by default"


>
> > >
> > > > >
> > > > > 

[Spice-devel] [spice-gtk v2] gtk-session: do not request guest's clipboard data unnecessarily

2019-01-07 Thread Victor Toso
From: Victor Toso 

If SpiceGtkSession is holding the keyboard, that's huge indication
that the client should not be requesting guest's clipboard data yet.

This patch adds a check in clipboard_get() callback, to avoid such
requests. In Linux, this only happens with X11 backend.

This patch helps to handle a possible state race between who owns the
grab between client and agent which could lead to agent clipboard
failing or getting stuck, see:

Linux guest:
https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9

Windows guest:
https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6

The way to reproduce the race might depend on guest system and
applications but it is connected to amount of VDAGENTD_CLIPBOARD_GRAB
sent by the agent which depends on the amount of clipboard changes in
the guest. Simple example is on RHEL 6.10, with Gedit, select a text
char by char; Client receives VDAGENTD_CLIPBOARD_GRAB every time a new
char is selected instead of once when the full message is selected.

v1 -> v2:
* Moved the check to the right place, otherwise the patch would not
  work on Wayland (Christophe, Jakub)
* Improve commit log (Jakub)

Related: https://gitlab.freedesktop.org/spice/win32/vd_agent/issues/6
Related: https://gitlab.freedesktop.org/spice/linux/vd_agent/issues/9
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1594876

Signed-off-by: Victor Toso 
---
 src/spice-gtk-session.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 1ccae07..a78f619 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -59,6 +59,7 @@ struct _SpiceGtkSessionPrivate {
 gbooleanclip_hasdata[CLIPBOARD_LAST];
 gbooleanclip_grabbed[CLIPBOARD_LAST];
 gbooleanclipboard_by_guest[CLIPBOARD_LAST];
+gbooleanclipboard_by_guest_released[CLIPBOARD_LAST];
 /* auto-usbredir related */
 gbooleanauto_usbredir_enable;
 int auto_usbredir_reqs;
@@ -634,6 +635,12 @@ static void clipboard_owner_change(GtkClipboard
*clipboard,
 if (s->main == NULL)
 return;
 
+if (s->clipboard_by_guest_released[selection]) {
+/* Ignore owner-change event if this is just about agent releasing 
grab */
+s->clipboard_by_guest_released[selection] = FALSE;
+return;
+}
+
 if (s->clip_grabbed[selection]) {
 s->clip_grabbed[selection] = FALSE;
 if (spice_main_channel_agent_test_capability(s->main, 
VD_AGENT_CAP_CLIPBOARD_BY_DEMAND))
@@ -728,6 +735,14 @@ static void clipboard_get(GtkClipboard *clipboard,
 g_return_if_fail(info < SPICE_N_ELEMENTS(atom2agent));
 g_return_if_fail(s->main != NULL);
 
+/* No real need to set clipboard data while no client application will
+ * be requested. This is useful for clients on X11 as in Wayland, this
+ * callback is only called when SpiceGtkSession:keyboard-focus is false */
+if (spice_gtk_session_get_keyboard_has_focus(self)) {
+SPICE_DEBUG("Do not request clipboard data while holding the keyboard 
focus");
+return;
+}
+
 ri.selection_data = selection_data;
 ri.info = info;
 ri.loop = g_main_loop_new(NULL, FALSE);
@@ -769,6 +784,15 @@ cleanup:
 
 static void clipboard_clear(GtkClipboard *clipboard, gpointer user_data)
 {
+SpiceGtkSession *self = user_data;
+SpiceGtkSessionPrivate *s = self->priv;
+gint selection = get_selection_from_clipboard(s, clipboard);
+
+g_return_if_fail(selection != -1);
+
+if (s->clipboard_by_guest_released[selection])
+return;
+
 SPICE_DEBUG("clipboard_clear");
 /* We watch for clipboard ownership changes and act on those, so we
don't need to do anything here */
@@ -1035,6 +1059,8 @@ static void clipboard_release(SpiceMainChannel *main, 
guint selection,
 
 if (!s->clipboard_by_guest[selection])
 return;
+
+s->clipboard_by_guest_released[selection] = TRUE;
 gtk_clipboard_clear(clipboard);
 s->clipboard_by_guest[selection] = FALSE;
 }
-- 
2.20.1

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


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 03:12:45PM +0400, Marc-André Lureau wrote:
> g_warning or g_debug, not a big difference to me here.
> 
> But g_debug() is likely to be missed, since it is silent by default.

Yes, and being silent for now is the goal since the vast majority of
systems will be hitting that fallback path, having a runtime warning for
something which is expected and harmless for now is not worth it, I'm
sure we'll be getting a few questions about it.

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-server 00/33] Port SPICE server to Windows

2019-01-07 Thread Frediano Ziglio
Can be used with Qemu on Windows or to implement software like Xspice on
Windows.
Requires a really small path for Qemu (just remove a "#include "
line).

Frediano

> 
> Can you explain the end goal here?
> 
> On Fri, 2018-12-21 at 12:02 +, Frediano Ziglio wrote:
> > Mainly SPICE server uses lot of libraries to expose a TCP protocol.
> > As TCP is implemented with socket library which is quite portable was
> > not that hard to port.
> > Beside some minor feature (see REAME.Windows) all was ported.
> > During porting was choosen to keep Unix as the main platform, if a
> > change would require too much changes some Windows wrapper is
> > preferred instead. Not too complicated stuff, the main "wrapper" is
> > that Windows errors from socket are written back into errno to avoid
> > to change lot of code handling errors.
> > 
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Frediano Ziglio
> Hi
> 
> On Sat, Jan 5, 2019 at 9:00 PM Frediano Ziglio  wrote:
> >
> > >
> > > Hi
> > >
> > > On Sat, Jan 5, 2019 at 1:59 PM Victor Toso  wrote:
> > > >
> > > > Hi,
> > > >
> > > > On Fri, Jan 04, 2019 at 04:48:21PM +0400, marcandre.lur...@redhat.com
> > > > wrote:
> > > > > From: Marc-André Lureau 
> > > > >
> > > > > Hi,
> > > > >
> > > > > The series drops support for optional GStreamer dependency. Spice
> > > > > increasingly require GStreamer for audio and video support. GStreamer
> > > > > is widely available, including in embedded space.
> > > >
> > > > I think this is fine indeed, not 100% sure if we shouldn't do a
> > > > last release without this first. Another question is about
> > >
> > > As long as we don't require a too recent GStreamer (only 1.0
> > > apparently, the rest is checked with GST_CHECK_VERSION), I think it
> > > should be fine.
> > >
> > > > pulseaudio backend. If gstreamer is always enabled, I don't see
> > > > why we need pulseaudio..
> > >
> > > Good point, I thought the the gst backend was inferior to the pulse
> > > backend wrt volume handling, but you pointed out in commit message
> > > 808ac1d9b3fd926f660231776d5c66946fda5664 that gst now implements it
> > > for various elements.
> > >
> > > And with pipewire plan to replace pulseaudio (and using the gstreamer
> > > elements), I think this is the path forward.
> > >
> >
> > Is pipewire stable and cross platform? From the website I cannot find these
> > information. Before removing some support we should make sure we have a
> > good
> > replacement.
> 
> There are several reasons I mentionned pipewire:
> - it uses the gstreamer audio elements, which means they have to be quite
> solid

It's not true, plugins are written because is important to interact, it's
not a proof that one technology us solid, just that is used.

> - spice-gtk audio should use pipewire, and GStreamer backend is a good
> to do that

I don't understand what you mean here. Your patch is embedding gstreamer
as a requirement removing the possibility to switch multimedia framework
in the future (will require to undo part of your patches).
The current code allow multiple implementation, I would like to keep this
possibility. I'm not saying that we cannot require gstreamer, just that
should not became a design requirement.

> 
> Don't get me wrong, pipewire is not going to be a spice-gtk dependency.
> 

Than what do you mean with "spice-gtk audio should use pipewire"?
If it should use pipewire through gstreamer should be up to gstreamer
to choose the best output.

> >
> > Honestly I'm not really fun of needing GStreamer, if any platform have
> > a different streaming library I'd like to be able to use it, making
> > GStreamer a need is going the other direction.
> 
> As long as we support only GStreamer for audio/video, I don't see the
> point in having a switch to disable it.
> 

Not saying to have a switch to disable, but is good to keep the
possibility to switch implementation in the future.

> >
> > > I'll work on a patch to remove pulse.
> > >
> >
> > It seems too soon.
> 
> yes, we haven't done enough testing of the gstreamer backend on Linux.
> The recording path at least fails very often for me due to a race:
> https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> 
> After fixing the pulsesrc element, I added a check in spice-gtk for
> pulseaudio plugin version. I don't see what else I could do.
> 

We can keep pulseaudio support. We have to consider also the various
distro. RHEL 7, for instance is using gstreamer 1.10.

> I propose to make GStreamer audio backend the default, and deprecate
> the pulse backend.
> 

"I'll work on a patch to remove pulse" is not deprecating, is removing it.

> If the gst pulseaudio plugin is too old (<1.15), then fallback on
> spice-gtk pulse backend for now.
> 

So it's not clear if you want to remove or not.

> >
> > > >
> > > > Thanks,
> > > >
> > > > > Marc-André Lureau (5):
> > > > >   build-sys: remove autoconf --with-audio=..
> > > > >   build-sys: drop gstaudio option, make GStreamer a requirement
> > > > >   build-sys: drop gstvideo option, make it required
> > > > >   widget: gst_size_allocate() is static
> > > > >   build-sys: fix gir/vapi warnings with GstPipeline
> > > > >
> > > > >  .gitlab-ci.yml  |  4 --
> > > > >  configure.ac| 85
> > > > >  ++---
> > > > >  meson.build | 33 ++---
> > > > >  meson_options.txt   | 10 
> > > > >  src/Makefile.am | 18 ++-
> > > > >  src/channel-display-priv.h  | 10 +---
> > > > >  src/channel-display.c   |  7 ---
> > > > >  src/meson.build | 14 ++
> > > > >  src/spice-audio.c   |  4 --
> > > > >  src/spice-widget-priv.h |  4 --
> > > > >  src/spice-widget.c  | 14 ++
> > > > >  tools/spicy.c   |  8 
> > > > >  vapi/Makefile.am  

[Spice-devel] Spice Protocol changes

2019-01-07 Thread ucontacti ss
Dear developers,

While I was looking in the packets using Wireshark I saw that the Major and
Minor version is 2 and not 1 anymore. And there are some discrepancies in
the Spice protocol v1.0 and the actual value of fields. Has the protocol
been updated in any way? If yes, where can I find the changelogs and
documentation?

Best wishes,
Saleh Daghigh
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 2:50 PM Christophe Fergeau  wrote:
>
> On Mon, Jan 07, 2019 at 02:12:34PM +0400, Marc-André Lureau wrote:
> > Hi
> >
> > On Mon, Jan 7, 2019 at 2:03 PM Christophe Fergeau  
> > wrote:
> > >
> > > On Sun, Jan 06, 2019 at 12:24:33AM +0400, Marc-André Lureau wrote:
> > > > >
> > > > > > I'll work on a patch to remove pulse.
> > > > > >
> > > > >
> > > > > It seems too soon.
> > > >
> > > > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > > > The recording path at least fails very often for me due to a race:
> > > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> > > >
> > > > After fixing the pulsesrc element, I added a check in spice-gtk for
> > > > pulseaudio plugin version. I don't see what else I could do.
> > > >
> > > > I propose to make GStreamer audio backend the default, and deprecate
> > > > the pulse backend.
> > > >
> > > > If the gst pulseaudio plugin is too old (<1.15), then fallback on
> > > > spice-gtk pulse backend for now.
> > >
> > > In other words, all systems using a stable release of gstreamer (latest
> > > is 1.14.4) will be falling back to the pulse backend for now, but we'll
> > > still pretend the pulse backend is deprecated and should not be used.
> > > And even if distros patch their 1.14 pulsesrc, we won't detect it and
> > > still fallback. In my opinion, it's unfortunately too early to be too
> > > that pushy on the switch, at least with respect to deprecation warnings.
> >
> > If we don't expose it as default, it will be hard to find problems
> > though. The pulsesrc bug is present since 2011-11-24..
>
> Yeah, I'm only questioning how verbose we should be when gstreamer is
> not used. Iirc the patch detecting if pulsesrc is too old outputs a
> g_warning if it is, there's a patch adding a warning if
> --with-pulseaudio is used, ... Imo at least the first one should only be
> a g_debug() for now.

g_warning or g_debug, not a big difference to me here.

But g_debug() is likely to be missed, since it is silent by default.

For the build-time warning, I think it is fair since it is mostly on
the packager side, and they should prepare themself and update
gstreamer.

The gst fix is queued for 1.14.5 now. I will update the patch checking
the version, and update the build warning to mention runtime
"requirement" of gstreamer 1.14.5


>
> Christophe
>
> >
> > Otoh, it's not such a bad bug either & the GStreamer backend works
> > fine on Windows for a long time.
> >
> > The GStreamer fix should be backported to -stable releases. I'll
> > discuss this with upstream GStreamer.
> >
> > --
> > Marc-André Lureau
> > ___
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel



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


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Christophe Fergeau
On Mon, Jan 07, 2019 at 02:12:34PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Mon, Jan 7, 2019 at 2:03 PM Christophe Fergeau  wrote:
> >
> > On Sun, Jan 06, 2019 at 12:24:33AM +0400, Marc-André Lureau wrote:
> > > >
> > > > > I'll work on a patch to remove pulse.
> > > > >
> > > >
> > > > It seems too soon.
> > >
> > > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > > The recording path at least fails very often for me due to a race:
> > > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> > >
> > > After fixing the pulsesrc element, I added a check in spice-gtk for
> > > pulseaudio plugin version. I don't see what else I could do.
> > >
> > > I propose to make GStreamer audio backend the default, and deprecate
> > > the pulse backend.
> > >
> > > If the gst pulseaudio plugin is too old (<1.15), then fallback on
> > > spice-gtk pulse backend for now.
> >
> > In other words, all systems using a stable release of gstreamer (latest
> > is 1.14.4) will be falling back to the pulse backend for now, but we'll
> > still pretend the pulse backend is deprecated and should not be used.
> > And even if distros patch their 1.14 pulsesrc, we won't detect it and
> > still fallback. In my opinion, it's unfortunately too early to be too
> > that pushy on the switch, at least with respect to deprecation warnings.
> 
> If we don't expose it as default, it will be hard to find problems
> though. The pulsesrc bug is present since 2011-11-24..

Yeah, I'm only questioning how verbose we should be when gstreamer is
not used. Iirc the patch detecting if pulsesrc is too old outputs a
g_warning if it is, there's a patch adding a warning if
--with-pulseaudio is used, ... Imo at least the first one should only be
a g_debug() for now.

Christophe

> 
> Otoh, it's not such a bad bug either & the GStreamer backend works
> fine on Windows for a long time.
> 
> The GStreamer fix should be backported to -stable releases. I'll
> discuss this with upstream GStreamer.
> 
> -- 
> Marc-André Lureau
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Marc-André Lureau
Hi

On Mon, Jan 7, 2019 at 2:03 PM Christophe Fergeau  wrote:
>
> On Sun, Jan 06, 2019 at 12:24:33AM +0400, Marc-André Lureau wrote:
> > >
> > > > I'll work on a patch to remove pulse.
> > > >
> > >
> > > It seems too soon.
> >
> > yes, we haven't done enough testing of the gstreamer backend on Linux.
> > The recording path at least fails very often for me due to a race:
> > https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> >
> > After fixing the pulsesrc element, I added a check in spice-gtk for
> > pulseaudio plugin version. I don't see what else I could do.
> >
> > I propose to make GStreamer audio backend the default, and deprecate
> > the pulse backend.
> >
> > If the gst pulseaudio plugin is too old (<1.15), then fallback on
> > spice-gtk pulse backend for now.
>
> In other words, all systems using a stable release of gstreamer (latest
> is 1.14.4) will be falling back to the pulse backend for now, but we'll
> still pretend the pulse backend is deprecated and should not be used.
> And even if distros patch their 1.14 pulsesrc, we won't detect it and
> still fallback. In my opinion, it's unfortunately too early to be too
> that pushy on the switch, at least with respect to deprecation warnings.

If we don't expose it as default, it will be hard to find problems
though. The pulsesrc bug is present since 2011-11-24..

Otoh, it's not such a bad bug either & the GStreamer backend works
fine on Windows for a long time.

The GStreamer fix should be backported to -stable releases. I'll
discuss this with upstream GStreamer.

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


Re: [Spice-devel] [PATCH spice-gtk 0/5] Require GStreamer, fix build warnings

2019-01-07 Thread Christophe Fergeau
On Sun, Jan 06, 2019 at 12:24:33AM +0400, Marc-André Lureau wrote:
> >
> > > I'll work on a patch to remove pulse.
> > >
> >
> > It seems too soon.
> 
> yes, we haven't done enough testing of the gstreamer backend on Linux.
> The recording path at least fails very often for me due to a race:
> https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69
> 
> After fixing the pulsesrc element, I added a check in spice-gtk for
> pulseaudio plugin version. I don't see what else I could do.
> 
> I propose to make GStreamer audio backend the default, and deprecate
> the pulse backend.
> 
> If the gst pulseaudio plugin is too old (<1.15), then fallback on
> spice-gtk pulse backend for now.

In other words, all systems using a stable release of gstreamer (latest
is 1.14.4) will be falling back to the pulse backend for now, but we'll
still pretend the pulse backend is deprecated and should not be used.
And even if distros patch their 1.14 pulsesrc, we won't detect it and
still fallback. In my opinion, it's unfortunately too early to be too
that pushy on the switch, at least with respect to deprecation warnings.

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [PATCH spice-gtk 32/34] gst: check pulseaudio plugin version >= 1.15

2019-01-07 Thread Snir Sheriber

Hi,


On 1/7/19 10:01 AM, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

There is a racy bug in pulsesrc that we can't easily workaround:
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/merge_requests/69

It will hopefully be fixed with 1.15.

In theory, pulseaudio may not be picked by autoaudiosink, but looking
up the actual sink or mimicking GstAutoDetect is unnecessarily complicated.

Signed-off-by: Marc-André Lureau 
---
  src/spice-gstaudio.c | 19 +++
  1 file changed, 19 insertions(+)

diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index d0cfbc6..d7bfc97 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -527,7 +527,26 @@ SpiceGstaudio *spice_gstaudio_new(SpiceSession *session, 
GMainContext *context,
const char *name)
  {
  GError *err = NULL;
+
  if (gst_init_check(NULL, NULL, )) {
+GstPlugin *plugin;
+
+plugin = gst_registry_find_plugin(gst_registry_get(), "pulseaudio");
+if (plugin) {
+unsigned maj, min;
+if (sscanf(gst_plugin_get_version(plugin), "%u.%u", , ) != 
2) {
+g_warn_if_reached();
+gst_object_unref(plugin);
+return NULL;
+}
+
+gst_object_unref(plugin);
+if (maj < 1 || min < 15) {
+g_warning("Disabling GStreamer audio: bad pulseaudio plugin 
version");
+return NULL;
+}
+}



You can avoid using the plugin by changing its rank (as we did with 
vaapisink in channel-display-gst.c)


Snir.



+
  return g_object_new(SPICE_TYPE_GSTAUDIO,
  "session", session,
  "main-context", context,

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


Re: [Spice-devel] [PATCH spice-gtk 30/34] gstaudio: set state to NULL before unref

2019-01-07 Thread Snir Sheriber

Hi,

On 1/7/19 10:00 AM, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

(lt-spicy:13097): GStreamer-CRITICAL **: 18:01:13.698:
Trying to dispose element pipeline1, but it is in READY instead of the NULL 
state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.

Signed-off-by: Marc-André Lureau 
---
  src/spice-gstaudio.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index aff69d2..d0cfbc6 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -191,7 +191,7 @@ static void record_start(SpiceRecordChannel *channel, gint 
format, gint channels
  if (p->record.pipe &&
  (p->record.rate != frequency ||
   p->record.channels != channels)) {
-record_stop(gstaudio);
+gst_element_set_state(p->record.pipe, GST_STATE_NULL);



I'm not sure, but wouldn't be better to do it in record_stop? or stop 
means pause here?



Snir.



  g_clear_pointer(>record.pipe, gst_object_unref);
  }
  


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


Re: [Spice-devel] [PATCH spice-gtk 04/34] widget: make clear gst_size_allocate() is static on definition

2019-01-07 Thread Snir Sheriber


On 1/7/19 10:00 AM, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

Signed-off-by: Marc-André Lureau 
---
  src/spice-widget.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 006dc5e..c71cc53 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -2609,7 +2609,7 @@ static gboolean gst_draw_event(GtkWidget *widget, cairo_t 
*cr, gpointer data)
  return false;
  }
  
-void gst_size_allocate(GtkWidget *widget, GdkRectangle *a, gpointer data)

+static void gst_size_allocate(GtkWidget *widget, GdkRectangle *a, gpointer 
data)
  {
  SpiceDisplay *display = SPICE_DISPLAY(data);
  SpiceDisplayPrivate *d = display->priv;



Missed it :p

Acked-by: Snir Sheriber 

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


  1   2   >