2017-04-20 15:25:55 +03:00
|
|
|
/*
|
|
|
|
* QEMU snapshots
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004-2008 Fabrice Bellard
|
|
|
|
* Copyright (c) 2009-2015 Red Hat Inc
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Juan Quintela <quintela@redhat.com>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_MIGRATION_SNAPSHOT_H
|
|
|
|
#define QEMU_MIGRATION_SNAPSHOT_H
|
|
|
|
|
2021-02-04 15:48:30 +03:00
|
|
|
#include "qapi/qapi-builtin-types.h"
|
migration: preserve suspended for snapshot
Restoring a snapshot can break a suspended guest. Snapshots suffer from
the same suspended-state issues that affect live migration, plus they must
handle an additional problematic scenario, which is that a running vm must
remain running if it loads a suspended snapshot.
To save, the existing vm_stop call now completely stops the suspended
state. Finish with vm_resume to leave the vm in the state it had prior
to the save, correctly restoring the suspended state.
To load, if the snapshot is not suspended, then vm_stop + vm_resume
correctly handles all states, and leaves the vm in the state it had prior
to the load. However, if the snapshot is suspended, restoration is
trickier. First, call vm_resume to restore the state to suspended so the
current state matches the saved state. Then, if the pre-load state is
running, call wakeup to resume running.
Prior to these changes, the vm_stop to RUN_STATE_SAVE_VM and
RUN_STATE_RESTORE_VM did not change runstate if the current state was
suspended, but now it does, so allow these transitions.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-8-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
2024-01-03 23:05:36 +03:00
|
|
|
#include "qapi/qapi-types-run-state.h"
|
2021-02-04 15:48:30 +03:00
|
|
|
|
2021-02-04 15:48:24 +03:00
|
|
|
/**
|
|
|
|
* save_snapshot: Save an internal snapshot.
|
|
|
|
* @name: name of internal snapshot
|
2021-02-04 15:48:29 +03:00
|
|
|
* @overwrite: replace existing snapshot with @name
|
2021-02-04 15:48:30 +03:00
|
|
|
* @vmstate: blockdev node name to store VM state in
|
|
|
|
* @has_devices: whether to use explicit device list
|
|
|
|
* @devices: explicit device list to snapshot
|
2021-02-04 15:48:24 +03:00
|
|
|
* @errp: pointer to error object
|
|
|
|
* On success, return %true.
|
|
|
|
* On failure, store an error through @errp and return %false.
|
|
|
|
*/
|
2021-02-04 15:48:30 +03:00
|
|
|
bool save_snapshot(const char *name, bool overwrite,
|
|
|
|
const char *vmstate,
|
|
|
|
bool has_devices, strList *devices,
|
|
|
|
Error **errp);
|
2021-02-04 15:48:25 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* load_snapshot: Load an internal snapshot.
|
|
|
|
* @name: name of internal snapshot
|
2021-02-04 15:48:30 +03:00
|
|
|
* @vmstate: blockdev node name to load VM state from
|
|
|
|
* @has_devices: whether to use explicit device list
|
|
|
|
* @devices: explicit device list to snapshot
|
2021-02-04 15:48:25 +03:00
|
|
|
* @errp: pointer to error object
|
|
|
|
* On success, return %true.
|
|
|
|
* On failure, store an error through @errp and return %false.
|
|
|
|
*/
|
2021-02-04 15:48:30 +03:00
|
|
|
bool load_snapshot(const char *name,
|
|
|
|
const char *vmstate,
|
|
|
|
bool has_devices, strList *devices,
|
|
|
|
Error **errp);
|
2017-04-20 15:25:55 +03:00
|
|
|
|
2021-02-04 15:48:31 +03:00
|
|
|
/**
|
|
|
|
* delete_snapshot: Delete a snapshot.
|
|
|
|
* @name: path to snapshot
|
|
|
|
* @has_devices: whether to use explicit device list
|
|
|
|
* @devices: explicit device list to snapshot
|
|
|
|
* @errp: pointer to error object
|
|
|
|
* On success, return %true.
|
|
|
|
* On failure, store an error through @errp and return %false.
|
|
|
|
*/
|
|
|
|
bool delete_snapshot(const char *name,
|
|
|
|
bool has_devices, strList *devices,
|
|
|
|
Error **errp);
|
|
|
|
|
migration: preserve suspended for snapshot
Restoring a snapshot can break a suspended guest. Snapshots suffer from
the same suspended-state issues that affect live migration, plus they must
handle an additional problematic scenario, which is that a running vm must
remain running if it loads a suspended snapshot.
To save, the existing vm_stop call now completely stops the suspended
state. Finish with vm_resume to leave the vm in the state it had prior
to the save, correctly restoring the suspended state.
To load, if the snapshot is not suspended, then vm_stop + vm_resume
correctly handles all states, and leaves the vm in the state it had prior
to the load. However, if the snapshot is suspended, restoration is
trickier. First, call vm_resume to restore the state to suspended so the
current state matches the saved state. Then, if the pre-load state is
running, call wakeup to resume running.
Prior to these changes, the vm_stop to RUN_STATE_SAVE_VM and
RUN_STATE_RESTORE_VM did not change runstate if the current state was
suspended, but now it does, so allow these transitions.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/1704312341-66640-8-git-send-email-steven.sistare@oracle.com
Signed-off-by: Peter Xu <peterx@redhat.com>
2024-01-03 23:05:36 +03:00
|
|
|
/**
|
|
|
|
* load_snapshot_resume: Restore runstate after loading snapshot.
|
|
|
|
* @state: state to restore
|
|
|
|
*/
|
|
|
|
void load_snapshot_resume(RunState state);
|
|
|
|
|
2017-04-20 15:25:55 +03:00
|
|
|
#endif
|