Saturday, July 19, 2025

Escaping the Grind: Our Office Adventure to Shogran & Makra Peak

✨ The Hesitant Starter

There’s always that one person who decides last minute — and this time, it was me. With some release blockers popping up and uncertainty lingering, I nearly dropped out. But with a little nudge from caring colleagues, I was back on board. Deep down, I knew the return would be filled with happiness, great stories, and memories I wouldn’t trade for anything.

🚐 Day One: Foggy Thoughts, Warm Coffee

The first leg of the trip wasn’t easy. Between the mental clutter of unfinished tasks and the physical fatigue of travel, I felt like I was just going through the motions. But then came that coffee — a simple gesture from our trip organizer that felt like a soul-reboot. Comfort in a cup, it shifted the vibe from drained to grateful in a heartbeat.
Our stay at Hotel Spruce Wood — also known as the Arcadian — was an absolute highlight of the trip! From the moment we arrived, it felt like stepping into a serene mountain haven. The rooms? Impeccably clean and cozy. The staff? Exceptionally warm, helpful, and always ready with a smile. And the food? Honestly, next level. I’ve stayed at plenty of places in the north, but the culinary experience here? Unmatched. Every bite felt like a gourmet treat after a long day of adventure.



🏔️ Makra Peak: Where Resolve Was Tested

Climbing Makra Peak was nothing short of epic. Almost 13,000 feet high and with no clear track. After reaching base camp, I pushed on solo for a while until clouds rolled in, swallowing the trail in fog and doubt. I thought of turning back. But then I saw a few colleagues heading up — it was the encouragement I needed.

The final stretch — two grueling hours — was pure grit. Every step demanded strength we didn’t think we had. Encouraging each other through exhaustion, we finally reached the summit. Hands down, the toughest peak I've summited yet — and the most satisfying.







🌲 Day Two: The Spontaneous Forest Mission

The initial plan was to rest. But the idea of spending the whole day confined to a hotel room didn’t sit well with my restless spirit. A quick breakfast chat about visiting Sharan Forest led to a spontaneous campaign to rally fellow adventurers. What started as a search for five companions turned into a mini movement. Enthusiasm snowballed, and soon we had a full crew set for the woods.

Sharan Forest was every bit the natural masterpiece we’d hoped for — thick greenery, peaceful trails, and a waterfall that looked like it had spilled straight out of a fantasy novel. Wandering through the jungle and soaking in the soothing sounds of water cascading through trees was truly unforgettable.




Post-exploration hi-tea felt like luxury, and team activities brought out the laughs. And yes, seeing bubble sort applied in real time (and still losing) was a hilarious reminder: algorithms may be brilliant, but execution is king.

🌟 Reflections

This wasn’t just a trip — it was a chance to reset. Office excursions like these are more than scenic retreats; they open a window to life outside deadlines and inboxes. Whether it's sharing quiet moments, pushing limits on rugged terrain, or rediscovering joy in simple conversations, they remind us of who we are beyond the job titles.

And though I started with hesitation, I returned with perspective, newfound energy, and stories worth telling.

Saturday, June 10, 2017

3 things I learned after visiting Toyota Service Center

My Toyota passo 2013 Model (2016 import) started giving a light grumbling sound while applying brakes. I had not visited any workshop since importing this car. I was just doing routine oil and filter changes and everything was going perfectly fine for last one and half years.
After discussing with some friends, I decided to visit Toyota service center for brake pads inspection. Toyota Walton and Toyota Cantt Motors are two nearest centers from my office. I visited Toyota Cantt Motors and got my car's front brake pads replaced but I learned following three lessons in this visit:

  1. Take Appointment before your visit

    Toyota service centers give discount to customers who take prior appointments. I didn't know about this but luckily I called them before leaving and got an appointment. I came to know that you get 10% discount on labor and 15% discount on parts if you have taken an appointment. If you plan to visit any Toyota service center, better call them a day before your visit and get an appointment.
  2. Do not purchase parts from Toyota

    It was my first experience visiting any of Toyota service center. I have heard that they charge extra on parts but I did not have any first hand experience. The overall experience of my visit was quite good. I was greeted by a staff member who took my personal details and my car's history. He then asked me to take car to service area for inspection. One of their service man then took a ride of my car along with me to understand the issue. One service person is then assigned to work on my car. He directed me to one of the bay areas and lifted my car using the lifter. He removed all the tires and then inspected both front and rear pads. He showed all of them to me and told me that it is better to replace front ones. I had a look at them and decided to replace them as pads seem quite thin and as I was already hearing a screeching sound so I decided to get them replaced. He took me to Toyota's parts purchase sections which was within their garage. The guy gave me pads and told me that price is Rs. 14000. As I have come with appointment so I'll get 15% discount so price for me is Rs. 11800. I called a friend and he suggested to better check I.A traders which is a well-reputed shop across the road in front of Toyota Cantt Motors. I returned brake pads to Toyota parts section and told them that I don't want to purchase from you as price is very high. He argued a bit saying he can give more discount but I told him that I don't want to purchase. I went to I.A traders and asked for genuine Toyota Passo break pads, he gave me a pair and quoted price of Rs. 7000/-. I asked him for a discount and finally got it in Rs. 6800. I took it back to Toyota service center and showed brake pads to Toyota service guy asking him if these are genuine and same to the one I was getting from Toyota parts section. He checked them and said yes these are the same ones. I got them replaced and took my car back and lesson that I learned was not to purchase parts from Toyota service center.
  3. Let someone else drive your car :)

    This might sound funny but this is another lesson that I learned. I imported my car in January 2016 and I have been driving it for about a year and half. During this time, no one else has actually driven it. When I got this car, it had genuine mats in it that were fixed with car floor. On suggestion of one of my friend, I went for rexine floor matting of my car where they removed car seats and fixed a rexine sheet on car floor. During this process, they also remove floor mat locks holding floor mats at their positions. At that time, I also put extra rubber floor mats on top of genuine ones to protect them. But I didn't notice that this extra matting has got stuck under my accelerator decreasing pedal space. For about a year and half I have been driving with two mats under my gas pedal making it hard for me to press it to its limit. I used to think that my car does not accelerate quickly because I have turned ECO mode ON to improve fuel economy. Good thing about it is that my car's fuel consumption was excellent and I was getting 20+ km/liter during this time :)
    When Toyota service person took test drive of my car, he stopped the car and asked me, how do I drive this car as it is so hard to accelerate it. He removed both mats from the floor and asked me to either cut their top right corner or get them fixed.
    On my way back from Toyota service center, it was very difficult to drive car for me as I was not used to driving without mats under the pedal. Car was accelerating very quickly and then I learned that slow acceleration was not because of ECO mode rather it was the EXTRA padding under the pedal.
    So let someone drive your car and look at it from another perspective :)


    Disclaimer: This post is just to share my personal experience. Toyota might have some very good reason to sell parts at higher price and there might be difference in quality that I am not aware of.






