From Fedora Project Wiki

Revision as of 02:46, 4 May 2009 by Herlo (talk | contribs) (initial creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

by Kevin Fenzi (irc: nirik)

IRC Log

@nirik Hello everyone. I'm Kevin Fenzi and I will be talking about libvirt 18:59
@nirik right here Acedip. ;) 19:00
Acedip hello.. :) 19:00
pluvo hi! 19:00
homerofutoi hello 19:00
Acedip i dint know you are the one :D 19:00
openpercept_ hi nirik 19:00
* jayson_r waves hi! 19:00
@nirik I'd like to note that I am a user of libvirt, I don't maintain or develop it. :) All that is needed to teach is a understanding of something and a desire to teach it. ;) 19:00
@nirik so, lets go ahead and get started then. 19:01
@nirik First of all: what is libvirt? libvirt is a frontend management framework for virtualization. 19:01
@nirik It allows you to use a common set of commands and configuration over a range of backend virt tech. 19:01
@nirik libvirt supports (that I know of): qemu, kvm, virtualbox, containers, xen and likely other backends. 19:02
@nirik How many people here have run virtual machines before? And what did you use? 19:02
* subfusc used qemu 19:02
homerofutoi me, i've use virtualbox 19:03
* Acedip used vbox 19:03
openpercept_ used qemu, vmware, virtualbox 19:03
@nirik cool. 19:03
@nirik I use kvm here, so that is what I know best... but much of this will apply to any of the backends libvirt supports. 19:03
* jayson_r uses kvm in Fedora, VirtualBox & Xen on Centos, and Citrix XenServer 19:03
pluvo vmware and later virtualbox 19:03
* herlo has used kvm, xen, etc... 19:03
@nirik kvm and qemu are available in fedora. 19:03
@nirik You can install libvirt (and qemu/kvm) via 'yum groupinstall "Virtualization"' 19:04
@nirik libvirtd then runs as a regular service. This daemon looks at your config and takes care of setting up networks, talking to the various backends and starting/stopping virtuals, etc. 19:05
@nirik by default, libvirtd in fedora will start up with a private virtual network for your guests and use qemu or kvm if your processor supports it. 19:05
* nirik will point out http://fedoraproject.org/wiki/Getting_started_with_virtualization has some good startup tips as well. 19:06
@nirik once libvirtd is running on your system you can connect to it via command line tools or virt-manager (a gui) 19:07
@nirik note that you don't need to be on the same machine your libvirtd is running on. You can use ssh transport to connect to it from any machine you like. 19:07
@nirik lets take a look at virt-manager first. If anyone wants to look around, you can run the above yum command and you should then be able to run 'virt-manager' to start the gui 19:08
@nirik for those of you not able to, you can look at scrreenshots at http://virt-manager.et.redhat.com/screenshots.html 19:08
@nirik so, this gui is pretty easy to deal with. From here you can connect to any machine running libvirtd and manage it. 19:09
@nirik you can setup new guests, stop or start guests, take snapshots, view a console or serial console and add/remove hardware 19:09
* subfusc wished to ask stupid question: This is the client? 19:09
@nirik virt-viewer is just a management tool that connects to any libvirtd instance... 19:10
@nirik does that answer the question? or what do you mean by client? 19:10
subfusc ah k, thanks. It answers it. If libvrtd is the backend or service, virt-viewer is in my world a client (admin clent thou) 19:11
@nirik yeah 19:11
@nirik ok, so if we want to create a new guest, you can select the connection and say 'new' 19:12
@nirik http://virt-manager.et.redhat.com/screenshots/install.html 19:12
@nirik these screens have changed somewhat in new fedora (f11 at least) to get simplified a bit. 19:13
@nirik basically you tell it a name, a arch type, what backend to use, what storage to use, network, mem, cpu. 19:13
@nirik and it creates it for you. 19:13
@nirik Let me touch a bit on storage. 19:14
@nirik You can set libvirt to use various storage backends. lvm, or physical raw partitions or files on your existing filesystem. 19:14
@nirik The default is just files on your filesystem, which is very easy to manage, but possibly less performance wise. 19:14
@nirik You can use things like iscsi or the like as well. 19:15
@nirik anyone have any questions on the gui so far? 19:15
@nirik virt-manager is nice, but I think the command line tools are very good. 19:16
@nirik There are a set of them: virt-top, virt-df, virt-viewer, and the best of all: virsh 19:16
@nirik the various utils like virt-top, virt-df let you run those unix commands on a specific guest from the command line. 19:17
@nirik virt-viewer lets you connect to a guest a bring up a vnc console for it. 19:17
@nirik virsh has a ton of commands 19:18
@nirik http://scrye.com/pastebin/600 is a list I get here on a rawhide server 19:18
@nirik vmware has something like this with its vmware-cmd, but thats very limited next to virsh, IMHO 19:18
@nirik common things I do with virsh: 19:19
@nirik 'virsh list' and 'virsh list --all' shows you all active guests, and all guests defined. 19:20
@nirik 'virsh shutdown <name>' and 'virsh start <name>' stops and starts guest 19:20
@nirik 'virsh console <name>' gets you a serial console on a guest. 19:21
subfusc nirik: and by guest you mean guest user, not guest OS? 19:21
@nirik no, I mean guest os... the virtual instance... 19:22
@herlo virsh also has a interactive mode I like 19:22
@nirik let me give an example from a machine here: 19:22
@nirik # virsh list 19:22
@nirik Id Name State 19:22
@nirik ---------------------------------- 19:22
@nirik 1 thulsadoom running 19:22
@nirik # ps axuww | grep thulsa 19:23
@nirik root 3657 20.5 29.0 2847016 2360028 ? Sl Apr18 4369:18 /usr/bin/qemu-kvm -S -M pc -m 2048 -smp 4 -name thulsadoom -uuid 29bb3791-3007-da35-9919-2466ea425ba1 -monitor pty -pidfile /var/run/libvirt/qemu//thulsadoom.pid -boot c -drive file=/var/lib/libvirt/images/thulsadoom.img,if=ide,index=0,boot=on -net nic,macaddr=00:16:3e:38:e2:98,vlan=0,model=virtio -net tap,fd=16,script=,vlan=0,ifname=vnet0 -serial none -parallel none -usb -vnc 127.0.0.1:0 19:23
@nirik you can see this is a kvm instance. 19:23
@nirik all those things on the kvm command line are taken care of for me by libvirt. 19:23
@nirik since I defined this guest to have 2048mb memory, 4 cpus, the name and uid it does, the disk image, etc. 19:24
@nirik yes, you can also run 'virsh' and get a interactive mode where you can do a set of commands... 19:24
@nirik subfusc: does that make sense? 19:24
@nirik ok, any further questions on those tools? 19:25
subfusc nirik: do i got it right if i think by running virsh stop <name> you kill the kvm instance? 19:25
pluvo What is the difference between "virsh -c qemu:///system" and "virsh -c qemu:///session"? 19:25
@herlo nirik: yes, I have one about virsh 19:25
@herlo specifically, I'd like to create a guest using the interactive mode, then save that out so it can be duplicated, how hard is that? 19:26
@nirik subfusc: yes. well, 'shutdown', but right. ;) 19:26
@nirik pluvo: good question. I always have used system and thats the default. I am unsure what session is there... 19:26
@nirik herlo: several ways. Perhaps the easiest is to make your template guest and copy the xml file and then use a 'virsh define <file.xml>' on it. 19:27
@nirik I just realized I left out 'virt-install'. 19:27
@nirik It's a command line version of the new guest procedure. It will ask you for memory, name, etc... or you can pass those as arguments to create a guest all from the command line. 19:28
@nirik herlo: so, you could just make a virt-install command line with all your parameters filled in as you like too. 19:28
@nirik I would like to touch on the guest config format that libvirt uses for a few here. 19:29
@nirik libvirt stores info about each guest in a xml file. Those files are located under /etc/libvirt/ 19:30
@nirik this xml format describes all the things about that guest libvirt needs to know to start/stop/manage it. 19:30
@nirik here's an example of a simple one: http://scrye.com/pastebin/601 19:31
@nirik if you are comfortable with xml or just want to do something that the command line or gui interfaces don't do, you can edit this xml and define guests by loading that xml file 19:32
@nirik herlo: oh, there is also 'virt-clone' to clone a template guest to another. 19:33
@nirik ok, any questions on the xml or anything else? ;) 19:33
pluvo here 19:34
pluvo if i edit the xml file under /etc/libvirt/... how can i tell the libvirt-daemon to reload this? 19:34
pluvo Normally i edit the xml file with "virsh edit" 19:34
@nirik pluvo: the only ways I know are: restart libvirtd. Or 'undefine' the guest and 'define' it again. I don't know of any easier way. 19:35
@herlo nirik: oh, nice 19:35
@herlo nirik: that's closer to what I was after... 19:36
@nirik pluvo: just out of curiosity, what do you need to edit usually? 19:36
@nirik ok, I would like to mention a few cool related items to libvirt here before we run low on time: 19:37
pluvo i changed the network device to "e1000" 19:38
@nirik virt-p2v is a pretty cool livecd for transfering a physical host to a guest on a libvirt server. 19:38
@nirik http://et.redhat.com/~rjones/virt-p2v/ 19:38
@nirik pluvo: ah, yeah, I hope that is configurable via the tools soon. 19:38
@nirik basically with virt-p2v, you download and make this livecd, then boot it and it manages transfering that host to a guest on a libvirt server. It handles the transfer of data and setup on the libvirt side. 19:39
@nirik very handy to move a machine to a virtual you want to no longer run as a physical machine. 19:39
@nirik And I also wanted to mention libguestfs. This is a library that lets you manipulate guest disk images... you just need access to the image. 19:40
@nirik You can use that to do cool things like script changes over a pool of guests. Or modify config without having to boot guests. 19:41
@nirik see http://rwmj.wordpress.com/2009/04/29/contributing-a-libguestfs-enhancement-with-examples/ for more info on that 19:41
@nirik any other further questions from the floor? 19:42
@herlo nirik: what about partitioning a disk img file, can libguestfs do that? I know it used to be done with kpartx, but I never learned that tool... 19:42
@nirik herlo: I think it requires the existing image already, and just manipulates the contents... I don't think it can partition. 19:43
@herlo the idea being that if the host is in a file, it's difficult to expand / partition, etc. 19:43
Acedip why actually do we need libvirt, virtualization backends like xen, vbox doesn use it eveywhere ? 19:43
@herlo nirik: ok 19:43
@nirik Acedip: well, because it puts a standard frontend on those things. You don't need to care what backend it's using (usually). 19:44
@nirik you can manage them the same if they are virtualbox or kvm or xen. 19:44
@nirik just need to learn one set of commands and such. ;) 19:44
@nirik also, libvirt is fully open (LGPL ed) so it gets rapid improvement and feedback from users. 19:45
@herlo nirik: so let's ask an obvious question. And it's probably not something anyone knows for sure. Xen functionality is currently not available in Fedora. Will it be coming back? 19:46
@nirik herlo: yeah, I don't know the answer for sure, but it is still being worked on. There are some devel/testing kernels for f11 with Xen Dom0 support. 19:46
@herlo oh? I thought for sure it'd be at least F12, that's good to hear... 19:46
@nirik and they are working on merging things upstream. So, perhaps f12 or f13 will have support back for xen Dom0 19:47
@nirik yeah, nothing official for f11, but it's being worked on. 19:47
* nirik checks his notes to see what else he wanted to cover. 19:47
@herlo I did see the stuff for f12, but didn't know there was anything going on for f11 :) 19:47
@nirik oh yeah, virt-viewer. So, virt-viewer lets you connect to a vnc console on a guest, so you can run and use gui programs 19:48
@nirik A nice new feature in f11 will be that the resolution has been increased and the mouse handling is wonderful now. 19:48
@nirik virt-viewer also lets you send various keys to the guest... 19:49
@nirik control-alt-del, control-alt-f2, etc... you can also scale it to fit in your client session and take screenshots. 19:50
* kdn applauds 19:50
@nirik you can connect via a ssh transport from your desktop to the server running libvirt easily by passing it a -c string. 19:50
@nirik for example here, I would use 'virt-viewer --connect qemu+ssh://root@theleb/system thulsadoom' 19:51
@nirik most of the tools take this --connect argument. In this case thats qemu(really kvm) via ssh and root on the machine 'theleb' connecting to guest 'thulsadoom' 19:51
@nirik so it's a secure fast gui console on the guest 19:51
@nirik the mouse handling has been vastly improved by changing the guest mouse device to a tablet. ;) 19:53
@nirik that way there is absolute control over where the pointer is. 19:53
@nirik any questions on virt-viewer? 19:54
@nirik oh, one thing I failed to mention when talking about storage: 19:54
@nirik You can use a file on your server to contain the guest disk space. You can also tell libvirt to use a 'sparse' file. This means that if you assign a 20GB drive to a guest, and make it a file it will not allocate all 20GB of that, only as data fills it up. 19:55
@nirik doing this you can have guests with more space than your host, but of course if they fill up your host drive, it could cause data loss on the guests. 19:55
* jayson_r has a question about that 19:56
@nirik You can also make new virtual drives and attach them to guests anytime you like. 19:56
@nirik jayson_r: ask away. 19:56
jayson_r Is there a performance difference between a sparse file and a fully allocated file? I've found that there is under VirtualBox and VMware in the past. 19:56
@nirik good question. I tend to do sparse ones... but I don't think I have benchmarked it with a allocated one. 19:57
@nirik I don't know, but might be fun to benchmark. ;) 19:57
@nirik also, lvm and raw partition would be nice cases to throw in there. 19:58
pluvo The default storage pool is '/var/lib/libvirt/images/', right? How can i change this? 19:58
@nirik pluvo: yes, you can do a 'virsh pool-edit' and define a new pool, or I think virt-manager has a way to define one. 19:58
jayson_r pluvo: in virt-manager 19:59
@nirik note that selinux expects guests images to be in that dir, so you may run into selinux issues if you pick another. 19:59
jayson_r edit - host details 19:59
jayson_r storage tab 19:59
* nirik nods. 19:59
@nirik Also in f11 we have svirt. 20:00
jayson_r svirt? 20:00
@nirik basically this is selinux protecting guests from each other and the host. ;) 20:00
jayson_r oh 20:00
@nirik https://fedoraproject.org/wiki/Features/SVirt_Mandatory_Access_Control 20:00
@nirik pretty nice stuff to keep guests and host from compromising each other. 20:01
@nirik ok, anyone have any further questions? or shall we wrap things up? 20:01
@nirik ok, lets call it a class. ;) 20:02
@nirik thanks for coming everyone. 20:02
DiscordianUK Thanks nirik 20:02
kdn Thanks, nirik. Well done! 20:02
@nirik I'd be happy to answer further questions here or in #fedora. 20:02
* subfusc is glad nirik had this session, and thanks nirik for the wonderfull class, and answering his stupid questions 20:02
jayson_r nirick: awesome job - thanks for your time 20:02
homerofutoi thank you nirik, good explaination 20:03
jayson_r nirik: sorry for the misspell :-) 20:03
@nirik questions are good. ;) 20:03
@nirik libvirt is great stuff. 20:03
pluvo nirik, thanks! 20:03
* nirik notes there is still 4 hours left of the teaching day if anyone wants to step up and teach a last minute class. 20:04

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!