[pve-devel] [PATCH 1/3] add qemu_machine_pxe

Alexandre Derumier aderumier at odiso.com
Fri Nov 6 10:27:04 CET 2015


return machinename with .pxe suffix if a nic with pxe romfile exist

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm | 12 ++----------
 PVE/QemuServer.pm  | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index ffa7a0b..7ae3880 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -141,16 +141,8 @@ sub prepare {
     if (my $pid = PVE::QemuServer::check_running($vmid)) {
 	die "cant migrate running VM without --online\n" if !$online;
 	$running = $pid;
-	$self->{forcemachine} = PVE::QemuServer::get_current_qemu_machine($vmid);
-
-	foreach my $opt (keys %$conf) {
-	    next if $opt !~ m/^net(\d+)$/;
-	    my $net = PVE::QemuServer::parse_net($conf->{$opt});
-	    next if !$net;
-	    my $romfile = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, 'qom-get', path => $opt, property => 'romfile');
-	    $self->{forcemachine} .= '.pxe' if $romfile =~ m/pxe/;
-	    last;
-	}
+
+	$self->{forcemachine} = PVE::QemuServer::qemu_machine_pxe($vmid, $conf);
 
     }
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 8b6da2f..0aa1ff4 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6365,6 +6365,22 @@ sub qemu_machine_feature_enabled {
 
 }
 
+sub qemu_machine_pxe {
+    my ($vmid, $conf, $machine) = @_;
+
+    $machine =  PVE::QemuServer::get_current_qemu_machine($vmid) if !$machine;
+
+    foreach my $opt (keys %$conf) {
+	next if $opt !~ m/^net(\d+)$/;
+	my $net = PVE::QemuServer::parse_net($conf->{$opt});
+	next if !$net;
+	my $romfile = PVE::QemuServer::vm_mon_cmd_nocheck($vmid, 'qom-get', path => $opt, property => 'romfile');
+	return $machine.".pxe" if $romfile =~ m/pxe/;
+	last;
+    }
+
+}
+
 sub lspci {
 
     my $devices = {};
-- 
2.1.4




More information about the pve-devel mailing list