Saturday, July 30, 2016

Importing/Purchasing Japanese car

It all started in last December when I decided to finally sell 89 model Swift and get a new car. I had around 13 lacs of budget and various options I evaluated at time are mentioned in Purchasing Car (JDM or local)
 post. I finally decided to go for JDM but the big decision for me was how to choose and import car. After evaluating different cars, I chose Toyota Passo. The reasons of choosing Passo were:
  • Car should be at least 1000 CC as I have to travel out of city almost every week.
  • Car should be common in Lahore as that helps in resale and parts availability.
  • Car should be of Honda, Toyota or Diahatsu brand as that also helps in resale.

Import Process

 I must say import process is made to look to complex and I noticed a lot of myths about Japenese cars and import process. It is is not as complex as it is made to look by local car vendors. If you are importing your first car, it will be good if you can take service of some good and reliable importer.

Step 1: Short-list cars for bidding


Everyone can see list of cars in auction from http://www.japan-partner.com/car-auction/list.html. You can search for cars on particular days and also on the basis of Lot number given on auction sheet. Click on Respective day for which you want to look. For example, I have selected Monday in below screen. You can also choose Maker, Model and some advanced fields to include only relevant cars.

Some importers also have their own sites providing access to list of cars in auction. I consulted http://auc.mycar.pk/_home for this. I visited them and also met Omar, the guy running this business. He is a nice guy and helped me a lot.

Step 2: Bidding for Car


If you have taken services of importer, you can send him list of cars you have selected and can also discuss each of them with him. You can tell him your bidding price for these cars. Some importers also bid for cars and then send list of cars that they have purchased. In that case, you can ask them for auction sheet and verify it on Japan-Partners website.

Step 3: Reading Auction Sheet

One thing you need to keep in mind is that it is very easy to create a fake auction sheet and it is very common practice in local market to use fake auction sheets to sell cars. Most of the importers import accidented cars, repair them and then sell them as good grade cars. If you are purchasing/importing a Japanese car, also ask for online-verifiable auction sheets. Auctions sheets are available online for 3 months but can also be verified after that. Some people have access to auction data. You can easily search for them on Pakwheels. Omar of Mycar.pk also has access to auction data and can also help in this regard. To verify an auction sheet from Japan partners website, note the Lot ID from auction sheet. It is normally written on top left corner of auction sheet. Complete procedure is explained at http://www.pakwheels.com/forums/passo/262209-jdm-time-passo-2012-a-21

Step 4. Car Payment Details

Car payments normally include following:
  • Japan Car Price
  • Japan Freight Charges
  • Japan Bank transfer charges
  • Shipment charges (JPN to Karachi)
  • Custom Duty (on car arrival at Karachi port)
  • Custom clearance charges
  • Inland Shipment charges
  • Importer's charges
Below is breakdown of my car (Toyota Pass 2013 model)





Step 5: Tracking car


Almost all shipment companies provide tracking mechanism to track car shipment from Japan to Karachi. If you are importing through importer, you can ask for container details and then track it. I used http://oolu.container-tracking.org/ for tracking mine.


