From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3F046B905E for ; Thu, 7 Dec 2023 13:51:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 206D8DF0B for ; Thu, 7 Dec 2023 13:51:04 +0100 (CET) Received: from bookworm-dev.localdomain (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Thu, 7 Dec 2023 13:51:02 +0100 (CET) Received: by bookworm-dev.localdomain (Postfix, from userid 1000) id BE88F604DC; Thu, 7 Dec 2023 13:51:02 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Thu, 7 Dec 2023 13:51:01 +0100 Message-Id: <20231207125102.128713-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.378 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [drive.rs, drive.name, mod.rs] Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tape: changer: save whole LtoTapeDrive config in MtxMediaChanger X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2023 12:51:34 -0000 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 --- 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, 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 { @@ -423,12 +421,12 @@ impl MediaChange for MtxMediaChanger { } fn load_media_from_slot(&mut self, slot: u64) -> Result { - self.config.load_slot(slot, self.drive_number) + self.config.load_slot(slot, self.drive_number()) } fn unload_media(&mut self, target_slot: Option) -> Result { 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