This article provides various commands to manage a vSRX instance using virsh.
1) List all running VMs/vSRX on the server.
root@kvm-server:~# virsh list Id Name State---------------------------- 16 ATT-VSRX-1 running 17 ATT-VSRX-2 running
List all VMs/VSRX on the server.
root@kvm-server:~# virsh list --all Id Name State---------------------------- 16 ATT-VSRX-1 running 17 ATT-VSRX-2 running
2) Create a vSRX using virsh.
root@kvm-server:~# virsh create /etc/libvirt/qemu/vsrx3.0-zshu-i40e-1.xmlDomain ATT-VSRX-1 created from /etc/libvirt/qemu/vsrx3.0-zshu-i40e-1.xml
Note: The XML file should be saved in etc/libvirt/qemu/.
3) Get details of a vSRX,
root@kvm-server:~# virsh dominfo ATT-VSRX-1Id: 18Name: ATT-VSRX-1UUID: 39ae56af-cf42-4753-960f-732fc627baa1OS Type: hvmState: runningCPU(s): 5CPU time: 5404.8sMax memory: 8195072 KiBUsed memory: 8195072 KiBPersistent: noAutostart: disableManaged save: noSecurity model: apparmorSecurity DOI: 0Security label: libvirt-39ae56af-cf42-4753-960f-732fc627baa1 (enforcing)
State: Shows if the VM is running, paused, shut off, etc.
CPU(s): Number of virtual CPUs assigned
Max/Used memory: RAM allocation
Persistent: Whether the VM config survives reboots
Autostart: If VM is set to boot with host
4) Define a VM to make it persistent.
root@kvm-server:~# virsh define /etc/libvirt/qemu/vsrx3.0-zshu-i40e-1.xmlDomain ATT-VSRX-1 defined from /etc/libvirt/qemu/vsrx3.0-zshu-i40e-1.xml
root@kvm-server:~# virsh dominfo ATT-VSRX-1Id: 19Name: ATT-VSRX-1UUID: 674069cb-9fdf-458d-bdd7-340b7da96af1OS Type: hvmState: runningCPU(s): 5CPU time: 30.6sMax memory: 8195072 KiBUsed memory: 8195072 KiBPersistent: yes>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>The VM config will survive the server reboot.Autostart: disableManaged save: noSecurity model: apparmorSecurity DOI: 0Security label: libvirt-674069cb-9fdf-458d-bdd7-340b7da96af1 (enforcing)
3) Console to vSRX using virsh.
root@kvm-server:~# virsh console ATT-VSRX-1Connected to domain ATT-VSRX-1Escape character is ^]
FreeBSD/amd64 (Amnesiac) (ttyu0)
login:
4) Pause/suspend a running vSRX
root@kvm-server:~# virsh suspend ATT-VSRX-1Domain ATT-VSRX-1 suspended
root@kvm-server:~# virsh list Id Name State---------------------------- 17 ATT-VSRX-2 running 18 ATT-VSRX-1 paused
5) Resume a paused vSRX
root@kvm-server:~# virsh resume ATT-VSRX-1Domain ATT-VSRX-1 resumed
root@kvm-server:~# virsh list Id Name State---------------------------- 17 ATT-VSRX-2 running 18 ATT-VSRX-1 running
6) Shutdown vSRX using virsh
root@kvm-server:/etc/libvirt/qemu# virsh list --all Id Name State------------------------------------ - ATT-VSRX-2 shut off - vsrx3.0-zshu-i40e shut off
7) Power-off the system using virsh.
root> request system power-off warning: The configuration has been changed but not committedPower Off the system ? [yes,no] (no) yes
8) Force stop (Destroy) a VM
root@kvm-server:~# virsh destroy ATT-VSRX-1Domain ATT-VSRX-1 destroyed
9) View XML configuration file.
root@kvm-server:/etc/libvirt/qemu# virsh dumpxml ATT-VSRX-2<domain type='kvm'> <name>ATT-VSRX-2</name> <uuid>db70a4a1-51f9-4fbd-9b6b-5ad09fde694a</uuid> <memory unit='KiB'>8194304</memory> <currentMemory unit='KiB'>8194304</currentMemory> <vcpu placement='static'>5</vcpu>
v1