Re: [pve-devel] [PATCH] lxc : vmstatus : add disk read|write stats
On Sun, 21 Jun 2015 13:06:27 +0200 Alexandre Derumier aderum...@odiso.com wrote: + my ($key, $value) = $byte =~ /(Read|Write) (\d+)/; I think this would be more secure: my ($key, $value) = $byte =~ /(Read|Write)\s+(\d+)/; -- Hilsen/Regards Michael Rasmussen Get my public GnuPG keys: michael at rasmussen dot cc http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xD3C9A00E mir at datanom dot net http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE501F51C mir at miras dot org http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0xE3E80917 -- /usr/games/fortune -es says: True, it returns for false, but is an even more interesting number than 0. -- Larry Wall in 199707300650.xaa05...@wall.org pgp_XaUyjpiWU.pgp Description: OpenPGP digital signature ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value V2
I'll try to improve that tomorrow. - Mail original - De: dietmar diet...@proxmox.com À: aderumier aderum...@odiso.com, pve-devel pve-devel@pve.proxmox.com Envoyé: Dimanche 21 Juin 2015 10:26:34 Objet: Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value V2 + +sub hotplug_lxc_config { + my ($vmid, $conf, $param, $delete) = @_; + + if (defined($delete)) { + foreach my $opt (@$delete) { + if ($opt eq 'swap') { + cgroups_write(memory, $vmid, memory.memsw.limit_in_bytes, -1); + } elsif ($opt =~ m/^net\d$/) { + #implement me + } + } + } + + foreach my $opt (keys %$param) { + my $value = $param-{$opt}; + if ($opt eq 'memory') { + cgroups_write(memory, $vmid, memory.limit_in_bytes, $value*1024*1024); + } elsif ($opt eq 'swap') { + my $mem = $conf-{'lxc.cgroup.memory.limit_in_bytes'}; + $mem = $param-{memory}*1024*1024 if $param-{memory}; is it really necessary to duplicate above code? I would prefer to do that only once. (Maybe remove it from update_lxc_conf)? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] lxc : vmstatus : add disk read|write stats
applied, with small improvement requested by mir (just to be safe). ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH] lxc : vmstatus : add disk read|write stats
using cgroup blkio.throttle.io_service_bytes They are also another cgroup blkio.io_service_bytes, but it's only work with cfq io scheduler. blkio.throttle.io_service_bytes works with any io scheduler Signed-off-by: Alexandre Derumier aderum...@odiso.com --- src/PVE/LXC.pm | 8 1 file changed, 8 insertions(+) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 0f21bcb..30f735c 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -752,6 +752,14 @@ sub vmstatus { $d-{mem} = read_cgroup_value('memory', $vmid, 'memory.usage_in_bytes'); $d-{swap} = read_cgroup_value('memory', $vmid, 'memory.memsw.usage_in_bytes') - $d-{mem}; + + my $blkio_bytes = read_cgroup_value('blkio', $vmid, 'blkio.throttle.io_service_bytes', 1); + my @bytes = split /\n/, $blkio_bytes; + foreach my $byte (@bytes) { + my ($key, $value) = $byte =~ /(Read|Write) (\d+)/; + $d-{diskread} = $2 if $key eq 'Read'; + $d-{diskwrite} = $2 if $key eq 'Write'; + } } return $list; -- 2.1.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value
We just want to remove the 'die' for hot-plug-able values. Please can you modify your patch? Maybe die only if we have at least 1 non hotplugglable option ? Yes. (simply die when we detect non-hotplugglable options) ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value V2
Signed-off-by: Alexandre Derumier aderum...@odiso.com --- src/PVE/LXC.pm | 65 -- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 068b46f..0f21bcb 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -964,8 +964,7 @@ sub verify_searchdomain_list { sub update_lxc_config { my ($vmid, $conf, $running, $param, $delete) = @_; -# fixme: hotplug -die unable to modify config while container is running\n if $running; +my $nohotplug; if (defined($delete)) { foreach my $opt (@$delete) { @@ -981,10 +980,13 @@ sub update_lxc_config { delete $conf-{'pve.startup'}; } elsif ($opt eq 'nameserver') { delete $conf-{'pve.nameserver'}; + $nohotplug = 1; } elsif ($opt eq 'searchdomain') { delete $conf-{'pve.searchdomain'}; + $nohotplug = 1; } elsif ($opt =~ m/^net\d$/) { delete $conf-{$opt}; + $nohotplug = 1; } else { die implement me } @@ -1002,9 +1004,11 @@ sub update_lxc_config { } elsif ($opt eq 'nameserver') { my $list = verify_nameserver_list($value); $conf-{'pve.nameserver'} = $list; + $nohotplug = 1; } elsif ($opt eq 'searchdomain') { my $list = verify_searchdomain_list($value); $conf-{'pve.searchdomain'} = $list; + $nohotplug = 1; } elsif ($opt eq 'memory') { $conf-{'lxc.cgroup.memory.limit_in_bytes'} = $value*1024*1024; } elsif ($opt eq 'swap') { @@ -1026,15 +1030,64 @@ sub update_lxc_config { $conf-{'pve.comment'} = PVE::Tools::encode_text($value); } elsif ($opt eq 'disk') { $conf-{'pve.disksize'} = $value; + $nohotplug = 1; } elsif ($opt =~ m/^net(\d+)$/) { my $netid = $1; my $net = PVE::LXC::parse_lxc_network($value); $net-{'veth.pair'} = veth${vmid}.$netid; $conf-{$opt} = $net; + $nohotplug = 1; } else { die implement me } } + +if($running) { + die unable to modify theses options while container is running\n if $nohotplug; + hotplug_lxc_config( $vmid, $conf, $param, $delete); +} + +} + +sub hotplug_lxc_config { +my ($vmid, $conf, $param, $delete) = @_; + +if (defined($delete)) { + foreach my $opt (@$delete) { + if ($opt eq 'swap') { + cgroups_write(memory, $vmid, memory.memsw.limit_in_bytes, -1); + } elsif ($opt =~ m/^net\d$/) { + #implement me + } + } +} + +foreach my $opt (keys %$param) { + my $value = $param-{$opt}; + if ($opt eq 'memory') { + cgroups_write(memory, $vmid, memory.limit_in_bytes, $value*1024*1024); + } elsif ($opt eq 'swap') { + my $mem = $conf-{'lxc.cgroup.memory.limit_in_bytes'}; + $mem = $param-{memory}*1024*1024 if $param-{memory}; + cgroups_write(memory, $vmid, memory.memsw.limit_in_bytes, $mem + $value*1024*1024); + } elsif ($opt eq 'cpulimit') { + if ($value 0) { + my $cfs_period_us = 10; + cgroups_write(cpu, $vmid, cpu.cfs_quota_us, $cfs_period_us*$value); + } else { + cgroups_write(cpu, $vmid, cpu.cfs_quota_us, -1); + } + } elsif ($opt eq 'cpuunits') { + cgroups_write(cpu, $vmid, cpu.shares, $value); + } elsif ($opt =~ m/^net(\d+)$/) { + my $netid = $1; + my $net = PVE::LXC::parse_lxc_network($value); + $net-{'veth.pair'} = veth${vmid}.$netid; + $conf-{$opt} = $net; + #implement me + } +} + } sub get_primary_ips { @@ -1071,5 +1124,13 @@ sub destory_lxc_container { PVE::Tools::run_command($cmd); } } + +sub cgroups_write { + my ($controller, $vmid, $option, $value) = @_; + + my $path = /sys/fs/cgroup/$controller/lxc/$vmid/$option; + PVE::ProcFSTools::write_proc_entry($path, $value); + +} 1; -- 2.1.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value V2
+ +sub hotplug_lxc_config { +my ($vmid, $conf, $param, $delete) = @_; + +if (defined($delete)) { + foreach my $opt (@$delete) { + if ($opt eq 'swap') { + cgroups_write(memory, $vmid, memory.memsw.limit_in_bytes, -1); + } elsif ($opt =~ m/^net\d$/) { + #implement me + } + } +} + +foreach my $opt (keys %$param) { + my $value = $param-{$opt}; + if ($opt eq 'memory') { + cgroups_write(memory, $vmid, memory.limit_in_bytes, $value*1024*1024); + } elsif ($opt eq 'swap') { + my $mem = $conf-{'lxc.cgroup.memory.limit_in_bytes'}; + $mem = $param-{memory}*1024*1024 if $param-{memory}; is it really necessary to duplicate above code? I would prefer to do that only once. (Maybe remove it from update_lxc_conf)? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] lxd support cloud-init through /dev/lxd interface
mounting with qemu-nbd is not really possible if you have a generic kvm VM (ufs, zfs, complex lvm setups, ...). I guess we should use the 'iso' approach for kvm. yes indeed, iso is better. But it would be easy to do with lxc, as we already have the code to loop/qemu-nbd mount the root device. I'll to look at this. - Mail original - De: dietmar diet...@proxmox.com À: aderumier aderum...@odiso.com Cc: pve-devel pve-devel@pve.proxmox.com Envoyé: Samedi 20 Juin 2015 17:28:39 Objet: Re: [pve-devel] lxd support cloud-init through /dev/lxd interface but it's also possible to send info to cloud-init, pushing user-data meta-data in a special /var/lib/cloud/seed/nocloud/ directory ah, great. here an example http://frederik.orellana.dk/booting-fedora-20-cloud-images-without-a-cloud/ mounting image with qemu-nbd (so it's working with almost all storages), write meta-data user-data. This could be done for qemu lxc too (not sure for windows qemu) mounting with qemu-nbd is not really possible if you have a generic kvm VM (ufs, zfs, complex lvm setups, ...). I guess we should use the 'iso' approach for kvm. But it would be easy to do with lxc, as we already have the code to loop/qemu-nbd mount the root device. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value
We just want to remove the 'die' for hot-plug-able values. Please can you modify your patch? Maybe die only if we have at least 1 non hotplugglable option ? - Mail original - De: dietmar diet...@proxmox.com À: aderumier aderum...@odiso.com Cc: pve-devel pve-devel@pve.proxmox.com Envoyé: Samedi 20 Juin 2015 17:22:29 Objet: Re: [pve-devel] [PATCH] lxc: add hotplug memory cpus cgroups value don't have remove the die yet, as all others options are not hotpluggable yet. (do we need to implement pending for network ?) No, I would not add such complex thing now. We simply disable changing configuration while container is running. but it's working if you remove the die We just want to remove the 'die' for hot-plug-able values. Please can you modify your patch? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel