From nobody Mon Apr 29 07:36:20 2024 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 149311569349192.91975626428632; Tue, 25 Apr 2017 03:21:33 -0700 (PDT) Received: from localhost ([::1]:48199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2xbA-0002MB-55 for importer@patchew.org; Tue, 25 Apr 2017 06:21:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2xXr-00004x-DF for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2xXq-0006iA-1D for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50052) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2xXp-0006i3-Ny for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:05 -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 A6A017CFA8 for ; Tue, 25 Apr 2017 10:18:04 +0000 (UTC) Received: from secure.mitica (unknown [10.36.118.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26F417F47D; Tue, 25 Apr 2017 10:18:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A6A017CFA8 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A6A017CFA8 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 25 Apr 2017 12:17:57 +0200 Message-Id: <20170425101758.3944-2-quintela@redhat.com> In-Reply-To: <20170425101758.3944-1-quintela@redhat.com> References: <20170425101758.3944-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.27]); Tue, 25 Apr 2017 10:18:04 +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] [PATCH 1/2] 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: Laurent Vivier --- hw/core/qdev.c | 15 ++++++++++++++- include/migration/migration.h | 3 --- include/migration/vmstate.h | 2 ++ migration/migration.c | 15 --------------- migration/savevm.c | 10 ++++++++++ stubs/vmstate.c | 5 ++--- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 02b632f..17ff638 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,19 @@ static bool device_get_realized(Object *obj, Error **e= rrp) return dev->realized; } =20 +static int check_migratable(Object *obj, Error **err) +{ + DeviceClass *dc =3D DEVICE_GET_CLASS(obj); + if (!vmstate_device_is_migratable(dc->vmsd)) { + error_setg(err, "Device %s is not migratable, but " + "--only-migratable was specified", + object_get_typename(obj)); + return -1; + } + + return 0; +} + static void device_set_realized(Object *obj, bool value, Error **errp) { DeviceState *dev =3D DEVICE(obj); diff --git a/include/migration/migration.h b/include/migration/migration.h index ba1a16c..dfeca38 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 @@ -292,8 +291,6 @@ int migrate_add_blocker(Error *reason, Error **errp); */ void migrate_del_blocker(Error *reason); =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 dad3984..9452dec 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1049,4 +1049,6 @@ int64_t self_announce_delay(int round) =20 void dump_vmstate_json_to_file(FILE *out_fp); =20 +bool vmstate_device_is_migratable(const VMStateDescription *vmsd); + #endif diff --git a/migration/migration.c b/migration/migration.c index 353f272..5447cab 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1158,21 +1158,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 03ae1bd..7421a67 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2480,3 +2480,13 @@ void vmstate_register_ram_global(MemoryRegion *mr) { vmstate_register_ram(mr, NULL); } + +bool vmstate_device_is_migratable(const VMStateDescription *vmsd) +{ + if (only_migratable && vmsd) { + if (vmsd->unmigratable) { + return false; + } + } + return true; +} diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6d52f29..5af824b 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_device_is_migratable(const VMStateDescription *vmsd) { - return 0; + return true; } --=20 2.9.3 From nobody Mon Apr 29 07:36:20 2024 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 1493115585290926.6451582485926; Tue, 25 Apr 2017 03:19:45 -0700 (PDT) Received: from localhost ([::1]:48187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2xZN-00012n-14 for importer@patchew.org; Tue, 25 Apr 2017 06:19:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2xXv-00007j-E2 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2xXr-0006iZ-Gf for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41380) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2xXr-0006iH-Ae for qemu-devel@nongnu.org; Tue, 25 Apr 2017 06:18:07 -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 51AD33B71C for ; Tue, 25 Apr 2017 10:18:06 +0000 (UTC) Received: from secure.mitica (unknown [10.36.118.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03A9F7F47D; Tue, 25 Apr 2017 10:18:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51AD33B71C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 51AD33B71C From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 25 Apr 2017 12:17:58 +0200 Message-Id: <20170425101758.3944-3-quintela@redhat.com> In-Reply-To: <20170425101758.3944-1-quintela@redhat.com> References: <20170425101758.3944-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.30]); Tue, 25 Apr 2017 10:18:06 +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] [PATCH 2/2] migration: to_dst_file at that point is NULL 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" We have just arrived as: migration.c: qemu_migrate() .... s =3D migrate_init() <- puts it to NULL .... {tcp,unix}_start_outgoing_migration -> socket_outgoing_migration migration_channel_connect() sets to_dst_file if tls is enabled, we do another round through migrate_channel_tls_connect(), but we only set it up if there is no error. So we don't need the assignation. I am removing it to remove in the follwing patches the knowledge about MigrationState in that two files. Signed-off-by: Juan Quintela Reviewed-by: Daniel P. Berrange Reviewed-by: Peter Xu --- migration/socket.c | 1 - migration/tls.c | 1 - 2 files changed, 2 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index 13966f1..dc88812 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -79,7 +79,6 @@ static void socket_outgoing_migration(QIOTask *task, =20 if (qio_task_propagate_error(task, &err)) { trace_migration_socket_outgoing_error(error_get_pretty(err)); - data->s->to_dst_file =3D NULL; migrate_fd_error(data->s, err); error_free(err); } else { diff --git a/migration/tls.c b/migration/tls.c index 45bec44..a33ecb7 100644 --- a/migration/tls.c +++ b/migration/tls.c @@ -116,7 +116,6 @@ static void migration_tls_outgoing_handshake(QIOTask *t= ask, =20 if (qio_task_propagate_error(task, &err)) { trace_migration_tls_outgoing_handshake_error(error_get_pretty(err)= ); - s->to_dst_file =3D NULL; migrate_fd_error(s, err); error_free(err); } else { --=20 2.9.3