diff --git a/src/tape/drive/linux_tape.rs b/src/tape/drive/linux_tape.rs index f0a5efc1..7ed18adf 100644 --- a/src/tape/drive/linux_tape.rs +++ b/src/tape/drive/linux_tape.rs @@ -70,42 +70,44 @@ impl LinuxTapeDrive { /// - for autoloader only, try to reload ejected tapes pub fn open(&self) -> Result { - let file = open_linux_tape_device(&self.path)?; + proxmox::try_block!({ + let file = open_linux_tape_device(&self.path)?; - let mut handle = LinuxTapeHandle::new(file); + let mut handle = LinuxTapeHandle::new(file); - let mut drive_status = handle.get_drive_status()?; + let mut drive_status = handle.get_drive_status()?; - if !drive_status.tape_is_ready() { - // for autoloader only, try to reload ejected tapes - if self.changer.is_some() { - let _ = handle.mtload(); // just try, ignore error - drive_status = handle.get_drive_status()?; + if !drive_status.tape_is_ready() { + // for autoloader only, try to reload ejected tapes + if self.changer.is_some() { + let _ = handle.mtload(); // just try, ignore error + drive_status = handle.get_drive_status()?; + } } - } - if !drive_status.tape_is_ready() { - bail!("tape not ready (no tape loaded)"); - } + if !drive_status.tape_is_ready() { + bail!("tape not ready (no tape loaded)"); + } - if drive_status.blocksize == 0 { - // device is variable block size - OK - } else { - if drive_status.blocksize != PROXMOX_TAPE_BLOCK_SIZE as u32 { - eprintln!("device is in fixed block size mode with wrong size ({} bytes)", drive_status.blocksize); - eprintln!("trying to set variable block size mode..."); - if handle.set_block_size(0).is_err() { - bail!("set variable block size mod failed - device uses wrong blocksize."); - } + if drive_status.blocksize == 0 { + // device is variable block size - OK } else { - // device is in fixed block size mode with correct block size + if drive_status.blocksize != PROXMOX_TAPE_BLOCK_SIZE as u32 { + eprintln!("device is in fixed block size mode with wrong size ({} bytes)", drive_status.blocksize); + eprintln!("trying to set variable block size mode..."); + if handle.set_block_size(0).is_err() { + bail!("set variable block size mod failed - device uses wrong blocksize."); + } + } else { + // device is in fixed block size mode with correct block size + } } - } - // Only root can set driver options, so we cannot - // handle.set_default_options()?; + // Only root can set driver options, so we cannot + // handle.set_default_options()?; - Ok(handle) + Ok(handle) + }).map_err(|err| format_err!("open drive '{}' ({}) failed - {}", self.name, self.path, err)) } } diff --git a/src/tape/pool_writer.rs b/src/tape/pool_writer.rs index b3ee9c23..95574499 100644 --- a/src/tape/pool_writer.rs +++ b/src/tape/pool_writer.rs @@ -214,11 +214,12 @@ impl PoolWriter { request_and_load_media(worker, &drive_config, &self.drive_name, media.label())?; // test for critical tape alert flags - let alert_flags = drive.tape_alert_flags()?; - if !alert_flags.is_empty() { - worker.log(format!("TapeAlertFlags: {:?}", alert_flags)); - if tape_alert_flags_critical(alert_flags) { - bail!("aborting due to critical tape alert flags: {:?}", alert_flags); + if let Ok(alert_flags) = drive.tape_alert_flags() { + if !alert_flags.is_empty() { + worker.log(format!("TapeAlertFlags: {:?}", alert_flags)); + if tape_alert_flags_critical(alert_flags) { + bail!("aborting due to critical tape alert flags: {:?}", alert_flags); + } } }