qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH 1/4] migration: alternative way to set instance_id in SaveStateEntry
Date: Mon, 24 Apr 2017 19:08:25 -0300	[thread overview]
Message-ID: <20170424220828.1472-2-danielhb@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170424220828.1472-1-danielhb@linux.vnet.ibm.com>

From: Jianjun Duan <duanj@linux.vnet.ibm.com>

In QOM (QEMU Object Model) migrated objects are identified with instance_id
which is calculated automatically using their path in the QOM composition
tree. For some objects, this path could change from source to target in
migration. To migrate such objects, we need to make sure the instance_id does
not change from source to target. We add a hook in DeviceClass to do customized
instance_id calculation in such cases.

As a result, in these cases compat will not be set in the concerned
SaveStateEntry. This will prevent the inconsistent idstr to be sent over in
migration. We could have set alias_id in a similar way. But that will be
overloading the purpose of alias_id.

The first application will be setting instance_id for pseries DRC objects using
its unique index. Doing this makes the instance_id of DRC to be consistent
across migration and supports flexible management of DRC objects in migration.

Signed-off-by: Jianjun Duan <duanj@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
---
 include/hw/qdev-core.h | 6 ++++++
 migration/savevm.c     | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 4bf86b0..9b3914c 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -127,6 +127,12 @@ typedef struct DeviceClass {
     qdev_initfn init; /* TODO remove, once users are converted to realize */
     qdev_event exit; /* TODO remove, once users are converted to unrealize */
     const char *bus_type;
+
+    /* When this field is set, qemu will use it to get an unique instance_id
+     * instead of calculating an auto idstr and instance_id for the relevant
+     * SaveStateEntry
+     */
+    int (*dev_get_instance_id)(DeviceState *dev);
 } DeviceClass;
 
 typedef struct NamedGPIOList NamedGPIOList;
diff --git a/migration/savevm.c b/migration/savevm.c
index 03ae1bd..5d8135f 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -606,6 +606,9 @@ int register_savevm_live(DeviceState *dev,
                          calculate_compat_instance_id(idstr) : instance_id;
             instance_id = -1;
         }
+        if (DEVICE_GET_CLASS(dev)->dev_get_instance_id) {
+            instance_id = DEVICE_GET_CLASS(dev)->dev_get_instance_id(dev);
+        }
     }
     pstrcat(se->idstr, sizeof(se->idstr), idstr);
 
@@ -696,6 +699,9 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
                          calculate_compat_instance_id(vmsd->name) : instance_id;
             instance_id = -1;
         }
+        if (DEVICE_GET_CLASS(dev)->dev_get_instance_id) {
+            instance_id = DEVICE_GET_CLASS(dev)->dev_get_instance_id(dev);
+        }
     }
     pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);
 
-- 
2.9.3

  reply	other threads:[~2017-04-24 22:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 22:08 [Qemu-devel] [PATCH 0/4 v6] migration/ppc: migrating DRC, ccs_list and pending_events Daniel Henrique Barboza
2017-04-24 22:08 ` Daniel Henrique Barboza [this message]
2017-04-25 22:26   ` [Qemu-devel] [PATCH 1/4] migration: alternative way to set instance_id in SaveStateEntry Michael Roth
2017-04-26 10:05     ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-04-24 22:08 ` [Qemu-devel] [PATCH 2/4] hw/ppc: migrating the DRC state of hotplugged devices Daniel Henrique Barboza
2017-04-25 22:45   ` Michael Roth
2017-04-26  5:55     ` David Gibson
2017-04-26 10:07       ` [Qemu-devel] [Qemu-ppc] " Daniel Henrique Barboza
2017-04-24 22:08 ` [Qemu-devel] [PATCH 3/4] migration: spapr: migrate ccs_list in spapr state Daniel Henrique Barboza
2017-04-25 22:47   ` Michael Roth
2017-04-24 22:08 ` [Qemu-devel] [PATCH 4/4] migration: spapr: migrate pending_events of " Daniel Henrique Barboza
2017-04-25 22:53   ` Michael Roth
2017-04-26 10:10     ` 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=20170424220828.1472-2-danielhb@linux.vnet.ibm.com \
    --to=danielhb@linux.vnet.ibm.com \
    --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 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).