api2/tape/{backup, restore}, proxmox-tape: set device state
set the drive device state everywhere we lock it, so that we know what it currently does Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
8be48ddfc7
commit
926d05ef0b
@ -54,6 +54,7 @@ use crate::{
|
|||||||
drive::{
|
drive::{
|
||||||
media_changer,
|
media_changer,
|
||||||
lock_tape_device,
|
lock_tape_device,
|
||||||
|
set_tape_device_state,
|
||||||
},
|
},
|
||||||
changer::update_changer_online_status,
|
changer::update_changer_online_status,
|
||||||
},
|
},
|
||||||
@ -139,6 +140,7 @@ pub fn do_tape_backup_job(
|
|||||||
move |worker| {
|
move |worker| {
|
||||||
let _drive_lock = drive_lock; // keep lock guard
|
let _drive_lock = drive_lock; // keep lock guard
|
||||||
|
|
||||||
|
set_tape_device_state(&tape_job.drive, &worker.upid().to_string())?;
|
||||||
job.start(&worker.upid().to_string())?;
|
job.start(&worker.upid().to_string())?;
|
||||||
|
|
||||||
let eject_media = false;
|
let eject_media = false;
|
||||||
@ -168,6 +170,14 @@ pub fn do_tape_backup_job(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Err(err) = set_tape_device_state(&tape_job.drive, "") {
|
||||||
|
eprintln!(
|
||||||
|
"could not unset drive state for {}: {}",
|
||||||
|
tape_job.drive,
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
job_result
|
job_result
|
||||||
}
|
}
|
||||||
)?;
|
)?;
|
||||||
@ -265,7 +275,10 @@ pub fn backup(
|
|||||||
to_stdout,
|
to_stdout,
|
||||||
move |worker| {
|
move |worker| {
|
||||||
let _drive_lock = drive_lock; // keep lock guard
|
let _drive_lock = drive_lock; // keep lock guard
|
||||||
|
set_tape_device_state(&drive, &worker.upid().to_string())?;
|
||||||
backup_worker(&worker, datastore, &drive, &pool_config, eject_media, export_media_set)?;
|
backup_worker(&worker, datastore, &drive, &pool_config, eject_media, export_media_set)?;
|
||||||
|
// ignore errors
|
||||||
|
let _ = set_tape_device_state(&drive, "");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
)?;
|
)?;
|
||||||
|
@ -69,6 +69,7 @@ use crate::{
|
|||||||
TapeDriver,
|
TapeDriver,
|
||||||
request_and_load_media,
|
request_and_load_media,
|
||||||
lock_tape_device,
|
lock_tape_device,
|
||||||
|
set_tape_device_state,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -134,6 +135,8 @@ pub fn restore(
|
|||||||
move |worker| {
|
move |worker| {
|
||||||
let _drive_lock = drive_lock; // keep lock guard
|
let _drive_lock = drive_lock; // keep lock guard
|
||||||
|
|
||||||
|
set_tape_device_state(&drive, &worker.upid().to_string())?;
|
||||||
|
|
||||||
let _lock = MediaPool::lock(status_path, &pool)?;
|
let _lock = MediaPool::lock(status_path, &pool)?;
|
||||||
|
|
||||||
let members = inventory.compute_media_set_members(&media_set_uuid)?;
|
let members = inventory.compute_media_set_members(&media_set_uuid)?;
|
||||||
@ -189,6 +192,16 @@ pub fn restore(
|
|||||||
}
|
}
|
||||||
|
|
||||||
task_log!(worker, "Restore mediaset '{}' done", media_set);
|
task_log!(worker, "Restore mediaset '{}' done", media_set);
|
||||||
|
|
||||||
|
if let Err(err) = set_tape_device_state(&drive, "") {
|
||||||
|
task_log!(
|
||||||
|
worker,
|
||||||
|
"could not unset drive state for {}: {}",
|
||||||
|
drive,
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
)?;
|
)?;
|
||||||
|
@ -43,6 +43,7 @@ use proxmox_backup::{
|
|||||||
drive::{
|
drive::{
|
||||||
open_drive,
|
open_drive,
|
||||||
lock_tape_device,
|
lock_tape_device,
|
||||||
|
set_tape_device_state,
|
||||||
},
|
},
|
||||||
complete_media_label_text,
|
complete_media_label_text,
|
||||||
complete_media_set_uuid,
|
complete_media_set_uuid,
|
||||||
@ -543,6 +544,7 @@ fn move_to_eom(mut param: Value) -> Result<(), Error> {
|
|||||||
let drive = extract_drive_name(&mut param, &config)?;
|
let drive = extract_drive_name(&mut param, &config)?;
|
||||||
|
|
||||||
let _lock = lock_tape_device(&config, &drive)?;
|
let _lock = lock_tape_device(&config, &drive)?;
|
||||||
|
set_tape_device_state(&drive, "moving to eom")?;
|
||||||
|
|
||||||
let mut drive = open_drive(&config, &drive)?;
|
let mut drive = open_drive(&config, &drive)?;
|
||||||
|
|
||||||
@ -572,6 +574,7 @@ fn debug_scan(mut param: Value) -> Result<(), Error> {
|
|||||||
let drive = extract_drive_name(&mut param, &config)?;
|
let drive = extract_drive_name(&mut param, &config)?;
|
||||||
|
|
||||||
let _lock = lock_tape_device(&config, &drive)?;
|
let _lock = lock_tape_device(&config, &drive)?;
|
||||||
|
set_tape_device_state(&drive, "debug scan")?;
|
||||||
|
|
||||||
let mut drive = open_drive(&config, &drive)?;
|
let mut drive = open_drive(&config, &drive)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user