]> git.proxmox.com Git - pve-container.git/log
pve-container.git
8 hours agofix #5414: use proper percentages in `pct df` master
Fabian Grünbichler [Thu, 25 Apr 2024 07:40:13 +0000 (09:40 +0200)]
fix #5414: use proper percentages in `pct df`

while some people write percentages as 0.XX , putting a % next to that is just
confusing. also, combined with the format modifier this would be rather lossy,
and also not match regular `df` output..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
36 hours agobump version to 5.0.11
Thomas Lamprecht [Wed, 24 Apr 2024 12:28:04 +0000 (14:28 +0200)]
bump version to 5.0.11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
36 hours agoapi: fix regression with locking start-after-create
Thomas Lamprecht [Wed, 24 Apr 2024 12:21:20 +0000 (14:21 +0200)]
api: fix regression with locking start-after-create

The API now correctly forks first a worker and then locks the config
in for the actual creation, but this broke the start-after-create
feature, as that also locks the config.

Use the same approach like in qemu-server and just do the start after
the create, outside of the lock.

While this has a small race window where another API call could lock
the newly created CT again, we never really guaranteed that the start
after create param is guaranteed atomic.

Even if we want to guarantee that someday, we can still do so, but
this is a good stop-gap until then and worked fine for VMs since its
introduction.

Fixes: 7a73568 ("api: status: move config locking from API handler into worker")
Reported-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
6 days agobump version to 5.0.10
Thomas Lamprecht [Fri, 19 Apr 2024 18:33:07 +0000 (20:33 +0200)]
bump version to 5.0.10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 days agofirewall: add handling for new nft firewall
Stefan Hanreich [Fri, 19 Apr 2024 09:42:35 +0000 (11:42 +0200)]
firewall: add handling for new nft firewall

