From 78bd46d4576a6562e37d647cba49506f1da7204e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Marchesin?= Date: Fri, 25 Mar 2011 16:35:01 -0700 Subject: [PATCH] Do not enable the use_tablet flag in qemu, as this breaks the mouse. Change-Id: I52901180e962c463bdaacbc573f93700cf9ab4bd BUG=None TEST=Run Chrome OS in qemu, check that the mouse is back. Review URL: http://codereview.chromium.org/6749020 --- fixup_image_for_qemu.py | 112 ---------------------------------------- image_to_vm.sh | 10 ---- 2 files changed, 122 deletions(-) delete mode 100755 fixup_image_for_qemu.py diff --git a/fixup_image_for_qemu.py b/fixup_image_for_qemu.py deleted file mode 100755 index 4c21e2b376..0000000000 --- a/fixup_image_for_qemu.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Makes changes to mounted Chromium OS image to allow it to run with VMs - -This script changes two files within the Chromium OS image to let the image -work with VMs, particularly QEMU - -Currently this script does the following, -1.) Modify the post install script to remove EFI fixup section; the VM's we -support don't have EFI support anyway and this section of the script needs -access to the actual device drives - -2.) For QEMU/KVM, we change the xorg.conf to remove mouse support and instead -change it to complete tablet support. This is done to provide better mouse -response in the VM since tablets work of absolute coordinates while the mouse -works of relative. In a screen that doesn't support a mouse grab (e.g., VNC), -relative coordinates can cause the mouse to be flaky - -""" - -from optparse import OptionParser -import os -import stat -import sys - -USAGE = "usage: %prog --mounted_dir=directory --enable_tablet=[true]" - -INPUT_SECTION_MARKER = r'Section "InputDevice"' -SECTION_END_MARKER = r'EndSection' - -MOUSE_SECTION_IDENTIFIERS = [] -MOUSE_SECTION_IDENTIFIERS += ['Identifier "Mouse'] -MOUSE_SECTION_IDENTIFIERS += ['Identifier "USBMouse'] - -REPLACE_USB_MOUSE_PAIR = ('InputDevice "USBMouse" "AlwaysCore"', '') -XORG_CONF_FILENAME = os.path.join('etc', 'X11', 'xorg.conf') - - -TABLET_DEVICE_CONFIG = """ -Section "InputDevice" - Identifier "Mouse1" - Driver "evdev" - Option "Device" "/dev/input/event2" - Option "CorePointer" "true" -EndSection -""" - - -# Modify the xorg.conf file to remove all mouse sections and replace it -# with ours containing the tablet - note: when running under QEMU, you -# *need* to specify the -usbdevice tablet option to get the mouse to work -def FixXorgConf(mount_point): - xorg_conf_filename = os.path.join(mount_point, XORG_CONF_FILENAME) - f = open(xorg_conf_filename, 'r') - xorg_conf = f.read() - f.close() - - more_sections = 1 - last_found = 0 - while (more_sections): - # Find the input section. - m1 = xorg_conf.find(INPUT_SECTION_MARKER, last_found) - if m1 > -1: - m2 = xorg_conf.find(SECTION_END_MARKER, m1) - m2 += len(SECTION_END_MARKER) - # Make sure the next iteration doesn't rinse/repeat. - last_found = m2 - # Check if this is a mouse section. - for ident in MOUSE_SECTION_IDENTIFIERS: - if xorg_conf.find(ident, m1, m2) != -1: - xorg_conf = xorg_conf[0:m1] + xorg_conf[m2:] - last_found -= (m2-m1) - break - else: - more_sections = 0 - - xorg_conf = xorg_conf[0:last_found] + TABLET_DEVICE_CONFIG + \ - xorg_conf[last_found:] - - # Replace UsbMouse with Tablet. - xorg_conf = xorg_conf.replace(REPLACE_USB_MOUSE_PAIR[0], - REPLACE_USB_MOUSE_PAIR[1]) - - # Write the file back out. - f = open(xorg_conf_filename, 'w') - f.write(xorg_conf) - f.close() - -def main(): - parser = OptionParser(USAGE) - parser.add_option('--mounted_dir', dest='mounted_dir', - help='directory where the Chromium OS image is mounted') - parser.add_option('--enable_tablet', dest='enable_tablet', - default="true", - help='fixup image for qemu') - (options, args) = parser.parse_args() - - if not options.mounted_dir: - parser.error("Please specify the mount point for the Chromium OS image"); - if options.enable_tablet not in ('true', 'false'): - parser.error("Please specify either true or false for --enable_tablet") - - if (options.enable_tablet == 'true'): - FixXorgConf(options.mounted_dir) - - -if __name__ == '__main__': - main() diff --git a/image_to_vm.sh b/image_to_vm.sh index dbc30eea0e..74b1d27c6c 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -189,16 +189,6 @@ sudo mount -o loop "${TEMP_ROOTFS}" "${TEMP_MNT}" mkdir -p "${TEMP_ESP_MNT}" sudo mount -o loop "${TEMP_ESP}" "${TEMP_ESP_MNT}" -if [ "${FLAGS_format}" = "qemu" ]; then - sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \ - --mounted_dir="${TEMP_MNT}" \ - --enable_tablet=true -else - sudo python "${SCRIPTS_DIR}/fixup_image_for_qemu.py" \ - --mounted_dir="${TEMP_MNT}" \ - --enable_tablet=false -fi - # Modify the unverified usb template which uses a default usb_disk of sdb3 sudo sed -i -e 's/sdb3/sda3/g' "${TEMP_MNT}/boot/syslinux/usb.A.cfg"