]> git.proxmox.com Git - pve-container.git/log
pve-container.git
2 years agoapi: move-volume: cleanup very long lines
Aaron Lauterer [Tue, 9 Nov 2021 14:55:40 +0000 (15:55 +0100)]
api: move-volume: cleanup very long lines

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoapi: move-volume: add move to another container
Aaron Lauterer [Tue, 9 Nov 2021 14:55:39 +0000 (15:55 +0100)]
api: move-volume: add move to another container

The goal of this is to expand the move-volume API endpoint to make it
possible to move a container volume / mountpoint to another container.

For unused volumes, the API parameters have been changed to allow them
as well. This means, additional checks had to be introduced to avoid
migration of an unusedX volume to another storage. Some follow up work
is needed for that to work properly.

Moving the rootfs from or to another container is prohibited.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoConfig: add valid_volume_keys_with_unused
Aaron Lauterer [Tue, 9 Nov 2021 14:55:38 +0000 (15:55 +0100)]
Config: add valid_volume_keys_with_unused

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agocli: pct: change move_volume to move-volume
Aaron Lauterer [Tue, 9 Nov 2021 14:55:37 +0000 (15:55 +0100)]
cli: pct: change move_volume to move-volume

also add alias to keep move_volume working

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agoconfig: rollback is possible: add blockers parameter
Fabian Ebner [Thu, 12 Aug 2021 11:01:03 +0000 (13:01 +0200)]
config: rollback is possible: add blockers parameter

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump version to 4.1-1
Thomas Lamprecht [Thu, 14 Oct 2021 11:13:13 +0000 (13:13 +0200)]
bump version to 4.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependency on libpve-common-perl
Thomas Lamprecht [Thu, 14 Oct 2021 11:07:35 +0000 (13:07 +0200)]
d/control: bump versioned dependency on libpve-common-perl

to ensure we've the new RPCEnv warn helper available added in
pve-common's commit ff79ee6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: support Fedora 35
Thomas Lamprecht [Thu, 14 Oct 2021 10:29:19 +0000 (12:29 +0200)]
setup: support Fedora 35

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agorestore: sanitize config: use new warn() function
Fabian Ebner [Thu, 8 Jul 2021 09:14:56 +0000 (11:14 +0200)]
restore: sanitize config: use new warn() function

to make it more visible that the task finished with warnings.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoclone: code bloat reduction
Thomas Lamprecht [Thu, 14 Oct 2021 09:59:34 +0000 (11:59 +0200)]
clone: code bloat reduction

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: clone_vm: don't include snapshot properties
Oguz Bektas [Wed, 13 Oct 2021 12:31:53 +0000 (14:31 +0200)]
api: clone_vm: don't include snapshot properties

apparently this caused a weird[0] bug... when a container with a snapshot was
cloned, it would take 'parent: foo' from the original container. if you
add a new snapshot 'bar', and then another one 'foo', this causes the
snapshots to become parents of each other (thus not parsed correctly in
the tree view of GUI nor with 'pct listsnapshot CTID')

we also drop these properties for VMs, so it makes sense to do the same
here as well.

[0]: https://forum.proxmox.com/threads/snapshots-of-one-lxc-disappeared.97711/

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agofix #3673: setup: allow ubuntu impish (release 21.10) containers
Oguz Bektas [Tue, 12 Oct 2021 10:32:17 +0000 (12:32 +0200)]
fix #3673: setup: allow ubuntu impish (release 21.10) containers

didn't notice any issue with basic privileged/unprivileged
configurations, so we can just add it here.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: also set contents of /etc/timezone
Fabian Ebner [Thu, 7 Oct 2021 10:48:03 +0000 (12:48 +0200)]
setup: also set contents of /etc/timezone

Some distributions like CentOS 8 and Gentoo don't have the file, so
only update if it already existed.

A slight change in behavior in set_timezone is that the warning will
now trigger if /etc/localtime is a link to $tz_path, but $tz_path does
not exist. Previously, it would return early if the link matched.

Programs that rely on /etc/timezone within the container will now see
the configured timezone too. While that is more correct, it's still a
change that might be unexpected.

Reported in the community forum:
https://forum.proxmox.com/threads/pct-create-command-with-timezone-host-option-fails-to-create-a-container.97538/

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agosetup: untaint path to host timezone
Fabian Ebner [Thu, 7 Oct 2021 10:48:02 +0000 (12:48 +0200)]
setup: untaint path to host timezone

