]> git.proxmox.com Git - pve-container.git/log
pve-container.git
5 months agod/control: recommend libpve-network-perl >= 0.8.3
Wolfgang Bumiller [Tue, 21 Nov 2023 13:46:03 +0000 (14:46 +0100)]
d/control: recommend libpve-network-perl >= 0.8.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoadd missing 'have_sdn' guards
Wolfgang Bumiller [Tue, 21 Nov 2023 11:50:12 +0000 (12:50 +0100)]
add missing 'have_sdn' guards

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agoMerge branch 'sdn/dhcp-support'
Wolfgang Bumiller [Tue, 21 Nov 2023 12:18:37 +0000 (13:18 +0100)]
Merge branch 'sdn/dhcp-support'

5 months agobump pve-common dep to 8.1.0
Wolfgang Bumiller [Tue, 21 Nov 2023 12:17:44 +0000 (13:17 +0100)]
bump pve-common dep to 8.1.0

required for the previous commit (device passthrough)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
5 months agocreate: Do not call create_ifaces_ipams_ips
Stefan Hanreich [Mon, 20 Nov 2023 19:19:54 +0000 (20:19 +0100)]
create: Do not call create_ifaces_ipams_ips

Since create_vm already calls update_pct_config, which in turn calls
vmconfig_apply_pending we do not need to explicitly create the IPAM
entries when creating a container from scratch.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agoconfig: Use LXC Config instead of QemuServer for parsing net
Stefan Hanreich [Mon, 20 Nov 2023 19:19:53 +0000 (20:19 +0100)]
config: Use LXC Config instead of QemuServer for parsing net

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agonetwork: Do not always reserve new IP in IPAM
Stefan Hanreich [Mon, 20 Nov 2023 19:19:52 +0000 (20:19 +0100)]
network: Do not always reserve new IP in IPAM

Currently when updating the network configuration of a container, SDN
would always create a new entry in the IPAM. Only create a new entry
when the bridge or MAC changes or the NIC is completely new.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agohotplug network: Only change IPAM when MAC or bridge changes
Stefan Hanreich [Mon, 20 Nov 2023 19:19:51 +0000 (20:19 +0100)]
hotplug network: Only change IPAM when MAC or bridge changes

Currently a new IPAM entry is created everytime a NIC config changes.
When editing properties other than MAC or Bridge this could lead to
duplicated entries in the IPAM. Only reserve a new IP when the bridge
or MAC changes or the NIC is completely new.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agolxc-pve-prestart-hook : add_dhcp_mapping
Alexandre Derumier [Fri, 17 Nov 2023 11:40:10 +0000 (12:40 +0100)]
lxc-pve-prestart-hook : add_dhcp_mapping

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_apply_pending: add|del ips from ipam for offline changes
Alexandre Derumier [Fri, 17 Nov 2023 11:40:09 +0000 (12:40 +0100)]
vm_apply_pending: add|del ips from ipam for offline changes

Co-Authored-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_clone : create ips in ipams
Alexandre Derumier [Fri, 17 Nov 2023 11:40:08 +0000 (12:40 +0100)]
vm_clone : create ips in ipams

also delete ips in case of failure

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_create|restore: create ips in ipam
Alexandre Derumier [Fri, 17 Nov 2023 11:40:07 +0000 (12:40 +0100)]
vm_create|restore: create ips in ipam

also delete ips on create failure

Co-Authored-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agovm_destroy: remove ips from ipam for all interfaces
Alexandre Derumier [Fri, 17 Nov 2023 11:40:06 +0000 (12:40 +0100)]
vm_destroy: remove ips from ipam for all interfaces

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agonic hotplug : add|del ips in ipam
Alexandre Derumier [Fri, 17 Nov 2023 11:40:05 +0000 (12:40 +0100)]
nic hotplug : add|del ips in ipam

Co-Authored-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agoAdd device passthrough
Filip Schauer [Fri, 17 Nov 2023 10:28:16 +0000 (11:28 +0100)]
Add device passthrough

