all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tape: changer: save whole LtoTapeDrive config in MtxMediaChanger
Date: Thu,  7 Dec 2023 13:51:01 +0100	[thread overview]
Message-ID: <20231207125102.128713-1-d.csapak@proxmox.com> (raw)

we'll need more info from there in the future, so derive clone for it
and save the whole config instead of adding an additional field.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-api-types/src/tape/drive.rs |  2 +-
 src/tape/changer/mod.rs         | 14 ++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/pbs-api-types/src/tape/drive.rs b/pbs-api-types/src/tape/drive.rs
index ea2cbbd8..ec7c8395 100644
--- a/pbs-api-types/src/tape/drive.rs
+++ b/pbs-api-types/src/tape/drive.rs
@@ -59,7 +59,7 @@ pub struct VirtualTapeDrive {
         },
     }
 )]
-#[derive(Serialize, Deserialize, Updater)]
+#[derive(Serialize, Deserialize, Updater, Clone)]
 #[serde(rename_all = "kebab-case")]
 /// Lto SCSI tape driver
 pub struct LtoTapeDrive {
diff --git a/src/tape/changer/mod.rs b/src/tape/changer/mod.rs
index 0cb42486..bf0a15f4 100644
--- a/src/tape/changer/mod.rs
+++ b/src/tape/changer/mod.rs
@@ -384,8 +384,7 @@ fn load_changer_state_cache(changer: &str) -> Result<Option<MtxStatus>, Error> {
 
 /// Implements MediaChange using 'mtx' linux cli tool
 pub struct MtxMediaChanger {
-    drive_name: String, // used for error messages
-    drive_number: u64,
+    drive: LtoTapeDrive,
     config: ScsiTapeChanger,
 }
 
@@ -398,8 +397,7 @@ impl MtxMediaChanger {
         };
 
         Ok(Self {
-            drive_name: drive_config.name.clone(),
-            drive_number: drive_config.changer_drivenum.unwrap_or(0),
+            drive: drive_config.clone(),
             config: changer_config,
         })
     }
@@ -407,11 +405,11 @@ impl MtxMediaChanger {
 
 impl MediaChange for MtxMediaChanger {
     fn drive_number(&self) -> u64 {
-        self.drive_number
+        self.drive.changer_drivenum.unwrap_or(0)
     }
 
     fn drive_name(&self) -> &str {
-        &self.drive_name
+        &self.drive.name
     }
 
     fn status(&mut self) -> Result<MtxStatus, Error> {
@@ -423,12 +421,12 @@ impl MediaChange for MtxMediaChanger {
     }
 
     fn load_media_from_slot(&mut self, slot: u64) -> Result<MtxStatus, Error> {
-        self.config.load_slot(slot, self.drive_number)
+        self.config.load_slot(slot, self.drive_number())
     }
 
     fn unload_media(&mut self, target_slot: Option<u64>) -> Result<MtxStatus, Error> {
         if let Some(target_slot) = target_slot {
-            self.config.unload(target_slot, self.drive_number)
+            self.config.unload(target_slot, self.drive_number())
         } else {
             let status = self.status()?;
             self.unload_to_free_slot(status)
-- 
2.39.2




             reply	other threads:[~2023-12-07 12:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07 12:51 Dominik Csapak [this message]
2023-12-07 12:51 ` [pbs-devel] [PATCH proxmox-backup 2/2] fix #4904: tape changer: add option to eject before unload Dominik Csapak
2023-12-12 13:38   ` [pbs-devel] applied: " Dietmar Maurer
2023-12-12 13:38 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] tape: changer: save whole LtoTapeDrive config in MtxMediaChanger Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231207125102.128713-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal