libxl: add support for multiple IP addresses
vif-* scripts support it for a long time, and expect addresses to be separated by spaces. Add appropriate support to libxl driver. Reviewed-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
2c01e4febc
commit
82ef04fe79
@ -49,6 +49,7 @@
|
|||||||
#include "virstoragefile.h"
|
#include "virstoragefile.h"
|
||||||
#include "secret_util.h"
|
#include "secret_util.h"
|
||||||
#include "cpu/cpu.h"
|
#include "cpu/cpu.h"
|
||||||
|
#include "xen_common.h"
|
||||||
|
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||||
@ -1144,7 +1145,7 @@ libxlMakeNic(virDomainDefPtr def,
|
|||||||
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
|
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (l_nic->guestIP.nips > 0) {
|
if (l_nic->guestIP.nips > 0) {
|
||||||
x_nic->ip = virSocketAddrFormat(&l_nic->guestIP.ips[0]->address);
|
x_nic->ip = xenMakeIPList(&l_nic->guestIP);
|
||||||
if (!x_nic->ip)
|
if (!x_nic->ip)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1160,7 +1161,7 @@ libxlMakeNic(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (l_nic->guestIP.nips > 0) {
|
if (l_nic->guestIP.nips > 0) {
|
||||||
x_nic->ip = virSocketAddrFormat(&l_nic->guestIP.ips[0]->address);
|
x_nic->ip = xenMakeIPList(&l_nic->guestIP);
|
||||||
if (!x_nic->ip)
|
if (!x_nic->ip)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -294,18 +294,6 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
def->os.type != VIR_DOMAIN_OSTYPE_HVM)
|
def->os.type != VIR_DOMAIN_OSTYPE_HVM)
|
||||||
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
||||||
|
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
|
||||||
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
|
|
||||||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
|
|
||||||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK)) {
|
|
||||||
if (dev->data.net->guestIP.nips > 1) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("multiple IP addresses not supported on device type %s"),
|
|
||||||
virDomainNetTypeToString(dev->data.net->type));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV ||
|
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV ||
|
||||||
(dev->type == VIR_DOMAIN_DEVICE_NET &&
|
(dev->type == VIR_DOMAIN_DEVICE_NET &&
|
||||||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
|
dev->data.net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)) {
|
||||||
|
@ -1166,6 +1166,30 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xenMakeIPList(virNetDevIPInfoPtr guestIP)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
char **address_array;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < guestIP->nips; i++) {
|
||||||
|
address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address);
|
||||||
|
if (!address_array[i])
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
address_array[guestIP->nips] = NULL;
|
||||||
|
|
||||||
|
ret = virStringListJoin((const char**)address_array, " ");
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
while (i > 0)
|
||||||
|
VIR_FREE(address_array[--i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenFormatNet(virConnectPtr conn,
|
xenFormatNet(virConnectPtr conn,
|
||||||
|
@ -67,6 +67,7 @@ int xenFormatConfigCommon(virConfPtr conf,
|
|||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
const char *nativeFormat);
|
const char *nativeFormat);
|
||||||
|
|
||||||
|
char *xenMakeIPList(virNetDevIPInfoPtr guestIP);
|
||||||
|
|
||||||
int xenDomainDefAddImplicitInputDevice(virDomainDefPtr def);
|
int xenDomainDefAddImplicitInputDevice(virDomainDefPtr def);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user