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