Amit Aviram has uploaded a new change for review.

Change subject: vm: Libvirt quering after disk detach operation addition.
......................................................................

vm: Libvirt quering after disk detach operation addition.

As stated in libvirt documentary, after detaching a device using the API
we need to verify that this device has actually been detached.

Not doing so can cause various problems, as hotunplugDisk could return a
success result while it did not actually succeeds to detach the disk.

This patch adds this functionallity to hotunplugDisk, and after some
timeout fails the operation if the disk was not detached.

Change-Id: I393ce55dd761ac825cb96bd499976fd74c366b09
Bug-Url: https://bugzilla.redhat.com/1206696
Signed-off-by: Amit Aviram <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/45138/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5094669..8546226 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -29,6 +29,7 @@
 import threading
 import time
 import uuid
+import datetime
 
 # 3rd party libs imports
 import libvirt
@@ -2635,6 +2636,14 @@
                                     params=drive.custom)
         try:
             self._dom.detachDevice(driveXml)
+            opStarted = datetime.datetime.now()
+            timoutSec = 10
+            while drive.serial in self._dom.XMLDesc(0):
+                self.log.debug("Waiting for hotunplug to finish.")
+                time.sleep(1)
+                if (datetime.datetime.now() - opStarted).seconds > timoutSec:
+                    return response.error('hotunplugDisk',
+                                   "libvirt could not detach the disk.")
         except libvirt.libvirtError as e:
             self.log.exception("Hotunplug failed")
             if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:


-- 
To view, visit https://gerrit.ovirt.org/45138
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I393ce55dd761ac825cb96bd499976fd74c366b09
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Amit Aviram <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to