Change in vdsm[master]: [wip] sdcache: avoid extra refresh due samplingmethod
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [wip] sdcache: avoid extra refresh due samplingmethod
......................................................................
[wip] sdcache: avoid extra refresh due samplingmethod
In order to avoid an extra iscsi rescan (symptomatic of samplingmethod)
an additional lock has been introduced to queue the requests when the
storage is flagged as stale.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=870768
Change-Id: If178a8eaeb94f1dfe9e0957036dde88f6a22829c
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/sdc.py
1 file changed, 25 insertions(+), 26 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/9274/1
diff --git a/vdsm/storage/sdc.py b/vdsm/storage/sdc.py
index f2f4534..978e3fa 100644
--- a/vdsm/storage/sdc.py
+++ b/vdsm/storage/sdc.py
@@ -62,32 +62,27 @@
STORAGE_UPDATED = 0
STORAGE_STALE = 1
- STORAGE_REFRESHING = 2
def __init__(self, storage_repo):
- self._syncroot = threading.Condition()
+ self._syncDomain = threading.Condition()
+ self._syncRefresh = threading.Lock()
self.__domainCache = {}
self.__inProgress = set()
self.__staleStatus = self.STORAGE_STALE
self.storage_repo = storage_repo
def invalidateStorage(self):
- with self._syncroot:
- self.__staleStatus = self.STORAGE_STALE
+ self.log.debug("The storages have been invalidated")
+ self.__staleStatus = self.STORAGE_STALE
@misc.samplingmethod
def refreshStorage(self):
- self.__staleStatus = self.STORAGE_REFRESHING
-
+ # We need to set the __staleStatus value at the beginning because we
+ # want to keep track of the future invalidateStorage calls that might
+ # arrive during the rescan procedure.
+ self.__staleStatus = self.STORAGE_UPDATED
multipath.rescan()
lvm.invalidateCache()
-
- # If a new invalidateStorage request came in after the refresh
- # started then we cannot flag the storages as updated (force a
- # new rescan later).
- with self._syncroot:
- if self.__staleStatus == self.STORAGE_REFRESHING:
- self.__staleStatus = self.STORAGE_UPDATED
def produce(self, sdUUID):
domain = DomainProxy(self, sdUUID)
@@ -98,7 +93,7 @@
return domain
def _realProduce(self, sdUUID):
- with self._syncroot:
+ with self._syncDomain:
while True:
domain = self.__domainCache.get(sdUUID)
@@ -109,25 +104,29 @@
self.__inProgress.add(sdUUID)
break
- self._syncroot.wait()
+ self._syncDomain.wait()
try:
- # If multiple calls reach this point and the storage is not
- # updated the refreshStorage() sampling method is called
- # serializing (and eventually grouping) the requests.
- if self.__staleStatus != self.STORAGE_UPDATED:
- self.refreshStorage()
+ # Here we cannot take full advantage of the refreshStorage
+ # samplingmethod since we might be scheduling an unneeded
+ # extra rescan. We need an additional lock (_syncRefresh)
+ # to make sure that __staleStatus is taken in account
+ # (without affecting all the other external refreshStorage
+ # calls as it would be if we move this check there).
+ with self._syncRefresh:
+ if self.__staleStatus != self.STORAGE_UPDATED:
+ self.refreshStorage()
domain = self._findDomain(sdUUID)
- with self._syncroot:
+ with self._syncDomain:
self.__domainCache[sdUUID] = domain
return domain
finally:
- with self._syncroot:
+ with self._syncDomain:
self.__inProgress.remove(sdUUID)
- self._syncroot.notifyAll()
+ self._syncDomain.notifyAll()
def _findDomain(self, sdUUID):
import blockSD
@@ -162,16 +161,16 @@
return uuids
def refresh(self):
- with self._syncroot:
+ with self._syncDomain:
lvm.invalidateCache()
self.__domainCache.clear()
def manuallyAddDomain(self, domain):
- with self._syncroot:
+ with self._syncDomain:
self.__domainCache[domain.sdUUID] = domain
def manuallyRemoveDomain(self, sdUUID):
- with self._syncroot:
+ with self._syncDomain:
try:
del self.__domainCache[sdUUID]
except KeyError:
--
To view, visit http://gerrit.ovirt.org/9274
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If178a8eaeb94f1dfe9e0957036dde88f6a22829c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: sp: load dumped tasks when recovering
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: sp: load dumped tasks when recovering
......................................................................
sp: load dumped tasks when recovering
Change-Id: I1cd2ea34c2013870b213d8baa471248adabfbbe3
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/sp.py
1 file changed, 1 insertion(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/02/26902/1
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 338232f..e6a6bd0 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -288,8 +288,6 @@
self.log.error("Backup domain validation failed",
exc_info=True)
- self.taskMng.loadDumpedTasks(self.tasksDir)
-
self.spmRole = SPM_ACQUIRED
# Once setSecure completes we are running as SPM
@@ -322,6 +320,7 @@
# Restore tasks is last because tasks are spm ops (spm has to
# be started)
+ self.taskMng.loadDumpedTasks(self.tasksDir)
self.taskMng.recoverDumpedTasks()
self.log.debug("ended.")
--
To view, visit http://gerrit.ovirt.org/26902
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cd2ea34c2013870b213d8baa471248adabfbbe3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: task: support task id in client request
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: task: support task id in client request
......................................................................
task: support task id in client request
Change-Id: Ib5034e6c3466d5a663699d4f924975b7e067c768
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/BindingXMLRPC.py
M vdsm/clientIF.py
M vdsm/storage/dispatcher.py
3 files changed, 16 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/26809/1
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 76251f5..d449088 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -98,6 +98,7 @@
Create xml-rpc server over http or https.
"""
HTTP_HEADER_FLOWID = "FlowID"
+ HTTP_HEADER_TASKID = "TaskID"
threadLocal = self.cif.threadLocal
@@ -200,6 +201,7 @@
def parse_request(self):
r = basehandler.parse_request(self)
threadLocal.flowID = self.headers.get(HTTP_HEADER_FLOWID)
+ threadLocal.taskID = self.headers.get(HTTP_HEADER_TASKID)
return r
def finish(self):
@@ -207,6 +209,7 @@
threadLocal.client = None
threadLocal.server = None
threadLocal.flowID = None
+ threadLocal.taskID = None
if sys.version_info[:2] == (2, 6):
# Override BaseHTTPServer.BaseRequestHandler implementation to
@@ -246,6 +249,10 @@
fmt += " flowID [%s]"
logargs.append(self.cif.threadLocal.flowID)
+ if getattr(self.cif.threadLocal, 'taskID', None) is not None:
+ fmt += " taskID [%s]"
+ logargs.append(self.cif.threadLocal.taskID)
+
self.log.debug(fmt, *logargs)
try:
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index eac7950..21e3c71 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -99,6 +99,7 @@
self.channelListener.start()
self.threadLocal = threading.local()
self.threadLocal.client = ''
+ self.irs.setClientThreadLocal(self.threadLocal)
except:
self.log.error('failed to init clientIF, '
'shutting down storage dispatcher')
diff --git a/vdsm/storage/dispatcher.py b/vdsm/storage/dispatcher.py
index 6586492..3e2bf0a 100644
--- a/vdsm/storage/dispatcher.py
+++ b/vdsm/storage/dispatcher.py
@@ -45,10 +45,14 @@
self.storage_repository = config.get('irs', 'repository')
self._exposeFunctions(obj)
self.log.info("Starting StorageDispatcher...")
+ self._clientThreadLocal = None
@property
def ready(self):
return getattr(self._obj, 'ready', True)
+
+ def setClientThreadLocal(self, clientThreadLocal):
+ self._clientThreadLocal = clientThreadLocal
def _exposeFunctions(self, obj):
for funcName in dir(obj):
@@ -66,7 +70,10 @@
@wraps(func)
def wrapper(*args, **kwargs):
try:
- ctask = task.Task(id=None, name=name)
+ ctaskid = getattr(self._clientThreadLocal, 'taskID', None)
+ if ctaskid is not None:
+ self.log.info('using client requested taskID %s', ctaskid)
+ ctask = task.Task(id=ctaskid, name=name)
try:
response = self.STATUS_OK.copy()
result = ctask.prepare(func, *args, **kwargs)
--
To view, visit http://gerrit.ovirt.org/26809
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5034e6c3466d5a663699d4f924975b7e067c768
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: volume: prepare only one volume on clone
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: volume: prepare only one volume on clone
......................................................................
volume: prepare only one volume on clone
When we are cloning a volume we need only
Change-Id: Idc009fac4dc1a258537b0ffb15bd627680d79330
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/volume.py
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/20/26920/1
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index e1d3fc7..a36914f 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -271,7 +271,7 @@
wasleaf = True
self.setInternal()
try:
- self.prepare(rw=False)
+ self.prepare(rw=False, justme=True)
dst_path = os.path.join(dst_image_dir, dst_volUUID)
self.log.debug('cloning volume %s to %s', self.volumePath,
dst_path)
@@ -283,15 +283,15 @@
qemuimg.create(dst_path, backing=parent,
format=fmt2str(volFormat),
backingFormat=fmt2str(self.getFormat()))
- self.teardown(self.sdUUID, self.volUUID)
except Exception as e:
self.log.exception('cannot clone volume %s to %s',
self.volumePath, dst_path)
# FIXME: might race with other clones
if wasleaf:
self.setLeaf()
- self.teardown(self.sdUUID, self.volUUID)
raise se.CannotCloneVolume(self.volumePath, dst_path, str(e))
+ finally:
+ self.teardown(self.sdUUID, self.volUUID, justme=True)
def _shareLease(self, dstImgPath):
"""
--
To view, visit http://gerrit.ovirt.org/26920
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc009fac4dc1a258537b0ffb15bd627680d79330
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: sp: prevent master demotion on activation
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: sp: prevent master demotion on activation
......................................................................
sp: prevent master demotion on activation
Change-Id: I47a0c3ea16bcdefa99899e04c453eaf995344dfb
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/storage/sp.py
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/28332/1
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 3f983b6..3762c10 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -1041,7 +1041,15 @@
# Domain conversion requires the links to be present
self._refreshDomainLinks(dom)
- self._backend.setDomainRegularRole(dom)
+
+ # This should never happen because we're not deactivating the
+ # current master in deactivateStorageDomain if a new master is
+ # not provided. It is also impossible to connect to a pool
+ # where the master domain is not active. Anyway to be on the
+ # safe side we must prevent the current master domain from
+ # being demoted to regular.
+ if sdUUID != self.masterDomain.sdUUID:
+ self._backend.setDomainRegularRole(dom)
if dom.getDomainClass() == sd.DATA_DOMAIN:
self._convertDomain(dom)
--
To view, visit http://gerrit.ovirt.org/28332
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I47a0c3ea16bcdefa99899e04c453eaf995344dfb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: [WIP] BZ#844656 Release the lock during _findDomain
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: [WIP] BZ#844656 Release the lock during _findDomain
......................................................................
[WIP] BZ#844656 Release the lock during _findDomain
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
Change-Id: I8088d5fe716a3a08c3e5cef2d2d9a654ee96f60a
---
M vdsm/storage/sdc.py
1 file changed, 21 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/22/6822/1
--
To view, visit http://gerrit.ovirt.org/6822
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8088d5fe716a3a08c3e5cef2d2d9a654ee96f60a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: tests: Add storage mailbox tests
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: tests: Add storage mailbox tests
......................................................................
tests: Add storage mailbox tests
Use fake repository for testing the content of the storage mailbox
without using real block devices.
Change-Id: If02ed99b95dfd0d6bc5cc9694e60c3808d0974aa
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/Makefile.am
A tests/mailboxTests.py
2 files changed, 91 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/29371/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6507165..a1fd385 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,6 +46,7 @@
libvirtconnectionTests.py \
lsblkTests.py \
lvmTests.py \
+ mailboxTests.py \
main.py \
md_utils_tests.py \
miscTests.py \
diff --git a/tests/mailboxTests.py b/tests/mailboxTests.py
new file mode 100644
index 0000000..ec6854c
--- /dev/null
+++ b/tests/mailboxTests.py
@@ -0,0 +1,90 @@
+import ConfigParser
+import errno
+import os
+import time
+
+from storage import sd
+from storage import storage_mailbox
+from vdsm import config
+
+from testrunner import VdsmTestCase as TestCaseBase
+import monkeypatch
+
+# Don't use /tmp, as O_DIRECT does not work with tempfs file system. Keeping
+# the test files in the source is ugly but make it very easy to debug the
+# mailbox content.
+REPO_DIR = 'mailboxTests.tmp'
+
+HOST_ID = 1
+POOL_ID = 'pool'
+MD_DIR = os.path.join(REPO_DIR, POOL_ID, "mastersd", sd.DOMAIN_META_DATA)
+INBOX = os.path.join(MD_DIR, "inbox")
+OUTBOX = os.path.join(MD_DIR, "outbox")
+MAX_HOSTS = 2000
+
+# U (0x55) is a nice initial value
+DIRTY_MAILBOX = 'U' * storage_mailbox.MAILBOX_SIZE
+
+fake_config = ConfigParser.ConfigParser()
+config.set_defaults(fake_config)
+fake_config.set('irs', 'repository', REPO_DIR)
+
+
+class HSMMailboxTests(TestCaseBase):
+
+ def setUp(self):
+ # Note: we don't remove the inbox and outbox when test ends to make it
+ # eaiser to debug by checking inbox and outbox content after a test
+ # fails.
+ create_repository()
+ init_mailbox(INBOX)
+ init_mailbox(OUTBOX)
+
+ @monkeypatch.MonkeyPatch(storage_mailbox, 'config', fake_config)
+ def test_init_inbox(self):
+ mailer = storage_mailbox.HSM_Mailbox(HOST_ID, POOL_ID)
+ try:
+ time.sleep(0.5)
+ with open(INBOX) as f:
+ # First mailbox is not used
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, DIRTY_MAILBOX)
+ # When mailbox is started, it clears the host inbox
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, storage_mailbox.EMPTYMAILBOX)
+ # This mailbox belong to another host, and should not change
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, DIRTY_MAILBOX)
+ finally:
+ mailer.stop()
+
+ @monkeypatch.MonkeyPatch(storage_mailbox, 'config', fake_config)
+ def test_keep_outbox(self):
+ mailer = storage_mailbox.HSM_Mailbox(HOST_ID, POOL_ID)
+ try:
+ time.sleep(0.5)
+ with open(OUTBOX) as f:
+ # First mailbox is not used
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, DIRTY_MAILBOX)
+ # Outbox is not touched
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, DIRTY_MAILBOX)
+ # This mailbox belong to another host, and should not change
+ data = f.read(storage_mailbox.MAILBOX_SIZE)
+ self.assertEquals(data, DIRTY_MAILBOX)
+ finally:
+ mailer.stop()
+
+
+def init_mailbox(path):
+ with open(path, 'w') as f:
+ f.write(DIRTY_MAILBOX * MAX_HOSTS)
+
+
+def create_repository():
+ try:
+ os.makedirs(MD_DIR)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
--
To view, visit http://gerrit.ovirt.org/29371
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If02ed99b95dfd0d6bc5cc9694e60c3808d0974aa
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 5 months
Change in vdsm[master]: get the status of core dump
by shaohef@linux.vnet.ibm.com
ShaoHe Feng has uploaded a new change for review.
Change subject: get the status of core dump
......................................................................
get the status of core dump
Change-Id: I5d552db4dbd88762950ec5a113a25c13b73319c8
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/vm.py
M vdsm_api/vdsmapi-schema.json
M vdsm_cli/vdsClient.py
5 files changed, 36 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/11131/1
diff --git a/vdsm/API.py b/vdsm/API.py
index c5f7d40..6b4663a 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -302,6 +302,15 @@
return errCode['noVM']
return v.dumpCancel()
+ def dumpStatus(self):
+ """
+ Report status of a currently outgoing core dump process.
+ """
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.dumpStatus()
+
def desktopLock(self):
"""
Lock user session in guest operating system using guest agent.
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 17d97b1..b1f22fd 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -219,6 +219,10 @@
vm = API.VM(vmId)
return vm.dumpCancel()
+ def vmCoreDumpStatus(self, vmId):
+ vm = API.VM(vmId)
+ return vm.dumpStatus()
+
def vmReset(self, vmId):
vm = API.VM(vmId)
return vm.reset()
@@ -769,6 +773,7 @@
(self.vmCont, 'cont'),
(self.vmCoreDump, 'coreDump'),
(self.vmCoreDumpCancel, 'dumpCancel'),
+ (self.vmCoreDumpStatus, 'dumpStatus'),
(self.vmSnapshot, 'snapshot'),
(self.vmMerge, 'merge'),
(self.vmMergeStatus, 'mergeStatus'),
diff --git a/vdsm/vm.py b/vdsm/vm.py
index 0a40e97..5d9c0d9 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1371,3 +1371,6 @@
return reportError(msg=e.message)
finally:
self._guestCpuLock.release()
+
+ def dumpStatus(self):
+ return self._doCoredumpThread.getStat()
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 39d1cba..e96f01f 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5484,6 +5484,16 @@
{'command': {'class': 'VM', 'name': 'dumpCancel'}}
##
+# @VM.dumpStatus:
+#
+# Reports the state of the currently core dump process
+#
+# Since: 4.10.4
+#
+##
+{'command': {'class': 'VM', 'name': 'dumpStatus'}}
+
+##
# @VM.monitorCommand:
#
# Send a command to the qemu monitor.
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index 32ad348..7edc674 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -1674,6 +1674,11 @@
response = self.s.dumpCancel(vmId)
return response['status']['code'], response['status']['message']
+ def do_dumpStat(self, args):
+ vmId = args[0]
+ response = self.s.dumpStatus(vmId)
+ return response['status']['code'], response['status']['message']
+
def coreDump(self, args):
dumpParams = {'crash': False,
'live': False,
@@ -2422,6 +2427,10 @@
('<vmId>',
'cancel machine core dump'
)),
+ 'coreDumpStatus': (serv.do_dumpStat,
+ ('<vmId>',
+ 'Check the progress of current core dump'
+ )),
'coreDump': (serv.coreDump,
('<vmId> <file> [live=<True|False>] '
'[crash=<True|False>] [bypass-cache=<True|False>] '
--
To view, visit http://gerrit.ovirt.org/11131
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d552db4dbd88762950ec5a113a25c13b73319c8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
7 years, 5 months
Change in vdsm[master]: dump the core of a domain
by shaohef@linux.vnet.ibm.com
ShaoHe Feng has uploaded a new change for review.
Change subject: dump the core of a domain
......................................................................
dump the core of a domain
libvirt support an API to dump the core of a domain on a given file for
analysis when guest OS crash.
There are two kind of dump files. one is QEMU suspend to disk image.
the other is core file which like kdump file butcontains registers'
value.
It's helpful to support by VDSM to find root cause if a guest gets hang
and kdump isn't set up in it. This would be a good RAS feature.
Here's the definition of the new API:
coreDump:
This method will dump the core of a domain on a given file for
analysis.
Input parameter:
vmId - VM UUID
to - the core file named by the user
flags - defined in libvirt.py
VIR_DUMP_CRASH
VIR_DUMP_LIVE
VIR_DUMP_BYPASS_CACHE
VIR_DUMP_RESET
VIR_DUMP_MEMORY_ONLY
Return value:
success: return doneCode
failure: return errCode including underlying libvirt error message.
Change-Id: If4aac9e747dc7aa64a6ff5ef256a7a4375aa2bb5
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/libvirtvm.py
M vdsm_cli/vdsClient.py
5 files changed, 80 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/7329/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 19cbb42..e2b24cb 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -244,6 +244,12 @@
self.log.debug("Error creating VM", exc_info=True)
return errCode['unexpected']
+ def coreDump(self, to, flags):
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.coreDump(to, flags)
+
def desktopLock(self):
"""
Lock user session in guest operating system using guest agent.
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index cc5300f..be71e6a 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -208,6 +208,10 @@
vm = API.VM(vmId)
return vm.cont()
+ def vmCoreDump(self, vmId, to, flags):
+ vm = API.VM(vmId)
+ return vm.coreDump(to, flags)
+
def vmReset(self, vmId):
vm = API.VM(vmId)
return vm.reset()
@@ -725,6 +729,7 @@
(self.getVMList, 'list'),
(self.vmPause, 'pause'),
(self.vmCont, 'cont'),
+ (self.vmCoreDump, 'coreDump'),
(self.vmSnapshot, 'snapshot'),
(self.vmMerge, 'merge'),
(self.vmMergeStatus, 'mergeStatus'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 31deb4f..1fedac5 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -114,6 +114,10 @@
'mergeErr': {'status':
{'code': 52,
'message': 'Merge failed'}},
+ 'coreDumpErr': {'status':
+ {'code': 54,
+ 'message':
+ 'Failed to get coreDump file'}},
'recovery': {'status':
{'code': 99,
'message':
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 4554fee..cbd9f96 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1904,6 +1904,27 @@
self.saveState()
+ def coreDump(self, to, flags):
+
+ def reportError(key='coreDumpErr', msg=None):
+ self.log.error("get coreDump failed", exc_info=True)
+ if msg == None:
+ error = errCode[key]
+ else:
+ error = {'status' : {'code': errCode[key] \
+ ['status']['code'], 'message': msg}}
+ return error
+
+ if self._dom == None:
+ return reportError()
+ try:
+ self._dom.coreDump(to, flags)
+ except libvirt.libvirtError, e:
+ if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
+ return reportError(key='noVM')
+ return reportError(msg=e.message)
+ return {'status': doneCode}
+
def changeCD(self, drivespec):
return self._changeBlockDev('cdrom', 'hdc', drivespec)
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index eeb7c95..cdcd3a8 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -1589,6 +1589,33 @@
return status['status']['code'], status['status']['message']
+ def coreDump(self, args):
+ DUMPFLAGS = {'crash': 1 << 0,
+ 'live': 1 << 1,
+ 'bypass-cache': 1 << 2,
+ 'reset': 1 << 3,
+ 'memory-only': 1 << 4}
+ flags = 0
+ vmId = args[0]
+ coreFile = args[1]
+ params = {}
+ if len(args) > 2:
+ for arg in args[2:]:
+ kv = arg.split('=', 1)
+ if len(kv) < 2:
+ params[kv[0]] = "True"
+ else:
+ params[kv[0]] = kv[1]
+ for k, v in params.items():
+ if v.lower() == "true" or not v:
+ try:
+ flags = flags + DUMPFLAGS[k]
+ except KeyError:
+ print "unrecognized optoin %s for cormDump command" % k
+ response = self.s.coreDump(vmId, coreFile, flags)
+ return response['status']['code'], response['status']['message']
+
+
if __name__ == '__main__':
if _glusterEnabled:
serv = ge.GlusterService()
@@ -2239,6 +2266,23 @@
('<vmId> <sdUUID> <imgUUID> <baseVolUUID> <volUUID>',
"Take a live snapshot"
)),
+ 'coreDump': (serv.coreDump,
+ ('<vmId> <file> [live=<True>] '
+ '[crash=<True>] [bypass-cache=<True>] '
+ '[reset=<True>] [memory-only=<True>]',
+ "get memeory dump or migration file"
+ 'optional params:',
+ 'crash: crash the domain after core dump'
+ 'default False',
+ 'live: perform a live core dump if supported, '
+ 'default False',
+ 'bypass-cache: avoid file system cache when saving'
+ 'default False',
+ 'reset: reset the domain after core dump'
+ 'default False',
+ "memory-only: dump domain's memory only"
+ 'default False'
+ )),
}
if _glusterEnabled:
commands.update(ge.getGlusterCmdDict(serv))
--
To view, visit http://gerrit.ovirt.org/7329
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If4aac9e747dc7aa64a6ff5ef256a7a4375aa2bb5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
7 years, 5 months
Change in vdsm[master]: cancel the core dump of a VM
by shaohef@linux.vnet.ibm.com
ShaoHe Feng has uploaded a new change for review.
Change subject: cancel the core dump of a VM
......................................................................
cancel the core dump of a VM
Change-Id: I2fa9e82cfbd43c9edb98fac9af41eb0deb0c67ad
Signed-off-by: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
---
M vdsm/API.py
M vdsm/BindingXMLRPC.py
M vdsm/define.py
M vdsm/vm.py
M vdsm_api/vdsmapi-schema.json
M vdsm_cli/vdsClient.py
6 files changed, 62 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/30/11130/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 4f5eed8..c5f7d40 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -293,6 +293,15 @@
return errCode['noVM']
return v.coreDump(to, dumpParams)
+ def dumpCancel(self):
+ """
+ Cancel a currently outgoing core dump process.
+ """
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.dumpCancel()
+
def desktopLock(self):
"""
Lock user session in guest operating system using guest agent.
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 9fcbefd..17d97b1 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -215,6 +215,10 @@
vm = API.VM(vmId)
return vm.coreDump(to, params)
+ def vmCoreDumpCancel(self, vmId):
+ vm = API.VM(vmId)
+ return vm.dumpCancel()
+
def vmReset(self, vmId):
vm = API.VM(vmId)
return vm.reset()
@@ -764,6 +768,7 @@
(self.vmPause, 'pause'),
(self.vmCont, 'cont'),
(self.vmCoreDump, 'coreDump'),
+ (self.vmCoreDumpCancel, 'dumpCancel'),
(self.vmSnapshot, 'snapshot'),
(self.vmMerge, 'merge'),
(self.vmMergeStatus, 'mergeStatus'),
diff --git a/vdsm/define.py b/vdsm/define.py
index 84aacad..e1d428c 100644
--- a/vdsm/define.py
+++ b/vdsm/define.py
@@ -134,6 +134,9 @@
{'code': 58,
'message':
'Failed to generate coreDump file'}},
+ 'dumpCancelErr': {'status':
+ {'code': 59,
+ 'message': 'Failed to cancel dump'}},
'recovery': {'status':
{'code': 99,
'message':
diff --git a/vdsm/vm.py b/vdsm/vm.py
index be947c6..0a40e97 100644
--- a/vdsm/vm.py
+++ b/vdsm/vm.py
@@ -1345,3 +1345,29 @@
return check
finally:
self._guestCpuLock.release()
+
+ def dumpCancel(self):
+ def reportError(self, key='dumpCancelErr', msg=None):
+ if msg is None:
+ error = errCode[key]
+ else:
+ error = {'status':
+ {'code': errCode[key]['status']['code'],
+ 'message': msg}}
+ self.log.error("Failed to cancel core dump. " + msg,
+ exc_info=True)
+ return error
+
+ self._acquireCpuLockWithTimeout()
+ try:
+ if not self.isDoingDump():
+ return reportError(msg='no core dump in process')
+ if self.dumpMode() == "memory":
+ return reportError(msg='invalid to cancel memory dump')
+ self._doCoredumpThread.stop()
+ return {'status': {'code': 0,
+ 'message': 'core dump process stopped'}}
+ except Exception, e:
+ return reportError(msg=e.message)
+ finally:
+ self._guestCpuLock.release()
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 63b0fb1..39d1cba 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -5474,6 +5474,16 @@
'data': {'to': 'str', 'params': 'DumpParams'}}
##
+# @VM.dumpCancel:
+#
+# Cancel the currently outgoing core dump process.
+#
+# Since: 4.10.4
+#
+##
+{'command': {'class': 'VM', 'name': 'dumpCancel'}}
+
+##
# @VM.monitorCommand:
#
# Send a command to the qemu monitor.
diff --git a/vdsm_cli/vdsClient.py b/vdsm_cli/vdsClient.py
index c4171d9..32ad348 100644
--- a/vdsm_cli/vdsClient.py
+++ b/vdsm_cli/vdsClient.py
@@ -1669,6 +1669,11 @@
return status['status']['code'], status['status']['message']
+ def do_dumpCancel(self, args):
+ vmId = args[0]
+ response = self.s.dumpCancel(vmId)
+ return response['status']['code'], response['status']['message']
+
def coreDump(self, args):
dumpParams = {'crash': False,
'live': False,
@@ -2413,6 +2418,10 @@
'Start live replication to the destination '
'domain'
)),
+ 'coreDumpCancel': (serv.do_dumpCancel,
+ ('<vmId>',
+ 'cancel machine core dump'
+ )),
'coreDump': (serv.coreDump,
('<vmId> <file> [live=<True|False>] '
'[crash=<True|False>] [bypass-cache=<True|False>] '
--
To view, visit http://gerrit.ovirt.org/11130
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2fa9e82cfbd43c9edb98fac9af41eb0deb0c67ad
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef(a)linux.vnet.ibm.com>
7 years, 5 months