提交 62d18146 编写于 作者: M Maxim Nestratov 提交者: Dmitry Guryanov

parallels: fix crash in prlsdkAddNet in case of CT definition

Since net->model is not defined for containers we shouldn't touch it.
In case network adapter model is defined, a warning about ignoring
it is shown.
Signed-off-by: NMaxim Nestratov <mnestratov@parallels.com>
上级 6f75779e
......@@ -2725,7 +2725,8 @@ static const char * prlsdkFormatMac(virMacAddrPtr mac, char *macstr)
static int prlsdkAddNet(PRL_HANDLE sdkdom,
parallelsConnPtr privconn,
virDomainNetDefPtr net)
virDomainNetDefPtr net,
bool isCt)
{
PRL_RESULT pret;
PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
......@@ -2757,6 +2758,11 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
prlsdkCheckRetGoto(pret, cleanup);
if (isCt) {
if (net->model)
VIR_WARN("Setting network adapter for containers is not "
"supported by Parallels Cloud Server.");
} else {
if (STREQ(net->model, "rtl8139")) {
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
} else if (STREQ(net->model, "e1000")) {
......@@ -2770,6 +2776,7 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
goto cleanup;
}
prlsdkCheckRetGoto(pret, cleanup);
}
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
......@@ -3153,7 +3160,7 @@ prlsdkDoApplyConfig(virConnectPtr conn,
}
for (i = 0; i < def->nnets; i++) {
if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i]) < 0)
if (prlsdkAddNet(sdkdom, conn->privateData, def->nets[i], IS_CT(def)) < 0)
goto error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册