Fix NAS backup filename for legacy LINSTOR path#13538
Conversation
When backing up a running VM, nasbackup.sh derives the backup filename from the disk source path reported by libvirt. VMs started before the switch to /dev/drbd/by-res/ paths still carry the raw DRBD device node (e.g. /dev/drbd1098) in their live domain XML, which fell into the basename fallback and produced root.drbd1098.qcow2 instead of root.<volume-uuid>.qcow2. Restore always expects the UUID-based name, so these backups could not be restored until the VM was stopped and started. Resolve raw /dev/drbdNNNN device nodes back to the volume UUID by asking udev for the device's /dev/drbd/by-res/cs-<uuid> symlink. Apply the same handling in all three backup loops (running-VM XML build, sparsify, and stopped-VM convert). Signed-off-by: Moritz Tanner <moritz.tanner@linbit.com>
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
There was a problem hiding this comment.
Pull request overview
Fixes CloudStack KVM NAS backup filename generation for legacy LINSTOR VMs whose live libvirt XML still references raw /dev/drbdNNNN device nodes, ensuring backups use the expected UUID-based naming so restores can locate the correct qcow2 files.
Changes:
- Add
get_linstor_uuid_from_device()to map raw DRBD device nodes back to a LINSTOR volume UUID via udev symlinks. - Apply the raw-DRBD handling consistently in the running-VM XML generation loop, the post-backup sparsify loop, and the stopped-VM convert loop.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return 0 | ||
| fi | ||
| done | ||
| echo "${fullpath##*/}" | ||
| } |
| elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then | ||
| volUuid=$(get_linstor_uuid_from_device "$fullpath") |
| elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then | ||
| volUuid=$(get_linstor_uuid_from_device "$fullpath") |
| elif [[ "$disk" == /dev/drbd[0-9]* ]]; then | ||
| volUuid=$(get_linstor_uuid_from_device "$disk") |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #13538 +/- ##
=========================================
Coverage 17.66% 17.66%
- Complexity 15791 15794 +3
=========================================
Files 5923 5923
Lines 533309 533309
Branches 65238 65238
=========================================
+ Hits 94226 94235 +9
+ Misses 428437 428427 -10
- Partials 10646 10647 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
When backing up a running VM, nasbackup.sh derives the backup filename from the disk source path reported by libvirt. VMs started before the switch to /dev/drbd/by-res/ paths still carry the raw DRBD device node (e.g. /dev/drbd1098) in their live domain XML, which fell into the basename fallback and produced root.drbd1098.qcow2 instead of root..qcow2. Restore always expects the UUID-based name, so these backups could not be restored until the VM was stopped and started.
Resolve raw /dev/drbdNNNN device nodes back to the volume UUID by asking udev for the device's /dev/drbd/by-res/cs- symlink. Apply the same handling in all three backup loops (running-VM XML build, sparsify, and stopped-VM convert).
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?