Purchasing car from dealer

 Importing a car is a difficult procedure and requires some patience as it takes around 2.5 months to get car. You can also purchase car from local market but you need to be extra careful. You need to take an oath that you will not listen to dealer and only consider those that have online-verifiable auction sheets. You only need a cell phone with good Internet connection and follow these steps:
  1. Visit the showroom
  2. Select car(s)
  3. Ask for auction sheet. Most of the dealers will not be able to provide and try to convince you that auction sheet has no value. But remember the oath you took. Ask for auction sheet.
  4. If you get auction sheet, verify it from Japan-partners website. If it is more than three months old, request pakwheelers who have access to database. In that case, you can take a picture of auction sheet.
  5. DO NOT PAY ANY TOKEN MONEY before verifying auction sheet.
  6. Match chasis number on auction sheet with car's chasis number.
  7. If everything goes well, grab the car.

Recommended Importers

  1.  I took services of Dr. Usman. His wordpress website is www.jdmtime.wordpress.com. You can contact him on pakwheels at http://www.pakwheels.com/forums/user/drusmannawaz
  2. I also had good discussions with Omar of Mycar.pk. Their showroom is near main market Gulberg. You can visit him as well.

Wednesday, December 23, 2015

My Shell Scripts

Traversing Directory

Below script traverses given directory, gets names of subdirectories, prepares name of zip file by appending zip to subdirectory name and copies zip those zip files to another directory.

IFS=$'\n';
for f in $(ls -l /home/taimoor/test | grep '^d' | sed 's/^.* //'); do
    cp /home/taimoor/toTest/$f.zip /home/taimoor/testLocation/;
    done

In above script, it traverses /home/taimoor/test, gets name of subdirectory, assign it to "f" and copies zip file with this name from /home/taimoor/toTest to /home/taimoor/testLocation

Print all files in directory n subdirectories (excluding svn)

test_dir=/home/taimoor/test
for f in $(find $test_dir -type f -a \! \( -path \*.svn\* \)); do
        echo $f
        done

Tuesday, December 1, 2015

School Hunt (Part two)

After some survey that was discussed in first School Hunt post, finally I chose "Rosans Islamic School" for my daughter.

Below is my first email to school administration after first week. This is quite old now. I must say that I got good response from administration. They called me for meeting and addressed all my concerns.

Assalam o Alaikum:
I hope you are fine and doing well. My name is Taimoor Mirza and I am father of XX who has recently joined your school in grade 1. We have recently moved from Bahria town and one of the reason of this move was to send my child to some better school that also provides Islamic environment to children. I am quite happy with the school so far. Below are few suggestions that are based on my one week's experience with Rosans:
1. Daily bag size
I was surprised to see the number of books that Grade 1 child has to carry every day. My kiddo is 6 years old and her weight is about 16 kg. Its very difficult for her to daily carry a bag with 13 books, 5 notebooks, one diary and a lunch box. She twice told me that her class is at first floor and she was about to fell down while bringing the bag down.
Isn't it possible to keep some of these books at school and only send few of them back?

2. Communication b/w teacher and parents
Currently there is no way (that I am aware of) to communicate with class teacher. We want to ask teacher various things about course, books, any missing book e.t.c.
In Bahria town school, teachers normally write such notes on student's diary and that diary was used as mode of communication. We are currently sending most of the books to School daily but my daughter still tells me everyday that teacher asked for some book that she did not have. Can you kindly ask teacher to write such things on student's diary so that we know exactly what book is it?
3. School leaving procedure
In Bahria town school they had their own bus transport service that includes driver, assistant and a maid. Teacher brings children to gate and maids then make sure that no child is missing. Its maid's responsibility to hand over child to parents. If parents are not at home, they call at their cell number and then take child back to School from where parents can collect him.
I can understand that such service is not possible in Rosans but I think process of collecting child can be improved. Currently, most of public transport service drivers are gathered at the gate and every driver has around 5-10 children to collect. They kept on chanting children names in full voice and its very difficult for anyone to pierce through their circle and tell gatekeeper name of  child.
One thing that can be done is that all these drivers provide a paper with names written on it to the guard and then stay away from the gate. Aaya G can then go through that list by calling names of every individual child.

4. No SMS/Email Notification from School
It happened with me last week when there was heavy rain in Lahore. It took me about an hour to reach Rosasn from Defence and at times, my car was about to die in pool of water. But after reaching School, I came to know that School is closed because of heavy rain. Its my humble request to kindly send some SMS or email notifications to let parents know about it. That'll really be very helpful for parents.
These are just few things that I have observed. Kindly don't take it as a criticism. I am not doing comparison of Rosans and Bahria town school. If I have moved my child from Bahria town school to  Rosans then its because I believe Rosans is a much better place for my child's grooming, character building and becoming good human.
Thanks and Jazak Allah,
Few other things that I learned from school switching experience.
  1. Infrastructure of School
    • I did not realize it initially but my daughter told me that she misses large playgrounds and kids playing areas of Bahria School.
  2. Extra curricular Activities
    • Rosans school focuses a lot on academics. They have CAT (continuous Assessment test) and child is always under a bit of burden. But with all this, they have no extra curricular activities.

Purchasing Car (JDM or local)

These days, I am planning to purchase a car in budget range of 13-13.5. Initially I thought it will be an easy decision for me but like so many things in past, it spun my head.

