---
src/parallels/parallels_sdk.c | 79 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 70 insertions(+), 9 deletions(-)
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 127d2bb..05b1049 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2899,14 +2899,27 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
PRL_HANDLE result = PRL_INVALID_HANDLE;
PRL_RESULT pret;
int ret = -1;
+ int useTemplate = 0;
+ unsigned int i;
+ char uuidstr[VIR_UUID_STRING_BUFLEN + 2];
- if (def->nfss && (def->nfss > 1 ||
- def->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE)) {
-
- virReportError(VIR_ERR_INVALID_ARG, "%s",
- _("There must be no more than 1 template FS for "
- "container creation"));
- return -1;
+ if (def->nfss > 1) {
+ /* Check all filesystems */
+ for (i = 0; i < def->nfss; i++) {
+ if (def->fss[i]->type != VIR_DOMAIN_FS_TYPE_FILE) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Unsupported filesystem type."));
+ return -1;
+ }
+ }
+ } else if (def->nfss == 1) {
+ if (def->fss[0]->type == VIR_DOMAIN_FS_TYPE_TEMPLATE) {
+ useTemplate = 1;
+ } else if (def->fss[0]->type != VIR_DOMAIN_FS_TYPE_FILE) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Unsupported filesystem type."));
+ return -1;
+ }
}
confParam.nVmType = PVT_CT;
@@ -2920,9 +2933,55 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
pret = PrlResult_GetParamByIndex(result, 0, &sdkdom);
prlsdkCheckRetGoto(pret, cleanup);
- if (def->nfss == 1) {
+ /*
+ * FIXME: This code must be replaced with the
+ * FIXME: commented code below after fixing
+ * FIXME: issue PSBM-30586.
+ */
+ if (useTemplate) {
pret = PrlVmCfg_SetOsTemplate(sdkdom, def->fss[0]->src);
prlsdkCheckRetGoto(pret, cleanup);
+
+ ret = prlsdkDoApplyConfig(sdkdom, def);
+ if (ret)
+ goto cleanup;
+
+ job = PrlVm_RegEx(sdkdom, "", PACF_NON_INTERACTIVE_MODE);
+ if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ ret = -1;
+ } else {
+ if (prlsdkClearDevices(sdkdom) < 0)
+ goto cleanup;
+
+ prlsdkUUIDFormat(def->uuid, uuidstr);
+
+ pret = PrlVmCfg_SetUuid(sdkdom, uuidstr);
+ prlsdkCheckRetGoto(pret, cleanup);
+
+ job = PrlVm_RegEx(sdkdom, "", PACF_NON_INTERACTIVE_MODE);
+ if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ goto cleanup;
+
+ job = PrlVm_BeginEdit(sdkdom);
+ if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ goto cleanup;
+
+ ret = prlsdkDoApplyConfig(sdkdom, def);
+ if (ret)
+ goto cleanup;
+
+ job = PrlVm_CommitEx(sdkdom, PVCF_DETACH_HDD_BUNDLE);
+ if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ ret = -1;
+
+ ret = 0;
+ }
+
+/*
+ if (useTemplate) {
+ pret = PrlVmCfg_SetOsTemplate(sdkdom, def->fss[0]->src);
+ prlsdkCheckRetGoto(pret, cleanup);
+
}
ret = prlsdkDoApplyConfig(sdkdom, def);
@@ -2933,9 +2992,11 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
ret = -1;
+*/
+
cleanup:
PrlHandle_Free(sdkdom);
- return -1;
+ return ret;
}
int
--
2.1.0