提交 17a1bd7e 编写于 作者: C Cole Robinson

vbox: Convert to net enum model

Convert the vbox driver to net model enum, which requires adding
enum values for Am79C970A, Am79C973, 82540EM, 82545EM, 82543GC. We
preserve the same casing that vbox historically used for these model
names.

Remove the now unused virDomainNetStrcaseeqModelString
Acked-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 848fdabd
...@@ -524,6 +524,11 @@ VIR_ENUM_IMPL(virDomainNetModel, ...@@ -524,6 +524,11 @@ VIR_ENUM_IMPL(virDomainNetModel,
"vmxnet", "vmxnet",
"vmxnet2", "vmxnet2",
"vmxnet3", "vmxnet3",
"Am79C970A",
"Am79C973",
"82540EM",
"82545EM",
"82543GC",
); );
VIR_ENUM_IMPL(virDomainNetBackend, VIR_ENUM_IMPL(virDomainNetBackend,
...@@ -29532,15 +29537,6 @@ virDomainNetSetModelString(virDomainNetDefPtr net, ...@@ -29532,15 +29537,6 @@ virDomainNetSetModelString(virDomainNetDefPtr net,
return 0; return 0;
} }
int
virDomainNetStrcaseeqModelString(const virDomainNetDef *net,
const char *model)
{
if (net->model)
return STRCASEEQ(virDomainNetModelTypeToString(net->model), model);
return net->modelstr && STRCASEEQ(net->modelstr, model);
}
bool bool
virDomainNetIsVirtioModel(const virDomainNetDef *net) virDomainNetIsVirtioModel(const virDomainNetDef *net)
{ {
......
...@@ -857,6 +857,11 @@ typedef enum { ...@@ -857,6 +857,11 @@ typedef enum {
VIR_DOMAIN_NET_MODEL_VMXNET, VIR_DOMAIN_NET_MODEL_VMXNET,
VIR_DOMAIN_NET_MODEL_VMXNET2, VIR_DOMAIN_NET_MODEL_VMXNET2,
VIR_DOMAIN_NET_MODEL_VMXNET3, VIR_DOMAIN_NET_MODEL_VMXNET3,
VIR_DOMAIN_NET_MODEL_AM79C970A,
VIR_DOMAIN_NET_MODEL_AM79C973,
VIR_DOMAIN_NET_MODEL_82540EM,
VIR_DOMAIN_NET_MODEL_82545EM,
VIR_DOMAIN_NET_MODEL_82543GC,
VIR_DOMAIN_NET_MODEL_LAST VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType; } virDomainNetModelType;
...@@ -3137,8 +3142,6 @@ bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface); ...@@ -3137,8 +3142,6 @@ bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
const char *virDomainNetGetModelString(const virDomainNetDef *net); const char *virDomainNetGetModelString(const virDomainNetDef *net);
int virDomainNetSetModelString(virDomainNetDefPtr et, int virDomainNetSetModelString(virDomainNetDefPtr et,
const char *model); 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,
......
...@@ -487,7 +487,6 @@ virDomainNetRemoveHostdev; ...@@ -487,7 +487,6 @@ virDomainNetRemoveHostdev;
virDomainNetResolveActualType; virDomainNetResolveActualType;
virDomainNetSetDeviceImpl; virDomainNetSetDeviceImpl;
virDomainNetSetModelString; virDomainNetSetModelString;
virDomainNetStrcaseeqModelString;
virDomainNetTypeFromString; virDomainNetTypeFromString;
virDomainNetTypeSharesHostView; virDomainNetTypeSharesHostView;
virDomainNetTypeToString; virDomainNetTypeToString;
......
...@@ -1310,7 +1310,7 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine) ...@@ -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, virDomainNetGetModelString(def->nets[i])); VIR_DEBUG("NIC(%zu): Model: %s", i, virDomainNetModelTypeToString(def->nets[i]->model));
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) ...@@ -1339,19 +1339,19 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
gVBoxAPI.UINetworkAdapter.SetEnabled(adapter, 1); gVBoxAPI.UINetworkAdapter.SetEnabled(adapter, 1);
if (virDomainNetGetModelString(def->nets[i])) { if (def->nets[i]->model) {
if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C970A")) { if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_AM79C970A) {
adapterType = NetworkAdapterType_Am79C970A; adapterType = NetworkAdapterType_Am79C970A;
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "Am79C973")) { } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_AM79C973) {
adapterType = NetworkAdapterType_Am79C973; adapterType = NetworkAdapterType_Am79C973;
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82540EM")) { } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82540EM) {
adapterType = NetworkAdapterType_I82540EM; adapterType = NetworkAdapterType_I82540EM;
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82545EM")) { } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82545EM) {
adapterType = NetworkAdapterType_I82545EM; adapterType = NetworkAdapterType_I82545EM;
} else if (virDomainNetStrcaseeqModelString(def->nets[i], "82543GC")) { } else if (def->nets[i]->model == VIR_DOMAIN_NET_MODEL_82543GC) {
adapterType = NetworkAdapterType_I82543GC; adapterType = NetworkAdapterType_I82543GC;
} else if (gVBoxAPI.APIVersion >= 3000051 && } else if (gVBoxAPI.APIVersion >= 3000051 &&
virDomainNetStrcaseeqModelString(def->nets[i], "virtio")) { def->nets[i]->model == VIR_DOMAIN_NET_MODEL_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;
} }
...@@ -3688,7 +3688,6 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) ...@@ -3688,7 +3688,6 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
{ {
PRUint32 attachmentType = NetworkAttachmentType_Null; PRUint32 attachmentType = NetworkAttachmentType_Null;
PRUint32 adapterType = NetworkAdapterType_Null; PRUint32 adapterType = NetworkAdapterType_Null;
const char *model = NULL;
PRUnichar *utf16 = NULL; PRUnichar *utf16 = NULL;
char *utf8 = NULL; char *utf8 = NULL;
virDomainNetDefPtr net = NULL; virDomainNetDefPtr net = NULL;
...@@ -3743,28 +3742,26 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter) ...@@ -3743,28 +3742,26 @@ vboxDumpNetwork(vboxDriverPtr data, INetworkAdapter *adapter)
gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapterType); gVBoxAPI.UINetworkAdapter.GetAdapterType(adapter, &adapterType);
switch (adapterType) { switch (adapterType) {
case NetworkAdapterType_Am79C970A: case NetworkAdapterType_Am79C970A:
model = "Am79C970A"; net->model = VIR_DOMAIN_NET_MODEL_AM79C970A;
break; break;
case NetworkAdapterType_Am79C973: case NetworkAdapterType_Am79C973:
model = "Am79C973"; net->model = VIR_DOMAIN_NET_MODEL_AM79C973;
break; break;
case NetworkAdapterType_I82540EM: case NetworkAdapterType_I82540EM:
model = "82540EM"; net->model = VIR_DOMAIN_NET_MODEL_82540EM;
break; break;
case NetworkAdapterType_I82545EM: case NetworkAdapterType_I82545EM:
model = "82545EM"; net->model = VIR_DOMAIN_NET_MODEL_82545EM;
break; break;
case NetworkAdapterType_I82543GC: case NetworkAdapterType_I82543GC:
model = "82543GC"; net->model = VIR_DOMAIN_NET_MODEL_82543GC;
break; break;
case NetworkAdapterType_Virtio: case NetworkAdapterType_Virtio:
/* Only vbox 3.1 and later support NetworkAdapterType_Virto */ /* Only vbox 3.1 and later support NetworkAdapterType_Virto */
if (gVBoxAPI.APIVersion >= 3000051) if (gVBoxAPI.APIVersion >= 3000051)
model = "virtio"; net->model = VIR_DOMAIN_NET_MODEL_VIRTIO;
break; break;
} }
if (virDomainNetSetModelString(net, model) < 0)
goto error;
gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16); gVBoxAPI.UINetworkAdapter.GetMACAddress(adapter, &utf16);
VBOX_UTF16_TO_UTF8(utf16, &utf8); VBOX_UTF16_TO_UTF8(utf16, &utf8);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册