a41c76
From 1e8e5094ee8112244c32704539202dd02866cfd6 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <1e8e5094ee8112244c32704539202dd02866cfd6@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:33 +0100
a41c76
Subject: [PATCH] qemuDomainGetGuestInfo: don't assign NULL hostname
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Don't rely on error check and assign hostname only when non-NULL.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 530ac288618b2f46e49f3ce86d4d89e7607ee3fe)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1812965
a41c76
Message-Id: <cb3528a36549edc5fdd23cb1e573e99fc43e9d15.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_driver.c | 12 ++++++------
a41c76
 1 file changed, 6 insertions(+), 6 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
a41c76
index 05e525e935..175a1961c2 100644
a41c76
--- a/src/qemu/qemu_driver.c
a41c76
+++ b/src/qemu/qemu_driver.c
a41c76
@@ -23254,14 +23254,14 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
a41c76
     }
a41c76
     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) {
a41c76
         rc = qemuAgentGetHostname(agent, &hostname);
a41c76
-        if (rc < 0 && !(rc == -2 && types == 0)) {
a41c76
+        if (rc < 0 && !(rc == -2 && types == 0))
a41c76
             goto exitagent;
a41c76
-        } else {
a41c76
-            if (virTypedParamsAddString(params, nparams, &maxparams, "hostname",
a41c76
-                                        hostname) < 0)
a41c76
-                goto exitagent;
a41c76
-        }
a41c76
     }
a41c76
+
a41c76
+    if (hostname &&
a41c76
+        virTypedParamsAddString(params, nparams, &maxparams, "hostname", hostname) < 0)
a41c76
+        goto exitagent;
a41c76
+
a41c76
     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
a41c76
         rc = qemuAgentGetFSInfo(agent, &agentfsinfo);
a41c76
         if (rc < 0) {
a41c76
-- 
a41c76
2.25.1
a41c76