[gnome-boxes] vm-creator: Ensure VM name is <= 15 characters long



commit bc3348d1e4135fd8a28cd2ba566dab6aa95005ab
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed May 14 20:51:46 2014 +0100

    vm-creator: Ensure VM name is <= 15 characters long
    
    Commit 4dd0b75 put variant id into the VM names (and therefore
    hostnames) to make it more likely to assign a meaningful name to VMs but
    it also broke express installation for OSs with variants name that are
    long and have very strict restrictions on number of characters in
    hostnames, e.g win7 professional.
    
    This patch fixes express installation of such OSes by ensuring that VM
    name is not longer than 15 characters.

 src/vm-creator.vala |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 6d8cbfa..06ce5a9 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -233,6 +233,10 @@ private class Boxes.VMCreator {
         return config;
     }
 
+    // Ensure name is less than 12 characters as its also used as the hostname of the guest OS in case of
+    // express installation and some OSes (you know who you are) don't like hostnames with more than 15
+    // characters (we later add a '-' and a number to the name if name is not unique so we leave 3 characters
+    // or that).
     protected virtual void create_domain_base_name_and_title (out string base_name, out string base_title) {
         base_title = install_media.label;
         if (install_media.os != null) {
@@ -244,6 +248,9 @@ private class Boxes.VMCreator {
                     // FIXME: Assuming first variant only from multivariant medias.
                     base_name += "-" + variants.get_nth (0).id;
             }
+
+            if (base_name.length > 12)
+                base_name = base_name[0:12];
         } else
             base_name = "boxes-unknown";
     }


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