暫無描述

Celestino Rey da55b7cc4e Primer commit 7 月之前
Complete Guide to KVM Virtualization.md da55b7cc4e Primer commit 7 月之前
README.md da55b7cc4e Primer commit 7 月之前
antix.xml da55b7cc4e Primer commit 7 月之前
instala.sh da55b7cc4e Primer commit 7 月之前
instalaGrafico.sh da55b7cc4e Primer commit 7 月之前
instalaWorker1.sh da55b7cc4e Primer commit 7 月之前
kubeconfig-principal da55b7cc4e Primer commit 7 月之前
kvm-hostbridge.xml da55b7cc4e Primer commit 7 月之前
principal.xml da55b7cc4e Primer commit 7 月之前
ubuntu44.config da55b7cc4e Primer commit 7 月之前
worker1.xml da55b7cc4e Primer commit 7 月之前
worker2.xml da55b7cc4e Primer commit 7 月之前

README.md

Notas sobre la creación de VM

Comando general para lanzar la VM

Lo encontré en (este enlace)[https://wiki.debian.org/KVM#Introduction]

Corregir error de desconexión de monitor

Para que no de error de que se desconecta del monitor, hay que modificar el fichero

/etc/libvirt/qemu.conf

y añadir las siguientes líneas (yo las puse al final del fichero)

user = "root"
group = "root"

Especificar initrd y kernel

| Distro |Kernel path|RAM disk path| |Fedora|/isolinux/vmlinuz|/isolinux/initrd.img| |RHEL5/CentOS5|/isolinux/vmlinuz|/isolinux/initrd.img| |openSUSE|/boot/i386/loader/linux|/boot/i386/loader/initrd| |Mandriva|/i586/isolinux/alt0/vmlinuz|/i586/isolinux/alt0/all.rdz| |Ubuntu|/casper/vmlinuz|/casper/initrd.gz or /casper/initrd| |Debian|/install.386/vmlinuz/|/isolinux/initrd.img|

Relocate an existing libvirtd (KVM) images directory

By default, KVM (libvirtd) images on Ubuntu and most other Linux distributions are found in /var/lib/libvirt/images. This can be inconvenient if you don't have a separate /var partition that can grow over time to accommodate multiple large images.

You can simply rename the images folder to something else and then symlink to a larger space with it (e.g. ln -s /data1/libvirt/images /var/lib/libvirt/images). That's what I used to do.

But that can lead to all sorts of unanticipated trouble. The right way to have your images on a bigger disk is to change the path for libvirt's default storage pool to a partition on that big disk, which is logically where KVM is going to create them.

NOTE: The Ubuntu package for libvirt-daemon-system automatically sets up a libvirt group for libvirt admins (that includes members of the sudo group by default). Members of libvirt can run virsh commands without sudo. YMMV if not a member of the sudo group, or not on Ubuntu.

First check to make sure a default pool exists:

$ virsh pool-list --all
 Name      State    Autostart
-------------------------------
 default   active   yes

NOTE: If no default pool exists, follow the instructions in this gist to create one on your preferred storage volume.

Assuming a default pool exists, find the current default pool's path:

$ virsh pool-dumpxml default
<pool type='dir'>
  <name>default</name>
  <uuid>91c6d1b3-4e42-4a1f-989e-89b2127da056</uuid>
  <capacity unit='bytes'>133070688256</capacity>
  <allocation unit='bytes'>25177309184</allocation>
  <available unit='bytes'>107893379072</available>
  <source>
  </source>
  <target>
    <path>/var/lib/libvirt/images</path>
    <permissions>
      <mode>0711</mode>
      <owner>64055</owner>
      <group>108</group>
    </permissions>
  </target>
</pool>

Before going further it is best to shut down ("destroy") all existing virtual machines).

Now use virsh edit to change the disk path in each virtual machines's configuration to the default pool's new location. Assuming this will be "/data1/libvirt/images", you would proceed like this:

$ virsh edit example
...
<disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
-   <source file='/var/lib/libvirt/images/example.qcow2'/>
+   <source file='/data1/libvirt/images/example.qcow2'/>

(the line will then read <source file='/data1/libvirt/images/example.qcow2'

Next, the default pool should be completely shut down:

$ virsh pool-destroy default

Then, undefined:

$ virsh pool-undefine default

NOTE: By default, virt-manager creates additional pools automatically for things like iso files. These should also be destroyed and undefined before proceeding, to free things up for redefining the default pool (if you don't, the system will spit out "error: operation failed: Storage source conflict with pool" messages when you try redefining).

Now, recreate the default pool anew and start:

$ virsh pool-define-as default dir --target "/data1/libvirt/images"
$ virsh pool-build default
$ virsh pool-start default
$ virsh pool-autostart default

Check the status with virsh-info:

$ virsh pool-info default

And then the configuration with pool-dumpxml:

$ virsh pool-dumpxml default

Finally, move any existing disk images from /var/lib/libvirt/images to the new location (e.g. /data1/libvirt/images).

Cambiar el interfaz de red de una VM

To change a VM's network with virsh, you can either edit the VM's XML configuration using virsh edit and then restart the VM, or use virsh net-edit to modify the network itself and then restart the network. The most common method is to shut down the VM, edit its XML definition, and then start it again. For network-wide changes, you can edit the network's XML definition and then restart the network to apply the changes.

Method 1: Editing the VM's network configuration

This method is for when you want to change the network attached to a specific VM.

  1. Shut down the VM: virsh shutdown
  2. Edit the VM's XML: virsh edit
  3. This will open the VM's XML file in a text editor. Find the section for the network you want to change.

    <interface type='network'>
      <mac address='52:54:00:7a:a0:cd'/>
    

    1. Save and close the editor.

    Apply the changes:

    virsh start <vm_name>
    

    The VM will start with the new network configuration.

    Renombrar máquina

    virsh dumpxml myvm > foo.xml
    <edit foo.xml, change the name, move storage>
    virsh undefine myvm
    virsh define foo.xml