提交 0f835855 编写于 作者: C Cole Robinson

vz: convert to net model enum

The vz driver only handles three models: virtio, e1000, and rtl8139.
Add enum values for those models, and convert the vz driver to
handling net->model natively
Acked-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 d79a2c07
...@@ -510,6 +510,9 @@ VIR_ENUM_IMPL(virDomainNetModel, ...@@ -510,6 +510,9 @@ VIR_ENUM_IMPL(virDomainNetModel,
VIR_DOMAIN_NET_MODEL_LAST, VIR_DOMAIN_NET_MODEL_LAST,
"unknown", "unknown",
"netfront", "netfront",
"rtl8139",
"virtio",
"e1000",
); );
VIR_ENUM_IMPL(virDomainNetBackend, VIR_ENUM_IMPL(virDomainNetBackend,
......
...@@ -843,6 +843,9 @@ typedef enum { ...@@ -843,6 +843,9 @@ typedef enum {
typedef enum { typedef enum {
VIR_DOMAIN_NET_MODEL_UNKNOWN, VIR_DOMAIN_NET_MODEL_UNKNOWN,
VIR_DOMAIN_NET_MODEL_NETFRONT, VIR_DOMAIN_NET_MODEL_NETFRONT,
VIR_DOMAIN_NET_MODEL_RTL8139,
VIR_DOMAIN_NET_MODEL_VIRTIO,
VIR_DOMAIN_NET_MODEL_E1000,
VIR_DOMAIN_NET_MODEL_LAST VIR_DOMAIN_NET_MODEL_LAST
} virDomainNetModelType; } virDomainNetModelType;
......
...@@ -265,10 +265,9 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, ...@@ -265,10 +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) &&
!virDomainNetGetModelString(dev->data.net) && dev->data.net->model == VIR_DOMAIN_NET_MODEL_UNKNOWN &&
def->os.type == VIR_DOMAIN_OSTYPE_HVM && def->os.type == VIR_DOMAIN_OSTYPE_HVM)
virDomainNetSetModelString(dev->data.net, "e1000") < 0) dev->data.net->model = VIR_DOMAIN_NET_MODEL_E1000;
return -1;
return 0; return 0;
} }
......
...@@ -1104,16 +1104,13 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt) ...@@ -1104,16 +1104,13 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
switch ((int)type) { switch ((int)type) {
case PNT_RTL: case PNT_RTL:
if (virDomainNetSetModelString(net, "rtl8139") < 0) net->model = VIR_DOMAIN_NET_MODEL_RTL8139;
goto cleanup;
break; break;
case PNT_E1000: case PNT_E1000:
if (virDomainNetSetModelString(net, "e1000") < 0) net->model = VIR_DOMAIN_NET_MODEL_E1000;
goto cleanup;
break; break;
case PNT_VIRTIO: case PNT_VIRTIO:
if (virDomainNetSetModelString(net, "virtio") < 0) net->model = VIR_DOMAIN_NET_MODEL_VIRTIO;
goto cleanup;
break; break;
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -3377,15 +3374,15 @@ static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED, ...@@ -3377,15 +3374,15 @@ static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED,
goto cleanup; goto cleanup;
if (isCt) { if (isCt) {
if (virDomainNetGetModelString(net)) if (net->model != VIR_DOMAIN_NET_MODEL_UNKNOWN)
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 (virDomainNetStreqModelString(net, "rtl8139")) { if (net->model == VIR_DOMAIN_NET_MODEL_RTL8139) {
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL); pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
} else if (virDomainNetStreqModelString(net, "e1000")) { } else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) {
pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000); pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
} else if (virDomainNetStreqModelString(net, "virtio")) { } else if (net->model == VIR_DOMAIN_NET_MODEL_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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册