RHCA: libvirt create/delete domain

create a kvm guest:
[root@home ~]# virt-install --connect qemu:///system \
               --hvm  --virt-type kvm \
               # --pxe
               # --cdrom /path/to/rhel-server-6.2-x86_64-dvd.iso \
               --name=client01 --description="satellite client 1" \
               --ram=1024 --vcpu=2 \
               --os-type=linux --os-variant=rhel6 --noapic --noacpi \
               --disk path=/var/lib/libvirt/images/client01.qcow2,size=10,bus=virtio,format=qcow2 \
               --network network=wireless0 \
               --serial pty --console pty,target_type=serial \
               # --dry-run 
               # --print-step all

clone a kvm guest:
[root@home ~]# virt-clone -o client01 -n client02 --auto-clone

delete a kvm guest:
[root@home ~]# virsh list --all
 Id Name                 State
----------------------------------
  4 satellite            paused
  - client01             shut off
  - client02             shut off

[root@home ~]# virsh pool-list
Name                 State      Autostart
-----------------------------------------
default              active     yes

[root@home ~]# virsh vol-list default | grep client01
client01.img         /var/lib/libvirt/images/client01.img
client01.qcow2       /var/lib/libvirt/images/client01.qcow2

[root@home ~]# virsh vol-delete /var/lib/libvirt/images/client01.img
Vol /var/lib/libvirt/images/client01.img deleted

[root@home ~]# virsh vol-delete /var/lib/libvirt/images/client01.qcow2
Vol /var/lib/libvirt/images/client01.qcow2 deleted

[root@home ~]# virsh undefine client01
Domain client01 has been undefined
[root@home ~]# virsh list --all
 Id Name                 State
----------------------------------
  4 satellite            paused
  - client02             shut off

No comments:

Post a Comment