Budget Range: 13-13.5

I decided not to increase this budget range but when I consulted with my friends and family, they suggested to up the budget a bit and get zero meter car. So I extended my survey and included those cars in my list as well.
Below is complete list of options that I evaluated.

New Cars
  1. Honda City
    •  Pros: 
      • Good fuel economy, 
      • Very good resale.
      • Relatively easy to maintain.
    • Cons: 
      • I drove my friend's City and I felt that its a bit underpowered and fragile.
  2. Suzuki Swift
    • Pros
      • Suzuki's stamp which means good resale and good parts availability.
    • Cons
      • Automatic one is costly it around 14.2 and adding all other charges takes it to 15.
      • Heard that its not fuel economical.
  3. Suzuki WagonR
    • Pros
      •  Again Pak Suzuki with good resale and good parts availability.
      • Every owner seems to be happy with his car.
      • Good mileage. Read that it does 13-14Km/L in city and 17-18Km/L on the highway.
    • Cons
      • Exterior is not good. More like mini bolan.
      • Interior lacks basic features.
  4. Faw V2
    • Pros
      • Feature rich
      • Good mileage
      • Very good price
    • Cons
      • Its very new to market and involves a lot of risk.
Used Cars
  • Imported Cars
  1. Toyota Passo
    • Pros: 
      • Good fuel economy.
      • Feature rich.
      • Parts are relatively easily available.
      • Can easily get less driven car.
      • Price is also affordable. 4.5 grade fresh import Hana plus that comes with Eco Idle, ACC, fog lights, projector lights is in 13-1320.
    •  Cons: 
      • Not very good resale.
      • Involves risk of import and getting any accidented one with fake auction sheet.
      • Second hand is second hand.
  2. Toyota Vitz
    • Pros: 
      • Most popular JDM car in Pakistan
      • Very good resale.
      • Parts are easily available.
    • Cons: 
      • Too expensive...spending 14.5 on a hatchback...huh
  3. Honda Fit
    •  Pros: 
      • Honda's stamp
      • Good fuel economy
    • Cons: 
      • Expensive
      • Expensive to maintain
      • Does not have good resale
  4. Toyota Aqua a.k.a mini prius
    •  Pros: 
      • hatchback prius
      • Very good fuel economy (20+ in city)
    • Cons: 
      • Expensive (S grade in 16.5)
      • Not very spacious
      • New to market so difficult to maintain i.e. finding parts and good mechanic.
  5. Toyota Prius 2007 model
    •  Pros: 
      • Prius to prius hai. Prius, Vitz and Mira and most popular JDMs in Pakistan.
    •  Cons: 
      • Fresh import is not possible...and difficult to rely on one used in Pak).
  6. Mitsubishi Mirage
    • Pros
      • Very good fuel economy
      • Feature rich
      • Good price. Can get fresh import in 11.75-12.
    • Cons
  • Local Cars
  1. Honda City
    • Pros
      • All good things of new city.
    • Cons
      • Second hand is also very costly. I was getting a second hand 40,000 km driven, 2012 model in 1575.
      • Relying on Paki second hand is very difficult

Monday, August 18, 2014

School Hunt


I have moved back to Cavalry ground area and now looking for some good nearby school for my daughter. She is done with preschool and will be going to class 1 insha Allah. I need your valuable suggestion in helping me deciding about school. Below is list of schools that I am evaluating:

Islamic:

I have contacted and visited schools that claim to be Islamic and focus on child's moral and character building along with education. But surprisingly, fee of all of these schools except Ibn e Sina is more that non-islamic schools. Below is short summary of my findings:

 

1. Rosans Islamic School

A school with small building and not very big infrastructure. A small playground and small rooms. They have salat rooms and also teach basic duas and manners to child (this is what they said). Also have hifz option.

