summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Neumoin <kneumoin@virtuozzo.com>2017-04-14 17:53:53 +0300
committerMaxim Nestratov <mnestratov@virtuozzo.com>2017-04-17 20:42:33 +0300
commitf99bc451feba8ebc00fc04a2cf6267bd2af29576 (patch)
treef6320385ef296cf3ef404975728936ce3eae43b2 /src
parentd678379df1967d18b050fedc1ab674391b3629f5 (diff)
downloadlibvirt-f99bc451feba8ebc00fc04a2cf6267bd2af29576.tar.gz
vz: support virDomainBlockResize
Acked-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Konstantin Neumoin <kneumoin@virtuozzo.com>
Diffstat (limited to 'src')
-rw-r--r--src/vz/vz_driver.c58
-rw-r--r--src/vz/vz_sdk.c37
-rw-r--r--src/vz/vz_sdk.h1
3 files changed, 96 insertions, 0 deletions
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index ed7132f213..059e7c9f4d 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3945,6 +3945,63 @@ static int vzDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
return vzDomainSetVcpusFlags(dom, nvcpus,
VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
}
+static int
+vzDomainBlockResize(virDomainPtr domain,
+ const char *path,
+ unsigned long long size,
+ unsigned int flags)
+{
+ virDomainObjPtr dom = NULL;
+ virDomainDiskDefPtr disk = NULL;
+ int ret = -1;
+ bool job = false;
+
+ virCheckFlags(VIR_DOMAIN_BLOCK_RESIZE_BYTES, -1);
+
+ if (!(dom = vzDomObjFromDomainRef(domain)))
+ goto cleanup;
+
+ if (virDomainBlockResizeEnsureACL(domain->conn, dom->def) < 0)
+ goto cleanup;
+
+ if (path[0] == '\0') {
+ virReportError(VIR_ERR_INVALID_ARG,
+ "%s", _("empty path"));
+ goto cleanup;
+ }
+
+ /* sdk wants Mb */
+ if (flags & VIR_DOMAIN_BLOCK_RESIZE_BYTES)
+ size /= 1024;
+ size /= 1024;
+
+ if (!(disk = virDomainDiskByName(dom->def, path, false))) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("invalid path: %s"), path);
+ goto cleanup;
+ }
+
+ if (vzDomainObjBeginJob(dom) < 0)
+ goto cleanup;
+ job = true;
+
+ if (vzEnsureDomainExists(dom) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(dom)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
+ ret = prlsdkResizeImage(dom, disk, size);
+
+ cleanup:
+ if (job)
+ vzDomainObjEndJob(dom);
+ virDomainObjEndAPI(&dom);
+ return ret;
+}
static virHypervisorDriver vzHypervisorDriver = {
.name = "vz",
@@ -4046,6 +4103,7 @@ static virHypervisorDriver vzHypervisorDriver = {
.connectGetAllDomainStats = vzConnectGetAllDomainStats, /* 3.1.0 */
.domainAbortJob = vzDomainAbortJob, /* 3.1.0 */
.domainReset = vzDomainReset, /* 3.1.0 */
+ .domainBlockResize = vzDomainBlockResize, /* 3.3.0 */
};
static virConnectDriver vzConnectDriver = {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 2daa44a900..4d2c6b0f1e 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -4925,3 +4925,40 @@ int prlsdkSetCpuCount(virDomainObjPtr dom, unsigned int count)
error:
return -1;
}
+
+int prlsdkResizeImage(virDomainObjPtr dom, virDomainDiskDefPtr disk,
+ unsigned long long newsize)
+{
+ int ret = -1;
+ PRL_RESULT pret;
+ vzDomObjPtr privdom = dom->privateData;
+ PRL_UINT32 emulatedType;
+ PRL_HANDLE job = PRL_INVALID_HANDLE;
+ PRL_HANDLE prldisk = PRL_INVALID_HANDLE;
+
+ prldisk = prlsdkGetDisk(privdom->sdkdom, disk);
+ if (prldisk == PRL_INVALID_HANDLE)
+ goto cleanup;
+
+ pret = PrlVmDev_GetEmulatedType(prldisk, &emulatedType);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ if (emulatedType != PDT_USE_IMAGE_FILE &&
+ emulatedType != PDT_USE_FILE_SYSTEM) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Only disk image supported for resize"));
+ goto cleanup;
+ }
+
+ job = PrlVmDev_ResizeImage(prldisk, newsize,
+ PRIF_RESIZE_LAST_PARTITION);
+ if (PRL_FAILED(waitJob(job)))
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+
+ PrlHandle_Free(prldisk);
+ return ret;
+}
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index 100a5e315b..0a77431db5 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -90,3 +90,4 @@ prlsdkMigrate(virDomainObjPtr dom,
PRL_HANDLE
prlsdkSdkDomainLookupByName(vzDriverPtr driver, const char *name);
int prlsdkCancelJob(virDomainObjPtr dom);
+int prlsdkResizeImage(virDomainObjPtr dom, virDomainDiskDefPtr disk, unsigned long long newsize);