mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-08-15 07:52:13 +00: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:
parent
3bafc5106e
commit
952958bc87
@ -1314,7 +1314,7 @@ __PACKAGE__->register_method({
|
|||||||
skiplock => get_standard_option('skiplock'),
|
skiplock => get_standard_option('skiplock'),
|
||||||
stateuri => get_standard_option('pve-qm-stateuri'),
|
stateuri => get_standard_option('pve-qm-stateuri'),
|
||||||
migratedfrom => get_standard_option('pve-node',{ optional => 1 }),
|
migratedfrom => get_standard_option('pve-node',{ optional => 1 }),
|
||||||
|
machine => get_standard_option('pve-qm-machine'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
@ -1331,6 +1331,8 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $vmid = extract_param($param, 'vmid');
|
my $vmid = extract_param($param, 'vmid');
|
||||||
|
|
||||||
|
my $machine = extract_param($param, 'machine');
|
||||||
|
|
||||||
my $stateuri = extract_param($param, 'stateuri');
|
my $stateuri = extract_param($param, 'stateuri');
|
||||||
raise_param_exc({ stateuri => "Only root may use this option." })
|
raise_param_exc({ stateuri => "Only root may use this option." })
|
||||||
if $stateuri && $authuser ne 'root@pam';
|
if $stateuri && $authuser ne 'root@pam';
|
||||||
@ -1371,7 +1373,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
syslog('info', "start VM $vmid: $upid\n");
|
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;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -2219,7 +2219,7 @@ sub foreach_volid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub config_to_command {
|
sub config_to_command {
|
||||||
my ($storecfg, $vmid, $conf, $defaults) = @_;
|
my ($storecfg, $vmid, $conf, $defaults, $forcemachine) = @_;
|
||||||
|
|
||||||
my $cmd = [];
|
my $cmd = [];
|
||||||
my $globalFlags = [];
|
my $globalFlags = [];
|
||||||
@ -2384,8 +2384,9 @@ sub config_to_command {
|
|||||||
die "No accelerator found!\n" if !$cpuinfo->{hvm};
|
die "No accelerator found!\n" if !$cpuinfo->{hvm};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->{machine}) {
|
my $machine_type = $forcemachine || $conf->{machine};
|
||||||
push @$machineFlags, "type=$conf->{machine}";
|
if ($machine_type) {
|
||||||
|
push @$machineFlags, "type=${machine_type}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->{startdate}) {
|
if ($conf->{startdate}) {
|
||||||
@ -2972,7 +2973,7 @@ sub qga_unfreezefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub vm_start {
|
sub vm_start {
|
||||||
my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused) = @_;
|
my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, $forcemachine) = @_;
|
||||||
|
|
||||||
lock_config($vmid, sub {
|
lock_config($vmid, sub {
|
||||||
my $conf = load_config($vmid, $migratedfrom);
|
my $conf = load_config($vmid, $migratedfrom);
|
||||||
@ -2988,7 +2989,7 @@ sub vm_start {
|
|||||||
# set environment variable useful inside network script
|
# set environment variable useful inside network script
|
||||||
$ENV{PVE_MIGRATED_FROM} = $migratedfrom if $migratedfrom;
|
$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;
|
my $migrate_port = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user