Change in vdsm[master]: virt: enable libgfapi with snapshot support

prasanna.kalever at redhat.com prasanna.kalever at redhat.com
Mon May 2 12:01:37 UTC 2016


Hello Ala Hino,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/56906

to review the following change.

Change subject: virt: enable libgfapi with snapshot support
......................................................................

virt: enable libgfapi with snapshot support

Change-Id: Ibbdedb8bf012fae2f69f4c8c5e952f5eb5ef9132
Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
Signed-off-by: Ala Hino <ahino at redhat.com>
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 25 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/56906/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 8ac6242..97d662d 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -3185,20 +3185,33 @@
     def snapshot(self, snapDrives, memoryParams, frozen=False):
         """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']['port'],
+                    'transport': newDriveDict['volumeInfo']['transport']})
+            else:
+                sourceAttrs.update({'file': 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):
@@ -3323,9 +3336,8 @@
                 _rollbackDrives(preparedDrives)
                 return response.error('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 https://gerrit.ovirt.org/56906
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibbdedb8bf012fae2f69f4c8c5e952f5eb5ef9132
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Prasanna Kumar Kalever <prasanna.kalever at redhat.com>
Gerrit-Reviewer: Ala Hino <ahino at redhat.com>


More information about the vdsm-patches mailing list