mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-15 07:20:26 +00:00
pve5to6: followup: improve coding style and outputs a bit
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
03f79391c0
commit
000acacacc
@ -160,14 +160,17 @@ sub get_vms_with_vmx {
|
|||||||
flag => [],
|
flag => [],
|
||||||
};
|
};
|
||||||
my $vmlist = PVE::QemuServer::vzlist();
|
my $vmlist = PVE::QemuServer::vzlist();
|
||||||
|
|
||||||
foreach my $vmid ( sort { $a <=> $b } keys %$vmlist ) {
|
foreach my $vmid ( sort { $a <=> $b } keys %$vmlist ) {
|
||||||
my $pid = $vmlist->{$vmid}->{pid};
|
my $pid = $vmlist->{$vmid}->{pid};
|
||||||
next if !$pid; # skip not running vms
|
next if !$pid; # skip not running vms
|
||||||
|
|
||||||
my $cmdline = eval { PVE::Tools::file_get_contents("/proc/$pid/cmdline") };
|
my $cmdline = eval { PVE::Tools::file_get_contents("/proc/$pid/cmdline") };
|
||||||
if ($cmdline) {
|
if ($cmdline) {
|
||||||
my @args = split(/\0/, $cmdline);
|
my @args = split(/\0/, $cmdline);
|
||||||
for (my $i = 0; $i < scalar(@args); $i++) {
|
for (my $i = 0; $i < scalar(@args); $i++) {
|
||||||
next if !$args[$i] || $args[$i] !~ m/^-?-cpu$/;
|
next if !$args[$i] || $args[$i] !~ m/^-?-cpu$/;
|
||||||
|
|
||||||
my $cpuarg = $args[$i+1];
|
my $cpuarg = $args[$i+1];
|
||||||
if ($cpuarg =~ m/^(host|max)/) {
|
if ($cpuarg =~ m/^(host|max)/) {
|
||||||
push @{$res->{cpu}}, $vmid;
|
push @{$res->{cpu}}, $vmid;
|
||||||
@ -177,11 +180,15 @@ sub get_vms_with_vmx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $count = scalar(@{$res->{cpu}}) + scalar(@{$res->{flag}});
|
|
||||||
return ($count, $res);
|
$res = undef if (scalar(@{$res->{cpu}}) + scalar(@{$res->{flag}})) <= 0;
|
||||||
|
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_kvm_nested {
|
sub check_kvm_nested {
|
||||||
|
log_info("Checking KVM nesting support, which breaks live migration for VMs using it..");
|
||||||
|
|
||||||
my $module_sysdir = "/sys/module";
|
my $module_sysdir = "/sys/module";
|
||||||
if (-e "$module_sysdir/kvm_amd") {
|
if (-e "$module_sysdir/kvm_amd") {
|
||||||
$module_sysdir .= "/kvm_amd/parameters";
|
$module_sysdir .= "/kvm_amd/parameters";
|
||||||
@ -195,21 +202,17 @@ sub check_kvm_nested {
|
|||||||
if (-f "$module_sysdir/nested") {
|
if (-f "$module_sysdir/nested") {
|
||||||
my $val = eval { PVE::Tools::file_read_firstline("$module_sysdir/nested") };
|
my $val = eval { PVE::Tools::file_read_firstline("$module_sysdir/nested") };
|
||||||
if ($val && $val =~ m/Y|1/) {
|
if ($val && $val =~ m/Y|1/) {
|
||||||
my ($count, $list) = get_vms_with_vmx();
|
my $list = get_vms_with_vmx();
|
||||||
if (!$count) {
|
if (!defined($list)) {
|
||||||
log_skip("KVM nested parameter set.\nVMs with cputype host/max " .
|
log_pass("KVM nested parameter set, but currently no VM with a 'vmx' or 'svm' flag is running.");
|
||||||
"or vmx/svm flag will not be able to live migrate to PVE 6.");
|
|
||||||
} else {
|
} else {
|
||||||
my $warnmsg = "KVM nested parameter set.\n" .
|
my $warnmsg = "KVM nested enabled. It will not be possible to live migrate the following running VMs to PVE 6:\n";
|
||||||
"It will not be possible to live migrate following VMs to PVE6:\n";
|
|
||||||
if (@{$list->{cpu}}) {
|
if (@{$list->{cpu}}) {
|
||||||
$warnmsg .= "VMs with cputype host/max: " . join(',', @{$list->{cpu}}) . "\n";
|
$warnmsg .= " VMID(s) with cputype 'host' or 'max': " . join(',', @{$list->{cpu}}) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@{$list->{flag}}) {
|
if (@{$list->{flag}}) {
|
||||||
$warnmsg .= "VMs with cpu flag vmx/svm: " . join(',', @{$list->{flag}}) . "\n";
|
$warnmsg .= " VMID(s) with enforced cpu flag 'vmx' or 'svm': " . join(',', @{$list->{flag}}) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn($warnmsg);
|
log_warn($warnmsg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user