When the nftables firewall is enabled, we do not need to create
firewall bridges.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [ TL: use a more meaningful variable name and add a comment ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agoapi: stop: reword overrule-shutdown parameter description
Friedrich Weber [Thu, 18 Apr 2024 13:46:36 +0000 (15:46 +0200)]
api: stop: reword overrule-shutdown parameter description

The previous wording made it sound like all "visible" tasks were
aborted, which is not the case: A user with Sys.Audit but without
Sys.Modify may see a task that was started by a different user, but
overrule-shutdown would not abort the task.

Change wording to better reflect that not all visible tasks may be
aborted.

Also, add a full-stop that was previously missing.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
7 days agovolume mount: make adding noacl more efficient
Thomas Lamprecht [Thu, 18 Apr 2024 13:48:46 +0000 (15:48 +0200)]
volume mount: make adding noacl more efficient

Move this special case handling inside the code branch where we
already got the format available to avoid calling parse_volname twice.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agod/control: record build-dependency for dh-apparmor
Thomas Lamprecht [Thu, 18 Apr 2024 13:41:46 +0000 (15:41 +0200)]
d/control: record build-dependency for dh-apparmor

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agoformat disk: set FS root uid/gid for passed through /dev/ volumes
Thomas Lamprecht [Thu, 18 Apr 2024 13:19:36 +0000 (15:19 +0200)]
format disk: set FS root uid/gid for passed through /dev/ volumes

When calling mkfs one must pass the root uid/gid parameter along side
as they are used unconditionally, but this wasn't done for the edge
case where a block device from the host was used as volume for the CT,
causing an undef warning.

Note that this code branch is not reachable currently, but that might
change. For now add a FIXME comment to mark this for removal, as we
probably do not want to format devices from /dev/ in any way (and no
user reported that this was broken, so use case seems to be
non-existent).

Fixes: d216e89 ("unprivileged: remove bad chown -R call")
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agotree-wide: style fixes for root uid/gid variable name
Thomas Lamprecht [Thu, 18 Apr 2024 13:17:49 +0000 (15:17 +0200)]
tree-wide: style fixes for root uid/gid variable name

no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agovolume mount: code clean-up & reduction
Thomas Lamprecht [Thu, 18 Apr 2024 12:55:15 +0000 (14:55 +0200)]
volume mount: code clean-up & reduction

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
7 days agofix #4846: Avoid the outdated noacl mount option on ext4
Filip Schauer [Wed, 17 Apr 2024 14:35:53 +0000 (16:35 +0200)]
fix #4846: Avoid the outdated noacl mount option on ext4

Do not use the 'noacl' mount option when mounting a container disk with
an ext4 file system. The option was deprecated in kernel commit
f70486055ee3 ("ext4: try to deprecate noacl and noxattr_user mount
options") (v3.4) as it no other filesystem exposed disabling ACL as
mount option, and then finally got removed in commit 2d544ec923db ("ext4:
remove deprecated noacl/nouser_xattr options") (v6.1).

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 days agod/control: bump versioned dependencies for libpve-guest-common-perl
Thomas Lamprecht [Wed, 17 Apr 2024 15:42:54 +0000 (17:42 +0200)]
d/control: bump versioned dependencies for libpve-guest-common-perl

to ensure that the new abort_guest_tasks helper is available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 days agofix #4474: lxc api: add overrule-shutdown parameter to stop endpoint
Friedrich Weber [Fri, 12 Apr 2024 14:15:50 +0000 (16:15 +0200)]
fix #4474: lxc api: add overrule-shutdown parameter to stop endpoint

The new `overrule-shutdown` parameter is boolean and defaults to 0. If
it is 1, all active `vzshutdown` tasks for the same CT (which are
visible to the user/token) are aborted before attempting to stop the
CT.

Passing `overrule-shutdown=1` is forbidden for HA resources.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
9 days agoconfig: add missing use statement for LXC::Tools module
Fiona Ebner [Tue, 16 Apr 2024 10:50:41 +0000 (12:50 +0200)]
config: add missing use statement for LXC::Tools module

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
9 days agofix invalid device passthrough being added to config
Filip Schauer [Tue, 16 Apr 2024 09:27:17 +0000 (11:27 +0200)]
fix invalid device passthrough being added to config

Fix a bug that allows a device passthrough entry to be added to the
config despite the device path not pointing to a device. Previously,
adding an invalid device passthrough entry would throw an error, but the
entry would still be added to the config. This is fixed by moving the
respective checks from update_lxc_config to update_pct_config, which is
run before the entry is written to the config file.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
[FE: drop hunk for use statements left-over from earlier version]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
13 days agopct: fsck: add missing call to activate volume
Fiona Ebner [Fri, 12 Apr 2024 11:08:14 +0000 (13:08 +0200)]
pct: fsck: add missing call to activate volume

Otherwise, running pct fsck for e.g. an LVM volume after shutting down
a container would fail.

The container is not running, so the volume should be deactivated
afterwards.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
13 days agopct: fsck: also unmap when fsck command failed
Fiona Ebner [Fri, 12 Apr 2024 11:08:13 +0000 (13:08 +0200)]
pct: fsck: also unmap when fsck command failed

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
13 days agomountpoint mount: activate PVE-managed volumes during preparation
Fiona Ebner [Fri, 12 Apr 2024 11:08:12 +0000 (13:08 +0200)]
mountpoint mount: activate PVE-managed volumes during preparation

Otherwise it was not possible to hotplug a volume that was previously
deactivated and requires activation, e.g. an LVM LV that was detached
after shutting down the container couldn't be hotplugged anymore
later.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 weeks agoconfig list helper: fix return type of vmid for container index API enpoint
Fiona Ebner [Tue, 5 Dec 2023 11:35:32 +0000 (12:35 +0100)]
config list helper: fix return type of vmid for container index API enpoint

The schema declares it to be an integer. Done in the config_list()
helper, to ensure consistency for the following existing code in
vmstatus():

> my $list = $opt_vmid ? { $opt_vmid => { type => 'lxc', vmid => int($opt_vmid) }} : config_list();

Should not cause any issues for other callers of the helper.

Reported in the community forum:
https://forum.proxmox.com/threads/137628/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2 weeks agofix undef warning when apparmor changeprofile fails
Filip Schauer [Tue, 9 Apr 2024 09:26:23 +0000 (11:26 +0200)]
fix undef warning when apparmor changeprofile fails

Fix a "Use of uninitialized value in numeric ne (!=)" warning when
syswrite returns undef when trying to change the apparmor profile.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
2 weeks agofix #5160: fix move_mount regression for mount point hotplug
Filip Schauer [Tue, 9 Apr 2024 09:26:22 +0000 (11:26 +0200)]
fix #5160: fix move_mount regression for mount point hotplug

Set up an Apparmor profile to allow moving mounts for mount point
hotplug.

This fixes a regression caused by
kernel commit 157a3537d6 ("apparmor: Fix regression in mount mediation")

The commit introduced move_mount mediation, which now requires
move_mount to be allowed in the Apparmor profile. Although it is allowed
for most paths in the /usr/bin/lxc-start profile, move_mount is called
with a file descriptor instead of a path in mountpoint_insert_staged,
thus it is not affected by the allow rules in
/etc/apparmor.d/abstractions/lxc/container-base.

To fix this, introduce a new Apparmor profile to allow move_mount on
every mount, specifically for mount point hotplug.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
3 weeks agoapi: status: move config locking from API handler into worker
Friedrich Weber [Tue, 30 Jan 2024 17:10:53 +0000 (18:10 +0100)]
api: status: move config locking from API handler into worker

Previously, container start/stop/shutdown/suspend would try to acquire
the config lock in the API handler prior to forking a worker. If the
lock was currently held elsewhere, this would block the API handler
and thus the pvedaemon worker thread until the 10s timeout expired (or
the lock could be acquired).

To avoid blocking the API handler, immediately fork off a worker
process and try to acquire the config lock in that worker.

Patch best viewed with `git show -w`.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
5 weeks agobump version to 5.0.9
Thomas Lamprecht [Fri, 15 Mar 2024 09:24:41 +0000 (10:24 +0100)]
bump version to 5.0.9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 weeks agopct: drop completion helper for target storage on remote-migration
Thomas Lamprecht [Fri, 15 Mar 2024 09:23:01 +0000 (10:23 +0100)]
pct: drop completion helper for target storage on remote-migration

not much use to complete local storages here

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 weeks agopct: avoid use of qemu-server completion method
Thomas Lamprecht [Fri, 15 Mar 2024 09:18:03 +0000 (10:18 +0100)]
pct: avoid use of qemu-server completion method

Didn't matter functionality wise, as VMIDs are agnostic to the actual
guest type, but ugly and making it harder to bootstrap.

Worked by luck only if QemuServer got loaded already.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 weeks agoapi: lxc: add missing use statement for UNIX Sockets module
Thomas Lamprecht [Fri, 8 Mar 2024 13:44:39 +0000 (14:44 +0100)]
api: lxc: add missing use statement for UNIX Sockets module

worked by luck as this was already loaded by some of our dependencies
already.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agopct: add keep-env option to the 'enter' and 'exec' command
Folke Gleumes [Fri, 9 Feb 2024 13:17:09 +0000 (14:17 +0100)]
pct: add keep-env option to the 'enter' and 'exec' command

The keep-env option allows the user to define if the current
environment should be kept when running 'pct enter/exec'. pct will now
always set '--keep-env' or '--clear-env' when calling lxc-attach to
anticipate the upcoming change in default behavior.

Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
 [ TL: fix some extra whitespace, extend subject slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agofix #5194: pct: delete environment variables set by pve
Folke Gleumes [Mon, 29 Jan 2024 15:43:17 +0000 (16:43 +0100)]
fix #5194: pct: delete environment variables set by pve

proxmox-perl-rs set's SSL_CERT_{DIR,FILE}, which can break ssl in
containers if their certificate store can't be found in the same spot.
This patch explicitly unsets those variables before starting the
container.

Signed-off-by: Folke Gleumes <f.gleumes@proxmox.com>
3 months agoconfig: schema: remove duplicate attribute assignment for mpX
Filip Schauer [Tue, 3 Oct 2023 12:46:41 +0000 (14:46 +0200)]
config: schema: remove duplicate attribute assignment for mpX

The 'optional' attribute is already set just above this hunk.

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
[FE: expand commit title/message]
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
5 months agobump version to 5.0.8
Thomas Lamprecht [Wed, 22 Nov 2023 13:11:58 +0000 (14:11 +0100)]
bump version to 5.0.8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
5 months agosdn: fix wrong vmid parameter in prestart-hook
Stefan Hanreich [Tue, 21 Nov 2023 17:50:16 +0000 (18:50 +0100)]
sdn: fix wrong vmid parameter in prestart-hook

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agosdn: pass vmid and hostname to add_dhcp_mapping
Stefan Lendl [Tue, 21 Nov 2023 14:55:55 +0000 (15:55 +0100)]
sdn: pass vmid and hostname to add_dhcp_mapping

If no DHCP mapping was found in IPAM it will request a new IP.
In order to register an IPAM mapping it requires these values.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
5 months agobump version to 5.0.7
Wolfgang Bumiller [Tue, 21 Nov 2023 14:45:09 +0000 (15:45 +0100)]
bump version to 5.0.7

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>