To avoid an error with 'pct create ... --timezone host'.

Reported in the community forum:
https://forum.proxmox.com/threads/pct-create-command-with-timezone-host-option-fails-to-create-a-container.97538/

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump version to 4.0-11
Thomas Lamprecht [Thu, 7 Oct 2021 06:17:47 +0000 (08:17 +0200)]
bump version to 4.0-11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: drop remaining unmanaged return
Oguz Bektas [Tue, 5 Oct 2021 08:09:52 +0000 (10:09 +0200)]
setup: drop remaining unmanaged return

not needed anymore since we have 'unmanaged' plugin, so $self->{plugin}
would be 'unmanaged' and get handled by that instead of an early return.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agosetup: fix creating unmanaged containers
Oguz Bektas [Tue, 5 Oct 2021 08:09:51 +0000 (10:09 +0200)]
setup: fix creating unmanaged containers

ssh_host_key_generate did not explicitly return in unmanaged plugin,
causing the post_create_hook to fail because of an invalid hash
reference (cannot use "1" as a HASH ref, "1" was likely being returned
implicitly as the scalar value of 'my ($self) = @_;')

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agosetup: alpine: also use CIDR format for newer versions
Thomas Lamprecht [Mon, 4 Oct 2021 13:13:25 +0000 (15:13 +0200)]
setup: alpine: also use CIDR format for newer versions

original ifupdown supports this since years and ifupdown-ng, the
ifupdown replacement from the Alpine Linux corner, does too
https://github.com/ifupdown-ng/ifupdown-ng/blob/main/doc/ADMIN-GUIDE.md

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: alpine: code text-width/indendation cleanup
Thomas Lamprecht [Mon, 4 Oct 2021 12:27:42 +0000 (14:27 +0200)]
setup: alpine: code text-width/indendation cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: make some returns more explicit
Thomas Lamprecht [Mon, 4 Oct 2021 11:47:41 +0000 (13:47 +0200)]
setup: make some returns more explicit

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: add no-op plugin for unmanaged CTs
Thomas Lamprecht [Wed, 29 Sep 2021 19:05:43 +0000 (21:05 +0200)]
setup: add no-op plugin for unmanaged CTs

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: add abstract plugin module
Thomas Lamprecht [Wed, 29 Sep 2021 18:52:55 +0000 (20:52 +0200)]
setup: add abstract plugin module

to define the base API

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: drop copying binfmt qemu-static executable
Thomas Lamprecht [Wed, 29 Sep 2021 17:45:23 +0000 (19:45 +0200)]
setup: drop copying binfmt qemu-static executable

