From 446e157b80bb959ff9acaa461e9bc9e8d39b7727 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Tue, 13 Nov 2012 22:41:47 +0100 Subject: [PATCH] Move code for --boot feature to END block. Fixes missing SSH fingerprint display if --boot was used. (Closes: #679183) Remove a redundant unsetting of $MOUNT_POINT. Guard a potentially second call to the not idempotent unMountImage(). --- bin/xen-create-image | 120 +++++++++++++++++++------------------------ debian/changelog | 2 + 2 files changed, 55 insertions(+), 67 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 4aa9cf7..719bba4 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -1087,73 +1087,6 @@ setupRootPassword() if ( $CONFIG{ 'passwd' } or $CONFIG{ 'genpass' } or $CONFIG{ logprint("All done\n"); -# -# If we're supposed to start the new instance do so - note here we -# have to unmount the image first. -# -if ( $CONFIG{ 'boot' } ) -{ - - # - # Unmount the image and any subsequent mounts. - # - unMountImage($MOUNT_POINT); - - # - # Mark us as unmounted. - # - $MOUNT_POINT = undef; - - # - # If there is an /etc/xen/auto directory then link - # in the domain so that it will automatically restart, if it isn't - # already present. - # - # (Will be present if this is overwriting a previous image, for example.) - # - if ( -d "/etc/xen/auto" ) - { - my $cfg = - $CONFIG{ 'output' } . "/" . $CONFIG{ 'hostname' } . - $CONFIG{ 'extension' }; - - if ( !-e $cfg ) - { - logprint("Creating auto-start symlink to: $cfg\n"); - - my $link = "ln -s $cfg /etc/xen/auto/"; - runCommand($link); - } - } - - - # - # - # Start the image - # - $CONFIG{ 'pid' } = fork(); - if ( $CONFIG{ 'pid' } ) - { - - # Parent. - exit; - } - else - { - - # Config file. - my $cfg = - $CONFIG{ 'output' } . "/" . $CONFIG{ 'hostname' } . - $CONFIG{ 'extension' }; - - # Child. - system("$CONFIG{'xm'} create $cfg >/dev/null 2>/dev/null"); - - logprint("Started new Xen guest: $CONFIG{'hostname'} [$cfg]\n"); - } -} - - # # Finished. # @@ -4394,6 +4327,59 @@ sub END unMountImage($MOUNT_POINT); } + # + # If we're supposed to start the new instance do so - note here we + # have to unmount the image first. + # + if ( $CONFIG{ 'boot' } and !$FAIL ) + { + + # + # Unmount the image and any subsequent mounts. + # + if ( defined($MOUNT_POINT) ) { + unMountImage($MOUNT_POINT); + } + + # + # If there is an /etc/xen/auto directory then link in the + # domain so that it will automatically restart, if it isn't + # already present. + # + # (Will be present if this is overwriting a previous image, + # for example.) + # + if ( -d "/etc/xen/auto" ) + { + my $cfg = + $CONFIG{ 'output' } . "/" . $CONFIG{ 'hostname' } . + $CONFIG{ 'extension' }; + + if ( !-e $cfg ) + { + logprint("Creating auto-start symlink to: $cfg\n"); + + my $link = "ln -s $cfg /etc/xen/auto/"; + runCommand($link); + } + } + + # + # + # Start the image + # + + # Config file. + my $cfg = + $CONFIG{ 'output' } . "/" . $CONFIG{ 'hostname' } . + $CONFIG{ 'extension' }; + + # Child. + system("$CONFIG{'xm'} create $cfg >/dev/null 2>/dev/null"); + + logprint("Started new Xen guest: $CONFIG{'hostname'} [$cfg]\n"); + } + # # Here we print out the status message when finishing. # diff --git a/debian/changelog b/debian/changelog index 52b6aec..a9c4628 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ xen-tools (4.3.1+dev-1) UNRELEASED; urgency=low * New upstream release - Fix symbolic link hooks/centos-6/15-setup-arch (Closes: #690299) - Execute END block not on --version/--help/--manual (Closes: #684346) + - Move code for --boot feature to END block. Fixes missing SSH + fingerprint display if --boot was used. (Closes: #679183) - Use local parameter instead of global variable in unMountImage. -- Axel Beckert Tue, 13 Nov 2012 18:05:05 +0100