background preloader

Sysadmin

Facebook Twitter

What is the IP address of my guest? When using libvirt to create virtual machines, I find that networking works pretty well right out of the box.

What is the IP address of my guest?

My VMs are connected to one another via a virtual subnet and have outbound access to the internet. But there is one itch that needs scratching. When I am ready to SSH into a VM, what hostname/IP address should I use? That answer is attained only after connecting to the VM with VNC, logging in, and looking at ‘ifconfig’ output. Sure, you could configure your VMs with static IPs, but that’s not a very elegant solution either.

The ideal solution to this problem is to be able to do: ssh <vm name> and have it “just work”. Libvirt Virtual Networks Libvirt provides many useful networking functions to domains through the concept of a virtual network. Create your own libvirt network The first step is to define a new virtual network. Let’s begin: On line 2, we define the name of the network. Immediately following that, are explicit per-host address assignments. Wiki: Networking. This page provides an introduction to the common networking configurations used by libvirt based applications.

Wiki: Networking

This information applies to all hypervisors, whether Xen, KVM or another. For additional information consult the libvirt network architecture docs. The two common setups are "virtual network" or "shared physical device". The former is identical across all distributions and available out-of-the-box. The latter needs distribution specific manual configuration. NAT forwarding (aka "virtual networks") Host configuration Every standard libvirt installation provides NAT based connectivity to virtual machines out of the box.

. # virsh net-list --all Name State Autostart ----------------------------------------- default active yes If it is missing, then the example XML config can be reloaded & activated When the libvirt default network is running, you will see an isolated bridge device. . # brctl show bridge name bridge id STP enabled interfaces virbr0 8000.000000000000 yes Guest configuration. Vm-builder - build ubuntu based virtual machines. KVM/QEMU hypervisor driver. The libvirt KVM/QEMU driver can manage any QEMU emulator from version 0.8.1 or later.

KVM/QEMU hypervisor driver

It can also manage Xenner, which provides the same QEMU command line syntax and monitor interaction. Project Links The KVM Linux hypervisor The QEMU emulator Deployment pre-requisites QEMU emulators : The driver will probe /usr/bin for the presence of qemu , qemu-system-x86_64 , qemu-system-microblaze , qemu-system-microblazeel , qemu-system-mips , qemu-system-mipsel , qemu-system-sparc , qemu-system-ppc . Connections to QEMU driver The libvirt QEMU driver is a multi-instance driver, providing a single system wide privileged driver (the "system" instance), and per-user unprivileged drivers (the "session" instance). KVM/Virsh. You can create, delete, run, stop, and manage your virtual machines from the command line, using a tool called virsh .

KVM/Virsh

Virsh is particularly useful for advanced Linux administrators, interested in script or automating some aspects of managing their virtual machines Installing Install virsh : sudo apt-get install virsh Connecting Connect to your hypervisor. . $ virsh connect Connecting to uri: Listing VMs $ virsh list Id Name State ---------------------------------- 1 foo running Creating a Virtual Machine Virtual Machines managed by virsh are created by describing the virtual machine in a libvirt XML file, and importing that XML file into virsh . LVM HOWTO. Lvm. LVM (Logical Volume Manager, ou gestionnaire de volumes logiques en français) permet la création et la gestion de volumes logiques sous Linux.

lvm

L'utilisation de volumes logiques remplace en quelque sorte le partitionnement des disques. C'est un système beaucoup plus souple, qui permet par exemple de diminuer la taille d'un système de fichier pour pouvoir en agrandir un autre, sans se préoccuper de leur emplacement sur le disque. Avantages de LVM Il n'y a pas de limitations « étranges » comme avec les partitions (primaire, étendue, etc.). On ne se préoccupe plus de l'emplacement exact des données. Inconvénients de LVM Si un des volumes physiques devient HS, alors c'est l'ensemble des volumes logiques qui utilisent ce volume physique qui sont perdus.

Un disque ou une partition libre. Installez le paquet lvm2. Volume physique Un volume physique ou « PV » pour « physical volume » est tout simplement un disque ou une partition.