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

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Sep 21 11:23:52 CEST 2010


Author: dietmar
Date: 2010-09-21 09:23:52 +0000 (Tue, 21 Sep 2010)
New Revision: 5191

Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/qmigrate
Log:

* qmigrate (logmsg): remove PVE::QemuServer->new() call.



Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-09-21 09:10:37 UTC (rev 5190)
+++ qemu-server/pve2/ChangeLog	2010-09-21 09:23:52 UTC (rev 5191)
@@ -1,5 +1,7 @@
 2010-09-21  Proxmox Support Team  <support at proxmox.com>
 
+	* qmigrate (logmsg): remove PVE::QemuServer->new() call.
+
 	* PVE/VZDump/QemuServer.pm (prepare): remove PVE::QemuServer->new() call.
 
 2010-09-17  Proxmox Support Team  <support at proxmox.com>

Modified: qemu-server/pve2/qmigrate
===================================================================
--- qemu-server/pve2/qmigrate	2010-09-21 09:10:37 UTC (rev 5190)
+++ qemu-server/pve2/qmigrate	2010-09-21 09:23:52 UTC (rev 5191)
@@ -6,6 +6,7 @@
 use IO::Select;
 use IPC::Open3;
 use IPC::Open2;
+use PVE::INotify qw(read_file);
 use PVE::QemuServer;
 use PVE::Storage;
 use POSIX qw(strftime);
@@ -69,7 +70,7 @@
 logmsg ('err', "illegal VMID") if $vmid !~ m/^\d+$/;
 $vmid = int ($vmid); # remove leading zeros
 
-my $qm = PVE::QemuServer->new();
+my $storecfg = read_file('storagecfg');
 
 my $conffile = PVE::QemuServer::config_file ($vmid);
 
@@ -133,16 +134,14 @@
 
     eval {
 
-	my $di =  $conf->{diskinfo};
-
 	my $volhash = {};
 
 	# get list from PVE::Storage (for unused volumes)
-	my $dl = PVE::Storage::vdisk_list ($qm->{storecfg}, undef, $vmid);
+	my $dl = PVE::Storage::vdisk_list ($storecfg, undef, $vmid);
 	PVE::Storage::foreach_volid ($dl, sub {
 	    my ($volid, $sid, $volname) = @_;
 
-	    my $scfg =  PVE::Storage::storage_config ($qm->{storecfg}, $sid);
+	    my $scfg =  PVE::Storage::storage_config ($storecfg, $sid);
 
 	    return if $scfg->{shared};
 
@@ -152,23 +151,26 @@
 	# and add used,owned/non-shared disks (just to be sure we have all)  
 
 	my $sharedvm = 1;
-	foreach my $ds (keys %$di) {
+	foreach my $ds (keys %$conf) {
+	    next if ! PVE::QemuServer::valid_drivename($ds); # only drives
 
-	    next if PVE::QemuServer::drive_is_cdrom ($di->{$ds});
+	    my $drive = PVE::QemuServer::parse_drive ($ds, $conf->{$ds});
+	    next if PVE::QemuServer::drive_is_cdrom ($drive);
 
-	    my $volid = $di->{$ds}->{file};
+	    my $volid = $drive->{file};
+
 	    next if !$volid;
 	    die "cant migrate local file/device '$volid'\n" if $volid =~ m|^/|;
 
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id ($volid);
 
-	    my $scfg =  PVE::Storage::storage_config ($qm->{storecfg}, $sid);
+	    my $scfg =  PVE::Storage::storage_config ($storecfg, $sid);
 
 	    next if $scfg->{shared};
 
 	    $sharedvm = 0;
 
-	    my ($path, $owner) = PVE::Storage::path ($qm->{storecfg}, $volid);
+	    my ($path, $owner) = PVE::Storage::path ($storecfg, $volid);
 
 	    die "can't migrate volume '$volid' - owned by other VM (owner = VM $owner)\n" 
 		if !$owner || ($owner != $vmid);
@@ -183,7 +185,7 @@
 	# do some checks first
 	foreach my $volid (keys %$volhash) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id ($volid);
-	    my $scfg =  PVE::Storage::storage_config ($qm->{storecfg}, $sid);
+	    my $scfg =  PVE::Storage::storage_config ($storecfg, $sid);
 
 	    die "can't migrate '$volid' - storagy type '$scfg->{type}' not supported\n"
 		if $scfg->{type} ne 'dir';
@@ -192,7 +194,7 @@
 	foreach my $volid (keys %$volhash) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id ($volid);
 	    push @{$rhash->{volumes}}, $volid;
-	    PVE::Storage::storage_migrate ($qm->{storecfg}, $volid, $host, $sid);
+	    PVE::Storage::storage_migrate ($storecfg, $volid, $host, $sid);
 	}
 
     };
@@ -310,12 +312,12 @@
 
     my $start = time();
 
-    $qm->vm_monitor_command ($vmid, "migrate -d \"tcp:localhost:$lport\"");
+    PVE::QemuServer::vm_monitor_command ($vmid, "migrate -d \"tcp:localhost:$lport\"");
 
     my $lstat = '';
     while (1) {
 	sleep (2);
-	my $stat = $qm->vm_monitor_command ($vmid, "info migrate", 1);
+	my $stat = PVE::QemuServer::vm_monitor_command ($vmid, "info migrate", 1);
 	if ($stat =~ m/^Migration status: (active|completed|failed|cancelled)$/im) {
 	    my $ms = $1;
 
@@ -363,7 +365,7 @@
     eval_int (\&prepare);
     die $@ if $@;
 
-    my $conf = $qm->load_config ($vmid);
+    my $conf = PVE::QemuServer::load_config($vmid);
 
     PVE::QemuServer::check_lock ($conf);
 	
@@ -416,7 +418,7 @@
 	}
 
 	# always stop local VM - no interrupts possible
-	eval { $qm->vm_stop ($vmid, 1); };
+	eval { PVE::QemuServer::vm_stop ($vmid, 1); };
 	if ($@) {
 	    logmsg ('err', "stopping vm failed - $@");
 	    $errors = 1;
@@ -442,7 +444,7 @@
 
     # destroy local copies
     foreach my $volid (@$volids) {
-	eval_int (sub { PVE::Storage::vdisk_free ($qm->{storecfg}, $volid); });
+	eval_int (sub { PVE::Storage::vdisk_free ($storecfg, $volid); });
 	my $err = $@;
 
 	if ($err) {




More information about the pve-devel mailing list