Cause: There was no validation the disks supplied by the user as command's parameters on SDK / REST API have been attached the VM. Therefore, in case the disk doesn't attach the VM, it would silently be ignored.
Consequence: Snapshot created with no disks.
Fix: Add validation for disks supplied by the user (as a part of SDK / REST API command parameters) that indicates if there are some disks among them which are not attached the VM before taking the snapshot.
Result: Error message which includes disks' names for disks which are not attached the VM (among the user's parameters) + operation stops.
Created attachment 1279973[details]
Demonstrates taking snapshot for a disk which is not attached to the VM.
Python SDK reproduction
Description of problem:
When taking a snapshot for a VM using the REST API, there's no validation on the VM disks attachments, so it's "possible" to take a snapshot for a disk which attached to other VM. (The snapshot created has no disks).
Version-Release number of selected component (if applicable):
Reproduced for 4.2 version, although according to the code, was probably present before that.
How reproducible:
100%
Steps to Reproduce:
1. Create a VM.
2. Create a disk and don't attach it to the vm.
3. Using the REST API or SDK, take a snapshot for the VM with the disk's id.
Actual results:
Snapshot created with no disks.
Expected results:
Error (the disk doesn't belong to the VM).
Additional info:
-
Shani, can you please add some doctext explaining the fix?
Comment 2Kevin Alon Goldblatt
2017-07-09 12:10:54 UTC
Verified with the following code:
-----------------------------------
ovirt-engine-4.2.0-0.0.master.20170621095718.git8901d14.el7.centos.noarch
vdsm-4.20.1-66.git228c7be.el7.centos.x86_64
Verified with the following scenaroi:
-------------------------------------------
1. Created a VM without a disk
2. Created a floating disk
3. Via REST API ran the following request:
Method:
-------------------------------------
POST
URL:
-------------------------------------
https://xxxx.xxxx.xxxx.xxxx.com/ovirt-engine/api/vms/<VM-ID>/snapshots
Headers:
-------------------------------------
Content-Type: application/xml
Body:
-------------------------------------
<snapshot>
<description>snapped1</description>
<disk_attachments>
<disk_attachment>
<disk id='07554ba6-d0d8-4afb-ba94-08488a6647e9'/>
</disk_attachment>
</disk_attachments>
</snapshot>
Returns:
------------------------------------
Status Code: 400 Bad Request
Moving to VERIFIED!
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.
Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.
If the solution does not work for you, please open a new bug report.
Created attachment 1279973 [details] Demonstrates taking snapshot for a disk which is not attached to the VM. Python SDK reproduction Description of problem: When taking a snapshot for a VM using the REST API, there's no validation on the VM disks attachments, so it's "possible" to take a snapshot for a disk which attached to other VM. (The snapshot created has no disks). Version-Release number of selected component (if applicable): Reproduced for 4.2 version, although according to the code, was probably present before that. How reproducible: 100% Steps to Reproduce: 1. Create a VM. 2. Create a disk and don't attach it to the vm. 3. Using the REST API or SDK, take a snapshot for the VM with the disk's id. Actual results: Snapshot created with no disks. Expected results: Error (the disk doesn't belong to the VM). Additional info: -