All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24
@ 2018-05-15  6:31 Olaf Hering
  2018-05-15  7:18 ` Thomas Huth
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2018-05-15  6:31 UTC (permalink / raw)
  To: qemu-trivial
  Cc: Olaf Hering, Fam Zheng, Stefan Hajnoczi, Paolo Bonzini,
	open list:All patches CC here

Currently the minimal supported version of glib is 2.22.
Since testing is done with a glib that claims to be 2.22, but in fact
has APIs from newer version of glib, this bug was not caught during
submit of the patch referenced below.

Replace g_realloc_n, which is available only since 2.24, with g_renew.

Fixes commit 418026ca43 ("util: Introduce vfio helpers")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---

 This must go into stable-2.12.

 util/vfio-helpers.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 006674c916..1d9272efa4 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s,
 
     assert(index >= 0);
     s->nr_mappings++;
-    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
-                              s->nr_mappings);
+    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
     insert = &s->mappings[index];
     shift = s->nr_mappings - index - 1;
     if (shift) {
@@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
     memmove(mapping, &s->mappings[index + 1],
             sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
     s->nr_mappings--;
-    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
-                              s->nr_mappings);
+    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
 }
 
 /* Check if the mapping list is (ascending) ordered. */

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24
  2018-05-15  6:31 [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24 Olaf Hering
@ 2018-05-15  7:18 ` Thomas Huth
  2018-05-15  8:09   ` Cornelia Huck
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2018-05-15  7:18 UTC (permalink / raw)
  To: Olaf Hering, qemu-trivial
  Cc: Paolo Bonzini, Fam Zheng, open list:All patches CC here,
	Stefan Hajnoczi, qemu-stable

On 15.05.2018 08:31, Olaf Hering wrote:
> Currently the minimal supported version of glib is 2.22.
> Since testing is done with a glib that claims to be 2.22, but in fact
> has APIs from newer version of glib, this bug was not caught during
> submit of the patch referenced below.
> 
> Replace g_realloc_n, which is available only since 2.24, with g_renew.
> 
> Fixes commit 418026ca43 ("util: Introduce vfio helpers")
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
>  This must go into stable-2.12.

In that case please CC: qemu-stable@nongnu.org (done now).

Reviewed-by: Thomas Huth <thuth@redhat.com>

>  util/vfio-helpers.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> index 006674c916..1d9272efa4 100644
> --- a/util/vfio-helpers.c
> +++ b/util/vfio-helpers.c
> @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s,
>  
>      assert(index >= 0);
>      s->nr_mappings++;
> -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> -                              s->nr_mappings);
> +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
>      insert = &s->mappings[index];
>      shift = s->nr_mappings - index - 1;
>      if (shift) {
> @@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
>      memmove(mapping, &s->mappings[index + 1],
>              sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
>      s->nr_mappings--;
> -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> -                              s->nr_mappings);
> +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
>  }
>  
>  /* Check if the mapping list is (ascending) ordered. */
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24
  2018-05-15  7:18 ` Thomas Huth
@ 2018-05-15  8:09   ` Cornelia Huck
  2018-06-12 22:21     ` [Qemu-devel] [Qemu-stable] " Michael Roth
  0 siblings, 1 reply; 4+ messages in thread
From: Cornelia Huck @ 2018-05-15  8:09 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Olaf Hering, qemu-trivial, Paolo Bonzini, Fam Zheng,
	open list:All patches CC here, Stefan Hajnoczi, qemu-stable

On Tue, 15 May 2018 09:18:52 +0200
Thomas Huth <thuth@redhat.com> wrote:

