Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1452139

Summary: No validation on the VM disks attachments when taking a snapshot
Product: [oVirt] ovirt-engine Reporter: shani <sleviim>
Component: BLL.StorageAssignee: shani <sleviim>
Status: CLOSED CURRENTRELEASE QA Contact: Kevin Alon Goldblatt <kgoldbla>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.2.0CC: amureini, bugs
Target Milestone: ovirt-4.2.0Flags: rule-engine: ovirt-4.2+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 10:43:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Demonstrates taking snapshot for a disk which is not attached to the VM. none

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.