]> git.proxmox.com Git - pve-container.git/log
pve-container.git
4 years agoRevert "apply pending changes in lxc prestart hook"
Wolfgang Bumiller [Thu, 21 Nov 2019 08:03:44 +0000 (09:03 +0100)]
Revert "apply pending changes in lxc prestart hook"

This reverts commit 5a98fd2b573e96e1af37402211ba2a07abb489ca.

The prestart hook is executed by lxc, that is *after* it
loaded the config, so any pending changes which involve
updates to /var/lib/lxc/$vmid/config won't have any actual
effect: seccomp profile, apparmor profile changes, cgroup
related settings, newly added network devices, ...

4 years agobump version to 3.0-12
Thomas Lamprecht [Wed, 20 Nov 2019 18:27:39 +0000 (19:27 +0100)]
bump version to 3.0-12

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapply pending changes in lxc prestart hook
Oguz Bektas [Wed, 20 Nov 2019 14:49:39 +0000 (15:49 +0100)]
apply pending changes in lxc prestart hook

this allows pending changes to be applied when a reboot is issued inside
the container.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoimplement container reboot
Oguz Bektas [Wed, 20 Nov 2019 14:49:38 +0000 (15:49 +0100)]
implement container reboot

* add helper function vm_reboot
* add vm_reboot api call
* add 'pct reboot'

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadd 'tags' option
Dominik Csapak [Thu, 31 Oct 2019 12:36:26 +0000 (13:36 +0100)]
add 'tags' option

this is useful as meta information for e.g., provisioning or config
management systems

adding the info also to the 'status' api call to make it easier to show
it in the gui

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agod/control: bump versioned dependency on pve-common
Thomas Lamprecht [Wed, 20 Nov 2019 17:58:23 +0000 (18:58 +0100)]
d/control: bump versioned dependency on pve-common

to ensure we have the new kernel mount API helpers and constants
available..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agouse lxc-start apparmor profile for mount hotplugging
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:07 +0000 (08:31 +0100)]
use lxc-start apparmor profile for mount hotplugging

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoimplement mountpoint hotplugging
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:06 +0000 (08:31 +0100)]
implement mountpoint hotplugging

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoconfig: apply_pending_mountpoint helper
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:05 +0000 (08:31 +0100)]
config: apply_pending_mountpoint helper

for reuse in hotplug code

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoprestart-hook: use staged mountpoints on newer kernels
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:04 +0000 (08:31 +0100)]
prestart-hook: use staged mountpoints on newer kernels

This way we operate on defined paths in the monitor
namespace (/run/pve/mountpoint/{rootfs,mp0,mp1,...}) while
performing the mount, and can use `move_mount()` without
passing the MOVE_MOUNT_T_SYMLINKS flag when putting the
hierarchy in place.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoadd mount stage directory helpers
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:03 +0000 (08:31 +0100)]
add mount stage directory helpers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoadd get_container_namespace helper
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:02 +0000 (08:31 +0100)]
add get_container_namespace helper

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agosplit open_namespace out of enter_namespace
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:01 +0000 (08:31 +0100)]
split open_namespace out of enter_namespace

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoadd open_pid_fd, open_lxc_pid, open_ppid helpers
Wolfgang Bumiller [Wed, 20 Nov 2019 07:31:00 +0000 (08:31 +0100)]
add open_pid_fd, open_lxc_pid, open_ppid helpers

Getting a pid and acting on it is always a race, so add
safer helpers for this.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoadd mountpoint_insert_staged helper
Wolfgang Bumiller [Wed, 20 Nov 2019 07:30:59 +0000 (08:30 +0100)]
add mountpoint_insert_staged helper

This takes care of creating the directories on the fly
before issuing the move_mount() syscall.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoimplement "staged mountpoints"
Wolfgang Bumiller [Wed, 20 Nov 2019 07:30:58 +0000 (08:30 +0100)]
implement "staged mountpoints"

