From nobody Fri May 3 06:47:41 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 1486400055766797.8246727228404; Mon, 6 Feb 2017 08:54:15 -0800 (PST) Received: from localhost ([::1]:49508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camYP-0005UC-Ea for importer@patchew.org; Mon, 06 Feb 2017 11:54:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWO-00047R-6G for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWM-0005kG-0x for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWL-0005jq-Of for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:05 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF3B480F9B for ; Mon, 6 Feb 2017 16:52:05 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Ml021125; Mon, 6 Feb 2017 11:52:04 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:44 +0100 Message-Id: <1486399909-16338-2-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Feb 2017 16:52:05 +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 1/6] migration: create Migration Incoming State at init time 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: amit.shah@redhat.com, dgilbert@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" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert Message-Id: <1485207141-1941-3-git-send-email-quintela@redhat.com> Signed-off-by: Juan Quintela --- include/migration/migration.h | 1 - migration/migration.c | 38 +++++++++++++++++--------------------- migration/savevm.c | 4 ++-- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index af9135f..7528cc2 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -122,7 +122,6 @@ struct MigrationIncomingState { }; MigrationIncomingState *migration_incoming_get_current(void); -MigrationIncomingState *migration_incoming_state_new(QEMUFile *f); void migration_incoming_state_destroy(void); /* diff --git a/migration/migration.c b/migration/migration.c index 2766d2f..619ccc4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -111,32 +111,28 @@ MigrationState *migrate_get_current(void) return ¤t_migration; } -/* For incoming */ -static MigrationIncomingState *mis_current; - MigrationIncomingState *migration_incoming_get_current(void) { - return mis_current; -} + static bool once; + static MigrationIncomingState mis_current; -MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) -{ - mis_current =3D g_new0(MigrationIncomingState, 1); - mis_current->from_src_file =3D f; - mis_current->state =3D MIGRATION_STATUS_NONE; - QLIST_INIT(&mis_current->loadvm_handlers); - qemu_mutex_init(&mis_current->rp_mutex); - qemu_event_init(&mis_current->main_thread_load_event, false); - - return mis_current; + if (!once) { + mis_current.state =3D MIGRATION_STATUS_NONE; + memset(&mis_current, 0, sizeof(MigrationIncomingState)); + QLIST_INIT(&mis_current.loadvm_handlers); + qemu_mutex_init(&mis_current.rp_mutex); + qemu_event_init(&mis_current.main_thread_load_event, false); + once =3D true; + } + return &mis_current; } void migration_incoming_state_destroy(void) { - qemu_event_destroy(&mis_current->main_thread_load_event); - loadvm_free_handlers(mis_current); - g_free(mis_current); - mis_current =3D NULL; + struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); + + qemu_event_destroy(&mis->main_thread_load_event); + loadvm_free_handlers(mis); } @@ -382,11 +378,11 @@ static void process_incoming_migration_bh(void *opaqu= e) static void process_incoming_migration_co(void *opaque) { QEMUFile *f =3D opaque; - MigrationIncomingState *mis; + MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyState ps; int ret; - mis =3D migration_incoming_state_new(f); + mis->from_src_file =3D f; postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); diff --git a/migration/savevm.c b/migration/savevm.c index 204012e..f3644ca 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2199,7 +2199,6 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state"); f =3D qemu_fopen_channel_input(QIO_CHANNEL(ioc)); - migration_incoming_state_new(f); ret =3D qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { @@ -2215,6 +2214,7 @@ int load_vmstate(const char *name) QEMUFile *f; int ret; AioContext *aio_context; + MigrationIncomingState *mis =3D migration_incoming_get_current(); if (!bdrv_all_can_snapshot(&bs)) { error_report("Device '%s' is writable but does not support snapsho= ts.", @@ -2265,7 +2265,7 @@ int load_vmstate(const char *name) } qemu_system_reset(VMRESET_SILENT); - migration_incoming_state_new(f); + mis->from_src_file =3D f; aio_context_acquire(aio_context); ret =3D qemu_loadvm_state(f); --=20 2.7.4 From nobody Fri May 3 06:47:41 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 1486400047610198.53451994333182; Mon, 6 Feb 2017 08:54:07 -0800 (PST) Received: from localhost ([::1]:49506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camYI-0005Nw-3v for importer@patchew.org; Mon, 06 Feb 2017 11:54:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWO-00047U-7g for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWN-0005kp-EE for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48420) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWN-0005kU-5i for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:07 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4868C80F9B for ; Mon, 6 Feb 2017 16:52:07 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Mm021125; Mon, 6 Feb 2017 11:52:06 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:45 +0100 Message-Id: <1486399909-16338-3-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Feb 2017 16:52:07 +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 2/6] vmstate_register_with_alias_id: Take an Error ** 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: amit.shah@redhat.com, dgilbert@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" From: "Dr. David Alan Gilbert" I'll be adding an error to it in a subsequent patch. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Message-Id: <20170202125956.21942-2-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- hw/core/qdev.c | 3 ++- hw/intc/apic_common.c | 2 +- include/migration/vmstate.h | 5 +++-- migration/savevm.c | 3 ++- stubs/vmstate.c | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 5783442..ea97b15 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -935,7 +935,8 @@ static void device_set_realized(Object *obj, bool value= , Error **errp) if (qdev_get_vmsd(dev)) { vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), de= v, dev->instance_id_alias, - dev->alias_required_for_version= ); + dev->alias_required_for_version, + NULL); } QLIST_FOREACH(bus, &dev->child_bus, sibling) { diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 17df24c..6ce8ef7 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -329,7 +329,7 @@ static void apic_common_realize(DeviceState *dev, Error= **errp) instance_id =3D -1; } vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common, - s, -1, 0); + s, -1, 0, NULL); } static void apic_common_unrealize(DeviceState *dev, Error **errp) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 3bbe3ed..c38b00a 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -988,14 +988,15 @@ bool vmstate_save_needed(const VMStateDescription *vm= sd, void *opaque); int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *base, int alias_id, - int required_for_version); + int required_for_version, + Error **errp); static inline int vmstate_register(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque) { return vmstate_register_with_alias_id(dev, instance_id, vmsd, - opaque, -1, 0); + opaque, -1, 0, NULL); } void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, diff --git a/migration/savevm.c b/migration/savevm.c index f3644ca..b11b4a2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -656,7 +656,8 @@ void unregister_savevm(DeviceState *dev, const char *id= str, void *opaque) int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque, int alias_id, - int required_for_version) + int required_for_version, + Error **errp) { SaveStateEntry *se; diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6590627..bbe158f 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -8,7 +8,8 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *base, int alias_id, - int required_for_version) + int required_for_version, + Error **errp) { return 0; } --=20 2.7.4 From nobody Fri May 3 06:47:41 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 1486400316994457.11528220245566; Mon, 6 Feb 2017 08:58:36 -0800 (PST) Received: from localhost ([::1]:49530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camcd-0000wc-Lr for importer@patchew.org; Mon, 06 Feb 2017 11:58:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWP-00048Z-OZ for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWP-0005lk-19 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWO-0005l9-OT for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:08 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5C40C04B311 for ; Mon, 6 Feb 2017 16:52:08 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Mn021125; Mon, 6 Feb 2017 11:52:07 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:46 +0100 Message-Id: <1486399909-16338-4-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 06 Feb 2017 16:52:08 +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 3/6] migration: Check for ID length 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: amit.shah@redhat.com, dgilbert@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" From: "Dr. David Alan Gilbert" The qdev id of a device can be huge if it's on the end of a chain of bridges; in reality such chains shouldn't occur but they can be made to by chaining PCIe bridges together. The migration format has a number of 256 character long format limits; check we don't hit them (we already use pstrcat/cpy but that just protects us from buffer overruns, we fairly quickly hit an assert). Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Message-Id: <20170202125956.21942-3-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- include/migration/vmstate.h | 2 ++ migration/savevm.c | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index c38b00a..6233fe2 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -985,12 +985,14 @@ void vmstate_save_state(QEMUFile *f, const VMStateDes= cription *vmsd, bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); +/* Returns: 0 on success, -1 on failure */ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *base, int alias_id, int required_for_version, Error **errp); +/* Returns: 0 on success, -1 on failure */ static inline int vmstate_register(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, void *opaque) diff --git a/migration/savevm.c b/migration/savevm.c index b11b4a2..8b8c74d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -590,8 +590,14 @@ int register_savevm_live(DeviceState *dev, if (dev) { char *id =3D qdev_get_dev_path(dev); if (id) { - pstrcpy(se->idstr, sizeof(se->idstr), id); - pstrcat(se->idstr, sizeof(se->idstr), "/"); + if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >=3D + sizeof(se->idstr)) { + error_report("Path too long for VMState (%s)", id); + g_free(id); + g_free(se); + + return -1; + } g_free(id); se->compat =3D g_new0(CompatEntry, 1); @@ -674,9 +680,14 @@ int vmstate_register_with_alias_id(DeviceState *dev, i= nt instance_id, if (dev) { char *id =3D qdev_get_dev_path(dev); if (id) { - pstrcpy(se->idstr, sizeof(se->idstr), id); - pstrcat(se->idstr, sizeof(se->idstr), "/"); - g_free(id); + if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >=3D + sizeof(se->idstr)) { + error_setg(errp, "Path too long for VMState (%s)", id); + g_free(id); + g_free(se); + + return -1; + } se->compat =3D g_new0(CompatEntry, 1); pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->na= me); --=20 2.7.4 From nobody Fri May 3 06:47:41 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 1486400302228415.13803902643815; Mon, 6 Feb 2017 08:58:22 -0800 (PST) Received: from localhost ([::1]:49528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camcO-0000kT-U3 for importer@patchew.org; Mon, 06 Feb 2017 11:58:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWQ-0004B2-WA for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWQ-0005mK-Am for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57858) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWQ-0005lx-5b for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:10 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C1DBC01C107 for ; Mon, 6 Feb 2017 16:52:10 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Mo021125; Mon, 6 Feb 2017 11:52:09 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:47 +0100 Message-Id: <1486399909-16338-5-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 06 Feb 2017 16:52: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 4/6] vmstate registration: check return values 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: amit.shah@redhat.com, dgilbert@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" From: "Dr. David Alan Gilbert" Check qdev's call to vmstate_register_with_alias_id; that gets most of the common uses; there's hundreds of calls via vmstate_register which could get fixed over time. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Message-Id: <20170202125956.21942-4-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- hw/core/qdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index ea97b15..06ba02e 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -933,10 +933,12 @@ static void device_set_realized(Object *obj, bool val= ue, Error **errp) } if (qdev_get_vmsd(dev)) { - vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), de= v, - dev->instance_id_alias, - dev->alias_required_for_version, - NULL); + if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev)= , dev, + dev->instance_id_alias, + dev->alias_required_for_ver= sion, + &local_err) < 0) { + goto post_realize_fail; + } } QLIST_FOREACH(bus, &dev->child_bus, sibling) { --=20 2.7.4 From nobody Fri May 3 06:47:41 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 1486400309313368.84543255647327; Mon, 6 Feb 2017 08:58:29 -0800 (PST) Received: from localhost ([::1]:49529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camcV-0000q5-QP for importer@patchew.org; Mon, 06 Feb 2017 11:58:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWS-0004GJ-He for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWR-0005n6-TA for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWR-0005mi-NT for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:11 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D02FF8046C for ; Mon, 6 Feb 2017 16:52:11 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Mp021125; Mon, 6 Feb 2017 11:52:10 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:48 +0100 Message-Id: <1486399909-16338-6-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Feb 2017 16:52:11 +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 5/6] Postcopy: Reset state to avoid cleanup assert 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: amit.shah@redhat.com, dgilbert@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" From: "Dr. David Alan Gilbert" On a destination host with no userfault support an incoming postcopy would cause the state to enter ADVISE before it realised there was no support, and because it was in ADVISE state it would perform a cleanup at the end. Since there was no support the cleanup function should be unreachable, but ends up being called and asserting. Reset the state when we realise we have no support, thus the cleanup doesn't happen. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20170202155909.31784-2-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/savevm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/savevm.c b/migration/savevm.c index 8b8c74d..0199768 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1355,6 +1355,7 @@ static int loadvm_postcopy_handle_advise(MigrationInc= omingState *mis) } if (!postcopy_ram_supported_by_host()) { + postcopy_state_set(POSTCOPY_INCOMING_NONE); return -1; } --=20 2.7.4 From nobody Fri May 3 06:47:41 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 1486400080764638.2485869663284; Mon, 6 Feb 2017 08:54:40 -0800 (PST) Received: from localhost ([::1]:49509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camYp-0005qY-7P for importer@patchew.org; Mon, 06 Feb 2017 11:54:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1camWU-0004IB-Aq for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1camWT-0005nm-Ek for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1camWT-0005nO-8W for qemu-devel@nongnu.org; Mon, 06 Feb 2017 11:52:13 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55CEE51469 for ; Mon, 6 Feb 2017 16:52:13 +0000 (UTC) Received: from emacs.mitica (ovpn-116-74.ams2.redhat.com [10.36.116.74]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16Gq2Mq021125; Mon, 6 Feb 2017 11:52:12 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 17:51:49 +0100 Message-Id: <1486399909-16338-7-git-send-email-quintela@redhat.com> In-Reply-To: <1486399909-16338-1-git-send-email-quintela@redhat.com> References: <1486399909-16338-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 06 Feb 2017 16:52:13 +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 6/6] postcopy: Recover block devices on early failure 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: amit.shah@redhat.com, dgilbert@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" From: "Dr. David Alan Gilbert" An early postcopy failure can be recovered from as long as we know we haven't sent the command to run the destination. We have to undo the bdrv_inactivate_all by calling bdrv_invalidate_cache_all Note that I'm not using ms->block_inactive because once we've sent the postcopy package we dont want anything else to try and recover the block storage on the source; the destination might have started writing to it. Signed-off-by: Dr. David Alan Gilbert Message-Id: <20170202155909.31784-3-dgilbert@redhat.com> Signed-off-by: Juan Quintela --- migration/migration.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 619ccc4..2b179c6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1601,6 +1601,7 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) QIOChannelBuffer *bioc; QEMUFile *fb; int64_t time_at_stop =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + bool restart_block =3D false; migrate_set_state(&ms->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_POSTCOPY_ACTIVE); @@ -1620,6 +1621,7 @@ static int postcopy_start(MigrationState *ms, bool *o= ld_vm_running) if (ret < 0) { goto fail; } + restart_block =3D true; /* * Cause any non-postcopiable, but iterative devices to @@ -1676,6 +1678,18 @@ static int postcopy_start(MigrationState *ms, bool *= old_vm_running) /* <><> end of stuff going into the package */ + /* Last point of recovery; as soon as we send the package the destinat= ion + * can open devices and potentially start running. + * Lets just check again we've not got any errors. + */ + ret =3D qemu_file_get_error(ms->to_dst_file); + if (ret) { + error_report("postcopy_start: Migration stream errored (pre packag= e)"); + goto fail_closefb; + } + + restart_block =3D false; + /* Now send that blob */ if (qemu_savevm_send_packaged(ms->to_dst_file, bioc->data, bioc->usage= )) { goto fail_closefb; @@ -1713,6 +1727,17 @@ fail_closefb: fail: migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, MIGRATION_STATUS_FAILED); + if (restart_block) { + /* A failure happened early enough that we know the destination ha= sn't + * accessed block devices, so we're safe to recover. + */ + Error *local_err =3D NULL; + + bdrv_invalidate_cache_all(&local_err); + if (local_err) { + error_report_err(local_err); + } + } qemu_mutex_unlock_iothread(); return -1; } --=20 2.7.4