lost and found ( for me ? )

Ubuntu 11.04 : install libvirt from source , connect to ESXi w/ virsh


libvirt which is provided by apt-get has no ESXi driver , so I build libvirt with ESX driver from source.
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 11.04"

# uname -r
2.6.38-10-server

# libvirtd --version
libvirtd (libvirt) 0.8.8


[ download libvirt ]

download libvirt source file from http://libvirt.org
I downloaded libvirt-0.9.3.tar.gz.

[ build libvirt ]

install the following packages via apt-get
# apt-get install gcc make libxml2-dev libgnutls-dev libdevmapper-dev libcurl4-gnutls-dev python-dev libnl-dev libsasl-dev

# tar xzvf libvirt-0.9.3.tar.gz
# cd libvirt-0.9.3/


specify –with-esx option.
# ./configure --help | egrep esx
 --with-esx              add ESX support [default=check]


confirm ESX diver is yes.
# ./configure –prefix=/usr/local/libvirt --with-esx
<snip>
configure: Drivers
configure:
configure:      Xen: no
configure:     QEMU: yes
configure:      UML: yes
configure:   OpenVZ: yes
configure:   VMware: yes
configure:     VBox: yes
configure:   XenAPI: no
configure: xenlight: no
configure:      LXC: yes
configure:     PHYP: no
configure:      ESX: yes
configure:     Test: yes
configure:   Remote: yes
configure:  Network: yes
configure: Libvirtd: yes
configure:    netcf: no
configure:  macvtap: yes
configure: virtport: yes

# ./configure --prefix=/usr/local/libvirt --with-esx
# make
# make install

# /usr/local/libvirt/sbin/libvirtd --version
/usr/local/libvirt/sbin/libvirtd (libvirt) 0.9.3

# ls /usr/local/libvirt/*
/usr/local/libvirt/bin:
virsh  virt-pki-validate  virt-xml-validate

/usr/local/libvirt/etc:
libvirt  logrotate.d  sasl2

/usr/local/libvirt/include:
libvirt

/usr/local/libvirt/lib:
libvirt          libvirt-qemu.so        libvirt.a   libvirt.so.0      python2.7
libvirt-qemu.a   libvirt-qemu.so.0      libvirt.la  libvirt.so.0.9.3
libvirt-qemu.la  libvirt-qemu.so.0.9.3  libvirt.so  pkgconfig

/usr/local/libvirt/libexec:
libvirt_iohelper  libvirt_lxc

/usr/local/libvirt/sbin:
libvirtd

/usr/local/libvirt/share:
augeas  doc  gtk-doc  libvirt  locale  man  polkit-1

/usr/local/libvirt/var:
cache  lib  log  run

# /usr/local/libvirt/sbin/libvirtd --help

libvirt management daemon:

 Default paths:

   Configuration file (unless overridden by -f):
     /usr/local/libvirt/etc/libvirt/libvirtd.conf

   Sockets:
     /usr/local/libvirt/var/run/libvirt/libvirt-sock
     /usr/local/libvirt/var/run/libvirt/libvirt-sock-ro

   TLS:
     CA certificate:     /usr/local/libvirt/etc/pki/CA/caert.pem
     Server certificate: /usr/local/libvirt/etc/pki/libvirt/servercert.pem
     Server private key: /usr/local/libvirt/etc/pki/libvirt/private/serverkey.pem

   PID file (unless overridden by -p):
     /usr/local/libvirt/var/run/libvirtd.pid


[ usage ]
connect to ESXi
# /usr/local/libvirt/bin/virsh -c esx://vmware/?no_verify=1 list --all
Enter username for vmware [root]: root
Enter root's password for vmware:
Id 名前               状態
----------------------------------
 - CentOS5-64bit        shut off
 - SL6-1-32bit          shut off
 - SL6-2-32bit          shut off


no_verify=1 instructs libvirt not to verify server’s certification.

You can manage VMs on ESXi via virsh

connect to ESXi
# LANG=C /usr/local/libvirt/bin/virsh -c esx://vmware/?no_verify=1
Enter username for vmware [root]: root
Enter root's password for vmware:
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
      'quit' to quit

virsh #


start VM
virsh # start SL6-1-32bit
Domain SL6-1-32bit started

virsh # list --all
Id Name                 State
----------------------------------
16 SL6-1-32bit          running


dump configuration file
virsh # dumpxml SL6-1-32bit
<domain type='vmware' id='16'>
 <name>SL6-1-32bit</name>
 <uuid>564deaf8-a7d9-676c-60ce-e497deb97091</uuid>
 <memory>1048576</memory>
 <currentMemory>1048576</currentMemory>
 <vcpu>1</vcpu>
 <cputune>
   <shares>1000</shares>
 </cputune>
 <os>
   <type arch='i686'>hvm</type>
 </os>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>destroy</on_crash>
 <devices>
   <disk type='file' device='disk'>
     <source file='[datastore1] SL1/SL1.vmdk'/>
     <target dev='sda' bus='scsi'/>
     <address type='drive' controller='0' bus='0' unit='0'/>
   </disk>
   <disk type='file' device='cdrom'>
     <source file='/usr/lib/vmware/isoimages/linux.iso'/>
     <target dev='hdc' bus='ide'/>
     <address type='drive' controller='0' bus='1' unit='0'/>
   </disk>
   <controller type='scsi' index='0' model='vmpvscsi'/>
   <controller type='ide' index='0'/>
   <interface type='bridge'>
     <mac address='00:0c:29:b9:70:91'/>
     <source bridge='VM Network'/>
     <model type='vmxnet3'/>
   </interface>
   <video>
     <model type='vmvga' vram='8192'/>
   </video>
 </devices>
</domain>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.