virtinst: Fix not to return duplicate entries from all_machine_names()

Since machine's canonical alias can be the same as other machine's
name, current all_machine_names() may return duplicates entries.
This causes the problem that the entry of "virt-5.0" appears twice in
machine selection menu when aarch64 is used.

So, fix this by just not adding the same entry twice.

Signed-off-by: Misono Tomohiro <misono.tm@gmail.com>
This commit is contained in:
Misono Tomohiro 2020-07-25 00:11:38 +09:00 committed by Pavel Hrdina
parent d773c4d934
commit 8744e741d1
1 changed files with 2 additions and 2 deletions

View File

@ -138,13 +138,13 @@ class _CapsGuest(XMLBuilder):
def all_machine_names(self, domain):
"""
Return all machine string names, including canonical aliases for
the guest+domain combo
the guest+domain combo but avoiding duplicates
"""
mobjs = (domain and domain.machines) or self.machines
ret = []
for m in mobjs:
ret.append(m.name)
if m.canonical:
if m.canonical and m.canonical not in ret:
ret.append(m.canonical)
return ret