[Devel] [RESEND PATCH vz9] ve/cgroups: improve state handling
Alexander Atanasov
alexander.atanasov at virtuozzo.com
Wed Feb 22 15:46:13 MSK 2023
Improve state handling on error paths and fix show state
to be compatible with vzctl.
libvzctl only cares if the ve is stopped or it is assummed
running - fix this by reporting and updating the states
so libvzctl gets what it expects.
https://jira.sw.ru/browse/PSBM-144580
Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
include/linux/ve.h | 4 ----
kernel/ve/ve.c | 6 +++---
2 files changed, 3 insertions(+), 7 deletions(-)
To addresses Pavel's comments.
libvzctl only checks for STOPPED and if the state is not
stopped it assumes it is running.
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 8e173628b532..5ce1b3edfa9d 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -159,8 +159,6 @@ static inline void ve_set_state(struct ve_struct *ve, int new_state)
"Invalid transition to running from %d\n", ve->state);
WARN_ONCE(new_state == VE_STATE_STOPPING && ve->state != VE_STATE_RUNNING,
"Invalid transition to stopping from %d\n", ve->state);
- WARN_ONCE(new_state == VE_STATE_STOPPED && ve->state != VE_STATE_STOPPING,
- "Invalid transition to stooped from %d\n", ve->state);
ve->state = new_state;
}
@@ -249,10 +247,8 @@ extern bool is_ve_init_net(const struct net *net);
static inline void ve_stop_ns(struct pid_namespace *ns) { }
static inline void ve_exit_ns(struct pid_namespace *ns) { }
-
static inline void ve_set_state(struct ve_struct *ve, int new_state) {}
-
#define ve_feature_set(ve, f) { true; }
static inline bool current_user_ns_initial(void)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 8afef0e631d5..1ff1d77d2ee7 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -787,6 +787,7 @@ static int ve_start_container(struct ve_struct *ve)
err_kthreadd:
ve_list_del(ve);
err_list:
+ ve_set_state(ve, VE_STATE_STOPPED);
ve_drop_context(ve);
return err;
}
@@ -1040,6 +1041,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
err_lat:
kmem_cache_free(ve_cachep, ve);
err_ve:
+ ve_set_state(ve, VE_STATE_STOPPED);
return ERR_PTR(err);
}
@@ -1225,10 +1227,8 @@ static int ve_state_show(struct seq_file *sf, void *v)
seq_puts(sf, "RUNNING");
else if (ve->state == VE_STATE_STOPPING)
seq_puts(sf, "STOPPING");
- else if (ve->state == VE_STATE_STOPPED)
+ else if (ve->state == VE_STATE_STOPPED || ve->state == VE_STATE_DEAD)
seq_puts(sf, "STOPPED");
- else if (ve->state == VE_STATE_DEAD)
- seq_puts(sf, "DEAD");
else
seq_puts(sf, "UNKNOWN");
seq_putc(sf, '\n');
--
2.31.1
More information about the Devel
mailing list