From c03029e0c6509489834312f888523dee3f7bc92d Mon Sep 17 00:00:00 2001 From: Dmitry Nedospasov Date: Wed, 19 May 2010 13:46:58 +0200 Subject: [PATCH] Added support for (optionally) setting the bridge --bridge Added support for setting the number of vcpus --vcpus --- bin/xen-create-image | 11 +++++++++++ etc/xm.tmpl | 26 ++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index fef2720..4c1952f 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -137,6 +137,10 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH. Install a getty on the specified serial device instead of the default device. + --vcpus=num + Set the number of vcpus that the new instance will have + instead of the default value of "1". + Installation options: @@ -202,6 +206,10 @@ xen-create-image - Easily create new Xen instances with networking and OpenSSH. --broadcast=123.456.789.ABC Setup the broadcast address for the new instance. + --bridge=brname + Optionally, set a specific bridge for the new instance. + This can be especially useful when running multiple + bridges on a machine. Mandatory options: @@ -1225,6 +1233,7 @@ sub setupDefaultOptions $CONFIG{ 'swap' } = '128M'; $CONFIG{ 'cache' } = 'yes'; $CONFIG{ 'image' } = 'sparse'; + $CONFIG{ 'vcpus' } = '1'; # # Misc. options. @@ -1421,6 +1430,7 @@ sub parseCommandLineArguments "noswap", \$CONFIG{ 'noswap' }, "image=s", \$CONFIG{ 'image' }, "memory=s", \$CONFIG{ 'memory' }, + "vcpus=s", \$CONFIG{ 'vcpus' }, # Locations "dir=s", \$install{ 'dir' }, @@ -1441,6 +1451,7 @@ sub parseCommandLineArguments # Networking options "dhcp", \$CONFIG{ 'dhcp' }, + "bridge=s", \$CONFIG{ 'bridge' }, "gateway=s", \$CONFIG{ 'gateway' }, "hostname=s", \$CONFIG{ 'hostname' }, "ip=s@", \$CONFIG{ 'ip' }, diff --git a/etc/xm.tmpl b/etc/xm.tmpl index ad1a3d1..a3c565c 100644 --- a/etc/xm.tmpl +++ b/etc/xm.tmpl @@ -34,6 +34,7 @@ $OUT .= "bootloader = '$pygrub_bin'\n"; } } +vcpus = '{$vcpus}' memory = '{$memory}' # @@ -106,8 +107,22 @@ name = '{$hostname}' { $m = "mac=$mac" } - - $OUT .= "vif = [ '$m' ]"; + my $br = ''; + if ( $bridge ) + { + if ( $mac ) + { + $br = ",bridge=$bridge" + } + else + { + $br = "bridge=$bridge" + } + } + $OUT .= "vif = [ '"; + $OUT .= "$m"; + $OUT .= "$br"; + $OUT .= "' ]"; } else { @@ -126,9 +141,16 @@ name = '{$hostname}' $vn = ",vifname=$vifname"; } + my $br = ''; + if ( $bridge ) + { + $br = ",bridge=$bridge" + } + $OUT .= "vif = [ 'ip=$ip1"; $OUT .= "$m"; $OUT .= "$vn"; + $OUT .= "$br"; $OUT .= "' ]"; } }