[pve-devel] r5165 - in qemu-server/pve2: . PVE PVE/API2/Qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Sep 16 15:17:19 CEST 2010


Author: dietmar
Date: 2010-09-16 13:17:19 +0000 (Thu, 16 Sep 2010)
New Revision: 5165

Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/PVE/API2/Qemu/Config.pm
   qemu-server/pve2/PVE/QemuServer.pm
Log:
	(parse_config): remove diskinfo
	(config_to_command): also return volume ID list
	(activate_volumes): removed



Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-09-16 12:13:05 UTC (rev 5164)
+++ qemu-server/pve2/ChangeLog	2010-09-16 13:17:19 UTC (rev 5165)
@@ -1,6 +1,9 @@
 2010-09-16  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/QemuServer.pm (disknames): removed - no longer needed
+	(parse_config): remove diskinfo
+	(config_to_command): also return volume ID list
+	(activate_volumes): removed
 
 	* PVE/QemuServer.pm (parse_options_new): removed - no longer needed
 

Modified: qemu-server/pve2/PVE/API2/Qemu/Config.pm
===================================================================
--- qemu-server/pve2/PVE/API2/Qemu/Config.pm	2010-09-16 12:13:05 UTC (rev 5164)
+++ qemu-server/pve2/PVE/API2/Qemu/Config.pm	2010-09-16 13:17:19 UTC (rev 5165)
@@ -330,11 +330,6 @@
 
 	my $conf = PVE::QemuServer::load_config ($param->{vmid});
 
-	# fixme: that should not be added to the config
-	delete $conf->{disksize};
-	delete $conf->{disktype};
-	delete $conf->{diskinfo};
-
 	return $conf;
     }});
 

Modified: qemu-server/pve2/PVE/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/QemuServer.pm	2010-09-16 12:13:05 UTC (rev 5164)
+++ qemu-server/pve2/PVE/QemuServer.pm	2010-09-16 13:17:19 UTC (rev 5165)
@@ -1202,24 +1202,25 @@
 
     check_lock ($conf);
 
-    my $di = $conf->{diskinfo};
-
     # only remove disks owned by this VM 
-    foreach my $ds (keys %$di) {
-	next if drive_is_cdrom ($di->{$ds});
+    foreach my $ds (keys %$conf) {
+	next if !valid_drivename($ds);
 
-	my $volid = $di->{$ds}->{file};
-	next if !$volid;
-	next if $volid =~ m|^/|;
+	my $drive = parse_drive ($ds, $conf->{$ds});
+	next if !$drive;
 
+	next if drive_is_cdrom ($drive);
+
+	my $volid = $drive->{file};
+	next if !$volid || $volid =~ m|^/|;
+
 	my ($path, $owner) = PVE::Storage::path ($storecfg, $volid);
-	next if !$path;
-	next if !$owner || ($owner != $vmid);
+	next if !$path || !$owner || ($owner != $vmid);
 
 	PVE::Storage::vdisk_free ($storecfg, $volid);
     }
     
-    system ("rm -f '$conffile'");
+    unlink $conffile;
 
     # also remove unused disk
     eval {
@@ -1237,6 +1238,7 @@
     warn $@ if $@;
 }
 
+# fixme: remove?
 sub load_diskinfo {
     my ($storecfg, $vmid, $conf) = @_;
 
@@ -1267,7 +1269,7 @@
 	PVE::Storage::foreach_volid ($dl, sub {
 	    my ($volid, $sid, $volname, $d) = @_;
 	    $info->{$volid} = $d;
-				     });
+	});
     };
     warn $@ if $@;
 
@@ -1347,23 +1349,6 @@
     } 
     delete $res->{smp};
 
-    my $disksize = 0;
-    my $disktype = 'none';
- 
-    my $di = load_diskinfo ($storecfg, $vmid, $res);
-
-    foreach my $ds (keys %$di) {
-	my $size = $di->{$ds}->{disksize};
-	if ($res->{bootdisk} && ($ds eq $res->{bootdisk}) && $size) {
-	    $disksize = $size;
-	    $disktype = $di->{$ds}->{interface};
-	}
-    }
-
-    $res->{disksize} = $disksize;
-    $res->{disktype} = $disktype;
-    $res->{diskinfo} = $di;
-
     return $res;
 }
 