Add a dev[n] argument to the container config to pass devices through to
a container. A device can be passed by its path. Additionally the access
mode, uid and gid can be specified through their respective properties.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
5 months agobump version to 5.0.6
Thomas Lamprecht [Sun, 19 Nov 2023 18:29:08 +0000 (19:29 +0100)]
bump version to 5.0.6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agotest: add coverage for presets in CentOS 8 setup test
Thomas Lamprecht [Sun, 19 Nov 2023 18:39:08 +0000 (19:39 +0100)]
test: add coverage for presets in CentOS 8 setup test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agotest: use sane indentation for files to check in setup test
Thomas Lamprecht [Sun, 19 Nov 2023 18:46:41 +0000 (19:46 +0100)]
test: use sane indentation for files to check in setup test

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosetup centos: set default systemd preset for CentOS 8 or newer
Thomas Lamprecht [Sun, 19 Nov 2023 18:23:55 +0000 (19:23 +0100)]
setup centos: set default systemd preset for CentOS 8 or newer

Those should be able to cope with our defaults, like enabling
container-getty@ instead of getty@, well

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosetup base: comment breakage potential if used with ancient distros
Thomas Lamprecht [Sun, 19 Nov 2023 18:22:51 +0000 (19:22 +0100)]
setup base: comment breakage potential if used with ancient distros

it isn't for now, but might be in the future

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosetup: handle getty services also via systemd-preset
Thomas Lamprecht [Sun, 19 Nov 2023 18:10:34 +0000 (19:10 +0100)]
setup: handle getty services also via systemd-preset

fixes an issue where the first boot of a Fedora 39 CT had no
container-getty due to the default prefixes enabling the getty@
service instead, only on second boot (where presets aren't applied
anymore) our TTY handling actually was in effect and worked.

Note that preset aren't bothered by a service not existing, but still,
for older distro releases disabling getty@ could lead to problem, for
now we call this only for modern distro releases any way, and it also
only affects newly created CTs.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosetup base: disable sysfs debug mounts via systemd presets
Thomas Lamprecht [Sun, 19 Nov 2023 16:42:38 +0000 (17:42 +0100)]
setup base: disable sysfs debug mounts via systemd presets

they will fail and are not really useful in the container, at least
not as default.
Just disable via the preset mechanism, so any user can easily start
that mount if it'd make sense for their use case.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosetup debian, centos: fixup comment typo/line-length
Thomas Lamprecht [Sun, 19 Nov 2023 16:53:15 +0000 (17:53 +0100)]
setup debian, centos: fixup comment typo/line-length

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agoMerge branch 'c.heiss/nixos/fix-arch-detection'
Wolfgang Bumiller [Fri, 17 Nov 2023 15:44:45 +0000 (16:44 +0100)]
Merge branch 'c.heiss/nixos/fix-arch-detection'

resolved conflict with b58ba5d4494c ("drop old mount code")

5 months agosetup: fix architecture detection for NixOS containers
Christoph Heiss [Mon, 25 Sep 2023 11:38:49 +0000 (13:38 +0200)]
setup: fix architecture detection for NixOS containers

NixOS is special and deviates in many places from a "standard" Linux
system. In this case, /bin/sh does not exist in the filesystem, before
the initial activation (aka. first boot) - which creates a symlink at
/bin/sh.

Due to the currently existing fallback code, only an error message is
logged and the architecture is defaulted to x86_64. Still, this is not
something users might expect.

Thus try a bit harder to detect the architecture for NixOS containers by
inspecting the init script, which contains a shebang-line with the full
path to the system shell.

This moves the architecture detection code to the end of the container
creation lifecycle, so that it can be implemented as a plugin
subroutine. Therefore this mechanism is now generic enough that it can
be adapted to other container OS's in the future if needed. AFAICS
`arch` is only used when writing the actual LXC config, so determining
it later during creation does not change anything.

detect_architecture() has been made a bit more generic; the LXC-specific
error was moved out of this function, as well as the chroot(). Ensuring
that it is executed from the correct rootdir/chroot should be handled by
the caller.

