Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 900481 Details for
Bug 1102881
virDomainBlockCommit fails with live snapshots on oVirt block storage
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
Test script to create two live snapshots
vdsm-test.py (text/plain), 5.22 KB, created by
Adam Litke
on 2014-05-29 18:31:01 UTC
(
hide
)
Description:
Test script to create two live snapshots
Filename:
MIME Type:
Creator:
Adam Litke
Created:
2014-05-29 18:31:01 UTC
Size:
5.22 KB
patch
obsolete
>import sys >import time >import uuid >import os.path >from vdsm import vdscli > >ssl = True > >def vdsOK(res): > code = res['status']['code'] > if code not in (0, ): > raise Exception("Vdsm error: %s" % res) > >def waitTask(s, taskId): > print "Waiting for task %s" % taskId > for i in xrange(60): > res = s.getAllTasksStatuses() > vdsOK(res) > try: > task = res['allTasksStatus'][taskId] > except KeyError: > raise Exception("Task '%s' not found" % taskId) > if (task['taskState'] == 'finished' and > task['taskResult'] == 'success'): > print "%s: %s" % (taskId, task['taskState']) > s.clearTask(taskId) > return True > time.sleep(1) > s.clearTask(taskId) > raise Exception("Timeout while waiting for task: %s" % task) > >def findDisk(s, vmId): > res = s.list(True, [vmId]) > vdsOK(res) > vmInfo = res['vmList'][0] > disks = [x for x in vmInfo['devices'] if x['type'] == 'disk' > and x['device'] == 'disk'] > if len(disks) != 1: > raise Exception("Expecting one and only one Vm Disk") > return disks[0] > >def getVolumeChain(s, vmId, disk): > sp = disk['poolID'] > sd = disk['domainID'] > img = disk['imageID'] > vol = disk['volumeID'] > > res = s.list(True, [vmId]) > vdsOK(res) > vm = res['vmList'][0] > for dev in vm['devices']: > if dev.get('imageID') != img: > continue > return [x['volumeID'] for x in dev['volumeChain']] > raise Exception("disk not found") > >def getOrderedVolumeChain(s, vmId, disk): > sp = disk['poolID'] > sd = disk['domainID'] > img = disk['imageID'] > chain = getVolumeChain(s, vmId, disk) > > parentMap = {} > for vol in chain: > res = s.getVolumeInfo(sd, sp, img, vol) > vdsOK(res) > parent = res['info']['parent'] > parentMap[vol] = parent > > vol = disk['volumeID'] > chain = list() > while True: > chain.insert(0, vol) > vol = parentMap[vol] > if vol == '00000000-0000-0000-0000-000000000000': > break > return chain > >def printVolumeChain(chain): > print 'Current volume chain:', ', '.join(chain) > >def printParameters(vmId, disk): > print "Basic test parameters:" > print "vm=%s\nsp=%s\nsd=%s\nimg=%s\nvol=%s" % (vmId, disk['poolID'], > disk['domainID'], disk['imageID'], disk['volumeID']) > >def createVolume(s, disk): > ''' > Create a new snapshot volume that is compatible with this disk > ''' > sd = disk['domainID'] > sp = disk['poolID'] > img = disk['imageID'] > vol = disk['volumeID'] > newVol = str(uuid.uuid4()) > > print "Creating volume: %s" % newVol > res = s.getVolumeInfo(sd, sp, img, vol) > vdsOK(res) > volInfo = res['info'] > size = volInfo['capacity'] > volFormat = 4 # COW > preallocate = 2 # SPARSE > diskType = volInfo['disktype'] > desc = 'snapshot for %s' % vol > res = s.createVolume(sd, sp, img, size, volFormat, preallocate, diskType, > newVol, desc, img, vol) > vdsOK(res) > taskId = res['uuid'] > waitTask(s, taskId) > return newVol > >def createSnapshot(s, vmId, disk, volUUID): > snapDisk = {'domainID': disk['domainID'], > 'imageID': disk['imageID'], > 'volumeID': volUUID, > 'baseVolumeID': disk['volumeID']} > print "Creating snapshot %s (base %s)" % (volUUID, disk['volumeID']) > res = s.snapshot(vmId, [snapDisk]) > vdsOK(res) > >def findSpmHost(pool, hosts): > for h in hosts: > s = vdscli.connect(h, ssl, None) > res = s.getSpmStatus(pool) > vdsOK(res) > if res['spm_st']['spmStatus'] == 'SPM': > return s > raise Exception("Unable to find an SPM host") > >def findHsmHost(hosts): > for h in hosts: > s = vdscli.connect(h, ssl, None) > res = s.list(True) > vdsOK(res) > if len(res['vmList']) == 1: > vmId = res['vmList'][0]['vmId'] > return s, vmId > raise Exception("Unable to find a host with exactly one VM running") > >def testMergeInternal(spmHost, hsmHost, vmId): > disk = findDisk(hsmHost, vmId) > orig_chain = getOrderedVolumeChain(hsmHost, vmId, disk) > expected_chain = orig_chain[:] > snapshots = [] > > print "Running test: merge internal snapshot" > printParameters(vmId, disk) > > # Create two snapshots > for i in xrange(2): > topVol = disk['volumeID'] > volUUID = createVolume(spmHost, disk) > createSnapshot(hsmHost, vmId, disk, volUUID) > disk = findDisk(hsmHost, vmId) > snapshots.append(topVol) > expected_chain.append(volUUID) > printVolumeChain(getVolumeChain(hsmHost, vmId, disk)) > > # Merge internal snapshot > base = snapshots[0] > top = snapshots[1] > > image_path = os.path.dirname(disk['path']) > base_path = os.path.join(image_path, base) > top_path = os.path.join(image_path, top) > print """ > Issue the following command on the host where the vm is running: > virsh blockcommit %s %s --base %s --top %s > """ % (vmId, disk['path'], base_path, top_path) > > > >def main(): > pool = sys.argv[1] > hosts = sys.argv[2:] > spmHost = findSpmHost(pool, hosts) > hsmHost, vmId = findHsmHost(hosts) > > testMergeInternal(spmHost, hsmHost, vmId) > sys.exit(0) > >if __name__ == '__main__': > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1102881
: 900481 |
900482
|
900483
|
900484
|
900523
|
901471
|
901490
|
922603
|
922604
|
922606
|
922607
|
923330