天天看點

ubuntu15.04下編譯 libvirt

很久沒有編譯 libvirt了。

工作需要,重新編譯。 

[org_ref]: http://libvirt.org/compiling.html 很簡單。 編譯過程, 還是很多問題。 

依賴包(給懶人參考):

$ sudo apt-get install libtool libxml-xpath-perl libxml2 libxml2-utils python-dev automake autopoint xsltproc libxml++2.6-dev  libdevmapper-dev  libpciaccess-dev libnl-3-dev  libnl-route-3-dev imagemagick libyajl-dev xmllint uniconvertor

勤快的家夥們,可以自己編譯,自己檢視,缺了每個包的功能。

libnl-route-3-200 - library for dealing with netlink sockets - route interface 

libnl-3-200: library for dealing with netlink sockets

rpcgen: 這個包不需要安裝,但是可以man一下。 之前在公司的wiki中,介紹過rpcgen。 可惜...

$ git grep RPCGEN

在libvirt中,src/remote/remote_protocol.x 産生:

$ tree -f |grep  remote_protocol

$ git show eb826444f90c2563dadf148630b0cd6a9b41ba1e 

檢視詳細過程。

編譯

https://libvirt.org/compiling.html

編譯完成,啟動遠端連結注意問題。 

http://libvirt.org/remote.html#Remote_certificates 

http://www.vmware.com/pdf/vsphere4/r40/vsp_40_esx_server_config.pdf

http://libvirt.org/drvesx.html#connproblems

 可以不啟用用tls,config中修改一下,就可以了。

1 diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
 2 index d2c439c..aa547bd 100644
 3 --- a/daemon/libvirtd.conf
 4 +++ b/daemon/libvirtd.conf
 5 @@ -19,7 +19,7 @@
 6  # using this capability.
 7  #
 8  # This is enabled by default, uncomment this to disable it
 9 -#listen_tls = 0
10 +listen_tls = 0
11  
12  # Listen for unencrypted TCP connections on the public TCP/IP port.
13  # NB, must pass the --listen flag to the libvirtd process for this to
14 @@ -164,7 +164,7 @@
15  #
16  # It is possible to make use of any SASL authentication
17  # mechanism as well, by using 'sasl' for this option
18 -#auth_tls = "none"
19 +auth_tls = "none"
20  
21  
22  # Change the API access control scheme
23 @@ -215,7 +215,7 @@
24  #
25  # Default is to always run sanity checks. Uncommenting this
26  # will disable sanity checks which is not a good idea
27 -#tls_no_sanity_certificate = 1
28 +tls_no_sanity_certificate = 1
29  
30  # Flag to disable verification of client certificates
31  #
32 @@ -225,7 +225,7 @@
33  #
34  # Default is to always verify. Uncommenting this will disable
35  # verification - make sure an IP whitelist is set
36 -#tls_no_verify_certificate = 1
37 +tls_no_verify_certificate = 1
38  
39  
40  # A whitelist of allowed x509 Distinguished Names      

View Code

啟動libvirt調試:

編譯

https://libvirt.org/compiling.html

$ cat /usr/bin/gdb-libvirt

1 # ps -ef  |grep  lt-libvirtd |grep -v grep  | awk '{print $2}'  | xargs gdb -p  
 2 LIBVIRT_PID=`ps -ef  |grep  lt-libvirtd |grep -v grep | grep -v gdb-libvirt | awk '{print $2}'`
 3 echo $LIBVIRT_PID                                                               
 4 LIBVIRT_PID=`cut -d " " -f1  <<< $LIBVIRT_PID`                                  
 5 if [ x$LIBVIRT_PID != x"" ]; then                                               
 6     echo "=================================================="                   
 7     echo "attach libvirt-d"                                                     
 8     echo "sudo gdb -p $LIBVIRT_PID"                                             
 9     sudo gdb -p $LIBVIRT_PID                                                    
10 else                                                                            
11     echo "***************************************************"                  
12     echo "start libvirt-d"                                                      
13     # sudo ./daemon/libvirtd --listen --verbose -f ./daemon/libvirtd.conf       
14     sudo ./daemon/libvirtd --listen -f ./daemon/libvirtd.conf                   
15 fi                 

View Code

1 # ps -ef  |grep  lt-libvirtd |grep -v grep  | awk '{print $2}'  | xargs gdb -p
 2 LIBVIRT_PID=`ps -ef  |grep  lt-libvirtd |grep -v grep | grep -v gdb-libvirt | awk '{print $2}'`
 3 echo $LIBVIRT_PID
 4 LIBVIRT_PID=`cut -d " " -f1  <<< $LIBVIRT_PID`
 5 if [ x$LIBVIRT_PID != x"" ]; then
 6     echo "=================================================="
 7     echo "attach libvirt-d"
 8     echo "sudo gdb -p $LIBVIRT_PID"
 9     if [ -f "br" ]; then
10         sudo gdb -p $LIBVIRT_PID -x br
11     else
12         sudo gdb -p $LIBVIRT_PID
13     fi
14 else
15     echo "***************************************************"
16     echo "start libvirt-d"
17     # sudo /home/ubuntu/libvirt/daemon/libvirtd --listen --verbose
18     sudo /home/ubuntu/libvirt/daemon/libvirtd -f /home/ubuntu/libvirt/daemon/libvirtd.conf --listen
19 fi      

View Code

$ cat /usr/bin/gdb-virsh

1 if [ x$1 = "x-g" ]; then
2 sudo /home/shaohe/libvirt/run gdb /home/shaohe/libvirt/tools/virsh
3 else
4 sudo /home/shaohe/libvirt/run /home/shaohe/libvirt/tools/virsh
5 fi      

View Code

1 if [ x$1 = "x-g" ]; then                                                        
2     sudo ./run gdb ./tools/virsh                                                
3 else                                                                            
4     sudo ./run ./tools/virsh                                                    
5 fi        

View Code