a. Admission fee: 40,000 Rs (Don't think I have added extra zero)
b. Registration fee: around 6000 Rs.
c. Tution fee: Around 10,000. (excluding stationary and A.C charges for summer).

 

2. Scholistic Islamia School

 

A school run by Dr. Arif Rana and Dr. Arif Zaman sb. I have not yet visited them but talked to them over phone. I am planning to go there tomorrow. Their claims are mostly similar to Rosans. Fee details are:
a. Admission fee: 31,000 Rs.
b. Registration fee: 1000 Rs.
c. Tution fee: 35000 Rs. (3 months)
d. Website: http://scholasticislamiah.com.pk/

 

3. SCIL

 

Another Islamic school in Gulberg. My ex-colleague's son is studying here and he provided good feedback of this school. Fee structure is:

a. Admission fee: 35,000 Rs.
b. Registration fee: 3000 Rs.
c. Tution fee: 9500, stationary: 850 Rs. and AC charges 1500 Rs. for summer quarters.
d. Website: http://www.scil.edu.pk

 

4. Ibn e Sina

 

Seems pretty good school but admissions are closed. Their academic year starts from January and admissions are closed now. Details are at http://www.ibnesinacollege.com/

 

5. LAPS

 

This school is run by Sheikh Zulfiqar sb's Mureedeen. My colleague's daughter is studying here and he is quite satisfied with school. One thing that I don't like about this school is that father is not allowed to visit school or participate in any parents teacher meetings. Only mother can visit school.
Fee structure is:

a. Admission fee: 20,000 Rs.
b. Registration fee: 3000 Rs.
c. Tution fee: 11000 excluding stationary and other charges.
d. Website: http://www.hamnacenter.org/little_angles_pre_school.php


Conventional Schools

6. Resource Academia

 

Its very near to my office on Khursheed Qaoori road near Hussain chowk. Its project of Punjab group of colleges for ELITE class. This is something that I don't like about this school. Fee and contact details are:
a. Admission fee: 10,000 Rs.
b. Registration fee: 3000 Rs.
c. Tution fee: 13500 excluding stationary and other charges.
d. Website: http://www.resourceacademia.edu.pk/ and for fee structure http://resourceacademia.edu.pk/admissions.htm

 

7. Citi School

 

A branded school and its Gulberg campus is very near to our office. It has huge infrastructure with large playgrounds for different sports. Bad thing is that like other non-islamic shools it also has Music class. Fee structure and other details are:

a. Admission fee: 0 Rs. (its 100% waved off At the moment).
b. Registration fee: 500 Rs.
c. Tution fee: 10205 excluding stationary and other charges. Computer fee is 400 Rs.
d. Website: http://thecityschool.edu.pk/

 

8. Lahore Grammar School (LGS)

 

Another branded school with huge infrastructure. Its campus is also near to our office which is good. Bad thing is its ultra mod education.

 

9. Beaconhouse

 

Haven't evaluated yet. Or I should say haven't considered to evaluate it.

 

10. Defence Public School

 

Same as 9.

 

11. Army Public School

 

It is also known as Garrison academy. Conventional school with conventional style of teaching. It has good infrastructure and is also not ultra mod with music and dance classes. Only thing is that these schools give preference to children of Army persons and civilians have very limited seats. Also admissions start in Jan/Feb. period.

Registration Fee:  800 Rs.
Prospectus Fee: 300 Rs.
Test Fee: 100 Rs.
Admission Fee: 14000 Rs.
Security: 5500 Rs.
Tution Fee: 5,386 Rs.
Computer Fee: 132 Rs.
Sports: 25 Rs.
Library: 35 Rs.
CDF: 167 Rs.
Generator:  55 Rs.

Above charges are excluding other charges.

Website: http://gja.lges.edu.pk/

Parameters of School Evaluation:

Following are few parameters that I am using to evaluate all of these schools:

1. Student to teacher ratio in a class

It should be small so that kid can get proper attention of teacher.

 

2. School infrastructure

    a. Building: Children should at least have some space to play.
    b. Grades: School should be at least up to A-Level/FSc. as I don't want to change school without any genuine reason.

3. Coaching Requirement:

I have observed this trend in almost every family. Child comes back from school, eat lunch and then go to academy/tution. He then comes back after 2-3 hrs and then his Qari sb comes to teach Quran e pak. I don't want to pay 15k to school and another 15k to academy. If I am paying 15k to school, I assume that teacher will be doing everything that is required for my kid's education.

4. Music/Dance classes:

This is something that I want to avoid. I don't want my kid to be performing (this is what they say) on different songs.

Wednesday, May 14, 2014

GNU project contribution

To start contributing to any GNU FSF project, one needs commit access and for that he needs to fill a form given at https://www.sourceware.org/cgi-bin/pdw/ps_form.cgi

Tuesday, December 3, 2013

nographic option does not work with QEMU on Windows

This seems a  Windows specific QEMU problem. -nographic works fine on Linux but on Windows it does not seem to work on Windows. After wasting several brain cells, I found one way to workaround this issue:

Run QEMU using following command:

  • qemu-system-arm.exe  -nographic -M realview-eb   -m 256 –kernel demo.out –sd <sdcardimage> -serial telnet::4444,server,nowait

This will run telnet server and redirect serial to given telnet port. After this, telnet to localhost 4444 using this command:

  • telnet localhost 4444

Thursday, November 7, 2013

SVN tips and tricks

Non-recursive checkout:

Being centralized version control system, it often happens that complete checkout takes a lot of time. One way to avoid this is to go for non-recursive checkout. This will only checkout first level files from repository.
Example of it is:

svn checkout -N http://svnserver/trunk/ /project

You can later checkout complete repo by running "svn update --set-depth infinity"

Monday, September 30, 2013

QEMU: Dive into QEMU





  • TCG (Tiny Code Generator)
  • Address Translation
  • Device emulation

                                                    This is basically a run time translator that converts target CPU instructions to host CPU instructions. Febrice Bellard (founder of QEMU) has written a paper about this dynamic translation. In short it translates the target CPU instructions to host CPU instructions that work with emulated memory space. There is a tcg folder in QEMU that contains most of target specific code generator’s code. Also there is a tcg.c file in main directory that contains generic code.






QEMU has a soft MMU model to translate target virtual addresses to host virtual addresses. SofMMU provides two types of mapping:

  • Mapping between Guest virtual address and host virtual addresses
  • Mapping between Guest virtual address and registered I/O functions for that device.


Mapping between Guest and host virtual addresses:

QEMU does not perform the address translation process on addresses i.e. it does not first translate target virtual address to target physical address then target physical address to host physical address and then host physical address to host virtual address. Rather QEMU uses address translation cache that does direct translation from target virtual address to host virtual address. This translation cache stores Addend for guest addresses. This Addend is actually offset of host virtual address from guest virtual address. This means

Host virtual address = Guest virtual address + Addend

Cache used for this is tlb_table. When translating the guest virtual address to host virtual address, it will search this TLB table firstly. If there is an entry in the table, then QEMU can add this offset to guest virtual address to get the host virtual address directly. You can read more about it from http://vm-kernel.org/blog/2009/07/10/qemu-internal-part-2-softmmu/
Mapping between Guest virtual address and registered I/O functions:
Cache used for memory mapped I/O accesses is iotlb. Iotlb is used to translate addresses to index of io_mem_write and io_mem_read arrays. Iotlb is defined in cpu_defs.h as
target_phys_addr_t iotlb[NB_MMU_MODES][CPU_TLB_SIZE];
io_mem_write and io_mem_read are two dimensional arrays of function pointers. These take index from tlb and invoke its respective function.


 All these Mappings are done in Softmmu_template.h and Softmmu_header.h. Softmmu header contains generic functions for load, store, load and store instructions.


2.1. Available simulations of peripherals in QEMU

  • - i440FX host PCI bridge and PIIX3 PCI to ISA bridge
  • - Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA extensions (hardware level, including all non standard modes).
  • - PS/2 mouse and keyboard
  • - 2 PCI IDE interfaces with hard disk and CD-ROM support
  • - Floppy disk
  • - PCI and ISA network adapters
  • - Serial ports
  • - Creative SoundBlaster 16 sound card
  • - ENSONIQ AudioPCI ES1370 sound card
  • - Intel 82801AA AC97 Audio compatible sound card
  • - Adlib(OPL2) - Yamaha YM3812 compatible chip
  • - Gravis Ultrasound GF1 sound card
  • - CS4231A compatible sound card
  • - PCI UHCI USB controller and a virtual USB hub.

2.2. Virtual Serial Port:

Set using –serial switch and serial output can be redirected to different devices using different options
  1. COMn(windows only): Redirect serial I/O to host serial port
  2. file:filename: Write output to some file….Works only for redirection of serial output and no serial data can be read.
  3. none: disable all serial ports
  4. vc: redirect to virtual console. Virtual console is in QEMU window and user can switch to it using Ctrl-Alt-3 option.

2.3. Control Flow in Serial simulation:




2.4. How serial port emulation works:


•         The generic part of UART emulation is implemented in qemu-char.c file.

•         Controller specific part of PL011 UART controller is in hw/pl011.c file. This file also contains MMIO read/write register handlers.

•         Register handlers in pl011.c calls generic read/writefunctions from qemu-char.c.

•         For example, pl011_read function calls qemu_chr_accept_input from qemu_char.c. Similarly, pl011_write in pl011.c calls qemu_chr_write from qemu-char.c.

•         The read/write handler functions pl011_read and pl011_write handle memory access to all the registers of the device. They implement a switch/case for the address to select a particular register.

2.4.1.  Layers in serial Port Emulation:


2.4.1.1.          SOFTMMU Layer:
                     Its code is in softmmu_template.h/softmmu_header.h. softmmu is used to accelerate the process of finding the mapping between guest physical address and host virtual address and the mapping between guest I/O region and qemu I/O emulation functions.

2.4.1.2.          Controller Specific Handlers:
                                               Every controller will register handlers for its memory space and these handler functions will be invoked by sofmmu.

PL011 UART Contoller Emulation: Its source code is in PL011.c. It contains PL011 UART controller's emulation inculding its read/write handler functions.

2.4.1.3.      Generic Read/Write Functions:
                                                                Its source code is in qemu-char.c. QEMU has a generic layer that provides generic functions for reading and writing serial data from/to different modes e.g. host serial port, stdio, QEMU's virtual console etc.

2.4.1.4.      Virtual Console Mode:
                                               Its source code is in console.c. QEMU has a command parser that parses command used to launch qemu vm. This parser sets mode of serial communication depending upon the switch. Generic function invokes these mode specific functions using function pointer which is set after command parsing.

2.4.2.  EXAMPLE Nucleus SHELL Demo:


2.4.3.  Control Flow in SoftMMU:




2.4.3.1.          Tiny Code Generator (TCG):
                                                It translates target instructions to host instructions. In QEMU every emulated target has a translation file (translate.c) that contains the complete source code of translator. This translator translates emulated target’s instructions to host machine i.e. x86. Below is pictorial representation of it.



Translator Details:

  1. DissAssembler
ARM translator has a disassembler function in it that translates machine language instructions to assembly language. It is disas_arm_insn function.
2.4.3.2.          TLBs: Maps target virtual address to host virtual address or Read/write handler (in case of Memory Mapped devices).

2.4.4.  Overall Control Flow in QEMU:




•         User gives command to launch qemu.
•         QEMU’s command parser mechanism parses given command and registers devices accordingly.
•         After this initialize function of target board (given in command) is invoked, default target is integratorcp for ARM.
•         Target initialization function creates devices. E.g. PL011 UART controller and also pass its memory address to creation function.
•         It then calls pl011_init function in pl011.c to initialize pl011 controller and passes memory address. It then register handlers for pl011 controller’s memory region.

2.5. Emulation for Linux based USB Host side applications:

                                                                               
User is developing a Linux based USB host application for some embedded target with host controller (EHCI/OHCI or UHCI) and he wants to test his application

QEMU:
            Features:
                        Allows Host controller emulation for 3 platforms.

·         PC System has a UHCI controller
·         MIPS/malta has a PIIX4 PCI/USB/SMbus controller
·         ARM Architecture ones:
o    ARM Versatile baseboard with a  PCI OHCI controller
o    ARM RealView Emulation/Platform with a  PCI OHCI controller
o    XScale-based clamshell PDA models with an On chip OHCI controller
o    Nokia N800 and N810 internet tablets
            Limitations:
·         Allows to test with physical USB devices plugged in host USB port but not for streaming devices (using Isochronous transfer). It means if user is developing a host side application with any Isochronous transfer based USB device.
·         Physical USB devices can be used in QEMU only in case of LINUX host.

                                   


2.6. Emulation for Linux based USB Function side applications:


User is developing an Embedded linux based USB device and wants to test it on his host machine without embedded target board by virtually plugging it in to host PC’s USB controller port.
Example: User is developing an embedded linux based mass storage device and wants to test his device side code.
QEMU: Provides emulation of USB devices which can be plugged with QEMU platform but I’ve not found any QEMU based solution that allows me to run an EL based USB device under QEMU and virtually plug that device in to host PC’s USB port..
Currently I am exploring dummy HCD in Linux, a model used by Openmoko for USB  and  USB/IP.

Below is a pdf document explaining OpenMoko’s emulator and USB settings.

This emulator allows users to connect the virtual, emulated Neo1973 ( OpenMoko’s hardware platform) to the Linux PC on which the emulator is running, and work with it as if a real Neo1973 was plugged into the computer's USB port. How if we take this idea for Android and other EL distributions based USB devices?


2.6.1.  Android Emulator:


1.     Device side applications:
                                                Developing an application that allows user to use Android cell phone’s camera as a Webcam on host machine.
           
a.     Emulator Status:

2.     Host side Applications:
The official kernel provided for Android phones does not have any USB host capabilities enabled. Android for mobile devices does not support USB host feature. But if we talk about Android for embedded platforms then it must have this feature enabled in the kernel.

a.     Emulator Status:
No support for USB host side application emulation.

3.     OTG:
The official kernel provided for Android phones does not have any USB OTG capabilities enabled. But if we talk about Android for embedded platforms then it must have this feature enabled in the kernel.

a.     Emulator Status:
                                                No support for USB OTG controllers emulation.



2.7. QEMU’s Network Emulation:


QEMU has a number of ways to set up networking for its guest applications. QEMU can simulate various network cards and can connect them to an arbitrary number of Virtual Local Area Networks (VLANs).

2.7.1.Virtual LAN:


A VLAN is a network switch running in the context of a qemu process. It can be symbolised as a virtual connection between several network devices. These devices can be for example QEMU virtual Ethernet cards or virtual Host ethernet devices (TAP devices). There can be multiple vlans in each qemu VM process. Multiple interfaces can be connected to each vlan. Anything sent via one of the interfaces on a vlan is received by all the other interfaces on that vlan. One example of interface on vlan is NIC card. Any frames sent by the guest OS over that nic will appear on the vlan which the nic is a member of. Any frames sent to the vlan from other interfaces will be received by the guest OS via the nic.

VLAN is QEMU VM process specific and it is not something that can be used to connect multiple QEMU instances. Below is pictorial representation of it (Got most of these from a website)

         +-----------+
         |   Guest   |
         |    OS     |
         |   +---+   |
         |   |NIC|   |
         +---+-+-+---+
               ^           +--------+
               |           |        +<------> Other IF (say another NIC in QEMU)
               +---------->+  VLAN  |
                           |        +<------> Other IF (host TAP device)
                           +--------+

2.7.2. Default User mode Network stack:

By using the option ‘-net user’, QEMU uses a completely user mode network stack (you don’t need root privilege to use the virtual network). The virtual network configuration is the following:

         +-----------+
         |   Guest   |
         |    OS     |
         |   +---+   |
         |   |NIC|   |
         +---+-+-+---+
               ^           +--------+
               |           |        +
               +---------->+  VLAN  |<------> Firewall/DHCP server <------> Internet 
                           |        +         | (10.0.2.2)
                           +--------+         |
                                               -----> DNS Server(10.0.2.3)
                                              |
                                               -----> SMB Server (10.0.2.4)  
 

The QEMU VM behaves as if it was behind a firewall which blocks all incoming connections. You can use a DHCP client to automatically configure the network in the QEMU VM. This user mode network stack is part of QEMU and there will be no other process running for DHCP and DNS servers. The DHCP server assigns addresses to the hosts starting from 10.0.2.15.

2.7.3.      Port Redirection:

                                                     As QEMU process acts as a firewall between Guest OS and host network, it does not support protocols other than TCP and UDP which means ping and ICMP can not be used from host for Guest network. For this QEMU provides an option of port redirection using which TCP or UDP connections on host can be redirected to guest OS. For example user can redirect telnet connections from host port 5555 to guest port using following command:
qemu -net user,hostfwd=tcp:5555::23


2.7.4.Connecting Multiple QEMU VMs (VLANs):


2.7.4.1.    Using Sockets:

Every QEMU process with network card emulation has at least one virtual LAN. Multiple VLANs can be connected together using socket.


      +-----------+                                      +-----------+
      |   Guest   |                                      |   Guest   |
      |     A     |                                      |     B     |
      |   +---+   |                                      |   +---+   |
      |   |NIC|   |                                      |   |NIC|   |
      +---+-+-+---+                                      +---+-+-+---+
            ^       +--------+                +--------+       ^
            |       |        |                |        |       |
            +------>+ VLAN 0 +<--> Socket <-->+ VLAN 2 +<------+
                    |        |                |        |
                    +--------+                +--------+

In this case one QEMU VM process connects to a socket in another QEMU VM.

2.7.4.2.  Using Host TAP devices:
                                                      I had to spend quite some time to learn about host TUN/TAP devices and I must say QEMU documentation does not provide any good explanation of it. TUN/TAP provides virtual Ethernet driver, which instead of receiving packets from a physical media, receives them from user space program and instead of sending packets via physical media sends them to the user space program. This is very similar to Nucleus SimTest, a simulated device (simulation model) and a “virtual Ethernet driver” for that device.
So in case of QEMU VM, it will be running as a user space program that can read/write packets from/to host TAP device. Configuring TAP devices is a bit difficult. It requires installing VPN on host and then adding bridge between host TAP device and physical Ethernet but you can easily find shell script that does this for you.

VDE (Virtual Distributed Ethernet) is a user program which can obtain a TAP device and allow a number of other programs(QEMU VMs) to connect to it and bridge those connections to the TAP device. There is a separate switch in QEMU for VDE.


    +-----------+                           +-----------+
    |   Guest   |                           |   Guest   |
    |     A     |                           |     B     |
    |   +---+   |                           |   +---+   |
    |   |NIC|   |                           |   |NIC|   |
    +---+-+-+---+                           +---+-+-+---+
          ^       +------+         +------+       ^
          |       |      | +-----+ |      |       |
          +------>+ VLAN +-+ VDE +-+ VLAN +<------+
                  |      | +--+--+ |      |
                  +------+    |    +------+
                              |
                          +---+-----+  +--------+
                          | Kernel  |  |  TAP   |
                          | TUN/TAP +--+ Device |
                          | Driver  |  | (qtap) |
                          +---------+  +--------+

2.7.4.3.    Using Port Redirection:
                                                             Android emulator uses this port redirection feature for inter connecting multiple instances of emulator.  


Based on all this, I assume that QEMU provides different options for emulating distributed multi target applications. Although it is difficult to setup and needs some effort but IT IS FREE.



2.8. FILE System Emulation:


I’ve been looking in to QEMU VM’s ability to communicate with host file system. Actually there are two modes of QEMU
  1. User Space emulation
  2. System emulation

2.8.1.     User space emulation:

                                      It allows running a Linux process (compiled for some other architecture) on host PC. E.g. I’ve developed an embedded linux application for ARM integrator. I can build this application on my host using cross development toos/IDEs. QEMU allows me to run this ARM binary in my host machine using QEMU’s user space emulation. The emulated Linux process is just like a host process and it call access host file system as well.

2.8.2.     System emulation:

                                It emulates a full system including processor and peripherals. This mode is similar to other VMs only thing is that it also allows emulation of non PC (embedded) targets. It provides emulation for disk as well that allows creation of virtual disk images of different formats.

2.8.3.  Transferring files to and from the host


1.     The emulator and file system are set up to automatically configure a virtual Ethernet interface in the virtual machine with an internal IP. Through that virtual network interface, the emulator is set up to enable transferring of files to and from the host machine file system using the TFTP protocol. I mentioned about this user mode network emulation in my last email about network emulation in QEMU.

I downloaded ARM Linux 2.6 kernel image and a RAM disk file system image from QEMU’s website. I then started my QEMU VM (ARM integrator) using following command:

qemu-system-arm –kernel zImage.integrator –initrd arm_root.img –tftp /

This command starts QEMU in system emulation mode emulating an ARM integrator platform (default platform for qemu-system-arm). It boots into kernel image zImage.integrator and loads it into VM’s RAM i.e. arm_root.img.

–tftp / instructs QEMU to make entire host root file system available for access via TFTP from VM.

I can now access my host file system using following command on guest Linux terminal:

Tftp –g –r /usr/QEMU_Learning/Test_Documents/test.txt –l guest_test.txt 10.0.2.2

This will read test.txt from my host file system and will copy it to guest system.

2.     SSH in QEMU VM:

     Copy it from emails.