Hot answers tagged

25

I'd like to start with a note that you should avoid using virsh attach-disk with its limited amount of options. Instead, I'd suggest to specify the exact disk format you prefer in a separate, temporary XML file or by using the virt-manager GUI application (for the latter, skip the first step). Create a temporary file with a disk definition like this one ...


22

The latest stable release for libvirt for Ubuntu is version 0.7.5, which doesn't have some newer features (i.e. script hooks and network filters) which make automatic network configuration easier. That said, here's how to enable port forwarding for libvirt 0.7.5 on Ubuntu 10.04 Lucid Lynx. These iptables rules should do the trick: iptables -t nat -I ...


16

If you don't want to do any configuration inside the guest, then the only option is a DHCP server that hands out static IP addresses. If you use bridge mode, that will probably be some external DHCP server. Consult its manual to find out how to serve static leases. But at least in forward modes nat or route, you could use libvirt's built-in 'dnsmasq' (More ...


14

virsh dumpxml myvm > foo.xml <edit foo.xml, change the name, move storage> virsh undefine myvm virsh define foo.xml Source: https://www.redhat.com/archives/libvirt-users/2010-October/msg00072.html


14

According to the manual of virsh this is: virsh destroy _domain-id_ virsh undefine _domain-id_ virsh vol-delete --pool vg0 _domain-id_.img And it further says: "Undefine (destroy) the configuration for an inactive domain. Since the domain is not running the domain name or UUID must be used as the domain-id."


13

Looking at the output of "help": virsh # help autostart NAME autostart - autostart a domain SYNOPSIS autostart <domain> [--disable] DESCRIPTION Configure a domain to be automatically started at boot. OPTIONS [--domain] <string> domain name, id or uuid --disable disable autostarting This requires that you ...


13

Use virsh define somefile.xml and virsh start domain-name, doing this the VM will be persistent. I can't check right now, but I think you can use virsh define on an already started VM and this will make it persistent.


12

I figured out a way of setting up port redirection on the fly when the guest is using user-mode networking, and blogged about it here: http://blog.adamspiers.org/2012/01/23/port-redirection-from-kvm-host-to-guest/ You can see the details there, but for convenience, here is the solution I figured out: virsh qemu-monitor-command --hmp sles11 'hostfwd_add ::...


12

run virsh dumpxml name_of_vm > name_of_vm.xml Undefine the old vm to prevent an error because of an duplicate UUID. virsh undefine name-of-vm Edit the xml file then import it. virsh define name_of_vm.xml Of course you will have to stop and start the vm for the changes to take effect virsh destroy name_of_vm virsh start name_of_vm


11

You can't use switch port security on the Cisco since all the VMs will be sharing a physical switch port. And you can't use Linux iptables because the traffic is being bridged, not routed, through the hypervisor machine. But you can emulate switch port security on the hypervisor with Linux ebtables, which is a lesser-known layer 2/3 firewall on the Linux ...


10

Here is a better way to set up port forwarding, using a hook script (source). In /etc/libvirt/hooks/qemu: #!/bin/sh GUEST_NAME= HOST_PORT= GUEST_IPADDR= GUEST_PORT= if [ "$1" = "$GUEST_NAME" ]; then if [ "$2" = start ]; then iptables -t nat -A PREROUTING -p tcp --dport "$HOST_PORT" \ -j DNAT --to "$GUEST_IPADDR:$GUEST_PORT" iptables -...


9

Red Hat is making a huge containerization push. They're building an entire new product, Red Hat Enterprise Linux Atomic Host, around it. For a less radical approach, take a look at their RHEL7 beta Resource Management and Linux Containers Guide; you'll notice it pushes libvirt-lxc and makes no mention of the lxc tools.


8

If libvirt doesn't reload VM settings on start/stop, virsh edit command may help. And please write entire XML file and libvirt version Hmm... everything seems OK. Try adding <boot dev='hd'/> <boot dev='cdrom'/> <bootmenu enable='yes'/> to <os> section and look if cdrom appears in boot menu. Also try removing all <boot> records ...


8

Check out the 'USB passthrough | Using Libvirt' section of this page from the Edubuntu wiki. More info here and here. If you don't ever plan to hot plug/unplug the usb drive while the guest is running you could also try adding a section like <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/sdb'/>...


8

The optimal configuration is (usually) as follows: On the host, set elevator=deadline Use virtio and only virtio use raw LVs whenever possible. Qcow2 gives overhead. Files on a FS also have overhead in the VM use the elevator=noop both in host and VM, use noatime,nodiratime in fstab wherever possible Make sure the virtio drivers are up to date, especially ...


8

Kids, don't try this at home: Libvirt should have rejected the creation of a domain with a space in its name, so someone did something strange to create the domain to begin with. To recover from this is going to require some hand-editing of files you aren't normally supposed to touch manually. So this is what I would do: Stop libvirtd (your VMs will ...


8

This is for google guys like me. Those answers are pretty useless, this is not a distro problem but a bug in Windows: http://keyliner.blogspot.se/2009/11/windows-7-slow-keyboard-response.html (second clause) That is what helped me: a. Start, Run, "Regedit" If the RUN command is not visible, see this link. b. Tunnel to this key: Hkey_LocalMachine/System/...


7

This issue was caused by the way libvirt uses apparmor. The default behavior is to provide some protection for the host against the guest by restricting which files the virtualization process on the host is allowed to access. libvirt knows that the virtualization process (kvm in this case) needs the disk image in order to operate properly, so it creates an ...


7

The Problem I've got the same problem and I haven't found a good solution. Here's what I found: The problem is that after resume, the system and hardware clock times on the guest are different: root@guest:~# date; hwclock Sat Oct 11 13:09:38 UTC 2014 Sat Oct 11 13:10:42 2014 -0.454380 seconds On the host, they agree: root@four:~# date; hwclock Sat ...


7

I would recommend powering everything down when you power cycle the array. That way you are completely sure that everything is flushed correctly. The additional outage time sucks, but when it comes to downing the storage array I don't screw around with shortcuts.


7

Use virtio for disks and network. for the mountpoint where you keep the images and the isos, use the noatime and nodiratime options use the deadline scheduler on the host use spice/qxl for video for proper video performance


7

I will give very rough idea/explanation. In OP situation, besides measuring within the VM, the host should be look at too. In this case, we can assume the following are correct In all the test, the host I/O(disk) bandwidth is not max out. As VM("monitoring") I/O increases with more CPUs allocated to it. If host I/O was already max out, there should be no ...


7

Deleting a file does not actually delete the file, it reduces the number of names pointing to an inode. If both the number of names and the number of open file descriptors to the file reach 0, the data gets deleted. So if you delete a file that's still open by some application, that application can still happily use that file. Only when the last file ...


7

list files in /etc/libvirt/qemu/networks/ and /etc/libvirt/qemu/networks/autostart/ if empty - create it useful commands: virsh net-start default or virsh net-autostart default and virsh net-destroy default virsh net-undefine default service libvirtd restart for detailed explanation read wiki: http://wiki.libvirt.org/page/Networking


7

What's the conventional wisdom regarding LXC and RHEL-like systems today? Personally, I find the current setup somewhat lacking. LXC seems more at the forefront -- certainly more maintained. How are you implementing them? In terms of offering it as a virtualization option I am not. I find the current technological setup lacking. No username ...


6

Why not simply set the guest to use br0? Instead of configuring it with a "network", you can configure it with a "bridge" and attach the VM to br0. example: <interface type='bridge'> <source bridge='br0'/> <mac address='00:16:3e:1a:b3:4a'/> </interface> This way the guest will get an IP from the external net and can contact the ...


6

If you get the response: virsh autostart domainname "cannot set autostart for transient domain" then virsh shutdown domainname virsh define xmlfile virsh start domainname virsh autostart domainname In my experience on Ubuntu 12.04, this only happens if a virsh undefine has been run. Domains created with virsh create usually ...


6

I recommend using libvirt for managing your KVM virtual machines. It makes the whole thing much easier than with just plain QEMU/KVM and provides also nice CPU, IO and network statistics. You will like tools such as virt-top and virt-manager which work on top of the libvirt framework. To collect the virtual machine interface statistics from a script, you ...


6

Your domain may be shut down. Run virsh list --all to see all domains.


6

Changes made to a network take place the next time the network is started. You need to perform this series of operations. virsh net-edit somenet virsh net-destroy somenet virsh net-start somenet For confirmation of this, see functionality of virsh net-edit Note that restarting a network like this will terminate network connectivity for any VMs using this ...



Only top voted, non community-wiki answers of a minimum length are eligible