Staging a mount point requires the new kernel mount API and
will mount the volume at a fixed path, then use open_tree()
to "pick it up" into a file descriptor.

For most of our volumes we wouldn't need the temp directory,
but some things cannot be handled with _only_ the new API
(like single-step read-only bind mounts). Additionally, the
'mount' command figures out file systems automatically and
has a bunch of helpers we'd need to reimplement, so instead,
go through our usual mount code and then pick up the result.

This can then be used to implement mount point hotplugging,
as with the open file descriptor we can move into the
container's namespace and issue a `move_mount()` to put the
mount point in place in the running container.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agosplit walk_tree_nofollow to allow a start fd
Wolfgang Bumiller [Wed, 20 Nov 2019 07:30:57 +0000 (08:30 +0100)]
split walk_tree_nofollow to allow a start fd

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agotools: add can_use_new_mount_api helper
Wolfgang Bumiller [Wed, 20 Nov 2019 07:30:56 +0000 (08:30 +0100)]
tools: add can_use_new_mount_api helper

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agobump version to 3.0-11
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:26 +0000 (11:28 +0100)]
bump version to 3.0-11

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agouse PVE::RRD for RRD data
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:25 +0000 (11:28 +0100)]
use PVE::RRD for RRD data

refactored from PVE::Cluster. same code, same semantics, different file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agouse PVE::DataCenterConfig
Fabian Grünbichler [Mon, 11 Nov 2019 10:28:24 +0000 (11:28 +0100)]
use PVE::DataCenterConfig

to make sure that the corresponding cfs_read_file works() works.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agod/control: bump version dependency to ha-manager
Thomas Lamprecht [Thu, 14 Nov 2019 13:44:11 +0000 (14:44 +0100)]
d/control: bump version dependency to ha-manager

so that we have the new "ha-manager crm-command" available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoUse crm-command stop to allow shutdown with timeout and hard stop for HA
Fabian Ebner [Thu, 14 Nov 2019 11:23:57 +0000 (12:23 +0100)]
Use crm-command stop to allow shutdown with timeout and hard stop for HA

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
4 years agovm_stop_cleanup: return early to avoid unecessary indentation levels
Thomas Lamprecht [Thu, 14 Nov 2019 13:35:01 +0000 (14:35 +0100)]
vm_stop_cleanup: return early to avoid unecessary indentation levels

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodestroy_lxc_container: drop unused outcommented code
Thomas Lamprecht [Thu, 14 Nov 2019 13:34:34 +0000 (14:34 +0100)]
destroy_lxc_container: drop unused outcommented code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agotest: add 'use PVE::LXC::Config' to setup test
Fabian Grünbichler [Wed, 6 Nov 2019 12:36:49 +0000 (13:36 +0100)]
test: add 'use PVE::LXC::Config' to setup test

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agotest: mock PVE::Cluster in setup tests
Fabian Grünbichler [Wed, 6 Nov 2019 12:36:48 +0000 (13:36 +0100)]
test: mock PVE::Cluster in setup tests

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix #2456 setting bind-mount through API/CLI is broken
Wolfgang Link [Thu, 7 Nov 2019 06:51:07 +0000 (07:51 +0100)]
fix #2456 setting bind-mount through API/CLI is broken

Content-type check is only valid for mp from type 'volume'.
The Content-type check is correct for rootfs and mount points.

4 years agofix #2453: actually reflect random MAC address selection in config
Oguz Bektas [Wed, 6 Nov 2019 14:58:55 +0000 (15:58 +0100)]
fix #2453: actually reflect random MAC address selection in config

When creating/changing the network interface of a container, the
parse_lxc_network can have side-effects, e.g., it adds a new random
MAC hwaddr if the netX format-string did not had any. Thus, we need
to call print_lxc_network again in order to have the correct,
up-to-date, property string in the config file.

Apparently this was a regression introduced with the pending changes
series.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoconfig: whitelist lxc.hook.version
Wolfgang Bumiller [Tue, 5 Nov 2019 12:58:05 +0000 (13:58 +0100)]
config: whitelist lxc.hook.version

