[gnome-boxes] Fix post reboot boot



commit 0d0dcf8458eb737f0f7e1e91768f3f1f290eaa22
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Nov 18 22:13:14 2011 +0200

    Fix post reboot boot
    
    After the first boot, Don't:
    
    1. use direct boot.
    2. boot from cdrom.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664473

 src/vm-creator.vala |   28 ++++++++++++++++++++++++----
 src/wizard.vala     |    9 ++++-----
 2 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 7aa6134..fc6f946 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -7,6 +7,14 @@ private class Boxes.VMCreator {
     private Connection connection;
     private uint16 spice_port;
 
+    private static Regex direct_boot_regex;
+    private static Regex cdrom_boot_regex;
+
+    static construct {
+        direct_boot_regex = /<kernel>.*<\/cmdline>/msx;
+        cdrom_boot_regex = /<boot.*dev=.cdrom.\/>/msx;
+    }
+
     public VMCreator (App app, string uri) throws GLib.Error {
         connection = new Connection (uri);
         spice_port = 5800;
@@ -29,9 +37,9 @@ private class Boxes.VMCreator {
         spice_port++;
     }
 
-    public async GVir.Domain create_domain_for_installer (InstallerMedia install_media,
-                                                          Resources      resources,
-                                                          Cancellable?   cancellable) throws GLib.Error {
+    public async GVir.Domain create_and_launch_vm (InstallerMedia install_media,
+                                                   Resources      resources,
+                                                   Cancellable?   cancellable) throws GLib.Error {
         if (!connection.is_open ())
             yield connect (cancellable);
 
@@ -50,7 +58,19 @@ private class Boxes.VMCreator {
         spice_port++; // So next VM doesn't get the same port
         var config = new GVirConfig.Domain.from_xml (xml);
 
-        return connection.create_domain (config);
+        var domain = connection.create_domain (config);
+
+        domain.start (0);
+
+        // FIXME: We really should use GVirConfig API (as soon as its available) to modify the configuration XML.
+        xml = domain.get_config (0).to_xml ();
+        xml = direct_boot_regex.replace (xml, -1, 0, "");
+        xml = cdrom_boot_regex.replace (xml, -1, 0, "");
+        config = new GVirConfig.Domain.from_xml (xml);
+
+        domain.set_config (config);
+
+        return domain;
     }
 
     private async void connect (Cancellable? cancellable) throws GLib.Error {
diff --git a/src/wizard.vala b/src/wizard.vala
index 93a0b58..7b72dd1 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -127,7 +127,7 @@ private class Boxes.Wizard: Boxes.UI {
                 return false;
 
             next_button.sensitive = false;
-            vm_creator.create_domain_for_installer.begin (install_media, resources, null, on_domain_created);
+            vm_creator.create_and_launch_vm.begin (install_media, resources, null, on_vm_created);
             install_media = null;
             resources = null;
             wizard_source.uri = "";
@@ -140,10 +140,9 @@ private class Boxes.Wizard: Boxes.UI {
         return true;
     }
 
-    private void on_domain_created (Object? source_object, AsyncResult result) {
+    private void on_vm_created (Object? source_object, AsyncResult result) {
         try {
-            var domain = vm_creator.create_domain_for_installer.end (result);
-            domain.start (0);
+            vm_creator.create_and_launch_vm.end (result);
         } catch (IOError.CANCELLED cancel_error) { // We did this, so ignore!
         } catch (GLib.Error error) {
             warning ("Fixme: %s".printf (error.message));
@@ -151,7 +150,7 @@ private class Boxes.Wizard: Boxes.UI {
             return;
         }
 
-        // Only let the user through if either domain was successfully created or operation was cancelled
+        // Only let the user through if either VM was successfully created or operation was cancelled
         next_button.sensitive = true;
     }
 



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