Saturday, November 3, 2012

Virtualization

Virtualization, the buzz word which we hear most these days in IT.

Virtualization, in computing, is the creation of a virtual (rather than actual) version of something, such as a hardware platform

Why Virtualization.?
  • Reduce the number of physical machines, thus reducing power consumption.
  • Increase space utilization efficiency in your data center.
  • Isolate environments but share hardware
  • Make better use of existing capacity
  • Virtualize Network and SAN interfaces to reduce infrastructure needs.
  • Ultimately save on maintenance and leases
Types
  • Full Virtualization
  • Para Virtualization
  • Hardware Assisted
The Hypervisor

The role of the Hypervisor is supporting Guest Operating Systems on a single machine.


Before going into Virtualization, there is one more concept which needs to be known, that is Security or Protection Rings in OS

Security / Protection Rings
  • Protection rings  is a mechanism to protect data and functionality from faults.
  • Computer operating systems provide different levels of access to resources.
  • Special gates exist between rings to allow outer ring to access inner rings resource is a predefined manner.

E.g. : A spyware program in ring 3 is not allowed to start web camera which is in ring 0.


Full Virtualization
  • In Full Virtualization Guest OS doesn’t know that it has been Virtualized, thinks it fully ‘owns’ the Hardware.
  • Uses a combination of binary translation and direct execution techniques.
  • Non-virtualizable instructions are translated into new sequences which have same intended effect in Virtual Hardware.
  • Guest OS is completely abstracted (decoupled) from under lying hardware by Virtualization layer.
  • Eg. VMWare ESX.


  • User Level code is directly executed on the Processor for high performance.
  • OS level sensitive calls are trapped by VM and executed.
  • Virtual machine monitor provides each Virtual Machine with all the services of the physical system, including virtual devices and virtualized memory management.
Para Virtualization
  • Also know as OS assisted Virtualization
  • Here the Guest OS knows that it has been modified to support Virtualization.
  • Non-virtualizable instructions are replaced by hyper calls that communicate  directly with virtualization layer.
  • It is relatively easy to modify guest OS to enable virtualization than to develop more sophisticated Full Virtualization.
  • E.g. :Xen


Installation Screen of SUSE Linux, asking to choose Server


Hardware Assisted Virtualization
  • Virtualization support is provided by Processors.
  • A privilege ring below “Ring 0” is added to support Virtualization.
  • All sensitive calls are set to automatically trap to the hypervisor, removing need for Full and Para Virtualization.


VMWare - Architecture

KVM - Architecture


Kernel Virtual Machine - KVM
  • KVM is relatively a new comer in Virtualization, but has changed the landscape of Virtualization.
  • Each guest OS is a single process of Host OS
  • A user-space program uses the /dev/kvm interface to set up the guest VM's address space
  • The approach that KVM takes is to turn a Linux kernel into a hypervisor simply by loading a kernel module.
  • The kernel module exports a device called /dev/kvm, which enables a guest mode of the kernel (in addition to the traditional kernel and user modes)
  • Supports Live Migration
  • A VM can be migrated from one Host to other in no time.
  • Guest is not involved.
  • Almost unnoticeable downtime.
  • VM image should be available on shared storage.
  • KVM introduces new process mode guest to existing user and kernel used for execution of guest OS code.
  • Guest mode exists to execute guest operating system code but only for code that's non-I/O.
  • Within guest mode are the standard two modes, so that a guest operating system runs in guest mode but supports the standard kernel and user modes for its kernel and user-space applications.
  • KVM mainly consists of two modules, KVM and QEMU.
  • KVM requires Intel-VT / AMD-SVM processor.

KVM
KVM module is used for Memory Virtualization.
Each guest operating system has its own address space that is mapped when the guest is instantiated.
The physical memory that is mapped for the guest operating system is actually virtual memory mapped into the process

QEMU
QEMU is used for I/O Virtualization.
QEMU is a platform virtualization solution that allows virtualization of an entire PC environment (including disks, graphic adapters, and network devices).
Any I/O requests a guest operating system makes are intercepted and routed to the user mode to be emulated by the QEMU process.

Other Virtualization Technologies
  • Xen, Bochs, UML, Linux-VServer, and coLinux.
  • VMWare
  • AIX – WPAR and VIOS
  • SUN – Zones and LDOMs
  • Microsoft – HyperV

Thursday, August 16, 2012

Code Coverage for PERL Scripts

Update[10/9/2012] : Sample Code Coverage reports are available here.
manosoftlive.com/blog/cover_db/coverage.html

Code Coverage : Code Coverage is considered as direct measure of quality of code.

For example, Consider we have some 1000 lines of code for some utility, which is thoroughly tested.
We don't know how many exact lines of code has been tested, here comes code coverage handy.

Uses : 
- Helps in determining the test gaps.
- To know what extent of code is covered.
- Creating additional test cases to increase the coverage.

Code Metrics
A large variety of metrics exists, many organisations have formal requirements for structural coverage.

Code Metrics for PERL
Code metrics for other languages like C C++ Java can be easily calculated as the code is instrumented.
Coming to PERL, here the code is interpreted, here is the catch.
There are very few tools to measure code metrics for PERL.
Here I will explain the code coverage for PERL using the Perl module Devel::Cover from CPAN.


Prerequisities
- Unix machine
- PERL installed
- make and gmake to install Devel::Cover


Get/Install Devel::Cover from CPAN
This module can be directly downloaded from CPAN at http://search.cpan.org/~pjcj/Devel-Cover-0.93/
All dependencies should be satisfied before going ahead.
OR

Once you have installed all dependencies, you can see "cover" binary in /usr/bin/ or /usr/local/bin
This is used to calculate coverage and generate HTML reports.

