[pve-devel] r5213 - qemu-server/pve2

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Oct 5 12:38:47 CEST 2010


Author: dietmar
Date: 2010-10-05 10:38:47 +0000 (Tue, 05 Oct 2010)
New Revision: 5213

Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/qmrestore
Log:
010-10-05  Seth Lauzon <seth.lauzon at gmail.com>

        * qmrestore (restore_qemu): new option --unique (create unique MAC
        address on restore)




Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-10-05 10:31:55 UTC (rev 5212)
+++ qemu-server/pve2/ChangeLog	2010-10-05 10:38:47 UTC (rev 5213)
@@ -1,3 +1,8 @@
+2010-10-05  Seth Lauzon <seth.lauzon at gmail.com>
+
+        * qmrestore (restore_qemu): new option --unique (create unique MAC
+        address on restore)
+
 2010-09-21  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/QemuServer.pm (new): remove unused method

Modified: qemu-server/pve2/qmrestore
===================================================================
--- qemu-server/pve2/qmrestore	2010-10-05 10:31:55 UTC (rev 5212)
+++ qemu-server/pve2/qmrestore	2010-10-05 10:38:47 UTC (rev 5213)
@@ -32,7 +32,7 @@
 
 openlog ('vzdump', 'cons,pid', 'daemon');
 
-my @std_opts = ('extract', 'storage=s', 'info', 'prealloc');
+my @std_opts = ('extract', 'storage=s', 'info', 'prealloc', 'unique');
 
 sub print_usage {
     my $msg = shift;
@@ -295,14 +295,23 @@
 	    next if $line =~ m/^\#vzdump\#/;
 	    next if $line =~ m/^lock:/;
 
-	    $line =~ m/^((ide|scsi|virtio)\d+):(.*)$/;
-	    my $virtdev = $1;
-	    my $value = $2;
-	    if ($virtdev && $map->{$virtdev}) {
-		my $di = PVE::QemuServer::parse_drive ($virtdev, $value);
-		$di->{file} = $map->{$virtdev};
-		$value = PVE::QemuServer::print_drive ($vmid, $di);
-		print $outfd "$virtdev: $value\n";
+	    if (($line =~ m/^((vlan)\d+):(.*)$/) && ($opts->{unique})) {
+		my ($id,$ethcfg) = ($1,$3);
+		$ethcfg =~ s/^\s+//;
+		my ($model, $mac) = split(/\=/,$ethcfg);
+		my $printvlan = PVE::QemuServer::print_vlan (PVE::QemuServer::parse_vlan ($model));
+		print $outfd "$id: $printvlan\n";
+	    } elsif ($line =~ m/^((ide|scsi|virtio)\d+):(.*)$/) {
+		my $virtdev = $1;
+		my $value = $2;
+		if ($virtdev && $map->{$virtdev}) {
+		    my $di = PVE::QemuServer::parse_drive ($virtdev, $value);
+		    $di->{file} = $map->{$virtdev};
+		    $value = PVE::QemuServer::print_drive ($vmid, $di);
+		    print $outfd "$virtdev: $value\n";
+		} else {
+		    print $outfd $line;
+		}
 	    } else {
 		print $outfd $line;
 	    }
@@ -392,6 +401,8 @@
  --info                    read/verify archive and print relevant 
                            information (test run)
 
+ --unique		   assign a unique random ethernet address
+
  --storage <STORAGE_ID>    restore to storage <STORAGE_ID>
 
  --prealloc                never generate sparse files




More information about the pve-devel mailing list