@@ -1233,53 +1233,7 @@ void spapr_free_hpt(sPAPRMachineState *spapr)
spapr->htab = NULL;
spapr->htab_shift = 0;
close_htab_fd(spapr);
-}
-
-static void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,
- Error **errp)
-{
- long rc;
-
- /* Clean up any HPT info from a previous boot */
- spapr_free_hpt(spapr);
-
- rc = kvmppc_reset_htab(shift);
- if (rc < 0) {
- /* kernel-side HPT needed, but couldn't allocate one */
- error_setg_errno(errp, errno,
- "Failed to allocate KVM HPT of order %d (try smaller maxmem?)",
- shift);
- /* This is almost certainly fatal, but if the caller really
- * wants to carry on with shift == 0, it's welcome to try */
- } else if (rc > 0) {
- /* kernel-side HPT allocated */
- if (rc != shift) {
- error_setg(errp,
- "Requested order %d HPT, but kernel allocated order %ld (try smaller maxmem?)",
- shift, rc);
- }
-
- spapr->htab_shift = shift;
- spapr->htab = NULL;
- } else {
- /* kernel-side HPT not needed, allocate in userspace instead */
- size_t size = 1ULL << shift;
- int i;
-
- spapr->htab = qemu_memalign(size, size);
- if (!spapr->htab) {
- error_setg_errno(errp, errno,
- "Could not allocate HPT of order %d", shift);
- return;
- }
-
- memset(spapr->htab, 0, size);
- spapr->htab_shift = shift;
-
- for (i = 0; i < size / HASH_PTE_SIZE_64; i++) {
- DIRTY_HPTE(HPTE(spapr->htab, i));
- }
- }
+ unregister_savevm(NULL, "spapr/htab", spapr);
}
void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr)
@@ -1879,6 +1833,55 @@ static SaveVMHandlers savevm_htab_handlers = {
.load_state = htab_load,
};
+void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,
+ Error **errp)
+{
+ long rc;
+
+ /* Clean up any HPT info from a previous boot */
+ spapr_free_hpt(spapr);
+
+ rc = kvmppc_reset_htab(shift);
+ if (rc < 0) {
+ /* kernel-side HPT needed, but couldn't allocate one */
+ error_setg_errno(errp, errno,
+ "Failed to allocate KVM HPT of order %d (try smaller maxmem?)",
+ shift);
+ /* This is almost certainly fatal, but if the caller really
+ * wants to carry on with shift == 0, it's welcome to try */
+ } else if (rc > 0) {
+ /* kernel-side HPT allocated */
+ if (rc != shift) {
+ error_setg(errp,
+ "Requested order %d HPT, but kernel allocated order %ld (try smaller maxmem?)",
+ shift, rc);
+ }
+
+ spapr->htab_shift = shift;
+ spapr->htab = NULL;
+ } else {
+ /* kernel-side HPT not needed, allocate in userspace instead */
+ size_t size = 1ULL << shift;
+ int i;
+
+ spapr->htab = qemu_memalign(size, size);
+ if (!spapr->htab) {
+ error_setg_errno(errp, errno,
+ "Could not allocate HPT of order %d", shift);
+ return;
+ }
+
+ memset(spapr->htab, 0, size);
+ spapr->htab_shift = shift;
+
+ for (i = 0; i < size / HASH_PTE_SIZE_64; i++) {
+ DIRTY_HPTE(HPTE(spapr->htab, i));
+ }
+ }
+ register_savevm_live(NULL, "spapr/htab", -1, 1,
+ &savevm_htab_handlers, spapr);
+}
+
static void spapr_boot_set(void *opaque, const char *boot_device,
Error **errp)
{
@@ -2341,8 +2344,6 @@ static void ppc_spapr_init(MachineState *machine)
* interface, this is a legacy from the sPAPREnvironment structure
* which predated MachineState but had a similar function */
vmstate_register(NULL, 0, &vmstate_spapr, spapr);
- register_savevm_live(NULL, "spapr/htab", -1, 1,
- &savevm_htab_handlers, spapr);
/* used by RTAS */
QTAILQ_INIT(&spapr->ccs_list);
@@ -636,6 +636,8 @@ void spapr_hotplug_req_remove_by_count_indexed(sPAPRDRConnectorType drc_type,
uint32_t count, uint32_t index);
void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset,
sPAPRMachineState *spapr);
+void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,
+ Error **errp);
/* rtas-configure-connector state */
struct sPAPRConfigureConnectorState {