all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] file-restore: strip .img.fidx suffix from drive serials
Date: Tue, 27 Apr 2021 15:35:45 +0200	[thread overview]
Message-ID: <20210427133545.12593-1-s.reiter@proxmox.com> (raw)

Drive serials have a character limit of 20, longer names like
"drive-virtio0.img.fidx" or "drive-efidisk0.img.fidx" would get cut off.

Fix this by removing the suffix, it is not necessary to uniquely
identify an image.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
 src/bin/proxmox_file_restore/qemu_helper.rs | 3 ++-
 src/bin/proxmox_restore_daemon/disk.rs      | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/bin/proxmox_file_restore/qemu_helper.rs b/src/bin/proxmox_file_restore/qemu_helper.rs
index e50a8bbf..9328addf 100644
--- a/src/bin/proxmox_file_restore/qemu_helper.rs
+++ b/src/bin/proxmox_file_restore/qemu_helper.rs
@@ -201,7 +201,8 @@ pub async fn start_vm(
         ));
         drives.push("-device".to_owned());
         // drive serial is used by VM to map .fidx files to /dev paths
-        drives.push(format!("virtio-blk-pci,drive=drive{},serial={}", id, file));
+        let serial = file.strip_suffix(".img.fidx").unwrap_or(&file);
+        drives.push(format!("virtio-blk-pci,drive=drive{},serial={}", id, serial));
         id += 1;
     }
 
diff --git a/src/bin/proxmox_restore_daemon/disk.rs b/src/bin/proxmox_restore_daemon/disk.rs
index 08fe7490..0b564e42 100644
--- a/src/bin/proxmox_restore_daemon/disk.rs
+++ b/src/bin/proxmox_restore_daemon/disk.rs
@@ -268,7 +268,11 @@ impl DiskState {
             _ => bail!("no or invalid image in path"),
         };
 
-        let buckets = match self.disk_map.get_mut(req_fidx.as_ref()) {
+        let buckets = match self.disk_map.get_mut(
+            req_fidx
+                .strip_suffix(".img.fidx")
+                .unwrap_or_else(|| req_fidx.as_ref()),
+        ) {
             Some(x) => x,
             None => bail!("given image '{}' not found", req_fidx),
         };
-- 
2.20.1





             reply	other threads:[~2021-04-27 13:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 13:35 Stefan Reiter [this message]
2021-04-27 15:06 ` [pbs-devel] applied: " Thomas Lamprecht

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=20210427133545.12593-1-s.reiter@proxmox.com \
    --to=s.reiter@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