Outils pour utilisateurs

Outils du site


blog

KVM LibVirt

Voir :

Votre CPU gère t-il VT ou AMD-V ?

egrep --color '^flags.*(vmx |svm )' /proc/cpuinfo

Ou

apt-get install cpu-checker
kvm-ok

Nested KVM ?

cat /sys/module/kvm_intel/parameters/nested
cat /sys/module/kvm_amd/parameters/nested

Parfois il faut activer l'option dans le BIOS

# virt-host-validate
...
   LXC: Checking if device /sys/fs/fuse/connections exists                   : FAIL (Load the 'fuse' module to enable /proc/ overrides)
   
echo fuse >> /etc/modules
modprobe fuse

Sous RedHat désactiver le NetworkManager

systemctl stop NetworkManager
systemctl disable NetworkManager

et ajouter la ligne suivante dans /etc/sysconfig/network-scripts/ifcfg-*

/etc/sysconfig/network-scripts/ifcfg-*

NM_CONTROLLED=no

Install

apt-get install --no-install-recommends qemu-kvm libvirt-clients libvirt-daemon-system
adduser jean libvirt
#adduser jean kvm

~/.bash_aliases

alias virsh="virsh -c qemu:///system"

ou

~/.bashrc

export LIBVIRT_DEFAULT_URI="qemu:///system"
virsh net-autostart default
virsh net-start default

/etc/default/libvirt-guests

#ON_BOOT=ignore
ON_BOOT=start
 
#START_DELAY=0
START_DELAY=30
 
#PARALLEL_SHUTDOWN=0
PARALLEL_SHUTDOWN=1
 
#SHUTDOWN_TIMEOUT=300
SHUTDOWN_TIMEOUT=180

Pour virt-sysprep (après clonage de VM)

apt-get install libguestfs-tools
UEFI
apt-get install ovmf

Virt-install

Exemple :

virt-install \
--name vm1 \
--ram 512 \
--location=http://ftp.us.debian.org/debian/dists/stable/main/installer-amd64/ \
--initrd-inject=/tmp/preseed.cfg \
--extra-args="console=ttyS0,115200n8 serial locale=fr_FR console-setup/ask_detect=false keyboard-configuration/layoutcode=fr hostname=virtual domain=unassigned-domain interface=auto" \
--vcpu=1 \
--vnc \
--vnclisten=0.0.0.0 \
--os-type=linux \
--os-variant=debianwheezy \
-w bridge=virbr0 \
-w bridge=br1 \
-w network=default \
--console pty,target_type=serial \
--disk format=qcow2,size=8,bus=virtio,path=/var/lib/libvirt/images/vm1.qcow2
#--connect qemu:///system
#--location=http://archive.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/ \
#--noautoconsole \
#--autostart \
#--cdrom=/var/lib/libvirt/images/test.iso \

--extra-args ne marche que si --location est défini.

Réseaux

PCI Passthrough - IOMMU

Voir :

BIOS/UEFI

Première étape, faire un tour dans le BIOS/UEFI pour activer les choses suivantes :

VT-D (cas d’un CPU intel)
AMD-Vi (cas d’un CPU AMD)

Pour vérifier :

# dmesg | grep -e "Directed I/O"
[    1.693161] DMAR: Intel(R) Virtualization Technology for Directed I/O

Pour du AMD :

dmesg | grep AMD-Vi

Dans le BIOS activer “SR-IOV” ?

# ls /sys/class/iommu/*/
/sys/class/iommu/dmar2/:
devices  intel-iommu  power  subsystem  uevent

/sys/class/iommu/dmar4/:
devices  intel-iommu  power  subsystem  uevent

/sys/class/iommu/dmar5/:
devices  intel-iommu  power  subsystem  uevent

/sys/class/iommu/dmar6/:
devices  intel-iommu  power  subsystem  uevent

/sys/class/iommu/dmar7/:
devices  intel-iommu  power  subsystem  uevent

/etc/modprobe.d/blacklist-nouveau.conf

blacklist nouveau
options nouveau modeset=0

/etc/default/grub

#GRUB_CMDLINE_LINUX_DEFAULT="modprobe.blacklist=nouveau modprobe.blacklist=nvidiafb"
#GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt rd.driver.pre=vfio-pci video=efifb:off vfio_iommu_type1.allow_unsafe_interrupts=1"
 
#GRUB_CMDLINE_LINUX="kvm_iommu=on iommu=pt"
GRUB_CMDLINE_LINUX="intel_iommu=on iommu=pt pci-stub.ids=10de:1b81,10de:10f1 video=efifb:off"
update-grub
echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
reboot
dmesg | grep 'remapping'

Pour nvidia

echo "options kvm ignore_msrs=1 report_ignored_msrs=0" > /etc/modprobe.d/kvm.conf
# lspci -nn | grep -i nvidia
3b:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104GL [Quadro P5000] [10de:1bb0] (rev a1)
3b:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1)
af:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104GL [Quadro P5000] [10de:1bb0] (rev a1)
af:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1)

/etc/modprobe.d/vfio.conf

#options vfio-pci ids=10de:1bb0,10de:10f0
options vfio-pci ids=10de:1bb0
options vfio-pci disable_vga=1
echo 'vfio-pci' > /etc/modules-load.d/vfio-pci.conf
update-initramfs -u
# dmesg | grep "Directed I/O"
[    1.705358] DMAR: Intel(R) Virtualization Technology for Directed I/O
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;
dmesg | grep -i vfio
# lspci -nnk | grep -i -A 2 nvidia
3b:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104GL [Quadro P5000] [10de:1bb0] (rev a1)
        Subsystem: Dell GP104GL [Quadro P5000] [1028:11b2]
        Kernel driver in use: vfio-pci