@@ -1635,12 +1620,15 @@
 	# fixme: better status?
 	$d->{status} = $list->{$veid}->{pid} ? 'running' : 'stopped';
 	$d->{ip} = '-';
+
+	# fixme: where to get disk info/usage ?
 	$d->{disk} = 0;
+	$d->{maxdisk} = 0;
+
 	$d->{cpus} = ($conf->{sockets} || 1) * ($conf->{cores} || 1);
 	$d->{name} = $conf->{name} || "VM$veid";
 	$d->{maxmem} = $conf->{memory} ? $conf->{memory} : 0; 
 
-	$d->{maxdisk} = $conf->{disksize} ? int($conf->{disksize}*1024) : 0;
 
 	$d->{uptime} = 0;
 	$d->{pctcpu} = 0;
@@ -1865,12 +1853,22 @@
     #push @$cmd, '-soundhw', 'es1370';
     #push @$cmd, '-soundhw', $soundhw if $soundhw;
 
-    my $di = $conf->{diskinfo};
-    foreach my $ds (sort keys %$di) {
+    my $vollist = [];
+    foreach my $ds (keys %$conf) {
+	next if !valid_drivename($ds);
+
+	my $drive = parse_drive ($ds, $conf->{$ds});
+	next if !$drive;
+
+	eval { 
+	    PVE::Storage::parse_volume_id ($drive->{file});
+	    push @$vollist, $drive->{file};
+	}; # ignore errors
+
 	$use_virtio = 1 if $ds =~ m/^virtio/;
-	my $drive = print_drive_full ($storecfg, $vmid, $di->{$ds});
-	$drive .= ",boot=on" if $conf->{bootdisk} && ($conf->{bootdisk} eq $ds);
-	push @$cmd, '-drive', $drive;
+	my $tmp = print_drive_full ($storecfg, $vmid, $drive);
+	$tmp .= ",boot=on" if $conf->{bootdisk} && ($conf->{bootdisk} eq $ds);
+	push @$cmd, '-drive', $tmp;
     }
 
     if ($conf->{memory}) {
@@ -1937,7 +1935,7 @@
 	push @$cmd, @$aa;
     }
 
-    return $cmd;
+    return wantarray ? ($cmd, $vollist) : $cmd;
 }
  
 sub vnc_socket {
@@ -2016,23 +2014,6 @@
     die "unable to find free vnc port";
 };
 
-sub activate_volumes {
-    my ($storecfg, $conf)  = @_;
-
-    my $di = $conf->{diskinfo};
-
-    my $vollist = [];
-    foreach my $ds (keys %$di) {
-	my $volid = $di->{$ds}->{file};
-	eval { 
-	    PVE::Storage::parse_volume_id ($volid);
-	    push @$vollist, $volid;
-	};
-    }
-
-    PVE::Storage::activate_volumes ($storecfg, $vollist);
-}
-
 sub vm_start {
     my ($storecfg, $vmid, $statefile, $skiplock) = @_;
 
@@ -2069,7 +2050,7 @@
 
 	my $defaults = load_defaults();
 
-	my $cmd = config_to_command ($storecfg, $vmid, $conf, $defaults, $migrate_uri);
+	my ($cmd, $vollist) = config_to_command ($storecfg, $vmid, $conf, $defaults, $migrate_uri);
 	# host pci devices
 	if (my $pcidl = $conf->{hostpci}) {
 	    my @dl = split (/,/, $pcidl);
@@ -2082,7 +2063,7 @@
 	    }
 	}
 
-	activate_volumes ($storecfg, $conf);
+	PVE::Storage::activate_volumes($storecfg, $vollist);
 
 	eval  { run_command ($cmd, timeout => $migrate_uri ? undef : 30); };
 




More information about the pve-devel mailing list