From 7554436d6d3ef5553f1c15ffb66432f1d05e6be1 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 30 Jan 2014 12:04:49 +0100 Subject: [PATCH] Add comments for the shutdown and shutdowntimeout variables, and other minor fixes --- virt-backup | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/virt-backup b/virt-backup index e25a90a..3f96d9b 100644 --- a/virt-backup +++ b/virt-backup @@ -4,7 +4,7 @@ # Daniel Berteaud # # COPYRIGHT -# Copyright (C) 2009-2012 Daniel Berteaud +# Copyright (C) 2009-2014 Daniel Berteaud # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -81,9 +81,14 @@ $opts{nice} = 'nice -n 19'; # which can be quite I/O intensive. This only works if your storage # uses the CFQ scheduler (which is the default on EL) $opts{ionice} = 'ionice -c 2 -n 7'; - +# if you want to shutdown the guest instead of suspending it +# you can pass the --shutdown flag (mutual exclusive with --state) +# in which case, this script will send an ACPI signal to the guest +# and wait for shutdowntimeout seconds for the guest to be off $opts{shutdown} = 0; -$opts{shutdown_time} = 300; +$opts{shutdowntimeout} = 300; + +# Those are internal variables, do not modify $opts{livebackup} = 1; $opts{wasrunning} = 1; @@ -338,14 +343,14 @@ sub prepare_backup{ my @df = `df -PT $source`; my ($dev,undef,undef,undef,undef,undef,$mount) = split /\s+/, $df[1]; # Ok, we now have the backing device which probably looks like /dev/mapper/vg-lv - # We cannot pass this arg to lvcreate to take a snapshot, wee need to detect Volume Group + # We cannot pass this arg to lvcreate to take a snapshot, we need to detect Volume Group # name and Logical Volume name my $lvm = ''; if ($opts{lvm} eq '' and $dev =~ m!^/dev/!){ my (undef,$lv,$vg) = split (/\s+/, `/sbin/lvs --noheadings -o lv_name,vg_name $dev get_info->{state} != Sys::Virt::Domain::STATE_SHUTOFF){ if ($shutdown_counter >= $opts{shutdowntimeout}){ - die "Waited $opts{shutdown_time} seconds for $vm to shutdown. Shutdown Failed\n"; + die "Waited $opts{shutdowntimeout} seconds for $vm to shutdown. Shutdown Failed\n"; } $shutdown_counter++; sleep(1);