> On 15.05.2018 08:31, Olaf Hering wrote:
> > Currently the minimal supported version of glib is 2.22.
> > Since testing is done with a glib that claims to be 2.22, but in fact
> > has APIs from newer version of glib, this bug was not caught during
> > submit of the patch referenced below.
> > 
> > Replace g_realloc_n, which is available only since 2.24, with g_renew.
> > 
> > Fixes commit 418026ca43 ("util: Introduce vfio helpers")
> > 
> > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > ---
> >  This must go into stable-2.12.  
> 
> In that case please CC: qemu-stable@nongnu.org (done now).
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> >  util/vfio-helpers.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> > index 006674c916..1d9272efa4 100644
> > --- a/util/vfio-helpers.c
> > +++ b/util/vfio-helpers.c
> > @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s,
> >  
> >      assert(index >= 0);
> >      s->nr_mappings++;
> > -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> > -                              s->nr_mappings);
> > +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
> >      insert = &s->mappings[index];
> >      shift = s->nr_mappings - index - 1;
> >      if (shift) {
> > @@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
> >      memmove(mapping, &s->mappings[index + 1],
> >              sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
> >      s->nr_mappings--;
> > -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> > -                              s->nr_mappings);
> > +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
> >  }
> >  
> >  /* Check if the mapping list is (ascending) ordered. */
> >   

This looks fine to me, so

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

But this leads to another question: What do we do if we want a fix only
in stable? Hypothetical scenario: Same parameters as for this patch
(glib version bump, newer function sneaked in), but the older function
that could be used in stable is clearly worse (IOW, we don't want it in
the new version). Do we have a process to get a change only into stable?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Qemu-stable] [PATCH v2] replace functions which are only available in glib-2.24
  2018-05-15  8:09   ` Cornelia Huck
@ 2018-06-12 22:21     ` Michael Roth
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Roth @ 2018-06-12 22:21 UTC (permalink / raw)
  To: Cornelia Huck, Thomas Huth
  Cc: Olaf Hering, qemu-trivial, open list:All patches   CC here,
	qemu-stable, Stefan Hajnoczi, Paolo Bonzini

Quoting Cornelia Huck (2018-05-15 03:09:49)
> On Tue, 15 May 2018 09:18:52 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > On 15.05.2018 08:31, Olaf Hering wrote:
> > > Currently the minimal supported version of glib is 2.22.
> > > Since testing is done with a glib that claims to be 2.22, but in fact
> > > has APIs from newer version of glib, this bug was not caught during
> > > submit of the patch referenced below.
> > > 
> > > Replace g_realloc_n, which is available only since 2.24, with g_renew.
> > > 
> > > Fixes commit 418026ca43 ("util: Introduce vfio helpers")
> > > 
> > > Signed-off-by: Olaf Hering <olaf@aepfle.de>
> > > ---
> > >  This must go into stable-2.12.  
> > 
> > In that case please CC: qemu-stable@nongnu.org (done now).
> > 
> > Reviewed-by: Thomas Huth <thuth@redhat.com>
> > 
> > >  util/vfio-helpers.c | 6 ++----
> > >  1 file changed, 2 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
> > > index 006674c916..1d9272efa4 100644
> > > --- a/util/vfio-helpers.c
> > > +++ b/util/vfio-helpers.c
> > > @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s,
> > >  
> > >      assert(index >= 0);
> > >      s->nr_mappings++;
> > > -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> > > -                              s->nr_mappings);
> > > +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
> > >      insert = &s->mappings[index];
> > >      shift = s->nr_mappings - index - 1;
> > >      if (shift) {
> > > @@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
> > >      memmove(mapping, &s->mappings[index + 1],
> > >              sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
> > >      s->nr_mappings--;
> > > -    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
> > > -                              s->nr_mappings);
> > > +    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
> > >  }
> > >  
> > >  /* Check if the mapping list is (ascending) ordered. */
> > >   
> 
> This looks fine to me, so
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
> 
> But this leads to another question: What do we do if we want a fix only
> in stable? Hypothetical scenario: Same parameters as for this patch
> (glib version bump, newer function sneaked in), but the older function
> that could be used in stable is clearly worse (IOW, we don't want it in
> the new version). Do we have a process to get a change only into stable?
> 

I've answered in the form of a patch :)

  "docs: add details regarding submitting stable-specific patches"

but here's a recent example:

  https://lists.gnu.org/archive/html/qemu-devel/2018-05/msg04999.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-12 22:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15  6:31 [Qemu-devel] [PATCH v2] replace functions which are only available in glib-2.24 Olaf Hering
2018-05-15  7:18 ` Thomas Huth
2018-05-15  8:09   ` Cornelia Huck
2018-06-12 22:21     ` [Qemu-devel] [Qemu-stable] " Michael Roth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.