[libvirt PATCH v2 1/6] conf: record deprecation messages against the domain

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

 



These messages will be stored in the live status XML.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/conf/domain_conf.c   | 28 +++++++++++++++++++++++++---
 src/conf/domain_conf.h   |  4 ++++
 src/libvirt_private.syms |  1 +
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 07e6f39256..a873c0ada2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1788,6 +1788,15 @@ bool virDomainObjTaint(virDomainObjPtr obj,
 }
 
 
+void virDomainObjDeprecation(virDomainObjPtr obj,
+                             const char *msg)
+{
+    obj->deprecations = g_renew(char *, obj->deprecations,
+                                obj->ndeprecations + 1);
+    obj->deprecations[obj->ndeprecations++] = g_strdup(msg);
+}
+
+
 static void
 virDomainGraphicsAuthDefClear(virDomainGraphicsAuthDefPtr def)
 {
@@ -21225,7 +21234,8 @@ virDomainObjParseXML(xmlDocPtr xml,
     int reason = 0;
     void *parseOpaque = NULL;
     g_autofree char *tmp = NULL;
-    g_autofree xmlNodePtr *nodes = NULL;
+    g_autofree xmlNodePtr *taintNodes = NULL;
+    g_autofree xmlNodePtr *depNodes = NULL;
 
     if (!(obj = virDomainObjNew(xmlopt)))
         return NULL;
@@ -21272,10 +21282,10 @@ virDomainObjParseXML(xmlDocPtr xml,
     }
     obj->pid = (pid_t)val;
 
-    if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0)
+    if ((n = virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0)
         goto error;
     for (i = 0; i < n; i++) {
-        char *str = virXMLPropString(nodes[i], "flag");
+        char *str = virXMLPropString(taintNodes[i], "flag");
         if (str) {
             int flag = virDomainTaintTypeFromString(str);
             if (flag < 0) {
@@ -21289,6 +21299,13 @@ virDomainObjParseXML(xmlDocPtr xml,
         }
     }
 
+    if ((n = virXPathNodeSet("./deprecation", ctxt, &depNodes)) < 0)
+        goto error;
+    for (i = 0; i < n; i++) {
+        g_autofree char *str = virXMLNodeContentString(depNodes[i]);
+        virDomainObjDeprecation(obj, str);
+    }
+
     if (xmlopt->privateData.parse &&
         xmlopt->privateData.parse(ctxt, obj, &xmlopt->config) < 0)
         goto error;
@@ -29122,6 +29139,11 @@ virDomainObjFormat(virDomainObjPtr obj,
                               virDomainTaintTypeToString(i));
     }
 
+    for (i = 0; i < obj->ndeprecations; i++) {
+        virBufferEscapeString(&buf, "<deprecation>%s</deprecation>\n",
+                              obj->deprecations[i]);
+    }
+
     if (xmlopt->privateData.format &&
         xmlopt->privateData.format(&buf, obj) < 0)
         return NULL;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8b1c8643be..ea6370c03d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2801,6 +2801,8 @@ struct _virDomainObj {
     void (*privateDataFreeFunc)(void *);
 
     int taint;
+    size_t ndeprecations;
+    char **deprecations;
 
     unsigned long long original_memlock; /* Original RLIMIT_MEMLOCK, zero if no
                                           * restore will be required later */
@@ -3058,6 +3060,8 @@ void virDomainObjEndAPI(virDomainObjPtr *vm);
 
 bool virDomainObjTaint(virDomainObjPtr obj,
                        virDomainTaintFlags taint);
+void virDomainObjDeprecation(virDomainObjPtr obj,
+                             const char *msg);
 
 void virDomainObjBroadcast(virDomainObjPtr vm);
 int virDomainObjWait(virDomainObjPtr vm);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0636b0d8c9..512da526fc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -547,6 +547,7 @@ virDomainObjAssignDef;
 virDomainObjBroadcast;
 virDomainObjCheckActive;
 virDomainObjCopyPersistentDef;
+virDomainObjDeprecation;
 virDomainObjEndAPI;
 virDomainObjFormat;
 virDomainObjGetDefs;
-- 
2.29.2




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

  Powered by Linux