[PATCH 03/20] qemuMigrationCookieXMLParse: Check domain element count more defensively

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

 



Make sure that 'virXPathNodeSet' returns '1' as the only expected value
rather than relying on the fact that the previous check for the number
of elements ensures success of the subsequent call.

The error message no longer mentions the number of <domain> elements in
the cookie, but this is a very unlikely internal error anyways.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration_cookie.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index f313b6d00e..9b1268833a 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1215,7 +1215,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
     g_autofree char *hostuuid = NULL;
     char localdomuuid[VIR_UUID_STRING_BUFLEN];
     xmlNodePtr *nodes = NULL;
-    int n;

     /* We don't store the uuid, name, hostname, or hostuuid
      * values. We just compare them to local data to do some
@@ -1300,11 +1299,9 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,

     if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
         virXPathBoolean("count(./domain) > 0", ctxt)) {
-        if ((n = virXPathNodeSet("./domain", ctxt, &nodes)) > 1) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Too many domain elements in "
-                             "migration cookie: %d"),
-                           n);
+        if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Too many domain elements in migration cookie"));
             goto error;
         }
         mig->persistent = virDomainDefParseNode(doc, nodes[0],
-- 
2.26.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