From: Juan Quintela <quintela@redhat.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: peterx@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com,
eric.auger.pro@gmail.com
Subject: Re: [PATCH v3] migration: Support gtree migration
Date: Sat, 05 Oct 2019 00:34:37 +0200 [thread overview]
Message-ID: <87a7aguole.fsf@trasno.org> (raw)
In-Reply-To: <20191004112025.28868-1-eric.auger@redhat.com> (Eric Auger's message of "Fri, 4 Oct 2019 13:20:25 +0200")
Eric Auger <eric.auger@redhat.com> wrote:
> Introduce support for GTree migration. A custom save/restore
> is implemented. Each item is made of a key and a data.
>
> If the key is a pointer to an object, 2 VMSDs are passed into
> the GTree VMStateField.
>
> When putting the items, the tree is traversed in sorted order by
> g_tree_foreach.
>
> On the get() path, gtrees must be allocated using the proper
> key compare, key destroy and value destroy. This must be handled
> beforehand, for example in a pre_load method.
>
> Tests are added to test save/dump of structs containing gtrees
> including the virtio-iommu domain/mappings scenario.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
Overal I like the patch. I think that I found a minor error.
> +static int put_gtree(QEMUFile *f, void *pv, size_t unused_size,
> + const VMStateField *field, QJSON *vmdesc)
> +{
> + bool direct_key = (!field->start);
> + const VMStateDescription *key_vmsd = direct_key ? NULL : &field->vmsd[0];
> + const VMStateDescription *val_vmsd = direct_key ? &field->vmsd[0] :
> + &field->vmsd[1];
> + struct put_gtree_data capsule = {f, key_vmsd, val_vmsd, 0};
Please, consider change the last line to:
struct put_gtree_data capsule = {
.f = f,
.key_vmsd = key_vmsd,
.val_vmsd = val_vmsd,
.ret = 0};
It makes much easier make changes on the future.
Once here, I think that you are missing on the middle a:
.vmdesc = vmdesc,
No? At least you use it on put_gtree_elem, and I don't see any place
where you assign it. When I did the change is when I noticed that it
was missing.
> + GTree **pval = pv;
> + GTree *tree = *pval;
> + int ret;
> +
> + qemu_put_be32(f, g_tree_nnodes(tree));
> + g_tree_foreach(tree, put_gtree_elem, (gpointer)&capsule);
> + qemu_put_byte(f, false);
> + ret = capsule.ret;
> + if (ret) {
> + error_report("%s : failed to save gtree (%d)", field->name, ret);
> + }
> + return ret;
> +}
As said before, with this changes you have my reviewed-by.
Later, Juan.
next prev parent reply other threads:[~2019-10-04 22:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 11:20 [PATCH v3] migration: Support gtree migration Eric Auger
2019-10-04 22:34 ` Juan Quintela [this message]
2019-10-10 7:32 ` Auger Eric
2019-10-09 6:28 ` Peter Xu
2019-10-10 7:57 ` Auger Eric
2019-10-10 11:35 ` Peter Xu
2019-10-10 12:11 ` Auger Eric
2019-10-10 12:35 ` Peter Xu
2019-10-10 18:52 ` Auger Eric
2019-10-10 18:53 ` Dr. David Alan Gilbert
2019-10-10 19:42 ` Auger Eric
2019-10-09 9:57 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a7aguole.fsf@trasno.org \
--to=quintela@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.