Renaming KVM Virtual Guest Running on Centos
This below docs covers how to rename any of the guest running on CentOS 5.6 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 Centos6-prakash with the ID 14 and its in running state.
[root@prakash ~]# 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
14 Centos6-prakash running
virsh # list --all
Id Name State
----------------------------------
4 RHEVM2.2-Win2k8R2 running
14 Centos6-prakash running
- Win2k3 shut off
- RHEL-WEB shut off
virsh # edit 14 (it will open the guest xml file in vi editor modify the name and save it)
<domain type='kvm'>
<name>Centos6-prakash</name> --->change the name from Centos6-prakash to RHEL6-X86_64_prakash and save it
<uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
virsh # edit 14
error: operation failed: domain 'Centos6-prakash' 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 Centos6-prakash
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 Centos6-prakash > CentOS6-X86_64_Prakash.xml
Now Undefine the configuration for an inactive guest (Centos6-prakash)
[root@prakash qemu]# virsh undefine Centos6-prakash
Domain Centos6-prakash has been undefined
Now edit the new xml file and save it
[root@prakash qemu]# vi Centos6-X86_64_prakash.xml
<domain type='kvm'>
<name>CentOS6-X86_64_prakash</name> --> Centos6-prakash was replaced by Centos6-X86_64_prakash
<uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>
Once you saved it Define a new domain from an XML (Centos6-X86_64_Prakash.xml)
[root@prakash qemu]# virsh define Centos6-X86_64_prakash.xml
Domain Centos6-X86_64_prakash defined from Centos6-X86_64_prakash.xml
Now go to virt-manager or visrh command line and start the renamed guest.
# virsh start Centos6-X86_64_prakash
[root@prakash qemu]# virsh list --all
Id Name State
----------------------------------
4 RHEVM2.2-Win2k8R2 running
5 Centos6-X86_64_Prakash running
----------------------------------
This below docs covers how to rename any of the guest running on CentOS 5.6 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 Centos6-prakash with the ID 14 and its in running state.
[root@prakash ~]# 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
14 Centos6-prakash running
virsh # list --all
Id Name State
----------------------------------
4 RHEVM2.2-Win2k8R2 running
14 Centos6-prakash running
- Win2k3 shut off
- RHEL-WEB shut off
virsh # edit 14 (it will open the guest xml file in vi editor modify the name and save it)
<domain type='kvm'>
<name>Centos6-prakash</name> --->change the name from Centos6-prakash to RHEL6-X86_64_prakash and save it
<uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
virsh # edit 14
error: operation failed: domain 'Centos6-prakash' 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 Centos6-prakash
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 Centos6-prakash > CentOS6-X86_64_Prakash.xml
Now Undefine the configuration for an inactive guest (Centos6-prakash)
[root@prakash qemu]# virsh undefine Centos6-prakash
Domain Centos6-prakash has been undefined
Now edit the new xml file and save it
[root@prakash qemu]# vi Centos6-X86_64_prakash.xml
<domain type='kvm'>
<name>CentOS6-X86_64_prakash</name> --> Centos6-prakash was replaced by Centos6-X86_64_prakash
<uuid>3a0a2cb7-095a-8ad9-624c-5163cf52692a</uuid>
Once you saved it Define a new domain from an XML (Centos6-X86_64_Prakash.xml)
[root@prakash qemu]# virsh define Centos6-X86_64_prakash.xml
Domain Centos6-X86_64_prakash defined from Centos6-X86_64_prakash.xml
Now go to virt-manager or visrh command line and start the renamed guest.
# virsh start Centos6-X86_64_prakash
[root@prakash qemu]# virsh list --all
Id Name State
----------------------------------
4 RHEVM2.2-Win2k8R2 running
5 Centos6-X86_64_Prakash running
----------------------------------
No comments:
Post a Comment