Change in vdsm[master]: virt-sparsify: add in-place sparsify support
shavivi at redhat.com
shavivi at redhat.com
Tue Feb 23 12:10:00 UTC 2016
Shahar Havivi has uploaded a new change for review.
Change subject: virt-sparsify: add in-place sparsify support
......................................................................
virt-sparsify: add in-place sparsify support
Change-Id: Icef4021567df5da1cd5b74a94c2d76fefcde3aba
Signed-off-by: Shahar Havivi <shaharh at redhat.com>
---
M lib/api/vdsmapi-schema.json
M lib/vdsm/virtsparsify.py
M vdsm/API.py
3 files changed, 69 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/53900/1
diff --git a/lib/api/vdsmapi-schema.json b/lib/api/vdsmapi-schema.json
index 69a6802..b5812b7 100644
--- a/lib/api/vdsmapi-schema.json
+++ b/lib/api/vdsmapi-schema.json
@@ -8307,6 +8307,25 @@
'data': {'vmID': 'UUID', 'drive': 'DriveSpecVolume', 'baseVolUUID': 'UUID',
'topVolUUID': 'UUID', '*bandwidth': 'int', '*jobUUID': 'UUID'}}
+##
+# @VM.sparsifyInplace:
+#
+# Perform an in-place sparse (e.g. not creating a new image) on given volume
+#
+# @vmID: The UUID of the VM
+#
+# @drive: A @DriveSpecVolume structure representing the disk
+#
+# @topVolUUID: The UUID of the sparsed volume
+#
+# @jobUUID: #optional Assign a UUID to this operation which can be used
+# to identify it in @VmStats
+#
+# Since: 4.15.0
+##
+{'command': {'class': 'VM', 'name': 'sparsifyInplace'},
+ 'data': {'vmID': 'UUID', 'drive': 'DriveSpecVolume', 'baseVolUUID': 'UUID',
+ 'topVolUUID': 'UUID', '*bandwidth': 'int', '*jobUUID': 'UUID'}}
## Category: @Volume ##########################################################
##
diff --git a/lib/vdsm/virtsparsify.py b/lib/vdsm/virtsparsify.py
index c4a63e5..6ba3fd5 100644
--- a/lib/vdsm/virtsparsify.py
+++ b/lib/vdsm/virtsparsify.py
@@ -20,9 +20,12 @@
from __future__ import absolute_import
import signal
+from uuid import uuid4
from . import cmdutils
from . import commands
+from . import concurrent
+from . import jobs
from . import utils
# Fedora, EL6
@@ -55,3 +58,44 @@
if rc != 0:
raise cmdutils.Error(cmd, rc, out, err)
+
+
+def inplace(self, vol):
+ """
+ Sparsify the volume in place
+ (instead of copying from an input disk to an output disk)
+ """
+ job = InplaceJob()
+ job.start()
+ jobs.add(job)
+
+
+def delete_inplace_job(job_id):
+ return jobs.delete(job_id)
+
+
+def abort_inplace_job(job_id):
+ return jobs.abort(job_id)
+
+
+class InplaceJob(jobs.Job):
+ def __init__(self):
+ self._id = uuid()
+ self._thread = None
+
+ def start(self):
+ self._thread = concurrent.thread(self._run)
+ self.jobs.add(self._id)
+ self._thread.start()
+
+ def _run(self):
+ cmd = [_VIRTSPARSIFY.cmd, '--machine-readable', '--in-place', vol]
+ return execCmd(cmd,
+ sync=False,
+ deathSignal=signal.SIGTERM,
+ env={'LIBGUESTFS_BACKEND': 'direct'})
+ self._proc = commands.execCmd(cmd,
+ env={'LIBGUESTFS_BACKEND': 'direct'})
+
+ if rc != 0:
+ raise cmdutils.Error(cmd, rc, out, err)
diff --git a/vdsm/API.py b/vdsm/API.py
index 2f7d04d..e843c96 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -809,6 +809,12 @@
return errCode['noVM']
return v.merge(drive, baseVolUUID, topVolUUID, bandwidth, jobUUID)
+ def sparsifyInplace(self, drive, volUUID, jobUUID=None):
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.sparsifyInplace(drive, volUUID, jobUUID)
+
class Volume(APIBase):
ctorArgs = ['volumeID', 'storagepoolID', 'storagedomainID', 'imageID']
--
To view, visit https://gerrit.ovirt.org/53900
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icef4021567df5da1cd5b74a94c2d76fefcde3aba
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi at redhat.com>
More information about the vdsm-patches
mailing list