return pid;
}
-static int get_vmstate(int sock)
+int get_vmstate(int sock)
{
int vmstate;
int r;
#include <kvm/util.h>
#include <kvm/kvm-cmd.h>
#include <kvm/builtin-pause.h>
+#include <kvm/builtin-list.h>
#include <kvm/kvm.h>
#include <kvm/parse-options.h>
#include <kvm/kvm-ipc.h>
static int do_pause(const char *name, int sock)
{
int r;
+ int vmstate;
+
+ vmstate = get_vmstate(sock);
+ if (vmstate < 0)
+ return vmstate;
+ if (vmstate == KVM_VMSTATE_PAUSED) {
+ printf("Guest %s is already paused.\n", name);
+ return 0;
+ }
r = kvm_ipc__send(sock, KVM_IPC_PAUSE);
if (r)
#include <kvm/util.h>
#include <kvm/kvm-cmd.h>
#include <kvm/builtin-resume.h>
+#include <kvm/builtin-list.h>
#include <kvm/kvm.h>
#include <kvm/parse-options.h>
#include <kvm/kvm-ipc.h>
static int do_resume(const char *name, int sock)
{
int r;
+ int vmstate;
+
+ vmstate = get_vmstate(sock);
+ if (vmstate < 0)
+ return vmstate;
+ if (vmstate == KVM_VMSTATE_RUNNING) {
+ printf("Guest %s is still running.\n", name);
+ return 0;
+ }
r = kvm_ipc__send(sock, KVM_IPC_RESUME);
if (r)
int kvm_cmd_list(int argc, const char **argv, const char *prefix);
void kvm_list_help(void) NORETURN;
+int get_vmstate(int sock);
#endif