diff mbox series

[05/10] vz: convert to net model enum

Message ID 8f79ddeb607669441bc0d93325ddf1b27ded8b2d.1547851897.git.crobinso@redhat.com
State Superseded
Headers show
Series RFC: conf: partially net model enum conversion | expand

Commit Message

Cole Robinson Jan. 18, 2019, 11:05 p.m. UTC
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

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_conf.c |  5 ++++-
 src/conf/domain_conf.h |  3 +++
 src/vz/vz_driver.c     |  7 +++----
 src/vz/vz_sdk.c        | 17 +++++++----------
 4 files changed, 17 insertions(+), 15 deletions(-)

-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 129e16bd0b..9b651d06b6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -438,7 +438,10 @@  VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainNetModel, VIR_DOMAIN_NET_MODEL_LAST,
               "unknown",
-              "netfront")
+              "netfront",
+              "rtl8139",
+              "virtio",
+              "e1000")
 
 VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST,
               "default",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e26b885508..2e1235a993 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -964,6 +964,9 @@  typedef enum {
 typedef enum {
     VIR_DOMAIN_NET_MODEL_UNKNOWN,
     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
 } virDomainNetModelType;
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index eab2953759..10fba0efb7 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -269,10 +269,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) &&
-        !virDomainNetGetModelString(dev->data.net) &&
-        def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
-        virDomainNetSetModelString(dev->data.net, "e1000") < 0)
-        return -1;
+        dev->data.net->model == VIR_DOMAIN_NET_MODEL_UNKNOWN &&
+        def->os.type == VIR_DOMAIN_OSTYPE_HVM)
+        dev->data.net->model = VIR_DOMAIN_NET_MODEL_E1000;
 
     return 0;
 }
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 60681591c6..13f18cbc19 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1105,16 +1105,13 @@  prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr net, bool isCt)
 
         switch ((int)type) {
         case PNT_RTL:
-            if (virDomainNetSetModelString(net, "rtl8139") < 0)
-                goto cleanup;
+            net->model = VIR_DOMAIN_NET_MODEL_RTL8139;
             break;
         case PNT_E1000:
-            if (virDomainNetSetModelString(net, "e1000") < 0)
-                goto cleanup;
+            net->model = VIR_DOMAIN_NET_MODEL_E1000;
             break;
         case PNT_VIRTIO:
-            if (virDomainNetSetModelString(net, "virtio") < 0)
-                goto cleanup;
+            net->model = VIR_DOMAIN_NET_MODEL_VIRTIO;
             break;
         default:
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3378,15 +3375,15 @@  static int prlsdkConfigureNet(vzDriverPtr driver ATTRIBUTE_UNUSED,
         goto cleanup;
 
     if (isCt) {
-        if (virDomainNetGetModelString(net))
+        if (net->model != VIR_DOMAIN_NET_MODEL_UNKNOWN)
             VIR_WARN("Setting network adapter for containers is not "
                      "supported by vz driver.");
     } else {
-        if (virDomainNetStreqModelString(net, "rtl8139")) {
+        if (net->model == VIR_DOMAIN_NET_MODEL_RTL8139) {
             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);
-        } else if (virDomainNetStreqModelString(net, "virtio")) {
+        } else if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) {
             pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
         } else {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",