so that we can control the reserved size for the internal qemu state from outside and the 30MiB are not hardcoded anymore
Signed-off-by: Dominik Csapak <d.csa...@proxmox.com> --- this patch applies directly to a qemu repository with our patches applied, instead of our pve-qemu repository this way the patch is much more readable than sending a patch of a patch hmp-commands.hx | 7 ++++--- hmp.c | 3 ++- qapi/misc.json | 6 +++++- savevm-async.c | 11 +++++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index fe3d827e38..f4dc296479 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1865,9 +1865,10 @@ ETEXI { .name = "savevm-start", - .args_type = "statefile:s?", - .params = "[statefile]", - .help = "Prepare for snapshot and halt VM. Save VM state to statefile.", + .args_type = "statefile:s?,statesize:i?", + .params = "[statefile] [statesize]", + .help = "Prepare for snapshot and halt VM. Save VM state to statefile." + "Statesize is the size reserved for the state in MiB.", .cmd = hmp_savevm_start, }, diff --git a/hmp.c b/hmp.c index ad0f5954d3..6b3d6c4df7 100644 --- a/hmp.c +++ b/hmp.c @@ -2550,8 +2550,9 @@ void hmp_savevm_start(Monitor *mon, const QDict *qdict) { Error *errp = NULL; const char *statefile = qdict_get_try_str(qdict, "statefile"); + uint32_t statesize = qdict_get_try_int(qdict, "statesize", -1); - qmp_savevm_start(statefile != NULL, statefile, &errp); + qmp_savevm_start(statefile != NULL, statefile, statesize != -1, statesize, &errp); hmp_handle_error(mon, &errp); } diff --git a/qapi/misc.json b/qapi/misc.json index b2fc2da955..a6e7256038 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2482,9 +2482,13 @@ # @savevm-start: # # Prepare for snapshot and halt VM. Save VM state to statefile. +# +# @statefile: the statefile +# +# @statesize: the size reserved for the internal state # ## -{ 'command': 'savevm-start', 'data': { '*statefile': 'str' } } +{ 'command': 'savevm-start', 'data': { '*statefile': 'str', '*statesize': 'uint32' } } ## # @snapshot-drive: diff --git a/savevm-async.c b/savevm-async.c index 2a1d40842e..40265bb1a0 100644 --- a/savevm-async.c +++ b/savevm-async.c @@ -49,6 +49,7 @@ static struct SnapshotState { int64_t total_time; QEMUBH *cleanup_bh; QemuThread thread; + uint32_t statesize; } snap_state; SaveVMInfo *qmp_query_savevm(Error **errp) @@ -237,7 +238,7 @@ static void *process_savevm_thread(void *opaque) qemu_savevm_state_pending(snap_state.file, 0, &pend_precopy, &pend_compatible, &pend_postcopy); pending_size = pend_precopy + pend_compatible + pend_postcopy; - maxlen = blk_getlength(snap_state.target) - 30*1024*1024; + maxlen = blk_getlength(snap_state.target) - snap_state.statesize*1024*1024; if (pending_size > 400000 && snap_state.bs_pos + pending_size < maxlen) { qemu_mutex_lock_iothread(); @@ -285,7 +286,7 @@ static void *process_savevm_thread(void *opaque) return NULL; } -void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp) +void qmp_savevm_start(bool has_statefile, const char *statefile, bool has_statesize, uint32_t statesize, Error **errp) { Error *local_err = NULL; @@ -303,6 +304,12 @@ void qmp_savevm_start(bool has_statefile, const char *statefile, Error **errp) snap_state.total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); snap_state.blocker = NULL; + if (has_statesize) { + snap_state.statesize = statesize; + } else { + snap_state.statesize = 512; + } + if (snap_state.error) { error_free(snap_state.error); snap_state.error = NULL; -- 2.11.0 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel