• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this document? Why not share!

Alterar memória kvm virtual machine

on

  • 772 views

 

Statistics

Views

Total Views
772
Views on SlideShare
772
Embed Views
0

Actions

Likes
0
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Alterar memória kvm virtual machine Alterar memória kvm virtual machine Document Transcript

    • Sem títuloManage your virtual machinesFrom the shellYou can manage your VMs from the shell using virsh. You can get a list of theavailable commands if you type "help". Type "help command" to get additionalinfos for a particular command.Define your new VMBefore you can manage your new VM with virsh, you must define it:$ virsh --connect qemu:///systemConnecting to uri: qemu:///systemWelcome to virsh, the virtualization interactive terminal.Type: help for help with commands quit to quitvirsh # define /etc/libvirt/qemu/newvm.xmlDomain newvm defined from /etc/libvirt/qemu/newvm.xmlNote that to list newvm, you must use list --inactive or list --all, sincelist without any options will only list currently running machines.List your VMsVirsh allows you to list the virtual machines available on the current host:yhamon@paris:/etc/libvirt/qemu$ virsh --connect qemu:///systemConnecting to uri: qemu:///systemWelcome to virsh, the virtualization interactive terminal.Type: help for help with commands quit to quitvirsh # help list NAME list - list domains SYNOPSIS list [--inactive | --all] DESCRIPTION Returns list of domains. OPTIONS --inactive list inactive domains --all list inactive & active domainsvirsh # list Id Name State---------------------------------- 15 mirror running 16 vm2 runningvirsh # list --all Id Name State---------------------------------- 15 mirror running 16 vm2 running - test5 shut offDefine, undefine, start, shutdown, destroy VMsThe VMs you see with list --all are VMs that have been "defined" from an XMLfile. Every VM is configured via a XML file in /etc/libvirt/qemu. If you want to Página 1
    • Sem títuloremove a VM from the list of VMs, you need to undefine it:virsh # undefine test5 # WARNING: undefine will delete your XML file!Domain test5 has been undefinedvirsh # list --all Id Name State---------------------------------- 15 mirror running 16 vm2 runningTo be able to undefine a virtual machine, it needs to be shutdown first:virsh # shutdown mirrorDomain mirror is being shutdownThis command asks for a nice shutdown (like running shutdown in command line).Notice: Ubuntu 10.04 server doesnt have acpid installed by default. Thispackage needs to be installed on the guest OS before it will listen to anyrequests from the host.You can also use "destroy", the more brutal way of shutting down a VM,equivalent of taking the power cable off:virsh # destroy mirrorDomain mirror destroyedIf you have made a change to the XML configuration file, you need to tell KVM toreload it before restarting the VM:virsh # define /etc/libvirt/qemu/mirror.xmlDomain mirror defined from /etc/libvirt/qemu/mirror.xmlThen, to restart the VM:virsh # start mirrorDomain mirror startedSuspend and resume a Virtual MachineVirsh allows you to easily suspend and resume a virtual machine.virsh # suspend mirrorDomain mirror suspendedvirsh # resume mirrorDomain mirror resumedEditing the attributes of a Virtual Machinelibvirt stores its configuration as xml in /etc/libvirt/qemu. The xml is easyto understand, and is similar to VMware *.vmx files. While it is possible toedit these files in place and restart libvirt-bin for the changes to takeaffect, the recommended method for modifying the attributes of a virtual machineis via virsh (or virt-manager, if it supports changing the hardware you want tochange). The concept is simple: export (aka dump) the xml of the virtual machine you want to edit edit the xml import (aka define) the xmlFor example, to edit the machine named foo (you can get a list of yourmachines with virsh list --all), do:$ virsh dumpxml foo > /tmp/foo.xml(edit /tmp/foo.xml as needed)$ virsh define /tmp/foo.xml Página 2
    • Sem títuloAdding CPUsKVM allows you to create SMP guests. To allocate two CPUs to a VM, dump the xmlas above, then edit your xml to have:<domain type=kvm> ... <vcpu>2</vcpu> ...</domain>Now define the VM as above.Adding MemoryTo change the memory allocation in a VM, dump the xml as above, then edit yourxml to have:<domain type=kvm> ... <memory>262144</memory> <currentMemory>262144</currentMemory> ...</domain>Now define the VM as above. Keep in mind that the memory allocation is inkilobytes, so to allocate 512MB of memory, use 512 * 1024, or 524288.Changing the Network Card Modelkvm and qemu currently default to using the rtl8139 NIC. Supported NICs inUbuntu 8.04 LTS are i82551, i82557b, i82559er, ne2k_pci, pcnet, rtl8139, e1000,and virtio. To use an alternate NIC, dump the xml as above, then edit your xmlto have:<domain type=kvm> ... <interface type=network> ... <model type=e1000/> </interface> ...</domain>Now define the VM as above.Adding USB Device Pass-throughLimitations USB protocol 1.1 only Device must be plugged in before KVM starts Apparmor modifications neededApparmor ModificationIn order for a software program to access the usb device correctly the apparmormust be changed. Edit /etc/apparmor.d/abstractions/libvirt-qemu and uncommentsome lines.:# WARNING: uncommenting these gives the guest direct access to host hardware.# This is required for USB pass through but is a security risk. You have been# warned./sys/bus/usb/devices/ r,/sys/devices/*/*/usb[0-9]*/** r,/dev/bus/usb/*/[0-9]* rw, Página 3
    • Sem títuloAfter making the changes apparmor must be restarted.:$ sudo /etc/init.d/apparmor restartAdding USB devicesFirst find the usb Vendor ID and Product ID.:$ lsusbBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 005 Device 012: ID 0a5c:2110 Broadcom Corp. Bluetooth ControllerBus 005 Device 003: ID 0483:2016 SGS Thomson Microelectronics Fingerprint ReaderBus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubBus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hubIn the event that the Broadcom Corp. Bluetooth Controller wans to be selectedthe vendor and product ids are 0a5c and 2110 respectively. These can be enteredinto the xml profile. This can be done through virsh through the edit <domain>command.:<domain type=kvm> <name>windowsxp</name> … <devices> … <hostdev mode=subsystem type=usb> <source> <vendor id=0x0a5c/> <product id=0x2110/> </source> </hostdev> </devices></domain> Página 4