[gnome-boxes] vm-configurator: Don't use device.get_name () directly
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] vm-configurator: Don't use device.get_name () directly
- Date: Tue, 16 Oct 2018 07:59:39 +0000 (UTC)
commit 2f73a7d7f3a4084ea4d189c1ac3acca0338f1032
Author: Fabiano FidĂȘncio <fidencio redhat com>
Date: Mon Oct 15 08:01:47 2018 +0200
vm-configurator: Don't use device.get_name () directly
According to libosinfo the device's name element is simply a human
readable string but there's absolutely no guarantee that it's the device
name used by qemu/libvirt.
So far, we've been lucky enough to never hit a poblem because of that
but there was already some issues on virt-manager because they were
blindly using that.
In order to avoid issues for the future, let's actually translate (on
our side for now) the libosinfo names into qemu/libvirt names (the ones
supported by libvirt-glib) and ensure we always use a valid one.
One example of the issue is the "ich9-hda" audio device that's known as
"ich9" on libvirt-glib side. Fortunately, we wouldn't never ever hit the
issue there as for this cases we're already returning the
DomainSoundModel.
Signed-off-by: Fabiano FidĂȘncio <fidencio redhat com>
src/vm-configurator.vala | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index c6f23bad..344cfeb1 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -379,7 +379,23 @@ private static DomainSoundModel get_sound_model (InstallerMedia install_media) {
if (device == null)
return (DomainSoundModel) DomainSoundModel.ICH6;
- var model = get_enum_value (device.get_name (), typeof (DomainSoundModel));
+ var osinfo_name = device.get_name ();
+ var libvirt_name = "";
+
+ if (osinfo_name == "ich9-hda")
+ libvirt_name = "ich9";
+ else if (osinfo_name == "ich6")
+ libvirt_name = "ich6";
+ else if (osinfo_name == "ac97")
+ libvirt_name = "ac97";
+ else if (osinfo_name == "pcspk")
+ libvirt_name = "pcspk";
+ else if (osinfo_name == "es1370")
+ libvirt_name = "es1370";
+ else if (osinfo_name == "sb16")
+ libvirt_name = "sb16";
+
+ var model = get_enum_value (libvirt_name, typeof (DomainSoundModel));
return_if_fail (model != -1);
return (DomainSoundModel) model;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]