Re: [Spice-devel] [PATCH spice-common 4/7] messages: Remove fields not used by the protocol

2019-02-18 Thread Frediano Ziglio
> 
> These fields are not used by the protocol.
> Avoid spice-gtk and spice-server to use them by mistake.
> This can cause memory errors (data_size is not used or
> is not set correctly) and useless code (spice-gtk uses
> the pub_key* fields but these fields are not sent to
> the server as the protocol does not have them).
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  common/messages.h | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/common/messages.h b/common/messages.h
> index 3e37235..91ac7ad 100644
> --- a/common/messages.h
> +++ b/common/messages.h
> @@ -43,7 +43,6 @@
>  SPICE_BEGIN_DECLS
>  
>  typedef struct SpiceMsgData {
> -uint32_t data_size;
>  uint8_t data[0];
>  } SpiceMsgData;
>  
> @@ -75,9 +74,6 @@ typedef struct SpiceMigrationDstInfo {
>  uint16_t sport;
>  uint32_t host_size;
>  uint8_t *host_data;
> -uint16_t pub_key_type;
> -uint32_t pub_key_size;
> -uint8_t *pub_key_data;
>  uint32_t cert_subject_size;
>  uint8_t *cert_subject_data;
>  } SpiceMigrationDstInfo;

A bit more digging on this weird one.

I found this patch:

commit 9cf6d39b369f9c22615fc329e307126721125ecd
Author: Yonit Halperin 
Date:   Sun Sep 18 10:31:38 2011 +0300

server,proto: tell the clients to connect to the migration target before 
migraton starts

(1) send SPICE_MSG_MAIN_MIGRATE_BEGIN upon spice_server_migrate_connect
(to all the clients that support it)
(2) wait for SPICE_MSGC_MAIN_MIGRATE_(CONNECTED|CONNECT_ERROR) from all the 
relevant clients,
or a timeout, in order to complete client_migrate_info monitor command
(cherry picked from commit 5560c56ef05c74da5e0e0825dc1f134019593cad branch 
0.8;
 Was modified to support the separation of main channel from reds, and 
multiple clients)

Conflicts:

server/reds.c

