Federico Simoncelli has uploaded a new change for review.
Change subject: vm: update volume apparentsize after snapshot
......................................................................
vm: update volume apparentsize after snapshot
After a live snapshot succeeded we need to force the update of the
volume apparentsize to avoid races in the extension requests.
Bug-Url:
https://bugzilla.redhat.com/show_bug.cgi?id=923964
Change-Id: I472c2931551643914e6a09b54d3d96f371f34864
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M vdsm/libvirtvm.py
1 file changed, 41 insertions(+), 25 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/46/13346/1
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index cb792b5..8e4f5ce 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -146,16 +146,7 @@
return
for vmDrive in self._vm._devices[vm.DISK_DEVICES]:
- if vmDrive.device == 'disk' and vmDrive.isVdsmImage():
- volSize = self._vm.cif.irs.getVolumeSize(
- vmDrive.domainID, vmDrive.poolID, vmDrive.imageID,
- vmDrive.volumeID)
-
- if volSize['status']['code'] != 0:
- continue
-
- vmDrive.truesize = int(volSize['truesize'])
- vmDrive.apparentsize = int(volSize['apparentsize'])
+ self._vm.updateDriveVolume(vmDrive)
def _sampleCpu(self):
cpuStats = self._vm._dom.getCPUStats(True, 0)
@@ -1929,28 +1920,47 @@
raise LookupError("No such drive: '%s'" % drive)
- def _updateDrive(self, drive):
+ def updateDriveVolume(self, vmDrive):
+ if not vmDrive.device == 'disk' or not vmDrive.isVdsmImage():
+ return
+
+ volSize = self.cif.irs.getVolumeSize(
+ vmDrive.domainID, vmDrive.poolID, vmDrive.imageID,
+ vmDrive.volumeID)
+
+ if volSize['status']['code'] != 0:
+ self.log.error(
+ "Unable to update the volume %s (domain: %s image: %s) "
+ "for the drive %s" % (vmDrive.volumeID, vmDrive.domainID,
+ vmDrive.imageID, vmDrive.name))
+ return
+
+ vmDrive.truesize = int(volSize['truesize'])
+ vmDrive.apparentsize = int(volSize['apparentsize'])
+
+ def updateDriveParameters(self, driveParams):
"""Update the drive with the new volume
information"""
- # Updating the drive object
- for device in self._devices[vm.DISK_DEVICES][:]:
- if device.name == drive["name"]:
- for k, v in drive.iteritems():
- setattr(device, k, v)
+ # Updating the vmDrive object
+ for vmDrive in self._devices[vm.DISK_DEVICES][:]:
+ if vmDrive.name == driveParams["name"]:
+ for k, v in driveParams.iteritems():
+ setattr(vmDrive, k, v)
+ self.updateDriveVolume(vmDrive)
break
else:
self.log.error("Unable to update the drive object for: %s",
- drive["name"])
+ driveParams["name"])
# Updating the VM configuration
- for device in self.conf["devices"][:]:
- if (device['type'] == vm.DISK_DEVICES and
- device.get("name") == drive["name"]):
- device.update(drive)
+ for vmDriveConfig in self.conf["devices"][:]:
+ if (vmDriveConfig['type'] == vm.DISK_DEVICES and
+ vmDriveConfig.get("name") ==
driveParams["name"]):
+ vmDriveConfig.update(driveParams)
break
else:
self.log.error("Unable to update the device configuration ",
- "for: %s", drive["name"])
+ "for: %s", driveParams["name"])
self.saveState()
@@ -2055,6 +2065,12 @@
snapxml = snap.toprettyxml()
self.log.debug(snapxml)
+
+ # We need to stop the collection of the stats for two reasons, one
+ # is to prevent spurious libvirt errors about missing drive paths
+ # (since we're changing them), and also to prevent to trigger a drive
+ # extension for the new volume with the apparent size of the old one
+ # (the apparentsize is updated as last step in updateDriveParameters)
self.stopDisksStatsCollection()
snapFlags = (libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY |
@@ -2089,7 +2105,7 @@
else:
# Update the drive information
for drive in newDrives.values():
- self._updateDrive(drive)
+ self.updateDriveParameters(drive)
finally:
self.startDisksStatsCollection()
@@ -2315,7 +2331,7 @@
# Updating the destination disk device and name, the device is used by
# prepareVolumePath (required to fill the new information as the path)
- # and the name is used by _updateDrive.
+ # and the name is used by updateDriveParameters.
dstDiskCopy.update({'device': srcDrive.device, 'name':
srcDrive.name})
dstDiskCopy['path'] = self.cif.prepareVolumePath(dstDiskCopy)
@@ -2356,7 +2372,7 @@
# There is nothing we can do at this point other than logging
self.log.error("Unable to teardown the previous chain: %s",
diskToTeardown, exc_info=True)
- self._updateDrive(dstDiskCopy) # Updating the drive structure
+ self.updateDriveParameters(dstDiskCopy)
finally:
self._delDiskReplica(srcDrive)
self.startDisksStatsCollection()
--
To view, visit
http://gerrit.ovirt.org/13346
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I472c2931551643914e6a09b54d3d96f371f34864
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>