]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use virXPathTristateBool()
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 2 Oct 2025 07:38:04 +0000 (09:38 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 15 Oct 2025 08:04:07 +0000 (10:04 +0200)
There are two places in our code base which can use freshly
introduced virXPathTristateBool():
qemuStorageSourcePrivateDataParse() and
qemuDomainObjPrivateXMLParseBlockjobs().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c

index b39fabfbb4f3eff3a3c1759358ccd8c1880b23cb..60a4bcc64c7189001e0765a9d52f01572f32712b 100644 (file)
@@ -2073,7 +2073,7 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr ctxt,
     g_autofree char *authalias = NULL;
     g_autofree char *httpcookiealias = NULL;
     g_autofree char *tlskeyalias = NULL;
-    g_autofree char *thresholdEventWithIndex = NULL;
+    virTristateBool thresholdEventWithIndex;
     bool fdsetPresent = false;
     unsigned int fdSetID;
     int enccount;
@@ -2139,9 +2139,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;
+    if (virXPathTristateBool("string(./thresholdEvent/@indexUsed)",
+                             ctxt, &thresholdEventWithIndex) >= 0) {
+        virTristateBoolToBool(thresholdEventWithIndex, &src->thresholdEventWithIndex);
+    }
 
     if ((nbdkitnode = virXPathNode("nbdkit", ctxt))) {
         if (qemuStorageSourcePrivateDataParseNbdkit(nbdkitnode, ctxt, src) < 0)