diff --git a/common/messages.h b/common/messages.h
index 8151dc0..a54190f 100644
--- a/common/messages.h
+++ b/common/messages.h
@@ -66,6 +66,8 @@ typedef struct SpiceMsgMainMigrationBegin {
 uint16_t pub_key_type;
 uint32_t pub_key_size;
 uint8_t *pub_key_data;
+uint32_t cert_subject_size;
+uint8_t *cert_subject_data;
 } SpiceMsgMainMigrationBegin;
 
 typedef struct SpiceMsgMainMigrationSwitchHost {
diff --git a/spice.proto b/spice.proto
index abf3ec3..78c1fad 100644
--- a/spice.proto
+++ b/spice.proto
@@ -167,9 +167,8 @@ channel MainChannel : BaseChannel {
uint16 sport;
uint32 host_size;
uint8 *host_data[host_size] @zero_terminated @marshall @nonnull;
-   pubkey_type pub_key_type;
-   uint32 pub_key_size;
-   uint8 *pub_key_data[pub_key_size] @zero_terminated  @marshall @nonnull;
+   uint32 cert_subject_size;
+   uint8 *cert_subject_data[cert_subject_size] @zero_terminated @marshall;
 } @ctype(SpiceMsgMainMigrationBegin) migrate_begin = 101;
 
 Empty migrate_cancel;


spice-gtk is still reading the old fields.
But as the marshaller code (spice-server) is ignoring them when
demarshalled (spice-gtk) all fields will be zeroes and client
will copy this "empty" array to the "pubkey" property.
I suppose, as nobody noticed it in 8 years that the relative
code in spice-gtk is not used.

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

Re: [Spice-devel] [PATCH spice-gtk v2] Move src/keycodemapdb -> subprojects/keycodemapdb

2019-02-18 Thread Frediano Ziglio
> > 
> > Hi
> > On Fri, Feb 15, 2019 at 8:49 PM Marc-André Lureau
> >  wrote:
> > >
> > > Hi
> > >
> > > On Fri, Feb 15, 2019 at 6:21 PM Frediano Ziglio 
> > > wrote:
> > > > Looking at http://mesonbuild.com/Subprojects.html looks like
> > > > subprojects should be Meson project too.
> > > > While spice-common is now a Meson project keycodemapdb is not
> > > > so it does not seem that great to declare it as subproject.
> > >
> > > Ok, it's a bit silly imho. Let's make one then:
> > > https://gitlab.com/keycodemap/keycodemapdb/merge_requests/7
> > 
> > It's applied now, ack with the subproject update?
> > 
> 
> Can you send a new series version?
> Too much updates.
> 

I changed my mind, merged.
Any missing patch?

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

[Spice-devel] [PATCH -next] drm/qxl: remove set but not used variable 'bo_old'

2019-02-18 Thread YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/gpu/drm/qxl/qxl_display.c: In function 'qxl_primary_atomic_update':
drivers/gpu/drm/qxl/qxl_display.c:538:17: warning:
 variable 'bo_old' set but not used [-Wunused-but-set-variable]

It's not used any more after 4979904c62b9 ("drm/qxl: use shadow bo directly")

Signed-off-by: YueHaibing 
---
 drivers/gpu/drm/qxl/qxl_display.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 08c725544a2f..8b319ebbb0fb 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -535,7 +535,7 @@ static void qxl_primary_atomic_update(struct drm_plane 
*plane,
 {
struct qxl_device *qdev = plane->dev->dev_private;
struct qxl_bo *bo = gem_to_qxl_bo(plane->state->fb->obj[0]);
-   struct qxl_bo *bo_old, *primary;
+   struct qxl_bo *primary;
struct drm_clip_rect norect = {
.x1 = 0,
.y1 = 0,
@@ -544,12 +544,6 @@ static void qxl_primary_atomic_update(struct drm_plane 
*plane,
};
uint32_t dumb_shadow_offset = 0;
 
-   if (old_state->fb) {
-   bo_old = gem_to_qxl_bo(old_state->fb->obj[0]);
-   } else {
-   bo_old = NULL;
-   }
-
primary = bo->shadow ? bo->shadow : bo;
 
if (!primary->is_primary) {





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

[Spice-devel] [PATCH spice-common 4/7] messages: Remove fields not used by the protocol

2019-02-18 Thread Frediano Ziglio
These fields are not used by the protocol.
Avoid spice-gtk and spice-server to use them by mistake.
This can cause memory errors (data_size is not used or
is not set correctly) and useless code (spice-gtk uses
the pub_key* fields but these fields are not sent to
the server as the protocol does not have them).

Signed-off-by: Frediano Ziglio 
---
 common/messages.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/common/messages.h b/common/messages.h
index 3e37235..91ac7ad 100644
--- a/common/messages.h
+++ b/common/messages.h
@@ -43,7 +43,6 @@
 SPICE_BEGIN_DECLS
 
 typedef struct SpiceMsgData {
-uint32_t data_size;
 uint8_t data[0];
 } SpiceMsgData;
 
@@ -75,9 +74,6 @@ typedef struct SpiceMigrationDstInfo {
 uint16_t sport;
 uint32_t host_size;
 uint8_t *host_data;
-uint16_t pub_key_type;
-uint32_t pub_key_size;
-uint8_t *pub_key_data;
 uint32_t cert_subject_size;
 uint8_t *cert_subject_data;
 } SpiceMigrationDstInfo;
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 5/7] codegen: Reduce indentation

2019-02-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 python_modules/ptypes.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index e5fb1e9..bc8762f 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -927,8 +927,7 @@ class MessageType(ContainerType):
 channelname = ""
 if cm.is_server:
 return codegen.prefix_camel("Msg", channelname, cm.name)
-else:
-return codegen.prefix_camel("Msgc", channelname, cm.name)
+return codegen.prefix_camel("Msgc", channelname, cm.name)
 else:
 return codegen.prefix_camel("Msg", self.name)
 
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 2/7] codegen: Add a test for attribute combination

2019-02-18 Thread Frediano Ziglio
Does not make sense to specify the same field to have 2
different C implementation at the same time.

Signed-off-by: Frediano Ziglio 
---
 python_modules/ptypes.py | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 3875970..e5fb1e9 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -96,6 +96,13 @@ def fix_attributes(attribute_list):
 elif len(lst) > 1:
 raise Exception("Attribute %s has more than 1 argument" % name)
 attrs[name] = lst
+
+# these attributes specify output format, only one can be set
+output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero'])
+output_attrs = [a for a in attrs.keys() if a in output_attrs]
+if len(output_attrs) > 1:
+raise Exception("Multiple output type attributes specified %s" % 
output_attrs)
+
 return attrs
 
 class Type:
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 6/7] codegen: Check wrong attribute

2019-02-18 Thread Frediano Ziglio
@ptr_array is supposed to change the destination to an array
of pointer to items. This for a raw buffer does not make sense
but check if user specifies this combination.

Signed-off-by: Frediano Ziglio 
---
 python_modules/demarshal.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 68532a9..50cf6c4 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -810,6 +810,8 @@ def write_array_parser(writer, member, nelements, array, 
dest, scope):
 at_end = True
 
 if element_type == ptypes.uint8 or element_type == ptypes.int8:
+if array.has_attr("ptr_array"):
+raise Exception("Attribute ptr_array not supported for array or 
int8/uint8")
 writer.statement("memcpy(%s, in, %s)" % (array_start, nelements))
 writer.increment("in", nelements)
 if at_end:
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 7/7] codegen: Fix c_type result for TypeAlias

2019-02-18 Thread Frediano Ziglio
c_type() method is supposed to return the type to use for
C structure field. But the name is not a C type but a
protocol name.
Return the type name of the aliased type (for instance
uint32_t for a uint32 type).
This does not change the generated code.

Signed-off-by: Frediano Ziglio 
---
 python_modules/ptypes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index bc8762f..06a960b 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -253,7 +253,7 @@ class TypeAlias(Type):
 def c_type(self):
 if self.has_attr("ctype"):
 return self.attributes["ctype"][0]
-return self.name
+return self.the_type.c_type()
 
 class EnumBaseType(Type):
 def is_enum(self):
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 3/7] codegen: Use a better type for pointer converted to integer

2019-02-18 Thread Frediano Ziglio
Although on the platform we support size_t and uintptr_t are
the same on some platform the size_t can (in theory) be smaller
than the necessary integer to store a pointer.

Signed-off-by: Frediano Ziglio 
---
 python_modules/demarshal.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 36213b1..68532a9 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -847,7 +847,7 @@ def write_array_parser(writer, member, nelements, array, 
dest, scope):
 write_container_parser(writer, element_type, dest2)
 if array.has_attr("ptr_array"):
 writer.comment("Align ptr_array element to 4 
bytes").newline()
-writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 
4)")
+writer.assign("end", "(uint8_t 
*)SPICE_ALIGN((uintptr_t)end, 4)")
 
 def write_parse_pointer_core(writer, target_type, offset, at_end, dest, 
member_name, scope):
 writer.assign("ptr_info[n_ptr].offset", offset)
@@ -968,7 +968,7 @@ def write_ptr_info_check(writer):
 writer.assign("*%s" % dest, "NULL")
 with writer.block(" else"):
 writer.comment("Align to 32 bit").newline()
-writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
+writer.assign("end", "(uint8_t *)SPICE_ALIGN((uintptr_t)end, 
4)")
 writer.assign("*%s" % dest, "(void *)end")
 writer.assign("end", "%s(message_start, message_end, end, 
_info[%s])" % (function, index))
 writer.error_check("end == NULL")
-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 0/7] Miscellaneous code generation cleanups

