summaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2017-04-17 14:57:54 +0200
committerJuan Quintela <quintela@redhat.com>2017-05-17 12:04:59 +0200
commit1bfe5f0586083747f1602931713111673849cd9d (patch)
treee70808d8e82700a8871ec9387835574e7ea5944d /hw/core
parentbac3b21218925006e1f7d3cae564afb1e9aeb8ee (diff)
downloadqemu-1bfe5f0586083747f1602931713111673849cd9d.zip
migration: Move check_migratable() into qdev.c
The function is only used once, and nothing else in migration knows about objects. Create the function vmstate_device_is_migratable() in savem.c that really do the bit that is related with migration. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/qdev.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 02b632f6b3..6f1b070616 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -37,7 +37,7 @@
#include "hw/boards.h"
#include "hw/sysbus.h"
#include "qapi-event.h"
-#include "migration/migration.h"
+#include "migration/vmstate.h"
bool qdev_hotplug = false;
static bool qdev_hot_added = false;
@@ -861,6 +861,20 @@ static bool device_get_realized(Object *obj, Error **errp)
return dev->realized;
}
+static bool check_only_migratable(Object *obj, Error **err)
+{
+ DeviceClass *dc = DEVICE_GET_CLASS(obj);
+
+ if (!vmstate_check_only_migratable(dc->vmsd)) {
+ error_setg(err, "Device %s is not migratable, but "
+ "--only-migratable was specified",
+ object_get_typename(obj));
+ return false;
+ }
+
+ return true;
+}
+
static void device_set_realized(Object *obj, bool value, Error **errp)
{
DeviceState *dev = DEVICE(obj);
@@ -870,7 +884,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
Error *local_err = NULL;
bool unattached_parent = false;
static int unattached_count;
- int ret;
if (dev->hotplugged && !dc->hotpluggable) {
error_setg(errp, QERR_DEVICE_NO_HOTPLUG, object_get_typename(obj));
@@ -878,8 +891,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
}
if (value && !dev->realized) {
- ret = check_migratable(obj, &local_err);
- if (ret < 0) {
+ if (!check_only_migratable(obj, &local_err)) {
goto fail;
}