Virsh este capabil sa gestioneze si containere LXC. Deosebirea este ca nu tine seama de fisierul de configurare creat de lxc-create, ci foloseste propriul fisier de configurare, in format XML.
Creati un nou container, de tip debian
, cu numele ct3
. Nu porniti containerul.
Creati un fisier XML ce va fi folosit in Virsh, dupa modelul de mai jos:
<domain type='lxc'> <name>NUME_CONTAINER</name> <memory>500000</memory> <os> <type>exe</type> <init>/sbin/init</init> </os> <vcpu>1</vcpu> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <interface type='network'> <source network='default'/> </interface> <console type='pty' /> <filesystem type='mount'> <source dir='CALE_CATRE_ROOTFS'/> <target dir='/'/> </filesystem> </devices> </domain>
Porniti virsh, conectandu-va la URI-ul corespunzator LXC:
root@saisp-vm-1:~# virsh -c lxc:/// Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh #
In Virsh, efectuati urmatoarele operatii:
virsh # define ct3.xml
Domain ct3 defined from ct3.xml
net-start default
virsh # start ct3
Domain ct3 started
virsh # console ct3 Connected to domain ct3 Escape character is ^]
Ctrl+]
virsh # dominfo ct3 Id: 2603 Name: ct3 UUID: 27f50e10-99dc-44ce-827d-ed8888115eb4 OS Type: exe State: running CPU(s): 1 CPU time: 0.5s Max memory: 500000 KiB Used memory: 12564 KiB Persistent: yes Autostart: disable Managed save: unknown Security model: none Security DOI: 0
virsh # shutdown ct3 virsh # undefine ct3