[PATCH 1/5] qemu: Add nic model to XML format.

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

 



Signed-off-by: Jim Paris <jim@xxxxxxxx>
---
 src/qemu_conf.c |   21 +++++++++++++++++++++
 src/qemu_conf.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index f3b8f4e..c463ffb 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -644,6 +644,7 @@ static struct qemud_vm_net_def *qemudParseInterfaceXML(virConnectPtr conn,
     struct qemud_vm_net_def *net = calloc(1, sizeof(struct qemud_vm_net_def));
     xmlNodePtr cur;
     xmlChar *macaddr = NULL;
+    xmlChar *model = NULL;
     xmlChar *type = NULL;
     xmlChar *network = NULL;
     xmlChar *bridge = NULL;
@@ -687,6 +688,9 @@ static struct qemud_vm_net_def *qemudParseInterfaceXML(virConnectPtr conn,
             if ((macaddr == NULL) &&
                 (xmlStrEqual(cur->name, BAD_CAST "mac"))) {
                 macaddr = xmlGetProp(cur, BAD_CAST "address");
+            } else if ((model == NULL) &&
+                       (xmlStrEqual(cur->name, BAD_CAST "nic"))) {
+                model = xmlGetProp(cur, BAD_CAST "model");
             } else if ((network == NULL) &&
                        (net->type == QEMUD_NET_NETWORK) &&
                        (xmlStrEqual(cur->name, BAD_CAST "source"))) {
@@ -739,6 +743,21 @@ static struct qemud_vm_net_def *qemudParseInterfaceXML(virConnectPtr conn,
         qemudRandomMAC(net);
     }
 
+    if (model) {
+        int len;
+
+        if ((len = xmlStrlen(model)) >= (QEMUD_MAX_MODEL_LEN-1)) {
+            qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                             "NIC model type '%s' is too long", model);
+            goto error;
+        } else {
+            strncpy(net->model, (char *)model, len);
+            net->model[len] = '\0';
+        }
+        xmlFree(model);
+        model = NULL;
+    }        
+
     if (net->type == QEMUD_NET_NETWORK) {
         int len;
 
@@ -872,6 +891,8 @@ static struct qemud_vm_net_def *qemudParseInterfaceXML(virConnectPtr conn,
     return net;
 
  error:
+    if (model)
+        xmlFree(model);
     if (network)
         xmlFree(network);
     if (address)
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index e1844da..d95871e 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -79,6 +79,7 @@ enum qemud_vm_net_type {
 };
 
 #define QEMUD_MAX_NAME_LEN 50
+#define QEMUD_MAX_MODEL_LEN 16
 #define QEMUD_MAX_XML_LEN 4096
 #define QEMUD_MAX_ERROR_LEN 1024
 
@@ -86,6 +87,7 @@ enum qemud_vm_net_type {
 struct qemud_vm_net_def {
     int type;
     unsigned char mac[QEMUD_MAC_ADDRESS_LEN];
+    char model[QEMUD_MAX_MODEL_LEN];
     union {
         struct {
             char ifname[BR_IFNAME_MAXLEN];
-- 
1.5.3.4

--
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]