[gnome-boxes] installer: Add ::supports_virtio_disk method



commit bcbc28ce8cbb00708ea359f6f9d08bbc0bf09c99
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed May 23 16:45:09 2012 +0200

    installer: Add ::supports_virtio_disk method
    
    This will be useful to be able to automatically use the viostor
    driver on Windows when we have it available. We already have
    a check for that, but this commit moves it to its own method
    that derived classes can override if they want. This will
    allow Windows unattended installers to override the info from
    libosinfo when the virtio drivers can be provided at install time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=679752

 src/installer-media.vala |    5 +++++
 src/vm-configurator.vala |    6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 91243a3..881ff8e 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -18,6 +18,11 @@ private class Boxes.InstallerMedia : GLib.Object {
     public virtual uint64 installed_size { get { return 0; } }
     public virtual bool need_user_input_for_vm_creation { get { return false; } }
     public virtual bool user_data_for_vm_creation_available { get { return true; } }
+    public virtual bool supports_virtio_disk {
+        get {
+            return (get_os_device_by_prop (os, DEVICE_PROP_NAME, "virtio-block") != null);
+        }
+    }
 
     public bool live { get { return os_media == null || os_media.live; } }
 
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 0576339..de8b356 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -180,11 +180,13 @@ private class Boxes.VMConfigurator {
         disk.set_driver_type ("qcow2");
         disk.set_source (target_path);
         disk.set_driver_cache (DomainDiskCacheType.NONE);
-        var device = get_os_device_by_prop (install_media.os, DEVICE_PROP_NAME, "virtio-block");
-        if (device != null) {
+
+        if (install_media.supports_virtio_disk) {
+            debug ("Using virtio controller for the main disk");
             disk.set_target_bus (DomainDiskBus.VIRTIO);
             disk.set_target_dev ("vda");
         } else {
+            debug ("Using IDE controller for the main disk");
             disk.set_target_bus (DomainDiskBus.IDE);
             disk.set_target_dev ("hda");
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]