[et-mgmt-tools] [PATCH][RFC] Add --keymap option to virt-install

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

 



Hi,

I would like to add --keymap option to virt-install in order to set up
jp106 keymap. Because I can't use jp106 keyboard. So, I made a patch
(notes:It relates libvirt)

 Usage: virt-install --keymap=ja

I confirmed that I can use jp106 keyboard on HVM domain.
But didn't confirm PV domain.

Please give me an advice, if you have it.

Signed-off-by: Tomohiro Takahashi <takatom@xxxxxxxxxxxxxx>

Thanks,
Tomohiro Takahashi.

===================================================================
diff -uNrp virtinst-0.101.0.orig/virt-install virtinst-0.101.0/virt-install
--- virtinst-0.101.0.orig/virt-install 2007-03-05 21:29:44.000000000 +0900
+++ virtinst-0.101.0/virt-install 2007-03-06 15:51:22.000000000 +0900
@@ -96,6 +96,13 @@ def get_vcpus(vcpus, guest):
        except ValueError, e:
            print "ERROR: ", e

+def get_keymap(keymap, guest):
+    if keymap:
+        try:
+            guest.keymap = keymap
+        except ValueError, e:
+            print "ERROR: ", e
+
def get_disk(disk, size, sparse, guest, hvm):
    # FIXME: need to handle a list of disks at some point
    while 1:
@@ -160,14 +167,14 @@ def get_networks(macs, bridges, guest):
    else:
        get_network(macs, bridges, guest)

-def get_graphics(vnc, vncport, nographics, sdl, guest):
+def get_graphics(vnc, vncport, nographics, sdl, keymap, guest):
    if vnc and nographics:
        raise ValueError, "Can't do both VNC graphics and nographics"
    if nographics:
        guest.graphics = False
        return
    if vnc is not None:
-        guest.graphics = (True, "vnc", vncport)
+        guest.graphics = (True, "vnc", vncport, keymap)
        return
    if sdl is not None:
        guest.graphics = (True, "sdl")
@@ -180,7 +187,7 @@ def get_graphics(vnc, vncport, nographic
            print "ERROR", e
            continue
        if vnc:
-            guest.graphics = "vnc"
+            guest.graphics = (True, "vnc", vncport, keymap)
        else:
            guest.graphics = False
        break
@@ -256,6 +263,9 @@ def parse_args():
                      action="store_false", dest="autoconsole",
help="Don't automatically try to connect to the guest console")

+    parser.add_option("-k", "--keymap", type="string", dest="keymap",
+                      help="set up keymap for a graphical console")
+
parser.add_option("", "--accelerate", action="store_true", dest="accelerate",
                      help="Use kernel acceleration capabilities")
    parser.add_option("", "--connect", type="string", dest="connect",
@@ -417,6 +427,7 @@ def main():
    get_memory(options.memory, guest)
    get_uuid(options.uuid, guest)
    get_vcpus(options.vcpus, guest)
+    get_keymap(options.keymap, guest)

    # set up disks
    get_disks(options.diskfile, options.disksize, options.sparse,
@@ -426,7 +437,7 @@ def main():
    get_networks(options.mac, options.bridge, guest)

    # set up graphics information
- get_graphics(options.vnc, options.vncport, options.nographics, options.sdl, guest) + get_graphics(options.vnc, options.vncport, options.nographics, options.sdl, options.keymap, guest)

    # and now for the full-virt vs paravirt specific questions
    if not hvm: # paravirt
diff -uNrp virtinst-0.101.0.orig/virtinst/Guest.py virtinst-0.101.0/virtinst/Guest.py --- virtinst-0.101.0.orig/virtinst/Guest.py 2007-03-05 21:29:44.000000000 +0900
+++ virtinst-0.101.0/virtinst/Guest.py 2007-03-06 15:39:08.000000000 +0900
@@ -185,9 +185,17 @@ class VNCVirtualGraphics(XenGraphics):
            self.port = args[0]
        else:
            self.port = -1
+        if len(args) >= 2 and args[1]:
+            self.keymap = args[1]
+        else:
+            self.keymap = None

    def get_xml_config(self):
-        return "    <graphics type='vnc' port='%d'/>" % (self.port)
+        if self.keymap == None:
+            keymapstr = ""
+        else:
+            keymapstr = "keymap='"+self.keymap+"' "
+ return " <graphics type='vnc' port='%(port)d' %(keymapstr)s/>" % {"port":self.port, "keymapstr":keymapstr}

# Back compat class to avoid ABI break
class XenVNCGraphics(VNCVirtualGraphics):
@@ -218,6 +226,7 @@ class Guest(object):
        self._maxmemory = None
        self._vcpus = None
        self._graphics = { "enabled": False }
+        self._keymap = None

        self.domain = None
        self.conn = connection
@@ -301,6 +310,21 @@ class Guest(object):
        self._vcpus = val
    vcpus = property(get_vcpus, set_vcpus)

+
+    # keymap for the guest
+    def get_keymap(self):
+        return self._keymap
+    def set_keymap(self, val):
+        if val and (re.match("^[a-zA-Z0-9_]*$", val) == None):
+            raise ValueError, "Keymap be alphanumeric or _"
+        if val and (len(val) > 16):
+            raise ValueError, "Keymap must be less than 16 characters"
+        if val and (type(val) != type("string")):
+            raise ValueError, "Keymap must be a string"
+        self._keymap = val
+    keymap = property(get_keymap, set_keymap)
+
+
# kernel + initrd pair to use for installing as opposed to using a location
    def get_boot(self):
        return self._boot
@@ -374,6 +398,7 @@ class Guest(object):
            if len(val) >= 1: self._graphics["enabled"] = val[0]
            if len(val) >= 2: t = val[1]
            if len(val) >= 3: opts = val[2]
+            if len(val) >= 4: self._graphics["keymap"] = val[3]
        else:
            if val in ("vnc", "sdl"):
                t = val
@@ -386,7 +411,7 @@ class Guest(object):

        if self._graphics["enabled"] == True:
            if t == "vnc":
-                gt = VNCVirtualGraphics(opts)
+                gt = VNCVirtualGraphics(opts, self._graphics["keymap"])
            elif t == "sdl":
                gt = SDLVirtualGraphics(opts)
            else:



[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux