notebook/IT/Virsh.md

48 lines
1.6 KiB
Markdown
Raw Normal View History

2021-04-20 18:56:58 +00:00
# Virsh
2020-11-26 17:38:25 +00:00
## virsh usefull command
2021-04-20 18:56:58 +00:00
2020-11-26 17:38:25 +00:00
### standart
- recover configuration xml from VM: `virsh dumpxml windows7> windows7.xml`
- start VM: `virsh start nas`
- shutdown VM: `virsh shutdown win7`
- rename VM: `virsh domrename --domain generic2 --new-name windows7`
- list all vm: `virsh list --all`
- create with xml file:`create --file debian8.xml`
- force shutdown:`virsh destroy win7`
2021-04-20 18:56:58 +00:00
### snapshot
2020-11-26 17:38:25 +00:00
- list for domain `virsh snapshot-list --domain nas`
2021-04-20 18:56:58 +00:00
- create snapshot `virsh snapshot-create-as --domain {VM-NAME} --name {SNAPSHOT-NAME} --live`
2020-11-26 17:38:25 +00:00
- info snapshot: ` virsh snapshot-info --domain nas --snapshotname "ansible ping OK" `
- appliquer une snapshot: `virsh snapshot-revert --domain --snapshotname "ansible ping OK" --running`
- delete snapshot: `virsh snapshot-delete --domain freebsd --snapshotname 5Sep2016_S2`
2021-02-26 18:05:54 +00:00
## share folder with host
- add a filesystem device to your host:
2021-04-20 18:56:58 +00:00
```xml
2021-02-26 18:05:54 +00:00
<filesystem type='mount' accessmode='squash'>
<source dir='/home/vincent/Documents'/>
<target dir='/mnt/workplace'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</filesystem>
```
2021-04-20 18:56:58 +00:00
2021-02-26 18:05:54 +00:00
- on guest mount the filesystem:
2021-04-20 18:56:58 +00:00
- with mount cmd :`mount -t 9p -o trans=virtio,version=9p2000.L mount_tag /path/to/mount_point/on/guest`
- in your fstab:`mount_tag/path/to/mount_point/on/guest 9p trans=virtio,version=9p2000.L 0 0`
2021-02-26 18:05:54 +00:00
- add in **9pnet_virtio** to **/etc/modules-load.d/9pnet_virtio.conf**
2020-11-26 17:38:25 +00:00
## enabling guest function on arch
- install `spice-vdagent`
- add in etc/mkinitcpio.conf
2021-04-20 18:56:58 +00:00
```ini
2020-11-26 17:38:25 +00:00
MODULES=(virtio virtio_blk virtio_pci virtio_net)
2021-02-26 18:05:54 +00:00
```