\&parse_vm_config,
\&write_vm_config);
-PVE::JSONSchema::register_standard_option('skiplock', {
- description => "Ignore locks - only root is allowed to use this option.",
- type => 'boolean',
- optional => 1,
-});
-
PVE::JSONSchema::register_standard_option('pve-qm-stateuri', {
description => "Some command save/restore state from this location.",
type => 'string',
'Haswell-noTSX' => 'GenuineIntel',
Broadwell => 'GenuineIntel',
'Broadwell-noTSX' => 'GenuineIntel',
+ 'Skylake-Client' => 'GenuineIntel',
# AMD CPUs
athlon => 'AuthenticAMD',
}
);
+my %scsiblock_fmt = (
+ scsiblock => {
+ type => 'boolean',
+ description => "whether to use scsi-block for full passthrough of host block device\n\nWARNING: can lead to I/O errors in combination with low memory or high memory fragmentation on host",
+ optional => 1,
+ default => 0,
+ },
+);
+
my $add_throttle_desc = sub {
my ($key, $type, $what, $unit, $longunit, $minimum) = @_;
my $d = {
%drivedesc_base,
%iothread_fmt,
%queues_fmt,
+ %scsiblock_fmt,
};
my $scsidesc = {
optional => 1,
%iothread_fmt,
%model_fmt,
%queues_fmt,
+ %scsiblock_fmt,
};
my $efidisk_fmt = {
optional => 1,
default => 1,
},
+ romfile => {
+ type => 'string',
+ pattern => '[^,;]+',
+ format_description => 'string',
+ description => "Custom pci device rom filename (must be located in /usr/share/kvm/).",
+ optional => 1,
+ },
pcie => {
type => 'boolean',
description => "Choose the PCI-express bus (needs the 'q35' machine model).",
if ($drive->{file} =~ m|^/|) {
$path = $drive->{file};
if (my $info = path_is_scsi($path)) {
- if ($info->{type} == 0) {
+ if ($info->{type} == 0 && $drive->{scsiblock}) {
$devicetype = 'block';
} elsif ($info->{type} == 1) { # tape
$devicetype = 'generic';
}
my $rombar = defined($d->{rombar}) && !$d->{rombar} ? ',rombar=0' : '';
+ my $romfile = $d->{romfile};
+
my $xvga = '';
if ($d->{'x-vga'}) {
$xvga = ',x-vga=on';
if($j == 0){
$devicestr .= "$rombar$xvga";
$devicestr .= ",multifunction=on" if $multifunction;
+ $devicestr .= ",romfile=/usr/share/kvm/$romfile" if $romfile;
}
push @$devices, '-device', $devicestr;
my $pfamily = PVE::Tools::get_host_address_family($nodename);
$spice_port = PVE::Tools::next_spice_port($pfamily);
- push @$devices, '-spice', "tls-port=${spice_port},addr=localhost,tls-ciphers=DES-CBC3-SHA,seamless-migration=on";
+ push @$devices, '-spice', "tls-port=${spice_port},addr=localhost,tls-ciphers=HIGH,seamless-migration=on";
push @$devices, '-device', "virtio-serial,id=spice$pciaddr";
push @$devices, '-chardev', "spicevmc,id=vdagent,name=vdagent";
my $running = check_running($vmid);
- return if !PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
+ $size = 0 if !PVE::Storage::volume_resize($storecfg, $volid, $size, $running);
return if !$running;
my $local_volumes = {};
- if( $targetstorage ){
-
+ if ($targetstorage) {
foreach_drive($conf, sub {
my ($ds, $drive) = @_;
#start nbd server for storage migration
if ($targetstorage) {
-
my $nodename = PVE::INotify::nodename();
my $migrate_network_addr = PVE::Cluster::get_local_migration_ip($migration_network);
my $localip = $migrate_network_addr ? $migrate_network_addr : PVE::Cluster::remote_node_ip($nodename, 1);
}
if ($migratedfrom) {
-
eval {
set_migration_caps($vmid);
};
}
} else {
-
if (!$statefile && (!defined($conf->{balloon}) || $conf->{balloon})) {
vm_mon_cmd_nocheck($vmid, "balloon", value => $conf->{balloon}*1024*1024)
if $conf->{balloon};
my $format;
$jobs->{"drive-$drive"} = {};
- if($dst_volid =~ /^nbd:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+):exportname=(\S+)/) {
+ if ($dst_volid =~ /^nbd:(localhost|[\d\.]+|\[[\d\.:a-fA-F]+\]):(\d+):exportname=(\S+)/) {
my $server = $1;
my $port = $2;
my $exportname = $3;
$format = "nbd";
my $unixsocket = "/run/qemu-server/$vmid.mirror-drive-$drive";
$qemu_target = "nbd+unix:///$exportname?socket=$unixsocket";
- my $cmd = ['socat', "UNIX-LISTEN:$unixsocket,fork", "TCP:$server:$2,connect-timeout=1"];
+ my $cmd = ['socat', '-T30', "UNIX-LISTEN:$unixsocket,fork", "TCP:$server:$2,connect-timeout=5"];
my $pid = fork();
if (!defined($pid)) {
- die "forking socat tunnel failed";
+ die "forking socat tunnel failed\n";
} elsif ($pid == 0) {
exec(@$cmd);
- exit(-1);
- } else {
-
- $jobs->{"drive-$drive"}->{pid} = $pid;
+ warn "exec failed: $!\n";
+ POSIX::_exit(-1);
+ }
+ $jobs->{"drive-$drive"}->{pid} = $pid;
- my $timeout = 0;
- while (1) {
- last if -S $unixsocket;
- die if $timeout > 5;
- $timeout++;
- sleep 1;
- }
+ my $timeout = 0;
+ while (!-S $unixsocket) {
+ die "nbd connection helper timed out\n"
+ if $timeout++ > 5;
+ sleep 1;
}
} else {
-
my $storecfg = PVE::Storage::config();
my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid);
die "mirroring error: $err";
}
-
qemu_drive_mirror_monitor ($vmid, $vmiddst, $jobs, $skipcomplete, $qga);
}
my ($vmid, $vmiddst, $jobs, $skipcomplete, $qga) = @_;
eval {
-
my $err_complete = 0;
while (1) {
next;
}
- die "$job: mirroring has been cancelled. Maybe do you have bad sectors?" if !defined($running_mirror_jobs->{$job});
+ die "$job: mirroring has been cancelled\n" if !defined($running_mirror_jobs->{$job});
my $busy = $running_mirror_jobs->{$job}->{busy};
my $ready = $running_mirror_jobs->{$job}->{ready};
print "$job: transferred: $transferred bytes remaining: $remaining bytes total: $total bytes progression: $percent % busy: $busy ready: $ready \n";
}
- $readycounter++ if $running_mirror_jobs->{$job}->{ready} eq 'true';
+ $readycounter++ if $running_mirror_jobs->{$job}->{ready};
}
last if scalar(keys %$jobs) == 0;
foreach my $job (keys %$jobs) {
# try to switch the disk if source and destination are on the same guest
- print "$job : Try to complete block job\n";
+ print "$job: Completing block job...\n";
eval { vm_mon_cmd($vmid, "block-job-complete", device => $job) };
if ($@ =~ m/cannot be completed/) {
- print "$job : block job cannot be complete. Try again \n";
+ print "$job: Block job cannot be completed, try again.\n";
$err_complete++;
}else {
- print "$job : complete ok : flushing pending writes\n";
+ print "$job: Completed successfully.\n";
$jobs->{$job}->{complete} = 1;
eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
}
my ($vmid, $jobs) = @_;
foreach my $job (keys %$jobs) {
- print "$job: try to cancel block job\n";
+ print "$job: Cancelling block job\n";
eval { vm_mon_cmd($vmid, "block-job-cancel", device => $job); };
$jobs->{$job}->{cancel} = 1;
}
foreach my $job (keys %$jobs) {
- if(defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
- print "$job : finished\n";
+ if (defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
+ print "$job: Done.\n";
eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
delete $jobs->{$job};
}
my $maxdev = 0;
- if ($conf->{scsihw} && ($conf->{scsihw} =~ m/^lsi/)) {
+ if (!$conf->{scsihw} || ($conf->{scsihw} =~ m/^lsi/)) {
$maxdev = 7;
} elsif ($conf->{scsihw} && ($conf->{scsihw} eq 'virtio-scsi-single')) {
$maxdev = 1;