Wednesday, March 21, 2018
Tuesday, March 13, 2018
copy/paste with mouse for tmux on mac
To restore the default copy/paste configuration you need to (at least temporarily) turn off mouse support within tmux:
prefix : set -g mouse off
Where
prefix
is the tmux access key (Ctrl+B by default unless you re-map it). : starts command mode and set -g
sets the parameter globally.Friday, February 23, 2018
Bash assign variable from a command output
How do I assign the output of a shell command to a shell variable under Unix like operating system? For example, I want to store the date command output to a variable called $now.
How do you do that?
var=$(/path/to/command arg1 arg2)
The content of test.sh
#!/bin/bash
PROD=$(ls -al)
echo "${PROD}"
the output
~$ bash test.sh |grep xen
drwxrwxr-x 3 user group 4096 Mar 7 2017 test_xen
drwxrwxr-x 3 user group 4096 Mar 7 2017 test_xen_4.7
Wednesday, February 21, 2018
install cross compiled VIM on the target machine
1. cross compiling vim8.0
2. copy vim to /usr/local/bin on the target machine
3. copy .vimrc to target machine
4. copy syntax.vim to /usr/local/share/vim/syntax on the target machine
5. copy ~/.vim/colors/kolor.vim (kolor is my favorite color theme) to the target machine
6. you are good to go
2. copy vim to /usr/local/bin on the target machine
3. copy .vimrc to target machine
4. copy syntax.vim to /usr/local/share/vim/syntax on the target machine
5. copy ~/.vim/colors/kolor.vim (kolor is my favorite color theme) to the target machine
6. you are good to go
Wednesday, February 14, 2018
Migrate KVM Disk Access from IDE to Virtio
So in order to make the switch from from
ide or Sata
to virtio
, the following steps need to be taken:
Run
virsh edit <your_vm_name>
. From there, edit the config file and adjust all lines of<target dev='hda' bus='ide'/>
<target dev='sda' bus='sata'/>
so they look like this
<target dev='vda' bus='virtio'/>
Furthermore, remove all
<address type .../>
lines so that libvirt
can regenerate them appropriately.
Inside the guest, edit
/etc/fstab
and replace all occurrences of /dev/sdX
with /dev/vdX`.
That’s it, now shutdown the machine and start it with an
virsh start <your_vm_name>
(just a reboot inside the started VM won’t work).Friday, February 9, 2018
using virt-viewer remote access KVM guest vm
sometime you try to access someone's host machine, which KVM running several vm image, you want to access one of the vm.
one the remote host (name: wawr-builder, ip 10.71.50.228) machine:
wawr@wawr-builder:~$ virsh list
Id Name State
----------------------------------------------------
2 Ubuntu64 running
11 av_virtual_3 running
from my local machine, you can do:
jim@jim-dell-5810:~$ virt-viewer --connect qemu+ssh://wawr@10.71.50.228/system av_virtual_3
With the above, you’ll have to enter your SSH password twice – first to establish the connection to the hypervisor and secondly to establish a tunnel to the VM’s VNC/SPICE session
see original post:
https://www.jethrocarr.com/2012/08/04/virt-viewer-remote-access-tricks/
using perf for profiling
the sample code test_a.c as below:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
void func3(void)
{
int count = 0;
char src[100];
char dst[100];
for(count=0; count < 0XFF; count++)
memcpy(src,dst, sizeof(src));
return;
}
void func2()
{
int count = 0;
int64_t s =1;
for(count=0; count < 0XFF; count++)
{
s =s *(count+1);
func3();
}
return;
}
void func4()
{
int count = 0;
int64_t s =1;
for(count=0; count < 0XFF; count++)
{
s =s *(count+1);
func3();
}
return;
}
void func1(void)
{
int count = 0;
for(count=0; count < 0XFFFF; count++)
func2();
return;
}
int main(void)
{
printf("\n Hello World! \n");
func1();
printf("\n step 2! \n");
func4();
return 0;
}
#include <stdint.h>
#include <string.h>
void func3(void)
{
int count = 0;
char src[100];
char dst[100];
for(count=0; count < 0XFF; count++)
memcpy(src,dst, sizeof(src));
return;
}
void func2()
{
int count = 0;
int64_t s =1;
for(count=0; count < 0XFF; count++)
{
s =s *(count+1);
func3();
}
return;
}
void func4()
{
int count = 0;
int64_t s =1;
for(count=0; count < 0XFF; count++)
{
s =s *(count+1);
func3();
}
return;
}
void func1(void)
{
int count = 0;
for(count=0; count < 0XFFFF; count++)
func2();
return;
}
int main(void)
{
printf("\n Hello World! \n");
func1();
printf("\n step 2! \n");
func4();
return 0;
}
#compiling with:
gcc -Wall test_a.c -g -o test_a
#install perf on ubuntu 14:
sudo apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r`
#run test_a:
./test_a
#find test_a pid as 21033 through
ps aux|grep test_a
sudo perf record -p 21033
#ctrl+c to break
sudo perf report
it will show the profiling result as below:
now you know the bottle neck--- func3()
you can also see real time cpu usage by :
sudo perf top
other option -g
perf record -g -p pid
perf report -g 'graph,0.5,caller'perf report --max-stack=6 --stdio -s parent
ref: http://rhaas.blogspot.co.uk/2012/06/perf-good-bad-ugly.html
Subscribe to:
Posts (Atom)