die "no storage ID specified (and no default storage)\n" if !$storeid;
my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
my $fmt = $disk->{format} || $defformat;
- my $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
- $fmt, undef, $size*1024*1024);
- $disk->{file} = $volid;
- $disk->{size} = $size*1024*1024*1024;
+
+ my $volid;
+ if ($ds eq 'efidisk0') {
+ # handle efidisk
+ my $ovmfvars = '/usr/share/kvm/OVMF_VARS-pure-efi.fd';
+ die "uefi vars image not found\n" if ! -f $ovmfvars;
+ $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
+ $fmt, undef, 128);
+ $disk->{file} = $volid;
+ $disk->{size} = 128*1024;
+ my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid);
+ my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
+ my $qemufmt = PVE::QemuServer::qemu_img_format($scfg, $volname);
+ my $path = PVE::Storage::path($storecfg, $volid);
+ my $efidiskcmd = ['/usr/bin/qemu-img', 'convert', '-n', '-f', 'raw', '-O', $qemufmt];
+ push @$efidiskcmd, $ovmfvars;
+ push @$efidiskcmd, $path;
+
+ PVE::Storage::activate_volumes($storecfg, [$volid]);
+
+ eval { PVE::Tools::run_command($efidiskcmd); };
+ my $err = $@;
+ die "Copying of EFI Vars image failed: $err" if $err;
+ } else {
+ $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
+ $fmt, undef, $size*1024*1024);
+ $disk->{file} = $volid;
+ $disk->{size} = $size*1024*1024*1024;
+ }
push @$vollist, $volid;
delete $disk->{format}; # no longer needed
$res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
die "unable to restore vm $vmid - vm is running\n"
if PVE::QemuServer::check_running($vmid);
+
+ die "unable to restore vm $vmid - vm is a template\n"
+ if PVE::QemuConfig->is_template($conf);
+
} else {
die "unable to restore vm $vmid - already existing on cluster node '$current_node'\n";
}
if (PVE::QemuServer::is_valid_drivename($opt)) {
# cleanup drive path
my $drive = PVE::QemuServer::parse_drive($opt, $param->{$opt});
+ raise_param_exc({ $opt => "unable to parse drive options" }) if !$drive;
PVE::QemuServer::cleanup_drive_path($opt, $storecfg, $drive);
$param->{$opt} = PVE::QemuServer::print_drive($vmid, $drive);
} elsif ($opt =~ m/^net(\d+)$/) {
skiplock => get_standard_option('skiplock'),
stateuri => get_standard_option('pve-qm-stateuri'),
migratedfrom => get_standard_option('pve-node',{ optional => 1 }),
+ migration_type => {
+ type => 'string',
+ enum => ['secure', 'insecure'],
+ description => "Migration traffic is encrypted using an SSH " .
+ "tunnel by default. On secure, completely private networks " .
+ "this can be disabled to increase performance.",
+ optional => 1,
+ },
+ migration_network => {
+ type => 'string',
+ format => 'CIDR',
+ description => "CIDR of the (sub) network that is used for migration.",
+ optional => 1,
+ },
machine => get_standard_option('pve-qm-machine'),
},
},
raise_param_exc({ migratedfrom => "Only root may use this option." })
if $migratedfrom && $authuser ne 'root@pam';
+ my $migration_type = extract_param($param, 'migration_type');
+ raise_param_exc({ migration_type => "Only root may use this option." })
+ if $migration_type && $authuser ne 'root@pam';
+
+ my $migration_network = extract_param($param, 'migration_network');
+ raise_param_exc({ migration_network => "Only root may use this option." })
+ if $migration_network && $authuser ne 'root@pam';
+
# read spice ticket from STDIN
my $spice_ticket;
if ($stateuri && ($stateuri eq 'tcp') && $migratedfrom && ($rpcenv->{type} eq 'cli')) {
syslog('info', "start VM $vmid: $upid\n");
PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom, undef,
- $machine, $spice_ticket);
+ $machine, $spice_ticket, $migration_network, $migration_type);
return;
};
optional => 1,
},
keepActive => {
- description => "Do not decativate storage volumes.",
+ description => "Do not deactivate storage volumes.",
type => 'boolean',
optional => 1,
default => 0,
default => 0,
},
keepActive => {
- description => "Do not decativate storage volumes.",
+ description => "Do not deactivate storage volumes.",
type => 'boolean',
optional => 1,
default => 0,
if ($target) {
# always deactivate volumes - avoid lvm LVs to be active on several nodes
PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) if !$running;
+ PVE::Storage::deactivate_volumes($storecfg, $newvollist);
my $newconffile = PVE::QemuConfig->config_file($newid, $target);
die "Failed to move config to node '$target' - rename failed: $!\n"
my $conf = PVE::QemuConfig->load_config($vmid);
+ PVE::QemuConfig->check_lock($conf);
+
die "checksum missmatch (file change by other user?)\n"
if $digest && $digest ne $conf->{digest};
description => "Allow to migrate VMs which use local devices. Only root may use this option.",
optional => 1,
},
+ migration_type => {
+ type => 'string',
+ enum => ['secure', 'insecure'],
+ description => "Migration traffic is encrypted using an SSH " .
+ "tunnel by default. On secure, completely private networks " .
+ "this can be disabled to increase performance.",
+ optional => 1,
+ },
+ migration_network => {
+ type => 'string',
+ format => 'CIDR',
+ description => "CIDR of the (sub) network that is used for migration.",
+ optional => 1,
+ },
},
},
returns => {
raise_param_exc({ force => "Only root may use this option." })
if $param->{force} && $authuser ne 'root@pam';
+ raise_param_exc({ migration_type => "Only root may use this option." })
+ if $param->{migration_type} && $authuser ne 'root@pam';
+
+ # allow root only until better network permissions are available
+ raise_param_exc({ migration_network => "Only root may use this option." })
+ if $param->{migration_network} && $authuser ne 'root@pam';
+
# test if VM exists
my $conf = PVE::QemuConfig->load_config($vmid);
parameters => {
additionalProperties => 0,
properties => {
- vmid => get_standard_option('pve-vmid'),
+ vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
node => get_standard_option('pve-node'),
},
},