Description

This article provides various commands to manage a vSRX instance using virsh.

Solution

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.xml
Domain 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-1
Id:             18
Name:           ATT-VSRX-1
UUID:           39ae56af-cf42-4753-960f-732fc627baa1
OS Type:        hvm
State:          running
CPU(s):         5
CPU time:       5404.8s
Max memory:     8195072 KiB
Used memory:    8195072 KiB
Persistent:     no
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0
Security 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.xml
Domain ATT-VSRX-1 defined from /etc/libvirt/qemu/vsrx3.0-zshu-i40e-1.xml

 

root@kvm-server:~# virsh dominfo ATT-VSRX-1
Id:             19
Name:           ATT-VSRX-1
UUID:           674069cb-9fdf-458d-bdd7-340b7da96af1
OS Type:        hvm
State:          running
CPU(s):         5
CPU time:       30.6s
Max memory:     8195072 KiB
Used memory:    8195072 KiB
Persistent:     yes>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>The VM config will survive the server reboot.
Autostart:      disable
Managed save:   no
Security model: apparmor
Security DOI:   0
Security label: libvirt-674069cb-9fdf-458d-bdd7-340b7da96af1 (enforcing)

3) Console to vSRX using virsh.

 

root@kvm-server:~# virsh console ATT-VSRX-1
Connected to domain ATT-VSRX-1
Escape character is ^]


FreeBSD/amd64 (Amnesiac) (ttyu0)

login: 

 

4) Pause/suspend a running vSRX

 

root@kvm-server:~# virsh suspend ATT-VSRX-1
Domain 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-1
Domain 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 committed
Power Off the system ? [yes,no] (no) yes 

 

8) Force stop (Destroy) a VM

 

root@kvm-server:~# virsh destroy ATT-VSRX-1
Domain 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>

 

 

Modification History

v1