Showing posts with label kvm. Show all posts
Showing posts with label kvm. Show all posts

03 September 2020

Sandbox: vmImage preparation

Sandbox normally will need a clean snapshot of vmImage.

If you are using qemu/kvm, this is how to create snapshot


1) run the guest, make sure evertyhing works
    - network ok 
    - - - can go to internet, 
    - - -  can communicate to sandbox manager(can ping to sandbox mgr)
    - - -  sandbox mgr can ping to vmImage
    - agent already running


2) create snapshot:
     $ virsh snapshot-create-as --domain <vm_image>  --name <snapshot_name>

3) to verified your snapshot is working
   -  shutdown the guest
          $  virsh shutdown <vm_image>
           or  virsh destroy <vm_image>

   -  revert to snapshot
           $ virsh snapshot-revert <vm_image> <snapshot_name>






25 August 2020

Good read to understand relation of Virtualization - Hypervisor - KVM -QEMU


- KVM is linux kernel modul. No gui. Only provide CPU and RAM, not hd, network etc.

- Qemu is an emulator of varied cpu. It also has features to use KVM which will boost performance compare to other emulated cpu type.

-Libvirt as wrapper to start QEMU with the right options.


For more, refer this good explanation:

 https://superuser.com/questions/1490188/what-is-the-difference-and-relationship-between-kvm-virt-manager-qemu-and-libv

Qemu/kvm/virsh Snapshot

 create snapshot:

sudo virsh snapshot-create-as <domain> <snapshot-name>


This will create xml file in /var/lib/libvirt/qemu/snapshot/<domain>/<snapshot-name>.xml


Normally for snapshot, will have Copy-On-Write. Means anything changes will be save somewhere else instead of main disk image.


But for qcow2, little bit different. The changes still will be store on the main disk image.


To list snapshot:

# qemu-img snapshot -l /var/lib/libvirt/qemu/centos7-server.qcow2
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
1         live_snapshot1         2.3G 2020-08-25 12:44:09   00:32:40.190



https://unix.stackexchange.com/questions/570414/understanding-how-libvirt-snapshots-are-stored