]> git.proxmox.com Git - proxmox-backup.git/commitdiff
file-restore: support more drives
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 6 May 2021 15:26:19 +0000 (17:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 7 May 2021 07:03:17 +0000 (09:03 +0200)
A PCI bus can only support up to 32 devices, so excluding built-in
devices that left us with a maximum of about 25 drives. By adding a new
PCI bridge every 32 devices (starting at bridge ID 2 to avoid conflicts
with automatic bridges), we can theoretically support up to 8096 drives.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/bin/proxmox_file_restore/qemu_helper.rs

index 1b57df5f924a66061104a16a33c18e48020d389a..4a289056a13ec56138b07387ab25228665a1f8f2 100644 (file)
@@ -197,10 +197,21 @@ pub async fn start_vm(
             "file=pbs:repository={},,snapshot={},,archive={}{},read-only=on,if=none,id=drive{}",
             details.repo, details.snapshot, file, keyfile, id
         ));
+
+        // a PCI bus can only support 32 devices, so add a new one every 32
+        let bus = (id / 32) + 2;
+        if id % 32 == 0 {
+            drives.push("-device".to_owned());
+            drives.push(format!("pci-bridge,id=bridge{},chassis_nr={}", bus, bus));
+        }
+
         drives.push("-device".to_owned());
         // drive serial is used by VM to map .fidx files to /dev paths
         let serial = file.strip_suffix(".img.fidx").unwrap_or(&file);
-        drives.push(format!("virtio-blk-pci,drive=drive{},serial={}", id, serial));
+        drives.push(format!(
+            "virtio-blk-pci,drive=drive{},serial={},bus=bridge{}",
+            id, serial, bus
+        ));
         id += 1;
     }