Re: [Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Peter Xu
On Mon, Jul 17, 2017 at 11:30:47AM -0500, Eric Blake wrote:
> On 07/17/2017 03:26 AM, Peter Xu wrote:
> > We have merely all the stuff, but this one is missing. Add it in.
> 
> s/merely/nearly/

Will fix this without removing r-bs.  Thanks,

> 
> > 
> > Am going to use this new helper for MigrationParameters fields, since
> > most of them are int64_t.
> > 
> > CC: Markus Armbruster 
> > CC: Eduardo Habkost 
> > CC: Marc-André Lureau 
> > CC: Peter Xu 
> > CC: Juan Quintela 
> > CC: Marcel Apfelbaum 
> > Reviewed-by: Marc-André Lureau 
> > Signed-off-by: Peter Xu 
> > ---
> >  hw/core/qdev-properties.c| 32 
> >  include/hw/qdev-properties.h |  3 +++
> >  2 files changed, 35 insertions(+)
> > 
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.   +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
> 




-- 
Peter Xu



Re: [Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Eduardo Habkost
On Mon, Jul 17, 2017 at 04:26:01PM +0800, Peter Xu wrote:
> We have merely all the stuff, but this one is missing. Add it in.
> 
> Am going to use this new helper for MigrationParameters fields, since
> most of them are int64_t.
> 
> CC: Markus Armbruster 
> CC: Eduardo Habkost 
> CC: Marc-André Lureau 
> CC: Peter Xu 
> CC: Juan Quintela 
> CC: Marcel Apfelbaum 
> Reviewed-by: Marc-André Lureau 
> Signed-off-by: Peter Xu 

Assuming that this will get merged through the migration tree:

Acked-by: Eduardo Habkost 

-- 
Eduardo



Re: [Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Eric Blake
On 07/17/2017 03:26 AM, Peter Xu wrote:
> We have merely all the stuff, but this one is missing. Add it in.

s/merely/nearly/

> 
> Am going to use this new helper for MigrationParameters fields, since
> most of them are int64_t.
> 
> CC: Markus Armbruster 
> CC: Eduardo Habkost 
> CC: Marc-André Lureau 
> CC: Peter Xu 
> CC: Juan Quintela 
> CC: Marcel Apfelbaum 
> Reviewed-by: Marc-André Lureau 
> Signed-off-by: Peter Xu 
> ---
>  hw/core/qdev-properties.c| 32 
>  include/hw/qdev-properties.h |  3 +++
>  2 files changed, 35 insertions(+)
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Juan Quintela
Peter Xu  wrote:
> We have merely all the stuff, but this one is missing. Add it in.
>
> Am going to use this new helper for MigrationParameters fields, since
> most of them are int64_t.
>
> CC: Markus Armbruster 
> CC: Eduardo Habkost 
> CC: Marc-André Lureau 
> CC: Peter Xu 
> CC: Juan Quintela 
> CC: Marcel Apfelbaum 
> Reviewed-by: Marc-André Lureau 
> Signed-off-by: Peter Xu 

Reviewed-by: Juan Quintela 



Re: [Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Marcel Apfelbaum

On 17/07/2017 11:26, Peter Xu wrote:

We have merely all the stuff, but this one is missing. Add it in.

Am going to use this new helper for MigrationParameters fields, since
most of them are int64_t.

CC: Markus Armbruster 
CC: Eduardo Habkost 
CC: Marc-André Lureau 
CC: Peter Xu 
CC: Juan Quintela 
CC: Marcel Apfelbaum 
Reviewed-by: Marc-André Lureau 
Signed-off-by: Peter Xu 
---
  hw/core/qdev-properties.c| 32 
  include/hw/qdev-properties.h |  3 +++
  2 files changed, 35 insertions(+)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index dcecdf0..c1d4e54 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -404,6 +404,31 @@ static void set_uint64(Object *obj, Visitor *v, const char 
*name,
  visit_type_uint64(v, name, ptr, errp);
  }
  
+static void get_int64(Object *obj, Visitor *v, const char *name,

+  void *opaque, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+Property *prop = opaque;
+int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+visit_type_int64(v, name, ptr, errp);
+}
+
+static void set_int64(Object *obj, Visitor *v, const char *name,
+  void *opaque, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+Property *prop = opaque;
+int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+if (dev->realized) {
+qdev_prop_set_after_realize(dev, name, errp);
+return;
+}
+
+visit_type_int64(v, name, ptr, errp);
+}
+
  const PropertyInfo qdev_prop_uint64 = {
  .name  = "uint64",
  .get   = get_uint64,
@@ -411,6 +436,13 @@ const PropertyInfo qdev_prop_uint64 = {
  .set_default_value = set_default_value_uint,
  };
  
+const PropertyInfo qdev_prop_int64 = {

+.name  = "int64",
+.get   = get_int64,
+.set   = set_int64,
+.set_default_value = set_default_value_int,
+};
+
  /* --- string --- */
  
  static void release_string(Object *obj, const char *name, void *opaque)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index f6692d5..30af33b 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -13,6 +13,7 @@ extern const PropertyInfo qdev_prop_uint16;
  extern const PropertyInfo qdev_prop_uint32;
  extern const PropertyInfo qdev_prop_int32;
  extern const PropertyInfo qdev_prop_uint64;
+extern const PropertyInfo qdev_prop_int64;
  extern const PropertyInfo qdev_prop_size;
  extern const PropertyInfo qdev_prop_string;
  extern const PropertyInfo qdev_prop_chr;
@@ -136,6 +137,8 @@ extern const PropertyInfo qdev_prop_link;
  DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
  #define DEFINE_PROP_UINT64(_n, _s, _f, _d)  \
  DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+#define DEFINE_PROP_INT64(_n, _s, _f, _d)  \
+DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t)
  #define DEFINE_PROP_SIZE(_n, _s, _f, _d)   \
  DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
  #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)   \




Reviewed-by: Marcel Apfelbaum 

Thanks,
Marcel






[Qemu-devel] [PATCH v2 01/11] qdev: provide DEFINE_PROP_INT64()

2017-07-17 Thread Peter Xu
We have merely all the stuff, but this one is missing. Add it in.

Am going to use this new helper for MigrationParameters fields, since
most of them are int64_t.

CC: Markus Armbruster 
CC: Eduardo Habkost 
CC: Marc-André Lureau 
CC: Peter Xu 
CC: Juan Quintela 
CC: Marcel Apfelbaum 
Reviewed-by: Marc-André Lureau 
Signed-off-by: Peter Xu 
---
 hw/core/qdev-properties.c| 32 
 include/hw/qdev-properties.h |  3 +++
 2 files changed, 35 insertions(+)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index dcecdf0..c1d4e54 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -404,6 +404,31 @@ static void set_uint64(Object *obj, Visitor *v, const char 
*name,
 visit_type_uint64(v, name, ptr, errp);
 }
 
+static void get_int64(Object *obj, Visitor *v, const char *name,
+  void *opaque, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+Property *prop = opaque;
+int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+visit_type_int64(v, name, ptr, errp);
+}
+
+static void set_int64(Object *obj, Visitor *v, const char *name,
+  void *opaque, Error **errp)
+{
+DeviceState *dev = DEVICE(obj);
+Property *prop = opaque;
+int64_t *ptr = qdev_get_prop_ptr(dev, prop);
+
+if (dev->realized) {
+qdev_prop_set_after_realize(dev, name, errp);
+return;
+}
+
+visit_type_int64(v, name, ptr, errp);
+}
+
 const PropertyInfo qdev_prop_uint64 = {
 .name  = "uint64",
 .get   = get_uint64,
@@ -411,6 +436,13 @@ const PropertyInfo qdev_prop_uint64 = {
 .set_default_value = set_default_value_uint,
 };
 
+const PropertyInfo qdev_prop_int64 = {
+.name  = "int64",
+.get   = get_int64,
+.set   = set_int64,
+.set_default_value = set_default_value_int,
+};
+
 /* --- string --- */
 
 static void release_string(Object *obj, const char *name, void *opaque)
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index f6692d5..30af33b 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -13,6 +13,7 @@ extern const PropertyInfo qdev_prop_uint16;
 extern const PropertyInfo qdev_prop_uint32;
 extern const PropertyInfo qdev_prop_int32;
 extern const PropertyInfo qdev_prop_uint64;
+extern const PropertyInfo qdev_prop_int64;
 extern const PropertyInfo qdev_prop_size;
 extern const PropertyInfo qdev_prop_string;
 extern const PropertyInfo qdev_prop_chr;
@@ -136,6 +137,8 @@ extern const PropertyInfo qdev_prop_link;
 DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int32, int32_t)
 #define DEFINE_PROP_UINT64(_n, _s, _f, _d)  \
 DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+#define DEFINE_PROP_INT64(_n, _s, _f, _d)  \
+DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_int64, int64_t)
 #define DEFINE_PROP_SIZE(_n, _s, _f, _d)   \
 DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_size, uint64_t)
 #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)   \
-- 
2.7.4