The binfmt-support and qemu-user-static package setup the
`/proc/sys/fs/binfmt_misc/' entry with the "fix binary" `F` flag:

> The usual behaviour of binfmt_misc is to spawn the binary lazily
> when the misc format file is invoked. However, this doesn't work
> very well in the face of mount namespaces and changeroots, so the F
> mode opens the binary as soon as the emulation is installed and
> uses the opened image to spawn the emulator, meaning it is always
> available once installed, regardless of how the environment
> changes.
--
https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html

which seems to be enough to make it work. binfmt-support's changelog
has some indication that it can use the `F` flag since the version
shipped in Debian Buster (PVE 6), and this support was added before
that, which would explain the earlier need for it..

Drop it now and slowly roll it out, if somebody really is using this
obscure PVE feature and yells we can always revert/workaround it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: add new ssh_host_key_types_to_generate helper to plugin API
Thomas Lamprecht [Wed, 29 Sep 2021 16:17:10 +0000 (18:17 +0200)]
setup: add new ssh_host_key_types_to_generate helper to plugin API

To guard the ct_file_set_contents call so that it's really only done
if the plugin wants ssh keys.

we'll use that in a future patch to have a more abstract interface
for plugins.

Additional benefit, we can drop (or at least skip) old key types (DSA
anyone) per container os-release type/version with this.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agodestroy: remove pending volumes as well
Fabian Grünbichler [Wed, 29 Sep 2021 09:45:06 +0000 (11:45 +0200)]
destroy: remove pending volumes as well

if a volume is only referenced in the pending section of a config it was
previously not removed when removing the CT, unless the non-default
'remove unreferenced disks' option was enabled.

keeping track of volume IDs which we attempt to remove gets rid of false
warnings in case a volume is referenced both in the config and the
pending section, or multiple times in the config for other reasons.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agopct status: mark suspend as experimental
Aaron Lauterer [Thu, 30 Sep 2021 09:49:11 +0000 (11:49 +0200)]
pct status: mark suspend as experimental

since container suspend is actually very experimental and only works in
very specific situations.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
2 years agobump version to 4.0-10
Thomas Lamprecht [Wed, 29 Sep 2021 20:14:27 +0000 (22:14 +0200)]
bump version to 4.0-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: centos: add non-fallback dns/searchdomain test
Thomas Lamprecht [Wed, 29 Sep 2021 20:07:10 +0000 (22:07 +0200)]
tests: centos: add non-fallback dns/searchdomain test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: dns conf: avoid testmode fallback if config defines properties
Thomas Lamprecht [Wed, 29 Sep 2021 20:05:54 +0000 (22:05 +0200)]
setup: dns conf: avoid testmode fallback if config defines properties

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopartially fix #3471: setup: centos: net: set DNS per iface config
Thomas Lamprecht [Wed, 29 Sep 2021 19:57:28 +0000 (21:57 +0200)]
partially fix #3471: setup: centos: net: set DNS per iface config

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: setup: also track locale.conf
Thomas Lamprecht [Wed, 29 Sep 2021 19:54:56 +0000 (21:54 +0200)]
tests: setup: also track locale.conf

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopartially fix #3471: setup: centos: net: fix IPv6 if/else chain
Thomas Lamprecht [Wed, 29 Sep 2021 19:28:47 +0000 (21:28 +0200)]
partially fix #3471: setup: centos: net: fix IPv6 if/else chain

we must not write the non-IP auto/dhcp formats as IP address, that
trips up network manager

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotests: setup: add CentOS 8 test
Thomas Lamprecht [Wed, 29 Sep 2021 19:48:18 +0000 (21:48 +0200)]
tests: setup: add CentOS 8 test

produces a bad (but not test-fatal) config with IPV6Addr set to
"auto", the next commit will fix that.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopartially fix #3471: setup: centos: net: add missing UUID to ifcfg
Thomas Lamprecht [Wed, 29 Sep 2021 19:28:13 +0000 (21:28 +0200)]
partially fix #3471: setup: centos: net: add missing UUID to ifcfg

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: centos: coding style
Thomas Lamprecht [Wed, 29 Sep 2021 19:25:09 +0000 (21:25 +0200)]
setup: centos: coding style

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobuildsys: split and order sources definition
Thomas Lamprecht [Wed, 29 Sep 2021 17:53:00 +0000 (19:53 +0200)]
buildsys: split and order sources definition

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: move getting cross-emulator to separate method
Thomas Lamprecht [Wed, 29 Sep 2021 19:08:51 +0000 (21:08 +0200)]
setup: move getting cross-emulator to separate method

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: move setting fastboot flag to base plugin
Thomas Lamprecht [Wed, 29 Sep 2021 17:39:21 +0000 (19:39 +0200)]
setup: move setting fastboot flag to base plugin

better fit there as this may actually not always be wanted.
As no sub-plugin overrides pre_start_hook there should be no actual
semantic change yet.

This is a preperation for a clean abstract Plugin interface and
Unmanaged plugin.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: code reduction
Thomas Lamprecht [Wed, 29 Sep 2021 16:16:55 +0000 (18:16 +0200)]
setup: code reduction

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: factor out actual ssh key generation
Thomas Lamprecht [Wed, 29 Sep 2021 16:13:12 +0000 (18:13 +0200)]
setup: factor out actual ssh key generation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosuse: pre-set locale/timezone to avoid systemd-firstboot hang on prompt
Thomas Lamprecht [Wed, 29 Sep 2021 15:30:50 +0000 (17:30 +0200)]
suse: pre-set locale/timezone to avoid systemd-firstboot hang on prompt

same as commit 1edabe807fe478e34548031c0b6e7e63dcc7f69e

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: group plugin related calls together
Thomas Lamprecht [Tue, 28 Sep 2021 13:43:40 +0000 (15:43 +0200)]
setup: group plugin related calls together

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: sort plugin use/map statements
Thomas Lamprecht [Tue, 28 Sep 2021 13:35:36 +0000 (15:35 +0200)]
setup: sort plugin use/map statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: indendation/code-style fixes
Thomas Lamprecht [Tue, 28 Sep 2021 13:33:58 +0000 (15:33 +0200)]
setup: indendation/code-style fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: avoid one-argument bless
Thomas Lamprecht [Tue, 28 Sep 2021 12:52:26 +0000 (14:52 +0200)]
setup: avoid one-argument bless

> Normally, bless takes two arguments: a reference to the referent
> that is to become the object, and a string naming the desired class
> of that object. However, the second argument is actually optional,
> and defaults to the current package name.
-- page 365 of Perl Best Practice, Convay.

That means that a inheriting module would get the wrong class due to
that, we do not really have that issue with Setup now, but copy-is-my
hobby would allow that error to infect other code ;-)

If one wants the default behavior should say so explicitly, e.g.:
bless { ... }, __PACKAGE__

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: avoid bloat in protected plugin calls
Thomas Lamprecht [Tue, 28 Sep 2021 11:46:22 +0000 (13:46 +0200)]
setup: avoid bloat in protected plugin calls

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocentos: improve rationale in comment and drop static intermediate variable
Thomas Lamprecht [Wed, 25 Aug 2021 14:10:45 +0000 (16:10 +0200)]
centos: improve rationale in comment and drop static intermediate variable

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocentos: set /etc/locale.conf to avoid systemd-firstboot hanging
Oguz Bektas [Tue, 24 Aug 2021 11:35:10 +0000 (13:35 +0200)]
centos: set /etc/locale.conf to avoid systemd-firstboot hanging

we can set the locale to a sane default to avoid the issue described in
forum post [0]

[0]: https://forum.proxmox.com/threads/centos-lxc-containers-require-a-reboot.94972/

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agobump version to 4.0-9
Fabian Grünbichler [Thu, 5 Aug 2021 14:12:00 +0000 (16:12 +0200)]
bump version to 4.0-9

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoapi: limit priv -> unpriv change on container restore to VM.Allocate
Dominik Csapak [Wed, 4 Aug 2021 14:01:34 +0000 (16:01 +0200)]
api: limit priv -> unpriv change on container restore to VM.Allocate

this should only be allowed for uses that have at least VM.Allocate,
but not for users that have only 'VM.Backup'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoskip features when restoring an unprivileged container as privileged
Dominik Csapak [Wed, 4 Aug 2021 10:51:09 +0000 (12:51 +0200)]
skip features when restoring an unprivileged container as privileged

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoallow nesting to be changed for VM.Allocate on unprivileged containers
Dominik Csapak [Wed, 4 Aug 2021 10:51:08 +0000 (12:51 +0200)]
allow nesting to be changed for VM.Allocate on unprivileged containers

instead of it being root only

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoadd old config and unprivileged to check_ct_modify_config_perm
Dominik Csapak [Wed, 4 Aug 2021 10:51:07 +0000 (12:51 +0200)]
add old config and unprivileged to check_ct_modify_config_perm

we'll need that for checking the features more granularly
for it to work correctly, we have to move the permission checks
into the 'lock_config' sub, since we now also need to check the current
config and it could change between the permission check and the lock

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agofix #3478: abort container creation on arch detection timeout
Lorenz Stechauner [Thu, 22 Jul 2021 07:54:56 +0000 (09:54 +0200)]
fix #3478: abort container creation on arch detection timeout

increased the timeout for detect_arch from 5 to 10 seconds.

until now, on any error detect_architecture would fall back to amd64.
to avoid falling back due to an timeout error this function now dies
on timeout errors.

additionally minor changes to the error messages have been made.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
2 years agopct cpuset: show effective values
Wolfgang Bumiller [Tue, 20 Jul 2021 11:19:28 +0000 (13:19 +0200)]
pct cpuset: show effective values

rather than the "desired" ones, this is more useful
(we could also show differences if there are any?)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agopct cpuset: use limiting cgroup
Wolfgang Bumiller [Tue, 20 Jul 2021 11:19:27 +0000 (13:19 +0200)]
pct cpuset: use limiting cgroup

this is what's actually applied to the container (although
the container may be imposing an even stricter limit, but
that's not what we want to see...)

also, the v2 cpuset list may be empty (and often is for
unprivileged+nesting containers), which currently fails to
parse

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump version to 4.0-8
Fabian Grünbichler [Thu, 8 Jul 2021 10:30:01 +0000 (12:30 +0200)]
bump version to 4.0-8

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoconfig: sync ACL checks with qemu-server
Fabian Grünbichler [Thu, 8 Jul 2021 09:23:55 +0000 (11:23 +0200)]
config: sync ACL checks with qemu-server

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agobump version to 4.0-7
Thomas Lamprecht [Tue, 6 Jul 2021 13:48:18 +0000 (15:48 +0200)]
bump version to 4.0-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3506: config: fix removing the cpulimit of a running CT
Thomas Lamprecht [Tue, 6 Jul 2021 13:45:53 +0000 (15:45 +0200)]
fix #3506: config: fix removing the cpulimit of a running CT

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 4.0-6
Wolfgang Bumiller [Tue, 6 Jul 2021 06:27:42 +0000 (08:27 +0200)]
bump version to 4.0-6

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoensure the config dir exists in update_lxc_config
Wolfgang Bumiller [Tue, 6 Jul 2021 06:22:28 +0000 (08:22 +0200)]
ensure the config dir exists in update_lxc_config

Otherwise make_seccomp_config cannot add files to it.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump version to 4.0-5
Thomas Lamprecht [Mon, 5 Jul 2021 16:56:16 +0000 (18:56 +0200)]
bump version to 4.0-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agostart: cgroup compat: warn also to task log
Thomas Lamprecht [Mon, 5 Jul 2021 16:54:31 +0000 (18:54 +0200)]
start: cgroup compat: warn also to task log

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agostart: add pre-start-hook log-warn infra
Thomas Lamprecht [Mon, 5 Jul 2021 16:54:10 +0000 (18:54 +0200)]
start: add pre-start-hook log-warn infra

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: shortcut cgroupv2 support for non-systemd distros
Stoiko Ivanov [Mon, 5 Jul 2021 10:57:15 +0000 (12:57 +0200)]
setup: shortcut cgroupv2 support for non-systemd distros

Alpine and Devuan do not use systemd as init, thus run without
problems in a pure cgroupv2 environment

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agoprestart-hook: detect cgroupv2 incompatible systemd version
Stoiko Ivanov [Mon, 5 Jul 2021 10:57:14 +0000 (12:57 +0200)]
prestart-hook: detect cgroupv2 incompatible systemd version

Some container OS (e.g. CentOS 7, Ubuntu 16.04) are booted with
systemd, in a version which is not able to run with a pure cgroupv2
(a.k.a unified hierarchy) environment.

Detect those in the lxc-pve-prestart-hook, because there we already
have all mount-points set up.

This approach only leaves syslog/journal as place for notifying the
user since starting a container eventually runs `systemctl start
pve-container@VMID.service`, where we lose the prints to stdout and
stderr.

The alternative of shortly mounting all container mounts just to
obtain the systemd-version, before starting the container seems
prohibitively expensive.

The heuristic of /sbin/init needing to be a link to something ending
in systemd is taken from the systemd documentation[0] and was verified
on a few of our container-templates.

[0] https://www.freedesktop.org/software/systemd/man/systemd.html
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 4.0-4
Wolfgang Bumiller [Mon, 5 Jul 2021 08:12:31 +0000 (10:12 +0200)]
bump version to 4.0-4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoadd default userns config file
Wolfgang Bumiller [Mon, 5 Jul 2021 07:13:51 +0000 (09:13 +0200)]
add default userns config file

With cgroupv2 we lose the default devices entries, which in
cgroupv1 results in the default inherited 'a *:* rwm', so
let's have lxc's cgroupv2 default do the same (iow. turn it
into a "deny-list").

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agodisable btrfs ioctl in user namespaces
Wolfgang Bumiller [Thu, 24 Jun 2021 14:09:17 +0000 (16:09 +0200)]
disable btrfs ioctl in user namespaces

Changes the seccomp profile to return EPERM on every btrfs
ioctl.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobtrfs: pass size when creating subvolumes
Wolfgang Bumiller [Thu, 24 Jun 2021 08:14:41 +0000 (10:14 +0200)]
btrfs: pass size when creating subvolumes

otherwise the exception doesn't make much sense

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agobump version to 4.0-3
Thomas Lamprecht [Thu, 24 Jun 2021 06:08:41 +0000 (08:08 +0200)]
bump version to 4.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agospecial case btrfs+quotas to use subvolumes
Wolfgang Bumiller [Tue, 22 Jun 2021 12:18:27 +0000 (14:18 +0200)]
special case btrfs+quotas to use subvolumes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoenable btrfs support via subvolumes
Wolfgang Bumiller [Tue, 22 Jun 2021 12:18:26 +0000 (14:18 +0200)]
enable btrfs support via subvolumes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agomigration: fix snapshots boolean accounting
Wolfgang Bumiller [Tue, 22 Jun 2021 12:18:25 +0000 (14:18 +0200)]
migration: fix snapshots boolean accounting

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoalloc_disk: adapt error for content-type
Thomas Lamprecht [Mon, 21 Jun 2021 08:49:59 +0000 (10:49 +0200)]
alloc_disk: adapt error for content-type

as containers may be supported by the underlying storage tech, but
just not configured at the moment.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoalloc_disk: indentation/text-width cleanup
Thomas Lamprecht [Mon, 21 Jun 2021 08:49:44 +0000 (10:49 +0200)]
alloc_disk: indentation/text-width cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3421: allow custom storage plugins to support rootfs
Lorenz Stechauner [Thu, 27 May 2021 12:23:30 +0000 (14:23 +0200)]
fix #3421: allow custom storage plugins to support rootfs

it is now necessary for storages to support the 'rootdir' content in
order to start containers on them. all native storage plugins
already report the rootdir content correctly.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agopct: correctly handle warnings task status
Fabian Ebner [Wed, 12 May 2021 12:32:56 +0000 (14:32 +0200)]
pct: correctly handle warnings task status

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump version to 4.0-2
Thomas Lamprecht [Mon, 21 Jun 2021 08:41:50 +0000 (10:41 +0200)]
bump version to 4.0-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agomigrate: enforce that rootdir content type is available
Fabian Ebner [Fri, 18 Jun 2021 10:59:32 +0000 (12:59 +0200)]
migrate: enforce that rootdir content type is available

and use it for the vdisk_list call too. This avoids scanning (and picking up
volumes from!) storages that are not even configured to hold container images.

Also serves a bit as a preparation to enforce content type on guest startup,
because now migration failure happens early and not only when trying to start
the guest on the remote node.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agomigrate: also test unused volumes
Fabian Ebner [Fri, 18 Jun 2021 10:59:31 +0000 (12:59 +0200)]
migrate: also test unused volumes

otherwise an unused volume on a disabled storage is silently left on the old
node, even if referenced.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoprefer storage_check_enabled over storage_check_node
Fabian Ebner [Fri, 18 Jun 2021 10:59:30 +0000 (12:59 +0200)]
prefer storage_check_enabled over storage_check_node

storage_check_enabled simply checks for the 'disable' option and then calls
storage_check_node.

While not strictly necessary for a second call where only the storage differs,
it is more future-proof: if support for a target storage is added at some point,
it might be easy to miss adapting the call.

For the migration checks, disabled storages are now always caught.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoclear machine-id: only truncate machine-id file if either it exists or systemd managed
Thomas Lamprecht [Fri, 18 Jun 2021 16:15:45 +0000 (18:15 +0200)]
clear machine-id: only truncate machine-id file if either it exists or systemd managed

Not nice to create empty /etc/machine-id files in, e.g., Alpine Linux
CTs.

The adaption of the else branch is not only an optimization to avoid
unlink call of non-existent file, but required as it not guaranteed
to be in the "no clone" case else anymore.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agosetup: fix calling clone hook with weird params
Thomas Lamprecht [Fri, 18 Jun 2021 16:02:21 +0000 (18:02 +0200)]
setup: fix calling clone hook with weird params

$clone has no use and what the interface constraints on $conf vs.
$self->{conf} really are is nowhere documented, so just use $conf for
now, to at least use only one thing (and avoid the highly confusing
case where the signature suggests that $conf is used, so when one
would pass a to $self->{conf} unrelated $conf it would not work)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoclone_vm: rework firewall config cloning
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:23 +0000 (14:51 +0200)]
clone_vm: rework firewall config cloning

we need to clone the firewall config before doing any actual work, else
we risk partially aborting and leaving a non-firewalled container
around. accordingly, we need to (attempt to) remove the cloned FW config
after successfully removing the guest config in error handling.

partially reverts/fixes 4925b86a920a862f25f0d93d243ce099c922979d clone_vm: improve config locking

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: refactor locking further
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:22 +0000 (14:51 +0200)]
clone_vm: refactor locking further

introduce a new helper handling
- obtaining the flock
- (re)loading the config
- checking that the 'create' lock is still there

before calling a passed-in sub with the current config, since this
pattern was used quite a lot here.

intentionally changed behaviour:
- flock is now held for the post_clone hook call
- failure to remove the 'create' lock or to move the config to the
  target node if applicable will not undo the clone, since either is
  trivially fixable ('pct unlock' or a no-op migration), and copying all
  those volumes might have been quite expensive..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: move linked clone check in eval
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:21 +0000 (14:51 +0200)]
clone_vm: move linked clone check in eval

so that the source config is properly cleaned up/unlocked

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: reduce source flock scope
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:20 +0000 (14:51 +0200)]
clone_vm: reduce source flock scope

set_lock already obtains the flock (since it does a read-modify-write
cycle), and the rest of this code does not touch the config file in any
fashion so no need to hold the flock either..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: use destroy_config instead of manual unlink
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:19 +0000 (14:51 +0200)]
clone_vm: use destroy_config instead of manual unlink

and wrap the calls in an eval to preserve original errors causing us to
remove the config in the first place..

also, remove disks before removing the locked config (reverse order of
creation).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: use move_config_to_node
Fabian Grünbichler [Fri, 18 Jun 2021 12:51:18 +0000 (14:51 +0200)]
clone_vm: use move_config_to_node

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agoclone_vm: fix minor typo in error message
Oguz Bektas [Thu, 17 Jun 2021 10:52:01 +0000 (12:52 +0200)]
clone_vm: fix minor typo in error message

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agorun post_clone_hook in clone_vm API
Oguz Bektas [Thu, 17 Jun 2021 10:52:00 +0000 (12:52 +0200)]
run post_clone_hook in clone_vm API

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agoclone_vm: improve config locking
Oguz Bektas [Thu, 17 Jun 2021 10:51:59 +0000 (12:51 +0200)]
clone_vm: improve config locking

cleaned up the locking situation with config files as Fabian G.
suggested in the review.

use the 'create_and_lock_config' helper in the beginning to ensure that
the target CTID is available, and that the target config is locked from
the beginning. in case any error happens during the initial checks, we
unlink this config in error handling.

firewall config is also now cloned inside the worker instead of before
the worker, in case the clone fails.

also lock the config file when renaming the conf (for moving to a target
node when the option is passed).

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agosetup: add post_clone_hook for containers
Oguz Bektas [Thu, 17 Jun 2021 10:51:58 +0000 (12:51 +0200)]
setup: add post_clone_hook for containers

for now it calls the new clear_machine_id function.

this way when new containers are created they will have a unique
/etc/machine-id.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agoconfig: limit description/comment length to 8 KiB
Thomas Lamprecht [Fri, 18 Jun 2021 11:10:56 +0000 (13:10 +0200)]
config: limit description/comment length to 8 KiB

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agovm status: force int where appropriate
Fabian Ebner [Tue, 1 Jun 2021 06:43:05 +0000 (08:43 +0200)]
vm status: force int where appropriate

In the case of a running container with cgroupv2, swap would be a string,
causing a
    size.toFixed is not a function
error for the format_size call in the containers's "Summary" page in the UI.

The vmids from config_list() are already integers as the return schema expects,
while the opt_vmid passed from the status/current API call needs to be
converted.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agopct: sort and group module-use
Thomas Lamprecht [Wed, 16 Jun 2021 16:34:21 +0000 (18:34 +0200)]
pct: sort and group module-use

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopct config: fix indentation and rework to shorter code
Thomas Lamprecht [Wed, 16 Jun 2021 14:14:10 +0000 (16:14 +0200)]
pct config: fix indentation and rework to shorter code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopct: exec, attach: drop "Error: " prefix from error message
Thomas Lamprecht [Wed, 16 Jun 2021 14:12:39 +0000 (16:12 +0200)]
pct: exec, attach: drop "Error: " prefix from error message

we normally do not have that here, the load_config call (which
ensures that the CT exists) also errors without any "Error" like
prefix, so for consistency drop it.

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