Change in vdsm[master]: [WIP] Added getStorageDevices verb.
by barumuga@redhat.com
Hello Ayal Baron, Timothy Asir, Saggi Mizrahi, Federico Simoncelli, Dan Kenigsberg,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/3725
to review the following change.
Change subject: [WIP] Added getStorageDevices verb.
......................................................................
[WIP] Added getStorageDevices verb.
This verb is used to get list of storage devices in the node. Return
value is a dictionary, its keys are device names and values are
properties of those devices as dictionary.
{DEVNAME: {'container': CONTAINER_DEVNAME,
'contentType': CONTENT_TYPE_STRING,
'endSize': SIZE_MB,
'flagList': STRING_LIST,
'fsSize': SIZE_MB,
'fsSizeFree': SIZE_MB,
'fsType': STRING,
'fsUuid': UUID,
'members': DEVNAME_LIST,
'model': STRING,
'mountPoint': STRING,
'name': DEVNAME,
'origin': LV_DEVNAME,
'parent': PARENT_DEVNAME,
'partitions': DEVNAME_LIST,
'size': SIZE_MB,
'sizeFree': SIZE_MB,
'startSize': SIZE_MB,
'status': STATUS_STRING,
'tableType': DISK_TABLE_TYPE,
'type': TYPE_STRING,
'uuid': UUID,
'vendor': STRING},...}
here, property dictionary contains
container: If DEVNAME is used by another device eg. LVM PV, MD etc, name
of that device is set
contentType: This is determined by various other properties. Possible
value is one of 'SWAP', 'OS', 'DATA' and 'NA'
endSize: If DEVNAME is a partition, its end boundry is set. The value
is in MB
flagList: If DEVNAME is a partition, its flags(eg. boot,bios_grub etc)
are set as a list of strings
fsSize: If DEVNAME has a file system, its size is set. The value is
in MB
fsSizeFree: If DEVNAME is mounted, its free size is set. The value is in
MB
fsType: If DEVNAME is formatted, its file system type is set
fsUuid': If DEVNAME has file system, its UUID is set
members: If DEVNAME is a MD, LVM VG etc, its member device names are
set as list of strings
model: Model of DEVNAME is set as string
mountPoint: If DEVNAME is mounted, its mount point is set
name: DEVNAME is set here for completion
origin: If DEVNAME is a snapshot of LV, that LV name is set
parent: If DEVNAME is a partition, its disk name is set
partitions: If DEVNAME is a disk, its partition names are set as list of
strings
size: Size of DEVNAME is set. The value is in MB
sizeFree: If DEVNAME is VG, its size of free extents is set. If its a
partitioned disk, its unallocated size is set. The value is
in MB
startSize: If DEVNAME is a partition, its start boundry is set. The
value is in MB
status: This is determined by various other properites of the DEVNAME.
Possible value is one of 'UNINITIALIZED', 'NA', 'UNUSABLE',
'FORMAT_UNSUPPORTED', 'MOUNTED', 'FORMATTED' and 'PARTED'
tableType': If DEVNAME is a disk, its table(label) type is set as a string
type: This is determined value. Possible value is one of 'MD',
'LVM_VG', 'LVM_LV_SNAPSHOT', 'LVM_LV' and 'BLOCK'
uuid: UUID of DEVNAME
vendor: Vendor of DEVNAME is set as string
Change-Id: I2cb217321a7a8dfcd1b507c7cba2888f08612207
Signed-off-by: Bala.FA <barumuga(a)redhat.com>
---
M vdsm.spec.in
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/Makefile.am
A vdsm/storage_device_utils.py
M vdsm_cli/vdsClient.py
6 files changed, 505 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/3725/1
--
To view, visit http://gerrit.ovirt.org/3725
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cb217321a7a8dfcd1b507c7cba2888f08612207
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Bala.FA <barumuga(a)redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi(a)redhat.com>
Gerrit-Reviewer: Timothy Asir <tjeyasin(a)redhat.com>
10 years, 1 month
Change in vdsm[master]: confNet: ifcfg's VLAN should be set only on vlan cfg
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: confNet: ifcfg's VLAN should be set only on vlan cfg
......................................................................
confNet: ifcfg's VLAN should be set only on vlan cfg
If a misguided script calls addNetwork with explicit VLAN option, it
sohuld not be blindly copied to the top-most device.
We set VLAN=yes on the ifcfg script for the vlan device, and that's
that.
Change-Id: Ia2c9d6c86e73104424ca8ac901bf09e4b98a47ab
Bug-Id: BZ#847733
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/configNetwork.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/11/7411/1
diff --git a/vdsm/configNetwork.py b/vdsm/configNetwork.py
index 3f99a66..2ef0a8a 100755
--- a/vdsm/configNetwork.py
+++ b/vdsm/configNetwork.py
@@ -384,7 +384,7 @@
if mtu:
cfg = cfg + 'MTU=%d\n' % mtu
cfg += 'NM_CONTROLLED=no\n'
- BLACKLIST = ['TYPE', 'NAME', 'DEVICE', 'bondingOptions',
+ BLACKLIST = ['TYPE', 'NAME', 'DEVICE', 'VLAN', 'bondingOptions',
'force', 'blockingdhcp',
'connectivityCheck', 'connectivityTimeout',
'implicitBonding']
--
To view, visit http://gerrit.ovirt.org/7411
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2c9d6c86e73104424ca8ac901bf09e4b98a47ab
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
10 years, 2 months
Change in vdsm[master]: avoid redundant domain produce() in createStoragePool
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: avoid redundant domain produce() in createStoragePool
......................................................................
avoid redundant domain produce() in createStoragePool
Change-Id: If1c236aa3043068ca8f3f376cb340e986cd484bb
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/storage/hsm.py
M vdsm/storage/sp.py
2 files changed, 4 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/7347/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 2227c03..b2c20c0 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -765,19 +765,6 @@
if msdType in sd.BLOCK_DOMAIN_TYPES and msdVersion in blockSD.VERS_METADATA_LV and len(domList) > sp.MAX_DOMAINS:
raise se.TooManyDomainsInStoragePoolError()
- for sdUUID in domList:
- try:
- dom = sdCache.produce(sdUUID=sdUUID)
- # TODO: consider removing validate() from here, as the domains
- # are going to be accessed much later, and may loose validity
- # until then.
- dom.validate()
- except:
- raise se.StorageDomainAccessError(sdUUID)
- #If you remove this condition, remove it from StoragePool.attachSD() too.
- if dom.isData() and (dom.getVersion() != msdVersion):
- raise se.MixedSDVersionError(dom.sdUUID, dom.getVersion(), msd.sdUUID, msdVersion)
-
vars.task.getExclusiveLock(STORAGE, spUUID)
for dom in sorted(domList):
vars.task.getExclusiveLock(STORAGE, dom)
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index ee45151..a5b65c7 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -549,6 +549,7 @@
domain.validate()
if sdUUID == msdUUID:
msd = domain
+ msdVersion = msd.getVersion()
except se.StorageException:
self.log.error("Unexpected error", exc_info=True)
raise se.StorageDomainAccessError(sdUUID)
@@ -560,6 +561,9 @@
# Non ISO domains have only 1 pool
if len(spUUIDs) > 0:
raise se.StorageDomainAlreadyAttached(spUUIDs[0], sdUUID)
+
+ if domain.isData() and (domain.getVersion() != msdVersion):
+ raise se.MixedSDVersionError(domain.sdUUID, domain.getVersion(), msd.sdUUID, msdVersion)
fileUtils.createdir(self.poolPath)
self._acquireTemporaryClusterLock(msdUUID, safeLease)
--
To view, visit http://gerrit.ovirt.org/7347
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If1c236aa3043068ca8f3f376cb340e986cd484bb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 2 months
Change in vdsm[master]: force reload udev rules to avoid LUN device permission error
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: force reload udev rules to avoid LUN device permission error
......................................................................
force reload udev rules to avoid LUN device permission error
udev rules creat symlink for LUN device making it usable for qemu
but the rules are not instantly loaded by udev
result in LUN device symlink not created before vm run
force reload to make the rules take effect instantly
Change-Id: I718d62e67b0a228f2510233c5dd9d1d94c4a736c
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/storage/hsm.py
M vdsm/supervdsmServer.py
2 files changed, 9 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/6780/1
--
To view, visit http://gerrit.ovirt.org/6780
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I718d62e67b0a228f2510233c5dd9d1d94c4a736c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 3 months
Change in vdsm[master]: Encapsulate vdsm-unregister into vdsm-tool function
by lilei@linux.vnet.ibm.com
Lei Li has uploaded a new change for review.
Change subject: Encapsulate vdsm-unregister into vdsm-tool function
......................................................................
Encapsulate vdsm-unregister into vdsm-tool function
Change-Id: I7348baeabbdcbb0c2da64170b6957430feaa1954
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
M vdsm-tool/Makefile.am
A vdsm-tool/register.py
M vdsm.spec.in
3 files changed, 43 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/4527/1
--
To view, visit http://gerrit.ovirt.org/4527
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7348baeabbdcbb0c2da64170b6957430feaa1954
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lei Li <lilei(a)linux.vnet.ibm.com>
10 years, 3 months
Change in vdsm[master]: Move uninstall preun section to vdsm-unregister
by lilei@linux.vnet.ibm.com
Lei Li has uploaded a new change for review.
Change subject: Move uninstall preun section to vdsm-unregister
......................................................................
Move uninstall preun section to vdsm-unregister
The specfile vdsm.spec.in has very long %post and %preun
sections, move the install/uninstall hooks into vdsm-tool.
This patch move unregister to a script which will be
encapsulated into a vdsm-tool function stop-vdsm-service.
Change-Id: I4e7b5dc969dfb51e6880b9bb209a363609f5e123
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
M vdsm.spec.in
M vdsm/Makefile.am
A vdsm/vdsm-unregister.in
3 files changed, 36 insertions(+), 42 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/4526/1
--
To view, visit http://gerrit.ovirt.org/4526
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e7b5dc969dfb51e6880b9bb209a363609f5e123
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lei Li <lilei(a)linux.vnet.ibm.com>
10 years, 3 months
Change in vdsm[master]: Adjust width for usage_command in vdsm-tool
by lilei@linux.vnet.ibm.com
Lei Li has uploaded a new change for review.
Change subject: Adjust width for usage_command in vdsm-tool
......................................................................
Adjust width for usage_command in vdsm-tool
The default value of width is 70 characters. It may not
be long enough for most of the usage_command comments.
So adjust it to add flexibility.
Change-Id: I800384e77452a76f651b73205b3335905274077c
Signed-off-by: Lei Li <lilei(a)linux.vnet.ibm.com>
---
M vdsm-tool/vdsm-tool
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/4648/1
--
To view, visit http://gerrit.ovirt.org/4648
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I800384e77452a76f651b73205b3335905274077c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Lei Li <lilei(a)linux.vnet.ibm.com>
10 years, 3 months
Change in vdsm[master]: [WIP] Move vm logic to it's own module
by smizrahi@redhat.com
Saggi Mizrahi has uploaded a new change for review.
Change subject: [WIP] Move vm logic to it's own module
......................................................................
[WIP] Move vm logic to it's own module
Change-Id: Icc54c1d0ab7ad535d825dcd72fd2f4583b690f44
Signed-off-by: Saggi Mizrahi <smizrahi(a)redhat.com>
---
M vdsm/API.py
M vdsm/Makefile.am
M vdsm/clientIF.py
A vdsm/vmContainer.py
4 files changed, 134 insertions(+), 79 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/23/7423/1
diff --git a/vdsm/API.py b/vdsm/API.py
index e132fb9..818e00c 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -167,34 +167,36 @@
self.log.error("Error restoring VM parameters",
exc_info=True)
- requiredParams = ['vmId', 'memSize', 'display']
- for param in requiredParams:
+ for param in ['vmId', 'memSize', 'display']:
if param not in vmParams:
- self.log.error('Missing required parameter %s' % (param))
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'Missing required' + \
- 'parameter %s' % (param)}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'Missing required parameter %s' % (param,)}
+ }
try:
storage.misc.validateUUID(vmParams['vmId'])
except:
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'vmId must be a valid UUID'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'vmId must be a valid UUID'}
+ }
if vmParams['memSize'] == 0:
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'Must specify nonzero memSize'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'Must specify nonzero memSize'}
+ }
if vmParams.get('boot') == 'c' and not 'hda' in vmParams \
and not vmParams.get('drives'):
- return {'status': {'code': errCode['MissParam']
- ['status']['code'],
- 'message': 'missing boot disk'}}
+ return {'status': {
+ 'code': errCode['MissParam']['status']['code'],
+ 'message': 'missing boot disk'}
+ }
if 'vmType' not in vmParams:
vmParams['vmType'] = 'kvm'
- elif vmParams['vmType'] == 'kvm':
+
+ if vmParams['vmType'] == 'kvm':
if 'kvmEnable' not in vmParams:
vmParams['kvmEnable'] = 'true'
@@ -205,25 +207,27 @@
vmParams['volatileFloppy'] = True
if caps.osversion()['name'] == caps.OSName.UNKNOWN:
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Unknown host operating system'}}
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Unknown host operating system'}
+ }
if 'sysprepInf' in vmParams:
if not self._createSysprepFloppyFromInf(vmParams['sysprepInf'],
vmParams['floppy']):
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Failed to create '
- 'sysprep floppy image. '
- 'No space on /tmp?'}}
- return errCode['createErr']
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Failed to create sysprep floppy image. '
+ 'No space on /tmp?'}
+ }
if vmParams.get('display') not in ('vnc', 'qxl', 'qxlnc', 'local'):
- return {'status': {'code': errCode['createErr']
- ['status']['code'],
- 'message': 'Unknown display type %s'
- % vmParams.get('display')}}
+ return {'status': {
+ 'code': errCode['createErr']['status']['code'],
+ 'message': 'Unknown display type %s' %
+ vmParams.get('display')}
+ }
+
if 'nicModel' not in vmParams:
vmParams['nicModel'] = config.get('vars', 'nic_model')
vmParams['displayIp'] = self._getNetworkIp(vmParams.get(
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
index d4c52ed..574d762 100644
--- a/vdsm/Makefile.am
+++ b/vdsm/Makefile.am
@@ -53,6 +53,7 @@
tc.py \
vdsmDebugPlugin.py \
vmChannels.py \
+ vmContainer.py \
vm.py \
$(NULL)
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index b9a4913..b2438fb 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -24,6 +24,7 @@
import pickle
from xml.dom import minidom
import uuid
+import errno
from storage.dispatcher import Dispatcher
from storage.hsm import HSM
@@ -40,9 +41,9 @@
import configNetwork
import caps
from vmChannels import Listener
-from libvirtvm import LibvirtVm
import blkid
import supervdsm
+import vmContainer
try:
import gluster.api as gapi
_glusterEnabled = True
@@ -66,7 +67,6 @@
:param log: a log object to be used for this object's logging.
:type log: :class:`logging.Logger`
"""
- self.vmContainerLock = threading.Lock()
self._networkSemaphore = threading.Semaphore()
self._shutdownSemaphore = threading.Semaphore()
self.log = log
@@ -82,7 +82,7 @@
else:
self.gluster = None
try:
- self.vmContainer = {}
+ self.vmContainer = vmContainer.VmContainer()
ifids = netinfo.nics() + netinfo.bondings()
ifrates = map(netinfo.speed, ifids)
self._hostStats = utils.HostStatsThread(
@@ -328,24 +328,19 @@
return res['status']['code']
def createVm(self, vmParams):
- self.vmContainerLock.acquire()
- self.log.info("vmContainerLock acquired by vm %s",
- vmParams['vmId'])
try:
- if 'recover' not in vmParams:
- if vmParams['vmId'] in self.vmContainer:
- self.log.warning('vm %s already exists' %
- vmParams['vmId'])
- return errCode['exist']
- vm = LibvirtVm(self, vmParams)
- self.vmContainer[vmParams['vmId']] = vm
- finally:
- container_len = len(self.vmContainer)
- self.vmContainerLock.release()
- vm.run()
- self.log.debug("Total desktops after creation of %s is %d" %
- (vmParams['vmId'], container_len))
- return {'status': doneCode, 'vmList': vm.status()}
+ vm = self.vmContainer.createVm(vmParams)
+ return {'status': doneCode, 'vmList': vm.status()}
+ except vmContainer.VmContainerError as e:
+ if e.errno == errno.EEXIST:
+ return errCode['exist']
+ return
+
+ def waitForShutdown(self, timeout=None):
+ self.shutdownEvent(timeout)
+ # Some versions of python have a bug where wait doesn't
+ # really return the correct value.
+ return self.shutdownEvent.isSet()
def _recoverExistingVms(self):
try:
@@ -364,10 +359,11 @@
'process with id: %s',
vmId, exc_info=True)
- while (self._enabled and
- 'WaitForLaunch' in [v.lastStatus for v in
- self.vmContainer.values()]):
- time.sleep(1)
+ vmList = self.vmContainer.getVMs()
+ while ('WaitForLaunch' in (v.lastStatus for v in vmList)):
+ if self.waitForShutdown(1):
+ break
+
self._cleanOldFiles()
self._recovery = False
@@ -375,20 +371,23 @@
# and then prepare all volumes.
# Actually, we need it just to get the resources for future
# volumes manipulations
- while self._enabled and self.vmContainer and \
- not self.irs.getConnectedStoragePoolsList()['poollist']:
- time.sleep(5)
+ if len(vmList) > 0:
+ while not self.irs.getConnectedStoragePoolsList()['poollist']:
+ if self.waitForShutdown(5):
+ break
- for vmId, vmObj in self.vmContainer.items():
- # Let's recover as much VMs as possible
+ # Let's recover as many VMs as possible
+ for vmObj in vmList:
+ # Do not prepare volumes when system goes down
+ if self.waitForShutdown(0):
+ break
+
try:
- # Do not prepare volumes when system goes down
- if self._enabled:
- vmObj.preparePaths(
- vmObj.getConfDevices()[vm.DISK_DEVICES])
+ devices = vmObj.getConfDevices()[vm.DISK_DEVICES]
+ vmObj.preparePaths(devices)
except:
- self.log.error("Vm %s recovery failed",
- vmId, exc_info=True)
+ self.log.error("Vm '%s' recovery failed", vmObj.id,
+ exc_info=True)
except:
self.log.error("Vm's recovery failed", exc_info=True)
@@ -452,27 +451,27 @@
return recoveryFile
except:
self.log.debug("Error recovering VM", exc_info=True)
- return None
def _cleanOldFiles(self):
for f in os.listdir(constants.P_VDSM_RUN):
try:
vmId, fileType = f.split(".", 1)
- if fileType in ["guest.socket", "monitor.socket", "pid",
+ if fileType not in ["guest.socket", "monitor.socket", "pid",
"stdio.dump", "recovery"]:
- if vmId in self.vmContainer:
- continue
- if f == 'vdsmd.pid':
- continue
- if f == 'respawn.pid':
- continue
- if f == 'svdsm.pid':
- continue
- if f == 'svdsm.sock':
- continue
- else:
continue
- self.log.debug("removing old file " + f)
+
+ if self.vmContainer.hasVM(vmId):
+ continue
+
+ #FIXME: Move VM crud to a subdir so we don't need a
+ # whitelist. I remember spending a considerable amount of
+ # time while writing Super VDSM trying to figure out why my
+ # pid file was disappearing!
+ if f in ('vdsmd.pid', 'respawn.pid',
+ 'svdsm.pid', 'svdsm.sock'):
+ continue
+
+ self.log.debug("Removing old file '%s'", f)
utils.rmFile(constants.P_VDSM_RUN + f)
except:
pass
diff --git a/vdsm/vmContainer.py b/vdsm/vmContainer.py
new file mode 100644
index 0000000..f15b8eb
--- /dev/null
+++ b/vdsm/vmContainer.py
@@ -0,0 +1,51 @@
+import logging
+import threading
+from libvirtvm import LibvirtVm
+import os
+import errno
+
+
+class VmContainerError(OSError):
+ def __init__(self, errno):
+ OSError.__init__(self, errno, os.strerror(errno))
+
+
+class VmContainer(object):
+ log = logging.getLogger("VmContainer")
+
+ def __init__(self):
+ self._syncroot = threading.Lock()
+ self._vms = {}
+
+ def createVm(self, vmParams):
+ self.log.info("vmContainerLock acquired by vm %s",
+ vmParams['vmId'])
+
+ with self._syncRoot:
+ if 'recover' not in vmParams:
+ if vmParams['vmId'] in self._vms:
+ self.log.warning('vm %s already exists' % vmParams['vmId'])
+
+ raise VmContainerError(errno.EEXIST)
+
+ vm = LibvirtVm(self, vmParams)
+ self._vms[vmParams['vmId']] = vm
+
+ container_len = len(self._vms)
+
+ vm.run()
+ self.log.debug("Total desktops after creation of %s is %d" %
+ (vmParams['vmId'], container_len))
+
+ return vm
+
+ def getVMs(self):
+ return self._vms.values()
+
+ def hasVM(self, vmId):
+ with self._syncRoot:
+ return vmId in self._vms
+
+ def get(self, vmId):
+ with self._syncRoot:
+ return self._vms.get(vmId)
--
To view, visit http://gerrit.ovirt.org/7423
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc54c1d0ab7ad535d825dcd72fd2f4583b690f44
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi(a)redhat.com>
10 years, 3 months
Change in vdsm[master]: add verb for vdsm to tuneCpu params
by lvroyce@linux.vnet.ibm.com
Royce Lv has uploaded a new change for review.
Change subject: add verb for vdsm to tuneCpu params
......................................................................
add verb for vdsm to tuneCpu params
Engine and Mom need an interface to cap the max cpu and share.
So add this verb to vdsm.
tuneCpu:
Dynamically tune cpu absolute max proportion and relative share.
Input:
vmId: VM to be tuned
max_proportion=<value>: absolute max proportion for each vCPU can consume
-1:no limit,[0.001,1]:valid proportion
relative_share=<value>:relative share of CPU compared with other VMs
output:
success: return doneCode
failure: return errCode tunecpuErr.
Change-Id: I09e02e09ef06ad6de45be75c3f2f913a3025750f
Signed-off-by: Royce Lv<lvroyce(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/libvirtvm.py
M vdsm/storage/misc.py
M vdsm_cli/vdsClient.py
6 files changed, 97 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/7492/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 827f73b..f0c47d1 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -26,6 +26,7 @@
import time
import threading
import logging
+import math
from vdsm import utils
from clientIF import clientIF
@@ -37,6 +38,7 @@
import storage.volume
import storage.sd
import storage.image
+import storage.storage_exception as se
from vdsm.define import doneCode, errCode, Kbytes, Mbytes
import caps
from vdsm.config import config
@@ -555,6 +557,33 @@
message = USER_SHUTDOWN_MESSAGE
return v.shutdown(delay, message)
+ def tuneCpu(self, tuneParams):
+ try:
+ v = self._cif.vmContainer[self._UUID]
+ if 'relative_share' in tuneParams:
+ tuneParams['cpu_shares'] = storage.misc.validateN(
+ tuneParams['relative_share'], 'relative_share')
+ del(tuneParams['relative_share'])
+ if 'max_proportion' in tuneParams:
+ max = storage.misc.validateFloat(
+ tuneParams['max_proportion'], 'max_proportion')
+ tuneParams['vcpu_period'] = 1000000
+ if max > 1:
+ raise se.InvalidParameterException('max_proportion', max)
+ elif max >= 0.001:
+ tuneParams['vcpu_quota'] = int(
+ round(tuneParams['vcpu_period'] * max))
+ else:
+ tuneParams['vcpu_quota'] = int(math.floor(max))
+ del(tuneParams['max_proportion'])
+ del(tuneParams['vmId'])
+ except KeyError:
+ return errCode['noVM']
+ except se.InvalidParameterException:
+ return errCode['tunecpuErr']
+
+ return v.tuneCpu(tuneParams)
+
def _createSysprepFloppyFromInf(self, infFileBinary, floppyImage):
try:
rc, out, err = utils.execCmd([constants.EXT_MK_SYSPREP_FLOPPY,
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 826c125..37b1f60 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -265,6 +265,10 @@
vm = API.VM(vmId)
return vm.snapshot(snapDrives)
+ def vmTuneCpu(self, params):
+ vm = API.VM(params['vmId'])
+ return vm.tuneCpu(params)
+
def vmMerge(self, vmId, mergeDrives):
vm = API.VM(vmId)
return vm.merge(mergeDrives)
@@ -765,7 +769,8 @@
(self.vmHotplugDisk, 'hotplugDisk'),
(self.vmHotunplugDisk, 'hotunplugDisk'),
(self.vmHotplugNic, 'hotplugNic'),
- (self.vmHotunplugNic, 'hotunplugNic'))
+ (self.vmHotunplugNic, 'hotunplugNic'),
+ (self.vmTuneCpu, 'tuneCpu'))
def getIrsMethods(self):
return ((self.domainActivate, 'activateStorageDomain'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 049d36c..d41d467 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -117,6 +117,9 @@
'momErr': {'status':
{'code': 54,
'message': 'Failed to set mom policy'}},
+ 'tunecpuErr': {'status':
+ {'code': 55,
+ 'message': 'Failed to Tune CPU'}},
'recovery': {'status':
{'code': 99,
'message':
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index e95e94b..59c7ec6 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1371,13 +1371,17 @@
if self._initTimePauseCode == 'ENOSPC':
self.cont()
self.conf['pid'] = self._getPid()
-
- nice = int(self.conf.get('nice', '0'))
- nice = max(min(nice, 19), 0)
- try:
- self._dom.setSchedulerParameters({'cpu_shares': (20 - nice) * 51})
- except:
- self.log.warning('failed to set Vm niceness', exc_info=True)
+ #do not trying to change cpu_shares for recovery and restore flows
+ if not 'recover' in self.conf and not 'restoreState' in self.conf:
+ nice = int(self.conf.get('nice', '0'))
+ nice = max(min(nice, 19), 0)
+ cpuShare = (20 - nice) * 51
+ try:
+ self._dom.setSchedulerParameters({'cpu_shares': cpuShare})
+ except:
+ self.log.warning('failed to set Vm niceness', exc_info=True)
+ self.conf['cpu_shares'] = cpuShare
+ self.saveState()
def _run(self):
self.log.info("VM wrapper has started")
@@ -1931,6 +1935,23 @@
(snapFlags & libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE
== libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE)}
+ def tuneCpu(self, tuneParams):
+ try:
+ self._dom.setSchedulerParameters(tuneParams)
+ self.conf['cpu_shares'] = tuneParams.get('cpu_shares')
+ self.conf['vcpu_quota'] = tuneParams.get('vcpu_quota')
+ self.conf['vcpu_period'] = tuneParams.get('vcpu_period')
+ self.saveState()
+ return {'status': doneCode}
+ except libvirt.libvirtError, e:
+ self.log.error("TuneCpu failed:%s",
+ e.message, exc_info=True)
+ return errCode['tunecpuErr']
+ except LookupError:
+ self.log.error('TuneCpu failed: unrecongnized params',
+ exc_info=True)
+ return errCode['tunecpuErr']
+
def _runMerge(self):
for mergeStatus in self.conf.get('liveMerge', []):
if mergeStatus['status'] != MERGESTATUS.NOT_STARTED:
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index 161726b..1f5ed1a 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -503,6 +503,13 @@
return n
+def validateFloat(floatNumber, name):
+ try:
+ return float(floatNumber)
+ except:
+ raise se.InvalidParameterException(floatNumber, name)
+
+
def rotateFiles(directory, prefixName, gen, cp=False, persist=False):
log.debug("dir: %s, prefixName: %s, versions: %s" %
(directory, prefixName, gen))
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index a164c20..ab0fa4c 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -204,6 +204,18 @@
return self.ExecAndExit(self.s.create(params))
+ def tuneCpu(self, args):
+ params = {}
+ confLines = []
+ params['vmId'] = args[0]
+ if len(args) > 1:
+ confLines.extend(args[1:])
+ for line in confLines:
+ if '=' in line:
+ param, value = line.split("=", 1)
+ params[param] = value
+ return self.ExecAndExit(self.s.tuneCpu(params))
+
def hotplugNic(self, args):
nic = self._parseDriveSpec(args[1])
nic['type'] = 'interface'
@@ -1802,6 +1814,18 @@
'Optional additional parameters in dictionary format,'
' name:value,name:value'
)),
+ 'tuneCpu': (serv.tuneCpu,
+ ('<vmId>'
+ '[max_proportion=value relative_share=value]',
+ 'Parameters list: r=required, o=optional',
+ 'r vmId: The vm to be tuned',
+ 'o max_proportion=<value>: '
+ 'max proportion for each vCPU can be consumed, '
+ '-1 is no limit,[0.001,1] is valid proportion',
+ 'o relative_share=<value>:relative share of CPU'
+ 'compared with other VMs',
+ 'Dynamically tune cpu absolute max proportion and relative share'
+ )),
'migrate': (serv.do_migrate,
('vmId=<id> method=<offline|online> src=<host:[port]> '
'dst=<host:[port]>',
--
To view, visit http://gerrit.ovirt.org/7492
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I09e02e09ef06ad6de45be75c3f2f913a3025750f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
10 years, 4 months
Change in vdsm[master]: adjust betterPopenTest.py
by xiawenc@linux.vnet.ibm.com
Wenchao Xia has uploaded a new change for review.
Change subject: adjust betterPopenTest.py
......................................................................
adjust betterPopenTest.py
The main function in betterPopenTest is used to check result
after popen, it should not include the betterPopen and test class
code. If it include and the directory it lies on changes, the
import will fail, which means additional python settings should be
passed to betterPopen making things more complicate.
Change-Id: I3059df6abb5c261f45720fc1a3b5266314c62e79
Signed-off-by: wenchao xia <xiawenc(a)linux.vnet.ibm.com>
---
M tests/betterPopenTests.py
1 file changed, 50 insertions(+), 51 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/4585/1
--
To view, visit http://gerrit.ovirt.org/4585
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3059df6abb5c261f45720fc1a3b5266314c62e79
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Wenchao Xia <xiawenc(a)linux.vnet.ibm.com>
10 years, 4 months