Thursday, July 25, 2013

Find out if CPU supports hardware vitualization Intel VT-X or AMD-V

grep --color vmx /proc/cpuinfo

or 

# grep --color svm /proc/cpuinfo


http://www.cyberciti.biz/faq/linux-xen-vmware-kvm-intel-vt-amd-v-support/

Monday, July 22, 2013

Tips of bibliography in Latex

include bibliography in main.tex

\bibliographystyle{abbrv}
\bibliographystyle{acm}
\bibliographystyle{plain}
\bibliographystyle{IEEEtran}  

\bibliography{bibliography/biosbib}

URL: 

You can put it in URL field, but it only shows on IEEE format (IEEEtran), it does not show up for other format. You have to move url to HowPublished field.

For example:
\url{www.windbg.org}

Please remember to include \usepackage{url} in the main.tex

Misc:

Sometimes, you don't know the author of the reference, and the author is a group name. In this case, you need to add a curly brace out side of the group name, and the bibtex will not threat it as human names.

For example:
@MISC{tboot,
  author = {{Trust Computing Group}},
  title = {{Trusted Boot}},
  howpublished = {\url{http://www.trustedcomputinggroup.org/resources/trusted_boot}},
  owner = {fengwei},
  timestamp = {2013.05.03}
}

If you don't add curly brace, it will treat the word "group" as the last name, and order the reference based on that.


Thursday, July 18, 2013

Assembly Tip

It look like we should not use memory address directly in Assembly. Let's take a look at following example:

movl $0xA9000, %ebx
rdtsc
movl %eax, (%ebx)
movl %edx, 4(%ebx)

It stores the TSC value to memory location 0xA9000.
If I use the memory location directly in the assembly, the code willl not work. 

rdtsc
movl %eax, 0xA9000
movl %edx, 0xA9004




Access MSR (memory specific register) on Linux

msr-tool

https://www.kernel.org/pub/linux/utils/cpu/msr-tools/

After download the tool, cd into the folder and do $make

Usage:
./rdmsr [ADDRESS]
./rdmsr [ADDRESS] [DATA]

If you have following error:
rdmsr:open: No such file or directory

Load the msr module
$modprobe msr

http://linux.koolsolutions.com/2009/09/19/howto-using-cpu-msr-tools-rdmsrwrmsr-in-debian-linux/


Friday, July 12, 2013

OpenVZ live migration

OpenVZ has its own migration tool: vzmigrate
Usage:
vzmigrate --live -t REMOTE_IP CONTAINER_ID

More detail: $man vzmigrate

A paper describe how it works: 
http://www.landley.net/kdocs/ols/2008/ols2008v2-pages-85-90.pdf

Tuesday, July 9, 2013

Basic Commands of OpenVZ

$ vzlist
list all of the active containers

$vzctl start 101
$vzctl stop 101
$vzctl restart 101

$vzctl destroy 101
$vzct enter 101

More: http://openvz.org/Basic_operations_in_OpenVZ_environment

[root@sr1s1 ~]# vz
vzcalc         vzcpucheck     vzdqdump       vzifup-post    vzmigrate      vzpid          vzstats      
vzcfgvalidate  vzctl          vzdqload       vzlist         vznetaddbr     vzquota        vzubc        
vzcptcheck     vzdqcheck      vzeventd       vzmemcheck     vznetcfg       vzsplit      


$ vzctl exec 101 ps -ef
See more on man vzctl

Wednesday, July 3, 2013

Enable networking in VENET OpenVZ container

I followed the instruction from OpenVZ website fo quickly create an VENET container, but it took me a while to enable networking.
Environment: CentOS 6.4 as the server, and try to create an centos-6-x86_64 container

Here is the instruction from OpenVZ website:

https://openvz.org/Quick_Installation_CentOS_6

Create a VENET Container

  • Create a CT
# vzctl create 101 --ostemplate centos-6-x86_64 --config vswap-1g
  • Configure the CT
# vzctl set 101 --save --name server101
# vzctl set 101 --save --onboot yes
# vzctl set 101 --save --hostname server101.example.com
# vzctl set 101 --save --ipadd 192.168.1.101
# vzctl set 101 --save --searchdomain example.com
# vzctl set 101 --save --nameserver 8.8.8.8 --nameserver 8.8.4.4
# vzctl set 101 --save --cpus 4
# vzctl set 101 --save --ram 8G
# vzctl set 101 --save --swap 4G
# vzctl set 101 --save --diskspace 100G
# vzctl start 101
# vzctl exec 101 passwd
  • Done. Enjoy your new VENET container



The instruction is correct, but there are 3 things you may want to pay attention.

1. set up a correct nameserver.
If you are setting up a real server, you can use command $dhclient, and it automatically identify the nameservers and write them into /etc/resovl.conf file. In OpenVZ container, we need to set it up manually.

2. use a correct IP.
In my case, I followed the instruction, and use IP address as 192.168.1.101, which causes me problem to connect to internet in the container. Then, I changed the IP address to 192.168.0.101, and the container can ping google successfully. I think this is because there are internal setting in my subnet, and they may have some IP restrictions.

3. set up a correct IP tables in host node.
Because I used Cent OS 6.4 as my host server, it has IP tables firewall enabled. One simpler solution is to run command $ iptables --flush, it clean all of the IP table rules, but it comes back after reboot. If you want to permanetly change the iptable settings, you need to add a rule to allow the connection from the container to the Internt.

Additionally, take read this page: https://openvz.org/Common_Networking_HOWTOs
My experiments have been working with private IP inaccessible from LAN (case 1) and public static IP accessible from the same LAN (case 2).

Note that, we need to change the interface name (run ifconfig to see which interface that connections to the outside on host) to run this command that enables ping google from the containers.
[host-node]# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE