From nobody Sun May 5 19:21:15 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 1495176306959139.28850721333788; Thu, 18 May 2017 23:45:06 -0700 (PDT) Received: from localhost ([::1]:56841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbep-0001Ff-1i for importer@patchew.org; Fri, 19 May 2017 02:45:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdc-0000Wg-A8 for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbdb-00049L-9w for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdb-00049H-0j for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:47 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDAB87F4A3 for ; Fri, 19 May 2017 06:43:45 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id C28CE17196; Fri, 19 May 2017 06:43:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DDAB87F4A3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DDAB87F4A3 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:27 +0800 Message-Id: <1495176212-14446-2-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 19 May 2017 06:43:46 +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 RFC 1/6] io: only allow return path for socket typed 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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 don't really have a return path for the other types yet. Let's check this when .get_return_path() is called. For this, we introduce a new feature bit, and set it up only for socket typed IO channels. This will help detect earlier failure for postcopy, e.g., logically speaking postcopy cannot work with "exec:". Before this patch, when we try to migrate with "migrate -d exec:cat>out", we'll hang the system. With this patch, we'll get: (qemu) migrate -d exec:cat>out Unable to open return-path for postcopy CC: Daniel P. Berrange Signed-off-by: Peter Xu --- include/io/channel.h | 1 + io/channel-socket.c | 1 + migration/qemu-file-channel.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index db9bb02..7876534 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -45,6 +45,7 @@ enum QIOChannelFeature { QIO_CHANNEL_FEATURE_FD_PASS, QIO_CHANNEL_FEATURE_SHUTDOWN, QIO_CHANNEL_FEATURE_LISTEN, + QIO_CHANNEL_FEATURE_RETURN_PATH, }; =20 =20 diff --git a/io/channel-socket.c b/io/channel-socket.c index 53386b7..ee81b2d 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -56,6 +56,7 @@ qio_channel_socket_new(void) =20 ioc =3D QIO_CHANNEL(sioc); qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); + qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_RETURN_PATH); =20 #ifdef WIN32 ioc->event =3D CreateEvent(NULL, FALSE, FALSE, NULL); diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index 45c13f1..3bd7940 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qom/object.h" #include "migration/qemu-file.h" #include "io/channel-socket.h" #include "qemu/iov.h" @@ -139,6 +140,10 @@ static QEMUFile *channel_get_input_return_path(void *o= paque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); =20 + if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_RETURN_PATH)) { + return NULL; + } + return qemu_fopen_channel_output(ioc); } =20 @@ -146,6 +151,10 @@ static QEMUFile *channel_get_output_return_path(void *= opaque) { QIOChannel *ioc =3D QIO_CHANNEL(opaque); =20 + if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_RETURN_PATH)) { + return NULL; + } + return qemu_fopen_channel_input(ioc); } =20 --=20 2.7.4 From nobody Sun May 5 19:21:15 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 1495176315054177.21876534439457; Thu, 18 May 2017 23:45:15 -0700 (PDT) Received: from localhost ([::1]:56842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbez-0001OG-Ky for importer@patchew.org; Fri, 19 May 2017 02:45:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdg-0000YX-HJ for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbdf-00049l-Dt for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdf-00049g-5L for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18D5A796E4 for ; Fri, 19 May 2017 06:43:50 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id BED055C546; Fri, 19 May 2017 06:43:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18D5A796E4 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 18D5A796E4 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:28 +0800 Message-Id: <1495176212-14446-3-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 19 May 2017 06:43:50 +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 RFC 2/6] migration: isolate return path on src 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" There are some places that binded "return path" with postcopy. Let's be prepared for its usage even without postcopy. This patch mainly did this on source side. This has no functional change. But it'll simplify further patches. Signed-off-by: Peter Xu --- migration/migration.c | 50 +++++++++++++++++++++++++++++++++++-----------= ---- migration/trace-events | 4 ++-- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0304c01..e4f4c8c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1817,13 +1817,12 @@ static void migration_completion(MigrationState *s,= int current_active_state, * cleaning everything else up (since if there are no failures * it will wait for the destination to send it's status in * a SHUT command). - * Postcopy opens rp if enabled (even if it's not avtivated) */ - if (migrate_postcopy_ram()) { + if (s->rp_state.from_dst_file) { int rp_error; - trace_migration_completion_postcopy_end_before_rp(); + trace_migration_return_path_end_before(); rp_error =3D await_return_path_close_on_source(s); - trace_migration_completion_postcopy_end_after_rp(rp_error); + trace_migration_return_path_end_after(rp_error); if (rp_error) { goto fail_invalidate; } @@ -1898,13 +1897,15 @@ static void *migration_thread(void *opaque) =20 qemu_savevm_state_header(s->to_dst_file); =20 - if (migrate_postcopy_ram()) { + if (s->to_dst_file) { /* Now tell the dest that it should open its end so it can reply */ qemu_savevm_send_open_return_path(s->to_dst_file); =20 /* And do a ping that will make stuff easier to debug */ qemu_savevm_send_ping(s->to_dst_file, 1); + } =20 + if (migrate_postcopy_ram()) { /* * Tell the destination that we *might* want to do postcopy later; * if the other end can't do postcopy it should fail now, nice and @@ -2044,6 +2045,29 @@ static void *migration_thread(void *opaque) return NULL; } =20 +/* Return true if success, otherwise false. */ +static bool migrate_return_path_create(MigrationState *s) +{ + /* Whether we should enable return path */ + bool enable_return_path =3D false; + /* Whether we should force its success */ + bool force_return_path =3D false; + + if (migrate_postcopy_ram()) { + enable_return_path =3D true; + force_return_path =3D true; + } + + if (enable_return_path) { + if (open_return_path_on_source(s) && force_return_path) { + error_report("Unable to open return-path"); + return false; + } + } + + return true; +} + void migrate_fd_connect(MigrationState *s) { s->expected_downtime =3D s->parameters.downtime_limit; @@ -2057,17 +2081,13 @@ void migrate_fd_connect(MigrationState *s) notifier_list_notify(&migration_state_notifiers, s); =20 /* - * Open the return path; currently for postcopy but other things might - * also want it. + * Open the return path. */ - if (migrate_postcopy_ram()) { - if (open_return_path_on_source(s)) { - error_report("Unable to open return-path for postcopy"); - migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, - MIGRATION_STATUS_FAILED); - migrate_fd_cleanup(s); - return; - } + if (!migrate_return_path_create(s)) { + migrate_set_state(&s->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_FAILED); + migrate_fd_cleanup(s); + return; } =20 migrate_compress_threads_create(); diff --git a/migration/trace-events b/migration/trace-events index 5b8ccf3..38345be 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -88,8 +88,8 @@ migrate_send_rp_message(int msg_type, uint16_t len) "%d: = len %d" migration_completion_file_err(void) "" migration_completion_postcopy_end(void) "" migration_completion_postcopy_end_after_complete(void) "" -migration_completion_postcopy_end_before_rp(void) "" -migration_completion_postcopy_end_after_rp(int rp_error) "%d" +migration_return_path_end_before(void) "" +migration_return_path_end_after(int rp_error) "%d" migration_thread_after_loop(void) "" migration_thread_file_err(void) "" migration_thread_setup_complete(void) "" --=20 2.7.4 From nobody Sun May 5 19:21:15 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 1495176322627424.19070872731095; Thu, 18 May 2017 23:45:22 -0700 (PDT) Received: from localhost ([::1]:56845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbf7-0001UO-6G for importer@patchew.org; Fri, 19 May 2017 02:45:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdn-0000dY-Ig for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbdj-0004A5-Lb for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdj-0004A1-G9 for qemu-devel@nongnu.org; Fri, 19 May 2017 02:43:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B5407D4E3 for ; Fri, 19 May 2017 06:43:54 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF9D35C546; Fri, 19 May 2017 06:43:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7B5407D4E3 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7B5407D4E3 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:29 +0800 Message-Id: <1495176212-14446-4-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 19 May 2017 06:43:54 +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 RFC 3/6] migration: fix leak of src file on dst 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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 return path channel is possibly leaked. Fix it. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- migration/migration.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index e4f4c8c..92617fc 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -130,6 +130,11 @@ void migration_incoming_state_destroy(void) { struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); =20 + if (mis->to_src_file) { + qemu_fclose(mis->to_src_file); + mis->to_src_file =3D NULL; + } + qemu_event_destroy(&mis->main_thread_load_event); loadvm_free_handlers(mis); } --=20 2.7.4 From nobody Sun May 5 19:21:15 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 149517645161128.485467595733212; Thu, 18 May 2017 23:47:31 -0700 (PDT) Received: from localhost ([::1]:56855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbhC-0003B6-0I for importer@patchew.org; Fri, 19 May 2017 02:47:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdp-0000f7-Ky for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbdo-0004Bh-PO for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42384) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdo-0004B2-Iy for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EA48C057FA8 for ; Fri, 19 May 2017 06:43:59 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44FE15C546; Fri, 19 May 2017 06:43:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7EA48C057FA8 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7EA48C057FA8 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:30 +0800 Message-Id: <1495176212-14446-5-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 19 May 2017 06:43:59 +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 RFC 4/6] migration: shut src return path unconditionally 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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 were do the shutting off only for postcopy. Now we do this as long as the source return path is there. Moving the cleanup of from_src_file there too. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/migration.c | 8 +++++++- migration/postcopy-ram.c | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 92617fc..a4006b4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -131,10 +131,17 @@ void migration_incoming_state_destroy(void) struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); =20 if (mis->to_src_file) { + /* Tell source that we are done */ + migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) = !=3D 0); qemu_fclose(mis->to_src_file); mis->to_src_file =3D NULL; } =20 + if (mis->from_src_file) { + qemu_fclose(mis->from_src_file); + mis->from_src_file =3D NULL; + } + qemu_event_destroy(&mis->main_thread_load_event); loadvm_free_handlers(mis); } @@ -433,7 +440,6 @@ static void process_incoming_migration_co(void *opaque) exit(EXIT_FAILURE); } =20 - qemu_fclose(f); free_xbzrle_decoded_buf(); =20 mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a0489f6..57aa208 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -320,7 +320,6 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingStat= e *mis) } =20 postcopy_state_set(POSTCOPY_INCOMING_END); - migrate_send_rp_shut(mis, qemu_file_get_error(mis->from_src_file) !=3D= 0); =20 if (mis->postcopy_tmp_page) { munmap(mis->postcopy_tmp_page, mis->largest_page_size); --=20 2.7.4 From nobody Sun May 5 19:21:15 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 1495176440554771.2433481967757; Thu, 18 May 2017 23:47:20 -0700 (PDT) Received: from localhost ([::1]:56854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbh1-00032n-14 for importer@patchew.org; Fri, 19 May 2017 02:47:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdt-0000iB-6p for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbds-0004EN-3o for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdr-0004Dn-RN for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3F547F4A2 for ; Fri, 19 May 2017 06:44:02 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A0045C884; Fri, 19 May 2017 06:43:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C3F547F4A2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C3F547F4A2 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:31 +0800 Message-Id: <1495176212-14446-6-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 19 May 2017 06:44:02 +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 RFC 5/6] migration: let MigrationState be an QObject 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" Let the old man "MigrationState" join the object family. Direct benefit is that we can start to use all the property features derived from current QObject, like: HW_COMPAT_* bits, command line setup for migration parameters (so will never need to set them up each time using HMP/QMP, this is really, really attractive for test writters), etc. I see no reason to disallow this happen yet. So let's start from this one, to see whether it would be anything good. No functional change at all. Signed-off-by: Peter Xu --- include/migration/migration.h | 24 +++++++++++++++--- include/qemu/typedefs.h | 1 - migration/migration.c | 57 +++++++++++++++++++++++++++++----------= ---- 3 files changed, 60 insertions(+), 22 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 49ec501..70710de 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -22,6 +22,7 @@ #include "qapi-types.h" #include "exec/cpu-common.h" #include "qemu/coroutine_int.h" +#include "hw/qdev.h" =20 #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 @@ -102,8 +103,25 @@ struct MigrationIncomingState { MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); =20 -struct MigrationState -{ +#define TYPE_MIGRATION "migration" + +#define MIGRATION_CLASS(klass) \ + OBJECT_CLASS_CHECK(MigrationClass, (klass), TYPE_MIGRATION) +#define MIGRATION_OBJ(obj) \ + OBJECT_CHECK(MigrationState, (obj), TYPE_MIGRATION) +#define MIGRATION_GET_CLASS(obj) \ + OBJECT_GET_CLASS(MigrationClass, (obj), TYPE_MIGRATION) + +typedef struct MigrationClass { + /*< private >*/ + DeviceClass parent_class; +} MigrationClass; + +typedef struct MigrationState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ size_t bytes_xfer; size_t xfer_limit; QemuThread thread; @@ -153,7 +171,7 @@ struct MigrationState =20 /* The last error that occurred */ Error *error; -}; +} MigrationState ; =20 void migrate_set_state(int *state, int old_state, int new_state); =20 diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 7d85057..95a382e 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -50,7 +50,6 @@ typedef struct MemoryRegionCache MemoryRegionCache; typedef struct MemoryRegionSection MemoryRegionSection; typedef struct MigrationIncomingState MigrationIncomingState; typedef struct MigrationParams MigrationParams; -typedef struct MigrationState MigrationState; typedef struct Monitor Monitor; typedef struct MonitorDef MonitorDef; typedef struct MouseTransformInfo MouseTransformInfo; diff --git a/migration/migration.c b/migration/migration.c index a4006b4..6df3483 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -86,28 +86,14 @@ static bool deferred_incoming; MigrationState *migrate_get_current(void) { static bool once; - static MigrationState current_migration =3D { - .state =3D MIGRATION_STATUS_NONE, - .xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE, - .mbps =3D -1, - .parameters =3D { - .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, - .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, - .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUN= T, - .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, - .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_INCRE= MENT, - .max_bandwidth =3D MAX_THROTTLE, - .downtime_limit =3D DEFAULT_MIGRATE_SET_DOWNTIME, - .x_checkpoint_delay =3D DEFAULT_MIGRATE_X_CHECKPOINT_DELAY, - }, - }; + static MigrationState *current_migration; =20 if (!once) { - current_migration.parameters.tls_creds =3D g_strdup(""); - current_migration.parameters.tls_hostname =3D g_strdup(""); + current_migration =3D MIGRATION_OBJ(object_new(TYPE_MIGRATION)); once =3D true; } - return ¤t_migration; + + return current_migration; } =20 MigrationIncomingState *migration_incoming_get_current(void) @@ -2107,3 +2093,38 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running =3D true; } =20 +static void migration_instance_init(Object *obj) +{ + MigrationState *ms =3D MIGRATION_OBJ(obj); + + ms->state =3D MIGRATION_STATUS_NONE; + ms->xbzrle_cache_size =3D DEFAULT_MIGRATE_CACHE_SIZE; + ms->mbps =3D -1; + ms->parameters =3D (MigrationParameters) { + .compress_level =3D DEFAULT_MIGRATE_COMPRESS_LEVEL, + .compress_threads =3D DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT, + .decompress_threads =3D DEFAULT_MIGRATE_DECOMPRESS_THREAD_COUNT, + .cpu_throttle_initial =3D DEFAULT_MIGRATE_CPU_THROTTLE_INITIAL, + .cpu_throttle_increment =3D DEFAULT_MIGRATE_CPU_THROTTLE_INCREMENT, + .max_bandwidth =3D MAX_THROTTLE, + .downtime_limit =3D DEFAULT_MIGRATE_SET_DOWNTIME, + .x_checkpoint_delay =3D DEFAULT_MIGRATE_X_CHECKPOINT_DELAY, + }; + ms->parameters.tls_creds =3D g_strdup(""); + ms->parameters.tls_hostname =3D g_strdup(""); +} + +static const TypeInfo migration_type =3D { + .name =3D TYPE_MIGRATION, + .parent =3D TYPE_DEVICE, + .class_size =3D sizeof(MigrationClass), + .instance_size =3D sizeof(MigrationState), + .instance_init =3D migration_instance_init, +}; + +static void register_migration_types(void) +{ + type_register_static(&migration_type); +} + +type_init(register_migration_types); --=20 2.7.4 From nobody Sun May 5 19:21:15 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 1495176528915927.3934707977213; Thu, 18 May 2017 23:48:48 -0700 (PDT) Received: from localhost ([::1]:56858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbiQ-0004LZ-It for importer@patchew.org; Fri, 19 May 2017 02:48:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBbdx-0000ll-IF for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBbdw-0004Ej-7y for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBbdv-0004Ee-V5 for qemu-devel@nongnu.org; Fri, 19 May 2017 02:44:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD856C056782 for ; Fri, 19 May 2017 06:44:06 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id A66845C546; Fri, 19 May 2017 06:44:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DD856C056782 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=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DD856C056782 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 14:43:32 +0800 Message-Id: <1495176212-14446-7-git-send-email-peterx@redhat.com> In-Reply-To: <1495176212-14446-1-git-send-email-peterx@redhat.com> References: <1495176212-14446-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 19 May 2017 06:44: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] [PATCH RFC 6/6] migration: enable return path for precopy 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: "Dr . David Alan Gilbert" , peterx@redhat.com, Juan Quintela 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" Let this be a flag, default to on. Turn it off for <=3D2.9 versions. After this patch, return path will be on even for pre-copy migration as long as the transport support, e.g., for socket typed transport including "tcp|udp|unix" typed. This will naturally fix the bug mentioned below, when destination failed on migration but source assumed it was successful - since now even for precopy, source will wait for destination's MIG_RP_MSG_SHUT signal, which will carry the final migration status of destination. Then, when destination failed at any point of migration, source will know it, and it'll resume the VM instead of a data lost. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D1439147 Signed-off-by: Peter Xu --- include/hw/compat.h | 4 ++++ include/migration/migration.h | 3 +++ migration/migration.c | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 55b1765..049457b 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -6,6 +6,10 @@ .driver =3D "pci-bridge",\ .property =3D "shpc",\ .value =3D "off",\ + },{\ + .driver =3D "migration",\ + .property =3D "return-path",\ + .value =3D "off",\ }, =20 #define HW_COMPAT_2_8 \ diff --git a/include/migration/migration.h b/include/migration/migration.h index 70710de..e44119c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -169,6 +169,9 @@ typedef struct MigrationState { int64_t colo_checkpoint_time; QEMUTimer *colo_delay_timer; =20 + /* Whether to try to enable return-path even for pre-copy */ + bool enable_return_path; + /* The last error that occurred */ Error *error; } MigrationState ; diff --git a/migration/migration.c b/migration/migration.c index 6df3483..16a856a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2046,7 +2046,7 @@ static void *migration_thread(void *opaque) static bool migrate_return_path_create(MigrationState *s) { /* Whether we should enable return path */ - bool enable_return_path =3D false; + bool enable_return_path =3D s->enable_return_path; /* Whether we should force its success */ bool force_return_path =3D false; =20 @@ -2114,9 +2114,22 @@ static void migration_instance_init(Object *obj) ms->parameters.tls_hostname =3D g_strdup(""); } =20 +static Property migration_properties[] =3D { + DEFINE_PROP_BOOL("return-path", MigrationState, enable_return_path, tr= ue), + DEFINE_PROP_END_OF_LIST(), +}; + +static void migration_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(oc); + + dc->props =3D migration_properties; +} + static const TypeInfo migration_type =3D { .name =3D TYPE_MIGRATION, .parent =3D TYPE_DEVICE, + .class_init =3D migration_class_init, .class_size =3D sizeof(MigrationClass), .instance_size =3D sizeof(MigrationState), .instance_init =3D migration_instance_init, --=20 2.7.4