From nobody Mon Apr 29 09:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510346313183359.5284258213359; Fri, 10 Nov 2017 12:38:33 -0800 (PST) Received: from localhost ([::1]:43411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDG4E-0006Yp-HO for importer@patchew.org; Fri, 10 Nov 2017 15:38:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDG2T-0005Ru-DA for qemu-devel@nongnu.org; Fri, 10 Nov 2017 15:36:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDG2Q-0006tV-7u for qemu-devel@nongnu.org; Fri, 10 Nov 2017 15:36:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54510 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDG2Q-0005tj-1S for qemu-devel@nongnu.org; Fri, 10 Nov 2017 15:36:30 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAAKZLbA056535 for ; Fri, 10 Nov 2017 15:35:29 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e5du98drp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 10 Nov 2017 15:35:28 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Nov 2017 15:35:27 -0500 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 10 Nov 2017 15:35:26 -0500 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAAKZPQA38797562; Fri, 10 Nov 2017 20:35:25 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85D5C112034; Fri, 10 Nov 2017 15:34:51 -0500 (EST) Received: from localhost.localdomain (unknown [9.85.137.76]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 4D16C112047; Fri, 10 Nov 2017 15:34:50 -0500 (EST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 10 Nov 2017 18:35:16 -0200 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 17111020-0052-0000-0000-00000280166D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008045; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00944008; UDB=6.00476342; IPR=6.00724290; BA=6.00005687; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017955; XFM=3.00000015; UTC=2017-11-10 20:35:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111020-0053-0000-0000-0000529630F6 Message-Id: <20171110203516.17027-1-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-10_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711100282 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v1] migration/ram.c: do not set 'postcopy_running' in POSTCOPY_INCOMING_END 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: mdroth@linux.vnet.ibm.com, dgilbert@redhat.com, quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When migrating a VM with 'migrate_set_capability postcopy-ram on' a postcopy_state is set during the process, ending up with the state POSTCOPY_INCOMING_END when the migration is over. This postcopy_state is taken into account inside ram_load to check how it will load the memory pages. This same ram_load is called when in a loadvm command. Inside ram_load, the logic to see if we're at postcopy_running state is: postcopy_running =3D postcopy_state_get() >=3D POSTCOPY_INCOMING_LISTENING postcopy_state_get() returns this enum type: typedef enum { POSTCOPY_INCOMING_NONE =3D 0, POSTCOPY_INCOMING_ADVISE, POSTCOPY_INCOMING_DISCARD, POSTCOPY_INCOMING_LISTENING, POSTCOPY_INCOMING_RUNNING, POSTCOPY_INCOMING_END } PostcopyState; In the case where ram_load is executed and postcopy_state is POSTCOPY_INCOMING_END, postcopy_running will be set to 'true' and ram_load will behave like a postcopy is in progress. This scenario isn't achievable in a migration but it is reproducible when executing savevm/loadvm after migrating with 'postcopy-ram on', causing loadvm to fail with Error -22: Source: (qemu) migrate_set_capability postcopy-ram on (qemu) migrate tcp:127.0.0.1:4444 Dest: (qemu) migrate_set_capability postcopy-ram on (qemu) ubuntu1704-intel login: Ubuntu 17.04 ubuntu1704-intel ttyS0 ubuntu1704-intel login: (qemu) (qemu) savevm test1 (qemu) loadvm test1 Unknown combination of migration flags: 0x4 (postcopy mode) error while loading state for instance 0x0 of device 'ram' Error -22 while loading VM state (qemu) This patch fixes this problem by changing a bit the semantics of postcopy_running inside ram_load, verifying first if we're not in the POSTCOPY_INCOMING_END state. In this case, postcopy_running is set to 'false'. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Juan Quintela --- migration/ram.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8620aa400a..43ed719668 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2803,13 +2803,21 @@ static int ram_load(QEMUFile *f, void *opaque, int = version_id) int flags =3D 0, ret =3D 0, invalid_flags =3D 0; static uint64_t seq_iter; int len =3D 0; - /* - * If system is running in postcopy mode, page inserts to host memory = must - * be atomic - */ - bool postcopy_running =3D postcopy_state_get() >=3D POSTCOPY_INCOMING_= LISTENING; - /* ADVISE is earlier, it shows the source has the postcopy capability = on */ - bool postcopy_advised =3D postcopy_state_get() >=3D POSTCOPY_INCOMING_= ADVISE; + bool postcopy_advised =3D false, postcopy_running =3D false; + uint8_t postcopy_state =3D postcopy_state_get(); + + if (postcopy_state !=3D POSTCOPY_INCOMING_END) { + /* + * If system is running in postcopy mode, page inserts to host mem= ory + * must be atomic + */ + postcopy_running =3D postcopy_state >=3D POSTCOPY_INCOMING_LISTENI= NG; + + /* ADVISE is earlier, it shows the source has the postcopy + * capability on + */ + postcopy_advised =3D postcopy_state >=3D POSTCOPY_INCOMING_ADVISE; + } =20 seq_iter++; =20 --=20 2.13.6