From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [POC qemu-server 2/6] create savevm_monitor helper
Date: Thu, 8 Apr 2021 12:33:12 +0200 [thread overview]
Message-ID: <20210408103316.7619-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210408103316.7619-1-f.ebner@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5a89853..983fb2f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5621,6 +5621,27 @@ sub vm_reboot {
});
}
+sub savevm_monitor {
+ my ($vmid) = @_;
+
+ for(;;) {
+ my $state = mon_cmd($vmid, "query-savevm");
+ if (!$state->{status}) {
+ die "savevm not active\n";
+ } elsif ($state->{status} eq 'active') {
+ sleep(1);
+ next;
+ } elsif ($state->{status} eq 'completed') {
+ print "State saved, quitting\n";
+ return;
+ } elsif ($state->{status} eq 'failed' && $state->{error}) {
+ die "query-savevm failed with error '$state->{error}'\n"
+ } else {
+ die "query-savevm returned status '$state->{status}'\n";
+ }
+ }
+}
+
# note: if using the statestorage parameter, the caller has to check privileges
sub vm_suspend {
my ($vmid, $skiplock, $includestate, $statestorage) = @_;
@@ -5672,22 +5693,7 @@ sub vm_suspend {
eval {
set_migration_caps($vmid, 1);
mon_cmd($vmid, "savevm-start", statefile => $path);
- for(;;) {
- my $state = mon_cmd($vmid, "query-savevm");
- if (!$state->{status}) {
- die "savevm not active\n";
- } elsif ($state->{status} eq 'active') {
- sleep(1);
- next;
- } elsif ($state->{status} eq 'completed') {
- print "State saved, quitting\n";
- last;
- } elsif ($state->{status} eq 'failed' && $state->{error}) {
- die "query-savevm failed with error '$state->{error}'\n"
- } else {
- die "query-savevm returned status '$state->{status}'\n";
- }
- }
+ savevm_monitor($vmid);
};
my $err = $@;
--
2.20.1
next prev parent reply other threads:[~2021-04-08 10:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 10:33 [pve-devel] [POC qemu-server] fix 3303: allow "live" upgrade of qemu version Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 1/6] create vmstate_size helper Fabian Ebner
2021-04-08 10:33 ` Fabian Ebner [this message]
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 3/6] draft of upgrade_qemu function Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 4/6] draft of qemuupgrade API call Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 5/6] add timing for testing Fabian Ebner
2021-04-08 10:33 ` [pve-devel] [POC qemu-server 6/6] add usleep parameter to savevm_monitor Fabian Ebner
2021-04-08 16:44 ` [pve-devel] [POC qemu-server] fix 3303: allow "live" upgrade of qemu version Thomas Lamprecht
2021-06-23 17:56 ` Laurent GUERBY
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210408103316.7619-3-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox