-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
problem
Description
When restoring a volume from backup and attaching it to a running KVM VM, the volume is only attached at the database level but not actually hot-attached to the running VM via libvirt. This means:
- The volume appears in CloudStack UI as "attached"
- The volume does NOT appear in
virsh domblklist <vm-name> - The volume is NOT visible inside the guest OS
- User must reboot(forced) the VM to see the restored volume
Root Cause
In KVMGuru.attachRestoredVolumeToVirtualMachine() (line 380-400), the method only:
- Updates the volume state in the database via
_volumeDao.attachVolume() - Sets volume state to
Ready
It does NOT: - Check if VM is running
- Send an
AttachCommandto the KVM agent to hot-attach the disk via libvirt
Expected Behavior
When attaching a restored volume to a running VM:
- CloudStack should detect the VM state
- If VM is Running, send a libvirt attach command to hot-attach the disk
- Volume should immediately appear in
virsh domblklistand inside guest OS - No reboot should be required
versions
CloudStack: 4.21.0
Hypervisor: KVM
Host OS: Rocky Linux 9
Guest OS: Rocky Linux 9 / Windows 10 - 2022 Server
The steps to reproduce the bug
Steps to Reproduce
- Create a VM with a data disk
- Create a backup of the VM
- Start the VM (ensure it's running)
- Restore the backed-up volume and attach to the running VM via API:
restoreVolumeFromBackupAndAttachToVM - Check
virsh domblklist <vm-name>on the KVM host - Observe: The restored volume is NOT listed
- Check inside guest OS
- Observe: The disk is NOT visible
- Reboot(forced) the VM
- Observe: After reboot(forced), the disk appears
What to do about it?
Either:
A) Add hot-attach logic to KVMGuru.attachRestoredVolumeToVirtualMachine() to send AttachCommand when VM is running
B) Or document this as expected behavior and require users to stop VM before restoring volumes
Option A is preferred as it aligns with how regular attachVolume API works for running VMs.
khayalhus
Metadata
Metadata
Assignees
Labels
No labels