Bug 1452139 - No validation on the VM disks attachments when taking a snapshot
Summary: No validation on the VM disks attachments when taking a snapshot
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: BLL.Storage
Version: 4.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.2.0
: ---
Assignee: shani
QA Contact: Kevin Alon Goldblatt
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-18 12:23 UTC by shani
Modified: 2017-12-20 10:43 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-12-20 10:43:05 UTC
oVirt Team: Storage
Embargoed:
rule-engine: ovirt-4.2+


Attachments (Terms of Use)
Demonstrates taking snapshot for a disk which is not attached to the VM. (832 bytes, text/plain)
2017-05-18 12:23 UTC, shani
no flags Details


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 77317 0 master MERGED core: Validate that disks are attached the VM before taking a snapshot 2017-06-01 15:54:02 UTC

Description shani 2017-05-18 12:23:37 UTC
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:
-

Comment 1 Allon Mureinik 2017-06-01 15:55:25 UTC
Shani, can you please add some doctext explaining the fix?

Comment 2 Kevin 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!

Comment 3 Sandro Bonazzola 2017-12-20 10:43:05 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.