Change in vdsm[ovirt-3.5]: virt: enable libgfapi with snapshot support

Federico Simoncelli fsimonce at redhat.com
Fri Jan 16 15:13:03 UTC 2015


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 <fsimonce at redhat.com>
---
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/01/37001/1

diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 45f1694..c994249 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3220,8 +3220,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)
 
@@ -3232,8 +3231,8 @@
                 })
 
             imgVolumesInfo.append(volInfo)
-            if volUUID == leafUUID:
-                leafInfo = volInfo
+
+        leafInfo = dom.produceVolume(imgUUID, leafUUID).getVmVolumeInfo()
 
         return {'path': leafPath, 'info': leafInfo,
                 'imgVolumesInfo': imgVolumesInfo}
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index c892e66..2bcf35a 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4251,20 +4251,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 = XMLElement('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):
@@ -4395,9 +4418,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/37001
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie0965bef605ba67297670c0bf7924f88fa3b0460
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>


More information about the vdsm-patches mailing list