Re: [pve-devel] pve-qemu-kvm : add numa support

2014-12-03 Thread Dietmar Maurer
applied, thanks.

> This add numa support to qemu.



___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] [PATCH] add numa options

2014-12-03 Thread Alexandre DERUMIER
Ok,
I'll send 2 patches today with both features.
- Mail original - 

De: "Dietmar Maurer"  
À: "Alexandre DERUMIER"  
Cc: pve-devel@pve.proxmox.com 
Envoyé: Mercredi 3 Décembre 2014 06:48:37 
Objet: RE: [pve-devel] [PATCH] add numa options 

> I think we could add: 
> 
> numa:0|1. 

I like that ;-) 

> which generate the first config, create 1numa node by socket, and share the 
> ram across the the nodes 
> 
> 
> 
> and also,for advanced users which need manual pinning: 
> 
> 
> numa0:cpus=,memory=,hostnode=,policy="bind|preferred|) 
> numa1:... 
> 
> what do you think about it ? 

yes, sounds reasonable. 
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH] Fix in PVE::QemuServer::snapshot_create

2014-12-03 Thread Wolfgang Link
remove the freezefs flag.
If Qemu Guest Agent flag is set in config the vm filesystem will always be 
frozen.

also remove param freezefs in PVE::API2 snapshot,
because there is no use for it.

