Skip to content

Fix NAS backup filename for legacy LINSTOR path#13538

Open
WanzenBug wants to merge 1 commit into
apache:4.22from
WanzenBug:fix-linstor-nas-backup-legacy-path
Open

Fix NAS backup filename for legacy LINSTOR path#13538
WanzenBug wants to merge 1 commit into
apache:4.22from
WanzenBug:fix-linstor-nas-backup-legacy-path

Conversation

@WanzenBug

Copy link
Copy Markdown

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

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

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>
@boring-cyborg

boring-cyborg Bot commented Jul 3, 2026

Copy link
Copy Markdown

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)
Here are some useful points:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +120 to +124
return 0
fi
done
echo "${fullpath##*/}"
}
Comment on lines +135 to +136
elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then
volUuid=$(get_linstor_uuid_from_device "$fullpath")
Comment on lines +196 to +197
elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then
volUuid=$(get_linstor_uuid_from_device "$fullpath")
Comment on lines +237 to +238
elif [[ "$disk" == /dev/drbd[0-9]* ]]; then
volUuid=$(get_linstor_uuid_from_device "$disk")
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.66%. Comparing base (348ceaf) to head (4e6ee49).
⚠️ Report is 1 commits behind head on 4.22.

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     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.74% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants