[PATCH v2 resend 3/4] 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
codes 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 6425290..687032b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -791,6 +791,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 5cb013c..3a98566 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6032,6 +6032,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]