* [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)
@ 2014-10-22 17:41 Peter Maydell
2014-10-30 12:33 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2014-10-22 17:41 UTC (permalink / raw)
To: qemu-devel; +Cc: Alexey Kardashevskiy, qemu-ppc, Alexander Graf, patches
The g_hash_table_iter_* functions for iterating through a hash table
are not present in glib 2.12, which is our current minimum requirement.
Rewrite the code to use g_hash_table_foreach() instead.
Cc: qemu-stable@nongnu.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
I have tested that this builds with a glib 2.12, and also that it
passes 'make check', but no further testing beyond that. Somebody
with an spapr migration test should check it doesn't break things...
The observant will note that since this is fixing breakage
introduced in commit 9a321e92343 (merged in late June) we
obviously released 2.1 in a "doesn't build all targets on
glib 2.12" state, and nobody actually complained... So there's
maybe scope for debate about moving the minimum version up,
but I think for 2.2 we should stick with the current definition.
The cc:stable is in the interests of fixing that build breakage
in 2.1.x.
hw/ppc/spapr_pci.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index ad0da7f..21b95b3 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -704,28 +704,34 @@ static const VMStateDescription vmstate_spapr_pci_msi = {
},
};
+static void spapr_pci_fill_msi_devs(gpointer key, gpointer value,
+ gpointer opaque)
+{
+ sPAPRPHBState *sphb = opaque;
+
+ sphb->msi_devs[sphb->msi_devs_num].key = *(uint32_t *)key;
+ sphb->msi_devs[sphb->msi_devs_num].value = *(spapr_pci_msi *)value;
+ sphb->msi_devs_num++;
+}
+
static void spapr_pci_pre_save(void *opaque)
{
sPAPRPHBState *sphb = opaque;
- GHashTableIter iter;
- gpointer key, value;
- int i;
+ int msi_devs_num;
if (sphb->msi_devs) {
g_free(sphb->msi_devs);
sphb->msi_devs = NULL;
}
- sphb->msi_devs_num = g_hash_table_size(sphb->msi);
- if (!sphb->msi_devs_num) {
+ sphb->msi_devs_num = 0;
+ msi_devs_num = g_hash_table_size(sphb->msi);
+ if (!msi_devs_num) {
return;
}
- sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
+ sphb->msi_devs = g_malloc(msi_devs_num * sizeof(spapr_pci_msi_mig));
- g_hash_table_iter_init(&iter, sphb->msi);
- for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
- sphb->msi_devs[i].key = *(uint32_t *) key;
- sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
- }
+ g_hash_table_foreach(sphb->msi, spapr_pci_fill_msi_devs, sphb);
+ assert(sphb->msi_devs_num == msi_devs_num);
}
static int spapr_pci_post_load(void *opaque, int version_id)
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)
2014-10-22 17:41 [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*) Peter Maydell
@ 2014-10-30 12:33 ` Peter Maydell
2014-11-03 14:31 ` Alexander Graf
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2014-10-30 12:33 UTC (permalink / raw)
To: QEMU Developers
Cc: Alexey Kardashevskiy, qemu-ppc@nongnu.org, Alexander Graf,
Patch Tracking
Ping! It would be nice to be able to get glib2.12 builds fixed...
thanks
-- PMM
On 22 October 2014 18:41, Peter Maydell <peter.maydell@linaro.org> wrote:
> The g_hash_table_iter_* functions for iterating through a hash table
> are not present in glib 2.12, which is our current minimum requirement.
> Rewrite the code to use g_hash_table_foreach() instead.
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I have tested that this builds with a glib 2.12, and also that it
> passes 'make check', but no further testing beyond that. Somebody
> with an spapr migration test should check it doesn't break things...
>
> The observant will note that since this is fixing breakage
> introduced in commit 9a321e92343 (merged in late June) we
> obviously released 2.1 in a "doesn't build all targets on
> glib 2.12" state, and nobody actually complained... So there's
> maybe scope for debate about moving the minimum version up,
> but I think for 2.2 we should stick with the current definition.
>
> The cc:stable is in the interests of fixing that build breakage
> in 2.1.x.
>
> hw/ppc/spapr_pci.c | 28 +++++++++++++++++-----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index ad0da7f..21b95b3 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -704,28 +704,34 @@ static const VMStateDescription vmstate_spapr_pci_msi = {
> },
> };
>
> +static void spapr_pci_fill_msi_devs(gpointer key, gpointer value,
> + gpointer opaque)
> +{
> + sPAPRPHBState *sphb = opaque;
> +
> + sphb->msi_devs[sphb->msi_devs_num].key = *(uint32_t *)key;
> + sphb->msi_devs[sphb->msi_devs_num].value = *(spapr_pci_msi *)value;
> + sphb->msi_devs_num++;
> +}
> +
> static void spapr_pci_pre_save(void *opaque)
> {
> sPAPRPHBState *sphb = opaque;
> - GHashTableIter iter;
> - gpointer key, value;
> - int i;
> + int msi_devs_num;
>
> if (sphb->msi_devs) {
> g_free(sphb->msi_devs);
> sphb->msi_devs = NULL;
> }
> - sphb->msi_devs_num = g_hash_table_size(sphb->msi);
> - if (!sphb->msi_devs_num) {
> + sphb->msi_devs_num = 0;
> + msi_devs_num = g_hash_table_size(sphb->msi);
> + if (!msi_devs_num) {
> return;
> }
> - sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
> + sphb->msi_devs = g_malloc(msi_devs_num * sizeof(spapr_pci_msi_mig));
>
> - g_hash_table_iter_init(&iter, sphb->msi);
> - for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) {
> - sphb->msi_devs[i].key = *(uint32_t *) key;
> - sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
> - }
> + g_hash_table_foreach(sphb->msi, spapr_pci_fill_msi_devs, sphb);
> + assert(sphb->msi_devs_num == msi_devs_num);
> }
>
> static int spapr_pci_post_load(void *opaque, int version_id)
> --
> 1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)
2014-10-30 12:33 ` Peter Maydell
@ 2014-11-03 14:31 ` Alexander Graf
2014-11-03 22:58 ` Alexey Kardashevskiy
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2014-11-03 14:31 UTC (permalink / raw)
To: Peter Maydell, QEMU Developers
Cc: Alexey Kardashevskiy, qemu-ppc@nongnu.org, Patch Tracking
On 30.10.14 13:33, Peter Maydell wrote:
> Ping! It would be nice to be able to get glib2.12 builds fixed...
Thanks, applied to ppc-next.
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*)
2014-11-03 14:31 ` Alexander Graf
@ 2014-11-03 22:58 ` Alexey Kardashevskiy
0 siblings, 0 replies; 4+ messages in thread
From: Alexey Kardashevskiy @ 2014-11-03 22:58 UTC (permalink / raw)
To: Alexander Graf, Peter Maydell, QEMU Developers
Cc: qemu-ppc@nongnu.org, Patch Tracking
On 11/03/2014 03:31 PM, Alexander Graf wrote:
>
>
> On 30.10.14 13:33, Peter Maydell wrote:
>> Ping! It would be nice to be able to get glib2.12 builds fixed...
>
> Thanks, applied to ppc-next.
Uff. I misread the original mail and decided I have to do the patch :)
I checked ppc-next, works fine, thanks!
--
Alexey
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-03 22:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-22 17:41 [Qemu-devel] [PATCH] hw/ppc/spapr_pci.c: Avoid functions not in glib 2.12 (g_hash_table_iter_*) Peter Maydell
2014-10-30 12:33 ` Peter Maydell
2014-11-03 14:31 ` Alexander Graf
2014-11-03 22:58 ` Alexey Kardashevskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).