gnome-boxes/SOURCES/gnome-boxes-use-q35-machine-type.patch
2021-09-09 17:43:38 +00:00

355 lines
12 KiB
Diff

---
src/meson.build | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/meson.build b/src/meson.build
index ac79b7fc..00903170 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -125,8 +125,8 @@ dependencies = [
dependency ('libsecret-1'),
dependency ('libsoup-2.4', version: '>= 2.38'),
dependency ('libusb-1.0', version: '>= 1.0.9'),
- dependency ('libvirt-gconfig-1.0', version: '>= 0.2.0'),
- dependency ('libvirt-gobject-1.0', version: '>= 0.2.0'),
+ dependency ('libvirt-gconfig-1.0', version: '>= 2.0.0'),
+ dependency ('libvirt-gobject-1.0', version: '>= 2.0.0'),
dependency ('libxml-2.0', version: '>= 2.7.8'),
dependency ('spice-client-gtk-3.0', version: '>= 0.32'),
dependency ('tracker-sparql-2.0'),
--
---
src/installer-media.vala | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index feb5d7b..b29c10b 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -25,12 +25,24 @@ private class Boxes.InstallerMedia : GLib.Object {
public virtual bool need_user_input_for_vm_creation { get { return false; } }
public virtual bool ready_to_create { get { return true; } }
+ public bool supports_virtio1_disk {
+ get {
+ return (find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "virtio1.0-block") != null);
+ }
+ }
+
public bool supports_virtio_disk {
get {
return (find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "virtio-block") != null);
}
}
+ public bool supports_virtio1_net {
+ get {
+ return (find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "virtio1.0-net") != null);
+ }
+ }
+
public bool supports_virtio_net {
get {
return (find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "virtio-net") != null);
--
---
src/unattended-installer.vala | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 4e0ba23..6a37e20 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -232,7 +232,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
if (os.distro == "win")
config.set_target_disk ("C");
else
- config.set_target_disk (supports_virtio_disk? "/dev/vda" : "/dev/sda");
+ config.set_target_disk (supports_virtio_disk || supports_virtio1_disk? "/dev/vda" : "/dev/sda");
var disk_config = get_unattended_disk_config (script.path_format);
var device_path = device_name_to_path (script.path_format, disk_config.get_target_dev ());
@@ -360,7 +360,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
disk.set_target_bus (DomainDiskBus.FDC);
} else {
// Path format checks below are most probably practically redundant but a small price for future safety
- if (supports_virtio_disk)
+ if (supports_virtio_disk || supports_virtio1_disk)
disk.set_target_dev ((path_format == PathFormat.UNIX)? "sda" : "E");
else
disk.set_target_dev ((path_format == PathFormat.UNIX)? "sdb" : "E");
--
---
src/vm-configurator.vala | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index e8eefa3..ceadc80 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -114,9 +114,10 @@ private class Boxes.VMConfigurator {
console.set_source (new DomainChardevSourcePty ());
domain.add_device (console);
+ var supports_virtio_net = install_media.supports_virtio_net || install_media.supports_virtio1_net;
var iface = create_network_interface (domain,
is_libvirt_bridge_net_available (),
- install_media.supports_virtio_net);
+ supports_virtio_net);
domain.add_device (iface);
return domain;
@@ -309,7 +310,7 @@ private class Boxes.VMConfigurator {
disk.set_driver_cache (DomainDiskCacheType.WRITEBACK);
var dev_letter_str = ((char) (dev_index + 97)).to_string ();
- if (install_media.supports_virtio_disk) {
+ if (install_media.supports_virtio_disk || install_media.supports_virtio1_disk) {
debug ("Using virtio controller for the main disk");
disk.set_target_bus (DomainDiskBus.VIRTIO);
disk.set_target_dev ("vd" + dev_letter_str);
--
---
src/installer-media.vala | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index b29c10b..0a83ba0 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -49,6 +49,12 @@ private class Boxes.InstallerMedia : GLib.Object {
}
}
+ public bool prefers_q35 {
+ get {
+ return false;
+ }
+ }
+
public virtual bool live { get { return os_media == null || os_media.live; } }
public virtual bool eject_after_install { get { return os_media == null || os_media.eject_after_install; } }
--
---
src/installer-media.vala | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 0a83ba0..7d95d65 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -55,6 +55,12 @@ private class Boxes.InstallerMedia : GLib.Object {
}
}
+ public bool prefers_ich9 {
+ get {
+ return false;
+ }
+ }
+
public virtual bool live { get { return os_media == null || os_media.live; } }
public virtual bool eject_after_install { get { return os_media == null || os_media.eject_after_install; } }
--
---
src/installer-media.vala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 7d95d65..ba6bfc8 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -173,7 +173,7 @@ private class Boxes.InstallerMedia : GLib.Object {
disk.set_target_dev (device_name);
if (iso_path != null)
disk.set_source (iso_path);
- disk.set_target_bus (DomainDiskBus.IDE);
+ disk.set_target_bus (prefers_q35? DomainDiskBus.SATA : DomainDiskBus.IDE);
if (mandatory)
disk.set_startup_policy (DomainDiskStartupPolicy.MANDATORY);
--
---
src/unattended-installer.vala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 6a37e20..e3fd115 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -379,7 +379,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
disk.set_source (secondary_disk_file.get_path ());
disk.set_target_dev ((path_format == PathFormat.DOS)? "E" : "hdd");
disk.set_guest_device_type (DomainDiskGuestDeviceType.CDROM);
- disk.set_target_bus (DomainDiskBus.IDE);
+ disk.set_target_bus (prefers_q35? DomainDiskBus.SATA : DomainDiskBus.IDE);
return disk;
}
--
---
src/vm-configurator.vala | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index ceadc80..c537316 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -315,8 +315,13 @@ private class Boxes.VMConfigurator {
disk.set_target_bus (DomainDiskBus.VIRTIO);
disk.set_target_dev ("vd" + dev_letter_str);
} else {
- debug ("Using IDE controller for the main disk");
- disk.set_target_bus (DomainDiskBus.IDE);
+ if (install_media.prefers_q35) {
+ debug ("Using SATA controller for the main disk");
+ disk.set_target_bus (DomainDiskBus.SATA);
+ } else {
+ debug ("Using IDE controller for the main disk");
+ disk.set_target_bus (DomainDiskBus.IDE);
+ }
disk.set_target_dev ("hd" + dev_letter_str);
}
--
---
src/vm-configurator.vala | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index c537316..07804f9 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -363,13 +363,22 @@ private class Boxes.VMConfigurator {
domain.add_device (video);
}
- private static void set_sound_config (Domain domain, InstallerMedia install_media) {
- var sound = new DomainSound ();
+ private static DomainSoundModel get_sound_model (InstallerMedia install_media) {
+ if (install_media.prefers_ich9)
+ return (DomainSoundModel) DomainSoundModel.ICH9;
+
var device = find_device_by_prop (install_media.supported_devices, DEVICE_PROP_CLASS, "audio");
- var model = (device != null)? get_enum_value (device.get_name (), typeof (DomainSoundModel)) :
- DomainSoundModel.AC97;
+ if (device == null)
+ return (DomainSoundModel) DomainSoundModel.ICH6;
+
+ var model = get_enum_value (device.get_name (), typeof (DomainSoundModel));
return_if_fail (model != -1);
- sound.set_model ((DomainSoundModel) model);
+ return (DomainSoundModel) model;
+ }
+
+ private static void set_sound_config (Domain domain, InstallerMedia install_media) {
+ var sound = new DomainSound ();
+ sound.set_model (get_sound_model (install_media));
domain.add_device (sound);
}
--
---
src/vm-configurator.vala | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 07804f9..3dc1c8e 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -338,6 +338,7 @@ private class Boxes.VMConfigurator {
os.set_boot_devices (boot_devices);
os.set_arch (old_os.get_arch ());
+ os.set_machine (old_os.get_machine ());
domain.set_os (os);
}
--
---
src/vm-configurator.vala | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 3dc1c8e..6c20f5e 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -347,6 +347,8 @@ private class Boxes.VMConfigurator {
var os = new DomainOs ();
os.set_os_type (DomainOsType.HVM);
os.set_arch (guest_caps.get_arch ().get_name ());
+ if (install_media.prefers_q35)
+ os.set_machine ("q35");
var boot_devices = new GLib.List<DomainOsBootDevice> ();
install_media.set_direct_boot_params (os);
--
---
src/installer-media.vala | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index ba6bfc8..4a8d913 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -57,7 +57,14 @@ private class Boxes.InstallerMedia : GLib.Object {
public bool prefers_ich9 {
get {
- return false;
+ if (!prefers_q35)
+ return false;
+
+ var device = find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "ich9-hda");
+ if (device == null)
+ return false;
+
+ return true;
}
}
--
---
src/installer-media.vala | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 4a8d913..5bde3ca 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -51,7 +51,17 @@ private class Boxes.InstallerMedia : GLib.Object {
public bool prefers_q35 {
get {
- return false;
+ if (os == null)
+ return true;
+
+ var device = find_device_by_prop (supported_devices, DEVICE_PROP_NAME, "qemu-x86-q35");
+ if (device == null)
+ return false;
+
+ if (supports_virtio_net && !supports_virtio1_net)
+ return false;
+
+ return true;
}
}
--