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