[pve-devel] r5263 - in qemu-server/pve2: . PVE PVE/VZDump

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Oct 12 10:49:17 CEST 2010


Author: dietmar
Date: 2010-10-12 08:49:17 +0000 (Tue, 12 Oct 2010)
New Revision: 5263

Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/PVE/QemuServer.pm
   qemu-server/pve2/PVE/VZDump/QemuServer.pm
   qemu-server/pve2/qmrestore
Log:


Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-10-12 08:38:59 UTC (rev 5262)
+++ qemu-server/pve2/ChangeLog	2010-10-12 08:49:17 UTC (rev 5263)
@@ -1,3 +1,11 @@
+2010-10-12  Proxmox Support Team  <support at proxmox.com>
+
+	* PVE/QemuServer.pm (parse_drive): add 'backup=[yes|no]' attribute.
+
+	* qmrestore (restore_qemu): comment out disks with backup=no
+
+	* PVE/VZDump/QemuServer.pm (prepare): skip disks with backup=no
+
 2010-10-05  Seth Lauzon <seth.lauzon at gmail.com>
 
         * qmrestore (restore_qemu): new option --unique (create unique MAC

Modified: qemu-server/pve2/PVE/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/QemuServer.pm	2010-10-12 08:38:59 UTC (rev 5262)
+++ qemu-server/pve2/PVE/QemuServer.pm	2010-10-12 08:49:17 UTC (rev 5263)
@@ -428,7 +428,7 @@
 my $idedesc = {
     optional => 1,
     type => 'string', format => 'pve-qm-drive',
-    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f]',
+    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f] [,backup=yes|no]',
     description => "Use volume as IDE hard disk or CD-ROM (n is 0 to 3).",
 };
 PVE::JSONSchema::register_standard_option("pve-qm-ide", $idedesc);
@@ -436,7 +436,7 @@
 my $scsidesc = {
     optional => 1,
     type => 'string', format => 'pve-qm-drive',
-    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f]',
+    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f] [,backup=yes|no]',
     description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to 15).",
 };
 PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
@@ -444,7 +444,7 @@
 my $virtiodesc = {
     optional => 1,
     type => 'string', format => 'pve-qm-drive',
-    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f]',
+    typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback] [,format=f] [,backup=yes|no]',
     description => "Use volume as VIRTIO hard disk (n is 0 to 15).",
 };
 PVE::JSONSchema::register_standard_option("pve-qm-virtio", $virtiodesc);
@@ -721,14 +721,14 @@
 }
 
 # ideX = [volume=]volume-id[,media=d][,cyls=c,heads=h,secs=s[,trans=t]]
-#        [,snapshot=on|off][,cache=on|off][,format=f]
+#        [,snapshot=on|off][,cache=on|off][,format=f][,backup=yes|no]
 
 sub parse_drive {
     my ($key, $data) = @_;
 
     my $res = {};
     
-    # $key my be undefined - used to verify JSON parameters
+    # $key may be undefined - used to verify JSON parameters
     if (!defined($key)) {
 	$res->{interface} = 'unknown'; # should not harm when used to verify parameters
 	$res->{index} = 0;
@@ -742,7 +742,7 @@
     foreach my $p (split (/,/, $data)) {
 	next if $p =~ m/^\s*$/;
 
-	if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror)=(.+)$/) {
+	if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup)=(.+)$/) {
 	    my ($k, $v) = ($1, $2);
 
 	    $k = 'file' if $k eq 'volume';
@@ -772,6 +772,7 @@
     return undef if $res->{format} && $res->{format} !~ m/^(raw|cow|qcow|qcow2|vmdk|cloop)$/;
     return undef if $res->{rerror} && $res->{rerror} !~ m/^(ignore|report|stop)$/;
     return undef if $res->{werror} && $res->{werror} !~ m/^(enospc|ignore|report|stop)$/;
+    return undef if $res->{backup} && $res->{backup} !~ m/^(yes|no)$/;
 
     if ($res->{media} && ($res->{media} eq 'cdrom')) {
 	return undef if $res->{snapshot} || $res->{trans} || $res->{format};
@@ -787,21 +788,15 @@
     return $res;
 }
 
-sub get_qemu_drive_options {
-    my ($drive) = @_;
+my @qemu_drive_options = qw(heads secs cyls trans media format cache snapshot rerror werror);
 
-    my $res = '';
-    foreach my $o (qw(heads secs cyls trans media format cache snapshot rerror werror)) {
-	$res .= ",$o=$drive->{$o}" if $drive->{$o};
-    }
-
-    return $res;
-}
-
 sub print_drive {
     my ($vmid, $drive) = @_;
 
-    my $opts = get_qemu_drive_options ($drive);
+    my $opts = '';
+    foreach my $o (@qemu_drive_options, 'backup') {
+	$opts .= ",$o=$drive->{$o}" if $drive->{$o};
+    }
 
     return "$drive->{file}$opts";
 }
@@ -809,7 +804,10 @@
 sub print_drive_full {
     my ($storecfg, $vmid, $drive) = @_;
 
-    my $opts = get_qemu_drive_options ($drive);
+    my $opts = '';
+    foreach my $o (@qemu_drive_options) {
+	$opts .= ",$o=$drive->{$o}" if $drive->{$o};
+    } 
 
     my $path;
     my $volid = $drive->{file};

Modified: qemu-server/pve2/PVE/VZDump/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/VZDump/QemuServer.pm	2010-10-12 08:38:59 UTC (rev 5262)
+++ qemu-server/pve2/PVE/VZDump/QemuServer.pm	2010-10-12 08:49:17 UTC (rev 5263)
@@ -81,6 +81,11 @@
 
 	return if PVE::QemuServer::drive_is_cdrom ($drive);
 
+	if (defined($drive->{backup}) && $drive->{backup} eq "no") {
+	    $self->loginfo("exclude disk '$ds' (backup=no)");
+	    return;
+	}	   
+ 
 	my $volid = $drive->{file};
 
 	my $path;

Modified: qemu-server/pve2/qmrestore
===================================================================
--- qemu-server/pve2/qmrestore	2010-10-12 08:38:59 UTC (rev 5262)
+++ qemu-server/pve2/qmrestore	2010-10-12 08:49:17 UTC (rev 5263)
@@ -304,7 +304,9 @@
 	    } elsif ($line =~ m/^((ide|scsi|virtio)\d+):(.*)$/) {
 		my $virtdev = $1;
 		my $value = $2;
-		if ($virtdev && $map->{$virtdev}) {
+		if ($line =~ m/backup=no/) {
+		    print $outfd "#$line";
+		} elsif ($virtdev && $map->{$virtdev}) {
 		    my $di = PVE::QemuServer::parse_drive ($virtdev, $value);
 		    $di->{file} = $map->{$virtdev};
 		    $value = PVE::QemuServer::print_drive ($vmid, $di);



More information about the pve-devel mailing list