Skip to content

Commit 3c38946

Browse files
authored
standalone: be more helpful with bad block device configs (#758)
1 parent 5267be8 commit 3c38946

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/propolis-standalone/src/config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ pub fn block_backend(
136136
log: &slog::Logger,
137137
) -> (Arc<dyn block::Backend>, String) {
138138
let backend_name = dev.options.get("block_dev").unwrap().as_str().unwrap();
139-
let be = config.block_devs.get(backend_name).unwrap();
139+
let Some(be) = config.block_devs.get(backend_name) else {
140+
panic!("No configured block device named \"{}\"", backend_name);
141+
};
140142
let opts = block::BackendOpts {
141143
block_size: be.block_opts.block_size,
142144
read_only: be.block_opts.read_only,
@@ -149,7 +151,14 @@ pub fn block_backend(
149151

150152
// Check if raw device is being used and gripe if it isn't
151153
let meta = std::fs::metadata(&parsed.path)
154+
.with_context(|| {
155+
format!(
156+
"opening {} for block device \"{}\"",
157+
parsed.path, backend_name
158+
)
159+
})
152160
.expect("file device path is valid");
161+
153162
if meta.file_type().is_block_device() {
154163
slog::warn!(log, "Block backend using standard device rather than raw";
155164
"path" => &parsed.path);

0 commit comments

Comments
 (0)