[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/26] spapr: introduce helpers to migrate HPT chunks
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 14/26] spapr: introduce helpers to migrate HPT chunks and the end marker |
Date: |
Wed, 27 Sep 2017 17:43:04 +1000 |
From: Greg Kurz <address@hidden>
This consolidates some duplicated code in a dedicated helpers.
Signed-off-by: Greg Kurz <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 90a94952c3..0ce3ec87ac 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1709,6 +1709,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
return 0;
}
+static void htab_save_chunk(QEMUFile *f, sPAPRMachineState *spapr,
+ int chunkstart, int n_valid, int n_invalid)
+{
+ qemu_put_be32(f, chunkstart);
+ qemu_put_be16(f, n_valid);
+ qemu_put_be16(f, n_invalid);
+ qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
+ HASH_PTE_SIZE_64 * n_valid);
+}
+
+static void htab_save_end_marker(QEMUFile *f)
+{
+ qemu_put_be32(f, 0);
+ qemu_put_be16(f, 0);
+ qemu_put_be16(f, 0);
+}
+
static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
int64_t max_ns)
{
@@ -1740,11 +1757,7 @@ static void htab_save_first_pass(QEMUFile *f,
sPAPRMachineState *spapr,
if (index > chunkstart) {
int n_valid = index - chunkstart;
- qemu_put_be32(f, chunkstart);
- qemu_put_be16(f, n_valid);
- qemu_put_be16(f, 0);
- qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
- HASH_PTE_SIZE_64 * n_valid);
+ htab_save_chunk(f, spapr, chunkstart, n_valid, 0);
if (has_timeout &&
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns)
{
@@ -1806,11 +1819,7 @@ static int htab_save_later_pass(QEMUFile *f,
sPAPRMachineState *spapr,
int n_valid = invalidstart - chunkstart;
int n_invalid = index - invalidstart;
- qemu_put_be32(f, chunkstart);
- qemu_put_be16(f, n_valid);
- qemu_put_be16(f, n_invalid);
- qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
- HASH_PTE_SIZE_64 * n_valid);
+ htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid);
sent += index - chunkstart;
if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime)
> max_ns) {
@@ -1873,10 +1882,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS);
}
- /* End marker */
- qemu_put_be32(f, 0);
- qemu_put_be16(f, 0);
- qemu_put_be16(f, 0);
+ htab_save_end_marker(f);
return rc;
}
@@ -1916,9 +1922,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
}
/* End marker */
- qemu_put_be32(f, 0);
- qemu_put_be16(f, 0);
- qemu_put_be16(f, 0);
+ htab_save_end_marker(f);
return 0;
}
--
2.13.5
- [Qemu-devel] [PULL 00/26] ppc-for-2.11 queue 20170927, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 04/26] ehci: Add ppc4xx-ehci for the USB 2.0 controller in embedded PPC SoCs, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 03/26] ohci: Allow sysbus version to be used as a companion, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 02/26] ppc/kvm: drop kvmppc_has_cap_htab_fd(), David Gibson, 2017/09/27
- [Qemu-devel] [PULL 05/26] ppc: Add 460EX embedded CPU, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 10/26] ppc/ide/macio: Add missing registers, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 01/26] ppc/kvm: check some capabilities with kvm_vm_check_extension(), David Gibson, 2017/09/27
- [Qemu-devel] [PULL 12/26] ppc/kvm: change kvmppc_get_htab_fd() to return -errno on error, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 06/26] ppc4xx: Add more PLB registers, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 14/26] spapr: introduce helpers to migrate HPT chunks and the end marker,
David Gibson <=
- [Qemu-devel] [PULL 13/26] ppc/kvm: generalize the use of kvmppc_get_htab_fd(), David Gibson, 2017/09/27
- [Qemu-devel] [PULL 09/26] ppc/mac: More rework of the DBDMA emulation, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 20/26] ppc/pnv: check for OPAL firmware file presence, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 19/26] ppc: remove all unused CPU definitions, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 21/26] spapr: fix the value of SDR1 in kvmppc_put_books_sregs(), David Gibson, 2017/09/27
- [Qemu-devel] [PULL 08/26] ppc/mac: Advertise a high clock frequency for NewWorld Macs, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 11/26] ppc: Fix OpenPIC model, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 15/26] ppc/pnv: Improve macro parenthesization, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 18/26] ppc: remove unused CPU definitions, David Gibson, 2017/09/27
- [Qemu-devel] [PULL 17/26] spapr_pci: make index property mandatory, David Gibson, 2017/09/27