KVM

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen

Installation

Fedora KVM

Spice

Handling

This command outputs the guest's XML configuration file to standard out (stdout). 
You can save the data by piping the output to a file. An example of piping the output to a file called guest.xml:
virsh dumpxml GuestID > guest.xml


Migration zu neuem Host

virsh migrate --live <GuestName> <DestinationURL>

Beispiel:

# virsh migrate --live galactica qemu+ssh://test2.example.com/system

Autostart

virsh autostart <domain>
virsh autostart <domain> --disable

An/Aus

Connecten auf Hypervisor

virsh -c qemu+ssh://SERVER/system

In Konsole eingeben

Zum starten:

start VM

Zum virtuellen Stecker rausziehn:

destroy VM

Nach Installation von acpid auf VM

Normales herunterfahren:

shutdown VM

Configure a Serial Console in the Guest

Enable on the VM

cat /etc/init/ttyS0.conf
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345] 

respawn
exec /sbin/getty -L 115200 ttyS0 xterm

Run the following command to initiate the Serial Console (or restart the VM):

sudo start ttyS0

Connect on Host to VM

console VM

00:50:56:00:31:f9

Virtuelle MACAdresse vergeben

gaius=KVM server

virsh console XXXXXXX
VM:     cp /etc/udev/rules./70-persistent.net(cd).rules 70-persistent.net(cd).rules.orig
VM:     herunterfahren...
gaius:  vi /etc/libvirt/qemu/XXXXXX.xml

-> MAC eintragen

gaius:     virsh define XXXXXXXX
gaius:     virsh start XXXXXXXX

-> TESTEN

Images umwandeln


img zu qcow2

qemu-img convert -f raw -O qcow2 input.img output.qcow2

qcow2 zu raw

qemu-img convert -f qcow2 -O raw input.img output.raw

raw zu vmdk

qemu-img convert -f raw -O vmdk input.img output.raw

qcow2 zu vmdk

qemu-img convert -f qcow2 -O vmdk input.img output.raw

4 unterstützten VirtBox-Typen:

- .vdi [ VirtualBox Disk Image ]

- .vmdk [ Virtual Machine Disk ]

- .vhd [ Virtual Hard Disk ]

- .hhd [ Parallels Hard Disk ]


das ist falsch .... wer hat es geschrieben?

umwandeln VirtB. zu KVM

qemu-img convert "source".vmdk -O qcow2 "target".qemu
qemu-img convert "source".hhd -O qcow2 "target".qemu
qemu-img convert "source".vhd -O qcow2 "target".qemu
qemu-img convert "source".vdi -O qcow2 "target".qemu

RAW (for VirtualBox)

qemu-img convert "source".vmdk -O raw "target".img

umwandeln VirtB. zu VirtB. (vdi-vmdk)

VBoxManage clonehd "source".vdi "target".vmdk --format VMDK

LVM in VMDK umwandeln

lvcreate -L592M -s -n myvolume /dev/myvg/myvolume_snapshot
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk


RAW Image mounten

Ein Raw Image ist ein einfaches Abbild einer Festplatte. Daher lässt es sich auch relativ leicht und ohne größere Umwege einhängen.

losetup /dev/loop0 foo.img
kpartx -av /dev/loop0
mount /dev/mapper/loop0p1 /mnt
[arbeiten durchführen...]
unmount /mnt
kpartx -dv /dev/loop0
losetup -d /dev/loop0

QCOW2 Image mounten

Ein dynamisches QCOW2 Image kann im System nicht mehr einfach so gemounted werden. Dafür kann man einen Umweg über NBD (Network Block Device) nehmen. Damit wird das gewünschte Image als Network Block Device gestartet und eingehängt.

modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 disk.img
mount /dev/nbd0p1 /mnt

disconnecten

qemu-nbd --d /dev/nbd0

Snapshot

Weitere Infos

Links


snapshot

http://kashyapc.wordpress.com/2013/01/22/live-backup-with-external-disk-snapshots-and-libvirts-blockpull/ Huang Wenlong 2011-09-26 03:14:09 EDT

Verify it with libvirt-0.9.4-13.el6.x86_64


1. define a persistent domain named "snap"with qcow2 disks 2. create a snapshot for domain snap

  1. virsh snapshot-create snap

3. virsh # snapshot-list snap

Name                 Creation Time             State

1317020538           2011-09-26 15:02:18 +0800 shutoff

4.virsh # undefine snap error: Failed to undefine domain snap error: Requested operation is not valid: cannot delete inactive domain with 1 snapshots

5. virsh undefine --snapshots-metadata snap Domain snap has been undefined

4. check snapshot metadata (no metadata)

  1. ls /var/lib/libvirt/qemu/snapshot/snap

5. define a new domain with the same name, but different UUID 6. check snapshot for domain test:

  1. virsh snapshot-list snap
Name                 Creation Time             State

https://bugzilla.redhat.com/show_bug.cgi?id=735457

Links

qemu-monitor

http://blog.vmsplice.net/2011/03/how-to-access-qemu-monitor-through.html

Links