5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-25 06:03:52 +03:00

API extension: add 'machine' parameter to vm_start

This allows us to overwrite the machine type at start - useful for
migration to make sure we use the same machine at the target node.
This commit is contained in:
Dietmar Maurer 2013-06-05 09:27:31 +02:00
parent 3bafc5106e
commit 952958bc87
2 changed files with 10 additions and 7 deletions

View File

@ -1314,7 +1314,7 @@ __PACKAGE__->register_method({
skiplock => get_standard_option('skiplock'),
stateuri => get_standard_option('pve-qm-stateuri'),
migratedfrom => get_standard_option('pve-node',{ optional => 1 }),
machine => get_standard_option('pve-qm-machine'),
},
},
returns => {
@ -1331,6 +1331,8 @@ __PACKAGE__->register_method({
my $vmid = extract_param($param, 'vmid');
my $machine = extract_param($param, 'machine');
my $stateuri = extract_param($param, 'stateuri');
raise_param_exc({ stateuri => "Only root may use this option." })
if $stateuri && $authuser ne 'root@pam';
@ -1371,7 +1373,7 @@ __PACKAGE__->register_method({
syslog('info', "start VM $vmid: $upid\n");
PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom);
PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom, undef, $machine);
return;
};

View File

@ -2219,7 +2219,7 @@ sub foreach_volid {
}
sub config_to_command {
my ($storecfg, $vmid, $conf, $defaults) = @_;
my ($storecfg, $vmid, $conf, $defaults, $forcemachine) = @_;
my $cmd = [];
my $globalFlags = [];
@ -2384,8 +2384,9 @@ sub config_to_command {
die "No accelerator found!\n" if !$cpuinfo->{hvm};
}
if ($conf->{machine}) {
push @$machineFlags, "type=$conf->{machine}";
my $machine_type = $forcemachine || $conf->{machine};
if ($machine_type) {
push @$machineFlags, "type=${machine_type}";
}
if ($conf->{startdate}) {
@ -2972,7 +2973,7 @@ sub qga_unfreezefs {
}
sub vm_start {
my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused) = @_;
my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, $forcemachine) = @_;
lock_config($vmid, sub {
my $conf = load_config($vmid, $migratedfrom);
@ -2988,7 +2989,7 @@ sub vm_start {
# set environment variable useful inside network script
$ENV{PVE_MIGRATED_FROM} = $migratedfrom if $migratedfrom;
my ($cmd, $vollist) = config_to_command($storecfg, $vmid, $conf, $defaults);
my ($cmd, $vollist) = config_to_command($storecfg, $vmid, $conf, $defaults, $forcemachine);
my $migrate_port = 0;