If you have problem with resolving dependencies, try manually installing modules as shown below.



Example and getting code Metrics

Save the below as Sample.pl

Save the below as Sample.pm


If you observer the above code, all i added was one line "use Devel::Cover;" , with which i get code metrics.

Lets see the sample run and results.  

Now a folder is created with name "cover_db", where all the info on runs is saved, now we need to generate reports.

Create HTML reports
"cover" is the utility, with which we can generate HTML reports.
All the HTML reports can be customized.



Once the HTML reports are generated, the work is damn simple, just open the HTML file in browser.
See the details reports generated, hope self readable and self explainable

Update[10/9/2012] : Sample Code Coverage reports are available here.
manosoftlive.com/blog/cover_db/coverage.html


Branch Coverage

Condition Coverage

File Coverage

Subroutine Coverage
Understand More: 
This is just to have quick understanding of PERL code coverage.
To understand more, save the above sample files and play around.
Try running the above code samples with different inputs like
bash# perl Sample.pl 3
bash# perl Sample.pl 2 1
bash# perl Sample.pl 2 2 

Many things can be customized according to your need, see below link to CPAN module

Monday, January 25, 2010

Clustering / High Availability

Clustering
A simple term which refers a bunch or group,
In computer terminology refers to bunch of computers.

High Availability
Name itself tells making something which is available all
the times.

We can't imagine a website like google or ebay going down
even for few seconds.There are organisation who can't afford even few seconds of downtime (planned or unplanned).So High Availability has become more important these days
For example we want to make a website/service highly available.
The website may use the following:
Database( some times more than one)
Webserver(some times more than one)
NIC Cards
Storage Connectivity
Internet Connectivity
Power Supply
List goes on.........

It indirectly means that we need to make all the above( sometimes even more) highly available.And its not possible to monitor all these manually, no one
knows when something is going to break or fault.

Here comes Clustering into picture, A group of computers
which are configured in such a way that they can overcome
failures for applications, etc and provide resilency

The load is distributed across different servers, and even
if any of the servers fails, the application is still
accessible via other cluster nodes

Generally a software which manages all these things known as Cluster Server.

A cluster compromises of redundent nodes to provide High
Availability, minimum configutaion requires 2 nodes.

Cluster Server software monitors all resources required to
run an application or service.
It checks the health of disks, R/W access, N/W Access, DB
Access, etc the way we configure it.

For example if something goes wrong say Some process/thread
related to Web Server is killed, it(Cluster s/w) immediately
detects that and gracefully shutsdown the application on
that node and starts it in another node ( redundent )


Major Vendors:
Symantec - Veritas Cluster Server
Sun - Solaris Cluster
Microsoft Microsoft Cluster Server
IBM - IBM Cluster
HP - HP Service Guard

To know more, check the following
http://en.wikipedia.org/wiki/Cluster_(computing)

Tuesday, January 19, 2010

Avoid Spam in GMail

Spam mails are annoying almost all netizens.

Sometimes it happens that we need to subscribe to some service (and see what it provides) and we guess/don’t know whether it may spam us.

But we are left with no other option than to give our e-mail and subscribe.

Here's a good idea to prevent such spam in GMail.

First know your Gmail Address

In GMail your address looks like your.name@gmail.com and no one else will have email address like you.r.name@gmail.com.
GMail has got nothing to do with (.), it ignores any dot (.) in email address.

Gmail doesn't recognize dots as characters within usernames, you can add or remove the dots from a Gmail address without changing the actual destination address; they'll all go to your inbox, and only yours.

For example, if your email address looks like
user.name1@gmail.com

Sending mail to following will come to your mail box only.
u.s.e.r.n.a.m.e.1@gmail.com
username1@gmail.com
u.s.e.r.n.a.m.e.1@googlemail.com
username1@googlemail.com
And even
username1+something@gmail.com this one refers to the same.

Avoiding Spam

If you need to subscribe to some abseexyzee.com and you suspect that it may spam you (and you want to try that), then follow these steps to avoid spam.

While giving your details in abseexyzee.com just give your email as username+test@gmail.com
username+test@googlemail.com

If abseexyzee.com starts sending spam they will be sent to username+test@gmail.com

Login to GMail at http://mail.google.com (use https for secure version) and Click on Settings top right.
Create a filter which deletes(depends how you create a filter) mails which come with that address username+test@gmail.com
Let us see how to create a filter in GMail

Creating a Filter in GMail
1. Click Setting in GMail


2. Go to Filters tab

3. Click on Create a new Filter

Just create a filter according to your requirements.
If you want to filter messages coming to username1+test@gmail.com
Specify that in to column, and others fields...
You can Test Filter using Test Search or Next Step to choose action
4. Select the option which you want to do.

Like delete, mark it as read; apply a label, etc, etc..
5. If a mail comes with username1+test@gmail.com it will be deleted (Depending on what you action you have chosen).

In this way you can avoid spam :-)

NOTE: abseexyzee.com is given only for illustration purpose, i have got nothing to do with this site even if it exists.

Sunday, March 22, 2009

GMail's new Feature "undo send"

Now, unsend emails

Gmail’s new feature ‘undo send’ enables users to stop emails from being sent within 5 secs

All those who tend to get themselves into unpleasant email “situations” every now and then can finally relax, thanks to an “undo send” feature launched by Gmail. Any user can enable the new feature in ‘Gmail Labs’ under ‘Settings’.




If a user feels that the email he just sent should be stopped, he or she should hit the ‘undo send’ button.
However, the user intending to stop the mail from being sent would get only five seconds to hit the button.