Change in vdsm[master]: v2v: janitorial: use the response module
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: v2v: janitorial: use the response module
......................................................................
v2v: janitorial: use the response module
This patch makes v2v.py use the response module.
Change-Id: I678e764a2895e7c34df6852759b1d43baeb687a1
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/v2v.py
1 file changed, 4 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/38447/1
diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index 4fbecf0..18f59d9 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -22,8 +22,8 @@
import libvirt
-from vdsm.define import errCode, doneCode
from vdsm import libvirtconnection
+from vdsm import response
import caps
@@ -39,7 +39,7 @@
def get_external_vms(uri, username, password):
if not supported():
- return errCode["noimpl"]
+ return response.error("noimpl")
try:
conn = libvirtconnection.open_connection(uri=uri,
@@ -47,8 +47,7 @@
passwd=password)
except libvirt.libvirtError as e:
logging.error('error connection to hypervisor: %r', e.message)
- return {'status': {'code': errCode['V2VConnection']['status']['code'],
- 'message': e.message}}
+ return response.error('V2VConnection', e.message)
with closing(conn):
vms = []
@@ -67,7 +66,7 @@
for disk in params['disks']:
_add_disk_info(conn, disk)
vms.append(params)
- return {'status': doneCode, 'vmList': vms}
+ return response.success(vmList=vms)
def _mem_to_mib(size, unit):
--
To view, visit https://gerrit.ovirt.org/38447
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I678e764a2895e7c34df6852759b1d43baeb687a1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: migration: make stop() update internal status
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: migration: make stop() update internal status
......................................................................
migration: make stop() update internal status
The SourceThread.stop() operation should update
the internal status accordingly in case of success.
Previously, it was the caller that updated the status (!)
adding unneeded coupling.
Change-Id: I0ab50fc789dde969b2fb9ab969241ed4ad12545c
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/40520/1
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 1eaed05..61d5a7b 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -371,6 +371,10 @@
except libvirt.libvirtError:
if not self._preparingMigrationEvt:
raise
+ else:
+ self.status['status']['message'] = \
+ 'Migration process cancelled'
+ return self.status
def exponential_downtime(downtime, steps):
--
To view, visit https://gerrit.ovirt.org/40520
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ab50fc789dde969b2fb9ab969241ed4ad12545c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: WIP
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: WIP
......................................................................
WIP
Change-Id: I39c2e6e4bca286a513992b7231f1356e8dd871a1
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 47 insertions(+), 37 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/40431/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 45afdfd..eec5ae5 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -551,51 +551,30 @@
return doms
-class HostStatsThread(threading.Thread):
- """
- A thread that periodically samples host statistics.
- """
- _CONNLOG = logging.getLogger('connectivity')
+class HostSampler(object):
+ _connlog = logging.getlogger('connectivity')
def __init__(self, log):
- self.startTime = time.time()
-
- threading.Thread.__init__(self)
- self.daemon = True
self._log = log
- self._stopEvent = threading.Event()
+ self._start_time = time.time()
self._samples = SampleWindow(size=5)
self._pid = os.getpid()
self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1)
- self._sampleInterval = \
- config.getint('vars', 'host_sample_stats_interval')
+ self._sample_interval = config.getint(
+ 'vars', 'host_sample_stats_interval')
- def stop(self):
- self._stopEvent.set()
-
- def run(self):
- try:
- # wait a bit before starting to sample
- time.sleep(self._sampleInterval)
- while not self._stopEvent.isSet():
- try:
- sample = HostSample(self._pid)
- self._samples.append(sample)
- prev, last = self._samples.last_pair()
- if prev is None:
- self._CONNLOG.debug('%s', sample.to_connlog())
- else:
- diff = sample.connlog_diff(prev)
- if diff:
- self._CONNLOG.debug('%s', diff)
- except TimeoutError:
- self._log.exception("Timeout while sampling stats")
- self._stopEvent.wait(self._sampleInterval)
- except:
- if not self._stopEvent.isSet():
- self._log.exception("Error while sampling stats")
+ def __call__(self):
+ sample = HostSample(self._pid)
+ self._samples.append(sample)
+ prev, last = self._samples.last_pair()
+ if prev is None:
+ self._CONNLOG.debug('%s', sample.to_connlog())
+ else:
+ diff = sample.connlog_diff(prev)
+ if diff:
+ self._CONNLOG.debug('%s', diff)
@utils.memoized
def _boot_time(self):
@@ -625,7 +604,7 @@
hs0, hs1, _ = self._samples.stats()
interval = hs1.timestamp - hs0.timestamp
- stats.update(self._get_interfaces_stats(hs0, hs1, interval))
+ stats.update(_get_interfaces_stats(hs0, hs1, interval))
jiffies = (hs1.pidcpu.user - hs0.pidcpu.user) % (2 ** 32)
stats['cpuUserVdsmd'] = jiffies / interval
@@ -655,6 +634,37 @@
return stats
+
+class HostStatsThread(threading.Thread):
+ """
+ A thread that periodically samples host statistics.
+ """
+ _connlog = logging.getlogger('connectivity')
+
+ def __init__(self, log):
+ threading.Thread.__init__(self)
+ self._sampler = HostSampler(log)
+ self.daemon = True
+ self._stopEvent = threading.Event()
+
+ def stop(self):
+ self._stopEvent.set()
+
+ def run(self):
+ try:
+ # wait a bit before starting to sample
+ time.sleep(self._sampleInterval)
+ while not self._stopEvent.isSet():
+ try:
+ self._sampler()
+ except TimeoutError:
+ self._log.exception("Timeout while sampling stats")
+ self._stopEvent.wait(self._sampleInterval)
+ except:
+ if not self._stopEvent.isSet():
+ self._log.exception("Error while sampling stats")
+
+
def _get_cpu_core_stats(hs0, hs1):
"""
:returns: a dict that with the following formats:
--
To view, visit https://gerrit.ovirt.org/40431
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I39c2e6e4bca286a513992b7231f1356e8dd871a1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: WIP: rename stats cache to vm stats cache
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: WIP: rename stats cache to vm stats cache
......................................................................
WIP: rename stats cache to vm stats cache
Future patch want to modernize HostStats* and
port it to periodic Operations infrastructure.
To make room for this change and reduce
ambiguity, re-introduced the ubiquitous
vm* prefix.
No changes besides naming.
Change-Id: If38c49f686dfc2bc0994d444ff24c7736f2e951b
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/samplingTests.py
M tests/vmfakelib.py
M vdsm/virt/periodic.py
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
5 files changed, 16 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/40371/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py
index 2624dd7..1f2a65c 100644
--- a/tests/samplingTests.py
+++ b/tests/samplingTests.py
@@ -250,13 +250,13 @@
self.assertTrue(self._sampleCount >= self.STOP_SAMPLE)
-class StatsCacheTests(TestCaseBase):
+class VmStatsCacheTests(TestCaseBase):
FAKE_CLOCK_STEP = 1
def setUp(self):
self.clock = 0
- self.cache = sampling.StatsCache(clock=self.fake_monotonic_time)
+ self.cache = sampling.VmStatsCache(clock=self.fake_monotonic_time)
def fake_monotonic_time(self):
self.clock += self.FAKE_CLOCK_STEP
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py
index d8ce6ce..544eb5a 100644
--- a/tests/vmfakelib.py
+++ b/tests/vmfakelib.py
@@ -201,7 +201,7 @@
fake._guestCpuRunning = runCpu
if status is not None:
fake._lastStatus = status
- sampling.stats_cache.add(fake.id)
+ sampling.vm_stats_cache.add(fake.id)
yield fake
diff --git a/vdsm/virt/periodic.py b/vdsm/virt/periodic.py
index a3f8cc6..00615c3 100644
--- a/vdsm/virt/periodic.py
+++ b/vdsm/virt/periodic.py
@@ -94,7 +94,7 @@
sampling.VMBulkSampler(
libvirtconnection.get(cif),
cif.getVMs,
- sampling.stats_cache),
+ sampling.vm_stats_cache),
config.getint('vars', 'vm_sample_interval')),
# we do this only until we get high water mark notifications
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 6804406..89f109b 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -375,7 +375,7 @@
EMPTY_SAMPLE = StatsSample(None, None, None, None)
-class StatsCache(object):
+class VmStatsCache(object):
"""
Cache for bulk stats samples.
Provide facilities to retrieve per-vm samples, and the glue code to deal
@@ -391,7 +391,7 @@
VDSM has countermeasures for those cases. Stuck threads are replaced,
thanks to Executor. But still, before to be destroyed, a replaced
- thread can mistakenly try to add a sample to a StatsCache.
+ thread can mistakenly try to add a sample to a VmStatsCache.
Because of worker thread replacement, that sample from stuck thread
can be stale.
@@ -402,7 +402,7 @@
between a well behaving call and an unblocked stuck call.
"""
- _log = logging.getLogger("sampling.StatsCache")
+ _log = logging.getLogger("sampling.VmStatsCache")
def __init__(self, clock=utils.monotonic_time):
self._clock = clock
@@ -478,7 +478,7 @@
self._vm_last_timestamp[vmid] = monotonic_ts
-stats_cache = StatsCache()
+vm_stats_cache = VmStatsCache()
# this value can be tricky to tune.
@@ -492,18 +492,18 @@
class VMBulkSampler(object):
- def __init__(self, conn, get_vms, stats_cache,
+ def __init__(self, conn, get_vms, vm_stats_cache,
stats_flags=0, timeout=_TIMEOUT):
self._conn = conn
self._get_vms = get_vms
- self._stats_cache = stats_cache
+ self._vm_stats_cache = vm_stats_cache
self._stats_flags = stats_flags
self._skip_doms = ExpiringCache(timeout)
self._sampling = Stage()
self._log = logging.getLogger("sampling.VMBulkSampler")
def __call__(self):
- timestamp = self._stats_cache.clock()
+ timestamp = self._vm_stats_cache.clock()
# we are deep in the hot path. bool(ExpiringCache)
# *is* costly so we should avoid it if we can.
fast_path = (self._sampling.empty and not self._skip_doms)
@@ -514,7 +514,7 @@
# If everything's ok, we can skip all the costly checks.
bulk_stats = self._conn.getAllDomainStats(
self._stats_flags)
- self._stats_cache.put(_translate(bulk_stats), timestamp)
+ self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
else:
# A previous call got stuck, or not every domain
# has properly recovered. Thus we must whitelist domains.
@@ -523,7 +523,7 @@
if doms:
bulk_stats = self._conn.domainListGetStats(
doms, self._stats_flags)
- self._stats_cache.put(_translate(bulk_stats), timestamp)
+ self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
def _get_responsive_doms(self):
vms = self._get_vms()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index dcc215b..2b7e3eb 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1308,7 +1308,7 @@
decStats = {}
try:
- vm_sample = sampling.stats_cache.get(self.id)
+ vm_sample = sampling.vm_stats_cache.get(self.id)
decStats = vmstats.produce(self,
vm_sample.first_value,
vm_sample.last_value,
@@ -1675,7 +1675,7 @@
nic.name)
self._guestEventTime = self._startTime
- sampling.stats_cache.add(self.id)
+ sampling.vm_stats_cache.add(self.id)
try:
self.guestAgent.connect()
except Exception:
@@ -3454,7 +3454,7 @@
self.lastStatus = vmstatus.POWERING_DOWN
# Terminate the VM's creation thread.
self._incomingMigrationFinished.set()
- sampling.stats_cache.remove(self.id)
+ sampling.vm_stats_cache.remove(self.id)
self.guestAgent.stop()
if self._dom:
result = self._destroyVmGraceful()
--
To view, visit https://gerrit.ovirt.org/40371
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If38c49f686dfc2bc0994d444ff24c7736f2e951b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: sampling: introduce expensive checks
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: sampling: introduce expensive checks
......................................................................
sampling: introduce expensive checks
To improve troubleshooting, introduce more
expensive sanity checks, with a default-off
tunable to enable them.
These sanity checks will make no attempt to recover,
will only add logs to report possible issues.
Change-Id: I7b3bb707dd60de194eedfc2e3de1efbf05574ff7
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/vdsm/config.py.in
M vdsm/virt/sampling.py
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/40391/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index e213839..b60e836 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -325,6 +325,10 @@
('periodic_task_per_worker', '100',
'Max number of tasks which can be queued on workers.'
' This is for internal usage and may change without warning'),
+
+ ('expensive_checks', 'false',
+ 'Perform additional sanity checks and does additional debug logs'
+ 'which are expensive performance-wise'),
]),
# Section: [devel]
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index b0628a4..3c1510f 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -504,6 +504,7 @@
self._skip_doms = ExpiringCache(timeout)
self._sampling = Stage()
self._log = logging.getLogger("sampling.VMBulkSampler")
+ self._extra_check = config.getboolean('sampling', 'expensive_checks')
def __call__(self):
timestamp = self._vm_stats_cache.clock()
@@ -517,7 +518,6 @@
# If everything's ok, we can skip all the costly checks.
bulk_stats = self._conn.getAllDomainStats(
self._stats_flags)
- self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
else:
# A previous call got stuck, or not every domain
# has properly recovered. Thus we must whitelist domains.
@@ -526,7 +526,12 @@
if doms:
bulk_stats = self._conn.domainListGetStats(
doms, self._stats_flags)
- self._vm_stats_cache.put(_translate(bulk_stats), timestamp)
+ else:
+ bulk_stats = []
+
+ stats = _translate(bulk_stats)
+ self._vm_stats_cache.put(stats, timestamp)
+ self._log_missing_vms(self._get_vms(), stats, timestamp)
def _get_responsive_doms(self):
vms = self._get_vms()
@@ -541,6 +546,14 @@
doms.append(vm_obj._dom._dom)
return doms
+ def _log_missing_vms(self, expected_vms, retrieved_stats, timestamp):
+ # costly check. add another layer of check before to embark on it.
+ if self._extra_check:
+ for vm_id in expected_vms:
+ if vm_id not in retrieved_stats:
+ self._log.debug('VM %s not updated in bulk at %f',
+ vm_id, timestamp)
+
class HostStatsThread(threading.Thread):
"""
--
To view, visit https://gerrit.ovirt.org/40391
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b3bb707dd60de194eedfc2e3de1efbf05574ff7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: sampling: simplify flows
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: sampling: simplify flows
......................................................................
sampling: simplify flows
Executor already has a fallback net for uncaught exceptions.
Failures in SampleVMs.__call__ are expected to be sporadic,
and in these cases we actually want to be as much noisy as we
can.
This patch removes redundant code in SampleVMs.__call__,
to make the flow less convoluted.
Change-Id: Ide103d0ed9a694cc9ddd9b0b382e2d81a1bd48c0
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 17 insertions(+), 21 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/40326/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 09ce2b3..5a205f7 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -507,27 +507,23 @@
# we are deep in the hot path. bool(ExpiringCache)
# *is* costly so we should avoid it if we can.
fast_path = (self._sampling.empty and not self._skip_doms)
- try:
- with self._sampling.performer():
- if fast_path:
- # This is expected to be the common case.
- # If everything's ok, we can skip all the costly checks.
- bulk_stats = self._conn.getAllDomainStats(
- self._stats_flags)
- else:
- # A previous call got stuck, or not every domain
- # has properly recovered. Thus we must whitelist domains.
- doms = self._get_responsive_doms()
- self._log.debug('sampling %d domains', len(doms))
- if doms:
- bulk_stats = self._conn.domainListGetStats(
- doms, self._stats_flags)
- else:
- bulk_stats = []
- except Exception:
- self._log.exception("vm sampling failed")
- else:
- self._stats_cache.put(_translate(bulk_stats), timestamp)
+
+ with self._sampling.performer():
+ if fast_path:
+ # This is expected to be the common case.
+ # If everything's ok, we can skip all the costly checks.
+ bulk_stats = self._conn.getAllDomainStats(
+ self._stats_flags)
+ self._stats_cache.put(_translate(bulk_stats), timestamp)
+ else:
+ # A previous call got stuck, or not every domain
+ # has properly recovered. Thus we must whitelist domains.
+ doms = self._get_responsive_doms()
+ self._log.debug('sampling %d domains', len(doms))
+ if doms:
+ bulk_stats = self._conn.domainListGetStats(
+ doms, self._stats_flags)
+ self._stats_cache.put(_translate(bulk_stats), timestamp)
def _get_responsive_doms(self):
vms = self._get_vms()
--
To view, visit https://gerrit.ovirt.org/40326
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide103d0ed9a694cc9ddd9b0b382e2d81a1bd48c0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: hsm: prepareForShutdown - operations order
by laravot@redhat.com
Liron Aravot has uploaded a new change for review.
Change subject: hsm: prepareForShutdown - operations order
......................................................................
hsm: prepareForShutdown - operations order
Currently cleanupMasterMount() is executed before
taskMgr.prepareForShutdown() and before the domain monitor is stopped,
that causes to errors during the tasks abortion (becasue of failure to
access the path) and to erros when stopping the domain monitoring
thread on that domain.
The solution introduced in that patch is to change the order of the
operations - so that the cleanupMasterMount() will be executed only
after the other operations are executed.
Change-Id: I9edd84317b08a17db80e265053edaf69582c2a51
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1161934
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/36162/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index c8aaf93..8f71d71 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3433,7 +3433,6 @@
# stop spm tasks if spm etc.)
try:
self._connectionMonitor.stopMonitoring()
- sp.StoragePool.cleanupMasterMount()
self.__releaseLocks()
for spUUID in self.pools:
@@ -3454,6 +3453,7 @@
exc_info=True)
self.taskMng.prepareForShutdown()
+ sp.StoragePool.cleanupMasterMount()
except:
pass
--
To view, visit http://gerrit.ovirt.org/36162
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9edd84317b08a17db80e265053edaf69582c2a51
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <laravot(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: vdsm: added functionality to teardownImage when disk has bee...
by cshereme@redhat.com
Candace Sheremeta has uploaded a new change for review.
Change subject: vdsm: added functionality to teardownImage when disk has been deleted
......................................................................
vdsm: added functionality to teardownImage when disk has been deleted
added code to teardownImage in hsm.py so that teardownImage reports
"Volume does not exist" for a previously deleted disk, where it
previously simply reported "OK" - teardownImage now checks to see
if volume exists before attempting to delete it
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1184718
Change-Id: Ia929dfdc78ccaa736033e41a77bce861d5a27769
Signed-off-by: Candace Sheremeta <cshereme(a)redhat.com>
---
M vdsm/storage/hsm.py
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/38241/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 8c75277..45e6634 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3271,6 +3271,13 @@
vars.task.getSharedLock(STORAGE, sdUUID)
dom = sdCache.produce(sdUUID)
+ allVols = dom.getAllVolumes()
+ # Filter volumes related to this image
+ imgVolumes = sd.getVolsOfImage(allVols, imgUUID).keys()
+
+ if volUUID not in imgVolumes:
+ raise se.VolumeDoesNotExist(volUUID)
+
dom.deactivateImage(imgUUID)
@public
--
To view, visit https://gerrit.ovirt.org/38241
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia929dfdc78ccaa736033e41a77bce861d5a27769
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Candace Sheremeta <cshereme(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: janitorial: vm: remove _reportError
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: janitorial: vm: remove _reportError
......................................................................
janitorial: vm: remove _reportError
Vm._reportError was an early attempt to build what
we have now with response.error().
With the new code in place there is no more reason
to use it, so this patch removes it.
Change-Id: Ie23167c0289bdb0326dcfe48903cd1bae905e9b5
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 15 insertions(+), 27 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/38269/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index cd392c7..4be63ce 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -42,7 +42,7 @@
from vdsm import utils
from vdsm.compat import pickle
from vdsm.config import config
-from vdsm.define import ERROR, NORMAL, doneCode, errCode
+from vdsm.define import ERROR, NORMAL, doneCode
from vdsm.netinfo import DUMMY_BRIDGE
from storage import outOfProcess as oop
from storage import sd
@@ -2650,15 +2650,15 @@
if not params:
self.log.error("updateVmPolicy got an empty policy.")
- return self._reportError(key='MissParam',
- msg="updateVmPolicy got an empty policy.")
+ return response.error('MissParam',
+ 'updateVmPolicy got an empty policy.')
#
# Get the current QoS block
metadata_modified = False
qos = self._getVmPolicy()
if qos is None:
- return self._reportError(key='updateVmPolicyErr')
+ return response.error('updateVmPolicyErr')
#
# Process provided properties, remove property after it is processed
@@ -2712,8 +2712,7 @@
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return response.error('noVM')
else:
- return self._reportError(key='updateVmPolicyErr',
- msg=e.message)
+ return response.error('updateVmPolicyErr', e.message)
return {'status': doneCode}
@@ -2771,9 +2770,9 @@
found_device = self._findDeviceByNameOrPath(device_name,
device_path)
if found_device is None:
- return self._reportError(
- key='updateIoTuneErr',
- msg="Device {} not found".format(device_name))
+ return response.error(
+ 'updateIoTuneErr',
+ "Device {} not found".format(device_name))
# Merge the update with current values
dom = found_device.getXML()
@@ -2799,8 +2798,7 @@
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return response.error('noVM')
else:
- return self._reportError(key='updateIoTuneErr',
- msg=e.message)
+ return response.error('updateIoTuneErr', e.message)
# Update both the ioTune arguments and device xml DOM
# so we are still up-to-date
@@ -3956,7 +3954,7 @@
def setBalloonTarget(self, target):
if self._dom is None:
- return self._reportError(key='balloonErr')
+ return response.error('balloonErr')
try:
target = int(target)
self._dom.setMemory(target)
@@ -3980,8 +3978,8 @@
try:
self._dom.setSchedulerParameters({'vcpu_quota': int(quota)})
except ValueError:
- return self._reportError(key='cpuTuneErr',
- msg='an integer is required for period')
+ return response.error('cpuTuneErr',
+ 'an integer is required for period')
except libvirt.libvirtError as e:
return self._reportException(key='cpuTuneErr', msg=e.message)
return {'status': doneCode}
@@ -3990,21 +3988,11 @@
try:
self._dom.setSchedulerParameters({'vcpu_period': int(period)})
except ValueError:
- return self._reportError(key='cpuTuneErr',
- msg='an integer is required for period')
+ return response.error('cpuTuneErr',
+ 'an integer is required for period')
except libvirt.libvirtError as e:
return self._reportException(key='cpuTuneErr', msg=e.message)
return {'status': doneCode}
-
- def _reportError(self, key, msg=None):
- """
- Produce an error status.
- """
- if msg is None:
- error = errCode[key]
- else:
- error = response.error(key, msg)
- return error
def _reportException(self, key, msg=None):
"""
@@ -4012,7 +4000,7 @@
This method should be called only within exception-handling context.
"""
self.log.exception("Operation failed")
- return self._reportError(key, msg)
+ return response.error(key, msg)
def _getUnderlyingDeviceAddress(self, devXml):
"""
--
To view, visit https://gerrit.ovirt.org/38269
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie23167c0289bdb0326dcfe48903cd1bae905e9b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: virt: add test to allow custom XML parsing test
by Martin Polednik
Martin Polednik has uploaded a new change for review.
Change subject: virt: add test to allow custom XML parsing test
......................................................................
virt: add test to allow custom XML parsing test
Tests should run against explicit device specification, but it may be
useful to have a means of simply testing that parse of given XML
succeeds. This patch implements such functionality, allowing user to
supply XML in tests/devices/data and modify
tests/parsing/custom_vm_tests.py to see if the parsing conforms general
device specification.
Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85
Signed-off-by: Martin Polednik <mpolednik(a)redhat.com>
---
M tests/Makefile.am
M tests/devices/data/Makefile.am
A tests/devices/data/testSriovVm.xml
M tests/devices/parsing/Makefile.am
A tests/devices/parsing/custom_vm_tests.py
5 files changed, 181 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/39909/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b8a8964..2bc9018 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -27,6 +27,7 @@
device_modules = \
devices/parsing/complex_vm_tests.py \
+ devices/parsing/custom_vm_tests.py \
$(NULL)
test_modules = \
diff --git a/tests/devices/data/Makefile.am b/tests/devices/data/Makefile.am
index 0ead0e2..6a6288c 100644
--- a/tests/devices/data/Makefile.am
+++ b/tests/devices/data/Makefile.am
@@ -22,4 +22,5 @@
dist_vdsmdevdatatests_DATA = \
testComplexVm.xml \
+ testSriovVm.xml \
$(NULL)
diff --git a/tests/devices/data/testSriovVm.xml b/tests/devices/data/testSriovVm.xml
new file mode 100644
index 0000000..2980c7f
--- /dev/null
+++ b/tests/devices/data/testSriovVm.xml
@@ -0,0 +1,144 @@
+<domain type='kvm' id='2'>
+ <name>vm1_Copy</name>
+ <uuid>78144ebf-7894-456e-997f-9fc96083341e</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static' current='1'>16</vcpu>
+ <cputune>
+ <shares>1020</shares>
+ <period>12500</period>
+ <quota>100000</quota>
+ </cputune>
+ <resource>
+ <partition>/machine</partition>
+ </resource>
+ <sysinfo type='smbios'>
+ <system>
+ <entry name='manufacturer'>oVirt</entry>
+ <entry name='product'>oVirt Node</entry>
+ <entry name='version'>7.1-0.1.el7</entry>
+ <entry name='serial'>38373035-3536-4247-3830-333334344139</entry>
+ <entry name='uuid'>78144ebf-7894-456e-997f-9fc96083341e</entry>
+ </system>
+ </sysinfo>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
+ <smbios mode='sysinfo'/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <cpu mode='custom' match='exact'>
+ <model fallback='allow'>Conroe</model>
+ <topology sockets='16' cores='1' threads='1'/>
+ </cpu>
+ <clock offset='variable' adjustment='0' basis='utc'>
+ <timer name='rtc' tickpolicy='catchup'/>
+ <timer name='pit' tickpolicy='delay'/>
+ <timer name='hpet' present='no'/>
+ </clock>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/qemu-kvm</emulator>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source startupPolicy='optional'/>
+ <backingStore/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <serial></serial>
+ <alias name='ide0-1-0'/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='disk' snapshot='no'>
+ <driver name='qemu' type='raw' cache='none' error_policy='stop' io='threads'/>
+ <source file='/rhev/data-center/bd4ba8d0-024e-412b-aa6e-b22a1654f53e/9a8980dc-b533-4085-884e-daa9f3753ce7/images/369a5d94-05bc-41c0-84c5-ed3b1b8d2d89/79d06c74-8a95-4e4b-afba-8d09975c5f8d'>
+ <seclabel model='selinux' labelskip='yes'/>
+ </source>
+ <backingStore/>
+ <target dev='vda' bus='virtio'/>
+ <serial>369a5d94-05bc-41c0-84c5-ed3b1b8d2d89</serial>
+ <boot order='1'/>
+ <alias name='virtio-disk0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+ </disk>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <alias name='scsi0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </controller>
+ <controller type='virtio-serial' index='0' ports='16'>
+ <alias name='virtio-serial0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+ </controller>
+ <controller type='usb' index='0'>
+ <alias name='usb0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'>
+ <alias name='pci.0'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <alias name='ide0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <interface type='hostdev'>
+ <mac address='00:1a:4a:16:01:53'/>
+ <driver name='vfio'/>
+ <source>
+ <address type='pci' domain='0x0000' bus='0x02' slot='0x10' function='0x0'/>
+ </source>
+ <alias name='hostdev0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </interface>
+ <interface type='bridge'>
+ <mac address='00:1a:4a:16:01:54'/>
+ <source bridge='ovirtmgmt'/>
+ <bandwidth>
+ </bandwidth>
+ <target dev='vnet0'/>
+ <model type='virtio'/>
+ <filterref filter='vdsm-no-mac-spoofing'/>
+ <link state='down'/>
+ <alias name='net1'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <channel type='unix'>
+ <source mode='bind' path='/var/lib/libvirt/qemu/channels/78144ebf-7894-456e-997f-9fc96083341e.com.redhat.rhevm.vdsm'/>
+ <target type='virtio' name='com.redhat.rhevm.vdsm'/>
+ <alias name='channel0'/>
+ <address type='virtio-serial' controller='0' bus='0' port='1'/>
+ </channel>
+ <channel type='unix'>
+ <source mode='bind' path='/var/lib/libvirt/qemu/channels/78144ebf-7894-456e-997f-9fc96083341e.org.qemu.guest_agent.0'/>
+ <target type='virtio' name='org.qemu.guest_agent.0'/>
+ <alias name='channel1'/>
+ <address type='virtio-serial' controller='0' bus='0' port='2'/>
+ </channel>
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <alias name='channel2'/>
+ <address type='virtio-serial' controller='0' bus='0' port='3'/>
+ </channel>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='spice' port='5900' tlsPort='5901' autoport='yes' listen='0' passwdValidTo='1970-01-01T00:00:01'>
+ <listen type='address' address='0'/>
+ </graphics>
+ <video>
+ <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
+ <alias name='video0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <alias name='balloon0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
+ </memballoon>
+ </devices>
+ <seclabel type='dynamic' model='selinux' relabel='yes'>
+ <label>system_u:system_r:svirt_t:s0:c799,c978</label>
+ <imagelabel>system_u:object_r:svirt_image_t:s0:c799,c978</imagelabel>
+ </seclabel>
+</domain>
+
diff --git a/tests/devices/parsing/Makefile.am b/tests/devices/parsing/Makefile.am
index 978e9bd..26edbd4 100644
--- a/tests/devices/parsing/Makefile.am
+++ b/tests/devices/parsing/Makefile.am
@@ -23,4 +23,5 @@
dist_vdsmdevparsingtests_PYTHON = \
__init__.py \
complex_vm_tests.py \
+ custom_vm_tests.py \
$(NULL)
diff --git a/tests/devices/parsing/custom_vm_tests.py b/tests/devices/parsing/custom_vm_tests.py
new file mode 100644
index 0000000..eca8db9
--- /dev/null
+++ b/tests/devices/parsing/custom_vm_tests.py
@@ -0,0 +1,34 @@
+import os
+
+from testlib import permutations, expandPermutations
+from testlib import XMLTestCase
+
+from virt import domain_descriptor
+import vmfakelib as fake
+
+import verify
+
+
+@expandPermutations
+class TestVmDevicesXmlParsing(XMLTestCase, verify.DeviceMixin):
+
+ @permutations([['testComplexVm.xml'], ['testSriovVm.xml']])
+ def test_custom_vm(self, domain_xml):
+ params = {'name': 'complexVm', 'displaySecurePort': '-1',
+ 'memSize': '256', 'displayPort': '-1', 'display': 'qxl'}
+
+ devices = [{'device': 'spice', 'type': 'graphics'}]
+
+ test_path = os.path.realpath(__file__)
+ dir_name = os.path.split(test_path)[0]
+ api_path = os.path.join(
+ dir_name, '..', 'data', domain_xml)
+
+ domain = None
+ with open(api_path, 'r') as domxml:
+ domain = domxml.read()
+
+ with fake.VM(params=params, devices=devices) as vm:
+ vm._domain = domain_descriptor.DomainDescriptor(domain)
+ vm._getUnderlyingVmDevicesInfo()
+ self.verifyDevicesConf(vm.conf['devices'])
--
To view, visit https://gerrit.ovirt.org/39909
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bb24e2854e6f7b93c5108eca8b6f79f17353e85
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik(a)redhat.com>
7 years, 11 months