[pve-devel] [PATCH qemu-server 4/4] implement a 'real' reboot for vms
Alexandre DERUMIER
aderumier at odiso.com
Wed Oct 17 14:02:57 CEST 2018
Wonderful !
It could be great to have something like, shutdown (clean shutdown) + start.
----- Mail original -----
De: "Dominik Csapak" <d.csapak at proxmox.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Mardi 16 Octobre 2018 12:07:06
Objet: [pve-devel] [PATCH qemu-server 4/4] implement a 'real' reboot for vms
instead of letting qemu handle a reset, add '-no-reboot' by default
(>= qemu 3.0) and use our cleanup to start the vm again
this has the advantage that pending changes will be applied
on a reboot from within the guest, starts with a new qemu version
and enables us to have a 'reboot' button in the future
(more work for this is needed)
it still respects the 'reboot' config we had
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/CLI/qm.pm | 22 ++++++++++++++++++++++
PVE/QemuServer.pm | 7 ++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 6a14c12..8772e8c 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -758,6 +758,8 @@ __PACKAGE__->register_method({
my $guest = $param->{'guest-requested'};
my $reset = $param->{'was-reset'};
+ my $needs_reset = 0;
+
my $storecfg = PVE::Storage::config();
PVE::QemuConfig->lock_config($vmid, sub {
@@ -780,8 +782,28 @@ __PACKAGE__->register_method({
# vm was shutdown from inside the guest or crashed, doing api cleanup
PVE::QemuServer::vm_stop_cleanup($storecfg, $vmid, $conf, 0, 0);
}
+
+ if ((!defined($conf->{reboot}) || $conf->{reboot}) && $reset) {
+ $needs_reset = 1;
+ }
});
+ if ($needs_reset) {
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $authuser = $rpcenv->get_user();
+ # got reset parameter, we should start the vm again
+ my $realcmd = sub {
+ my $upid = shift;
+
+ syslog('info', "restart VM $vmid: $upid\n");
+
+ PVE::QemuServer::vm_start($storecfg, $vmid);
+ return;
+ };
+
+ $rpcenv->fork_worker('qmrestart', $vmid, $authuser, $realcmd);
+ }
+
return undef;
}});
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4838e79..7dad560 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3402,7 +3402,12 @@ sub config_to_command {
push @$cmd, '-no-acpi' if defined($conf->{acpi}) && $conf->{acpi} == 0;
- push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0;
+ # we add it by default and check in the cleanup call if we want to start
+ # it again
+ if ((defined($conf->{reboot}) && $conf->{reboot} == 0) ||
+ qemu_machine_feature_enabled($machine_type, $kvmver, 3, 0)) {
+ push @$cmd, '-no-reboot' if defined($conf->{reboot}) && $conf->{reboot} == 0;
+ }
push @$cmd, '-vga', $vga if $vga && $vga !~ m/^serial\d+$/; # for kvm 77 and later
--
2.11.0
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list