Signed-off-by: Wolfgang Link 
---
 PVE/API2/Qemu.pm  |7 +--
 PVE/QemuServer.pm |8 
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 0787074..6cbfa7a 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -2853,11 +2853,6 @@ __PACKAGE__->register_method({
type => 'boolean',
description => "Save the vmstate",
},
-   freezefs => {
-   optional => 1,
-   type => 'boolean',
-   description => "Freeze the filesystem",
-   },
description => {
optional => 1,
type => 'string',
@@ -2888,7 +2883,7 @@ __PACKAGE__->register_method({
my $realcmd = sub {
PVE::Cluster::log_msg('info', $authuser, "snapshot VM $vmid: 
$snapname");
PVE::QemuServer::snapshot_create($vmid, $snapname, 
$param->{vmstate},
-$param->{freezefs}, 
$param->{description});
+, $param->{description});
};
 
return $rpcenv->fork_worker('qmsnapshot', $vmid, $authuser, $realcmd);
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index eb15f9c..b6245c3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4876,11 +4876,11 @@ my $savevm_wait = sub {
 };
 
 sub snapshot_create {
-my ($vmid, $snapname, $save_vmstate, $freezefs, $comment) = @_;
+my ($vmid, $snapname, $save_vmstate, $comment) = @_;
 
 my $snap = &$snapshot_prepare($vmid, $snapname, $save_vmstate, $comment);
 
-$freezefs = $save_vmstate = 0 if !$snap->{vmstate}; # vm is not running
+$save_vmstate = 0 if !$snap->{vmstate}; # vm is not running
 
 my $drivehash = {};
 
@@ -4888,7 +4888,7 @@ sub snapshot_create {
 
 my $config = load_config($vmid); 

-if ($running && $freezefs && $config->{agent}) {
+if ($running && $config->{agent}) {
eval { vm_mon_cmd($vmid, "guest-fsfreeze-freeze"); };
warn "guest-fsfreeze-freeze problems - $@" if $@;
 }
@@ -4926,7 +4926,7 @@ sub snapshot_create {
eval { vm_mon_cmd($vmid, "savevm-end")  };
warn $@ if $@;
 
-   if ($freezefs && $config->{agent}) {
+   if ($config->{agent}) {
eval { vm_mon_cmd($vmid, "guest-fsfreeze-thaw"); }; 
warn "guest-fsfreeze-thaw problems - $@" if $@;
}
-- 
1.7.10.4

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH 2/2] add custom numa topology support

2014-12-03 Thread Alexandre Derumier
numaX: 
cpus=[[,hostnodes=][,policy=]]

example:
---
sockets:4
cores:2
memory:4096
numa: 1
numa0: cpus=0-1,memory=1024,hostnodes=0-1,policy=interleave
numa1: cpus=2-3,memory=3072,hostnodes=2,policy=bind

qemu command line
-
-object 
memory-backend-ram,size=1024M,policy=interleave,host-nodes=0-1,id=ram-node0
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0

-object memory-backend-ram,size=3072M,policy=bind,host-nodes=2,id=ram-node1
-numa node,nodeid=1,cpus=2-3,memdev=ram-node1

Signed-off-by: Alexandre Derumier 
---
 PVE/QemuServer.pm |  114 +
 1 file changed, 107 insertions(+), 7 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 94fd523..b758016 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -489,6 +489,19 @@ my $MAX_UNUSED_DISKS = 8;
 my $MAX_HOSTPCI_DEVICES = 4;
 my $MAX_SERIAL_PORTS = 4;
 my $MAX_PARALLEL_PORTS = 3;
+my $MAX_NUMA = 8;
+
+my $numadesc = {
+optional => 1,
+type => 'string', format => 'pve-qm-numanode',
+typetext => 
"cpus=[[,hostnodes=][,policy=]]",
+description => "numa topology",
+};
+PVE::JSONSchema::register_standard_option("pve-qm-numanode", $numadesc);
+
+for (my $i = 0; $i < $MAX_NUMA; $i++)  {
+$confdesc->{"numa$i"} = $numadesc;
+}
 
 my $nic_model_list = ['rtl8139', 'ne2k_pci', 'e1000',  'pcnet',  'virtio',
  'ne2k_isa', 'i82551', 'i82557b', 'i82559er', 'vmxnet3'];
@@ -1278,6 +1291,31 @@ sub drive_is_cdrom {
 
 }
 
+sub parse_numa {
+my ($data) = @_;
+
+my $res = {};
+
+foreach my $kvp (split(/,/, $data)) {
+
+   if ($kvp =~ m/^memory=(\S+)$/) {
+   $res->{memory} = $1;
+   } elsif ($kvp =~ m/^policy=(preferred|bind|interleave)$/) {
+   $res->{policy} = $1;
+   } elsif ($kvp =~ m/^cpus=(\d+)(-(\d+))?$/) {
+   $res->{cpus}->{start} = $1;
+   $res->{cpus}->{end} = $3;
+   } elsif ($kvp =~ m/^hostnodes=(\d+)(-(\d+))?$/) {
+   $res->{hostnodes}->{start} = $1;
+   $res->{hostnodes}->{end} = $3;
+   } else {
+   return undef;
+   }
+}
+
+return $res;
+}
+
 sub parse_hostpci {
 my ($value) = @_;
 
@@ -1458,6 +1496,17 @@ sub verify_bootdisk {
 die "invalid boot disk '$value'\n";
 }
 
+PVE::JSONSchema::register_format('pve-qm-numanode', \&verify_numa);
+sub verify_numa {
+my ($value, $noerr) = @_;
+
+return $value if parse_numa($value);
+
+return undef if $noerr;
+
+die "unable to parse numa options\n";
+}
+
 PVE::JSONSchema::register_format('pve-qm-net', \&verify_net);
 sub verify_net {
 my ($value, $noerr) = @_;
@@ -2697,18 +2746,69 @@ sub config_to_command {
 
 if($conf->{numa}){
 
-   my $numa_memory = ($memory / $sockets)."M";
+   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};
+   my $numa_memory = $numa->{memory};
+   $numa_totalmemory += $numa_memory;
+   my $numa_object = 
"memory-backend-ram,id=ram-node$i,size=$numa_memory"."M";
+
+   #cpus
+   my $cpus_start = $numa->{cpus}->{start};
+   die "missing numa node$i cpus" 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;
+   }
 
-   for (my $i = 0; $i < $sockets; $i++)  {
+   #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;
+   }
 
-   my $cpustart = ($cores * $i);
-   my $cpuend = ($cpustart + $cores - 1) if $cores && $cores > 1;
-   my $cpus = $cpustart;
-   $cpus .= "-$cpuend" if $cpuend;
+   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/");
+   }
 
-   push @$cmd, '-object', 
"memory-backend-ram,size=$numa_memory,id=ram-node$i";
+   #policy
+   my $policy = $numa->{policy};
+   die "you need to define a policy for hostnode $hostnodes"

[pve-devel] [PATCH 1/2] add numa options v3

2014-12-03 Thread Alexandre Derumier
This enable numa support inside the guest, and share the memory and cores 
across the sockets numa nodes.

numa: 0|1

example:
---
sockets:2
cores:2
memory:4096
numa: 1

qemu command line
-
-object memory-backend-ram,size=2048,id=ram-node0
-numa node,nodeid=0,cpus=0-1,memdev=ram-node0
-object memory-backend-ram,size=2048,id=ram-node1
-numa node,nodeid=1,cpus=2-3,memdev=ram-node1

Signed-off-by: Alexandre Derumier 
---
 PVE/QemuServer.pm |   29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 75ddcdd..94fd523 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -306,6 +306,12 @@ EODESC
minimum => 1,
default => 1,
 },
+numa => {
+   optional => 1,
+   type => 'boolean',
+   description => "Enable/disable Numa.",
+   default => 0,
+},
 maxcpus => {
optional => 1,
type => 'integer',
@@ -2686,8 +2692,29 @@ sub config_to_command {
 # push @$cmd, '-cpu', "$cpu,enforce";
 push @$cmd, '-cpu', $cpu;
 
+my $memory =  $conf->{memory} || $defaults->{memory};
+push @$cmd, '-m', $memory;
+
+if($conf->{numa}){
+
+   my $numa_memory = ($memory / $sockets)."M";
+
+   for (my $i = 0; $i < $sockets; $i++)  {
+
+   my $cpustart = ($cores * $i);
+   my $cpuend = ($cpustart + $cores - 1) if $cores && $cores > 1;
+   my $cpus = $cpustart;
+   $cpus .= "-$cpuend" if $cpuend;
+
+   push @$cmd, '-object', 
"memory-backend-ram,size=$numa_memory,id=ram-node$i";
+   push @$cmd, '-numa', "node,nodeid=$i,cpus=$cpus,memdev=ram-node$i";
+   }
+}
+
 push @$cmd, '-S' if $conf->{freeze};
 
+
+
 # set keyboard layout
 my $kb = $conf->{keyboard} || $defaults->{keyboard};
 push @$cmd, '-k', $kb if $kb;
@@ -2798,8 +2825,6 @@ sub config_to_command {
push @$devices, '-device', print_drivedevice_full($storecfg, $conf, 
$vmid, $drive, $bridges);
 });
 
-push @$cmd, '-m', $conf->{memory} || $defaults->{memory};
-
 for (my $i = 0; $i < $MAX_NETS; $i++) {
  next if !$conf->{"net$i"};
  my $d = parse_net($conf->{"net$i"});
-- 
1.7.10.4

___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] "ballon: 0" don't work with kernel 3.10

2014-12-03 Thread Cesar Peschiera

Hi PVE team.

The option of configuration of PVE VM "ballon: 0" don't work with the kernel 
"3.10.0-5-pve".


Best regards
Cesar




___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] "ballon: 0" don't work with kernel 3.10

2014-12-03 Thread Alexandre DERUMIER
>>"ballon: 0" don't work

balloon: 0   (with 2 oo)




(#man qm , il you need to known all the options)

- Mail original - 

De: "Cesar Peschiera"  
À: pve-devel@pve.proxmox.com 
Envoyé: Jeudi 4 Décembre 2014 01:15:54 
Objet: [pve-devel] "ballon: 0" don't work with kernel 3.10 

Hi PVE team. 

The option of configuration of PVE VM "ballon: 0" don't work with the kernel 
"3.10.0-5-pve". 

Best regards 
Cesar 




___ 
pve-devel mailing list 
pve-devel@pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel