From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au
Subject: [PATCH for-7.1 1/4] hw/ppc: use qdev to register logical DRC vmstates
Date: Tue, 22 Mar 2022 15:38:51 -0300 [thread overview]
Message-ID: <20220322183854.196063-2-danielhb413@gmail.com> (raw)
In-Reply-To: <20220322183854.196063-1-danielhb413@gmail.com>
Today we use vmstate_register() to register the vmstate of logical DRCs
during drc_realize(), following it up with a similar
vmstate_unregister() during drc_unrealize().
We can instead use qdev to init the vmstate of the device via the
dc->vmsd interface. This will spare us of both vmstate calls and make
the code a little more maintainable.
Since we're using spapr_drc_index() as instance_id in
vmstate_register(), we'll need to use qdev_set_legacy_instance_id() to set
the same instance_id the DRC vmstates are now used to have.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/spapr_drc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 76bc5d42a0..a5ef64d2a2 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -536,8 +536,7 @@ static void drc_realize(DeviceState *d, Error **errp)
trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
object_property_add_alias(root_container, link_name,
drc->owner, child_name);
- vmstate_register(VMSTATE_IF(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
- drc);
+ qdev_set_legacy_instance_id(d, spapr_drc_index(drc), 1);
trace_spapr_drc_realize_complete(spapr_drc_index(drc));
}
@@ -548,7 +547,6 @@ static void drc_unrealize(DeviceState *d)
Object *root_container;
trace_spapr_drc_unrealize(spapr_drc_index(drc));
- vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc);
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
object_property_del(root_container, name);
}
@@ -673,8 +671,11 @@ static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
static void spapr_drc_logical_class_init(ObjectClass *k, void *data)
{
+ DeviceClass *dk = DEVICE_CLASS(k);
SpaprDrcClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
+ dk->vmsd = &vmstate_spapr_drc;
+
drck->dr_entity_sense = logical_entity_sense;
drck->isolate = drc_isolate_logical;
drck->unisolate = drc_unisolate_logical;
--
2.35.1
next prev parent reply other threads:[~2022-03-22 18:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 18:38 [PATCH for-7.1 0/4] use dc->vmsd with spapr devices vmstate Daniel Henrique Barboza
2022-03-22 18:38 ` Daniel Henrique Barboza [this message]
2022-03-22 18:38 ` [PATCH for-7.1 2/4] hw/ppc: use qdev to register physical DRC vmstates Daniel Henrique Barboza
2022-03-23 1:48 ` David Gibson
2022-03-23 21:44 ` Daniel Henrique Barboza
2022-03-22 18:38 ` [PATCH for-7.1 3/4] hw/ppc: use qdev to register spapr_iommu tcet vmstate Daniel Henrique Barboza
2022-03-22 18:38 ` [PATCH for-7.1 4/4] hw/ppc: use qdev to register spapr_nvdimm vmsd Daniel Henrique Barboza
2022-03-23 1:49 ` [PATCH for-7.1 0/4] use dc->vmsd with spapr devices vmstate David Gibson
2022-03-23 21:47 ` Daniel Henrique Barboza
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=20220322183854.196063-2-danielhb413@gmail.com \
--to=danielhb413@gmail.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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.