]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: record deprecation messages against the domain
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 22 Jan 2021 14:47:32 +0000 (14:47 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 12 Feb 2021 09:19:12 +0000 (09:19 +0000)
These messages will be stored in the live status XML.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms

index 17e0d1ed31339482ffe3d46d70fb5a7b359cadd5..922310954b4e91bcc5a7ba5bbd8dc019b7154fcb 100644 (file)
@@ -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)
 {
@@ -21258,7 +21267,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;
@@ -21305,10 +21315,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) {
@@ -21322,6 +21332,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;
@@ -29166,6 +29183,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;
index e263e6098b2eec086bb60dbea49cfd3697dd55de..98458c9e74e32a178b4bac558fe5ed7693a2f221 100644 (file)
@@ -2804,6 +2804,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 */
@@ -3061,6 +3063,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);
index 49e665a5f0012dba9a1fe94761c976fe915e6440..5829916c681b3ab5822a6748412947839d016f33 100644 (file)
@@ -548,6 +548,7 @@ virDomainObjAssignDef;
 virDomainObjBroadcast;
 virDomainObjCheckActive;
 virDomainObjCopyPersistentDef;
+virDomainObjDeprecation;
 virDomainObjEndAPI;
 virDomainObjFormat;
 virDomainObjGetDefs;