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

[libvirt] [PATCH 06/10] linkstate: Add parsing code for new XML element



---
 src/conf/domain_conf.c |   19 +++++++++++++++++++
 src/conf/domain_conf.h |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 010ce57..053f324 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2748,6 +2748,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
     char *internal = NULL;
     char *devaddr = NULL;
     char *mode = NULL;
+    char *linkstate = NULL;
     virNWFilterHashTablePtr filterparams = NULL;
     virVirtualPortProfileParamsPtr virtPort = NULL;
     virDomainActualNetDefPtr actual = NULL;
@@ -2824,6 +2825,9 @@ virDomainNetDefParseXML(virCapsPtr caps,
                     /* An auto-generated target name, blank it out */
                     VIR_FREE(ifname);
                 }
+            } else if ((linkstate == NULL) &&
+                       xmlStrEqual(cur->name, BAD_CAST "link")) {
+                linkstate = virXMLPropString(cur, "state");
             } else if ((script == NULL) &&
                        (def->type == VIR_DOMAIN_NET_TYPE_ETHERNET ||
                         def->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
@@ -3077,6 +3081,14 @@ virDomainNetDefParseXML(virCapsPtr caps,
         }
     }

+    def->linkstate = VIR_LINK_STATE_DEFAULT;
+    if (linkstate != NULL) {
+        if (STREQ(linkstate, "down"))
+            def->linkstate = VIR_LINK_STATE_DOWN;
+        else
+            def->linkstate = VIR_LINK_STATE_UP;
+    }
+
     if (filter != NULL) {
         switch (def->type) {
         case VIR_DOMAIN_NET_TYPE_ETHERNET:
@@ -3123,6 +3135,7 @@ cleanup:
     VIR_FREE(internal);
     VIR_FREE(devaddr);
     VIR_FREE(mode);
+    VIR_FREE(linkstate);
     virNWFilterHashTableFree(filterparams);

     return def;
@@ -9019,6 +9032,12 @@ virDomainNetDefFormat(virBufferPtr buf,
         virBufferAddLit(buf,   "      </tune>\n");
     }

+
+    if (def->linkstate == VIR_LINK_STATE_DOWN)
+        virBufferAddLit(buf,   "      <link state='down'/>\n");
+    if (def->linkstate == VIR_LINK_STATE_UP)
+        virBufferAddLit(buf,   "      <link state='up'/>\n");
+
     if (virBandwidthDefFormat(buf, def->bandwidth, "      ") < 0)
         return -1;

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index abf9cbd..4655563 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -427,6 +427,7 @@ struct _virDomainNetDef {
     char *filter;
     virNWFilterHashTablePtr filterparams;
     virBandwidthPtr bandwidth;
+    unsigned int linkstate;
 };

 /* Used for prefix of ifname of any network name generated dynamically
-- 
1.7.6


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