Tested by creating a NixOS and a Debian container (to verify that
nothing regressed) and checking if the warning "Architecure detection
failed: [..]" no longer appears for the NixOS CT and if  `arch` in the
CT config is correct. Also tested restoring both containers from a local
and a PBS backup, as well as migrating both container.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
5 months agogitignore: add build artefacts to ignore list
Stefan Lendl [Fri, 17 Nov 2023 14:30:44 +0000 (15:30 +0100)]
gitignore: add build artefacts to ignore list

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
 [ TL: fix subject & more specific glob ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agoapi: network: get interfaces from containers
Leo Nunner [Thu, 15 Jun 2023 09:43:31 +0000 (11:43 +0200)]
api: network: get interfaces from containers

Adds an 'interfaces' endpoint in the API
(/nodes/{node}/lxc/{vmid}/interfaces'), which returns a list of
interface names, together with a MAC, IPv4 and IPv6 address. This list
may be expanded in the future. Note that this is only returned for
*running* containers, stopped containers simply return an empty list.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
6 months agoadd_bridge_fbd: remove unused firewall param
Alexandre Derumier [Tue, 26 Sep 2023 07:39:38 +0000 (09:39 +0200)]
add_bridge_fbd: remove unused firewall param

6 months agoMerge remote-tracking branch 'origin/master'
Thomas Lamprecht [Wed, 11 Oct 2023 12:06:33 +0000 (14:06 +0200)]
Merge remote-tracking branch 'origin/master'

6 months agodrop old mount code
Wolfgang Bumiller [Tue, 31 May 2022 11:52:27 +0000 (13:52 +0200)]
drop old mount code

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 months agobump version to 5.0.5
Thomas Lamprecht [Mon, 18 Sep 2023 14:52:09 +0000 (16:52 +0200)]
bump version to 5.0.5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 months agofix #3069: vzdump: add 'pbs-entries-max' parameter
Alexander Zeidler [Fri, 28 Jul 2023 13:28:56 +0000 (15:28 +0200)]
fix #3069: vzdump: add 'pbs-entries-max' parameter

configuring pbs-entries-max can avoid failing backups due to a high
amount of files in folders where a folder exclusion is not possible

Signed-off-by: Alexander Zeidler <a.zeidler@proxmox.com>
8 months agofix #3460: restore: honor '--ignore-unpack-errors' flag for pbs
Max Carrara [Mon, 17 Jul 2023 08:04:10 +0000 (10:04 +0200)]
fix #3460: restore: honor '--ignore-unpack-errors' flag for pbs

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
8 months agod/control: require pbs client 3.0.2-1
Wolfgang Bumiller [Wed, 23 Aug 2023 08:04:38 +0000 (10:04 +0200)]
d/control: require pbs client 3.0.2-1

for the `--ignore-extract-device-errors` flag

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
9 months agoconfig permission check: also check access for currently configured bridge
Fiona Ebner [Mon, 17 Jul 2023 07:15:17 +0000 (09:15 +0200)]
config permission check: also check access for currently configured bridge

Relevant when modifying or removing an existing network device.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 months agofix #4765: pct: do not report cpu usage
Maximiliano Sandoval [Thu, 29 Jun 2023 11:34:23 +0000 (13:34 +0200)]
fix #4765: pct: do not report cpu usage

When running `pct status VMID` the variable
$last_proc_vmid_stat->{$vmid} is not set and pct reports no cpu usage.

For consistency with the qt command we do not print the cpu usage.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
10 months agobump version to 5.0.4
Thomas Lamprecht [Sat, 24 Jun 2023 13:08:41 +0000 (15:08 +0200)]
bump version to 5.0.4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agosetup: fedora: fix wrong systemd-networkd preset
Stoiko Ivanov [Fri, 23 Jun 2023 17:19:37 +0000 (19:19 +0200)]
setup: fedora: fix wrong systemd-networkd preset

The refactoring of the systemd-preset handling inadvertently changed
the preset for Fedora >= 37 to disabled in e11806e ("add
setup_systemd_preset helper, disable networkd for debian 12+")

Reported in our community forum:
https://forum.proxmox.com/threads/129395/

Tested with a Fedora 38 container on PVE 8.0

Fixes: e11806e0de064e6570d40e7c04bc4656687b2c62
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
10 months agobump version to 5.0.3
Thomas Lamprecht [Wed, 21 Jun 2023 11:06:01 +0000 (13:06 +0200)]
bump version to 5.0.3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agomigration: add trailing newline to aliased volumes error message
Fiona Ebner [Wed, 21 Jun 2023 10:24:48 +0000 (12:24 +0200)]
migration: add trailing newline to aliased volumes error message

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
10 months agomigration: fail when aliased volume is detected
Aaron Lauterer [Mon, 19 Jun 2023 09:29:36 +0000 (11:29 +0200)]
migration: fail when aliased volume is detected

Aliased volumes (referencing the same volume multiple times) can lead to
unexpected behavior in a migration.

Therefore, stop the migration in such a case.

The check works by comparing the path returned by the storage plugin.
This means that we should be able to catch the common situations where
it can happen:

* by referencing the same volid multiple times
* having a different volid due to an aliased storage: different storage
name but pointing to the same location.

We decided against checking the storages themselves being aliased. It is
not possible to infer that reliably from just the storage configuration
options alone.

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
10 months agomigration: only migrate volumes used by the guest
Aaron Lauterer [Mon, 19 Jun 2023 09:29:35 +0000 (11:29 +0200)]
migration: only migrate volumes used by the guest

When scanning all configured storages for volumes belonging to the
container, the migration could easily fail if a storage is not
available, but enabled. That storage might not even be used by the
container at all.

By not doing that and only looking at the disk images referenced in the
config, we can avoid that.
We need to add additional steps for pending volumes with checks if they
actually exist. Changing an existing mountpoint to a new volume
will only create the volume on the next start of the container.

The big change regarding behavior is that volumes not referenced in the
container config will be ignored.  They are already orphans that used to
be migrated as well, but are now left where they are.

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
10 months agobump version to 5.0.2
Thomas Lamprecht [Fri, 16 Jun 2023 11:35:18 +0000 (13:35 +0200)]
bump version to 5.0.2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agosetup: debian: factor out inittab setup
Wolfgang Bumiller [Fri, 16 Jun 2023 07:59:26 +0000 (09:59 +0200)]
setup: debian: factor out inittab setup

it's too easy to try to append to `setup_init`, missing that
there's a `return if !file_exists` in there...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agosetup: enable systemd-networkd via preset for ubuntu 23.04+
Wolfgang Bumiller [Fri, 16 Jun 2023 07:43:03 +0000 (09:43 +0200)]
setup: enable systemd-networkd via preset for ubuntu 23.04+

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agosetup: enable systemd-networkd via preset for archlinux
Wolfgang Bumiller [Fri, 16 Jun 2023 07:39:45 +0000 (09:39 +0200)]
setup: enable systemd-networkd via preset for archlinux

Note that this is now done in `setup_init` which is a
pre-start hook rather than a one time template fixup,
however, the presets are only applied on first boot or if
the user requests them explicitly, and the usual mechanisms
to prevent the file from being written can be used.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoadd setup_systemd_preset helper, disable networkd for debian 12+
Wolfgang Bumiller [Fri, 16 Jun 2023 07:24:56 +0000 (09:24 +0200)]
add setup_systemd_preset helper, disable networkd for debian 12+

Since we use ifupdown by defaul there and systemd-networkd
would also pull systemd-networkd-wait-online.service which
fails.

We expect this to have to be used for more initial service
setups in the future, so a helper is added to `Base`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agobuildsys: expand clean target
Thomas Lamprecht [Thu, 15 Jun 2023 08:19:05 +0000 (10:19 +0200)]
buildsys: expand clean target

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agoCT modification: fix hostname/DNS perm check
Fabian Grünbichler [Thu, 15 Jun 2023 07:30:06 +0000 (09:30 +0200)]
CT modification: fix hostname/DNS perm check

the old broken code tried to parse the hostname, searchdomain and nameserver
options as guest NIC, which obviously cannot work.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
10 months agotests: add minimal test for LXC_NAME hosts entry
Stoiko Ivanov [Wed, 14 Jun 2023 12:33:25 +0000 (14:33 +0200)]
tests: add minimal test for LXC_NAME hosts entry

based on test-alpine-002

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
10 months agotests: fix small syntax glitch
Stoiko Ivanov [Wed, 14 Jun 2023 12:33:24 +0000 (14:33 +0200)]
tests: fix small syntax glitch

adaptation to adhere to perlcritics recommendation led to the snapshot
tests to not work anymore:
```
Undefined subroutine &Test::MockModule called at snapshot-test.pm line 300.
```

With this the snapshot tests still run and perlcritic seems happy

Fixes: f505de300431134b202ad5a88f55721cb95e6fe4
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
10 months agosetup: cope with non-existing /etc/hosts again
Thomas Lamprecht [Tue, 13 Jun 2023 16:43:31 +0000 (18:43 +0200)]
setup: cope with non-existing /etc/hosts again

Fixes: 8f56203 ("fix #4515: template setup: remove bogus LXC_NAME line from /etc/hosts")
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agosetup: support upcoming Debian, Devuan and Ubuntu releases
Thomas Lamprecht [Tue, 13 Jun 2023 15:49:18 +0000 (17:49 +0200)]
setup: support upcoming Debian, Devuan and Ubuntu releases

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
10 months agofix #4515: template setup: remove bogus LXC_NAME line from /etc/hosts
Stoiko Ivanov [Fri, 9 Jun 2023 17:36:27 +0000 (19:36 +0200)]
fix #4515: template setup: remove bogus LXC_NAME line from /etc/hosts

Templates not built directly by us, but redistributed from
images.linuxcontainer.org contain the following line in /etc/hosts:
`127.0.1.1       LXC_NAME`

While it is mostly cosmetic - LXC_NAME, contains an underscore and is
not a valid DNS name.

Simply drop it for newly created containers in template_fixup.

We ship Debian, Devuan ourselves, without this line - so no need for
modification there.

Currently the NixOS container-template (see [0]) also does not seem
to contain the line.

Noticed the issue with a fresh fedora container, where systemd-resolved
logs a warning upon boot.

[0] https://nixos.wiki/wiki/Proxmox_Linux_Container

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
11 months agosetup: systemd-network: use correct values for dhcp-modes
Stoiko Ivanov [Fri, 9 Jun 2023 13:05:51 +0000 (15:05 +0200)]
setup: systemd-network: use correct values for dhcp-modes

the change from v4->ipv4 happened 2015 in systemd commit
cb9fc36a1211967e8c58b0502a26c42552ac8060 - so by now it should be
safe to replace it for all containers relying on systemd-networkd.

This change follows fb554c701f1e9cac4b278fd6b82a4f2b45da8acf (in
pve-container) but in this case the issue is only cosmetic for now.

Noticed with a current arch-linux container

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
11 months agobump version to 5.0.1
Thomas Lamprecht [Fri, 9 Jun 2023 08:18:29 +0000 (10:18 +0200)]
bump version to 5.0.1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agod/control: bump versioned dependency to libpve-access-control
Thomas Lamprecht [Fri, 9 Jun 2023 08:15:40 +0000 (10:15 +0200)]
d/control: bump versioned dependency to libpve-access-control

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agod/control: bump versioned dependency to libpve-guest-common-perl
Thomas Lamprecht [Fri, 9 Jun 2023 08:15:29 +0000 (10:15 +0200)]
d/control: bump versioned dependency to libpve-guest-common-perl

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agocheck_bridge_access: code cleanup
Thomas Lamprecht [Fri, 9 Jun 2023 08:10:04 +0000 (10:10 +0200)]
check_bridge_access: code cleanup

like in qemu-server

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agonetwork permissions: implement checks
Fabian Grünbichler [Fri, 9 Jun 2023 07:51:41 +0000 (09:51 +0200)]
network permissions: implement checks

when creating a new container
when restoring a backup
when cloning a container
and obviously, when changing the nics of an existing container

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
 [ T: add $opt in override param check ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agoconfig: implement method to calculate derived properties from a config
Fiona Ebner [Tue, 28 Feb 2023 10:54:08 +0000 (11:54 +0100)]
config: implement method to calculate derived properties from a config

See the corresponding commit in guest-common for more information.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
11 months agosetup: fedora: support up to Fedora 40 for future proofing
Thomas Lamprecht [Thu, 8 Jun 2023 09:38:11 +0000 (11:38 +0200)]
setup: fedora: support up to Fedora 40 for future proofing

We might want to make this actually open ended, or just warn for
best-effort if above our tested range..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agoapi: resize: fork before locking
Fiona Ebner [Tue, 30 May 2023 13:52:07 +0000 (15:52 +0200)]
api: resize: fork before locking

making sure the early checks are done once before the expensive
forking and locking and once after locking, because the state might
have changed.

The size calculation had to be adapted a bit, to ensure the original
size is not added twice when it's a request with a leading '+'.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
11 months agoapi: resize: drop error that can never apply
Fiona Ebner [Tue, 30 May 2023 13:52:06 +0000 (15:52 +0200)]
api: resize: drop error that can never apply

Because container images are never qcow2.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
11 months agofix #4457: use bridge mtu if no mtu is defined
Alexandre Derumier [Tue, 11 Apr 2023 12:44:48 +0000 (14:44 +0200)]
fix #4457: use bridge mtu if no mtu is defined

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
11 months agodrop old 'lxc.id_map' config key support
Wolfgang Bumiller [Mon, 5 Jun 2023 09:51:48 +0000 (11:51 +0200)]
drop old 'lxc.id_map' config key support

lxc since v3 only support 'lxc.idmap' now and we don't need
to support this here either anymore

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: expand clean target
Wolfgang Bumiller [Thu, 25 May 2023 12:16:21 +0000 (14:16 +0200)]
buildsys: expand clean target

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump version to 5.0.0
Wolfgang Bumiller [Thu, 25 May 2023 11:58:56 +0000 (13:58 +0200)]
bump version to 5.0.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agoskip userns tests in sbuild environment
Wolfgang Bumiller [Thu, 25 May 2023 12:04:57 +0000 (14:04 +0200)]
skip userns tests in sbuild environment

Since they cannot run in a chroot. They'd need a
`pivot_root` environment instead.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agod/control: depend on debhelper-compat =13
Wolfgang Bumiller [Thu, 25 May 2023 11:58:49 +0000 (13:58 +0200)]
d/control: depend on debhelper-compat =13

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agod/control: raise standards compliance to 4.6.2
Wolfgang Bumiller [Thu, 25 May 2023 11:58:28 +0000 (13:58 +0200)]
d/control: raise standards compliance to 4.6.2

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: change source format to native
Wolfgang Bumiller [Thu, 25 May 2023 11:58:03 +0000 (13:58 +0200)]
buildsys: change source format to native

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump version to 4.4-4
Wolfgang Bumiller [Thu, 25 May 2023 07:37:32 +0000 (09:37 +0200)]
bump version to 4.4-4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: improve builddir generation
Wolfgang Bumiller [Thu, 25 May 2023 07:49:15 +0000 (09:49 +0200)]
buildsys: improve builddir generation

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: derive upload dist automatically
Wolfgang Bumiller [Thu, 25 May 2023 07:44:48 +0000 (09:44 +0200)]
buildsys: derive upload dist automatically

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: improve clean target
Wolfgang Bumiller [Thu, 25 May 2023 07:44:07 +0000 (09:44 +0200)]
buildsys: improve clean target

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobuildsys: add sbuild target, improve dsc target
Wolfgang Bumiller [Thu, 25 May 2023 07:40:23 +0000 (09:40 +0200)]
buildsys: add sbuild target, improve dsc target

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agomakefile: convert to simple parenthesis
Wolfgang Bumiller [Thu, 25 May 2023 07:39:26 +0000 (09:39 +0200)]
makefile: convert to simple parenthesis

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agolxc start: warn in case of conflicting lxc.idmap entries
Friedrich Weber [Mon, 15 May 2023 13:08:23 +0000 (15:08 +0200)]
lxc start: warn in case of conflicting lxc.idmap entries

Users can customize the mapping between host and container uids/gids
by providing `lxc.idmap` entries in the container config. The syntax
is described in lxc.container.conf(5). One source of errors are
conflicting entries for one or more uid/gids. An example:

    ...
    lxc.idmap: u 0 100000 65536
    lxc.idmap: u 1000 1000 10
    ...

Assuming `root:1000:10` is correctly added to /etc/subuid, starting
the container fails with an error that is hard to interpret:

    lxc_map_ids: 3701 newuidmap failed to write mapping
    "newuidmap: write to uid_map failed: Invalid argument":
    newuidmap 67993 0 100000 65536 1000 1000 10

In order to simplify troubleshooting, validate the mapping before
starting the container and print a warning if a conflict is detected.
For the above mapping:

    lxc.idmap: invalid map entry 'u 1000 1000 10':
    container uid 1000 is also mapped by entry 'u 0 100000 65536'

The warning appears in the task log and in the output of `pct start`.

The validation subroutine considers uid and gid mappings separately.
For each of the two types, it makes one pass to detect container id
conflicts and one pass to detect host id conflicts. The subroutine
dies with the first detected conflict.

A failed validation only prints a warning instead of erroring out, to
make sure buggy (or outdated) validation logic does not prevent
containers from starting.

Note that validation does not take /etc/sub{uid,gid} into account,
which, if misconfigured, could still prevent the container from
starting with an error like

    "newuidmap: uid range [1000-1010) -> [1000-1010) not allowed"

If needed, validating /etc/sub{uid,gid} could be added in the future.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
12 months agod/copyright: update years
Thomas Lamprecht [Mon, 8 May 2023 08:51:18 +0000 (10:51 +0200)]
d/copyright: update years

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agomemory: enforce memory.high also on hotplug changes
Thomas Lamprecht [Wed, 26 Apr 2023 14:21:21 +0000 (16:21 +0200)]
memory: enforce memory.high also on hotplug changes

Factor out the calculation into a method to ensure it keeps in sync
and then use the newly added parameter of the change_memory_limit
PVE::CGroup method, bump the dependency in d/control respectively.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agomemory: set cgroupv2 memory.high to ~99.6% of memory.max hard-limit
Thomas Lamprecht [Mon, 3 Oct 2022 09:10:30 +0000 (11:10 +0200)]
memory: set cgroupv2 memory.high to ~99.6% of memory.max hard-limit

cgroup memory usage is limited by the hard 'max' limit (OOM-killer
enforced) and the soft 'high' limit (cgroup processes get throttled
and put under heavy reclaim pressure). Set the latter high limit to
1016/1024 (~99.2%) of the 'max' hard limit, this scales with CT
memory allocations, & gives a decent 2^x based rest for 2^y memory
config which is still quite near the upper bound – clamp the maximum
gap between high and max at 128 MiB to avoid that huge container pay
quite an high amount of absolute cost.

A few example for differences between max & high for a few mem sizes:
- 2 MiB lower for 256 MiB max
- 16 MiB lower for 2 GiB max
- 128 MiB for 16 GiB and above

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agosetup: avoid writing truncated machine-id if it didn't exist
Thomas Lamprecht [Wed, 26 Apr 2023 14:22:35 +0000 (16:22 +0200)]
setup: avoid writing truncated machine-id if it didn't exist

Allows an admin to prepare a template that will have the first-boot
condition set on first start, as we only want to disable first-boot
condition but (re)generate also a machine-id on clone if the
machine-id already exist and isn't set to "uninitialized".

Link: https://forum.proxmox.com/threads/126291/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agogroup and order use statements
Thomas Lamprecht [Wed, 26 Apr 2023 12:28:31 +0000 (14:28 +0200)]
group and order use statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agofix various perlcritic lints
Thomas Lamprecht [Tue, 11 Apr 2023 14:42:54 +0000 (16:42 +0200)]
fix various perlcritic lints

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agoprestart hook: avoid variable declared in conditional statement
Thomas Lamprecht [Tue, 11 Apr 2023 14:42:41 +0000 (16:42 +0200)]
prestart hook: avoid variable declared in conditional statement

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agomigration: avoid variable declared in conditional statement
Thomas Lamprecht [Tue, 11 Apr 2023 14:42:18 +0000 (16:42 +0200)]
migration: avoid variable declared in conditional statement

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agoupdate disk size: avoid variable declared in conditional statement
Thomas Lamprecht [Tue, 11 Apr 2023 14:41:59 +0000 (16:41 +0200)]
update disk size: avoid variable declared in conditional statement

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agopct: avoid variable declared in conditional statement
Thomas Lamprecht [Tue, 11 Apr 2023 14:41:21 +0000 (16:41 +0200)]
pct: avoid variable declared in conditional statement

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
12 months agotest: fix perlcritic lint
Thomas Lamprecht [Tue, 11 Apr 2023 14:41:00 +0000 (16:41 +0200)]
test: fix perlcritic lint

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
13 months agobump version to 4.4-3
Wolfgang Bumiller [Thu, 16 Mar 2023 15:00:03 +0000 (16:00 +0100)]
bump version to 4.4-3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
13 months agonet: Add `link_down` config to allow setting interfaces as disconnected
Christoph Heiss [Wed, 22 Feb 2023 12:49:02 +0000 (13:49 +0100)]
net: Add `link_down` config to allow setting interfaces as disconnected

If this network option is set, the host-side link will be forced down
and the interface won't be connected to the bridge.

Add a `Disconnect` option for network interfaces on LXC containers, much
like it already exists for VMs. This has been requested in #3413 [0] and
seems useful, especially considering we already support the same thing
for VMs.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=3413

One thing to note is that LXC does not seem to support the notion of
setting an interface down. The `flags` property would suggest that this
possible [1], but AFAICS it does not work. I tried setting the value as
empty and to something else than "up" (since that is really the only
supported option [2][3]), which both had absolutely no effect.

[1] https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html#lbAO
[2] https://github.com/lxc/lxc/blob/08f0e769/src/lxc/confile.c#L453-L467
[3] https://github.com/lxc/lxc/blob/08f0e769/src/lxc/confile.c#L5933-L5952

Thus force the host-side link of the container network down and avoid
adding it to the designated bridge if the new option is set, effectively
disconnecting the container network.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by:  Friedrich Weber <f.weber@proxmox.com>
 [ T: paste cover letter as commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
13 months agonet: Pass network config directly to net_tap_plug()
Christoph Heiss [Wed, 22 Feb 2023 12:49:01 +0000 (13:49 +0100)]
net: Pass network config directly to net_tap_plug()

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by:  Friedrich Weber <f.weber@proxmox.com>
14 months agohotplug net: whitespace/indentation fixup
Thomas Lamprecht [Tue, 21 Feb 2023 16:59:07 +0000 (17:59 +0100)]
hotplug net: whitespace/indentation fixup

we don't keep the closing param parenthesis at the same line if
params use up more than one line.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
14 months agolxc: Avoid open-coding normal vs SDN-specific tap_plug()
Christoph Heiss [Tue, 21 Feb 2023 08:05:48 +0000 (09:05 +0100)]
lxc: Avoid open-coding normal vs SDN-specific tap_plug()

This pattern is used in multiple places, thus just extract it into a sub
on its own.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
14 months agolxc: Fix some trailing whitespace
Christoph Heiss [Tue, 21 Feb 2023 08:05:47 +0000 (09:05 +0100)]
lxc: Fix some trailing whitespace

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
14 months agofix #4470: pct fstrim: ignore bind or read-only mountpoints
Friedrich Weber [Mon, 20 Feb 2023 10:04:45 +0000 (11:04 +0100)]
fix #4470: pct fstrim: ignore bind or read-only mountpoints

Currently, `pct fstrim` will run `fstrim` on all mountpoints
of the container, including bind and read-only mountpoints.

However, trimming a bind mountpoint might trim a host
filesystem, which users may not expect. Also, trimming can
be considered a write operation, which users may not expect
to be carried out on a read-only mountpoint.

Hence, exclude bind mointpoints and read-only mountpoints
from trimming.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
14 months agofix: shutdown: if lxc-stop fails, wait for socket closing with timeout
Friedrich Weber [Wed, 25 Jan 2023 13:07:49 +0000 (14:07 +0100)]
fix: shutdown: if lxc-stop fails, wait for socket closing with timeout

When trying to shutdown a hung container with `forceStop=0` (e.g. via
the Web UI), the shutdown task may run indefinitely while holding a lock
on the container config. The reason is that the shutdown subroutine
waits for the LXC command socket to close, even if the `lxc-stop`
command has failed due to timeout. This prevents other tasks (such as a
stop task) from acquiring the lock. In order to stop the container, the
shutdown task has to be explicitly killed first, which is inconvenient.
This occurs e.g. when trying to shutdown a hung CentOS 7 container (with
systemd <v232) in a cgroupv2 environment.

This fix imposes a timeout on the socket polling operation if the
`lxc-stop` command has failed. Behavior in case `lxc-stop` succeeds is
unchanged. This reintroduces some behavior from b1bad293. The timeout
duration is the given shutdown timeout, meaning that the final task
duration in the scenario above is twice the shutdown timeout.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
15 months agofix #4460: setup: centos: create /etc/hostname if it does not exist
Friedrich Weber [Mon, 16 Jan 2023 16:52:34 +0000 (17:52 +0100)]
fix #4460: setup: centos: create /etc/hostname if it does not exist

Previously, the CentOS setup only wrote to /etc/hostname if the file
already existed. Many CT templates of Redhat-derived distros do not
contain that file, so the containers ended up without /etc/hostname.
This caused systemd-hostnamed to report the "static hostname" to be
empty. If networking is handled by NetworkManager, the empty static
hostname caused DHCP requests to be sent without the "Hostname"
field, as reported in #4460.

With this fix, the CentOS setup module creates /etc/hostname if it
does not exist, so NetworkManager correctly reads the hostname and
includes it in DHCP requests.

Manually tested with the following CT templates (checking that
/etc/hostname exists and DHCP requests include the hostname):

- Distros using NetworkManager:

  - Alma Linux 9 (almalinux-9-default_20221108_amd64.tar.xz)
  - CentOS 8 (centos-8-default_20201210_amd64.tar.xz)
  - CentOS 9 Stream (centos-9-stream-default_20221109_amd64.tar.xz)
  - Rocky Linux 9 (rockylinux-9-default_20221109_amd64.tar.xz)

- Distros using network-scripts (here, DHCP requests already
  contained the hostname without this fix, as network-scripts does
  not rely on systemd-hostnamed):

  - Alma Linux 8 (almalinux-8-default_20210928_amd64.tar.xz)
  - CentOS 7 (centos-7-default_20190926_amd64.tar.xz)
  - CentOS 8 Stream (centos-8-stream-default_20220327_amd64.tar.xz)
  - Rocky Linux 8 (rockylinux-8-default_20210929_amd64.tar.xz)

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
 [ T: slightly touch up of commit message format / wording ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
15 months agoallow riscv32/64 containers
Wolfgang Bumiller [Thu, 12 Jan 2023 10:50:47 +0000 (11:50 +0100)]
allow riscv32/64 containers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>