diff mbox series

[v2,06/11] bhyve: convert to net model enum

Message ID a1c777171a0cf7b42602767d14f6ae8b11404560.1552492022.git.crobinso@redhat.com
State Accepted
Commit c0cf17c280bb5cce69aed0828af6a3633b9a2dd5
Headers show
Series conf: partial net model enum conversion | expand

Commit Message

Cole Robinson March 13, 2019, 3:51 p.m. UTC
The bhyve driver only works with the virtio and e1000 models,
which we already have in the enum. Some error reporting is
slightly downgraded to avoid some subtle usage of modelstr

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

---
 src/bhyve/bhyve_command.c       | 15 ++++-----------
 src/bhyve/bhyve_parse_command.c | 10 ++++------
 2 files changed, 8 insertions(+), 17 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/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index d3d790f6b6..219e2b8d9e 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -57,16 +57,10 @@  bhyveBuildNetArgStr(virConnectPtr conn,
     int ret = -1;
     virDomainNetType actualType = virDomainNetGetActualType(net);
 
-    if (!virDomainNetGetModelString(net)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("NIC model must be specified"));
-        return -1;
-    }
-
-    if (virDomainNetStreqModelString(net, "virtio")) {
+    if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) {
         if (VIR_STRDUP(nic_model, "virtio-net") < 0)
             return -1;
-    } else if (virDomainNetStreqModelString(net, "e1000")) {
+    } else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) {
         if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) {
             if (VIR_STRDUP(nic_model, "e1000") < 0)
                 return -1;
@@ -77,9 +71,8 @@  bhyveBuildNetArgStr(virConnectPtr conn,
             return -1;
         }
     } else {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("NIC model '%s' is not supported"),
-                       virDomainNetGetModelString(net));
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("NIC model is not supported"));
         return -1;
     }
 
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index 60eb4c5412..490381688c 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -492,7 +492,7 @@  bhyveParsePCINet(virDomainDefPtr def,
                  unsigned pcislot,
                  unsigned pcibus,
                  unsigned function,
-                 const char *model,
+                 int model,
                  const char *config)
 {
     /* -s slot,virtio-net,tapN[,mac=xx:xx:xx:xx:xx:xx] */
@@ -511,9 +511,7 @@  bhyveParsePCINet(virDomainDefPtr def,
     if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0)
         goto error;
 
-    if (virDomainNetSetModelString(net, model) < 0)
-        goto error;
-
+    net->model = model;
     net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
     net->info.addr.pci.slot = pcislot;
     net->info.addr.pci.bus = pcibus;
@@ -621,10 +619,10 @@  bhyveParseBhyvePCIArg(virDomainDefPtr def,
                           conf);
     else if (STREQ(emulation, "virtio-net"))
         bhyveParsePCINet(def, xmlopt, caps, pcislot, bus, function,
-                         "virtio", conf);
+                         VIR_DOMAIN_NET_MODEL_VIRTIO, conf);
     else if (STREQ(emulation, "e1000"))
         bhyveParsePCINet(def, xmlopt, caps, pcislot, bus, function,
-                         "e1000", conf);
+                         VIR_DOMAIN_NET_MODEL_E1000, conf);
 
     VIR_FREE(emulation);
     VIR_FREE(slotdef);