Change in vdsm[master]: [WIP] Start moving proc parsing to it's own module
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Start moving proc parsing to it's own module
......................................................................
[WIP] Start moving proc parsing to it's own module
Change-Id: I7ba84c7ece95bdef7448a7c7af277e7f58695401
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm.spec.in
M vdsm/API.py
M vdsm/Makefile.am
M vdsm/caps.py
A vdsm/procfs.py
M vdsm/utils.py
M vdsm/vm.py
7 files changed, 53 insertions(+), 40 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/7513/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index bd01c2a..1f01961 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -573,6 +573,7 @@
%{_datadir}/%{vdsm_name}/supervdsmServer.py*
%{_datadir}/%{vdsm_name}/vmChannels.py*
%{_datadir}/%{vdsm_name}/vmContainer.py*
+%{_datadir}/%{vdsm_name}/procfs.py*
%{_datadir}/%{vdsm_name}/tc.py*
%{_datadir}/%{vdsm_name}/vdsm
%{_datadir}/%{vdsm_name}/vdsm-restore-net-config
diff --git a/vdsm/API.py b/vdsm/API.py
index 720c3b9..aab69cd 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -37,6 +37,7 @@
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
+import procfs
import supervdsm
@@ -864,7 +865,7 @@
"""
def _readSwapTotalFree():
- meminfo = utils.readMemInfo()
+ meminfo = procfs.meminfo()
return meminfo['SwapTotal'] / 1024, meminfo['SwapFree'] / 1024
stats = {}
@@ -1111,17 +1112,16 @@
memCommitted = self._memCommitted()
resident = 0
for v in self._cif.vmContainer.getVMs():
- if v.conf['pid'] == '0':
- continue
try:
- statmfile = file('/proc/' + v.conf['pid'] + '/statm')
- resident += int(statmfile.read().split()[1])
+ resident += v.statm().resident
except:
pass
+
resident *= PAGE_SIZE_BYTES
- meminfo = utils.readMemInfo()
- freeOrCached = (meminfo['MemFree'] +
- meminfo['Cached'] + meminfo['Buffers']) * Kbytes
+
+ meminfo = procfs.meminfo()
+ freeOrCached = (meminfo['MemFree'] + meminfo['Cached'] +
+ meminfo['Buffers']) * Kbytes
return freeOrCached + resident - memCommitted - \
config.getint('vars', 'host_mem_reserve') * Mbytes
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index 574d762..1a3ac43 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -47,6 +47,7 @@
momIF.py \
neterrors.py \
parted_utils.py \
+ procfs.py \
pthread.py \
supervdsm.py \
supervdsmServer.py \
diff --git a/vdsm/caps.py b/vdsm/caps.py
index f1641ff..39fc837 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -41,6 +41,7 @@
from vdsm import utils
from vdsm import constants
import storage.hba
+import procfs
# For debian systems we can use python-apt if available
try:
@@ -271,7 +272,7 @@
caps['HBAInventory'] = storage.hba.HBAInventory()
caps['vmTypes'] = ['kvm']
- caps['memSize'] = str(utils.readMemInfo()['MemTotal'] / 1024)
+ caps['memSize'] = str(procfs.meminfo()['MemTotal'] / 1024)
caps['reservedMem'] = str(
config.getint('vars', 'host_mem_reserve') +
config.getint('vars', 'extra_mem_reserve'))
diff --git a/vdsm/procfs.py b/vdsm/procfs.py
new file mode 100644
index 0000000..29fc973
--- /dev/null
+++ b/vdsm/procfs.py
@@ -0,0 +1,31 @@
+from collections import namedtuple
+
+buffsize = 4096
+
+MemStat = namedtuple("MemStat",
+ "size, resident, share, text, UNUSED1, data, UNUSED2")
+
+
+def statm(pid):
+ """
+ Parses statm for a pid. Note all results are in pages.
+ """
+ with open("/proc/%d/statm" % pid, "rb") as f:
+ return MemStat(*(int(val) for val in f.read().split()))
+
+
+def meminfo():
+ """
+ Parse ``/proc/meminfo`` and return its content as a dictionary.
+
+ note.
+ All values are in KB
+ """
+ meminfo = {}
+ with open("/proc/meminfo", "rb") as f:
+ f.seek(0)
+ lines = f.readlines()
+ for var, val in (l.split()[0:2] for l in lines):
+ meminfo[var[:-1]] = int(val)
+
+ return meminfo
diff --git a/vdsm/utils.py b/vdsm/utils.py
index 5e2d4e5..048a528 100644
--- a/vdsm/utils.py
+++ b/vdsm/utils.py
@@ -19,7 +19,8 @@
#
"""
-A module containing miscellaneous functions and classes that are user plentifuly around vdsm.
+A module containing miscellaneous functions and classes that are user
+plentifuly around vdsm.
.. attribute:: utils.symbolerror
@@ -28,7 +29,8 @@
from SimpleXMLRPCServer import SimpleXMLRPCServer
import SocketServer
import threading
-import os, time
+import os
+import time
import logging
import errno
import subprocess
@@ -42,6 +44,7 @@
import constants
from config import config
import netinfo
+import procfs
_THP_STATE_PATH = '/sys/kernel/mm/transparent_hugepage/enabled'
if not os.path.exists(_THP_STATE_PATH):
@@ -63,34 +66,6 @@
os.unlink(fileToRemove)
except:
pass
-
-def readMemInfo():
- """
- Parse ``/proc/meminfo`` and return its content as a dictionary.
-
- For a reason unknown to me, ``/proc/meminfo`` is is sometime
- empty when opened. If that happens, the function retries to open it
- 3 times.
-
- :returns: a dictionary representation of ``/proc/meminfo``
- """
- # FIXME the root cause for these retries should be found and fixed
- tries = 3
- meminfo = {}
- while True:
- tries -= 1
- try:
- lines = []
- lines = file('/proc/meminfo').readlines()
- for line in lines:
- var, val = line.split()[0:2]
- meminfo[var[:-1]] = int(val)
- return meminfo
- except:
- logging.warning(lines, exc_info=True)
- if tries <= 0:
- raise
- time.sleep(0.1)
#Threaded version of SimpleXMLRPCServer
class SimpleThreadedXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
@@ -225,7 +200,7 @@
"""
BaseSample.__init__(self, pid, ifids)
self.totcpu = TotalCpuSample()
- meminfo = readMemInfo()
+ meminfo = procfs.meminfo()
freeOrCached = (meminfo['MemFree'] +
meminfo['Cached'] + meminfo['Buffers'])
self.memUsed = 100 - int(100.0 * (freeOrCached) / meminfo['MemTotal'])
diff --git a/vdsm/vm.py b/vdsm/vm.py
index c1a22b0..bd436e0 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -36,6 +36,7 @@
import libvirt
from vdsm import vdscli
import caps
+import procfs
DEFAULT_BRIDGE = config.get("vars", "default_bridge")
@@ -693,6 +694,9 @@
load = len(self.cif.vmContainer.getVMs())
return base * (doubler + load) / doubler
+ def statm(self):
+ return procfs.statm(int(self.conf['pid']))
+
def saveState(self):
if self.destroyed:
return
--
To view, visit http://gerrit.ovirt.org/7513
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ba84c7ece95bdef7448a7c7af277e7f58695401
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: Refactor prepareVolumePath
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Refactor prepareVolumePath
......................................................................
Refactor prepareVolumePath
Change-Id: I57bb8684fd11a47843a158d13fcc2815147fa7ef
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
M vdsm/clientIF.py
M vdsm/libvirtvm.py
M vdsm/storage/devicemapper.py
M vdsm/vm.py
5 files changed, 93 insertions(+), 63 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/7755/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 720c3b9..c324d79 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -173,8 +173,7 @@
# NOTE: pickled params override command-line params. this
# might cause problems if an upgrade took place since the
# parmas were stored.
- fname = self._cif.prepareVolumePath(paramFilespec)
- try:
+ with self._cif.preparedDrive(paramFilespec) as fname:
with file(fname) as f:
pickledMachineParams = pickle.load(f)
@@ -183,8 +182,6 @@
+ str(pickledMachineParams))
self.log.debug('former conf ' + str(vmParams))
vmParams.update(pickledMachineParams)
- finally:
- self._cif.teardownVolumePath(paramFilespec)
except:
self.log.error("Error restoring VM parameters",
exc_info=True)
@@ -299,9 +296,15 @@
:param hiberVolHandle: opaque string, indicating the location of
hibernation images.
"""
- params = {'vmId': self._UUID, 'mode': 'file',
- 'hiberVolHandle': hibernationVolHandle}
- response = self.migrate(params)
+ v = self._getVmObject()
+ if v is None:
+ return errCode['noVM']
+
+ try:
+ response = self.hibernate(hibernationVolHandle)
+ except vm.WrongStateError:
+ response = errCode['noVM']
+
if not response['status']['code']:
response['status']['message'] = 'Hibernation process starting'
return response
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 55a7fc9..0446eb2 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -25,6 +25,7 @@
from xml.dom import minidom
import uuid
import errno
+from contextlib import contextmanager
from storage.dispatcher import Dispatcher
from storage.hsm import HSM
@@ -44,6 +45,7 @@
import blkid
import supervdsm
import vmContainer
+from storage import devicemapper
try:
import gluster.api as gapi
_glusterEnabled = True
@@ -239,50 +241,74 @@
self.log.info('Error finding path for device', exc_info=True)
raise vm.VolumeError(uuid)
+ def _preparePoolImage(self, drive):
+ res = self.irs.prepareImage(
+ drive['domainID'], drive['poolID'],
+ drive['imageID'], drive['volumeID'])
+
+ if res['status']['code']:
+ raise vm.VolumeError(drive)
+
+ drive['volumeChain'] = res['chain']
+ return res['path']
+
+ def _prepareDmDevice(self, drive, vmId):
+ volPath = devicemapper.getDevicePathByGuid(drive["GUID"])
+
+ if not os.path.exists(volPath):
+ raise vm.VolumeError(drive)
+
+ res = self.irs.appropriateDevice(drive["GUID"], vmId)
+ if res['status']['code']:
+ raise vm.VolumeError(drive)
+
+ return volPath
+
+ def _prepareScsiDevice(self, drive):
+ return self._getUUIDSpecPath(drive["UUID"])
+
+ def _prepareVmPayload(self, drive, vmId):
+ '''
+ vmPayload is a key in specParams
+ 'vmPayload': {'file': {'filename': 'content'}}
+ '''
+ for key, files in drive['specParams']['vmPayload'].iteritems():
+ if key == 'file':
+ svdsm = supervdsm.getProxy()
+ if drive['device'] == 'cdrom':
+ return svdsm.mkIsoFs(vmId, files)
+ elif drive['device'] == 'floppy':
+ return svdsm.mkFloppyFs(vmId, files)
+
+ raise vm.VolumeError(drive)
+
+ def _preparePath(self, drive):
+ return drive['path']
+
+ @contextmanager
+ def perparedDrive(self, drive, vmId=None):
+ path = self.prepareVolumePath(drive, vmId)
+ try:
+ yield path
+ finally:
+ self.teardownVolumePath(drive, vmId)
+
def prepareVolumePath(self, drive, vmId=None):
if type(drive) is dict:
- # PDIV drive format
if drive['device'] == 'disk' and vm.isVdsmImage(drive):
- res = self.irs.prepareImage(
- drive['domainID'], drive['poolID'],
- drive['imageID'], drive['volumeID'])
+ volPath = self._preparePoolImage(drive)
- if res['status']['code']:
- raise vm.VolumeError(drive)
-
- volPath = res['path']
- drive['volumeChain'] = res['chain']
-
- # GUID drive format
elif "GUID" in drive:
- volPath = os.path.join("/dev/mapper", drive["GUID"])
+ volPath = self._prepareDmDevice(drive, vmId)
- if not os.path.exists(volPath):
- raise vm.VolumeError(drive)
-
- res = self.irs.appropriateDevice(drive["GUID"], vmId)
- if res['status']['code']:
- raise vm.VolumeError(drive)
-
- # UUID drive format
elif "UUID" in drive:
- volPath = self._getUUIDSpecPath(drive["UUID"])
+ volPath = self._prepareScsiDevice(drive)
elif 'specParams' in drive and 'vmPayload' in drive['specParams']:
- '''
- vmPayload is a key in specParams
- 'vmPayload': {'file': {'filename': 'content'}}
- '''
- for key, files in drive['specParams']['vmPayload'].iteritems():
- if key == 'file':
- if drive['device'] == 'cdrom':
- volPath = supervdsm.getProxy().mkIsoFs(vmId, files)
- elif drive['device'] == 'floppy':
- volPath = \
- supervdsm.getProxy().mkFloppyFs(vmId, files)
+ volPath = self._prepareVmPayload(drive, vmId)
elif "path" in drive:
- volPath = drive['path']
+ volPath = self._preparePath(drive)
else:
raise vm.VolumeError(drive)
@@ -301,17 +327,22 @@
self.log.info("prepared volume path: %s", volPath)
return volPath
- def teardownVolumePath(self, drive):
- res = {'status': doneCode}
- if type(drive) == dict:
- try:
- res = self.irs.teardownImage(drive['domainID'],
- drive['poolID'], drive['imageID'])
- except KeyError:
- #This drive is not a vdsm image (quartet)
- self.log.info("Avoiding tear down drive %s", str(drive))
+ def _teardownPoolImage(self, drive):
+ try:
+ res = self.irs.teardownImage(drive['domainID'],
+ drive['poolID'], drive['imageID'])
+ return res['status']['code']
+ except KeyError:
+ #This drive is not a vdsm image (quartet)
+ self.log.info("Avoiding tear down drive %s", str(drive))
+ return doneCode
- return res['status']['code']
+ def teardownVolumePath(self, drive):
+ if type(drive) == dict:
+ return self._teardownPoolImage(drive)
+ else:
+ # Other types don't require tear down
+ return 0
def createVm(self, vmParams):
try:
@@ -320,6 +351,7 @@
except vmContainer.VmContainerError as e:
if e.errno == errno.EEXIST:
return errCode['exist']
+
return
def waitForShutdown(self, timeout=None):
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index a530228..ea0d017 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -404,11 +404,8 @@
hooks.before_vm_hibernate(self._vm._dom.XMLDesc(0), self._vm.conf)
try:
self._vm._vmStats.pause()
- fname = self._vm.cif.prepareVolumePath(self._dst)
- try:
+ with self._vm.cif.preparedDrive(self._dst) as fname:
self._vm._dom.save(fname)
- finally:
- self._vm.cif.teardownVolumePath(self._dst)
except:
self._vm._vmStats.cont()
raise
@@ -1397,11 +1394,8 @@
elif 'restoreState' in self.conf:
hooks.before_vm_dehibernate(self.conf.pop('_srcDomXML'), self.conf)
- fname = self.cif.prepareVolumePath(self.conf['restoreState'])
- try:
+ with self.cif.preparedDrive(self.conf['restoreState']) as fname:
self._connection.restore(fname)
- finally:
- self.cif.teardownVolumePath(self.conf['restoreState'])
self._dom = NotifyingVirDomain(
self._connection.lookupByUUIDString(self.id),
diff --git a/vdsm/storage/devicemapper.py b/vdsm/storage/devicemapper.py
index a1651e0..388c1cd 100644
--- a/vdsm/storage/devicemapper.py
+++ b/vdsm/storage/devicemapper.py
@@ -46,6 +46,10 @@
(major, minor)))
+def getDevicePathByGuid(devGuid):
+ return DMPATH_FORMAT % devGuid
+
+
def getSysfsPath(devName):
if "/" in devName:
raise ValueError("devName has an illegal format. "
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 3aa9f52..49193d3 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -210,12 +210,9 @@
if ignoreParam in self._machineParams:
del self._machineParams[ignoreParam]
- fname = self._vm.cif.prepareVolumePath(self._dstparams)
- try:
- with file(fname, "w") as f:
+ with self._vm.cif.preparedDrive(self._dstparams) as fname:
+ with file(fname, "wb") as f:
pickle.dump(self._machineParams, f)
- finally:
- self._vm.cif.teardownVolumePath(self._dstparams)
self._vm.setDownStatus(NORMAL, "SaveState succeeded")
self.status = {
--
To view, visit http://gerrit.ovirt.org/7755
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I57bb8684fd11a47843a158d13fcc2815147fa7ef
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: Remove unnecesary preparePaths.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Remove unnecesary preparePaths.
......................................................................
Remove unnecesary preparePaths.
Recovering running VM's therefore paths are already prepared.
Prepare paths is not locking the volumes anymore (Federico).
Change-Id: I35890d36227633ca147387d670c152b9be357e50
---
M vdsm/clientIF.py
1 file changed, 0 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/786/1
--
To view, visit http://gerrit.ovirt.org/786
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I35890d36227633ca147387d670c152b9be357e50
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: Avoid template deactivation and lock.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: Avoid template deactivation and lock.
......................................................................
Avoid template deactivation and lock.
Change-Id: Ieedf863ac967f34405f038201bac324c52fbbe89
---
M vdsm/storage/blockVolume.py
M vdsm/storage/volume.py
2 files changed, 39 insertions(+), 18 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/63/863/1
--
To view, visit http://gerrit.ovirt.org/863
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieedf863ac967f34405f038201bac324c52fbbe89
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: [WIP] Add the validateImage command to the SPM
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [WIP] Add the validateImage command to the SPM
......................................................................
[WIP] Add the validateImage command to the SPM
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
Change-Id: I095362e7d1eb91045569bd9526a102392e7adbe8
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/storage/hsm.py
M vdsm/storage/image.py
M vdsm/storage/sp.py
M vdsm/storage/volume.py
6 files changed, 60 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/3491/1
--
To view, visit http://gerrit.ovirt.org/3491
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I095362e7d1eb91045569bd9526a102392e7adbe8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: [wip] volume: make volume._share idempotent
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [wip] volume: make volume._share idempotent
......................................................................
[wip] volume: make volume._share idempotent
With this patch it will possible to run the volume._share command
multiple times without harm (idempotent) for the image and for the
running VMs.
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
Change-Id: I237e4a8f094ba04dcd4ef7bff418e03f81162d8d
---
M vdsm/storage/blockVolume.py
M vdsm/storage/fileVolume.py
M vdsm/storage/volume.py
3 files changed, 39 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/8270/1
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 38285c1..ee8ba67 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -324,6 +324,7 @@
dstPath = os.path.join(dstImgPath, self.volUUID)
self.log.debug("Share volume %s to %s", self.volUUID, dstImgPath)
+ # TODO: make this idempotent
os.symlink(self.getDevPath(), dstPath)
@classmethod
diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py
index 0aa9043..2e76944 100644
--- a/vdsm/storage/fileVolume.py
+++ b/vdsm/storage/fileVolume.py
@@ -227,29 +227,49 @@
"""
Share this volume to dstImgPath, including the metadata and the lease
"""
- dstVolPath = os.path.join(dstImgPath, self.volUUID)
- dstMetaPath = self._getMetaVolumePath(dstVolPath)
-
self.log.debug("Share volume %s to %s", self.volUUID, dstImgPath)
- self.oop.fileUtils.safeUnlink(dstVolPath)
- self.oop.os.link(self.getVolumePath(), dstVolPath)
+ dstVolumePath = os.path.join(dstImgPath, self.volUUID)
- self.log.debug("Share volume metadata of %s to %s", self.volUUID,
- dstImgPath)
+ # Format: itemName, srcPath, dstPath, itemRequired
+ itemsList = [
+ ('volume', self.getVolumePath(), dstVolumePath, True),
+ ('metadata', self._getMetaVolumePath(),
+ self._getMetaVolumePath(dstVolumePath), True),
+ ('lease', self._getLeaseVolumePath(),
+ self._getLeaseVolumePath(dstVolumePath),
+ sdCache.produce(self.sdUUID).hasVolumeLeases()),
+ ]
- self.oop.fileUtils.safeUnlink(dstMetaPath)
- self.oop.os.link(self._getMetaVolumePath(), dstMetaPath)
+ for itemName, srcPath, dstPath, itemRequired in itemsList:
+ self.log.debug("Sharing %s %s to %s (required: %s)", itemName,
+ self.volUUID, dstPath, itemRequired)
- # Link the lease file if the domain uses sanlock
- if sdCache.produce(self.sdUUID).hasVolumeLeases():
- dstLeasePath = self._getLeaseVolumePath(dstVolPath)
+ try:
+ srcInfo = self.oop.stat(srcPath)
+ except OSError, e:
+ if e != os.errno.ENOENT or itemRequired:
+ # Source not found
+ self.log.debug("TODO: <message>")
+ raise
- self.log.debug("Share volume lease of %s to %s", self.volUUID,
- dstImgPath)
+ try:
+ dstInfo = self.oop.stat(dstPath)
+ except OSError, e:
+ if e != os.errno.ENOENT:
+ raise
- self.oop.fileUtils.safeUnlink(dstLeasePath)
- self.oop.os.link(self._getLeaseVolumePath(), dstLeasePath)
+ # Destination file not present, linking
+ self.log.debug("TODO: <message>")
+ self.oop.os.link(srcPath, dstPath)
+ else:
+ # If both the source and destination are present and they are
+ # the same file (already linked) then continue.
+ if srcInfo.st_ino == dstInfo.st_ino:
+ self.log.debug("TODO: <message>")
+ else:
+ self.log.debug("TODO: <message>")
+ raise OSError(os.errno.EEXIST, "Destination file exists")
@classmethod
def shareVolumeRollback(cls, taskObj, volPath):
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index b9eb356..7938c6f 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -297,6 +297,8 @@
self._share(dstImgPath)
except Exception, e:
+ self.log.debug("Cannot share volume %s to %s", self.volUUID,
+ dstImgPath, exc_info=True)
raise se.CannotShareVolume(self.getVolumePath(), dstPath, str(e))
def refreshVolume(self):
--
To view, visit http://gerrit.ovirt.org/8270
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I237e4a8f094ba04dcd4ef7bff418e03f81162d8d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: WIP - Avoid creation of fake templates.
by ewarszaw@redhat.com
Eduardo has uploaded a new change for review.
Change subject: WIP - Avoid creation of fake templates.
......................................................................
WIP - Avoid creation of fake templates.
Change-Id: I7ae6e455757f247bfc3d8e261d8f5cec25f8776a
Signed-off-by: Eduardo <ewarszaw(a)redhat.com>
---
M vdsm/storage/image.py
M vdsm/storage/sp.py
2 files changed, 0 insertions(+), 45 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/8280/1
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index d004046..bb620ef 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -20,7 +20,6 @@
import os
import logging
-import threading
import uuid
from contextlib import contextmanager
@@ -65,7 +64,6 @@
Consist from chain of volumes.
"""
log = logging.getLogger('Storage.Image')
- _fakeTemplateLock = threading.Lock()
@classmethod
def createImageRollback(cls, taskObj, imageDir):
@@ -428,37 +426,6 @@
self.repoPath, destDom.sdUUID, sd.DOMAIN_IMAGES,
templateImage, volUUID), tLink)
- def createFakeTemplate(self, sdUUID, volParams):
- """
- Create fake template (relevant for Backup domain only)
- """
- with self._fakeTemplateLock:
- try:
- destDom = sdCache.produce(sdUUID)
- volclass = destDom.getVolumeClass()
- # Validate that the destination template exists and accessible
- volclass(self.repoPath, sdUUID, volParams['imgUUID'], volParams['volUUID'])
- except (se.VolumeDoesNotExist, se.ImagePathError):
- try:
- # Create fake parent volume
- destDom.createVolume(imgUUID=volParams['imgUUID'], size=volParams['size'],
- volFormat=volume.COW_FORMAT, preallocate=volume.SPARSE_VOL,
- diskType=volParams['disktype'], volUUID=volParams['volUUID'], desc="Fake volume",
- srcImgUUID=volume.BLANK_UUID, srcVolUUID=volume.BLANK_UUID)
-
- vol = destDom.produceVolume(imgUUID=volParams['imgUUID'], volUUID=volParams['volUUID'])
- # Mark fake volume as "FAKE"
- vol.setLegality(volume.FAKE_VOL)
- # Mark fake volume as shared
- vol.setShared()
- # Now we should re-link all hardlinks of this template in all VMs based on it
- self.__templateRelink(destDom, volParams['imgUUID'], volParams['volUUID'])
-
- self.log.debug("Succeeded to create fake image %s in domain %s", volParams['imgUUID'], destDom.sdUUID)
- except Exception:
- self.log.error("Failure to create fake image %s in domain %s", volParams['imgUUID'],
- destDom.sdUUID, exc_info=True)
-
def isLegal(self, sdUUID, imgUUID):
"""
Check correctness of the whole chain (excluding template)
@@ -502,7 +469,6 @@
self.log.error("Unexpected error", exc_info=True)
raise se.SourceImageActionError(imgUUID, srcSdUUID, str(e))
- fakeTemplate = False
pimg = volume.BLANK_UUID # standalone chain
# check if the chain is build above a template, or it is a standalone
pvol = srcChain[0].getParentVolume()
@@ -510,11 +476,6 @@
# find out parent volume parameters
volParams = pvol.getVolumeParams()
pimg = volParams['imgUUID'] # pimg == template image
- if destDom.isBackup():
- # FIXME: This workaround help as copy VM to the backup domain without its template
- # We will create fake template for future VM creation and mark it as FAKE volume
- # This situation is relevant for backup domain only
- fakeTemplate = True
@contextmanager
def justLogIt(img):
@@ -525,9 +486,6 @@
# In destination domain we need to lock image's template if exists
with rmanager.acquireResource(dstImageResourcesNamespace, pimg, rm.LockType.shared) \
if pimg != volume.BLANK_UUID else justLogIt(imgUUID):
- if fakeTemplate:
- self.createFakeTemplate(destDom.sdUUID, volParams)
-
dstChain = []
for srcVol in srcChain:
# Create the dst volume
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 78fbe66..d3b7009 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1828,10 +1828,7 @@
allVols)
else:
# Removing a template with dependencies in backup domain
- # A fake template will be created
img.delete(sdUUID=sdUUID, imgUUID=imgUUID, postZero=postZero, force=True)
- tParams = dom.produceVolume(imgUUID, tName).getVolumeParams()
- img.createFakeTemplate(sdUUID=sdUUID, volParams=tParams)
def mergeSnapshots(self, sdUUID, vmUUID, imgUUID, ancestor, successor, postZero):
"""
--
To view, visit http://gerrit.ovirt.org/8280
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ae6e455757f247bfc3d8e261d8f5cec25f8776a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Eduardo <ewarszaw(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: [WIP] Add new repository management code
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Add new repository management code
......................................................................
[WIP] Add new repository management code
Change-Id: Ib09c89cf982b475f45d26b2428fe05e2f4565dab
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M tests/Makefile.am
A tests/imageMainuplatorTests.py
A tests/repositoryEngineTests.py
A vdsm/storage/imageRepository/engines/__init__.py
A vdsm/storage/imageRepository/engines/localfs/__init__.py
A vdsm/storage/imageRepository/imageManipulator.py
6 files changed, 1,339 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/6247/1
--
To view, visit http://gerrit.ovirt.org/6247
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib09c89cf982b475f45d26b2428fe05e2f4565dab
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: Add create operation to qemu-img
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: Add create operation to qemu-img
......................................................................
Add create operation to qemu-img
Change-Id: I078afcb0899792805584fc56832747d36908f18b
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/qemuImg.py
1 file changed, 29 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/6245/1
--
To view, visit http://gerrit.ovirt.org/6245
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I078afcb0899792805584fc56832747d36908f18b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 5 months
Change in vdsm[master]: [WIP] Continue moving VM code to it's own module
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Continue moving VM code to it's own module
......................................................................
[WIP] Continue moving VM code to it's own module
Change-Id: I374dae67449f65c7c55ed028bd301be8b6a01eb5
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
1 file changed, 16 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/7514/1
diff --git a/vdsm/API.py b/vdsm/API.py
index aab69cd..e6a1048 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -136,15 +136,18 @@
for methName in GUEST_AGENT_METHODS:
self.setattr(attrName, partial(guestTrampoline, methName))
+ def _getVmObject(self):
+ return self._cif.vmContainer.get(self._UUID)
+
def _runThinMethod(self, methodName, *args, **kwargs):
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v:
return errCode['noVM']
return getattr(v, methodName)(*args, **kwargs)
def _runGuestAgentMethod(self, methodName, *args, **kwargs):
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if v is None:
return errCode['noVM']
@@ -163,7 +166,7 @@
"""
vmParams['vmId'] = self._UUID
try:
- if self._cif.vmContainer.get(self._UUID) is not None:
+ if self._getVmObject() is not None:
self.log.warning('vm %s already exists' % vmParams['vmId'])
return errCode['exist']
@@ -286,7 +289,7 @@
"""
Obtain statistics of the specified VM
"""
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v:
return errCode['noVM']
stats = v.getStats().copy()
@@ -364,7 +367,7 @@
"""
params['vmId'] = self._UUID
self.log.debug(params)
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if v is None:
return errCode['noVM']
@@ -395,7 +398,7 @@
self.log.debug('Migration create - Failed')
return response
- v = self._cif.vmContainer.get(self._UUID)
+ v = self._getVmObject()
if not v.waitForMigrationDestinationPrepare():
return errCode['createErr']
@@ -921,12 +924,14 @@
return d
else:
return {'vmId': d['vmId'], 'status': d['status']}
- # To improve complexity, convert 'vms' to set(vms)
- vmSet = set(vmList)
+
+ if vmList:
+ vms = (self._cif.vmContainer.get(vm) for vm in vmList)
+ else:
+ vms = self._cif.vmContainer.getVMs()
+
return {'status': doneCode,
- 'vmList': [reportedStatus(v, fullStatus)
- for v in self._cif.vmContainer.getVMs()
- if not vmSet or v.id in vmSet]}
+ 'vmList': [reportedStatus(vm, fullStatus) for vm in vms]}
# Networking-related functions
def setupNetworks(self, networks={}, bondings={}, options={}):
--
To view, visit http://gerrit.ovirt.org/7514
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I374dae67449f65c7c55ed028bd301be8b6a01eb5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
9 years, 5 months