summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <palcantara@suse.de>2018-04-17 11:05:07 -0300
committerPaulo Alcantara <palcantara@suse.de>2018-04-17 11:05:07 -0300
commit01c15ba45f0d38305b5c01b630e67c9ecd0da781 (patch)
treed6ff9fbbdb9826e8808399d02047ad3c210c2b64
parent951f9e06006a3f6b70dec8cc0ae4da741d6085f3 (diff)
downloadvmhtool-01c15ba45f0d38305b5c01b630e67c9ecd0da781.tar.gz
vmhtool-01c15ba45f0d38305b5c01b630e67c9ecd0da781.tar.xz
vmhtool-01c15ba45f0d38305b5c01b630e67c9ecd0da781.zip
Only generate random macaddr for new vm entries
Signed-off-by: Paulo Alcantara <palcantara@suse.de>
-rwxr-xr-xvmhelper27
1 files changed, 15 insertions, 12 deletions
diff --git a/vmhelper b/vmhelper
index 50a9b4b..7148a09 100755
--- a/vmhelper
+++ b/vmhelper
@@ -300,12 +300,26 @@ usage() unless $vm_name;
my $vm_img_path = "$vm_path/$vm_name.img";
+sub get_vm_macaddr {
+ open(my $conf, "<", $vm_info) or die "failed to open vm info file: $!";
+ while (<$conf>) {
+ chomp;
+ next unless /^$vm_name\s+.*$/;
+ my ($name, $macaddr) = split /\s+/;
+ return $macaddr;
+ }
+ return '';
+}
+
if ($install_iso_path) {
create_guest_img($vm_img_path);
create_tap_dev();
- my $macaddr = get_random_macaddr();
+ my $macaddr = get_vm_macaddr();
+ unless ($macaddr) {
+ $macaddr = get_random_macaddr();
+ }
my $qemu_cmd = "/usr/bin/qemu-system-x86_64";
if ($windows_guest) {
@@ -335,17 +349,6 @@ if ($install_iso_path) {
exit 0;
}
-sub get_vm_macaddr {
- open(my $conf, "<", $vm_info) or die "failed to open vm info file: $!";
- while (<$conf>) {
- chomp;
- next unless /^$vm_name\s+.*$/;
- my ($name, $macaddr) = split /\s+/;
- return $macaddr;
- }
- return '';
-}
-
die "$vm_img_path does not exist" unless -f $vm_img_path;
if ($delete_vm) {