We currently don't depend on a particular version, although
in the future we may want to enforce a minimum (at which
point we'll need more than just a whitelist entry for this,
but right now this will do...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoautodev hook: use new helpers and whitespace fixup
Wolfgang Bumiller [Tue, 5 Nov 2019 12:58:04 +0000 (13:58 +0100)]
autodev hook: use new helpers and whitespace fixup

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agotools: add device file iterator, and cgroup_do_write
Wolfgang Bumiller [Tue, 5 Nov 2019 12:58:03 +0000 (13:58 +0100)]
tools: add device file iterator, and cgroup_do_write

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agochange hooks to use new helper
Wolfgang Bumiller [Tue, 5 Nov 2019 12:58:02 +0000 (13:58 +0100)]
change hooks to use new helper

We now get rid of all the PVE::CLIHandler baggage which
reduces the code a lot. It is also not compatible with the
new lxc.hook.version=1 method of hooks!

The new helper is specific to lxc hooks and supports both
current `lxc.hook.version`s.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoadd PVE::LXC::Tools
Wolfgang Bumiller [Tue, 5 Nov 2019 12:58:01 +0000 (13:58 +0100)]
add PVE::LXC::Tools

Will contain lxc/container specific tools which should also
be accessible within our lxc hook scripts.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agobump version to 3.0-10
Thomas Lamprecht [Wed, 30 Oct 2019 17:13:55 +0000 (18:13 +0100)]
bump version to 3.0-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agosetup: fedora: allow 31 (and 32)
Thomas Lamprecht [Wed, 30 Oct 2019 14:35:02 +0000 (15:35 +0100)]
setup: fedora: allow 31 (and 32)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 3.0-9
Thomas Lamprecht [Tue, 29 Oct 2019 06:32:48 +0000 (07:32 +0100)]
bump version to 3.0-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agosetup: do host architecture translation ourself
Stefan Reiter [Mon, 28 Oct 2019 11:59:14 +0000 (12:59 +0100)]
setup: do host architecture translation ourself

This was done by the PVE:Tools backed get_host_arch method, but as we
were the only user of that specific translation and it's quite LXC
related it makes more sense to do it here. This also allows reuse of
the PVE::Tools function.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agoiterate pending config changes sorted
Oguz Bektas [Wed, 23 Oct 2019 16:48:27 +0000 (18:48 +0200)]
iterate pending config changes sorted

since we sort them while going through the delete hash, we can do it
for the other loops for consistency.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadd 'lock' as a fastplug option
Oguz Bektas [Thu, 24 Oct 2019 13:58:56 +0000 (15:58 +0200)]
add 'lock' as a fastplug option

lock option needs to be fastpluggable when modifying with 'pct set'.
otherwise it registers as a pending change.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agofollowup: iterate over pending changes sorted
Thomas Lamprecht [Tue, 22 Oct 2019 11:22:33 +0000 (13:22 +0200)]
followup: iterate over pending changes sorted

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agopending apply/hotplug: use normal for loop iterate over
Oguz Bektas [Tue, 22 Oct 2019 10:40:41 +0000 (12:40 +0200)]
pending apply/hotplug: use normal for loop iterate over

format of pending_delete_hash is changed in guest-common, so we have to
use the new format while looping over the hash.

also it make no sense to have a `my ($foo, undef) = each` here, the
undef did nothing anyway.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agobump version to 3.0-8
Thomas Lamprecht [Fri, 18 Oct 2019 20:03:34 +0000 (22:03 +0200)]
bump version to 3.0-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofixup error message
Thomas Lamprecht [Fri, 18 Oct 2019 19:59:50 +0000 (21:59 +0200)]
fixup error message

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd check to resize disk if current size could not be determined
Tim Marx [Thu, 12 Sep 2019 10:56:20 +0000 (12:56 +0200)]
add check to resize disk if current size could not be determined

This check ensures that disks aren't unintentionally shrunken, if the
size is zero due to an underlying problem.

4 years agowhitespace cleanup
Tim Marx [Thu, 12 Sep 2019 10:56:19 +0000 (12:56 +0200)]
whitespace cleanup

4 years agofix #1291: add option purge for destroy_vm api call
Christian Ebner [Tue, 15 Oct 2019 11:00:24 +0000 (13:00 +0200)]
fix #1291: add option purge for destroy_vm api call

When destroying a CT, we intentionally did not remove all related
configs such as backup or replication jobs.
The intention of this flag is to allow the removal of references to
the VM being removed from such configs on destroy.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoimplement pending changes
Oguz Bektas [Mon, 14 Oct 2019 08:28:51 +0000 (10:28 +0200)]
implement pending changes

previous behaviour directly applied the possible config changes, and
died when there was something which can't be applied while CT is
running.

instead, we now write all the changes directly into the config pending
section, and then apply or hotplug the changes depending on whether CT
is running. the non-hotpluggable changes are left as pending changes.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoapply pending changes during container start
Oguz Bektas [Mon, 14 Oct 2019 08:28:50 +0000 (10:28 +0200)]
apply pending changes during container start

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadd vmconfig_hotplug_pending and vmconfig_apply_pending
Oguz Bektas [Mon, 14 Oct 2019 08:28:49 +0000 (10:28 +0200)]
add vmconfig_hotplug_pending and vmconfig_apply_pending

vmconfig_hotplug_pending is responsible for checking if a key/value pair
in the pending section can be hotpugged, if yes; perform a generic
replace, or perform specific actions for hotplugging the special cases.

vmconfig_apply_pending is only supposed to be called when ct isn't live.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoallow to check for in-use volumes in pending section
Oguz Bektas [Mon, 14 Oct 2019 08:28:48 +0000 (10:28 +0200)]
allow to check for in-use volumes in pending section

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoskip pending changes while taking backup
Oguz Bektas [Mon, 14 Oct 2019 08:28:46 +0000 (10:28 +0200)]
skip pending changes while taking backup

we can only clone the current state of container (without pending
changes), as otherwise the on-disk state might not match the
configuration. this also makes it more consistent to qemu-server
behavior.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoskip pending changes while cloning
Oguz Bektas [Mon, 14 Oct 2019 08:28:45 +0000 (10:28 +0200)]
skip pending changes while cloning

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoapi: config: use shared guesthelpers in GET call
Oguz Bektas [Mon, 14 Oct 2019 08:28:44 +0000 (10:28 +0200)]
api: config: use shared guesthelpers in GET call

since containers can also have pending changes now, we need a method to
get the current applied config as well as the one with the pending
changes inside. this makes the GET config api more consistent with
qemu-server's by reusing load_current_config and load_snapshot_config from
AbstractConfig.
to decide which method to call, we look at the parameters.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadd 'pct pending'
Oguz Bektas [Mon, 14 Oct 2019 08:28:43 +0000 (10:28 +0200)]
add 'pct pending'

same as 'qm pending', the code is shared via GuestHelpers

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agofixup: add lxc/pending API path
Thomas Lamprecht [Fri, 18 Oct 2019 18:44:16 +0000 (20:44 +0200)]
fixup: add lxc/pending API path

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd lxc/pending API path
Oguz Bektas [Mon, 14 Oct 2019 08:28:42 +0000 (10:28 +0200)]
add lxc/pending API path

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadapt CT config parser for pending changes
Oguz Bektas [Mon, 14 Oct 2019 08:28:41 +0000 (10:28 +0200)]
adapt CT config parser for pending changes

config parser can now read/write [pve:pending] section. this was named
such, instead of [PENDING], after on- and offline discussion regarding
namespacing the pending section and snapshots.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agodelete_mp: warn if we ignore a volume deletion due to wrong owner
Thomas Lamprecht [Fri, 18 Oct 2019 10:51:21 +0000 (12:51 +0200)]
delete_mp: warn if we ignore a volume deletion due to wrong owner

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2412: ct destroy: only delete config after deleted from pools, fw
Thomas Lamprecht [Fri, 18 Oct 2019 10:01:49 +0000 (12:01 +0200)]
fix #2412: ct destroy: only delete config after deleted from pools, fw

commit message stolen from:
https://pve.proxmox.com/pipermail/pve-devel/2019-October/039594.html

Between calling destroy_lxc_container and removing the ID from
user.cfg (remove_vm_access) creating a new CT with this ID was
possible. CTs could go missing from pools as a consequence.

unlinking must happen at the very end of the deletion
process to avoid that other nodes use the ID in the meanwhile

Further lock the config after the VM was destroyed with a config lock
named, well, destroyed. This way it's easy to know that the CT was
destroyed but has still the config skelleton and FW, access etc.
stuff possible left over.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agouse print_snapshot_tree guest helper for pct listsnapshot
Oguz Bektas [Wed, 2 Oct 2019 09:39:54 +0000 (11:39 +0200)]
use print_snapshot_tree guest helper for pct listsnapshot

adds feature parity between qm/pct 'listsnapshot' w.r.t. showing
snapshot tree ordered by date.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agod/control: bump version dependency to libpve-guest-common-perl
Thomas Lamprecht [Fri, 18 Oct 2019 08:47:19 +0000 (10:47 +0200)]
d/control: bump version dependency to libpve-guest-common-perl

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoreuse guest-common destroy_config
Thomas Lamprecht [Fri, 18 Oct 2019 08:42:32 +0000 (10:42 +0200)]
reuse guest-common destroy_config

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoprepend underscores for is_volume_in_use private helper
Oguz Bektas [Mon, 14 Oct 2019 08:28:47 +0000 (10:28 +0200)]
prepend underscores for is_volume_in_use private helper

this helper was defined twice, once as 'my $is_volume_in_use' sub and
second as a helper sub. as our other helpers with a similar structure,
it is better to prepend the variable sub with two underscores.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoadd upcomming Ubuntu 19.10 Eoan as supported
Thomas Lamprecht [Thu, 3 Oct 2019 11:03:04 +0000 (13:03 +0200)]
add upcomming Ubuntu 19.10 Eoan as supported

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorestore lxc.* entries once
Fabian Grünbichler [Wed, 25 Sep 2019 12:35:04 +0000 (14:35 +0200)]
restore lxc.* entries once

either via recover_config, OR via restore_configuration. non-root behaviour stays the same.

Tested-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agofix issue where ttys aren't correctly set after restore
Oguz Bektas [Fri, 13 Sep 2019 10:35:57 +0000 (12:35 +0200)]
fix issue where ttys aren't correctly set after restore

restore from unpriv to priv causes a problem with the log-in from web
console, since the /etc/securetty file isn't modified after a restore to
reflect that change (/dev/lxc/tty1 and so on).

template_fixup is normally called in post_create_hook, but we have no
$password or $ssh_keys to call the hook with during the restore. instead
we call template_fixup by itself to fix the ttys on some distributions.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoapi lxc: remove trailing whitespace
Oguz Bektas [Thu, 5 Sep 2019 14:11:16 +0000 (16:11 +0200)]
api lxc: remove trailing whitespace

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoNewline cleanups
Christian Ebner [Mon, 1 Jul 2019 13:43:49 +0000 (15:43 +0200)]
Newline cleanups

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
4 years agobump version to 3.0-7
Thomas Lamprecht [Tue, 3 Sep 2019 05:21:27 +0000 (07:21 +0200)]
bump version to 3.0-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: bump version dependency from pve-common to 6.0-4
Thomas Lamprecht [Tue, 3 Sep 2019 05:19:33 +0000 (07:19 +0200)]
d/control: bump version dependency from pve-common to 6.0-4

to ensure we've the new fchownat syscall helper available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoumount_all tell caller if we succeeded in $noerr case
Thomas Lamprecht [Wed, 28 Aug 2019 08:46:28 +0000 (10:46 +0200)]
umount_all tell caller if we succeeded in $noerr case

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodon't leave fstrim lock if mount_all fails
Oguz Bektas [Mon, 26 Aug 2019 14:06:32 +0000 (16:06 +0200)]
don't leave fstrim lock if mount_all fails

when a container has a mountpoint which can't be mounted for some
reason, mount_all dies and the fstrim lock stays. prevent this by
moving the call into eval, warn if any error occurs.

Still try to unmount all already mounted MPs so that nothing blocking
remains left.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agosetup: allow CentOS 5 and CentOS 8
Thomas Lamprecht [Tue, 27 Aug 2019 16:49:01 +0000 (18:49 +0200)]
setup: allow CentOS 5 and CentOS 8

One is in the extended support phase, it should not be used but
people report that the CentOS 6 code path works just fine, so why
not...

The other is for the upcoming CentOS 8, while not fully testable for
compatibility yet, CentOS 7 code path should do the trick, else
we'll need to adapt it anyway, so see this as experimental

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agomountpoints: create parent dirs with correct owner
Fabian Grünbichler [Wed, 24 Jul 2019 11:37:13 +0000 (13:37 +0200)]
mountpoints: create parent dirs with correct owner

otherwise unprivileged containers might end up with directories that
they cannot modify since they are owned by the user root in the host
namespace, instead of root inside the container.

note: the problematic behaviour is only exhibited when an intermediate
directory needs to be created, e.g. a mountpoint /test/mp gets mounted,
and /test does not yet exist.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agobump version to 3.0-5
Fabian Grünbichler [Fri, 26 Jul 2019 10:41:24 +0000 (12:41 +0200)]
bump version to 3.0-5

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agorestore: correctly handle fw config from archive
Fabian Grünbichler [Thu, 25 Jul 2019 12:40:42 +0000 (14:40 +0200)]
restore: correctly handle fw config from archive

and skip restoring it if the user only has VM.Backup permissions, the
contained config file is a symlink, or if it is empty.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agovzdump: always add (empty) firewall config
Fabian Grünbichler [Thu, 25 Jul 2019 12:40:41 +0000 (14:40 +0200)]
vzdump: always add (empty) firewall config

just like we always add the container config

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agobump version to 3.0-4
Thomas Lamprecht [Fri, 19 Jul 2019 14:05:10 +0000 (16:05 +0200)]
bump version to 3.0-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodebian: bump compat to 12 and don't restart container.slice
Thomas Lamprecht [Fri, 19 Jul 2019 13:42:13 +0000 (15:42 +0200)]
debian: bump compat to 12 and don't restart container.slice

since compat 10 the restart is default, as I want to use
'dh_installsystemd' (vs 'dh_systemd_start') I need at least compat
level 11, so go for the now recommended compat level 12.

diffoscope tells me that the main change us the wanted:

./postinst
> @@ -1,10 +1,15 @@
>  #!/bin/sh
>  set -e
> -# Automatically added by dh_systemd_start/12.1.1
> +# Automatically added by dh_installsystemd/12.1.1
>  if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
>   if [ -d /run/systemd/system ]; then
>           systemctl --system daemon-reload >/dev/null || true
> -         if [ -n "$2" ]; then
> -                 _dh_action=restart
> -         else
> -                 _dh_action=start
> -         fi
> -         deb-systemd-invoke $_dh_action 'system-pve\x2dcontainer.slice' >/dev/null || true
> +         deb-systemd-invoke start 'system-pve\x2dcontainer.slice' >/dev/null || true
>   fi
>  fi
>  # End automatically added section

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agosetup getty: ensure the getty.target is not masked
Thomas Lamprecht [Wed, 17 Jul 2019 10:07:40 +0000 (12:07 +0200)]
setup getty: ensure the getty.target is not masked

some distro templates have this masked by default, it makes sense to
always ensure that it can work, a CT admin can still prevent this by
using the .pve-ignore.$file mechanism.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agosetup getty: drop now obsolete setup_systemd_console
Thomas Lamprecht [Thu, 18 Jul 2019 15:17:17 +0000 (17:17 +0200)]
setup getty: drop now obsolete setup_systemd_console

The setup_container_getty_service can now handle also old
getty@.service if the newer container-getty@.service is not
available. So drop, and convert the two remaining users to calling
the now compatible setup_container_getty_service

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agosetup getty: generalize setup_container_getty_service
Thomas Lamprecht [Thu, 18 Jul 2019 15:10:30 +0000 (17:10 +0200)]
setup getty: generalize setup_container_getty_service

to allow switching the two remaining users and then finally dropping
the setup_systemd_console method

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Co-developed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agosetup getty: ensure the correct services are enabled
Thomas Lamprecht [Wed, 17 Jul 2019 10:02:34 +0000 (12:02 +0200)]
setup getty: ensure the correct services are enabled

I.e., some distro templates do not have anything enabled, thus also
ensure that the respective container-getty@ services are enabled.

But, as to getty on the same TTY makes for a strange experience also
ensure that the getty@ are all removed (and vice versa in the other
case)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agogetty setup: move hack for old systemd getty services out
Thomas Lamprecht [Thu, 18 Jul 2019 13:25:33 +0000 (15:25 +0200)]
getty setup: move hack for old systemd getty services out

This makes it easier to remove the setup_systemd_console method in
the future.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
4 years agoadd support for debian bullseye/sid
Mira Limbeck [Thu, 18 Jul 2019 13:56:12 +0000 (15:56 +0200)]
add support for debian bullseye/sid

Add support for the newest DebianTesting aka bullseye.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Tested-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agoremove obsolete lxc@.service.d
Thomas Lamprecht [Wed, 17 Jul 2019 17:03:54 +0000 (19:03 +0200)]
remove obsolete lxc@.service.d

follow through with the preparations of commit
e407207213f3e23c7f274b101c6e49233b4ff0d2 which was part of the series
cleaning the whole handling up [0]

[0]: https://pve.proxmox.com/pipermail/pve-devel/2017-October/029077.html

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #1042: inotify: increase watches, instances & queue default limits
Thomas Lamprecht [Wed, 17 Jul 2019 16:20:28 +0000 (18:20 +0200)]
fix #1042: inotify: increase watches, instances & queue default limits

Some recent distributions running as a LXC container eat the relative
low default limits up very fast. Thus increase all those
(semi-related) limits by a factor of 512. This was chosen by using
one of our bigger know CT setup (~1500 CTs per host) and the fact
that I can have only a very low count (circa 5 - 7) of running
"inotify watch hungry" CTs (e.g., ones with a recent systemd > 240).

So, as 5 * 512 is well >> 1500, we can assume with confidence to
allow most reasonable and existing setups by default.

As with the kernel commit d46eb14b735b11927d4bdc2d1854c311af19de6d
"fs: fsnotify: account fsnotify metadata to kmemcg" [0] the memory
usage from the watch and queue overhead is accounted to the users
respective memory CGroup (i.e., for LXC containers their memory
limit) we can do this without to much fear of negative implications.

[0]: https://git.kernel.org/torvalds/c/d46eb14b735b11927d4bdc2d1854c311af19de6d

Don't change the hardcoded kernel default values directly though,
ship a sysctl.d configuration file, which is a bit more transparent
about what happens and can be shipped by the component needing this
(i.e., pve-container).

Follow the considerations of `man 5 sysctl.d` for shipping:
> Packages should install their configuration files in /lib/. Files
> in /etc/ are reserved for the local administrator, who may use this
> logic to override the configuration files installed by vendor
> packages. All configuration files are sorted by their filename in
> lexicographic order, regardless of which of the directories they
> reside in. If multiple files specify the same option, the entry in
> the file with the lexicographically latest name will take
> precedence. It is recommended to prefix all filenames with a
> two-digit number and a dash, to simplify the ordering of the files.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoconfig: whitelist lxc.seccomp.notify.proxy/cookie
Wolfgang Bumiller [Thu, 4 Jul 2019 14:42:01 +0000 (16:42 +0200)]
config: whitelist lxc.seccomp.notify.proxy/cookie

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agobump version to 3.0-3
Thomas Lamprecht [Thu, 11 Jul 2019 17:26:15 +0000 (19:26 +0200)]
bump version to 3.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2270: allow custom lxc options to be restored as root
Stefan Reiter [Tue, 9 Jul 2019 15:20:57 +0000 (17:20 +0200)]
fix #2270: allow custom lxc options to be restored as root

Seems to be a regression introduced with
f360d7f16b094fa258cf82d2557d06f3284435e4 (related to #2028).
$conf->{'lxc'} would always be defined, hence we never replaced it with
the restored options.

Co-developed-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
4 years agofollowup: code cleanup and uninitialized value access fix
Thomas Lamprecht [Fri, 5 Jul 2019 16:48:33 +0000 (18:48 +0200)]
followup: code cleanup and uninitialized value access fix

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #1451: allow one to add mount options to CT mountpoints
Oguz Bektas [Fri, 5 Jul 2019 11:27:05 +0000 (13:27 +0200)]
fix #1451: allow one to add mount options to CT mountpoints

for now allows the following non-problematic ones:
* noexec - Do not permit execution of binaries on the mounted FS
* noatime - Do not update inode access times on this filesystem
* nosuid - Do not allow suid or sgid bits to take effect
* nodev - Do not interpret character or block devices on the FS

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
4 years agotests: avoid ipcc usage by mocking PVE::Cluster::get_config
Wolfgang Bumiller [Fri, 28 Jun 2019 09:58:32 +0000 (11:58 +0200)]
tests: avoid ipcc usage by mocking PVE::Cluster::get_config

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agobump version to 3.0-2
Thomas Lamprecht [Mon, 24 Jun 2019 16:38:10 +0000 (18:38 +0200)]
bump version to 3.0-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoFix #576: Fix dangling files for Move Disk
Dominic Jäger [Wed, 12 Jun 2019 10:04:57 +0000 (12:04 +0200)]
Fix #576: Fix dangling files for Move Disk

When Move Disk is called for a container rsync starts copying it to a
new destination. This initial rsync process gets killed when the Stop
button gets pressed. At this moment the destination file is not fully
copied and useless as a consequence. Our code already tries to remove
it. However, rsync has forked and those forks are still accessing the
destination file for some time. Thus, the attempt to remove it fails.

With the patch we wait for other processes to release the destination
files. As we are in a mount namespace and protected by a config lock,
those other processes should be children of rsync only. The waiting
time was less than a second when I tried it. Afterwards, the existing
remove procedure is carried out.

Co-developed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
5 years agofixup: nitpick: no parenthesis on simple post if
Thomas Lamprecht [Thu, 23 May 2019 07:28:45 +0000 (09:28 +0200)]
fixup: nitpick: no parenthesis on simple post if

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agoFix: check if compression_map format is undefined
Alwin Antreich [Thu, 23 May 2019 07:13:40 +0000 (09:13 +0200)]
Fix: check if compression_map format is undefined

We want to check for an supported compression type, but the check was
not correct as this only works if both sides are scalars, but an
assignment to an array is always "truthy", so actually check explicitly
if the compression type is supported before.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 years agotests: fix lxc-usernsexec invocation for uid != gid
Wolfgang Bumiller [Wed, 22 May 2019 12:25:11 +0000 (14:25 +0200)]
tests: fix lxc-usernsexec invocation for uid != gid

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 years agobuildsys: switch upload dist over to buster
Thomas Lamprecht [Wed, 22 May 2019 11:16:39 +0000 (13:16 +0200)]
buildsys: switch upload dist over to buster

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>