Tuesday, 10 September 2013

OpenIndiana

I have not used Solaris in some time so I thought it would be interesting to get OpenSolaris installed under kvm to test out. However, this has stopped being produced, but there is a fork called OpenIndiana.

I downloaded the Live dvd for desktops and booted that up under kvm, I have given the vm a qcow2 format disk to install to.

Once the OS boots up there is an option to install to disk, this will take you through a few install questions and then install to disk.


Thursday, 5 September 2013

Qemu monitor

If your virtual system is running under qmeu then you can access the qemu monitor to interact with that os, various things can be achieved such as sending keystrokes, sending nmi, changing state of the vm, snapshotting, add/remove devices etc.

To gain access to the monitor
ctrl-alt-2

There is a good description of the various options in QEMU-Buch / QEMU-Book, the book is in German but there is an English translation.


Tuesday, 3 September 2013

Running Raspbian image via qemu on x86_64

While testing some virtualisation configurations I came across mention that it is possible for qemu to run code compiled for different architectures. I was particularly interested in arm, as I could then run some quick testing of Raspberry Pi stuff from my laptop.

So here is how to get Raspbian OS running under qemu.

I needed to install the package containing qemu-system-arm to allow me to run software compiled for arm. I also needed a suitable kernel compiled for arm as well, there are some good instructions located at http://xecdesign.com/compiling-a-kernel/ .

The particular arm cpu I am going to use is arm1176, first double check that this is provided by qemu, it should show up in the list of cpus given by the command
qemu-system-arm -cpu ?

The particular arm machine I am going to use is versatilepb, for a full list of machines run
qemu-system-arm -M ?

Next I need a copy of Raspbian OS image from http://www.raspberrypi.org/downloads, extract from the archive.

To boot the OS I use the following command
qemu-system-arm -kernel <location of kernel for arm> -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2013-07-26-wheezy-raspbian.img

This did not work upon first attempt, this is mentioned on the Raspberry Pi forums. I changed my command to include an additional kernel boot parameter init=/bin/sh, and once booted up I remounted the root filesystem rw and commented out the line in /etc/ld.so.preload.

I restarted the OS using the unmodified command above and it booted.

Monday, 2 September 2013

Monkey Patching

This was mentioned in passing in a python book I read and I ignored it until I saw it being used to discover the internals of frozen/obfuscated python code.

It is a great term, basically you can overload defined functions with your own code, this is particularly useful for code testing. For example I have seen someone discuss testing an emailing function and rather than send out lots of emails they monkey patch parts of smtplib to add the messages to a dictionary.

A simple example
class orig:
    def method1(self):
         print "Original method1()"

    def method2(self):
        print "Original method2()"

if __name__ == "__main__":

    obj = orig()

    def monkeypatch():
        print "Monkey code!"

    print "method1()"
    obj.method1()
    obj.method1 = monkeypatch
    print "method1()"
    obj.method1()
    print "method2()"
    obj.method2()


Wednesday, 21 August 2013

Developing Android apps

I thought I would have a quick run through some of the tutorial info on getting a basic Android application built and then run it on the Android x86 port I have running in a VM.

I downloaded the adt bundle for linux which includes the sdk, a version of eclipse and the adt plugin. First time through I forgot that I did not have a jdk environment installed so had to grab that as well.
I also added the platform-tools and tools directories to my PATH.

Following the instructions I tested out a basic layout on the emulator that comes as part of the bundle and then exported my project as an Android application.

Here is where I believed the tricky part would be, to get the apk file onto my android instance running in a VM. I could have placed it on a webserver and then downloaded it (but where is the fun in that). If this was runnign on a real device/handset I could connect it up via usb and use adb.

Actually I can still use adb, as android is running in a VM and has networkig configured I just need to configure adb to connect to the VM.
I do this by the command

adb connect <ip address of VM>:5555

Then I can load my custom application using
adb install <apk file>

When I did this I needed to dismiss a warning that popped up on android, but the application installed fine. 

Once the application has been installed, disconnect adb using
adb disconnect

Both before connecting adb and after it is worth checking that an existing adb server instance is not already running, it can be killed with
adb kill-server

Now to figure out a useful app to develop.

Tuesday, 20 August 2013

Haiku

I am not about to break into poetry so don't panic.

A number of years back when I first started looking at Unix/Linux I came across several other Operating Systems which I would like to try out, one of these was BeOs (time permitting I may explore some more).

However, BeOs has all but died and was a proprietary OS anyway, but I did come across some people developing an opensource implementation called Haiku

I have downloaded it and installed it in a virtual image under KVM.
I created a 3Gb raw image and have booted from the ISO image using the following command to bring up a 32bit vm and given it 512Mb

qemu-system-i386 -m 512 -boot d -cdrom <image file> -hda haiku.img

I just passed it a raw image, so using the disk utility in the installer I need to create a partition and a location to create as Be File system. Follow the instructions in the installer and it is installed.
Next time when booting up the following command is used

qemu-system-i386 -m 512 -boot c -hda haiku.img



Friday, 16 August 2013

emscripten

There was a cool demo using the Unreal Engine that had been ported to javascript using emscripten I saw a while ago.
I had some time I thought I would test this out and see what it can do, I will come back to it later if I have any nifty code that I want to reproduce on the web.

Following the instructions, I downloaded and compiled up llvm (& clang) version 3.2, as per the instructions 3.3 (which was provided in my distribution) does not work.
I needed to grab node (version 10.15 was the one I tested) as well.

Once I had all these I ran the emcc utility which generated a default config file in my home directory (.emscripten), the paths in this needed modifying as I compiled/installed the utilities in my own directory and not in directories for system wide use.

I ran emcc again and it ran with out errors, just the fact that I had not provided any input files, so looks good.

Following the brief tutorial on the wiki I was able to run some of the test programs and some very simple C code that I had written (including some basic openGL using simple lines).

When I have some good examples I will attach them to this page.