Nir Soffer has uploaded a new change for review.
Change subject: guest-lvs: Deactivate guest-lvs when deactivating lvs
......................................................................
guest-lvs: Deactivate guest-lvs when deactivating lvs
Before deactivating lvs (e.g. when shuting down a vm), remove holders
that may keep the lv open and prevent deactivation. This patch fixes
this error seen when a raw volume was used as a pv in the guest:
CannotDeactivateLogicalVolume: Cannot deactivate Logical Volume:
('General Storage Exception: ("5 [] [\' Logical volume
5f35b5c0-17d7-4475-9125-e97f1cdb06f9/17e03f6d-008a-45ed-8c73-d9b22430cd6a
is used by another device.\']
Change-Id: I56bd79013909c6dfcae789f0985c6085768e792a
Bug-Url:
https://bugzilla.redhat.com/1374545
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/storage_lvm_test.py
M vdsm/storage/lvm.py
2 files changed, 27 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/64369/1
diff --git a/tests/storage_lvm_test.py b/tests/storage_lvm_test.py
index c5d2af1..d4a1952 100644
--- a/tests/storage_lvm_test.py
+++ b/tests/storage_lvm_test.py
@@ -103,6 +103,31 @@
finally:
run("vgchange", "-an", "ovirt-vg")
+ @ValidateRunningAsRoot
+ def test_deactivate_ovirt_lv_with_guest_lvs(self):
+ with fake_env() as env:
+ log.debug("Creating host lv")
+ run("pvcreate", "-ff", env.device)
+ run("vgcreate", "ovirt-vg", env.device)
+ run("lvcreate", "-n", "ovirt-lv",
"-L", "512m", "ovirt-vg")
+ try:
+ log.debug("Creating guest-lv")
+ guest_pv = "/dev/ovirt-vg/ovirt-lv"
+ config = "devices {filter=['a|%s|']}" % guest_pv
+ run("pvcreate", "--config", config, "-ff",
"-y", guest_pv)
+ run("vgcreate", "--config", config,
"guest-vg", guest_pv)
+ run("lvcreate", "--config", config, "-n",
"guest-lv",
+ "-L", "128m", "guest-vg")
+ try:
+ lvm.deactivateLVs("ovirt-vg", ["ovirt-lv"])
+ # ovirt-lv must be inactive
+ self.assertEqual(self.find_active_lvs("ovirt-vg"), [])
+ except AssertionError:
+ run("vgchange", "--config", config,
"-an", "guest-vg")
+ raise
+ finally:
+ run("vgchange", "-an", "ovirt-vg")
+
def find_active_lvs(self, vgname):
out = run("lvs", "--noheadings", "-o",
"name",
"--select", "lv_active=active", vgname)[0]
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index c501105..eadf11d 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -1260,6 +1260,8 @@
def deactivateLVs(vgName, lvNames):
toDeactivate = [lvName for lvName in lvNames
if _isLVActive(vgName, lvName)]
+ for lvName in toDeactivate:
+ _remove_lv_holders(vgName, lvName)
if toDeactivate:
log.info("Deactivating lvs: vg=%s lvs=%s", vgName, toDeactivate)
_setLVAvailability(vgName, toDeactivate, "n")
--
To view, visit
https://gerrit.ovirt.org/64369
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I56bd79013909c6dfcae789f0985c6085768e792a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>