]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_source: Add flag storing whether threshold event was registered with index
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Jul 2021 14:03:56 +0000 (16:03 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Jul 2021 14:34:07 +0000 (16:34 +0200)
When users register the threshold event for the top level image with an
explicit index (e.g. vda[3]) they are clearly expecting the index in the
event.

This flag will help avoiding emission of the second event without the
index when the client clearly requested one with the index.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/storage_source_conf.h
src/qemu/qemu_domain.c
tests/qemustatusxml2xmldata/modern-in.xml

index 389c7b56d13211cc71f432f59bcad5f003800f76..40db29c418b13ebc38293f3950de8243899dbadd 100644 (file)
@@ -387,6 +387,11 @@ struct _virStorageSource {
     char *nfs_group;
     uid_t nfs_uid;
     gid_t nfs_gid;
+
+    /* We need a flag to remember that the threshold event for this source was
+     * registered with a full index (vda[3]) so that we can properly report just
+     * one event for it */
+    bool thresholdEventWithIndex;
 };
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref);
index 5fcd5e7f8207a31b2bf8dc5c456f16819f213354..89e03fdf72ef1737a4a9c35ac7a0b396f48a01ed 100644 (file)
@@ -1951,6 +1951,7 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
     g_autofree char *encalias = NULL;
     g_autofree char *httpcookiealias = NULL;
     g_autofree char *tlskeyalias = NULL;
+    g_autofree char *thresholdEventWithIndex = NULL;
 
     src->nodestorage = virXPathString("string(./nodenames/nodename[@type='storage']/@name)", ctxt);
     src->nodeformat = virXPathString("string(./nodenames/nodename[@type='format']/@name)", ctxt);
@@ -1990,6 +1991,10 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
     if (virStorageSourcePrivateDataParseRelPath(ctxt, src) < 0)
         return -1;
 
+    if ((thresholdEventWithIndex = virXPathString("string(./thresholdEvent/@indexUsed)", ctxt)) &&
+        virTristateBoolTypeFromString(thresholdEventWithIndex) == VIR_TRISTATE_BOOL_YES)
+        src->thresholdEventWithIndex = true;
+
     return 0;
 }
 
@@ -2044,6 +2049,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSource *src,
 
     virXMLFormatElement(buf, "objects", NULL, &tmp);
 
+    if (src->thresholdEventWithIndex)
+        virBufferAddLit(buf, "<thresholdEvent indexUsed='yes'/>\n");
+
     return 0;
 }
 
index ba0858a4ff0544a1771739ce3df11567caba52b1..cc5fd1cb74b6f7cc25576c794840a404cd0eda99 100644 (file)
                 <secret type='tlskey' alias='tls-certificate-key-alias'/>
                 <TLSx509 alias='transport-alias'/>
               </objects>
+              <thresholdEvent indexUsed='yes'/>
             </privateData>
           </source>
           <backingStore/>