2019-02-18 Thread Frediano Ziglio
Not much related, some documentation, some additional checks
and some cleanups.

Frediano Ziglio (7):
  codegen: Document ptr_array attribute
  codegen: Add a test for attribute combination
  codegen: Use a better type for pointer converted to integer
  messages: Remove fields not used by the protocol
  codegen: Reduce indentation
  codegen: Check wrong attribute
  codegen: Fix c_type result for TypeAlias

 common/messages.h   |  4 
 python_modules/demarshal.py |  6 --
 python_modules/ptypes.py| 15 ---
 3 files changed, 16 insertions(+), 9 deletions(-)

-- 
2.20.1

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

[Spice-devel] [PATCH spice-common 1/7] codegen: Document ptr_array attribute

2019-02-18 Thread Frediano Ziglio
Signed-off-by: Frediano Ziglio 
---
 python_modules/ptypes.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index c548a28..3875970 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -55,6 +55,9 @@ valid_attributes=set([
 'nonnull',
 # this flag member contains only a single flag
 'unique_flag',
+# represent array as an array of pointers (in the C structure)
+# for instance a "Type name[size] @ptr_array" in the protocol
+# will be stored in a "Type *name[0]" field in the C structure
 'ptr_array',
 'outvar',
 # C structure has an anonymous member (used in switch)
-- 
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 v2] Move src/keycodemapdb -> subprojects/keycodemapdb

2019-02-18 Thread Frediano Ziglio
> 
> Hi
> On Fri, Feb 15, 2019 at 8:49 PM Marc-André Lureau
>  wrote:
> >
> > Hi
> >
> > On Fri, Feb 15, 2019 at 6:21 PM Frediano Ziglio  wrote:
> > > Looking at http://mesonbuild.com/Subprojects.html looks like
> > > subprojects should be Meson project too.
> > > While spice-common is now a Meson project keycodemapdb is not
> > > so it does not seem that great to declare it as subproject.
> >
> > Ok, it's a bit silly imho. Let's make one then:
> > https://gitlab.com/keycodemap/keycodemapdb/merge_requests/7
> 
> It's applied now, ack with the subproject update?
> 

Can you send a new series version?
Too much updates.

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

Re: [Spice-devel] [PATCH spice-gtk v2] Move src/keycodemapdb -> subprojects/keycodemapdb

2019-02-18 Thread Marc-André Lureau
Hi
On Fri, Feb 15, 2019 at 8:49 PM Marc-André Lureau
 wrote:
>
> Hi
>
> On Fri, Feb 15, 2019 at 6:21 PM Frediano Ziglio  wrote:
> > Looking at http://mesonbuild.com/Subprojects.html looks like
> > subprojects should be Meson project too.
> > While spice-common is now a Meson project keycodemapdb is not
> > so it does not seem that great to declare it as subproject.
>
> Ok, it's a bit silly imho. Let's make one then:
> https://gitlab.com/keycodemap/keycodemapdb/merge_requests/7

It's applied now, ack with the subproject update?

>
> --
> Marc-André Lureau



-- 
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 v2] Move src/keycodemapdb -> subprojects/keycodemapdb

2019-02-18 Thread Frediano Ziglio
> 
> Hi
> 
> On Fri, Feb 15, 2019 at 6:21 PM Frediano Ziglio  wrote:
> > Looking at http://mesonbuild.com/Subprojects.html looks like
> > subprojects should be Meson project too.
> > While spice-common is now a Meson project keycodemapdb is not
> > so it does not seem that great to declare it as subproject.
> 
> Ok, it's a bit silly imho. Let's make one then:
> https://gitlab.com/keycodemap/keycodemapdb/merge_requests/7
> 

Yes, or use wrap-git

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