mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
conf: net: Add wrapper functions for <model> value
To ease converting the net->model value to an enum, add the wrapper functions: virDomainNetGetModelString virDomainNetSetModelString virDomainNetStreqModelString virDomainNetStrcaseeqModelString Acked-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
c800e29b87
commit
6bf7c67699
@ -57,16 +57,16 @@ bhyveBuildNetArgStr(virConnectPtr conn,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
virDomainNetType actualType = virDomainNetGetActualType(net);
|
virDomainNetType actualType = virDomainNetGetActualType(net);
|
||||||
|
|
||||||
if (net->model == NULL) {
|
if (!virDomainNetGetModelString(net)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("NIC model must be specified"));
|
_("NIC model must be specified"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ(net->model, "virtio")) {
|
if (virDomainNetStreqModelString(net, "virtio")) {
|
||||||
if (VIR_STRDUP(nic_model, "virtio-net") < 0)
|
if (VIR_STRDUP(nic_model, "virtio-net") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else if (STREQ(net->model, "e1000")) {
|
} else if (virDomainNetStreqModelString(net, "e1000")) {
|
||||||
if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) {
|
if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) {
|
||||||
if (VIR_STRDUP(nic_model, "e1000") < 0)
|
if (VIR_STRDUP(nic_model, "e1000") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -79,7 +79,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
|
|||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("NIC model '%s' is not supported"),
|
_("NIC model '%s' is not supported"),
|
||||||
net->model);
|
virDomainNetGetModelString(net));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ bhyveParsePCINet(virDomainDefPtr def,
|
|||||||
if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0)
|
if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(net->model, model) < 0)
|
if (virDomainNetSetModelString(net, model) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
|
@ -25365,9 +25365,9 @@ virDomainNetDefFormat(virBufferPtr buf,
|
|||||||
virBufferEscapeString(buf, " actual='%s'", def->ifname_guest_actual);
|
virBufferEscapeString(buf, " actual='%s'", def->ifname_guest_actual);
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
if (def->model) {
|
if (virDomainNetGetModelString(def)) {
|
||||||
virBufferEscapeString(buf, "<model type='%s'/>\n",
|
virBufferEscapeString(buf, "<model type='%s'/>\n",
|
||||||
def->model);
|
virDomainNetGetModelString(def));
|
||||||
if (virDomainNetIsVirtioModel(def)) {
|
if (virDomainNetIsVirtioModel(def)) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
VIR_AUTOFREE(char *) str = NULL;
|
VIR_AUTOFREE(char *) str = NULL;
|
||||||
@ -29477,13 +29477,39 @@ virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface)
|
|||||||
return iface->trustGuestRxFilters == VIR_TRISTATE_BOOL_YES;
|
return iface->trustGuestRxFilters == VIR_TRISTATE_BOOL_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
virDomainNetGetModelString(const virDomainNetDef *net)
|
||||||
|
{
|
||||||
|
return net->model;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetSetModelString(virDomainNetDefPtr net,
|
||||||
|
const char *model)
|
||||||
|
{
|
||||||
|
return VIR_STRDUP(net->model, model);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetStreqModelString(const virDomainNetDef *net,
|
||||||
|
const char *model)
|
||||||
|
{
|
||||||
|
return STREQ_NULLABLE(net->model, model);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainNetStrcaseeqModelString(const virDomainNetDef *net,
|
||||||
|
const char *model)
|
||||||
|
{
|
||||||
|
return net->model && STRCASEEQ(net->model, model);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
virDomainNetIsVirtioModel(const virDomainNetDef *net)
|
virDomainNetIsVirtioModel(const virDomainNetDef *net)
|
||||||
{
|
{
|
||||||
return (STREQ_NULLABLE(net->model, "virtio") ||
|
return (virDomainNetStreqModelString(net, "virtio") ||
|
||||||
STREQ_NULLABLE(net->model, "virtio-transitional") ||
|
virDomainNetStreqModelString(net, "virtio-transitional") ||
|
||||||
STREQ_NULLABLE(net->model, "virtio-non-transitional"));
|
virDomainNetStreqModelString(net, "virtio-non-transitional"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3111,6 +3111,13 @@ virNetDevBandwidthPtr
|
|||||||
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
|
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
|
||||||
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
|
virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
|
||||||
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
|
bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
|
||||||
|
const char *virDomainNetGetModelString(const virDomainNetDef *net);
|
||||||
|
int virDomainNetSetModelString(virDomainNetDefPtr et,
|
||||||
|
const char *model);
|
||||||
|
int virDomainNetStreqModelString(const virDomainNetDef *net,
|
||||||
|
const char *model);
|
||||||
|
int virDomainNetStrcaseeqModelString(const virDomainNetDef *net,
|
||||||
|
const char *model);
|
||||||
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
|
bool virDomainNetIsVirtioModel(const virDomainNetDef *net);
|
||||||
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
|
int virDomainNetAppendIPAddress(virDomainNetDefPtr def,
|
||||||
const char *address,
|
const char *address,
|
||||||
|
@ -475,6 +475,7 @@ virDomainNetGetActualTrustGuestRxFilters;
|
|||||||
virDomainNetGetActualType;
|
virDomainNetGetActualType;
|
||||||
virDomainNetGetActualVirtPortProfile;
|
virDomainNetGetActualVirtPortProfile;
|
||||||
virDomainNetGetActualVlan;
|
virDomainNetGetActualVlan;
|
||||||
|
virDomainNetGetModelString;
|
||||||
virDomainNetInsert;
|
virDomainNetInsert;
|
||||||
virDomainNetIsVirtioModel;
|
virDomainNetIsVirtioModel;
|
||||||
virDomainNetNotifyActualDevice;
|
virDomainNetNotifyActualDevice;
|
||||||
@ -483,6 +484,9 @@ virDomainNetRemove;
|
|||||||
virDomainNetRemoveHostdev;
|
virDomainNetRemoveHostdev;
|
||||||
virDomainNetResolveActualType;
|
virDomainNetResolveActualType;
|
||||||
virDomainNetSetDeviceImpl;
|
virDomainNetSetDeviceImpl;
|
||||||
|
virDomainNetSetModelString;
|
||||||
|
virDomainNetStrcaseeqModelString;
|
||||||
|
virDomainNetStreqModelString;
|
||||||
virDomainNetTypeFromString;
|
virDomainNetTypeFromString;
|
||||||
virDomainNetTypeSharesHostView;
|
virDomainNetTypeSharesHostView;
|
||||||
virDomainNetTypeToString;
|
virDomainNetTypeToString;
|
||||||
|
@ -1275,18 +1275,18 @@ libxlMakeNic(virDomainDefPtr def,
|
|||||||
* xen commit 32e9d0f ("libxl: nic type defaults to vif in hotplug for
|
* xen commit 32e9d0f ("libxl: nic type defaults to vif in hotplug for
|
||||||
* hvm guest").
|
* hvm guest").
|
||||||
*/
|
*/
|
||||||
if (l_nic->model) {
|
if (virDomainNetGetModelString(l_nic)) {
|
||||||
if ((def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
|
if ((def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
|
||||||
def->os.type == VIR_DOMAIN_OSTYPE_XENPVH) &&
|
def->os.type == VIR_DOMAIN_OSTYPE_XENPVH) &&
|
||||||
STRNEQ(l_nic->model, "netfront")) {
|
!virDomainNetStreqModelString(l_nic, "netfront")) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("only model 'netfront' is supported for "
|
_("only model 'netfront' is supported for "
|
||||||
"Xen PV(H) domains"));
|
"Xen PV(H) domains"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_STRDUP(x_nic->model, l_nic->model) < 0)
|
if (VIR_STRDUP(x_nic->model, virDomainNetGetModelString(l_nic)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (STREQ(l_nic->model, "netfront"))
|
if (virDomainNetStreqModelString(l_nic, "netfront"))
|
||||||
x_nic->nictype = LIBXL_NIC_TYPE_VIF;
|
x_nic->nictype = LIBXL_NIC_TYPE_VIF;
|
||||||
else
|
else
|
||||||
x_nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
|
x_nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
|
||||||
|
@ -489,10 +489,10 @@ qemuBuildVirtioDevStr(virBufferPtr buf,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_NET:
|
case VIR_DOMAIN_DEVICE_NET:
|
||||||
has_tmodel = STREQ_NULLABLE(device.data.net->model,
|
has_tmodel = virDomainNetStreqModelString(device.data.net,
|
||||||
"virtio-transitional");
|
"virtio-transitional");
|
||||||
has_ntmodel = STREQ_NULLABLE(device.data.net->model,
|
has_ntmodel = virDomainNetStreqModelString(device.data.net,
|
||||||
"virtio-non-transitional");
|
"virtio-non-transitional");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||||
@ -3875,13 +3875,14 @@ qemuBuildLegacyNicStr(virDomainNetDefPtr net)
|
|||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
char macaddr[VIR_MAC_STRING_BUFLEN];
|
char macaddr[VIR_MAC_STRING_BUFLEN];
|
||||||
|
const char *netmodel = virDomainNetGetModelString(net);
|
||||||
|
|
||||||
ignore_value(virAsprintf(&str,
|
ignore_value(virAsprintf(&str,
|
||||||
"nic,macaddr=%s,netdev=host%s%s%s%s%s",
|
"nic,macaddr=%s,netdev=host%s%s%s%s%s",
|
||||||
virMacAddrFormat(&net->mac, macaddr),
|
virMacAddrFormat(&net->mac, macaddr),
|
||||||
net->info.alias,
|
net->info.alias,
|
||||||
(net->model ? ",model=" : ""),
|
netmodel ? ",model=" : "",
|
||||||
NULLSTR_EMPTY(net->model),
|
NULLSTR_EMPTY(netmodel),
|
||||||
(net->info.alias ? ",id=" : ""),
|
(net->info.alias ? ",id=" : ""),
|
||||||
NULLSTR_EMPTY(net->info.alias)));
|
NULLSTR_EMPTY(net->info.alias)));
|
||||||
return str;
|
return str;
|
||||||
@ -3907,7 +3908,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
|
|||||||
|
|
||||||
usingVirtio = true;
|
usingVirtio = true;
|
||||||
} else {
|
} else {
|
||||||
virBufferAddStr(&buf, net->model);
|
virBufferAddStr(&buf, virDomainNetGetModelString(net));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingVirtio && net->driver.virtio.txmode) {
|
if (usingVirtio && net->driver.virtio.txmode) {
|
||||||
|
@ -6722,8 +6722,8 @@ qemuDomainDeviceNetDefPostParse(virDomainNetDefPtr net,
|
|||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
if (net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
|
if (net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
|
||||||
!net->model) {
|
!virDomainNetGetModelString(net)) {
|
||||||
if (VIR_STRDUP(net->model,
|
if (virDomainNetSetModelString(net,
|
||||||
qemuDomainDefaultNetModel(def, qemuCaps)) < 0)
|
qemuDomainDefaultNetModel(def, qemuCaps)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
|
|||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
virDomainNetDefPtr net = def->nets[i];
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
|
|
||||||
if (STREQ_NULLABLE(net->model, "spapr-vlan"))
|
if (virDomainNetStreqModelString(net, "spapr-vlan"))
|
||||||
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
||||||
|
|
||||||
if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0)
|
if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0)
|
||||||
@ -699,19 +699,18 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
|
|||||||
* addresses for other hostdev devices.
|
* addresses for other hostdev devices.
|
||||||
*/
|
*/
|
||||||
if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV ||
|
if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV ||
|
||||||
STREQ_NULLABLE(net->model, "usb-net")) {
|
virDomainNetStreqModelString(net, "usb-net")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ_NULLABLE(net->model, "virtio") ||
|
if (virDomainNetStreqModelString(net, "virtio") ||
|
||||||
STREQ_NULLABLE(net->model, "virtio-non-transitional"))
|
virDomainNetStreqModelString(net, "virtio-non-transitional"))
|
||||||
return virtioFlags;
|
return virtioFlags;
|
||||||
|
|
||||||
/* Transitional devices only work in conventional PCI slots */
|
if (virDomainNetStreqModelString(net, "virtio-transitional"))
|
||||||
if (STREQ_NULLABLE(net->model, "virtio-transitional"))
|
|
||||||
return pciFlags;
|
return pciFlags;
|
||||||
|
|
||||||
if (STREQ_NULLABLE(net->model, "e1000e"))
|
if (virDomainNetStreqModelString(net, "e1000e"))
|
||||||
return pcieFlags;
|
return pcieFlags;
|
||||||
|
|
||||||
return pciFlags;
|
return pciFlags;
|
||||||
|
@ -7411,20 +7411,28 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
|||||||
for (i = 0; i < vm->def->nnets; i++) {
|
for (i = 0; i < vm->def->nnets; i++) {
|
||||||
virDomainNetDefPtr net = vm->def->nets[i];
|
virDomainNetDefPtr net = vm->def->nets[i];
|
||||||
unsigned int bootIndex = net->info.bootIndex;
|
unsigned int bootIndex = net->info.bootIndex;
|
||||||
char *model = net->model;
|
char *model;
|
||||||
virMacAddr mac = net->mac;
|
virMacAddr mac = net->mac;
|
||||||
char *script = net->script;
|
char *script = net->script;
|
||||||
|
|
||||||
net->model = NULL;
|
if (virDomainNetGetModelString(net) &&
|
||||||
|
VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
net->script = NULL;
|
net->script = NULL;
|
||||||
|
|
||||||
virDomainNetDefClear(net);
|
virDomainNetDefClear(net);
|
||||||
|
|
||||||
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
||||||
net->info.bootIndex = bootIndex;
|
net->info.bootIndex = bootIndex;
|
||||||
net->model = model;
|
|
||||||
net->mac = mac;
|
net->mac = mac;
|
||||||
net->script = script;
|
net->script = script;
|
||||||
|
|
||||||
|
if (model && virDomainNetSetModelString(net, model) < 0) {
|
||||||
|
VIR_FREE(model);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
VIR_FREE(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cmd = qemuProcessCreatePretendCmd(driver, vm, NULL,
|
if (!(cmd = qemuProcessCreatePretendCmd(driver, vm, NULL,
|
||||||
|
@ -3790,11 +3790,12 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(olddev->model, newdev->model)) {
|
if (STRNEQ_NULLABLE(virDomainNetGetModelString(olddev),
|
||||||
|
virDomainNetGetModelString(newdev))) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
|
||||||
_("cannot modify network device model from %s to %s"),
|
_("cannot modify network device model from %s to %s"),
|
||||||
olddev->model ? olddev->model : "(default)",
|
NULLSTR(virDomainNetGetModelString(olddev)),
|
||||||
newdev->model ? newdev->model : "(default)");
|
NULLSTR(virDomainNetGetModelString(newdev)));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,8 +1109,9 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (STREQ(keywords[i], "model")) {
|
} else if (STREQ(keywords[i], "model")) {
|
||||||
def->model = values[i];
|
if (virDomainNetSetModelString(def, values[i]) < 0)
|
||||||
values[i] = NULL;
|
goto error;
|
||||||
|
VIR_FREE(values[i]);
|
||||||
} else if (STREQ(keywords[i], "vhost")) {
|
} else if (STREQ(keywords[i], "vhost")) {
|
||||||
if ((values[i] == NULL) || STREQ(values[i], "on")) {
|
if ((values[i] == NULL) || STREQ(values[i], "on")) {
|
||||||
def->driver.virtio.name = VIR_DOMAIN_NET_BACKEND_TYPE_VHOST;
|
def->driver.virtio.name = VIR_DOMAIN_NET_BACKEND_TYPE_VHOST;
|
||||||
|
@ -1253,7 +1253,7 @@ get_files(vahControl * ctl)
|
|||||||
if (ctl->def->virtType == VIR_DOMAIN_VIRT_KVM) {
|
if (ctl->def->virtType == VIR_DOMAIN_VIRT_KVM) {
|
||||||
for (i = 0; i < ctl->def->nnets; i++) {
|
for (i = 0; i < ctl->def->nnets; i++) {
|
||||||
virDomainNetDefPtr net = ctl->def->nets[i];
|
virDomainNetDefPtr net = ctl->def->nets[i];
|
||||||
if (net && net->model) {
|
if (net && virDomainNetGetModelString(net)) {
|
||||||
if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU)
|
if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU)
|
||||||
continue;
|
continue;
|
||||||
if (!virDomainNetIsVirtioModel(net))
|
if (!virDomainNetIsVirtioModel(net))
|
||||||
|
@ -1310,7 +1310,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
|||||||
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
|
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
|
||||||
|
|
||||||
VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type);
|
VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type);
|
||||||
VIR_DEBUG("NIC(%zu): Model: %s", i, def->nets[i]->model);
|
VIR_DEBUG("NIC(%zu): Model: %s", i, virDomainNetGetModelString(def->nets[i]));
|
||||||
VIR_DEBUG("NIC(%zu): Mac: %s", i, macaddr);
|
VIR_DEBUG("NIC(%zu): Mac: %s", i, macaddr);
|
||||||
VIR_DEBUG("NIC(%zu): ifname: %s", i, def->nets[i]->ifname);
|
VIR_DEBUG("NIC(%zu): ifname: %s", i, def->nets[i]->ifname);
|
||||||
if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
@ -1339,19 +1339,19 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
|||||||
|
|
||||||
gVBoxAPI.UINetworkAdapter.SetEnabled(adapter, 1);
|
gVBoxAPI.UINetworkAdapter.SetEnabled(adapter, 1);
|
||||||
|
|
||||||
if (def->nets[i]->model) {
|
if (virDomainNetGetModelString(def->nets[i])) {
|
||||||
if (STRCASEEQ(def->nets[i]->model, "Am79C970A")) {
|
if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C970A")) {
|
||||||
adapterType = NetworkAdapterType_Am79C970A;
|
adapterType = NetworkAdapterType_Am79C970A;
|
||||||
} else if (STRCASEEQ(def->nets[i]->model, "Am79C973")) {
|
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C973")) {
|
||||||
adapterType = NetworkAdapterType_Am79C973;
|
adapterType = NetworkAdapterType_Am79C973;
|
||||||
} else if (STRCASEEQ(def->nets[i]->model, "82540EM")) {
|
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82540EM")) {
|
||||||
adapterType = NetworkAdapterType_I82540EM;
|
adapterType = NetworkAdapterType_I82540EM;
|
||||||
} else if (STRCASEEQ(def->nets[i]->model, "82545EM")) {
|
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82545EM")) {
|
||||||
adapterType = NetworkAdapterType_I82545EM;
|
adapterType = NetworkAdapterType_I82545EM;
|
||||||
} else if (STRCASEEQ(def->nets[i]->model, "82543GC")) {
|
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82543GC")) {
|
||||||
adapterType = NetworkAdapterType_I82543GC;
|
adapterType = NetworkAdapterType_I82543GC;
|
||||||
} else if (gVBoxAPI.APIVersion >= 3000051 &&
|
} else if (gVBoxAPI.APIVersion >= 3000051 &&
|
||||||
STRCASEEQ(def->nets[i]->model, "virtio")) {
|
virDomainNetStrcaseeqModelString(def->nets[i], "virtio")) {
|
||||||
/* Only vbox 3.1 and later support NetworkAdapterType_Virto */
|
/* Only vbox 3.1 and later support NetworkAdapterType_Virto */
|
||||||
adapterType = NetworkAdapterType_Virtio;
|
adapterType = NetworkAdapterType_Virtio;
|
||||||
}
|
}
|
||||||
@ -3763,7 +3763,7 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
|
|||||||
model = "virtio";
|
model = "virtio";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (VIR_STRDUP(net->model, model) < 0)
|
if (virDomainNetSetModelString(net, model) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16);
|
gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16);
|
||||||
|
@ -2673,10 +2673,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|||||||
/* Setup virDomainNetDef */
|
/* Setup virDomainNetDef */
|
||||||
if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
|
if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) {
|
||||||
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||||
(*def)->model = virtualDev;
|
|
||||||
(*def)->data.bridge.brname = networkName;
|
(*def)->data.bridge.brname = networkName;
|
||||||
|
|
||||||
virtualDev = NULL;
|
|
||||||
networkName = NULL;
|
networkName = NULL;
|
||||||
} else if (STRCASEEQ(connectionType, "hostonly")) {
|
} else if (STRCASEEQ(connectionType, "hostonly")) {
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
@ -2686,16 +2684,12 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (STRCASEEQ(connectionType, "nat")) {
|
} else if (STRCASEEQ(connectionType, "nat")) {
|
||||||
(*def)->type = VIR_DOMAIN_NET_TYPE_USER;
|
(*def)->type = VIR_DOMAIN_NET_TYPE_USER;
|
||||||
(*def)->model = virtualDev;
|
|
||||||
|
|
||||||
virtualDev = NULL;
|
|
||||||
} else if (STRCASEEQ(connectionType, "custom")) {
|
} else if (STRCASEEQ(connectionType, "custom")) {
|
||||||
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
(*def)->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||||
(*def)->model = virtualDev;
|
|
||||||
(*def)->data.bridge.brname = networkName;
|
(*def)->data.bridge.brname = networkName;
|
||||||
(*def)->ifname = vnet;
|
(*def)->ifname = vnet;
|
||||||
|
|
||||||
virtualDev = NULL;
|
|
||||||
networkName = NULL;
|
networkName = NULL;
|
||||||
vnet = NULL;
|
vnet = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -2705,6 +2699,10 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virDomainNetSetModelString((*def), virtualDev) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
VIR_FREE(virtualDev);
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3746,28 +3744,29 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
|
|||||||
virBufferAsprintf(buffer, "ethernet%d.present = \"true\"\n", controller);
|
virBufferAsprintf(buffer, "ethernet%d.present = \"true\"\n", controller);
|
||||||
|
|
||||||
/* def:model -> vmx:virtualDev, vmx:features */
|
/* def:model -> vmx:virtualDev, vmx:features */
|
||||||
if (def->model != NULL) {
|
if (virDomainNetGetModelString(def)) {
|
||||||
if (STRCASENEQ(def->model, "vlance") &&
|
if (!virDomainNetStrcaseeqModelString(def, "vlance") &&
|
||||||
STRCASENEQ(def->model, "vmxnet") &&
|
!virDomainNetStrcaseeqModelString(def, "vmxnet") &&
|
||||||
STRCASENEQ(def->model, "vmxnet2") &&
|
!virDomainNetStrcaseeqModelString(def, "vmxnet2") &&
|
||||||
STRCASENEQ(def->model, "vmxnet3") &&
|
!virDomainNetStrcaseeqModelString(def, "vmxnet3") &&
|
||||||
STRCASENEQ(def->model, "e1000") &&
|
!virDomainNetStrcaseeqModelString(def, "e1000") &&
|
||||||
STRCASENEQ(def->model, "e1000e")) {
|
!virDomainNetStrcaseeqModelString(def, "e1000e")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Expecting domain XML entry 'devices/interface/model' "
|
_("Expecting domain XML entry 'devices/interface/model' "
|
||||||
"to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' "
|
"to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' "
|
||||||
"or 'e1000' or 'e1000e' but found '%s'"), def->model);
|
"or 'e1000' or 'e1000e' but found '%s'"),
|
||||||
|
virDomainNetGetModelString(def));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRCASEEQ(def->model, "vmxnet2")) {
|
if (virDomainNetStrcaseeqModelString(def, "vmxnet2")) {
|
||||||
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"vmxnet\"\n",
|
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"vmxnet\"\n",
|
||||||
controller);
|
controller);
|
||||||
virBufferAsprintf(buffer, "ethernet%d.features = \"15\"\n",
|
virBufferAsprintf(buffer, "ethernet%d.features = \"15\"\n",
|
||||||
controller);
|
controller);
|
||||||
} else {
|
} else {
|
||||||
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n",
|
virBufferAsprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n",
|
||||||
controller, def->model);
|
controller, virDomainNetGetModelString(def));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,9 +265,9 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
|||||||
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
||||||
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
||||||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
|
dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
|
||||||
!dev->data.net->model &&
|
!virDomainNetGetModelString(dev->data.net) &&
|
||||||
def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
|
def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
|
||||||
VIR_STRDUP(dev->data.net->model, "e1000") < 0)
|
virDomainNetSetModelString(dev->data.net, "e1000") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1104,15 +1104,15 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
|
|||||||
|
|
||||||
switch ((int)type) {
|
switch ((int)type) {
|
||||||
case PNT_RTL:
|
case PNT_RTL:
|
||||||
if (VIR_STRDUP(net->model, "rtl8139") < 0)
|
if (virDomainNetSetModelString(net, "rtl8139") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
case PNT_E1000:
|
case PNT_E1000:
|
||||||
if (VIR_STRDUP(net->model, "e1000") < 0)
|
if (virDomainNetSetModelString(net, "e1000") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
case PNT_VIRTIO:
|
case PNT_VIRTIO:
|
||||||
if (VIR_STRDUP(net->model, "virtio") < 0)
|
if (virDomainNetSetModelString(net, "virtio") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -3377,15 +3377,15 @@ static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (isCt) {
|
if (isCt) {
|
||||||
if (net->model)
|
if (virDomainNetGetModelString(net))
|
||||||
VIR_WARN("Setting network adapter for containers is not "
|
VIR_WARN("Setting network adapter for containers is not "
|
||||||
"supported by vz driver.");
|
"supported by vz driver.");
|
||||||
} else {
|
} else {
|
||||||
if (STREQ(net->model, "rtl8139")) {
|
if (virDomainNetStreqModelString(net, "rtl8139")) {
|
||||||
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
|
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
|
||||||
} else if (STREQ(net->model, "e1000")) {
|
} else if (virDomainNetStreqModelString(net, "e1000")) {
|
||||||
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
|
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
|
||||||
} else if (STREQ(net->model, "virtio")) {
|
} else if (virDomainNetStreqModelString(net, "virtio")) {
|
||||||
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
|
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
@ -1069,11 +1069,11 @@ xenParseVif(char *entry, const char *vif_typename)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (model[0] &&
|
if (model[0] &&
|
||||||
VIR_STRDUP(net->model, model) < 0)
|
virDomainNetSetModelString(net, model) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!model[0] && type[0] && STREQ(type, vif_typename) &&
|
if (!model[0] && type[0] && STREQ(type, vif_typename) &&
|
||||||
VIR_STRDUP(net->model, "netfront") < 0)
|
virDomainNetSetModelString(net, "netfront") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (vifname[0] &&
|
if (vifname[0] &&
|
||||||
@ -1422,15 +1422,16 @@ xenFormatNet(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hvm) {
|
if (virDomainNetGetModelString(net)) {
|
||||||
if (net->model != NULL)
|
if (!hvm) {
|
||||||
virBufferAsprintf(&buf, ",model=%s", net->model);
|
virBufferAsprintf(&buf, ",model=%s",
|
||||||
} else {
|
virDomainNetGetModelString(net));
|
||||||
if (net->model != NULL && STREQ(net->model, "netfront")) {
|
|
||||||
virBufferAsprintf(&buf, ",type=%s", vif_typename);
|
|
||||||
} else {
|
} else {
|
||||||
if (net->model != NULL)
|
if (virDomainNetStreqModelString(net, "netfront"))
|
||||||
virBufferAsprintf(&buf, ",model=%s", net->model);
|
virBufferAsprintf(&buf, ",type=%s", vif_typename);
|
||||||
|
else
|
||||||
|
virBufferAsprintf(&buf, ",model=%s",
|
||||||
|
virDomainNetGetModelString(net));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,11 +642,11 @@ xenParseSxprNets(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(net->model, model) < 0)
|
if (virDomainNetSetModelString(net, model) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!model && type && STREQ(type, "netfront") &&
|
if (!model && type && STREQ(type, "netfront") &&
|
||||||
VIR_STRDUP(net->model, "netfront") < 0)
|
virDomainNetSetModelString(net, "netfront") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
tmp = sexpr_node(node, "device/vif/rate");
|
tmp = sexpr_node(node, "device/vif/rate");
|
||||||
@ -1929,15 +1929,16 @@ xenFormatSxprNet(virConnectPtr conn,
|
|||||||
!STRPREFIX(def->ifname, "vif"))
|
!STRPREFIX(def->ifname, "vif"))
|
||||||
virBufferEscapeSexpr(buf, "(vifname '%s')", def->ifname);
|
virBufferEscapeSexpr(buf, "(vifname '%s')", def->ifname);
|
||||||
|
|
||||||
if (!hvm) {
|
if (virDomainNetGetModelString(def)) {
|
||||||
if (def->model != NULL)
|
if (!hvm) {
|
||||||
virBufferEscapeSexpr(buf, "(model '%s')", def->model);
|
virBufferEscapeSexpr(buf, "(model '%s')",
|
||||||
} else {
|
virDomainNetGetModelString(def));
|
||||||
if (def->model != NULL && STREQ(def->model, "netfront")) {
|
|
||||||
virBufferAddLit(buf, "(type netfront)");
|
|
||||||
} else {
|
} else {
|
||||||
if (def->model != NULL)
|
if (virDomainNetStreqModelString(def, "netfront"))
|
||||||
virBufferEscapeSexpr(buf, "(model '%s')", def->model);
|
virBufferAddLit(buf, "(type netfront)");
|
||||||
|
else
|
||||||
|
virBufferEscapeSexpr(buf, "(model '%s')",
|
||||||
|
virDomainNetGetModelString(def));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user