mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
parallels: create container from existing image
It's possible to create a container with existing disk image as root filesystem. You need to remove existing disks from PCS VM config and then add a new one, pointing to your image. And then call PrlVm_RegEx with PRNVM_PRESERVE_DISK flag. With this patch you can create such container with something like this for new domain XML config: <filesystem type='file' accessmode='passthrough'> <driver type='ploop' format='ploop'/> <source file='/path-to-image'/> <target dir='/'/> </filesystem> Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
aba95c287c
commit
2bc460d3c1
@ -2907,14 +2907,26 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
|
|||||||
PRL_HANDLE result = PRL_INVALID_HANDLE;
|
PRL_HANDLE result = PRL_INVALID_HANDLE;
|
||||||
PRL_RESULT pret;
|
PRL_RESULT pret;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
int useTemplate = 0;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (def->nfss && (def->nfss > 1 ||
|
if (def->nfss > 1) {
|
||||||
def->fss[0]->type != VIR_DOMAIN_FS_TYPE_TEMPLATE)) {
|
/* Check all filesystems */
|
||||||
|
for (i = 0; i < def->nfss; i++) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
if (def->fss[i]->type != VIR_DOMAIN_FS_TYPE_FILE) {
|
||||||
_("There must be no more than 1 template FS for "
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
"container creation"));
|
_("Unsupported filesystem type."));
|
||||||
return -1;
|
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;
|
confParam.nVmType = PVT_CT;
|
||||||
@ -2928,22 +2940,24 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
|
|||||||
pret = PrlResult_GetParamByIndex(result, 0, &sdkdom);
|
pret = PrlResult_GetParamByIndex(result, 0, &sdkdom);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
if (def->nfss == 1) {
|
if (useTemplate) {
|
||||||
pret = PrlVmCfg_SetOsTemplate(sdkdom, def->fss[0]->src);
|
pret = PrlVmCfg_SetOsTemplate(sdkdom, def->fss[0]->src);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = prlsdkDoApplyConfig(sdkdom, def);
|
ret = prlsdkDoApplyConfig(sdkdom, def);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
job = PrlVm_RegEx(sdkdom, "", PACF_NON_INTERACTIVE_MODE);
|
job = PrlVm_RegEx(sdkdom, "",
|
||||||
|
PACF_NON_INTERACTIVE_MODE | PRNVM_PRESERVE_DISK);
|
||||||
if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
|
if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
PrlHandle_Free(sdkdom);
|
PrlHandle_Free(sdkdom);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user