From aba94e4c7355f60c96352ea683461c3e6e121a93 Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Wed, 26 May 2010 23:26:09 +0200 Subject: [PATCH 1/2] xen-update-image: Reformat source code comment to fit into 80 columns --- bin/xen-update-image | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/bin/xen-update-image b/bin/xen-update-image index 6cbef5b..bd5f97c 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -242,19 +242,24 @@ sub updateXenImage elsif ( $CONFIG{ 'evms' } ) { - # The EVMS volume -- note, unlike LVM, you don't need the $CONFIG{'evms'} - # to see it and mount the volume. $CONFIG{'evms'} is only used for manipulating - # the underlying object. Still, I don't want to mess with the parse code and - # make it confusing - otherwise --evms takes an argument everywhere but here, - # which will confuse users. The better solution is to make it so that --evms can - # take a following container, but doesn't require it. For the moment, it is - # better to leave it as it is, take a container, and then ignore it. + # The EVMS volume -- note, unlike LVM, you don't need the + # $CONFIG{'evms'} to see it and mount the + # volume. $CONFIG{'evms'} is only used for manipulating the + # underlying object. Still, I don't want to mess with the + # parse code and make it confusing - otherwise --evms takes an + # argument everywhere but here, which will confuse users. The + # better solution is to make it so that --evms can take a + # following container, but doesn't require it. For the + # moment, it is better to leave it as it is, take a container, + # and then ignore it. - # The best way to do it is to just read it out of the configuration file, - # tell the user what you got and where you got it from, and not bother the user - # with picking --dir or --lvm or --evms at all, but infer it from the config - # file's disk = parameter. xen-delete-image might work the same way, but - # it could be *slightly* more dangerous in the context of deleting. + # The best way to do it is to just read it out of the + # configuration file, tell the user what you got and where you + # got it from, and not bother the user with picking --dir or + # --lvm or --evms at all, but infer it from the config file's + # disk = parameter. xen-delete-image might work the same way, + # but it could be *slightly* more dangerous in the context of + # deleting. $img = "/dev/evms/$name-disk"; # make sure it exists. From 7d9ee76da361132509a2d188a1d35eced43826da Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Wed, 26 May 2010 23:32:18 +0200 Subject: [PATCH 2/2] Offer --domaindir as alternativ to --dir See http://bugs.debian.org/477238 for the discussion. --- bin/xen-create-image | 63 ++++++++++++++++++++++++++++++---------- bin/xen-delete-image | 32 +++++++++++++++----- bin/xen-resize-guest | 40 +++++++++++++++++-------- bin/xen-update-image | 23 ++++++++++++--- bin/xt-create-xen-config | 2 +- debian/changelog | 2 ++ 6 files changed, 121 insertions(+), 41 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 7c99949..0d833ee 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -216,19 +216,35 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH. Mandatory options: + --domaindir=dir --dir=dir Specify where the output images should go. - Subdirectories will be created for each guest - If you do not wish to use loopback images specify --lvm - or --evms. (These three options are mutually exclusive.) + Subdirectories will be created for each guest. + + Using --dir will create subdirectory domains as before + for backwards compatibility, e.g. if you use + --dir=foo, the default disk image will go to + foo/domains/$hostname/disk.img. + + Using --domaindir will create direct subdirectories + named after the hostname as discussed in + http://bugs.debian.org/477238, e.g. if you use + --domaindir=foo, the default disk image will go to + foo/$hostname/disk.img. + + If you do not wish to use loopback images specify + --lvm or --evms. (These three respectively four + options are mutually exclusive.) --lvm=vg Specify the volume group to save images within. - If you do not wish to use LVM specify --dir or --evms. - (These three options are mutually exclusive.) + If you do not wish to use LVM specify --evms. or + --dir/--domaindir (These three respectively four + options are mutually exclusive.) --evms=lvm2/container Specify the container to save images within, i.e. '--evms lvm2/mycontainer'. If you do not wish to use EVMS specify - --dir or --lvm. (These three options are mutually exclusive.) + --dir/--domaindir or --lvm. (These three respectively + four options are mutually exclusive.) --hostname=host.example.org Set the hostname of the new guest system. Ideally @@ -862,7 +878,7 @@ checkBinariesPresent(); if ( !$#PARTITIONS ) { populatePartitionsData() - if ( ( $CONFIG{ 'dir' } ) || + if ( ( $CONFIG{ 'domaindir' } ) || ( $CONFIG{ 'evms' } ) || ( $CONFIG{ 'lvm' } ) ); } @@ -878,7 +894,7 @@ showSummary(); # # Create and format the images if we're using loopback filesystems. # -if ( $CONFIG{ 'dir' } ) +if ( $CONFIG{ 'domaindir' } ) { # @@ -1447,6 +1463,7 @@ sub parseCommandLineArguments my %install; $install{ 'evms' } = undef; $install{ 'dir' } = undef; + $install{ 'domaindir' } = undef; $install{ 'lvm' } = undef; $install{ 'image-dev' } = undef; @@ -1469,6 +1486,7 @@ sub parseCommandLineArguments # Locations "dir=s", \$install{ 'dir' }, + "domaindir=s", \$install{ 'domaindir' }, "evms=s", \$install{ 'evms' }, "kernel=s", \$CONFIG{ 'kernel' }, "initrd=s", \$CONFIG{ 'initrd' }, @@ -1557,12 +1575,22 @@ sub parseCommandLineArguments # - # Now make ensure that the command line setting of '--lvm', '--evms' - # and '--dir=x' override anything specified in the configuration file. + # Now make ensure that the command line setting of '--lvm', '--evms', + # '--domaindir=x' and '--dir=x' override anything specified in the + # configuration file. # if ( $install{ 'dir' } ) { - $CONFIG{ 'dir' } = $install{ 'dir' }; + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'domaindir' } = $install{ 'dir' }.'/domains'; + $CONFIG{ 'evms' } = undef; + $CONFIG{ 'lvm' } = undef; + $CONFIG{ 'image-dev' } = undef; + } + if ( $install{ 'domaindir' } ) + { + $CONFIG{ 'dir' } = undef; + $CONFIG{ 'domaindir' } = $install{ 'domaindir' }; $CONFIG{ 'evms' } = undef; $CONFIG{ 'lvm' } = undef; $CONFIG{ 'image-dev' } = undef; @@ -1570,6 +1598,7 @@ sub parseCommandLineArguments if ( $install{ 'evms' } ) { $CONFIG{ 'dir' } = undef; + $CONFIG{ 'domaindir' } = undef; $CONFIG{ 'evms' } = $install{ 'evms' }; $CONFIG{ 'lvm' } = undef; $CONFIG{ 'image-dev' } = undef; @@ -1577,6 +1606,7 @@ sub parseCommandLineArguments if ( $install{ 'lvm' } ) { $CONFIG{ 'dir' } = undef; + $CONFIG{ 'domaindir' } = undef; $CONFIG{ 'evms' } = undef; $CONFIG{ 'lvm' } = $install{ 'lvm' }; $CONFIG{ 'image-dev' } = undef; @@ -1584,6 +1614,7 @@ sub parseCommandLineArguments if ( $install{ 'image-dev' } ) { $CONFIG{ 'dir' } = undef; + $CONFIG{ 'domaindir' } = undef; $CONFIG{ 'evms' } = undef; $CONFIG{ 'lvm' } = undef; $CONFIG{ 'image-dev' } = $install{ 'image-dev' }; @@ -1709,7 +1740,7 @@ sub checkArguments my $err = <{ 'name' } . '.img'; if ( -e $disk ) @@ -2685,7 +2716,7 @@ sub createLoopbackImages foreach my $partition (@PARTITIONS) { my $disk = - $CONFIG{ 'dir' } . '/domains/' . $CONFIG{ 'hostname' } . '/' . + $CONFIG{ 'domaindir' } . '/' . $CONFIG{ 'hostname' } . '/' . $partition->{ 'name' } . '.img'; # diff --git a/bin/xen-delete-image b/bin/xen-delete-image index 546e13e..8a9f319 100755 --- a/bin/xen-delete-image +++ b/bin/xen-delete-image @@ -15,9 +15,12 @@ xen-delete-image - Delete previously created Xen instances. --verbose Show diagnostic output. General options: - --dir Specify the output directory where images were previously saved. - --lvm Specify the LVM volume to use. - --evms Specify the EVMS container to use. + --dir Specify the output directory where images were previously + saved. (old style) + --domaindir Specify the output directory where images were previously + saved. (new style) + --lvm Specify the LVM volume to use. + --evms Specify the EVMS container to use. Specifying hosts: --hostname Specify the image name to delete. @@ -33,7 +36,14 @@ xen-delete-image - Delete previously created Xen instances. =over 8 =item B<--dir> -Specify the output directory where images were previously saved. +Specify the output directory where images were previously saved. Looks +for directories named after the hostname in a subdirectory +"domains". (old style, see xen-create-image(1) for details) + +=item B<--domaindir> +Specify the output directory where images were previously saved. Looks +for directories named after the hostname directorly in this +directory. (new style, see xen-create-image(1) for details) =item B<--evms> Specify the EVMS container where images were previously saved. @@ -345,6 +355,7 @@ sub parseCommandLineArguments # Parse options. # GetOptions( "dir=s", \$CONFIG{ 'dir' }, + "domaindir=s", \$CONFIG{ 'domaindir' }, "dry-run", \$CONFIG{ 'dry-run' }, "lvm=s", \$CONFIG{ 'lvm' }, "evms=s", \$CONFIG{ 'evms' }, @@ -359,7 +370,6 @@ sub parseCommandLineArguments pod2usage(1) if $HELP; pod2usage( -verbose => 2 ) if $MANUAL; - if ($VERSION) { my $REVISION = '$Revision: 1.41 $'; @@ -373,6 +383,11 @@ sub parseCommandLineArguments exit; } + + if ($CONFIG{ 'dir' }) { + $CONFIG{ 'domaindir' } = $CONFIG{ 'dir' }.'/domains'; + $CONFIG{ 'dir' } = undef; + } } @@ -401,7 +416,7 @@ sub checkArguments # Make sure we got one and only one installation method. # my $count = 0; - foreach my $type (qw/dir lvm evms/) + foreach my $type (qw/dir domaindir lvm evms/) { $count += 1 if defined( $CONFIG{ $type } ); } @@ -414,6 +429,7 @@ sub checkArguments { print "Please select one and only one of the installation methods:\n"; print " --dir\n"; + print " --domaindir\n"; print " --evms\n"; print " --lvm\n"; exit; @@ -504,9 +520,9 @@ sub deleteXenImage } - if ( defined( $CONFIG{ 'dir' } ) ) + if ( defined( $CONFIG{ 'domaindir' } ) ) { - my $prefix = $CONFIG{ 'dir' } . "/domains/"; + my $prefix = $CONFIG{ 'domaindir' } . '/'; # # Now remove the directory. diff --git a/bin/xen-resize-guest b/bin/xen-resize-guest index 0c9192a..7986ee0 100755 --- a/bin/xen-resize-guest +++ b/bin/xen-resize-guest @@ -15,10 +15,11 @@ xen-resize-guest - Resize a loopback or LVM based xen guest. --verbose Show diagnostic output. General Options: - --add Specify the amount of space to add, e.g. --add=1gb - --dir Specify the path to the loopback image root. - --force Force the resize to happen without a last-chance delay. - --hostname Specify the hostname of the guest to resize. + --add Specify the amount of space to add, e.g. --add=1gb + --dir Specify the path to the loopback image root. (old style) + --domaindir Specify the path to the loopback image root. (new style) + --force Force the resize to happen without a last-chance delay. + --hostname Specify the hostname of the guest to resize. =cut @@ -28,10 +29,14 @@ xen-resize-guest - Resize a loopback or LVM based xen guest. =over 8 =item B<--add> -Specify the amount of storage to add to the primary disk. +Specify the amount of storage to add to the primary disk. Looks +for directories named after the hostname in a subdirectory +"domains". (old style, see xen-create-image(1) for details) -=item B<--dir> -Specify the directory where the loopback files are based. +=item B<--domaindir> +Specify the directory where the loopback files are based. Looks +for directories named after the hostname directorly in this +directory. (new style, see xen-create-image(1) for details) =item B<--force> Don't pause for 10 seconds prior to commencing. @@ -143,14 +148,14 @@ testArguments(); # my $path = undef; -if ( $CONFIG{ 'dir' } ) +if ( $CONFIG{ 'domaindir' } ) { # # Make sure we can find the disk # $path = - $CONFIG{ 'dir' } . "/domains/" . $CONFIG{ 'hostname' } . "/disk.img"; + $CONFIG{ 'domaindir' } . '/' . $CONFIG{ 'hostname' } . "/disk.img"; if ( !-e $path ) { print < 1 ) { - print "Please specify only one of --lvm or --dir - not both!\n"; + print "Please specify only one of --lvm, --domaindir or --dir - not several of them!\n"; exit 1; } diff --git a/bin/xen-update-image b/bin/xen-update-image index bd5f97c..dd9e419 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -14,7 +14,8 @@ xen-update-image - Update the software installed upon offline Xen images. --version Show the version number and exit. General Options: - --dir Specify the directory which contains the image(s). + --dir Specify the directory which contains the image(s). (old style) + --domaindir Specify the directory which contains the image(s). (new style) --lvm Specify the LVM volume group which contains the image(s). --evms Specify the EVMS container which contains the image(s). @@ -27,7 +28,14 @@ xen-update-image - Update the software installed upon offline Xen images. =over 8 =item B<--dir> -Specify the directory which contains the image(s). +Specify the directory which contains the image(s). Looks +for directories named after the hostname in a subdirectory +"domains". (old style, see xen-create-image(1) for details) + +=item B<--domaindir> +Specify the directory which contains the image(s). Looks +for directories named after the hostname directorly in this +directory. (new style, see xen-create-image(1) for details) =item B<--evms> Specify the EVMS container which contains the image(s). @@ -214,7 +222,7 @@ sub updateXenImage { # The loopback image. - $img = $CONFIG{ 'dir' } . "/domains/" . $name . "/disk.img"; + $img = $CONFIG{ 'domaindir' } . '/' . $name . "/disk.img"; if ( !-e $img ) { @@ -438,6 +446,7 @@ sub parseCommandLineArguments # Parse options. # GetOptions( "dir=s", \$CONFIG{ 'dir' }, "lvm=s", \$CONFIG{ 'lvm' }, + "domaindir=s", \$CONFIG{ 'dir' }, "evms=s", \$CONFIG{ 'evms' }, "help", \$HELP, "manual", \$MANUAL, "version", \$VERSION ); @@ -457,6 +466,11 @@ sub parseCommandLineArguments exit; } + + if ($CONFIG{ 'dir' }) { + $CONFIG{ 'domaindir' } = $CONFIG{ 'dir' }.'/domains'; + $CONFIG{ 'dir' } = undef; + } } @@ -477,7 +491,7 @@ sub checkArguments # Make sure we got one and only one installation method. # my $count = 0; - foreach my $type (qw/dir lvm evms/) + foreach my $type (qw/dir domaindir lvm evms/) { $count += 1 if defined( $CONFIG{ $type } ); } @@ -490,6 +504,7 @@ sub checkArguments { print "Please select one and only one of the installation methods:\n"; print " --dir\n"; + print " --domaindir\n"; print " --evms\n"; print " --lvm\n"; exit; diff --git a/bin/xt-create-xen-config b/bin/xt-create-xen-config index 8ae783c..1b45fd9 100755 --- a/bin/xt-create-xen-config +++ b/bin/xt-create-xen-config @@ -419,7 +419,7 @@ sub createXenConfig } else { - $ENV{ 'image_prefix' } = "file:$ENV{'dir'}/domains/$ENV{'hostname'}/"; + $ENV{ 'image_prefix' } = "file:$ENV{'domaindir'}/$ENV{'hostname'}/"; $ENV{ 'image_suffix' } = '.img'; importPartitionsFromEnvironment(); } diff --git a/debian/changelog b/debian/changelog index 5c32fa5..bd22261 100644 --- a/debian/changelog +++ b/debian/changelog @@ -41,6 +41,8 @@ xen-tools (4.2~rc1-1) UNRELEASED; urgency=low - Checks for debootstrap and cdebootstrap, uses debootstrap if both are installed (Changed "Depends: debootstrap" to "Depends: debootstrap | cdebootstrap" in debian/control) + - Introduces the --domaindir option as alternative to --dir which + always appends "/domains/" to the path. (Closes: #477238) * Removal of /etc/bash_completion.d/xm from the package since bash-completion ships a more elaborate version of that file. (Closes: #566683, #550590, LP: #538917, #484098)