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