spapr: introduce helpers to migrate HPT chunks and the end marker
This consolidates some duplicated code in a dedicated helpers. Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
14b0d74887
commit
332f7721cb
@ -1709,6 +1709,23 @@ static int htab_save_setup(QEMUFile *f, void *opaque)
|
|||||||
return 0;
|
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,
|
static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
|
||||||
int64_t max_ns)
|
int64_t max_ns)
|
||||||
{
|
{
|
||||||
@ -1740,11 +1757,7 @@ static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,
|
|||||||
if (index > chunkstart) {
|
if (index > chunkstart) {
|
||||||
int n_valid = index - chunkstart;
|
int n_valid = index - chunkstart;
|
||||||
|
|
||||||
qemu_put_be32(f, chunkstart);
|
htab_save_chunk(f, spapr, chunkstart, n_valid, 0);
|
||||||
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);
|
|
||||||
|
|
||||||
if (has_timeout &&
|
if (has_timeout &&
|
||||||
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
|
(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_valid = invalidstart - chunkstart;
|
||||||
int n_invalid = index - invalidstart;
|
int n_invalid = index - invalidstart;
|
||||||
|
|
||||||
qemu_put_be32(f, chunkstart);
|
htab_save_chunk(f, spapr, chunkstart, n_valid, n_invalid);
|
||||||
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);
|
|
||||||
sent += index - chunkstart;
|
sent += index - chunkstart;
|
||||||
|
|
||||||
if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
|
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);
|
rc = htab_save_later_pass(f, spapr, MAX_ITERATION_NS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End marker */
|
htab_save_end_marker(f);
|
||||||
qemu_put_be32(f, 0);
|
|
||||||
qemu_put_be16(f, 0);
|
|
||||||
qemu_put_be16(f, 0);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -1916,9 +1922,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* End marker */
|
/* End marker */
|
||||||
qemu_put_be32(f, 0);
|
htab_save_end_marker(f);
|
||||||
qemu_put_be16(f, 0);
|
|
||||||
qemu_put_be16(f, 0);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user