From 41e7bdb9169b23e776c57ca6ca8191ae99c20078 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 20 Apr 2012 09:30:42 +0200 Subject: [PATCH] removed startall/stopall commands Because we now support startup priorities, and start/stop order must include containers --- PVE/QemuServer.pm | 99 ----------------------------------------------- changelog.Debian | 5 +++ qemu.init.d | 3 +- qm | 88 ----------------------------------------- 4 files changed, 6 insertions(+), 189 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 0d78bac6..fbd4b54a 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -2937,105 +2937,6 @@ sub vm_destroy { }); } -sub vm_stopall { - my ($storecfg, $timeout) = @_; - - $timeout = 3*60 if !$timeout; - - my $cleanuphash = {}; - - my $vzlist = vzlist(); - my $count = 0; - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - $count++; - $cleanuphash->{$vmid} = 1; - } - - return if !$count; - - my $msg = "Stopping Qemu Server - sending shutdown requests to all VMs\n"; - syslog('info', $msg); - warn $msg; - - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - eval { vm_monitor_command($vmid, "system_powerdown"); }; - warn $@ if $@; - } - - my $wt = 5; - my $maxtries = int(($timeout + $wt -1)/$wt); - my $try = 0; - while (($try < $maxtries) && $count) { - $try++; - sleep $wt; - - $vzlist = vzlist(); - $count = 0; - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - $count++; - } - last if !$count; - } - - if ($count) { - - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - - warn "VM $vmid still running - sending stop now\n"; - eval { vm_monitor_command($vmid, "quit"); }; - warn $@ if $@; - } - - $timeout = 30; - $maxtries = int(($timeout + $wt -1)/$wt); - $try = 0; - while (($try < $maxtries) && $count) { - $try++; - sleep $wt; - - $vzlist = vzlist(); - $count = 0; - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - $count++; - } - last if !$count; - } - - if ($count) { - - foreach my $vmid (keys %$vzlist) { - next if !$vzlist->{$vmid}->{pid}; - - warn "VM $vmid still running - terminating now with SIGTERM\n"; - kill 15, $vzlist->{$vmid}->{pid}; - } - sleep 1; - } - - # this is called by system shotdown scripts, so remaining - # processes gets killed anyways (no need to send kill -9 here) - } - - $vzlist = vzlist(); - foreach my $vmid (keys %$cleanuphash) { - next if $vzlist->{$vmid}->{pid}; - eval { - my $conf = load_config($vmid); - vm_stop_cleanup($storecfg, $vmid, $conf); - }; - warn $@ if $@; - } - - $msg = "Qemu Server stopped\n"; - syslog('info', $msg); - print $msg; -} - # pci helpers sub file_write { diff --git a/changelog.Debian b/changelog.Debian index 5bd70d73..1e5449ff 100644 --- a/changelog.Debian +++ b/changelog.Debian @@ -1,6 +1,11 @@ qemu-server (2.0-39) unstable; urgency=low * new startup option to define startup order. + + * do not start VMs with /etc/init.d/qemu-server. This is now + done with /etc/init.d/pve-manager + + * qm: removed startall/stopall commands -- Proxmox Support Team Thu, 19 Apr 2012 14:26:04 +0200 diff --git a/qemu.init.d b/qemu.init.d index 333c0acc..3b142ad0 100644 --- a/qemu.init.d +++ b/qemu.init.d @@ -32,10 +32,9 @@ case "$1" in mkdir -p /var/run/qemu-server mkdir -p /var/lock/qemu-server - $PROG startall ;; stop) - $PROG stopall + # nothing to do, because we are no real daemon ;; force-reload) ;; diff --git a/qm b/qm index b45dc319..044bc21d 100755 --- a/qm +++ b/qm @@ -222,90 +222,6 @@ __PACKAGE__->register_method ({ return undef; }}); -__PACKAGE__->register_method ({ - name => 'startall', - path => 'startall', - method => 'POST', - description => "Start all virtual machines (when onboot=1).", - parameters => { - additionalProperties => 0, - properties => {}, - }, - returns => { type => 'null'}, - code => sub { - my ($param) = @_; - - # wait up to 10 seconds for quorum - for (my $i = 10; $i >= 0; $i--) { - last if PVE::Cluster::check_cfs_quorum($i != 0 ? 1 : 0); - sleep(1); - } - - my $vzlist = PVE::QemuServer::vzlist(); - my $storecfg = PVE::Storage::config(); - - my $cc = PVE::Cluster::cfs_read_file('cluster.conf'); - - my $count = 0; - foreach my $vmid (keys %$vzlist) { - next if $vzlist->{$vmid}->{pid}; # already running - - my $conf; - eval { $conf = PVE::QemuServer::load_config($vmid); }; - if (my $err = $@) { - warn $err; - next; - } - - next if !($conf && $conf->{onboot}); - - # skip ha managed VMs (started by rgmanager) - next if PVE::Cluster::cluster_conf_lookup_pvevm($cc, 0, $vmid, 1); - - sleep(2) if $count != 0; # reduce load - $count++; - - PVE::Cluster::check_cfs_quorum(); # abort when we loose quorum - - eval { - print STDERR "Starting Qemu VM $vmid\n"; - PVE::QemuServer::vm_start($storecfg, $vmid); - }; - warn $@ if $@; - } - - return undef; - }}); - -__PACKAGE__->register_method ({ - name => 'stopall', - path => 'stopall', - method => 'POST', - description => "Stop all virtual machines.", - parameters => { - additionalProperties => 0, - properties => { - timeout => { - description => "Timeout in seconds. Default is to wait 3 minutes.", - type => 'integer', - minimum => 1, - optional => 1, - } - }, - }, - returns => { type => 'null'}, - code => sub { - my ($param) = @_; - - my $timeout = $param->{timeout}; - - my $storecfg = PVE::Storage::config(); - - PVE::QemuServer::vm_stopall($storecfg, $timeout); - - return undef; - }}); - __PACKAGE__->register_method ({ name => 'wait', path => 'wait', @@ -457,10 +373,6 @@ my $cmddef = { monitor => [ __PACKAGE__, 'monitor', ['vmid']], - startall => [ __PACKAGE__, 'startall', []], - - stopall => [ __PACKAGE__, 'stopall', []], - mtunnel => [ __PACKAGE__, 'mtunnel', []], }; -- 2.39.5