[libvirt PATCH 02/18] conf: stronger error reporting when parsing audio related params

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

 



Check for varuous mandatory elements and improve error message
clarity

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b731744f04..d30ca627aa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13794,6 +13794,11 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt,
     if (audioNode) {
         g_autofree char *tmp = NULL;
         tmp = virXMLPropString(audioNode, "id");
+        if (!tmp) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("missing audio 'id' attribute"));
+            goto error;
+        }
         if (virStrToLong_ui(tmp, NULL, 10, &def->audioId) < 0 ||
             def->audioId == 0) {
             virReportError(VIR_ERR_XML_ERROR,
@@ -13867,6 +13872,12 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED,
     ctxt->node = node;
 
     type = virXMLPropString(node, "type");
+    if (!type) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("missing audio 'type' attribute"));
+        goto error;
+    }
+
     if ((def->type = virDomainAudioTypeTypeFromString(type)) < 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("unknown audio type '%s'"), type);
@@ -13874,6 +13885,11 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED,
     }
 
     tmp = virXMLPropString(node, "id");
+    if (!tmp) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("missing audio 'id' attribute"));
+        goto error;
+    }
     if (virStrToLong_ui(tmp, NULL, 10, &def->id) < 0 ||
         def->id == 0) {
         virReportError(VIR_ERR_XML_ERROR,
-- 
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