提交 9baf87bb 编写于 作者: M Maxim Nestratov 提交者: Michal Privoznik

parallels: delete old networks in prlsdkDoApplyConfig before adding new ones

In order to change an existing domain we delete all existing devices and add
new from scratch. In case of network devices we should also delete corresponding
virtual networks (if any) before removing actual devices from xml. In the patch,
we do it by extending prlsdkDoApplyConfig with a new parameter, which stands for
old xml, and calling prlsdkDelNet every time old xml is specified.
Signed-off-by: NMaxim Nestratov <mnestratov@parallels.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 fa2607d5
......@@ -2935,7 +2935,8 @@ prlsdkAddFS(PRL_HANDLE sdkdom, virDomainFSDefPtr fs)
static int
prlsdkDoApplyConfig(virConnectPtr conn,
PRL_HANDLE sdkdom,
virDomainDefPtr def)
virDomainDefPtr def,
virDomainDefPtr olddef)
{
PRL_RESULT pret;
size_t i;
......@@ -2997,6 +2998,16 @@ prlsdkDoApplyConfig(virConnectPtr conn,
if (prlsdkRemoveBootDevices(sdkdom) < 0)
goto error;
if (olddef) {
for (i = 0; i < olddef->nnets; i++)
prlsdkDelNet(conn->privateData, olddef->nets[i]);
}
for (i = 0; i < def->nnets; i++) {
if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
goto error;
}
if (prlsdkApplyGraphicsParams(sdkdom, def) < 0)
goto error;
......@@ -3008,11 +3019,6 @@ prlsdkDoApplyConfig(virConnectPtr conn,
goto error;
}
for (i = 0; i < def->nnets; i++) {
if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
goto error;
}
for (i = 0; i < def->ndisks; i++) {
bool bootDisk = false;
......@@ -3060,7 +3066,7 @@ prlsdkApplyConfig(virConnectPtr conn,
if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
return -1;
ret = prlsdkDoApplyConfig(conn, sdkdom, new);
ret = prlsdkDoApplyConfig(conn, sdkdom, new, dom->def);
if (ret == 0) {
job = PrlVm_CommitEx(sdkdom, PVCF_DETACH_HDD_BUNDLE);
......@@ -3100,7 +3106,7 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
pret = PrlVmCfg_SetOfflineManagementEnabled(sdkdom, 0);
prlsdkCheckRetGoto(pret, cleanup);
ret = prlsdkDoApplyConfig(conn, sdkdom, def);
ret = prlsdkDoApplyConfig(conn, sdkdom, def, NULL);
if (ret)
goto cleanup;
......@@ -3162,7 +3168,7 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
}
ret = prlsdkDoApplyConfig(conn, sdkdom, def);
ret = prlsdkDoApplyConfig(conn, sdkdom, def, NULL);
if (ret)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册