{"id":814275,"url":"http://patchwork.ozlabs.org/api/patches/814275/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/150548136111.5945.6437882724141726495.stgit@bahia.lan/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<150548136111.5945.6437882724141726495.stgit@bahia.lan>","list_archive_url":null,"date":"2017-09-15T13:16:01","name":"[2/4] spapr: introduce helpers to migrate HPT chunks and the end marker","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2a79d57c9c337975b67721b1a0ed93e32848e6c5","submitter":{"id":69178,"url":"http://patchwork.ozlabs.org/api/people/69178/?format=json","name":"Greg Kurz","email":"groug@kaod.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/150548136111.5945.6437882724141726495.stgit@bahia.lan/mbox/","series":[{"id":3310,"url":"http://patchwork.ozlabs.org/api/series/3310/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3310","date":"2017-09-15T13:15:33","name":"ppc/kvm: htab fd code improvements","version":1,"mbox":"http://patchwork.ozlabs.org/series/3310/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814275/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814275/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtwvH6zV3z9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 23:18:19 +1000 (AEST)","from localhost ([::1]:53357 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dsqVe-0004rJ-0k\n\tfor incoming@patchwork.ozlabs.org; Fri, 15 Sep 2017 09:18:18 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:41992)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1dsqTc-0002gn-KF\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:16 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1dsqTY-0003sW-K4\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:12 -0400","from 7.mo2.mail-out.ovh.net ([188.165.48.182]:37196)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <groug@kaod.org>) id 1dsqTY-0003sG-D0\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:08 -0400","from player770.ha.ovh.net (b6.ovh.net [213.186.33.56])\n\tby mo2.mail-out.ovh.net (Postfix) with ESMTP id AB816A9AE1\n\tfor <qemu-devel@nongnu.org>; Fri, 15 Sep 2017 15:16:05 +0200 (CEST)","from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139])\n\t(Authenticated sender: groug@kaod.org)\n\tby player770.ha.ovh.net (Postfix) with ESMTPA id 55A1B3C008B;\n\tFri, 15 Sep 2017 15:16:01 +0200 (CEST)"],"From":"Greg Kurz <groug@kaod.org>","To":"qemu-devel@nongnu.org","Date":"Fri, 15 Sep 2017 15:16:01 +0200","Message-ID":"<150548136111.5945.6437882724141726495.stgit@bahia.lan>","In-Reply-To":"<150548133297.5945.7401220081077343726.stgit@bahia.lan>","References":"<150548133297.5945.7401220081077343726.stgit@bahia.lan>","User-Agent":"StGit/0.17.1-46-g6855-dirty","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","X-Ovh-Tracer-Id":"15174034520613755381","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrgeekgdeifecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"188.165.48.182","Subject":"[Qemu-devel] [PATCH 2/4] spapr: introduce helpers to migrate HPT\n\tchunks and the end marker","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Alexey Kardashevskiy <aik@ozlabs.ru>, Thomas Huth <thuth@redhat.com>,\n\tqemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"This consolidates some duplicated code in a single helper.\n\nSigned-off-by: Greg Kurz <groug@kaod.org>\n---\n hw/ppc/spapr.c |   38 +++++++++++++++++++++-----------------\n 1 file changed, 21 insertions(+), 17 deletions(-)","diff":"diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c\nindex f680f28a15ea..841117f6d185 100644\n--- a/hw/ppc/spapr.c\n+++ b/hw/ppc/spapr.c\n@@ -1708,6 +1708,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque)\n     return 0;\n }\n \n+static void htab_save_chunk(QEMUFile *f, sPAPRMachineState *spapr,\n+                            int chunkstart, int n_valid, int n_invalid)\n+{\n+    qemu_put_be32(f, chunkstart);\n+    qemu_put_be16(f, n_valid);\n+    qemu_put_be16(f, n_invalid);\n+    if (spapr) {\n+        qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),\n+                        HASH_PTE_SIZE_64 * n_valid);\n+    }\n+}\n+\n+static void htab_save_end_marker(QEMUFile *f)\n+{\n+    htab_save_chunk(f, NULL, 0, 0, 0);\n+}\n+\n static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,\n                                  int64_t max_ns)\n {\n@@ -1739,11 +1756,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,\n         if (index > chunkstart) {\n             int n_valid = index - chunkstart;\n \n-            qemu_put_be32(f, chunkstart);\n-            qemu_put_be16(f, n_valid);\n-            qemu_put_be16(f, 0);\n-            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),\n-                            HASH_PTE_SIZE_64 * n_valid);\n+            htab_save_chunk(f, spapr, chunkstart, n_valid, 0);\n \n             if (has_timeout &&\n                 (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {\n@@ -1805,11 +1818,7 @@ static int htab_save_later_pass(QEMUFile *f, sPAPRMachineState *spapr,\n             int n_valid = invalidstart - chunkstart;\n             int n_invalid = index - invalidstart;\n \n-            qemu_put_be32(f, chunkstart);\n-            qemu_put_be16(f, n_valid);\n-            qemu_put_be16(f, n_invalid);\n-            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),\n-                            HASH_PTE_SIZE_64 * n_valid);\n+            htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid);\n             sent += index - chunkstart;\n \n             if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {\n@@ -1872,10 +1881,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)\n         rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS);\n     }\n \n-    /* End marker */\n-    qemu_put_be32(f, 0);\n-    qemu_put_be16(f, 0);\n-    qemu_put_be16(f, 0);\n+    htab_save_end_marker(f);\n \n     return rc;\n }\n@@ -1915,9 +1921,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)\n     }\n \n     /* End marker */\n-    qemu_put_be32(f, 0);\n-    qemu_put_be16(f, 0);\n-    qemu_put_be16(f, 0);\n+    htab_save_end_marker(f);\n \n     return 0;\n }\n","prefixes":["2/4"]}