]> git.proxmox.com Git - qemu-server.git/commitdiff
add qemu_machine_feature_enabled sub
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 16 Mar 2015 04:57:41 +0000 (05:57 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 17 Mar 2015 07:55:49 +0000 (08:55 +0100)
This sub compare current machine type to a specific version,
and return 1 if machinetype is bigger or equal to version

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/QemuServer.pm

index 00cff6721bab936b5e8d9e64e18105bd5917ada2..db8572baa1fa2dde375bacaaf776fc759d1a0669 100644 (file)
@@ -2651,6 +2651,7 @@ sub config_to_command {
 
     my $q35 = machine_type_is_q35($conf);
     my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
 
     my $q35 = machine_type_is_q35($conf);
     my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
+    my $machine_type = $forcemachine || $conf->{machine};
 
     push @$cmd, '/usr/bin/kvm';
 
 
     push @$cmd, '/usr/bin/kvm';
 
@@ -2881,7 +2882,6 @@ sub config_to_command {
        die "No accelerator found!\n" if !$cpuinfo->{hvm};
     }
 
        die "No accelerator found!\n" if !$cpuinfo->{hvm};
     }
 
-    my $machine_type = $forcemachine || $conf->{machine};
     if ($machine_type) {
        push @$machineFlags, "type=${machine_type}";
     }
     if ($machine_type) {
        push @$machineFlags, "type=${machine_type}";
     }
@@ -6117,6 +6117,28 @@ sub get_current_qemu_machine {
     return $current || $default || 'pc';
 }
 
     return $current || $default || 'pc';
 }
 
+sub qemu_machine_feature_enabled {
+    my ($machine, $kvmver, $version_major, $version_minor) = @_;
+
+    my $current_major;
+    my $current_minor;
+
+    if ($machine && $machine =~ m/^(pc(-i440fx|-q35)?-(\d+)\.(\d+))/) {
+
+       $current_major = $3;
+       $current_minor = $4;
+
+    } elsif ($kvmver =~ m/^(\d+)\.(\d+)/) {
+
+       $current_major = $1;
+       $current_minor = $2;
+    }
+
+    return 1 if $current_major >= $version_major && $current_minor >= $version_minor;
+
+
+}
+
 sub lspci {
 
     my $devices = {};
 sub lspci {
 
     my $devices = {};