rustjail: print type of cgroup manager

Since the cgroup manager is wrapped in a dyn now, the print in
LinuxContainer::new has been useless and just says "CgroupManager". Extend the
Debug trait for 'dyn Manager' to print the type of the cgroup manager so that
it's easier to debug issues.

Fixes: #5779
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
(cherry picked from commit ad8968c8d9)
Signed-off-by: Greg Kurz <groug@kaod.org>
This commit is contained in:
Jeremi Piotrowski 2023-02-10 14:34:53 +01:00 committed by Greg Kurz
parent 491b95451c
commit 12ec33d70d
4 changed files with 15 additions and 1 deletions

View File

@ -267,6 +267,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> { fn as_any(&self) -> Result<&dyn Any> {
Ok(self) Ok(self)
} }
fn name(&self) -> &str {
"cgroupfs"
}
} }
fn set_network_resources( fn set_network_resources(

View File

@ -66,6 +66,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> { fn as_any(&self) -> Result<&dyn Any> {
Ok(self) Ok(self)
} }
fn name(&self) -> &str {
"mock"
}
} }
impl Manager { impl Manager {

View File

@ -52,10 +52,12 @@ pub trait Manager {
fn as_any(&self) -> Result<&dyn Any> { fn as_any(&self) -> Result<&dyn Any> {
Err(anyhow!("not supported!")) Err(anyhow!("not supported!"))
} }
fn name(&self) -> &str;
} }
impl Debug for dyn Manager + Send + Sync { impl Debug for dyn Manager + Send + Sync {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "CgroupManager") write!(f, "{}", self.name())
} }
} }

View File

@ -101,6 +101,10 @@ impl CgroupManager for Manager {
fn as_any(&self) -> Result<&dyn Any> { fn as_any(&self) -> Result<&dyn Any> {
Ok(self) Ok(self)
} }
fn name(&self) -> &str {
"systemd"
}
} }
impl Manager { impl Manager {