mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
Report error if a driver can't handle multiple IP addresses
Drivers supporting one and only one IP address raise an error if more IP addresses are configured.
This commit is contained in:
parent
a4e8639068
commit
e85df0901d
@ -1254,7 +1254,7 @@ vboxAttachSound(virDomainDefPtr def, IMachine *machine)
|
|||||||
VBOX_RELEASE(audioAdapter);
|
VBOX_RELEASE(audioAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
||||||
{
|
{
|
||||||
ISystemProperties *systemProperties = NULL;
|
ISystemProperties *systemProperties = NULL;
|
||||||
@ -1306,10 +1306,14 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
|||||||
} else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
} else if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||||
VIR_DEBUG("NIC(%zu): brname: %s", i, def->nets[i]->data.bridge.brname);
|
VIR_DEBUG("NIC(%zu): brname: %s", i, def->nets[i]->data.bridge.brname);
|
||||||
VIR_DEBUG("NIC(%zu): script: %s", i, def->nets[i]->script);
|
VIR_DEBUG("NIC(%zu): script: %s", i, def->nets[i]->script);
|
||||||
if (def->nets[i]->nips > 0) {
|
if (def->nets[i]->nips == 1) {
|
||||||
char *ipStr = virSocketAddrFormat(&def->nets[i]->ips[0]->address);
|
char *ipStr = virSocketAddrFormat(&def->nets[i]->ips[0]->address);
|
||||||
VIR_DEBUG("NIC(%zu): ipaddr: %s", i, ipStr);
|
VIR_DEBUG("NIC(%zu): ipaddr: %s", i, ipStr);
|
||||||
VIR_FREE(ipStr);
|
VIR_FREE(ipStr);
|
||||||
|
} else if (def->nets[i]->nips > 1) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Driver does not support setting multiple IP addresses"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1393,6 +1397,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
|||||||
gVBoxAPI.UINetworkAdapter.SetMACAddress(adapter, MACAddress);
|
gVBoxAPI.UINetworkAdapter.SetMACAddress(adapter, MACAddress);
|
||||||
VBOX_UTF16_FREE(MACAddress);
|
VBOX_UTF16_FREE(MACAddress);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1938,7 +1943,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
vboxSetBootDeviceOrder(def, data, machine);
|
vboxSetBootDeviceOrder(def, data, machine);
|
||||||
vboxAttachDrives(def, data, machine);
|
vboxAttachDrives(def, data, machine);
|
||||||
vboxAttachSound(def, machine);
|
vboxAttachSound(def, machine);
|
||||||
vboxAttachNetwork(def, data, machine);
|
if (vboxAttachNetwork(def, data, machine) < 0)
|
||||||
|
goto cleanup;
|
||||||
vboxAttachSerial(def, data, machine);
|
vboxAttachSerial(def, data, machine);
|
||||||
vboxAttachParallel(def, data, machine);
|
vboxAttachParallel(def, data, machine);
|
||||||
vboxAttachVideo(def, machine);
|
vboxAttachVideo(def, machine);
|
||||||
|
@ -1220,10 +1220,14 @@ xenFormatNet(virConnectPtr conn,
|
|||||||
switch (net->type) {
|
switch (net->type) {
|
||||||
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||||
virBufferAsprintf(&buf, ",bridge=%s", net->data.bridge.brname);
|
virBufferAsprintf(&buf, ",bridge=%s", net->data.bridge.brname);
|
||||||
if (net->nips > 0) {
|
if (net->nips == 1) {
|
||||||
char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
|
char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
|
||||||
virBufferAsprintf(&buf, ",ip=%s", ipStr);
|
virBufferAsprintf(&buf, ",ip=%s", ipStr);
|
||||||
VIR_FREE(ipStr);
|
VIR_FREE(ipStr);
|
||||||
|
} else if (net->nips > 1) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Driver does not support setting multiple IP addresses"));
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(&buf, ",script=%s", DEFAULT_VIF_SCRIPT);
|
virBufferAsprintf(&buf, ",script=%s", DEFAULT_VIF_SCRIPT);
|
||||||
break;
|
break;
|
||||||
@ -1231,10 +1235,14 @@ xenFormatNet(virConnectPtr conn,
|
|||||||
case VIR_DOMAIN_NET_TYPE_ETHERNET:
|
case VIR_DOMAIN_NET_TYPE_ETHERNET:
|
||||||
if (net->script)
|
if (net->script)
|
||||||
virBufferAsprintf(&buf, ",script=%s", net->script);
|
virBufferAsprintf(&buf, ",script=%s", net->script);
|
||||||
if (net->nips > 0) {
|
if (net->nips == 1) {
|
||||||
char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
|
char *ipStr = virSocketAddrFormat(&net->ips[0]->address);
|
||||||
virBufferAsprintf(&buf, ",ip=%s", ipStr);
|
virBufferAsprintf(&buf, ",ip=%s", ipStr);
|
||||||
VIR_FREE(ipStr);
|
VIR_FREE(ipStr);
|
||||||
|
} else if (net->nips > 1) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Driver does not support setting multiple IP addresses"));
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1898,10 +1898,14 @@ xenFormatSxprNet(virConnectPtr conn,
|
|||||||
script = def->script;
|
script = def->script;
|
||||||
|
|
||||||
virBufferEscapeSexpr(buf, "(script '%s')", script);
|
virBufferEscapeSexpr(buf, "(script '%s')", script);
|
||||||
if (def->nips > 0) {
|
if (def->nips == 1) {
|
||||||
char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
|
char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
|
||||||
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
|
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
|
||||||
VIR_FREE(ipStr);
|
VIR_FREE(ipStr);
|
||||||
|
} else if (def->nips > 1) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Driver does not support setting multiple IP addresses"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1935,10 +1939,14 @@ xenFormatSxprNet(virConnectPtr conn,
|
|||||||
if (def->script)
|
if (def->script)
|
||||||
virBufferEscapeSexpr(buf, "(script '%s')",
|
virBufferEscapeSexpr(buf, "(script '%s')",
|
||||||
def->script);
|
def->script);
|
||||||
if (def->nips > 0) {
|
if (def->nips == 1) {
|
||||||
char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
|
char *ipStr = virSocketAddrFormat(&def->ips[0]->address);
|
||||||
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
|
virBufferEscapeSexpr(buf, "(ip '%s')", ipStr);
|
||||||
VIR_FREE(ipStr);
|
VIR_FREE(ipStr);
|
||||||
|
} else if (def->nips > 1) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("Driver does not support setting multiple IP addresses"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user