[pve-devel] [PATCH] add machine parameter to qemu command
Stefan Priebe
s.priebe at profihost.ag
Sat May 25 23:03:18 CEST 2013
Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
---
PVE/QemuServer.pm | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index fe479a1..eb06688 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -236,6 +236,13 @@ my $confdesc = {
enum => [qw(lsi virtio-scsi-pci megasas)],
default => 'lsi',
},
+ machine => {
+ optional => 1,
+ type => 'string',
+ description => "qemu machine version",
+ enum => [qw(q35 pc-q35-1.5 pc-q35-1.4 pc-i440fx-1.5 pc-i440fx-1.4)],
+ default => 'pc-i440fx-1.5',
+ },
description => {
optional => 1,
type => 'string',
@@ -2251,6 +2258,9 @@ sub config_to_command {
push @$cmd, '-id', $vmid;
+ my $machine = defined($conf->{machine}) ? $conf->{machine} : $defaults->{machine};
+ push @$cmd, '-machine', $machine;
+
my $use_virtio = 0;
my $qmpsocket = qmp_socket($vmid);
@@ -2991,6 +3001,18 @@ sub vm_start {
# set environment variable useful inside network script
$ENV{PVE_MIGRATED_FROM} = $migratedfrom if $migratedfrom;
+ # gather machine value before we create the command
+ if (!$statefile && !$migratedfrom && (!$conf->{machine} || $conf->{machine} ne $defaults->{machine})) {
+ # this is a FRESH start (no migration no snapshot (statefile))
+ $conf->{machine} = $defaults->{machine};
+ update_config_nolock($vmid, $conf, 1);
+ } elsif (!defined $conf->{machine}) {
+ # migration or snapshot (OLD so this should be qemu 1.4)
+ $conf->{machine} = "pc-i440fx-1.4";
+ # do not "create" a config on migration
+ update_config_nolock($vmid, $conf, 1) if (!$migratedfrom);
+ }
+
my ($cmd, $vollist) = config_to_command($storecfg, $vmid, $conf, $defaults);
my $migrate_port = 0;
--
1.7.10.4
More information about the pve-devel
mailing list