Federico Simoncelli has uploaded a new change for review. Change subject: virt: enable libgfapi with snapshot support ......................................................................
virt: enable libgfapi with snapshot support Change-Id: Ie0965bef605ba67297670c0bf7924f88fa3b0460 Signed-off-by: Federico Simoncelli <[email protected]> --- M vdsm/storage/hsm.py M vdsm/virt/vm.py 2 files changed, 38 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/33768/1 diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index cd6f4b9..bde04be 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -3225,8 +3225,7 @@ path = os.path.join(dom.domaindir, sd.DOMAIN_IMAGES, imgUUID, volUUID) volInfo = {'domainID': sdUUID, 'imageID': imgUUID, - 'volumeID': volUUID, 'path': path, - 'volType': "path"} + 'volumeID': volUUID, 'path': path} leasePath, leaseOffset = dom.getVolumeLease(imgUUID, volUUID) @@ -3237,8 +3236,8 @@ }) imgVolumesInfo.append(volInfo) - if volUUID == leafUUID: - leafInfo = volInfo + + leafInfo = dom.produceVolume(imgUUID, volUUID).getVmVolumeInfo() return {'path': leafPath, 'info': leafInfo, 'imgVolumesInfo': imgVolumesInfo} diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 1eebb69..af0830a 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -3821,20 +3821,43 @@ def snapshot(self, snapDrives, memoryParams): """Live snapshot command""" - def _diskSnapshot(vmDev, newPath, sourceType): + def _diskSnapshot(vmDev, oldDrive, newDriveDict): """Libvirt snapshot XML""" + sourceType = 'file' + sourceAttrs = {} + hostAttrs = {} + + # TODO: unify these with the Drive.getXML() method + if oldDrive.networkDev: + sourceType = 'network' + sourceAttrs.update({ + 'name': newDriveDict['volumeInfo']['path'], + 'protocol': newDriveDict['volumeInfo']['protocol']}) + hostAttrs.update({ + 'name': newDriveDict['volumeInfo']['volfileServer'], + 'port': newDriveDict['volumeInfo']['volPort'], + 'transport': newDriveDict['volumeInfo']['volTransport']}) + else: + sourceAttrs.update({'file': newDriveDict['path']}) + + # Libvirt versions before 1.2.2 do not understand 'type' + # and treat all snapshots as if they are type='file'. + # In order to ensure proper handling of block snapshots + # in modern libvirt versions, we specify type='block' + # and dev=path for block volumes but we always speficy + # the file=path for backwards compatibility. + if oldDrive.blockDev: + sourceType = 'block' + sourceAttrs.update({'dev': newDriveDict['path']}) disk = vmxml.Element('disk', name=vmDev, snapshot='external', type=sourceType) - # Libvirt versions before 1.2.2 do not understand 'type' and treat - # all snapshots as if they are type='file'. In order to ensure - # proper handling of block snapshots in modern libvirt versions, - # we specify type='block' and dev=path for block volumes but we - # always speficy the file=path for backwards compatibility. - args = {'type': sourceType, 'file': newPath} - if sourceType == 'block': - args['dev'] = newPath - disk.appendChildWithArgs('source', **args) + + source = disk.appendChildWithArgs('source', **sourceAttrs) + + if hostAttrs: + source.appendChildWithArgs('host', **hostAttrs) + return disk def _normSnapDriveParams(drive): @@ -3964,9 +3987,8 @@ _rollbackDrives(preparedDrives) return errCode['snapshotErr'] - snapType = 'block' if vmDrives[vmDevName].blockDev else 'file' - snapelem = _diskSnapshot(vmDevName, newDrives[vmDevName]["path"], - snapType) + snapelem = _diskSnapshot(vmDevName, vmDrives[vmDevName], + newDrives[vmDevName]) disks.appendChild(snapelem) snap.appendChild(disks) -- To view, visit http://gerrit.ovirt.org/33768 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie0965bef605ba67297670c0bf7924f88fa3b0460 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
