From a75f83225dd6f4641451a24b18326069ef01f129 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 3 May 2022 11:42:26 +0200 Subject: [PATCH] lxc-pve-{prestart, poststop}-hook: initialize RESTEnvironment else some operations will fail, e.g. using an guest disk on an external ceph-cluster Signed-off-by: Dominik Csapak --- src/lxc-pve-poststop-hook | 3 +++ src/lxc-pve-prestart-hook | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook index 0fdd49e..2fe97ec 100755 --- a/src/lxc-pve-poststop-hook +++ b/src/lxc-pve-poststop-hook @@ -12,6 +12,7 @@ use PVE::LXC::Config; use PVE::LXC::Tools; use PVE::LXC; use PVE::Network; +use PVE::RESTEnvironment; use PVE::Storage; use PVE::Tools; @@ -20,6 +21,8 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub { return undef if ! -f PVE::LXC::Config->config_file($vmid); + PVE::RESTEnvironment->setup_default_cli_env(); + my $conf = PVE::LXC::Config->load_config($vmid); my $storage_cfg = PVE::Storage::config(); diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook index 0a76aee..2911e1b 100755 --- a/src/lxc-pve-prestart-hook +++ b/src/lxc-pve-prestart-hook @@ -15,6 +15,7 @@ use PVE::LXC::Config; use PVE::LXC::Setup; use PVE::LXC::Tools; use PVE::LXC; +use PVE::RESTEnvironment; use PVE::SafeSyslog; use PVE::Storage; use PVE::Syscall qw(:fsmount); @@ -39,6 +40,8 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub { PVE::Cluster::check_cfs_quorum(); # only start if we have quorum + PVE::RESTEnvironment->setup_default_cli_env(); + return undef if ! -f PVE::LXC::Config->config_file($vmid); my $conf = PVE::LXC::Config->load_config($vmid); -- 2.39.5