From nobody Sat May 18 13:16:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594548095; cv=none; d=zohomail.com; s=zohoarc; b=N4Nm8L4op/iTkAwxEiRCXDdXsV4RCCwUYwztHuPZDRAQtlEALdyt/Kz5qr9wEKgasAvQKJHFmlx3f/MY7BzVEP4ASEC21rFz2fncYl/s5+z65UkwwK2yFznWiKaF+LbJKtK77Fd2iot1mr7P25rq/FRRhcZ9aC28xEmVghOxsyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594548095; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=capdBFHak2KkcCrlXFxCuXAg7FirYJd9dQR00NksaXA=; b=S0meYQ6cl+Whk6nQsFI675GJt4HOpBkIzIrFJgLU4oxlKpg/TwF19k+FewCcUqsgjsNmrtbL9gT93sO5gol2wd9xf6pgjp5Dvvn0l9lUtQD3pdZReguEjCs/3op4+pEnixPyD7Hodey7/2g9cXVbBIUQWna0j6pMYSij9+q5kGU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594548095604619.8951146873519; Sun, 12 Jul 2020 03:01:35 -0700 (PDT) Received: from localhost ([::1]:58328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1juYne-0003za-En for importer@patchew.org; Sun, 12 Jul 2020 06:01:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juYmm-0003Xm-JK for qemu-devel@nongnu.org; Sun, 12 Jul 2020 06:00:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:40908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1juYmk-0004rT-BD for qemu-devel@nongnu.org; Sun, 12 Jul 2020 06:00:40 -0400 Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7A11AAE84; Sun, 12 Jul 2020 10:00:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de To: Juan Quintela , "Dr. David Alan Gilbert" From: Claudio Fontana Subject: migration: broken snapshot saves appear on s390 when small fields in migration stream removed Message-ID: <8bbafdec-836d-b7de-cab8-7a325b6e238d@suse.de> Date: Sun, 12 Jul 2020 12:00:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.15; envelope-from=cfontana@suse.de; helo=mx2.suse.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/12 04:51:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason J. Herne" , Fam Zheng , Thomas Huth , Peter Maydell , Cornelia Huck , qemu-devel , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Hello all, during unrelated work for splitting QTest from the TCG instruction counting= module, I encountered what seems to be a migration stream issue, which is apparent = only on s390, and only shows in block test 267. ./check -qcow2 267 when it comes to snapshot save and load using backing file. Here is a minimal reproducer patch that causes the issue on s390 only. --------------------------------------------cut----------------------------= --------------- diff --git a/cpus.c b/cpus.c index 41d1c5099f..443b88697a 100644 --- a/cpus.c +++ b/cpus.c @@ -643,7 +643,7 @@ static void qemu_account_warp_timer(void) =20 static bool icount_state_needed(void *opaque) { - return use_icount; + return 0; } =20 static bool warp_timer_state_needed(void *opaque) --------------------------------------------cut----------------------------= --------------- config.status configure line: exec '/home/cfontana/qemu-build/../qemu/configure' '--enable-tcg' '--disabl= e-kvm' '--disable-hax' '--target-list=3Ds390x-softmmu' '--enable-debug' $ make check-block TEST iotest-qcow2: 267 [fail] QEMU -- "/home/cfontana/qemu-build/tests/qemu-iotests/../../s390x-= softmmu/qemu-system-s390x" -nodefaults -display none -accel qtest QEMU_IMG -- "/home/cfontana/qemu-build/tests/qemu-iotests/../../qemu-i= mg"=20 QEMU_IO -- "/home/cfontana/qemu-build/tests/qemu-iotests/../../qemu-i= o" --cache writeback --aio threads -f qcow2 QEMU_NBD -- "/home/cfontana/qemu-build/tests/qemu-iotests/../../qemu-n= bd"=20 IMGFMT -- qcow2 (compat=3D1.1) IMGPROTO -- file PLATFORM -- Linux/s390x s390zp13 5.3.18-21-default TEST_DIR -- /home/cfontana/qemu-build/tests/qemu-iotests/scratch SOCK_DIR -- /tmp/tmp.bLJcJVtzk5 SOCKET_SCM_HELPER -- /home/cfontana/qemu-build/tests/qemu-iotests/socket_sc= m_helper --- /home/cfontana/qemu/tests/qemu-iotests/267.out 2020-07-12 05:10:07.9482= 62675 -0400 +++ /home/cfontana/qemu-build/tests/qemu-iotests/267.out.bad 2020-07-12 05:= 27:03.358362781 -0400 @@ -137,6 +137,9 @@ ID TAG VM SIZE DATE VM CLOCK -- snap0 SIZE yyyy-mm-dd hh:mm:ss 00:00:00.000 (qemu) loadvm snap0 +Unexpected storage key flag data: 0 +error while loading state for instance 0x0 of device 's390-skeys' +Error: Error -22 while loading VM state (qemu) quit =20 =20 ----------- Not run: 172 186 192 259 287 Failures: 267 Failed 1 of 115 iotests make: *** [/home/cfontana/qemu/tests/Makefile.include:880: check-tests/chec= k-block.sh] Error 1 ----------- Note: only the =3D=3D=3D -blockdev with a backing file =3D=3D=3D part of te= st 267 fails. -blockdev with NBD is ok, like all the rest. Interesting facts about s390 in particular: its save/load code includes the= transfer of "storage keys", which include a buffer of 32768 bytes of keydata in the stream. The code (hw/s390x/s390-skeys.c), is modeled similarly to RAM transfer (like in migration/ram.c), with an EOS= (end of stream) marker. Countrary to RAM transfer code though, after qemu_put_be64(f, EOS), the s39= 0 code does not qemu_fflush(f). ---------- Observation: the migration/qemu-file.c shows an IO_BUF_SIZE of 32768. -- The following workarounds hide the problem (make the test pass): 1) always including the icount field in the (unrelated) timers field that a= re sent before in the migration stream (ie not applying the reproducer patc= h). 2) increasing the IO_BUF_SIZE also hides the problem: ----------------------cut-------------------------- diff --git a/migration/qemu-file.c b/migration/qemu-file.c index be21518c57..f81d1272eb 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -30,7 +30,7 @@ #include "trace.h" #include "qapi/error.h" =20 -#define IO_BUF_SIZE 32768 +#define IO_BUF_SIZE 65536 #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) =20 struct QEMUFile { ----------------------cut-------------------------- 3) adding a qemu_fflush in hw/s390x/s390-skeys.c after EOS also "fixes" the= problem: ----------------------cut-------------------------- diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 1e036cc602..47c9a015af 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -252,6 +252,8 @@ static const TypeInfo qemu_s390_skeys_info =3D { .class_size =3D sizeof(S390SKeysClass), }; =20 +extern void qemu_fflush(QEMUFile *f); + static void s390_storage_keys_save(QEMUFile *f, void *opaque) { S390SKeysState *ss =3D S390_SKEYS(opaque); @@ -302,6 +304,7 @@ static void s390_storage_keys_save(QEMUFile *f, void *o= paque) g_free(buf); end_stream: qemu_put_be64(f, eos); + qemu_fflush(f); } =20 static int s390_storage_keys_load(QEMUFile *f, void *opaque, int version_i= d) ----------------------cut-------------------------- Do any of you with better understanding of migration/, block and s390 have = a suggestion on what could be the issue here, and what could be the next step in the investigation? Is the fact that migration/ram.c always does fflush after writing the EOS h= ave any relevance here? why does it do it, and should s390 code also follow the same pattern? Thanks, Claudio --=20 Claudio Fontana Engineering Manager Virtualization, SUSE Labs Core SUSE Software Solutions Italy Srl