Skip to content

Commit

Permalink
dump-guest-memory: add dump_in_progress() helper function
Browse files Browse the repository at this point in the history
For now, it has no effect. It will be used in dump detach support.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: Fam Zheng <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
xzpeter authored and bonzini committed Feb 22, 2016
1 parent baf28f5 commit 65d64f3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,12 @@ static void dump_state_prepare(DumpState *s)
*s = (DumpState) { .status = DUMP_STATUS_ACTIVE };
}

bool dump_in_progress(void)
{
DumpState *state = &dump_state_global;
return (state->status == DUMP_STATUS_ACTIVE);
}

static void dump_init(DumpState *s, int fd, bool has_format,
DumpGuestMemoryFormat format, bool paging, bool has_filter,
int64_t begin, int64_t length, Error **errp)
Expand Down Expand Up @@ -1628,6 +1634,13 @@ void qmp_dump_guest_memory(bool paging, const char *file,
DumpState *s;
Error *local_err = NULL;

/* if there is a dump in background, we should wait until the dump
* finished */
if (dump_in_progress()) {
error_setg(errp, "There is a dump in process, please wait.");
return;
}

/*
* kdump-compressed format need the whole memory dumped, so paging or
* filter is not supported here.
Expand Down
4 changes: 4 additions & 0 deletions include/qemu-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,8 @@ int parse_debug_env(const char *name, int max, int initial);
const char *qemu_ether_ntoa(const MACAddr *mac);
void page_size_init(void);

/* returns non-zero if dump is in progress, otherwise zero is
* returned. */
bool dump_in_progress(void);

#endif
14 changes: 14 additions & 0 deletions qmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ void qmp_quit(Error **errp)

void qmp_stop(Error **errp)
{
/* if there is a dump in background, we should wait until the dump
* finished */
if (dump_in_progress()) {
error_setg(errp, "There is a dump in process, please wait.");
return;
}

if (runstate_check(RUN_STATE_INMIGRATE)) {
autostart = 0;
} else {
Expand Down Expand Up @@ -175,6 +182,13 @@ void qmp_cont(Error **errp)
BlockBackend *blk;
BlockDriverState *bs;

/* if there is a dump in background, we should wait until the dump
* finished */
if (dump_in_progress()) {
error_setg(errp, "There is a dump in process, please wait.");
return;
}

if (runstate_needs_reset()) {
error_setg(errp, "Resetting the Virtual Machine is required");
return;
Expand Down

0 comments on commit 65d64f3

Please sign in to comment.