[PATCH 4/5] qemu: add NIC model checking for qemu hypervisor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As the enum virDomainNICModel is a big collection of NIC models
for all of hypervisors, for qemu/kvm, only some of them are
supported, so the patch tries to add a checking for NIC model that
is qemu specific.

The way of doing this is the same as VMX and Vbox do which have
code to validate the hypervisor-specific NIC model in their
implementation rather than domain XML parsing code.
---
 src/conf/domain_conf.h  | 6 ++++++
 src/qemu/qemu_command.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a5ce119..2921cab 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -790,6 +790,12 @@ enum virDomainNICModel {
     VIR_DOMAIN_NIC_MODEL_PCNET,
     VIR_DOMAIN_NIC_MODEL_RTL8139,
     VIR_DOMAIN_NIC_MODEL_E1000,
+
+    /* Add new NIC model for qemu above this.
+     */
+    VIR_DOMAIN_NIC_MODEL_FOR_QEMU_END =
+        VIR_DOMAIN_NIC_MODEL_E1000,
+
     VIR_DOMAIN_NIC_MODEL_NETFRONT,
     VIR_DOMAIN_NIC_MODEL_VLANCE,
     VIR_DOMAIN_NIC_MODEL_VMXNET,
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9ba27a1..fcd7512 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6020,6 +6020,13 @@ qemuBuildCommandLine(virConnectPtr conn,
             else
                 vlan = i;
 
+            if (net->model < 0 || net->model > VIR_DOMAIN_NIC_MODEL_FOR_QEMU_END) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               "NIC model '%s' is unsupported for QEMU",
+                               virDomainNICModelTypeToString(net->model));
+                goto error;
+            }
+
             /* If appropriate, grab a physical device from the configured
              * network's pool of devices, or resolve bridge device name
              * to the one defined in the network definition.
-- 
1.7.11.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]