--
3b:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1)
        Subsystem: Dell GP104 High Definition Audio Controller [1028:11b2]
        Kernel driver in use: snd_hda_intel
--
af:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104GL [Quadro P5000] [10de:1bb0] (rev a1)
        Subsystem: Dell GP104GL [Quadro P5000] [1028:11b2]
        Kernel driver in use: vfio-pci
--
af:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1)
        Subsystem: Dell GP104 High Definition Audio Controller [1028:11b2]
        Kernel driver in use: snd_hda_intel
# echo "0000:3b:00.0" | tee /sys/bus/pci/drivers/vfio-pci/unbind
0000:3b:00.0
# echo "0000:3b:00.0" | tee /sys/bus/pci/drivers/vfio-pci/unbind
0000:3b:00.0
tee: /sys/bus/pci/drivers/vfio-pci/unbind: No such device
cd /sys/bus/pci/devices/0000\:3b\:00.0
echo 1 > rom
cat rom > /tmp/gpu.rom
echo 0 > rom

/etc/libvirt/qemu/vm1.xml

   <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x00' function='0x0'/>
      </source>
      <rom bar='on'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0xaf' slot='0x00' function='0x0'/>
      </source>
      <rom bar='on'/>
      <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
    </hostdev>

Autres

Boot2docker

qemu-system-x86_64 -m 1G -accel kvm -kernel b2c-kernel -initrd b2c-initrd.xz \
-append 'b2c.run="-it docker.io/alpine:3.20" b2c.keymap=fr'

Source : https://hal.science/hal-04893828v1/document

2025/03/24 15:06

Git facile

Voir a-la-decouverte-de-git

PC Dépôt

mkdir test.git
cd test.git
mkdir test.git

PC1

echo "test1" > test1.txt
echo "test1" > test.txt

PC2

echo "test2" > test2.txt
echo "test2" > test.txt

PC3

echo "test3" > test3.txt
echo "test3" > test.txt

PC1, PC2, PC3

git init
git add .
git commit -m "1ere initialisation"

PC1

git push -u git@koala:test.git master

PC2, PC3

git pull git@koala:test.git
 
# Pour chaque conflit :
modifier fichier en question
git add fichier_conflict
git commit
git push -u git@koala:test.git master

PC1, PC2, PC3

git add .
git commit
git pull git@koala:test.git
git add .
git commit
git push -u git@koala:test.git master
###########
Merge koala:test

Conflicts:
        test.txt
#
2025/03/24 15:06

Noyau Linux Debian

Méthode I

cat >> /etc/apt/sources.list <<EOF
deb http://linux-libre.fsfla.org/pub/linux-libre/freesh freesh main
EOF
# apt-get update && apt-get install linux-libre64 linux-libre64-headers
259 ko réceptionnés en 5s (49,8 ko/s)
Lecture des listes de paquets... Fait
W: Erreur de GPG : http://linux-libre.fsfla.org freesh InRelease : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY 6FCB32C947486962
$ #gpg --keyserver pgpkeys.mit.edu --recv-key 6FCB32C947486962
$ gpg --keyserver pool.sks-keyservers.net --recv-key 6FCB32C947486962
gpg: le porte-clefs « /root/.gnupg/secring.gpg » a été créé
gpg: demande de la clef 47486962 sur le serveur hkp pgpkeys.mit.edu
gpg: clef 47486962 : clef publique « Jason Self <jself@gnu.org> » importée
gpg: aucune clef de confiance ultime n'a été trouvée
gpg:       Quantité totale traitée : 1
gpg:                     importées : 1
$ gpg -a --export 6FCB32C947486962 | sudo apt-key add -
OK

Autre

Connaitre la version du noyau à partir des sources

make kernelversion
2025/03/24 15:06

tmp draft zabbix zabcon

Notes Zabcon - ne marche pas chez moi

http://trac.red-tux.net/ http://www.zabbix.com/img/zabconf2011/presentations/Andrew_Nelson_-_Zabbix_Console.pdf

apt-get install ruby-highline
 
 
gem install --user zabcon zbxapi
 
export PATH=$PATH:/home/jean/.gem/ruby/2.1.0/bin
 
https://github.com/red-tux/zabcon/blob/master/zabcon.conf.default

Erreur

zabcon.rb
x86_64-linux-gnu
Runtime error detected
(RuntimeError): Unbalanced String: help commands

Top 10 items in backtrace
1: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/libs/utility_items.rb:120:in `split2'
2: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/libs/command_tree.rb:663:in `add_command'
3: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/libs/zabcon_commands.rb:55:in `<top (required)>'
4: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
5: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
6: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/libs/zabcon_core.rb:42:in `<top (required)>'
7: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
8: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
9: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/zabcon.rb:315:in `run'
10: /home/jean/.gem/ruby/2.1.0/gems/zabcon-0.0.392/zabcon.rb:326:in `<top (required)>'
2025/03/24 15:06

Tests - Web

Voir :

Cypress

<HTML> <body> <h1>Result<h1> </body> </HTML>

cy.get('h1').contains('Result')
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki