From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530760815095747.1784029209407; Wed, 4 Jul 2018 20:20:15 -0700 (PDT) Received: from localhost ([::1]:50073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauoP-00057J-Gz for importer@patchew.org; Wed, 04 Jul 2018 23:20:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumS-00041b-1S for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumQ-0001ZD-Sa for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:04 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47282 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumQ-0001Yh-Ht for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:02 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3916281A4EAD for ; Thu, 5 Jul 2018 03:18:02 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46B222156889; Thu, 5 Jul 2018 03:17:59 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:47 +0800 Message-Id: <20180705031755.3254-2-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 1/9] migration: simplify check to use qemu file buffer 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" Firstly, renaming the old matching_page_sizes variable to matching_target_page_size, which suites more to what it did (it only checks against target page size rather than multiple page sizes). Meanwhile, simplify the check logic a bit, and enhance the comments. Should have no functional change. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/ram.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 23cea47090..fbeb23f750 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3580,7 +3580,7 @@ static int ram_load_postcopy(QEMUFile *f) { int flags =3D 0, ret =3D 0; bool place_needed =3D false; - bool matching_page_sizes =3D false; + bool matching_target_page_size =3D false; MigrationIncomingState *mis =3D migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page =3D postcopy_get_tmp_page(mis); @@ -3620,7 +3620,7 @@ static int ram_load_postcopy(QEMUFile *f) ret =3D -EINVAL; break; } - matching_page_sizes =3D block->page_size =3D=3D TARGET_PAGE_SI= ZE; + matching_target_page_size =3D block->page_size =3D=3D TARGET_P= AGE_SIZE; /* * Postcopy requires that we place whole host pages atomically; * these may be huge pages for RAMBlocks that are backed by @@ -3668,12 +3668,17 @@ static int ram_load_postcopy(QEMUFile *f) =20 case RAM_SAVE_FLAG_PAGE: all_zero =3D false; - if (!place_needed || !matching_page_sizes) { + if (!matching_target_page_size) { + /* For huge pages, we always use temporary buffer */ qemu_get_buffer(f, page_buffer, TARGET_PAGE_SIZE); } else { - /* Avoids the qemu_file copy during postcopy, which is - * going to do a copy later; can only do it when we - * do this read in one go (matching page sizes) + /* + * For small pages that matches target page size, we + * avoid the qemu_file copy. Instead we directly use + * the buffer of QEMUFile to place the page. Note: we + * cannot do any QEMUFile operation before using that + * buffer to make sure the buffer is valid when + * placing the page. */ qemu_get_buffer_in_place(f, (uint8_t **)&place_source, TARGET_PAGE_SIZE); --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15307609536706.99349856424908; Wed, 4 Jul 2018 20:22:33 -0700 (PDT) Received: from localhost ([::1]:50090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauqm-0007KM-T8 for importer@patchew.org; Wed, 04 Jul 2018 23:22:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumU-00042F-6m for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumT-0001dq-8S for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47294 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumT-0001co-46 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:05 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBC9F81A4EAD for ; Thu, 5 Jul 2018 03:18:04 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCCE02156889; Thu, 5 Jul 2018 03:18:02 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:48 +0800 Message-Id: <20180705031755.3254-3-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:04 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 2/9] migration: loosen recovery check when load vm 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 checking against -EIO, assuming that it will cover all IO failures. But actually it is not. One example is that in qemu_loadvm_section_start_full() we can have tons of places that will return -EINVAL even if the error is caused by IO failures on the network. Let's loosen the recovery check logic here to cover all the error cases happened by removing the explicit check against -EIO. After all we won't lose anything here if any other failure happened. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/savevm.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 851d74e8b6..efcc795071 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2276,18 +2276,14 @@ out: qemu_file_set_error(f, ret); =20 /* - * Detect whether it is: - * - * 1. postcopy running (after receiving all device data, which - * must be in POSTCOPY_INCOMING_RUNNING state. Note that - * POSTCOPY_INCOMING_LISTENING is still not enough, it's - * still receiving device states). - * 2. network failure (-EIO) - * - * If so, we try to wait for a recovery. + * If we are during an active postcopy, then we pause instead + * of bail out to at least keep the VM's dirty data. Note + * that POSTCOPY_INCOMING_LISTENING stage is still not enough, + * during which we're still receiving device states and we + * still haven't yet started the VM on destination. */ if (postcopy_state_get() =3D=3D POSTCOPY_INCOMING_RUNNING && - ret =3D=3D -EIO && postcopy_pause_incoming(mis)) { + postcopy_pause_incoming(mis)) { /* Reset f to point to the newly created channel */ f =3D mis->from_src_file; goto retry; --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530760814320588.280119560629; Wed, 4 Jul 2018 20:20:14 -0700 (PDT) Received: from localhost ([::1]:50074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauoX-0005Lk-Gq for importer@patchew.org; Wed, 04 Jul 2018 23:20:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumX-00044b-31 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumV-0001l8-To for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47296 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumV-0001jk-Oz for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EE0781A4EAD for ; Thu, 5 Jul 2018 03:18:07 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E7852166BA9; Thu, 5 Jul 2018 03:18:05 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:49 +0800 Message-Id: <20180705031755.3254-4-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 3/9] migration: fix incorrect bitmap size calculation 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 calculation on size of received bitmap is incorrect for postcopy recovery. Here we wanted to let the size to cover all the valid bits in the bitmap, we should use DIV_ROUND_UP() instead of a division. For example, a RAMBlock with size=3D4K (which contains only one single 4K page) will have nbits=3D1, then nbits/8=3D0, then the real bitmap won't be sent to source at all. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- migration/ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fbeb23f750..203c691ded 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -235,7 +235,7 @@ int64_t ramblock_recv_bitmap_send(QEMUFile *file, bitmap_to_le(le_bitmap, block->receivedmap, nbits); =20 /* Size of the bitmap, in bytes */ - size =3D nbits / 8; + size =3D DIV_ROUND_UP(nbits, 8); =20 /* * size is always aligned to 8 bytes for 64bit machines, but it @@ -3944,7 +3944,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlo= ck *block) int ret =3D -EINVAL; QEMUFile *file =3D s->rp_state.from_dst_file; unsigned long *le_bitmap, nbits =3D block->used_length >> TARGET_PAGE_= BITS; - uint64_t local_size =3D nbits / 8; + uint64_t local_size =3D DIV_ROUND_UP(nbits, 8); uint64_t size, end_mark; =20 trace_ram_dirty_bitmap_reload_begin(block->idstr); --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153076107349892.19774349314787; Wed, 4 Jul 2018 20:24:33 -0700 (PDT) Received: from localhost ([::1]:50099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fausi-0000Qk-RW for importer@patchew.org; Wed, 04 Jul 2018 23:24:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauma-00048s-B4 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumY-0001qr-AW for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47298 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumY-0001pi-5W for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D4CDB81A4EAD for ; Thu, 5 Jul 2018 03:18:09 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49502156889; Thu, 5 Jul 2018 03:18:07 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:50 +0800 Message-Id: <20180705031755.3254-5-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:09 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 4/9] tests: introduce migrate_postcopy_* helpers 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" Separate the old postcopy UNIX socket test into three steps, provide a helper for each step. With these helpers, we can do more compliated tests like postcopy recovery, while keep the codes shared. Signed-off-by: Peter Xu Reviewed-by: Balamuruhan S Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 3a85446f95..2155869b96 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -351,13 +351,19 @@ static void migrate(QTestState *who, const char *uri) qobject_unref(rsp); } =20 -static void migrate_start_postcopy(QTestState *who) +static void migrate_postcopy_start(QTestState *from, QTestState *to) { QDict *rsp; =20 - rsp =3D wait_command(who, "{ 'execute': 'migrate-start-postcopy' }"); + rsp =3D wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); g_assert(qdict_haskey(rsp, "return")); qobject_unref(rsp); + + if (!got_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + + qtest_qmp_eventwait(to, "RESUME"); } =20 static void test_migrate_start(QTestState **from, QTestState **to, @@ -505,7 +511,8 @@ static void test_deprecated(void) qtest_quit(from); } =20 -static void test_postcopy(void) +static void migrate_postcopy_prepare(QTestState **from_ptr, + QTestState **to_ptr) { char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; @@ -527,28 +534,37 @@ static void test_postcopy(void) wait_for_serial("src_serial"); =20 migrate(from, uri); + g_free(uri); =20 wait_for_migration_pass(from); =20 - migrate_start_postcopy(from); - - if (!got_stop) { - qtest_qmp_eventwait(from, "STOP"); - } + *from_ptr =3D from; + *to_ptr =3D to; +} =20 - qtest_qmp_eventwait(to, "RESUME"); +static void migrate_postcopy_complete(QTestState *from, QTestState *to) +{ + wait_for_migration_complete(from); =20 + /* Make sure we get at least one "B" on destination */ wait_for_serial("dest_serial"); - wait_for_migration_complete(from); =20 if (uffd_feature_thread_id) { read_blocktime(to); } - g_free(uri); =20 test_migrate_end(from, to, true); } =20 +static void test_postcopy(void) +{ + QTestState *from, *to; + + migrate_postcopy_prepare(&from, &to); + migrate_postcopy_start(from, to); + migrate_postcopy_complete(from, to); +} + static void test_baddest(void) { QTestState *from, *to; --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530760949620806.6867509278893; Wed, 4 Jul 2018 20:22:29 -0700 (PDT) Received: from localhost ([::1]:50089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauqi-0007HP-UT for importer@patchew.org; Wed, 04 Jul 2018 23:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumb-0004AO-Ou for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fauma-0001y0-SZ for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54694 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fauma-0001xQ-OT for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66D8A87A6E for ; Thu, 5 Jul 2018 03:18:12 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 775BB2156889; Thu, 5 Jul 2018 03:18:10 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:51 +0800 Message-Id: <20180705031755.3254-6-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 03:18:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Jul 2018 03:18:12 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 5/9] tests: allow migrate() to take extra flags 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" For example, we can pass in '"resume": true' to resume a migration. Signed-off-by: Peter Xu Reviewed-by: Balamuruhan S Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 2155869b96..af82a04789 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -337,14 +337,14 @@ static void migrate_set_capability(QTestState *who, c= onst char *capability, qobject_unref(rsp); } =20 -static void migrate(QTestState *who, const char *uri) +static void migrate(QTestState *who, const char *uri, const char *extra) { QDict *rsp; gchar *cmd; =20 cmd =3D g_strdup_printf("{ 'execute': 'migrate'," - "'arguments': { 'uri': '%s' } }", - uri); + " 'arguments': { 'uri': '%s' %s } }", + uri, extra ? extra : ""); rsp =3D qtest_qmp(who, cmd); g_free(cmd); g_assert(qdict_haskey(rsp, "return")); @@ -533,7 +533,7 @@ static void migrate_postcopy_prepare(QTestState **from_= ptr, /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); =20 - migrate(from, uri); + migrate(from, uri, NULL); g_free(uri); =20 wait_for_migration_pass(from); @@ -573,7 +573,7 @@ static void test_baddest(void) bool failed; =20 test_migrate_start(&from, &to, "tcp:0:0", true); - migrate(from, "tcp:0:0"); + migrate(from, "tcp:0:0", NULL); do { rsp =3D wait_command(from, "{ 'execute': 'query-migrate' }"); rsp_return =3D qdict_get_qdict(rsp, "return"); @@ -615,7 +615,7 @@ static void test_precopy_unix(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); =20 - migrate(from, uri); + migrate(from, uri, NULL); =20 wait_for_migration_pass(from); =20 --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530761070369409.18996220788483; Wed, 4 Jul 2018 20:24:30 -0700 (PDT) Received: from localhost ([::1]:50098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fausf-0000Nb-Mh for importer@patchew.org; Wed, 04 Jul 2018 23:24:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faume-0004DR-N7 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumd-00024N-Ep for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47300 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumd-00023Q-9O for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECD5A81A4EAD for ; Thu, 5 Jul 2018 03:18:14 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 096082166BA9; Thu, 5 Jul 2018 03:18:12 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:52 +0800 Message-Id: <20180705031755.3254-7-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:14 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 6/9] tests: introduce migrate_query*() helpers 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" Introduce helpers to query migration states and use it. Signed-off-by: Peter Xu Reviewed-by: Balamuruhan S Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 64 ++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index af82a04789..1d85ccbef1 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -168,6 +168,37 @@ static QDict *wait_command(QTestState *who, const char= *command) return response; } =20 +/* + * Note: caller is responsible to free the returned object via + * qobject_unref() after use + */ +static QDict *migrate_query(QTestState *who) +{ + QDict *rsp, *rsp_return; + + rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); + rsp_return =3D qdict_get_qdict(rsp, "return"); + g_assert(rsp_return); + qobject_ref(rsp_return); + qobject_unref(rsp); + + return rsp_return; +} + +/* + * Note: caller is responsible to free the returned object via + * g_free() after use + */ +static gchar *migrate_query_status(QTestState *who) +{ + QDict *rsp_return =3D migrate_query(who); + gchar *status =3D g_strdup(qdict_get_str(rsp_return, "status")); + + g_assert(status); + qobject_unref(rsp_return); + + return status; +} =20 /* * It's tricky to use qemu's migration event capability with qtest, @@ -176,11 +207,10 @@ static QDict *wait_command(QTestState *who, const cha= r *command) =20 static uint64_t get_migration_pass(QTestState *who) { - QDict *rsp, *rsp_return, *rsp_ram; + QDict *rsp_return, *rsp_ram; uint64_t result; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); - rsp_return =3D qdict_get_qdict(rsp, "return"); + rsp_return =3D migrate_query(who); if (!qdict_haskey(rsp_return, "ram")) { /* Still in setup */ result =3D 0; @@ -188,33 +218,29 @@ static uint64_t get_migration_pass(QTestState *who) rsp_ram =3D qdict_get_qdict(rsp_return, "ram"); result =3D qdict_get_try_int(rsp_ram, "dirty-sync-count", 0); } - qobject_unref(rsp); + qobject_unref(rsp_return); return result; } =20 static void read_blocktime(QTestState *who) { - QDict *rsp, *rsp_return; + QDict *rsp_return; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); - rsp_return =3D qdict_get_qdict(rsp, "return"); + rsp_return =3D migrate_query(who); g_assert(qdict_haskey(rsp_return, "postcopy-blocktime")); - qobject_unref(rsp); + qobject_unref(rsp_return); } =20 static void wait_for_migration_complete(QTestState *who) { while (true) { - QDict *rsp, *rsp_return; bool completed; - const char *status; + char *status; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate' }"); - rsp_return =3D qdict_get_qdict(rsp, "return"); - status =3D qdict_get_str(rsp_return, "status"); + status =3D migrate_query_status(who); completed =3D strcmp(status, "completed") =3D=3D 0; g_assert_cmpstr(status, !=3D, "failed"); - qobject_unref(rsp); + g_free(status); if (completed) { return; } @@ -569,20 +595,16 @@ static void test_baddest(void) { QTestState *from, *to; QDict *rsp, *rsp_return; - const char *status; + char *status; bool failed; =20 test_migrate_start(&from, &to, "tcp:0:0", true); migrate(from, "tcp:0:0", NULL); do { - rsp =3D wait_command(from, "{ 'execute': 'query-migrate' }"); - rsp_return =3D qdict_get_qdict(rsp, "return"); - - status =3D qdict_get_str(rsp_return, "status"); - + status =3D migrate_query_status(from); g_assert(!strcmp(status, "setup") || !(strcmp(status, "failed"))); failed =3D !strcmp(status, "failed"); - qobject_unref(rsp); + g_free(status); } while (!failed); =20 /* Is the machine currently running? */ --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530760831482425.6749956959886; Wed, 4 Jul 2018 20:20:31 -0700 (PDT) Received: from localhost ([::1]:50075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauoo-0005XF-OL for importer@patchew.org; Wed, 04 Jul 2018 23:20:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumj-0004Hb-8D for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumg-0002BE-1s for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47302 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumf-0002AS-Sy for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80D6A81A4EAD for ; Thu, 5 Jul 2018 03:18:17 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FA6A2156889; Thu, 5 Jul 2018 03:18:15 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:53 +0800 Message-Id: <20180705031755.3254-8-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:17 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 7/9] tests: introduce wait_for_migration_status() 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" It's generalized from wait_for_migration_complete() to allow us to wait for any migration status besides failure. Signed-off-by: Peter Xu Reviewed-by: Balamuruhan S Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 1d85ccbef1..761bf62ffe 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -231,14 +231,15 @@ static void read_blocktime(QTestState *who) qobject_unref(rsp_return); } =20 -static void wait_for_migration_complete(QTestState *who) +static void wait_for_migration_status(QTestState *who, + const char *goal) { while (true) { bool completed; char *status; =20 status =3D migrate_query_status(who); - completed =3D strcmp(status, "completed") =3D=3D 0; + completed =3D strcmp(status, goal) =3D=3D 0; g_assert_cmpstr(status, !=3D, "failed"); g_free(status); if (completed) { @@ -248,6 +249,11 @@ static void wait_for_migration_complete(QTestState *wh= o) } } =20 +static void wait_for_migration_complete(QTestState *who) +{ + wait_for_migration_status(who, "completed"); +} + static void wait_for_migration_pass(QTestState *who) { uint64_t initial_pass =3D get_migration_pass(who); --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530761177537936.028714669868; Wed, 4 Jul 2018 20:26:17 -0700 (PDT) Received: from localhost ([::1]:50110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fauuB-0001XE-GG for importer@patchew.org; Wed, 04 Jul 2018 23:26:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumj-0004I3-Ni for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faumi-0002HX-L2 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47304 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumi-0002GD-FM for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1521581A4EAD for ; Thu, 5 Jul 2018 03:18:20 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24E092156889; Thu, 5 Jul 2018 03:18:17 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:54 +0800 Message-Id: <20180705031755.3254-9-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:20 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 8/9] tests: add postcopy recovery test 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" Test the postcopy recovery procedure by emulating a network failure using migrate-pause command. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/migration-test.c b/tests/migration-test.c index 761bf62ffe..182fc88e93 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -352,6 +352,29 @@ static void migrate_set_parameter(QTestState *who, con= st char *parameter, migrate_check_parameter(who, parameter, value); } =20 +static void migrate_pause(QTestState *who) +{ + QDict *rsp; + + rsp =3D wait_command(who, "{ 'execute': 'migrate-pause' }"); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); +} + +static void migrate_recover(QTestState *who, const char *uri) +{ + QDict *rsp; + gchar *cmd =3D g_strdup_printf( + "{ 'execute': 'migrate-recover', " + " 'id': 'recover-cmd', " + " 'arguments': { 'uri': '%s' } }", uri); + + rsp =3D wait_command(who, cmd); + g_assert(qdict_haskey(rsp, "return")); + g_free(cmd); + qobject_unref(rsp); +} + static void migrate_set_capability(QTestState *who, const char *capability, const char *value) { @@ -597,6 +620,53 @@ static void test_postcopy(void) migrate_postcopy_complete(from, to); } =20 +static void test_postcopy_recovery(void) +{ + QTestState *from, *to; + char *uri; + + migrate_postcopy_prepare(&from, &to); + + /* Turn postcopy speed down, 4K/s is slow enough on any machines */ + migrate_set_parameter(from, "max-postcopy-bandwidth", "4096"); + + /* Now we start the postcopy */ + migrate_postcopy_start(from, to); + + /* + * Wait until postcopy is really started; we can only run the + * migrate-pause command during a postcopy + */ + wait_for_migration_status(from, "postcopy-active"); + + /* + * Manually stop the postcopy migration. This emulates a network + * failure with the migration socket + */ + migrate_pause(from); + + /* + * Create a new socket to emulate a new channel that is different + * from the broken migration channel; tell the destination to + * listen to the new port + */ + uri =3D g_strdup_printf("unix:%s/migsocket-recover", tmpfs); + migrate_recover(to, uri); + + /* + * Try to rebuild the migration channel using the resume flag and + * the newly created channel + */ + wait_for_migration_status(from, "postcopy-paused"); + migrate(from, uri, ", 'resume': true"); + g_free(uri); + + /* Restore the postcopy bandwidth to unlimited */ + migrate_set_parameter(from, "max-postcopy-bandwidth", "0"); + + migrate_postcopy_complete(from, to); +} + static void test_baddest(void) { QTestState *from, *to; @@ -683,6 +753,7 @@ int main(int argc, char **argv) module_call_init(MODULE_INIT_QOM); =20 qtest_add_func("/migration/postcopy/unix", test_postcopy); + qtest_add_func("/migration/postcopy/recovery", test_postcopy_recovery); qtest_add_func("/migration/deprecated", test_deprecated); qtest_add_func("/migration/bad_dest", test_baddest); qtest_add_func("/migration/precopy/unix", test_precopy_unix); --=20 2.17.1 From nobody Tue Nov 4 19:03:30 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530760974873415.8500850810816; Wed, 4 Jul 2018 20:22:54 -0700 (PDT) Received: from localhost ([::1]:50091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faur8-0007Zk-4F for importer@patchew.org; Wed, 04 Jul 2018 23:22:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faumm-0004Jh-4F for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fauml-0002Nu-3c for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47308 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faumk-0002Mr-Vc for qemu-devel@nongnu.org; Wed, 04 Jul 2018 23:18:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A50881A4EAD for ; Thu, 5 Jul 2018 03:18:22 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-142.nay.redhat.com [10.66.14.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB4412156889; Thu, 5 Jul 2018 03:18:20 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 5 Jul 2018 11:17:55 +0800 Message-Id: <20180705031755.3254-10-peterx@redhat.com> In-Reply-To: <20180705031755.3254-1-peterx@redhat.com> References: <20180705031755.3254-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Jul 2018 03:18:22 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH for-3.0 9/9] tests: hide stderr for postcopy recovery test 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 dumped something when network failure happens. We should avoid those messages to be dumped when running the tests: $ ./tests/migration-test -p /x86_64/migration/postcopy/recovery /x86_64/migration/postcopy/recovery: qemu-system-x86_64: check_section_fo= oter: Read section footer failed: -5 qemu-system-x86_64: Detected IO failure for postcopy. Migration paused. qemu-system-x86_64: Detected IO failure for postcopy. Migration paused. OK After the patch: $ ./tests/migration-test -p /x86_64/migration/postcopy/recovery /x86_64/migration/postcopy/recovery: OK Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Tested-by: Balamuruhan S --- tests/migration-test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 182fc88e93..96e69dab99 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -567,12 +567,13 @@ static void test_deprecated(void) } =20 static void migrate_postcopy_prepare(QTestState **from_ptr, - QTestState **to_ptr) + QTestState **to_ptr, + bool hide_error) { char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - test_migrate_start(&from, &to, uri, false); + test_migrate_start(&from, &to, uri, hide_error); =20 migrate_set_capability(from, "postcopy-ram", "true"); migrate_set_capability(to, "postcopy-ram", "true"); @@ -615,7 +616,7 @@ static void test_postcopy(void) { QTestState *from, *to; =20 - migrate_postcopy_prepare(&from, &to); + migrate_postcopy_prepare(&from, &to, false); migrate_postcopy_start(from, to); migrate_postcopy_complete(from, to); } @@ -625,7 +626,7 @@ static void test_postcopy_recovery(void) QTestState *from, *to; char *uri; =20 - migrate_postcopy_prepare(&from, &to); + migrate_postcopy_prepare(&from, &to, true); =20 /* Turn postcopy speed down, 4K/s is slow enough on any machines */ migrate_set_parameter(from, "max-postcopy-bandwidth", "4096"); --=20 2.17.1