Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previaPróxima revisiónAmbos lados, revisión siguiente |
es:howtos:general_admin:kvm_libvirt [2019/02/09 00:23 (UTC)] – [Creation and maintenance] slackwarespanol | es:howtos:general_admin:kvm_libvirt [2019/02/09 00:52 (UTC)] – [Resources] slackwarespanol |
---|
Ingrese el nombre del nuevo grupo. El tipo predeterminado es // dir //, que es el tipo correcto. Presione <key> Forward </key> e ingrese el directorio del sistema en el campo de entrada // Target Path //. Presione <key> Finalizar </key> para crear el grupo. | Ingrese el nombre del nuevo grupo. El tipo predeterminado es // dir //, que es el tipo correcto. Presione <key> Forward </key> e ingrese el directorio del sistema en el campo de entrada // Target Path //. Presione <key> Finalizar </key> para crear el grupo. |
| |
===== Creating a new virtual machine ===== | |
| |
==== Creando una nueva máquina virtual usando virt-manager ==== | ==== Creando una nueva máquina virtual usando virt-manager ==== |
- Enrutado: el conmutador virtual está conectado a la LAN del host sin NAT. | - Enrutado: el conmutador virtual está conectado a la LAN del host sin NAT. |
- Aislado: el conmutador virtual no está conectado al host. Las máquinas virtuales pueden verse entre sí y al host, pero el tráfico de la red no pasa fuera del host. | - Aislado: el conmutador virtual no está conectado al host. Las máquinas virtuales pueden verse entre sí y al host, pero el tráfico de la red no pasa fuera del host. |
==== Dnsmasq y iptables ==== | === Dnsmasq y iptables === |
DHCP y DNS en las redes virtuales son manejados por Dnsmasq. Para cada red virtual que se inicia, libvirt inicia una instancia separada de Dnsmasq. | DHCP y DNS en las redes virtuales son manejados por Dnsmasq. Para cada red virtual que se inicia, libvirt inicia una instancia separada de Dnsmasq. |
| |
Al iniciar una red virtual, libvirt también agregará reglas de iptables para manejar el enrutamiento y NAT entre el host y la red virtual. También habilitará ip_forward. | Al iniciar una red virtual, libvirt también agregará reglas de iptables para manejar el enrutamiento y NAT entre el host y la red virtual. También habilitará ip_forward. |
==== Red por defecto ==== | === Red por defecto === |
Después de la instalación, una red (apropiadamente llamada // por defecto //) ya está creada. Se configura como tipo NAT y esta es la red predeterminada que está vinculada a nuevas máquinas virtuales. La red está configurada para iniciarse automáticamente cuando se inicia libvirt, por lo que está disponible inmediatamente cuando se ejecuta libvirt. | Después de la instalación, una red (apropiadamente llamada // por defecto //) ya está creada. Se configura como tipo NAT y esta es la red predeterminada que está vinculada a nuevas máquinas virtuales. La red está configurada para iniciarse automáticamente cuando se inicia libvirt, por lo que está disponible inmediatamente cuando se ejecuta libvirt. |
| |
<note warning>No agregue interfaces físicas a este bridge. Es manejado por libvirt.</note> | <note warning>No agregue interfaces físicas a este bridge. Es manejado por libvirt.</note> |
| |
==== Creación y mantenimiento ==== | === Creación y mantenimiento === |
Las redes virtuales están visibles en la pestaña // Redes virtuales // de la ventana // Detalles de conexión del host // en Virtual Machine Manager. La tecla <key> + </key> se puede usar para agregar una nueva red virtual. Ingrese el nombre, la dirección de red IPv4, el rango DHCP y el tipo de red. | Las redes virtuales están visibles en la pestaña // Redes virtuales // de la ventana // Detalles de conexión del host // en Virtual Machine Manager. La tecla <key> + </key> se puede usar para agregar una nueva red virtual. Ingrese el nombre, la dirección de red IPv4, el rango DHCP y el tipo de red. |
| |
Una vez que se crea la red virtual, se puede utilizar en las pantallas de mantenimiento de la máquina virtual. | Una vez que se crea la red virtual, se puede utilizar en las pantallas de mantenimiento de la máquina virtual. |
| |
===== Shared folders using VirtFS ===== | === Carpetas compartidas usando VirtFS === |
It is possible to share folders between the guest and host system using VirtFS (Plan 9 folder sharing over Virtio). This is available from kernel version 2.6.36 onwards. VirtFS is a passthrough filesystem, which means that a directory on the host can be directly accessed from the guest through the virtualization layer. | Es posible compartir carpetas entre el sistema huésped y el host mediante VirtFS (carpeta de Plan 9 compartidas sobre Virtio). Esto está disponible desde la versión 2.6.36 del kernel en adelante. VirtFS es un sistema de archivos de acceso directo, lo que significa que se puede acceder directamente a un directorio en el host desde el invitado a través de la capa de virtualización. |
| === Preparar kernel host === |
==== Prepare host kernel ==== | Asegúrese de que las siguientes opciones estén configuradas en el núcleo del host: |
Make sure the following options are set in the host kernel: | |
<code> | <code> |
CONFIG_NET_9P=y | CONFIG_NET_9P=y |
CONFIG_9P_FS_POSIX_ACL=y | CONFIG_9P_FS_POSIX_ACL=y |
</code> | </code> |
On the guest system, modules ''9p'', ''9pnet'' and ''9pnet_virtio'' are needed. These should be available in the standard Slackware kernel. | En el sistema invitado, se necesitan los módulos '' 9p '', '' 9pnet '' y '' 9pnet_virtio ''. Estos deberían estar disponibles en el kernel estándar de Slackware. |
| |
==== Guest configuration ==== | === Configuración de invitado === |
In virt-manager, edit the guest virtual machine and add new hardware. Select //Filesystem// and fill the required fields as shown below. | En virt-manager, edite la máquina virtual invitada y agregue nuevo hardware. Seleccione // Sistema de archivos // y complete los campos requeridos como se muestra a continuación. |
| |
{{:howtos:general_admin:virt-manager-fspassthr.png?200|}} | {{:howtos:general_admin:virt-manager-fspassthr.png?200|}} |
| * Modo. Selecciona uno de los siguientes: |
| * Passthrough: se accede al recurso compartido de host con los permisos del usuario invitado. |
| * Asignado: se accede al recurso compartido de host con los permisos del hipervisor (proceso QEMU). |
| * Squash: similar a // passthrough // excepto que se ignoran las fallas de operaciones privilegiadas como // chown //. Esto hace que se pueda utilizar un modo similar al paso a través de personas que ejecutan el hipervisor como no root. |
| * Controlador: use // Ruta //. |
| * Política de escritura (solo disponible para el controlador '' ruta ''): use // Predeterminado //. |
| * Ruta de origen = directorio en el host que se comparte. |
| * Ruta de destino = etiqueta de montaje que está disponible en el sistema huésped. Esto no tiene que ser una ruta existente. |
| La opción // Exportar sistema de archivos como montaje de solo lectura // hace lo que sugiere. |
| |
* Mode. Select one of the following: | === Mounting the share === |
* Passthrough: the host share is accessed with the permissions of the guest user. | Para montar el sistema de archivos con la etiqueta '' hostshare '' en el invitado en '' / mnt / share '', inicie sesión en el invitado y use: |
* Mapped: the host share is accessed with the permissions of the hypervisor (QEMU process). | |
* Squash: Similar to //passthrough// except that failure of privileged operations like //chown// are ignored. This makes a passthrough-like mode usable for people who run the hypervisor as non-root. | |
* Driver: use //Path//. | |
* Write Policy (only available for ''path'' driver): use //Default//. | |
* Source path = directory on the host which is shared. | |
* Target path = mount tag that is made available on the guest system. This doesn't have to be an existing path. | |
Option //Export filesystem as readonly mount// does what it suggests. | |
| |
==== Mounting the share ==== | |
To mount the filesystem with tag ''hostshare'' on the guest at ''/mnt/share'', logon to the guest and use: | |
<code> | <code> |
# mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/share | # mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/share |
</code> | </code> |
Now the /mnt/share folder is available and changes are visible on the host and the guest. When permission errors occur, try sharing the host directory with a different mode. | Ahora la carpeta /mnt/share está disponible y los cambios son visibles en el host y el invitado. Cuando se produzcan errores de permiso, intente compartir el directorio del host con un modo diferente. |
===== Remote access ===== | ==== Acceso remoto ==== |
| |
<note>Work in progress</note> | <note>Nota del Autor. Trabajo en progreso</note> |
| |
===== Advanced topics ===== | ===== Temas avanzados ===== |
| |
==== Mount qcow image using nbd ==== | ==== Monte la imagen qcow usando nbd ==== |
Raw disk images can be mounted outside the virtual machine using a loopback device. To mount other image types like qcow, the ''qemu-nbd'' command can be used, which comes with qemu-kvm. It relies on the nbd (network block device) kernel module. | Las imágenes de disco sin procesar se pueden montar fuera de la máquina virtual mediante un dispositivo de bucle invertido. Para montar otros tipos de imágenes como qcow, se puede usar el comando '' qemu-nbd '', que viene con qemu-kvm. Se basa en el módulo del núcleo nbd (dispositivo de bloqueo de red). |
| |
Start by loading the kernel module. The only parameter is the maximum partitions to be accessed. If this parameter is omitted, the default value is 0, which means no partitions will be mapped. | Comience cargando el módulo del kernel. El único parámetro es el número máximo de particiones a las que se puede acceder. Si se omite este parámetro, el valor predeterminado es 0, lo que significa que no se asignarán particiones. |
<code> | <code> |
# modprobe nbd max_part=8 | # modprobe nbd max_part=8 |
</code> | </code> |
This will create various new devices ''/dev/nbdxx''. Now the disk image can be connected to one of them: | Esto creará varios dispositivos nuevos '' /dev/nbdxx ''. Ahora la imagen del disco se puede conectar a uno de ellos: |
<code> | <code> |
# qemu-nbd -c /dev/ndb0 slackware.img | # qemu-nbd -c /dev/ndb0 slackware.img |
</code> | </code> |
This will create additional devices ''/dev/nbd0pxx'' for the partitions on the disk. Partitions are numbered sequentially starting with 1. You can use the nbd0 device to access the whole disk, or the nbd0pxx devices to access the partitions: | Esto creará dispositivos adicionales '' /dev/nbd0pxx '' para las particiones en el disco. Las particiones se numeran secuencialmente comenzando con 1. Puede usar el dispositivo nbd0 para acceder a todo el disco, o los dispositivos nbd0pxx para acceder a las particiones: |
<code> | <code> |
# fdisk /dev/nbd0 | # fdisk /dev/nbd0 |
# mount /dev/nbd0p1 /mnt/hd | # mount /dev/nbd0p1 /mnt/hd |
</code> | </code> |
<note important>Make sure the virtual machine is not running when you mount the disk image. Mounting the disk of a running machine will damage it.</note> | <note important>Asegúrese de que la máquina virtual no se esté ejecutando cuando monte la imagen de disco. Montar el disco de una máquina en marcha lo dañará.</note> |
To remove the connection: | Para eliminar la conexión: |
<code> | <code> |
# qemu-nbd -d /dev/nbd0 | # qemu-nbd -d /dev/nbd0 |
</code> | </code> |
| |
==== Setup PXE boot in libvirt ==== | ==== Configurar el arranque PXE en libvirt ==== |
To enable PXE booting for the guest machines, a PXE boot server and a TFTP server are needed. Libvirt can be configured to handle both internally. These configuration options are not available in virt-manager, so virsh must be used to set this up. | Para habilitar el arranque PXE para las máquinas invitadas, se necesitan un servidor de arranque PXE y un servidor TFTP. Libvirt se puede configurar para manejar tanto internamente. Estas opciones de configuración no están disponibles en virt-manager, por lo que se debe usar virsh para configurar esto. |
| |
- Create a directory ''/tftpboot'' and fill with the required files for the tftp boot service. See the article [[http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:pxe|PXE: Installing Slackware over the network]] by AlienBOB for more details. | - Cree un directorio '' /tftpboot '' y rellénelo con los archivos necesarios para el servicio de arranque tftp. Consulte el artículo [[http://alien.slackbook.org/dokuwiki/doku.php?id=slackware:pxe|PXE: Instalación de Slackware en la red]] por AlienBOB para obtener más detalles. |
- Stop the default network and edit the network definition: <code> | - Detenga la red predeterminada y edite la definición de red: <code> |
# virsh net-destroy default | # virsh net-destroy default |
# virsh net-edit default | # virsh net-edit default |
</code> | </code> |
- This will open the network configuration in a vi session. Add the //tftp// and //bootp// parameters in the //ip// section and save the file: <code> | - Esto abrirá la configuración de red en una sesión vi. Agregue los parámetros // tftp // y // bootp // en la sección // ip // y guarde el archivo: <code> |
<ip address='192.168.122.1' netmask='255.255.255.0'> | <ip address='192.168.122.1' netmask='255.255.255.0'> |
<tftp root='/tftpboot' /> | <tftp root='/tftpboot' /> |
</ip> | </ip> |
</code> | </code> |
- Now restart the network: <code> | - Ahora reinicie la red: <code> |
# virsh net-start default | # virsh net-start default |
</code> | </code> |
| Ahora el servidor DHCP libvirt permitirá a los invitados arrancar con PXE. |
Now the libvirt DHCP server will allow guests to PXE boot. | |
===== Troubleshooting ===== | ===== Troubleshooting ===== |
| |
==== Remove password prompt in virt-manager ==== | ==== Eliminar solicitud de contraseña en virt-manager ==== |
When you start virt-manager as a regular user, you may still be asked for the root password, even when you have setup the correct unix socket permissions (notification: "system policy prevents management of local virtualized systems"). This is because older versions of libvirt were using PolicyKit by default. Disable the use of PolicyKit by editing ''/etc/libvirt/libvirtd.conf''. Uncomment the following options and change them to ''none'' : | Cuando inicie virt-manager como un usuario regular, es posible que se le solicite la contraseña de root, incluso cuando haya configurado los permisos de socket de Unix correctos (notificación: "la política del sistema impide la administración de sistemas virtualizados locales"). Esto se debe a que las versiones anteriores de libvirt usaban PolicyKit de forma predeterminada. Desactive el uso de PolicyKit editando '' /etc/libvirt/libvirtd.conf ''. Descomente las siguientes opciones y cámbielas a '' ninguna '': |
<code> | <code> |
auth_unix_ro = "none" | auth_unix_ro = "none" |
auth_unix_rw = "none" | auth_unix_rw = "none" |
</code> | </code> |
==== Improve mouse movement ==== | ==== Mejorar el movimiento del ratón ==== |
In graphics mode, the mouse movement can be erratic and difficult to change in the settings of your VM. To solve this, add a virtual tablet. | En el modo gráfico, el movimiento del mouse puede ser errático y difícil de cambiar en la configuración de su VM. Para resolver esto, agregue una tableta virtual. |
| |
In //virt-manager//, open the VM by double-clicking on the machine and select the hardware info screen (the blue <key>''i''</key> button). Now, press <key>+ Add Hardware</key> and select //Input//. Select Type //EvTouch USB Graphics Tablet// and press <key>Finish</key>. The next time the VM is started, the mouse movement is synchronized with your desktop cursor. | |
| |
==== Change screen resolution to higher than 1024x768 ==== | En // virt-manager //, abra la máquina virtual haciendo doble clic en la máquina y seleccione la pantalla de información del hardware (el botón azul <key> '' i '' </key>). Ahora, presione <key> + Add Hardware </key> y seleccione // Input //. Seleccione Type // EvTouch USB Graphics Tablet // y presione <key> Finish </key>. La próxima vez que se inicie la máquina virtual, el movimiento del mouse se sincronizará con el cursor del escritorio. |
The default emulated video card is of type Cirrus. This has a maximum resolution of 1024x768. The //vga// type can achieve a higher resolution, but for that to work, the X configuration in the guest OS needs to be changed as well. | ==== Cambiar la resolución de la pantalla a más de 1024x768 ==== |
| La tarjeta de video emulada predeterminada es de tipo Cirrus. Esto tiene una resolución máxima de 1024x768. El tipo // vga // puede lograr una resolución más alta, pero para que funcione, la configuración de X en el sistema operativo invitado también debe cambiarse. |
| |
To change this, open the VM and select the hardware info screen. Select the Video card and change the type to //vga//. | Para cambiar esto, abra la máquina virtual y seleccione la pantalla de información de hardware. Seleccione la tarjeta de video y cambie el tipo a // vga //. |
| |
Start the VM. If a file ''/etc/X11/xorg.conf'' exists, change that. Otherwise create a new text file in ''/etc/X11/xorg.conf.d'' with extension ''conf'', for example ''/etc/X11/xorg.conf.d/monitor.conf''. | Iniciar la máquina virtual. Si existe un archivo '' /etc/X11/xorg.conf '', cámbielo. De lo contrario, cree un nuevo archivo de texto en '' /etc/X11/xorg.conf.d '' con la extensión '' conf '', por ejemplo '' /etc/X11/xorg.conf.d/monitor.conf ''. |
| |
Add or change the following sections: | Agrega o cambia las siguientes secciones: |
<code> | <code> |
Section "Monitor" | Section "Monitor" |
EndSection | EndSection |
</code> | </code> |
You can change the screen resolution (the //Modes// line) depending on your needs. | Puede cambiar la resolución de la pantalla (la línea // Modes //) según sus necesidades. |
| |
===== Resources ===== | ===== Recursos ===== |
| |
* Official pages for [[http://libvirt.org|libvirt]], [[http://virt-manager.org|virt-manager]], [[http://wiki.qemu.org/Index.html|QEMU]], [[http://www.linux-kvm.org/page/Main_Page|KVM]]. | * Páginas oficiales de[[http://libvirt.org|libvirt]], [[http://virt-manager.org|virt-manager]], [[http://wiki.qemu.org/Index.html|QEMU]], [[http://www.linux-kvm.org/page/Main_Page|KVM]]. |
* Red Hat [[https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html|Virtualization Administration Guide]]. | * Red Hat [[https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html|Guía de administración de virtualización]]. |
| |
===== Sources ===== | ===== Sources ===== |