Header image alt text

Kevin's Thoughts!

Maybe you agree, maybe you don't… find out!

New adventure in technology: MacOS/IPad development

Posted by Kevin on August 31, 2011
Posted in Tech Talk  | Tagged With: , | No Comments yet, please leave one

New adventure in technology:  MacOS/IPad development

Yesterday I started down the path of discovering what it takes to develop application for the IPad (and I suppose the IPhone and MacOS in general).  Step one was to register as an Apple Developer (http://developer.apple.com/programs/register/).  That was quick, painless, and free.

Today I went and looked for the Apple Software Development Kit (SDK).  Its free, and is designed to run under Mac OS (of course!).  So… how to proceed?  Would I need to buy a Mac to explore this?  Not an option right now.  A bit of we browsing has revealed a lot on how to create a “hackintosh” – a normal PC running Mac OS natively.  This was made technically possible when MacOS converted to running on the Intel platform a number of years ago.  One needs either a new PC machine (cheaper than a Mac equivalent) or a partition on an existing Windows box.  Fortunately, my Windows 7 machine has several hundred GBs free on its disk, so I just used the Windows disk management (control panel -> Administrative Tools -> Computer Management -> Storage -> Disk Management) to shrink the partition freeing up space for a Mac OS partition.  The hackintosh page indicates I need a Mac OS thumb-drive to boot from.  This can be created by downloading the Mac OS DVD image ($29 from the Mac Store) and placing on your own USB thumb drive, or buy buying the OS pre-installed on a thumb drive from the Mac store ($69).  Given that a 16GB thumb drive cost at least half the difference, and requires some effort to format and move the DVD image over, I opted to order the pre-installed device.  That should be here next week.

I was wondering if I could run it in a VM under Windows and found this link:

http://techexxpert.blogspot.com/2011/08/how-to-virtualize-os-x-lion-on-windows.html

Apparently one can.  Seems to me like the legalities are questionable, but I’ll probably explore this while waiting for my thumb drive.  Note the above link is based on VMWare Workstation, which is free for 30 days, but cost $189 to purchase.

More as I progress!

9/1/2011:  Quick update.  I ordered the MAC OS thumb drive from the Apple store at 11:23am yesterday.  Standard delivery.   Order was shipped UPS at 4:46pm.  Delivered today at noon.  Pretty darn impressive!

Share

KVM – libvirt

Posted by Kevin on August 31, 2011
Posted in Tech Talk  | Tagged With: , , | No Comments yet, please leave one

KVM - libvirt

I think I’m done playing with Libvirt for the moment.  As a general purpose library management tool it looks good.  From an ease-of-use perspective I suspect its not bad if you are running in an X-windows environment.  From a “lets convert” standpoint?  Well, that is proving to be another issue.

For instance, I currently start up my KVMs with a command similar to:

kvm -net nic,model=virtio -net tap,ifname=tap6,script=no  -drive file=test2.img,if=virtio,boot=on -curses -no-reboot -m 2g -smp 2

This starts a fully paravirtualized instance using virtio for both networking and the disk image.  The resulting VM has 2gb of memory and 2 virtual CPUs allocated to it.

Libvirt uses XML files to control everything, an idea I fully support.  However getting started creating those can be a challenge.  I found two approaches.  The first was with a related tool called “virt-install”.  It is not part of the libvirt, but built using it and closely tied to it.  So after playing for a bit, I came up with:

virt-install –name “test2″ –ram 2048 –vcpus=2  –cpu host –description “Test VM” –import –file test2.img –os-type=linux –os-variant=virtio26  –network bridge=br0,model=virtio –graphics=none   –noreboot

Using the virsh list command shows the VM has been created and is running!  Probing around a bit shows the file /etc/libvirt/qemu/test2.xml has been created.  Using virsh edit test2 puts me into a VI editing session on the XML.  All looks good.  Now to connect.  Connect?  Connect to what?  I try opening a ssh session and it times out.  Unlike when I issue the KVM command directly, there is no associated curses window to look it.  Looking at /var/log/libvirt/qemu shows a log of the command being issued… very useful!  Apparently a serial console connection has been opened on /dev/pts/2.  Ok, crank up screen /dev/pts/2 and it connects, but there is no output…  Looking at the log file shows a few concerning things:  1) KVM is being started up with a “-S” switch, which the developers tell me is normal, but the man-pages say disables the startup of the CPUs.  Its sure behaving like the man-pages are right.  2) the image file is being started with “if=none” instead of “if=virtio”.  A bit of command line testing verifies that “if=none” prevents the kernel from finding the root disk.  Not good.  Checked in with the user-list community and the generated XML looks appropriate, so this issue remains pending.  Finally, the network is not being started using tap6, my assigned network device for this VM.

The user community suggested I try an alternative method to generate the initial XML.  Apparently virsh amoungst its MANY options, has one for generating XML from a command line!  Cool.  Wish I had noticed that earlier.  The command:

virsh domxml-from-native qemu-argv /kvms/test2 >test2.xml

Takes the file test (which contains the KVM command at the top of this post) and converts it to equivalent xml for libvirt.  Very Cool!  Well, at least in concept.  It has a few very minor parsing problems, like the “2g” for memory must be specified as “2048″ (in megabytes).  Also the kvm command must be fully qualified as /usr/bin/kvm.  Other than that, its works fine.  The generated xml looks very similar to that created by virt-install with a few minor differences like the instance not being named (ok, ok, its named “unnamed”) and the OS architecture and CPU information is generic X86 instead of the very specific AMD statements generated by virt-install.  There is also no serial port defined like virt-install did, but there is a “ethernet” device now that reflects my tap6 port.  A bit of cut & pasting and I managed to create a custom.xml with the best of both worlds.  Issuing virsh define /kvms/custom.xml imports the new xml file and again defines and tries to starts a running instance.

Notice the “tries” word above?  The network won’t start, so the instance is stopped.  The network won’t start because the “tap” device apparently needs to be a “tun” device.  Again looking at the log file shows the same if=none for the disk image as well.  Even if I reconfigured my network to use “tun” devices instead of “tap” devices, the VM would not get past booting the kernel.

I’ve spent a significant amount of time browsing the various man pages to try and figure out the above issues.  I did discover that libvirt appears to be more “cutting edge” than even the man pages for kvm.  e.g.  It uses some “newer” format parameters that I couldn’t find in the man pages (both local and on the official qemu site), which was a bit frustrating, but the format was pretty obvious. It also appears that the libvirt world really is built around VMs being behind a NAT subnet which libvirt wants to control.  It may be possible to get around that, but so far I haven’t had any luck.

So, for now, I’ll just manage my VMs from the command line, and start them via /etc/local.d/local.start.

 

 

Share