Fix NAS backup filename for legacy LINSTOR path (#13538)
Some checks failed
Build / build (push) Has been cancelled
Simulator CI / build (component/find_hosts_for_migration component/test_acl_isolatednetwork component/test_acl_isolatednetwork_delete component/test_acl_listsnapshot) (push) Has been cancelled
Simulator CI / build (component/test_acl_listvm component/test_acl_listvolume) (push) Has been cancelled
Simulator CI / build (component/test_acl_sharednetwork component/test_acl_sharednetwork_deployVM-impersonation component/test_user_private_gateway component/test_user_shared_network) (push) Has been cancelled
Simulator CI / build (component/test_affinity_groups_projects component/test_allocation_states component/test_assign_vm) (push) Has been cancelled
Simulator CI / build (component/test_concurrent_snapshots_limit component/test_cpu_domain_limits component/test_cpu_limits component/test_cpu_max_limits component/test_cpu_project_limits component/test_deploy_vm_userdata_multi_nic component/test_deploy_vm_lease) (push) Has been cancelled
Simulator CI / build (component/test_egress_fw_rules component/test_invalid_gw_nm component/test_ip_reservation) (push) Has been cancelled
Simulator CI / build (component/test_lb_secondary_ip component/test_list_nics component/test_list_pod component/test_memory_limits) (push) Has been cancelled
Simulator CI / build (component/test_mm_domain_limits component/test_mm_max_limits component/test_mm_project_limits component/test_network_offering component/test_non_contiguous_vlan) (push) Has been cancelled
Simulator CI / build (component/test_persistent_networks component/test_project_configs component/test_project_limits component/test_project_resources) (push) Has been cancelled
Simulator CI / build (component/test_project_usage component/test_protocol_number_security_group component/test_public_ip component/test_resource_limits component/test_resource_limit_tags) (push) Has been cancelled
Simulator CI / build (component/test_regions_accounts component/test_routers component/test_snapshots component/test_stopped_vm component/test_tags component/test_templates component/test_updateResourceCount component/test_update_vm) (push) Has been cancelled
Simulator CI / build (component/test_volumes component/test_vpc component/test_vpc_distributed_routing_offering component/test_vpc_network component/test_vpc_offerings component/test_vpc_routers component/test_vpn_users component/test_vpc_network_lbrules) (push) Has been cancelled
Simulator CI / build (smoke/test_accounts smoke/test_account_access smoke/test_affinity_groups smoke/test_affinity_groups_projects smoke/test_annotations smoke/test_async_job smoke/test_attach_multiple_volumes smoke/test_backup_recovery_dummy smoke/test_certauthority… (push) Has been cancelled
Simulator CI / build (smoke/test_cluster_drs smoke/test_dynamicroles smoke/test_enable_account_settings_for_domain smoke/test_enable_role_based_users_in_projects smoke/test_events_resource smoke/test_global_settings smoke/test_guest_vlan_range smoke/test_host_mainten… (push) Has been cancelled
Simulator CI / build (smoke/test_list_accounts smoke/test_list_disk_offerings smoke/test_list_domains smoke/test_list_hosts smoke/test_list_service_offerings smoke/test_list_storage_pools smoke/test_list_volumes) (push) Has been cancelled
Simulator CI / build (smoke/test_network smoke/test_network_acl smoke/test_network_ipv6 smoke/test_network_permissions smoke/test_nic smoke/test_nic_adapter_type smoke/test_non_contigiousvlan smoke/test_object_stores smoke/test_outofbandmanagement smoke/test_outofban… (push) Has been cancelled
Simulator CI / build (smoke/test_router_dhcphosts smoke/test_router_dns smoke/test_router_dnsservice smoke/test_routers smoke/test_routers_iptables_default_policy smoke/test_routers_network_ops smoke/test_scale_vm smoke/test_secondary_storage smoke/test_service_offer… (push) Has been cancelled
Coverage Check / codecov (push) Has been cancelled
PR Merge Conflict Check / triage (push) Has been cancelled
License Check / build (push) Has been cancelled
UI Build / build (push) Has been cancelled

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>
This commit is contained in:
Moritz Tanner 2026-08-19 08:59:13 +02:00 committed by GitHub
parent 7fc063ec13
commit 85bcdb1cc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,6 +108,23 @@ get_linstor_uuid_from_path() {
echo "$volUuid"
}
get_linstor_uuid_from_device() {
local fullpath="$1"
# VMs started before the /dev/drbd/by-res/ change still reference the raw DRBD
# device node (e.g. /dev/drbd1098) in their live libvirt XML. Ask udev for the
# device's symlinks and map it back to the volume UUID via the by-res symlink.
local link
for link in $(udevadm info --query=symlink --name="$fullpath" 2>/dev/null || true); do
if [[ "$link" == drbd/by-res/cs-* ]]; then
get_linstor_uuid_from_path "/dev/$link"
return 0
fi
done
# Without a by-res symlink we cannot derive the volume UUID. Falling back to the
# raw device name would produce a backup that restore cannot find, so fail hard.
return 1
}
backup_running_vm() {
mount_operation
mkdir -p "$dest" || { echo "Failed to create backup directory $dest"; exit 1; }
@ -117,6 +134,12 @@ backup_running_vm() {
while read -r disk fullpath; do
if [[ "$fullpath" == /dev/drbd/by-res/* ]]; then
volUuid=$(get_linstor_uuid_from_path "$fullpath")
elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then
if ! volUuid=$(get_linstor_uuid_from_device "$fullpath"); then
echo "Failed to resolve LINSTOR volume UUID for $fullpath"
cleanup
exit 1
fi
else
volUuid="${fullpath##*/}"
fi
@ -174,10 +197,18 @@ backup_running_vm() {
# Use qemu-img convert to sparsify linstor backups which get bloated due to virsh backup-begin.
name="root"
while read -r disk fullpath; do
if [[ "$fullpath" != /dev/drbd/by-res/* ]]; then
if [[ "$fullpath" == /dev/drbd/by-res/* ]]; then
volUuid=$(get_linstor_uuid_from_path "$fullpath")
elif [[ "$fullpath" == /dev/drbd[0-9]* ]]; then
if ! volUuid=$(get_linstor_uuid_from_device "$fullpath"); then
echo "Failed to resolve LINSTOR volume UUID for $fullpath"
cleanup
exit 1
fi
else
name="datadisk"
continue
fi
volUuid=$(get_linstor_uuid_from_path "$fullpath")
if ! qemu-img convert -O qcow2 "$dest/$name.$volUuid.qcow2" "$dest/$name.$volUuid.qcow2.tmp" >> "$logFile" 2> >(cat >&2); then
echo "qemu-img convert failed for $dest/$name.$volUuid.qcow2"
cleanup
@ -213,6 +244,12 @@ backup_stopped_vm() {
volUuid=$(get_ceph_uuid_from_path "$disk")
elif [[ "$disk" == /dev/drbd/by-res/* ]]; then
volUuid=$(get_linstor_uuid_from_path "$disk")
elif [[ "$disk" == /dev/drbd[0-9]* ]]; then
if ! volUuid=$(get_linstor_uuid_from_device "$disk"); then
echo "Failed to resolve LINSTOR volume UUID for $disk"
cleanup
exit 1
fi
else
volUuid="${disk##*/}"
fi