render / rpms / libvirt

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