white space cleanups

This commit is contained in:
Dietmar Maurer 2014-12-04 13:07:59 +01:00
parent 2ed5d5724c
commit 67fb9de608

View File

@ -2744,59 +2744,61 @@ sub config_to_command {
my $memory = $conf->{memory} || $defaults->{memory};
push @$cmd, '-m', $memory;
if($conf->{numa}){
if ($conf->{numa}) {
my $numa_totalmemory = undef;
for (my $i = 0; $i < $MAX_NUMA; $i++) {
next if !$conf->{"numa$i"};
my $numa = parse_numa($conf->{"numa$i"});
next if !$numa;
#memory
die "missing numa node$i memory value" if !$numa->{memory};
# memory
die "missing numa node$i memory value\n" if !$numa->{memory};
my $numa_memory = $numa->{memory};
$numa_totalmemory += $numa_memory;
my $numa_object = "memory-backend-ram,id=ram-node$i,size=$numa_memory"."M";
#cpus
# cpus
my $cpus_start = $numa->{cpus}->{start};
die "missing numa node$i cpus" if !defined($cpus_start);
die "missing numa node$i cpus\n" if !defined($cpus_start);
my $cpus_end = $numa->{cpus}->{end} if defined($numa->{cpus}->{end});
my $cpus = $cpus_start;
if (defined($cpus_end)) {
$cpus .= "-$cpus_end";
die "numa node$i : cpu range $cpus is incorrect" if $cpus_end <= $cpus_start;
die "numa node$i : cpu range $cpus is incorrect\n" if $cpus_end <= $cpus_start;
}
#hostnodes
# hostnodes
my $hostnodes_start = $numa->{hostnodes}->{start};
if (defined($hostnodes_start)) {
my $hostnodes_end = $numa->{hostnodes}->{end} if defined($numa->{hostnodes}->{end});
my $hostnodes = $hostnodes_start;
if (defined($hostnodes_end)) {
$hostnodes .= "-$hostnodes_end";
die "host node $hostnodes range is incorrect" if $hostnodes_end <= $hostnodes_start;
die "host node $hostnodes range is incorrect\n" if $hostnodes_end <= $hostnodes_start;
}
my $hostnodes_end_range = defined($hostnodes_end) ? $hostnodes_end : $hostnodes_start;
for (my $i = $hostnodes_start; $i <= $hostnodes_end_range; $i++ ) {
die "host numa node$i don't exist" if !(-d "/sys/devices/system/node/node$i/");
die "host numa node$i don't exist\n" if ! -d "/sys/devices/system/node/node$i/";
}
#policy
# policy
my $policy = $numa->{policy};
die "you need to define a policy for hostnode $hostnodes" if !$policy;
die "you need to define a policy for hostnode $hostnodes\n" if !$policy;
$numa_object .= ",host-nodes=$hostnodes,policy=$policy";
}
push @$cmd, '-object', $numa_object;
push @$cmd, '-numa', "node,nodeid=$i,cpus=$cpus,memdev=ram-node$i";
}
die "total memory for NUMA nodes must be equal to vm memory" if $numa_totalmemory && $numa_totalmemory != $memory;
die "total memory for NUMA nodes must be equal to vm memory\n"
if $numa_totalmemory && $numa_totalmemory != $memory;
#if no custom tology, we split memory and cores across numa nodes
if(!$numa_totalmemory) {
my $numa_memory = ($memory / $sockets)."M";
my $numa_memory = ($memory / $sockets) . "M";
for (my $i = 0; $i < $sockets; $i++) {
@ -2813,8 +2815,6 @@ sub config_to_command {
push @$cmd, '-S' if $conf->{freeze};
# set keyboard layout
my $kb = $conf->{keyboard} || $defaults->{keyboard};
push @$cmd, '-k', $kb if $kb;