In prlsdkAddDisk() we try to check disk format, before adding disk.
If disk format is not specified in XML (VIR_STORAGE_FILE_NONE) than we accept this disk.
Otherwise we try to find disk format in connection struct.
---
src/vz/vz_driver.c | 2 +-
src/vz/vz_sdk.c | 28 ++++++++++++++++++++--------
src/vz/vz_sdk.h | 2 +-
src/vz/vz_utils.c | 11 +++++++++++
src/vz/vz_utils.h | 4 ++++
5 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 82eba27..c1ccbc5 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1070,7 +1070,7 @@ static int vzDomainAttachDeviceFlags(virDomainPtr dom, const char
*xml,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
- ret = prlsdkAttachVolume(privdom, dev->data.disk);
+ ret = prlsdkAttachVolume(privconn, privdom, dev->data.disk);
if (ret) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("disk attach failed"));
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 92bb7c5..0bd80f0 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3106,7 +3106,8 @@ static int prlsdkDelDisk(PRL_HANDLE sdkdom, int idx)
return ret;
}
-static int prlsdkAddDisk(PRL_HANDLE sdkdom,
+static int prlsdkAddDisk(vzConnPtr privconn,
+ PRL_HANDLE sdkdom,
virDomainDiskDefPtr disk,
bool bootDisk,
bool isCt)
@@ -3141,11 +3142,12 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
- virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_PLOOP) {
+ virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
+ !vzCheckDiskFormat(privconn, virDomainDiskGetFormat(disk), isCt)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format of "
- "disk %s, vz driver
supports only "
- "images in ploop
format."), disk->src->path);
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported format of disk %s"),
+ disk->src->path);
goto cleanup;
}
@@ -3287,7 +3289,9 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
}
int
-prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
+prlsdkAttachVolume(vzConnPtr privconn,
+ virDomainObjPtr dom,
+ virDomainDiskDefPtr disk)
{
int ret = -1;
vzDomObjPtr privdom = dom->privateData;
@@ -3297,7 +3301,11 @@ prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
if (PRL_FAILED(waitJob(job)))
goto cleanup;
- ret = prlsdkAddDisk(privdom->sdkdom, disk, false, IS_CT(dom->def));
+ ret = prlsdkAddDisk(privconn,
+ privdom->sdkdom,
+ disk,
+ false,
+ IS_CT(dom->def));
if (ret == 0) {
job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
if (PRL_FAILED(waitJob(job))) {
@@ -3528,7 +3536,11 @@ prlsdkDoApplyConfig(virConnectPtr conn,
needBoot = false;
bootDisk = true;
}
- if (prlsdkAddDisk(sdkdom, def->disks[i], bootDisk, IS_CT(def)) < 0)
+ if (prlsdkAddDisk(conn->privateData,
+ sdkdom,
+ def->disks[i],
+ bootDisk,
+ IS_CT(def)) < 0)
goto error;
}
diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h
index c2d9cb4..8a38797 100644
--- a/src/vz/vz_sdk.h
+++ b/src/vz/vz_sdk.h
@@ -63,7 +63,7 @@ prlsdkUnregisterDomain(vzConnPtr privconn, virDomainObjPtr dom, unsigned
int fla
int
prlsdkDomainManagedSaveRemove(virDomainObjPtr dom);
int
-prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
+prlsdkAttachVolume(vzConnPtr privconn, virDomainObjPtr dom, virDomainDiskDefPtr disk);
int
prlsdkDetachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
int
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index f7db9cf..e2be56d 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -233,3 +233,14 @@ vzInitVersion(vzConnPtr privconn)
VIR_FREE(output);
return ret;
}
+
+bool vzCheckDiskFormat(vzConnPtr privconn, virStorageFileFormat format, bool isCt)
+{
+ if (isCt && privconn->ctDiskFormat == format)
+ return true;
+
+ if (!isCt && privconn->vmDiskFormat == format)
+ return true;
+
+ return false;
+}
diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h
index b1bdcce..a6274fb 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -100,6 +100,10 @@ vzNewDomain(vzConnPtr privconn,
const unsigned char *uuid);
int
vzInitVersion(vzConnPtr privconn);
+bool
+vzCheckDiskFormat(vzConnPtr privconn,
+ virStorageFileFormat format,
+ bool isCt);
# define PARALLELS_BLOCK_STATS_FOREACH(OP) \
OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests") \
--
1.8.3.1