提交 848fdabd 编写于 作者: C Cole Robinson

vmx: convert to net model enum

Convert the vmware/vmx driver to net model enum, which requires
adding enum values for vlance, vmxnet, vmxnet2, and vmxnet3.
Acked-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 79c8bc7d
......@@ -520,6 +520,10 @@ VIR_ENUM_IMPL(virDomainNetModel,
"spapr-vlan",
"lan9118",
"scm91c111",
"vlance",
"vmxnet",
"vmxnet2",
"vmxnet3",
);
VIR_ENUM_IMPL(virDomainNetBackend,
......
......@@ -853,6 +853,10 @@ typedef enum {
VIR_DOMAIN_NET_MODEL_SPAPR_VLAN,
VIR_DOMAIN_NET_MODEL_LAN9118,
VIR_DOMAIN_NET_MODEL_SMC91C111,
VIR_DOMAIN_NET_MODEL_VLANCE,
VIR_DOMAIN_NET_MODEL_VMXNET,
VIR_DOMAIN_NET_MODEL_VMXNET2,
VIR_DOMAIN_NET_MODEL_VMXNET3,
VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType;
......
......@@ -2548,6 +2548,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
char networkName_name[48] = "";
char *networkName = NULL;
int netmodel = VIR_DOMAIN_NET_MODEL_UNKNOWN;
if (def == NULL || *def != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
......@@ -2632,11 +2634,17 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
}
if (virtualDev != NULL) {
if (STRCASENEQ(virtualDev, "vlance") &&
STRCASENEQ(virtualDev, "vmxnet") &&
STRCASENEQ(virtualDev, "vmxnet3") &&
STRCASENEQ(virtualDev, "e1000") &&
STRCASENEQ(virtualDev, "e1000e")) {
if (STRCASEEQ(virtualDev, "vlance")) {
netmodel = VIR_DOMAIN_NET_MODEL_VLANCE;
} else if (STRCASEEQ(virtualDev, "vmxnet")) {
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET;
} else if (STRCASEEQ(virtualDev, "vmxnet3")) {
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET3;
} else if (STRCASEEQ(virtualDev, "e1000")) {
netmodel = VIR_DOMAIN_NET_MODEL_E1000;
} else if (STRCASEEQ(virtualDev, "e1000e")) {
netmodel = VIR_DOMAIN_NET_MODEL_E1000E;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'vlance' or 'vmxnet' or "
"'vmxnet3' or 'e1000' or 'e1000e' but found '%s'"),
......@@ -2644,12 +2652,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
goto cleanup;
}
if (STRCASEEQ(virtualDev, "vmxnet") && features == 15) {
VIR_FREE(virtualDev);
if (VIR_STRDUP(virtualDev, "vmxnet2") < 0)
goto cleanup;
}
if (netmodel == VIR_DOMAIN_NET_MODEL_VMXNET && features == 15)
netmodel = VIR_DOMAIN_NET_MODEL_VMXNET2;
}
/* vmx:networkName -> def:data.bridge.brname */
......@@ -2699,10 +2703,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
goto cleanup;
}
if (virDomainNetSetModelString((*def), virtualDev) < 0)
goto cleanup;
VIR_FREE(virtualDev);
(*def)->model = netmodel;
result = 0;
cleanup:
......@@ -3744,29 +3745,30 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
virBufferAsprintf(buffer, "ethernet%d.present = \"true\"\n", controller);
/* def:model -> vmx:virtualDev, vmx:features */
if (virDomainNetGetModelString(def)) {
if (!virDomainNetStrcaseeqModelString(def, "vlance") &&
!virDomainNetStrcaseeqModelString(def, "vmxnet") &&
!virDomainNetStrcaseeqModelString(def, "vmxnet2") &&
!virDomainNetStrcaseeqModelString(def, "vmxnet3") &&
!virDomainNetStrcaseeqModelString(def, "e1000") &&
!virDomainNetStrcaseeqModelString(def, "e1000e")) {
if (def->model) {
if (def->model != VIR_DOMAIN_NET_MODEL_VLANCE &&
def->model != VIR_DOMAIN_NET_MODEL_VMXNET &&
def->model != VIR_DOMAIN_NET_MODEL_VMXNET2 &&
def->model != VIR_DOMAIN_NET_MODEL_VMXNET3 &&
def->model != VIR_DOMAIN_NET_MODEL_E1000 &&
def->model != VIR_DOMAIN_NET_MODEL_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'"),
virDomainNetGetModelString(def));
virDomainNetModelTypeToString(def->model));
return -1;
}
if (virDomainNetStrcaseeqModelString(def, "vmxnet2")) {
if (def->model == VIR_DOMAIN_NET_MODEL_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, virDomainNetGetModelString(def));
controller,
virDomainNetModelTypeToString(def->model));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册