From nobody Tue Feb 10 05:44:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495020063896741.5619305990872; Wed, 17 May 2017 04:21:03 -0700 (PDT) Received: from localhost ([::1]:46966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAx0n-0007hs-E0 for importer@patchew.org; Wed, 17 May 2017 07:21:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dAwuC-0002Mx-S6 for qemu-devel@nongnu.org; Wed, 17 May 2017 07:14:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dAwuB-0002FB-J0 for qemu-devel@nongnu.org; Wed, 17 May 2017 07:14:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dAwuB-0002Ei-9i for qemu-devel@nongnu.org; Wed, 17 May 2017 07:14:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5268FC0B39C4 for ; Wed, 17 May 2017 11:14:10 +0000 (UTC) Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6319627DD; Wed, 17 May 2017 11:14:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5268FC0B39C4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5268FC0B39C4 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 13:13:46 +0200 Message-Id: <20170517111346.21450-8-quintela@redhat.com> In-Reply-To: <20170517111346.21450-1-quintela@redhat.com> References: <20170517111346.21450-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 May 2017 11:14:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/7] migration: Move check_migratable() into qdev.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Peter Xu --- hw/core/qdev.c | 20 ++++++++++++++++---- include/migration/migration.h | 6 ------ include/migration/vmstate.h | 2 ++ include/sysemu/sysemu.h | 2 +- migration/migration.c | 15 --------------- migration/savevm.c | 10 ++++++++++ stubs/vmstate.c | 5 ++--- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 02b632f..6f1b070 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" =20 bool qdev_hotplug =3D false; static bool qdev_hot_added =3D false; @@ -861,6 +861,20 @@ static bool device_get_realized(Object *obj, Error **e= rrp) return dev->realized; } =20 +static bool check_only_migratable(Object *obj, Error **err) +{ + DeviceClass *dc =3D 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 =3D DEVICE(obj); @@ -870,7 +884,6 @@ static void device_set_realized(Object *obj, bool value= , Error **errp) Error *local_err =3D NULL; bool unattached_parent =3D false; static int unattached_count; - int ret; =20 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) } =20 if (value && !dev->realized) { - ret =3D check_migratable(obj, &local_err); - if (ret < 0) { + if (!check_only_migratable(obj, &local_err)) { goto fail; } =20 diff --git a/include/migration/migration.h b/include/migration/migration.h index 97e78ba..49ec501 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -22,7 +22,6 @@ #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" -#include "qom/object.h" =20 #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 @@ -39,9 +38,6 @@ #define QEMU_VM_COMMAND 0x08 #define QEMU_VM_SECTION_FOOTER 0x7e =20 -/* for vl.c */ -extern int only_migratable; - struct MigrationParams { bool blk; bool shared; @@ -253,8 +249,6 @@ int ram_discard_range(const char *block_name, uint64_t = start, size_t length); int ram_postcopy_incoming_init(MigrationIncomingState *mis); void ram_postcopy_migrated_memory_release(MigrationState *ms); =20 -int check_migratable(Object *obj, Error **err); - bool migrate_release_ram(void); bool migrate_postcopy_ram(void); bool migrate_zero_blocks(void); diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f4bf3f1..8489659 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1067,4 +1067,6 @@ int64_t self_announce_delay(int round) =20 void dump_vmstate_json_to_file(FILE *out_fp); =20 +bool vmstate_check_only_migratable(const VMStateDescription *vmsd); + #endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 282f6bc..83c1ceb 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -15,7 +15,7 @@ /* vl.c */ =20 extern const char *bios_name; - +extern int only_migratable; extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; diff --git a/migration/migration.c b/migration/migration.c index ed11c1f..0304c01 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1143,21 +1143,6 @@ void migrate_del_blocker(Error *reason) migration_blockers =3D g_slist_remove(migration_blockers, reason); } =20 -int check_migratable(Object *obj, Error **err) -{ - DeviceClass *dc =3D DEVICE_GET_CLASS(obj); - if (only_migratable && dc->vmsd) { - if (dc->vmsd->unmigratable) { - error_setg(err, "Device %s is not migratable, but " - "--only-migratable was specified", - object_get_typename(obj)); - return -1; - } - } - - return 0; -} - void qmp_migrate_incoming(const char *uri, Error **errp) { Error *local_err =3D NULL; diff --git a/migration/savevm.c b/migration/savevm.c index b4f736f..f5e8194 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2317,3 +2317,13 @@ void vmstate_register_ram_global(MemoryRegion *mr) { vmstate_register_ram(mr, NULL); } + +bool vmstate_check_only_migratable(const VMStateDescription *vmsd) +{ + /* check needed if --only-migratable is specified */ + if (!only_migratable) { + return true; + } + + return !(vmsd && vmsd->unmigratable); +} diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6d52f29..6399474 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -1,7 +1,6 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "migration/vmstate.h" -#include "migration/migration.h" =20 const VMStateDescription vmstate_dummy =3D {}; =20 @@ -21,7 +20,7 @@ void vmstate_unregister(DeviceState *dev, { } =20 -int check_migratable(Object *obj, Error **err) +bool vmstate_check_only_migratable(const VMStateDescription *vmsd) { - return 0; + return true; } --=20 2.9.3