virt-manager/SOURCES/virt-manager-inspection-fix-check-of-null-icon.patch

52 lines
2.0 KiB
Diff
Raw Normal View History

2019-05-07 13:21:15 +00:00
From caea48c879b0a5d292c74a4a3721d56350cf5537 Mon Sep 17 00:00:00 2001
Message-Id: <caea48c879b0a5d292c74a4a3721d56350cf5537@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Wed, 30 Jan 2019 18:28:14 +0100
Subject: [PATCH] inspection: fix check of null icon
From: Pino Toscano <ptoscano@redhat.com>
Recently the Python binding of libguestfs was adapted to properly use
bytes in APIs that return data, instead of (ab)using strings [1].
This change was done only when built for Python 3, which has this
distinct bytes and strings.
Because of that, now the 'icon == ""' (empty string) checks fail, using
whatever inspect_get_icon() returns, including empty arrays of bytes.
Hence, change the checks to use the length of the data as condition, as
also the libguestfs Python API documentation says. Leave also the
checks for None, in the remote case the API will return None in the
future for no data.
[1] https://github.com/libguestfs/libguestfs/commit/0ee02e0117527b86a31b2a88a14994ce7f15571f
(cherry picked from commit bce4cc4ef837754de81e1420905159cc2fc3d773)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1671278
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
virtManager/inspection.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/virtManager/inspection.py b/virtManager/inspection.py
index ea6123b8..fde48474 100644
--- a/virtManager/inspection.py
+++ b/virtManager/inspection.py
@@ -268,10 +268,10 @@ class vmmInspection(vmmGObject):
if filesystems_mounted:
# string containing PNG data
icon = g.inspect_get_icon(root, favicon=0, highquality=1)
- if icon == "" or icon is None:
+ if icon is None or len(icon) == 0:
# no high quality icon, try a low quality one
icon = g.inspect_get_icon(root, favicon=0, highquality=0)
- if icon == "":
+ if icon is None or len(icon) == 0:
icon = None
# Inspection applications.
--
2.20.1