Total Pageviews

Showing posts with label KVM. Show all posts
Showing posts with label KVM. Show all posts

Wednesday, February 2, 2011

KVM Virtual Machine Renaming

 Renaming KVM  Virtual Guest Running on RHEL

 This below docs covers how to rename  any of the guest  running on  RHL5.4 and later KVM+libvirt Host

Log in as root on the Host because Most of below virsh  commands require root privileges to run due to the communications channels used to talk to the hypervisor. Running as non root will return an error.

Then run the virsh - management user interface  tool from  the command line

What is virsh?

The virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains.

The basic structure of most virsh usage is:

virsh <command> <domain-id> [OPTIONS]

Where command is one of the commands listed below, domain-id is the numeric domain id, or the domain name (which will be internally translated to domain id), and OPTIONS are command specific options.

The virsh program can be used either to run one command at a time by giving the command as an argument on the command line, or as a shell if no command is given in the command line, it will then start a minimal interpreter waiting for your commands and the quit command will then exit the program.

 After execute the "list" command  it will list all the running guest with Name is the name of the domain.  ID the domain numeric id.  State is the run state .  If you want to list all the guest run "list --all" inside a virsh shell

 In our next step  we are going to  select the guest we wish to rename in our case its RHEL6-JON with the ID 11 and its in running state .

[root@kvm7-hp-dl-380G6 ~]# virsh
Welcome to virsh, the virtualization interactive terminal.

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

virsh # list
 Id Name                 State
----------------------------------
  4 RHEVM2.2-Win2k8R2    running
 11 RHEL6-JON            running

virsh # list --all
 Id Name                 State
----------------------------------
  4 RHEVM2.2-Win2k8R2    running
 11 RHEL6-JON            running
  - Win2k3            shut off
  - RHEL-WEB             shut off

virsh # edit 11          (it will open the guest xml file in vi  editor modify the name and save it)
<domain type='kvm'>
  <name>RHEL6-JON</name>        --->change the name from  RHEL6-JON to RHEL6-X86_64_JON and save it
  <uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>


virsh # edit 11
error: operation failed: domain 'RHEL6-JON' is already defined with uuid 3a0a2cb7-095a-8ad9-624c-5163cf52692a


 The above error  is exactly the expected behavior.  virsh edit does not support changing the name or UUID.  If you want to change either of those, you'll need to the following.


Shut down the vm using the virsh command line or using virt-manager

#virsh shutdown RHEL6-JON

Change to the directory

cd /etc/libvirt/qemu/

 An easy way to obtain the definition of a pre-existing guest is by using dumpxml command.

# virsh  dumpxml RHEL6-JON  >  RHEL6-X86_64_JON.xml

Now Undefine the configuration for an inactive guest (RHEL6-JON)
[root@kvm7-hp-dl-380G6 qemu]# virsh  undefine RHEL6-JON
Domain RHEL6-JON has been undefined

Now edit the new xml file and save it

[root@kvm7-hp-dl-380G6 qemu]# vi RHEL6-X86_64_JON.xml
<domain type='kvm'>
  <name>RHEL6-X86_64_JON</name>  --> RHEL6-JON was replaced by RHEL6-X86_64_JON
  <uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>

Once you saved it  Define a new  domain from an XML (RHEL6-X86_64_JON.xml)
 
[root@kvm7-hp-dl-380G6 qemu]# virsh define RHEL6-X86_64_JON.xml
Domain RHEL6-X86_64_JON defined from RHEL6-X86_64_JON.xml

Now go to virt-manager or visrh command line and start the renamed guest.

#virsh start RHEL6-X86_64_JON

[root@kvm7-hp-dl-380G6 qemu]# virsh  list --all
 Id Name                 State
----------------------------------
  4 RHEVM2.2-Win2k8R2    running
  5 RHEL6-X86_64_JON     running

Thursday, January 6, 2011

Debugging virt-v2v

Enable Debugging Level on RHEV  Virt-V2v

 In some case if you get any error while  trying  to migrate some of the virtual machines running on vmware or xen using virt-v2v tools and if you didn't get any error output on the command line then you can increase the virt-v2v  debug level verbosity by following the below steps to narrow down and fix the issue .

Check "netcat"  is installed on the machine that is executing virt-v2v from?

 Log in to the server console ( where v2v is installed ) a root and execute the below command to verify netcat is installed or not on the host .

# which  nc 
/usr/bin/nc
# rpm -qf /usr/bin/nc
nc-1.84-22.el6.x86_64

 If you didn't find any then use the below command to install it .


 yum install nc



Please enable debugging by running following commands to get debug logs on the same terminal console where you executed the above commands .

# export LIBGUESTFS_TRACE=1
# export LIBGUESTFS_DEBUG=1

Now try the earlier virt-v2v command on the same terminal console  and check the console logs for detailed error output