diff --git a/src/dbus_api/api/manager_3_2/props.rs b/src/dbus_api/api/manager_3_2/props.rs index 9e0ce6b77f..5e58ff844f 100644 --- a/src/dbus_api/api/manager_3_2/props.rs +++ b/src/dbus_api/api/manager_3_2/props.rs @@ -14,5 +14,5 @@ pub fn get_stopped_pools( i: &mut IterAppend<'_>, p: &PropInfo<'_, MTSync, TData>, ) -> Result<(), MethodErr> { - get_manager_property(i, p, |e| Ok(shared::stopped_pools_prop(e))) + get_manager_property(i, p, |e| Ok(shared::stopped_pools_prop(e, false))) } diff --git a/src/dbus_api/api/manager_3_7/api.rs b/src/dbus_api/api/manager_3_7/api.rs index 3427ce854c..7dc0cc6cce 100644 --- a/src/dbus_api/api/manager_3_7/api.rs +++ b/src/dbus_api/api/manager_3_7/api.rs @@ -2,9 +2,16 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use dbus_tree::{Factory, MTSync, Method}; +use dbus_tree::{Access, EmitsChangedSignal, Factory, MTSync, Method, Property}; -use crate::dbus_api::{api::manager_3_7::methods::start_pool, types::TData}; +use crate::dbus_api::{ + api::{ + manager_3_7::{methods::start_pool, props::get_stopped_pools}, + prop_conv::StoppedOrLockedPools, + }, + consts, + types::TData, +}; pub fn start_pool_method(f: &Factory, TData>) -> Method, TData> { f.method("StartPool", (), start_pool) @@ -23,3 +30,10 @@ pub fn start_pool_method(f: &Factory, TData>) -> Method, TData>) -> Property, TData> { + f.property::(consts::STOPPED_POOLS_PROP, ()) + .access(Access::Read) + .emits_changed(EmitsChangedSignal::True) + .on_get(get_stopped_pools) +} diff --git a/src/dbus_api/api/manager_3_7/mod.rs b/src/dbus_api/api/manager_3_7/mod.rs index f6871e56b4..48fc8b4d99 100644 --- a/src/dbus_api/api/manager_3_7/mod.rs +++ b/src/dbus_api/api/manager_3_7/mod.rs @@ -4,5 +4,6 @@ mod api; mod methods; +mod props; -pub use api::start_pool_method; +pub use api::{start_pool_method, stopped_pools_property}; diff --git a/src/dbus_api/api/manager_3_7/props.rs b/src/dbus_api/api/manager_3_7/props.rs new file mode 100644 index 0000000000..543dba10dc --- /dev/null +++ b/src/dbus_api/api/manager_3_7/props.rs @@ -0,0 +1,18 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +use dbus::arg::IterAppend; +use dbus_tree::{MTSync, MethodErr, PropInfo}; + +use crate::dbus_api::{ + api::shared::{self, get_manager_property}, + types::TData, +}; + +pub fn get_stopped_pools( + i: &mut IterAppend<'_>, + p: &PropInfo<'_, MTSync, TData>, +) -> Result<(), MethodErr> { + get_manager_property(i, p, |e| Ok(shared::stopped_pools_prop(e, true))) +} diff --git a/src/dbus_api/api/mod.rs b/src/dbus_api/api/mod.rs index f299e006a1..8a92d980f6 100644 --- a/src/dbus_api/api/mod.rs +++ b/src/dbus_api/api/mod.rs @@ -148,7 +148,7 @@ pub fn get_base_tree<'a>( .add_m(manager_3_6::stop_pool_method(&f)) .add_m(manager_3_2::refresh_state_method(&f)) .add_p(manager_3_0::version_property(&f)) - .add_p(manager_3_2::stopped_pools_property(&f)), + .add_p(manager_3_7::stopped_pools_property(&f)), ) .add( f.interface(consts::REPORT_INTERFACE_NAME_3_0, ()) diff --git a/src/dbus_api/api/prop_conv.rs b/src/dbus_api/api/prop_conv.rs index e53051fac1..f4bbc177fa 100644 --- a/src/dbus_api/api/prop_conv.rs +++ b/src/dbus_api/api/prop_conv.rs @@ -66,7 +66,7 @@ pub fn locked_pools_to_prop(pools: &LockedPoolsInfo) -> StoppedOrLockedPools { } /// Convert a stopped pool data structure to a property format. -pub fn stopped_pools_to_prop(pools: &StoppedPoolsInfo) -> StoppedOrLockedPools { +pub fn stopped_pools_to_prop(pools: &StoppedPoolsInfo, metadata: bool) -> StoppedOrLockedPools { pools .stopped .iter() @@ -111,6 +111,15 @@ pub fn stopped_pools_to_prop(pools: &StoppedPoolsInfo) -> StoppedOrLockedPools { .collect::>(), )), ); + if metadata { + map.insert( + "metadata_version".to_string(), + match stopped.metadata_version { + Some(m) => Variant(Box::new((true, m as u64))), + None => Variant(Box::new((false, 0))), + }, + ); + } (uuid_to_string!(u), map) }) .collect::>() diff --git a/src/dbus_api/api/shared.rs b/src/dbus_api/api/shared.rs index 825e1b3dda..e2132b6d88 100644 --- a/src/dbus_api/api/shared.rs +++ b/src/dbus_api/api/shared.rs @@ -163,6 +163,6 @@ pub fn locked_pools_prop(e: Arc) -> StoppedOrLockedPools { /// Generate D-Bus representation of stopped pools #[inline] -pub fn stopped_pools_prop(e: Arc) -> StoppedOrLockedPools { - prop_conv::stopped_pools_to_prop(&block_on(e.stopped_pools())) +pub fn stopped_pools_prop(e: Arc, metadata: bool) -> StoppedOrLockedPools { + prop_conv::stopped_pools_to_prop(&block_on(e.stopped_pools()), metadata) } diff --git a/src/dbus_api/tree.rs b/src/dbus_api/tree.rs index b44cd502d1..1fadb300a6 100644 --- a/src/dbus_api/tree.rs +++ b/src/dbus_api/tree.rs @@ -578,32 +578,32 @@ impl DbusTreeHandler { consts::MANAGER_INTERFACE_NAME_3_2 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, false)) }, consts::MANAGER_INTERFACE_NAME_3_3 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, false)) }, consts::MANAGER_INTERFACE_NAME_3_4 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, false)) }, consts::MANAGER_INTERFACE_NAME_3_5 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, false)) }, consts::MANAGER_INTERFACE_NAME_3_6 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, false)) }, consts::MANAGER_INTERFACE_NAME_3_7 => { Vec::new(), consts::STOPPED_POOLS_PROP.to_string() => - box_variant!(stopped_pools_to_prop(&stopped_pools)) + box_variant!(stopped_pools_to_prop(&stopped_pools, true)) } }, ) diff --git a/src/engine/sim_engine/engine.rs b/src/engine/sim_engine/engine.rs index 7c61fc685d..65546d1c60 100644 --- a/src/engine/sim_engine/engine.rs +++ b/src/engine/sim_engine/engine.rs @@ -29,6 +29,7 @@ use crate::{ SetUnlockAction, StartAction, StopAction, StoppedPoolInfo, StoppedPoolsInfo, StratFilesystemDiff, UdevEngineEvent, UnlockMethod, }, + StratSigblockVersion, }, stratis::{StratisError, StratisResult}, }; @@ -254,6 +255,7 @@ impl Engine for SimEngine { uuid: dev_uuid, }) .collect::>(), + metadata_version: Some(StratSigblockVersion::V2), }, ); st diff --git a/src/engine/strat_engine/liminal/device_info.rs b/src/engine/strat_engine/liminal/device_info.rs index 5893cc0e85..8a2f1539ab 100644 --- a/src/engine/strat_engine/liminal/device_info.rs +++ b/src/engine/strat_engine/liminal/device_info.rs @@ -710,6 +710,7 @@ impl DeviceSet { } }) .collect::>(), + metadata_version: self.metadata_version().ok(), }) } diff --git a/src/engine/types/mod.rs b/src/engine/types/mod.rs index 3ea5428053..06e53501ae 100644 --- a/src/engine/types/mod.rs +++ b/src/engine/types/mod.rs @@ -246,6 +246,7 @@ pub struct LockedPoolsInfo { pub struct StoppedPoolInfo { pub info: Option, pub devices: Vec, + pub metadata_version: Option, } #[derive(Default, Debug, Eq, PartialEq)]