mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
vz: support type=bridge network interface type correctly
Recently, libprlsdk got a separate flag PNA_BRIDGE corresponding to type=bridge libvirt network interfaces. Let's use it and get rid of all workarounds previously added to support it. Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
This commit is contained in:
parent
8b035c84d8
commit
0e094a4495
100
src/vz/vz_sdk.c
100
src/vz/vz_sdk.c
@ -1015,27 +1015,19 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
|
|||||||
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
|
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
char *netid = NULL;
|
char *netid =
|
||||||
|
|
||||||
if (!(netid =
|
|
||||||
prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId,
|
prlsdkGetStringParamVar(PrlVmDevNet_GetVirtualNetworkId,
|
||||||
netAdapter)))
|
netAdapter);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/*
|
if (emulatedType == PNA_BRIDGE) {
|
||||||
* We use VIR_DOMAIN_NET_TYPE_NETWORK for all network adapters
|
|
||||||
* except those whose Virtual Network Id differ from Parallels
|
|
||||||
* predefined ones such as PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME
|
|
||||||
* and PARALLELS_DONAIN_ROUTED_NETWORK_NAME
|
|
||||||
*/
|
|
||||||
if (STRNEQ(netid, PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME)) {
|
|
||||||
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||||
net->data.network.name = netid;
|
if (netid)
|
||||||
|
net->data.bridge.brname = netid;
|
||||||
} else {
|
} else {
|
||||||
net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
|
net->type = VIR_DOMAIN_NET_TYPE_NETWORK;
|
||||||
net->data.bridge.brname = netid;
|
if (netid)
|
||||||
|
net->data.network.name = netid;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCt) {
|
if (!isCt) {
|
||||||
@ -3186,16 +3178,14 @@ static int prlsdkConfigureGateways(PRL_HANDLE sdknet, virDomainNetDefPtr net)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prlsdkConfigureNet(vzDriverPtr driver,
|
static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom ATTRIBUTE_UNUSED,
|
||||||
PRL_HANDLE sdkdom,
|
PRL_HANDLE sdkdom,
|
||||||
virDomainNetDefPtr net,
|
virDomainNetDefPtr net,
|
||||||
bool isCt, bool create)
|
bool isCt, bool create)
|
||||||
{
|
{
|
||||||
PRL_RESULT pret;
|
PRL_RESULT pret;
|
||||||
PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
|
PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
|
||||||
PRL_HANDLE vnet = PRL_INVALID_HANDLE;
|
|
||||||
PRL_HANDLE job = PRL_INVALID_HANDLE;
|
|
||||||
PRL_HANDLE addrlist = PRL_INVALID_HANDLE;
|
PRL_HANDLE addrlist = PRL_INVALID_HANDLE;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -3302,35 +3292,17 @@ static int prlsdkConfigureNet(vzDriverPtr driver,
|
|||||||
if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
|
if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
|
||||||
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
|
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
} else if (STREQ(net->data.network.name, PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME)) {
|
} else {
|
||||||
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
|
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_NETWORK);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
|
pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||||
/*
|
|
||||||
* For this type of adapter we create a new
|
|
||||||
* Virtual Network assuming that bridge with given name exists
|
|
||||||
* Failing creating this means domain creation failure
|
|
||||||
*/
|
|
||||||
pret = PrlVirtNet_Create(&vnet);
|
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
|
||||||
|
|
||||||
pret = PrlVirtNet_SetNetworkId(vnet, net->data.bridge.brname);
|
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGE);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
|
||||||
|
|
||||||
pret = PrlVirtNet_SetNetworkType(vnet, PVN_BRIDGED_ETHERNET);
|
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
|
||||||
|
|
||||||
job = PrlSrv_AddVirtualNetwork(driver->server,
|
|
||||||
vnet,
|
|
||||||
PRL_USE_VNET_NAME_FOR_BRIDGE_NAME);
|
|
||||||
if (PRL_FAILED(pret = waitDomainJob(job, dom)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
|
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.bridge.brname);
|
pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.bridge.brname);
|
||||||
@ -3345,40 +3317,10 @@ static int prlsdkConfigureNet(vzDriverPtr driver,
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(addrstr);
|
VIR_FREE(addrstr);
|
||||||
PrlHandle_Free(addrlist);
|
PrlHandle_Free(addrlist);
|
||||||
PrlHandle_Free(vnet);
|
|
||||||
PrlHandle_Free(sdknet);
|
PrlHandle_Free(sdknet);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
prlsdkCleanupBridgedNet(vzDriverPtr driver,
|
|
||||||
virDomainObjPtr dom,
|
|
||||||
virDomainNetDefPtr net)
|
|
||||||
{
|
|
||||||
PRL_RESULT pret;
|
|
||||||
PRL_HANDLE vnet = PRL_INVALID_HANDLE;
|
|
||||||
PRL_HANDLE job = PRL_INVALID_HANDLE;
|
|
||||||
|
|
||||||
if (net->type != VIR_DOMAIN_NET_TYPE_BRIDGE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pret = PrlVirtNet_Create(&vnet);
|
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
|
||||||
|
|
||||||
pret = PrlVirtNet_SetNetworkId(vnet, net->data.network.name);
|
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
|
||||||
|
|
||||||
job = PrlSrv_DeleteVirtualNetwork(driver->server, vnet, 0);
|
|
||||||
ignore_value(waitDomainJob(job, dom));
|
|
||||||
|
|
||||||
/* As far as waitDomainJob finally calls virReportErrorHelper
|
|
||||||
* and we are not going to report it, reset it expicitly*/
|
|
||||||
virResetLastError();
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
PrlHandle_Free(vnet);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PRL_HANDLE
|
static PRL_HANDLE
|
||||||
prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac)
|
prlsdkFindNetByMAC(PRL_HANDLE sdkdom, virMacAddrPtr mac)
|
||||||
{
|
{
|
||||||
@ -3624,7 +3566,7 @@ prlsdkAttachDevice(vzDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
prlsdkDetachDevice(vzDriverPtr driver,
|
prlsdkDetachDevice(vzDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
virDomainDeviceDefPtr dev)
|
virDomainDeviceDefPtr dev)
|
||||||
{
|
{
|
||||||
@ -3659,8 +3601,6 @@ prlsdkDetachDevice(vzDriverPtr driver,
|
|||||||
if (sdkdev == PRL_INVALID_HANDLE)
|
if (sdkdev == PRL_INVALID_HANDLE)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
prlsdkCleanupBridgedNet(driver, dom, dev->data.net);
|
|
||||||
|
|
||||||
pret = PrlVmDev_Remove(sdkdev);
|
pret = PrlVmDev_Remove(sdkdev);
|
||||||
prlsdkCheckRetGoto(pret, cleanup);
|
prlsdkCheckRetGoto(pret, cleanup);
|
||||||
|
|
||||||
@ -3973,11 +3913,6 @@ prlsdkDoApplyConfig(vzDriverPtr driver,
|
|||||||
if (prlsdkRemoveBootDevices(sdkdom) < 0)
|
if (prlsdkRemoveBootDevices(sdkdom) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (dom) {
|
|
||||||
for (i = 0; i < dom->def->nnets; i++)
|
|
||||||
prlsdkCleanupBridgedNet(driver, dom, dom->def->nets[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
if (prlsdkConfigureNet(driver, dom, sdkdom, def->nets[i],
|
if (prlsdkConfigureNet(driver, dom, sdkdom, def->nets[i],
|
||||||
IS_CT(def), true) < 0)
|
IS_CT(def), true) < 0)
|
||||||
@ -4026,9 +3961,6 @@ prlsdkDoApplyConfig(vzDriverPtr driver,
|
|||||||
error:
|
error:
|
||||||
VIR_FREE(mask);
|
VIR_FREE(mask);
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++)
|
|
||||||
prlsdkCleanupBridgedNet(driver, dom, def->nets[i]);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4267,7 +4199,6 @@ prlsdkUnregisterDomain(vzDriverPtr driver, virDomainObjPtr dom, unsigned int fla
|
|||||||
{
|
{
|
||||||
vzDomObjPtr privdom = dom->privateData;
|
vzDomObjPtr privdom = dom->privateData;
|
||||||
PRL_HANDLE job;
|
PRL_HANDLE job;
|
||||||
size_t i;
|
|
||||||
virDomainSnapshotObjListPtr snapshots = NULL;
|
virDomainSnapshotObjListPtr snapshots = NULL;
|
||||||
VIRTUAL_MACHINE_STATE domainState;
|
VIRTUAL_MACHINE_STATE domainState;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -4304,9 +4235,6 @@ prlsdkUnregisterDomain(vzDriverPtr driver, virDomainObjPtr dom, unsigned int fla
|
|||||||
if (PRL_FAILED(waitDomainJob(job, dom)))
|
if (PRL_FAILED(waitDomainJob(job, dom)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < dom->def->nnets; i++)
|
|
||||||
prlsdkCleanupBridgedNet(driver, dom, dom->def->nets[i]);
|
|
||||||
|
|
||||||
prlsdkSendEvent(driver, dom, VIR_DOMAIN_EVENT_UNDEFINED,
|
prlsdkSendEvent(driver, dom, VIR_DOMAIN_EVENT_UNDEFINED,
|
||||||
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
|
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user