[libvirt-users] LXC libvirt support
by Nirmal Guhan
Hi,
Has anyone used libvirt to start/stop/manage LXC (linux containers) ?
Is it supported at all? Last I tried, had few issues and the reply was
:
///
Note that libvirt lxc driver is a different implementation from lxc tools
and doesn't use lxc tools internally. You may not be able to do what
you are doing with lxc tools. Especially, the driver doesn't take aware
of files and settings inside a container at all. You have to prepare them
by yourself in advance
///
Is it still the case?
~nirmal
13 years, 9 months
[libvirt-users] Start domain with usable QMP connection?
by Bryan D. Payne
Is there any way to get virsh / libvirt to create a domain such that I
can later connect to it via QMP (without hacking the code)?
The command line that libvirt creates for my current setup looks like this:
/usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512
-smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid
ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev
socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait
-mon chardev=monitor,mode=control -rtc base=localtime -boot c -drive
file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0
-drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
-netdev tap,fd=16,id=hostnet0 -device
rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3
-chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb
-device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std
-device ES1370,id=sound0,bus=pci.0,addr=0x4 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
The important pieces of this command line (I believe) are:
-chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait
-mon chardev=monitor,mode=control
However, I'm unable to connect using this path because -- I'm guessing
-- libvirt has already connected. As a test, I added some code to
src/qemu/qemu_command.c to open a second chardev. My new command line
looks like this:
/usr/local/bin/qemu-system-x86_64 -S -M pc-0.12 -enable-kvm -m 512
-smp 1,sockets=1,cores=1,threads=1 -name winxpsp2 -uuid
ab244939-c804-1aff-68b6-9324f174c3c8 -nodefconfig -nodefaults -chardev
socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait
-mon chardev=monitor,mode=control -chardev
socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait
-mon chardev=qmpmonitor,mode=control -rtc base=localtime -boot c
-drive file=/var/lib/libvirt/images/winxpsp2.img,if=none,id=drive-ide0-0-0,format=raw
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0
-drive file=/home/username/iso/en_winxp_pro_with_sp2.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw
-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0
-netdev tap,fd=15,id=hostnet0 -device
rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:4d:1d:1b,bus=pci.0,addr=0x3
-chardev pty,id=serial0 -device isa-serial,chardev=serial0 -usb
-device usb-tablet,id=input0 -vnc 127.0.0.1:0 -k en-us -vga std
-device ES1370,id=sound0,bus=pci.0,addr=0x4 -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
Notice that there are now two chardevs:
-chardev socket,id=monitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.monitor,server,nowait
-mon chardev=monitor,mode=control
-chardev socket,id=qmpmonitor,path=/usr/local/var/lib/libvirt/qemu/winxpsp2.qmpmonitor,server,nowait
-mon chardev=qmpmonitor,mode=control
As expected, I am able to connect to this second chardev via QMP. Is
there anyway that I can enable such functionality in libvirt without
hacking the code?
Thanks,
bryan
13 years, 9 months
[libvirt-users] Not able to capture detailed CPU information of the guest machine using Libvirt API.
by arpita k
Hi ,
I have two KVM guests in ubuntu host machine.I am using Python binding of
Libvirt API to query on the hypervisor and capture the CPU , memory related
information of the guest machines.
I need to capture the detail information regarding CPU like : cpu_aidle,
cpu_idle, cpu_speed, cpu_wio and memory like
:mem_cached,mem_buffers,mem_free etc. of the guest machines.
How could I get these information?
Please help me.
Thanks in Advance!!
Arpita
13 years, 9 months
Re: [libvirt-users] [libvirt] configuring network interface
by Marcela Castro León
Hello Laine:
I've revised the configuration and followed all your instructions.
I'll try to give you a better explain of my problem.
a) I need a bridged (3) configuration, because I have to connect the guests
from each others. (via ssh and execute mpi). I've three hosts, each of one
has at least a guest.
I'll only explain about the configuration of one of them, because the
problem is only related a one configuration.
hostname=rionegro ip=192.168.1.4
guest-name=rnompi1
b) I've configured host bridge following step by step ther instruction on
http://wiki.libvirt.org/page/Networking
this is the /etc/network/config
# The loopback network interface
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
address 192.168.1.4
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.10
bridge_ports eth0
bridge_stp on
bridge_fd 0
bridge_maxwait 0
c) this is the xml guest configuration related to the network.
<interface type='bridge'>
<source bridge='br0'/>
</interface>
d) But the guest doesn't get any IP automatically, and create an interface
with a variable name (eth4, eth5,etch6..)*. I don't know how to achieve the
guest don't behave like this and create always its network interface *with a
fixed name, for example, eth0).
Why I ask that?
if the guest created an interface with a fixed name, I would configure and
static ip for the it.
I'm attaching a printscreen "rnompi1.jpg" that show what ifconfig ahow on
the guest (eth14 and without any IP). It doesn't get their host either.
The only way I achieve to solve but "temporally" until reboot is configuring
the guest statically using the name of the interface that has just up.In
that case every works fine, and the guest can connect to all the other
guests on the lan and others can connect to it.
But this only works until reboot or reconfigure the guest, because each time
the name of interface change, and my configuration I had done of
/etc/network/interface didn't work any more because is related to another
interface.
I hope I've explained better the problem I have.
Thank you very much, you've already helped too much to better understand the
different cases of network configuration
Regards.
2011/2/10 Marcela Castro León <mcastrol(a)gmail.com>
> Hello Laine:
> Thank you very much.
> I've showed only one of the guest, each one have it's own ip address.
> Anyway, I'll follow your advise of revise all the configuration after
> reading the doc.
> Thank you very much again.
> Regards.
>
> 2011/2/8 Laine Stump <laine(a)laine.org>
>
> (For future questions such as this, you may find you get a better response
>> (and lower signal-noise ratio) by asking on the recently -created
>> libvirt-users(a)redhat.com list, as libvir-list has a very large volume of
>> patches and discussion about the internals of libvirt)
>>
>>
>> On 02/08/2011 12:05 PM, Marcela Castro León wrote:
>>
>> Hello
>>
>>>
>>> I've a lan of virtual machine configured with bridge. I've a private
>> lan of 4 machine, but one of them have 2 lan-card with access to internet.
>>
>> Evertything works almost fine, except that I've configured on each guest
>> the static configuration of the bridge with the ip address, like this:
>>
>> auto lo
>> iface lo inet loopback
>>
>> auto eth6
>> iface eth6 inet static
>> address 192.168.1.41
>> network 192.168.1.0
>> netmask 255.255.255.0
>> gateway 192.168.1.10
>>
>>
>>
>> So are you saying that you're attempting to give each guest the *same* IP
>> address? There's no way that can possibly work, even if each is connected to
>> a separate virtual network or bridge. Since the host's IP stack can "see"
>> all of the guests' network traffic, regardless of the connection mode you
>> choose, each must have a unique IP address even if they can't see each
>> other.
>>
>>
>>
>>
>> But each time I, for example, define the guest, it start with a ascending
>> number of interface: eth6,eth7, eth8, etc, Now is initializing with eth12.
>>
>>
>> There must be a mixup in the explanation - I'm understanding that you put
>> the same config file in each guest, but each guest, when it starts, shows a
>> different ethernet interface in its ifconfig. That doesn't seem right,
>> because none of the guests know about each other. Or are you saying
>> something different? Where are you seeing the "eth6", "eth7", ... "eth12"?
>> In the guest XML config maybe?
>>
>>
>> So, it doesn't get the manual configuration I've done on the
>> /etc/network/interfaces.
>> How can avoid this way of work of the number of ethernet interface the
>> guest start?
>>
>>
>> Why are you doing a manual/static definition on the guest at all? It's
>> simpler to just leave the guest to automatically configure its eth0, and if
>> you really want a particular IP address for a particular guest, handle that
>> with a <host> element in the <dhcp> section of the virtual network the guest
>> is connected to (or, if you're using a pure bridging setup, then in the
>> static hosts config of the dhcp server on that network).
>>
>>
>>
>> A way i'm trying to solve is configuring the interface trough the guest
>> xml definition,
>>
>>
>> The guest xml interface configuration cannot be used to setup the IP
>> address, route, etc config of the guest. It is only used for two things:
>>
>> 1) configuring what kind of hardware appears on the guest (but not what
>> name the guest gives to it!)
>>
>> 2) configuring how that hardware is connected to the physical network
>> (usually either via an existing bridge interface on the host (in order for
>> the guest to appear as if its directly connected to the physical network),
>> or via a "virtual network" created by libvirt (which is really just a bridge
>> that's not directly connected to any physical interface, relying instead on
>> the host's IP stack to route packets from the guest out to the physical
>> network.)
>>
>>
>> but the operation "define" on virsh accepted without error the xml i've
>> done, but the dumpxml doesn't show them, so, it doesn't work at all.
>> I've followed the instruction that said the manual "Application
>> development guide - a guide to application development with libvirt" on page
>> 71.
>>
>>
>>
>> That document is targeted towards software developers writing applications
>> to manage virtual guests using the libvirt API, not for system
>> administrators who are configuring virtual guests manually (or, more likely,
>> by using software that uses the libvirt API, eg virsh or virt-manager). It
>> likely contains more detail and less overview than what you need, which is
>> probably what led to the confusion. I've included a pointer to a wiki page
>> below that is more the appropriate level of information (Justin, if the docs
>> you were working on are somewhere easily accessible, you can point to those
>> instead.)
>>
>>
>>
>> The whole definition of the VM is attached, but the related to interface
>> is:
>> <interface type='bridge'>
>> <source bridge='br0'/>
>> <target dev='vnet0'/>
>> <protocol>
>> <ip address="192.168.1.41" prefix="24"/>
>> <route gateway="192.168.1.10"/>
>> </protocol>
>> <bridge stp="off" delay="0.01">
>> <interface type="ethernet" name="eth12">
>> <protocol>
>> <ip address="192.168.1.41" prefix="24"/>
>> <route gateway="192.168.1.10"/>
>> </protocol>
>> </interface>
>> </bridge>
>> </interface>
>>
>>
>>
>> You are confusing the guest interface config (that is part of the guest's
>> XML config, and described above), and host physical interface config (that
>> is not in any way associated with guest config, but instead used to
>> configure the host's physical network interfaces, bridges, bonds, and vlan
>> interfaces; and nearly as important, is not supported on Ubuntu anyway).
>>
>> Actual guest interface config is *much* simpler than that.
>>
>>
>>
>>
>> But after define, the dumpxml only show this part:
>> <interface type='bridge'>
>> <mac address='52:54:00:3c:92:9a'/>
>> <source bridge='br0'/>
>> </interface>
>>
>>
>>
>> That's because everything else you've put in your guest config is not
>> actually a part of a valid guest interface config, and so is ignored.
>>
>>
>>
>>
>> I would appreciate any help to solve the question. The problem I've is I
>> lost the access to the guest every time the libvirt change the name of the
>> interface eth1,2,3, etc.
>>
>>
>> In this case I think it may be useful to start over. You've somehow been
>> tricked into misunderstanding the way that network configuration in libvirt
>> works, confusing host interface config with guest interface config, and the
>> resulting config bears little resemblance to what would actually work.
>>
>> ==
>> The first step is to read this page:
>>
>> http://wiki.libvirt.org/page/Networking
>>
>> to get a basic overview.
>>
>> ==
>> Second step: you should decide which of the three methods of connecting to
>> guests to the physical network you want to use:
>>
>> 1) NATed
>> 2) routed
>> 3) bridged
>>
>> The simplest is (1), and that will probably work just fine as long as 1)
>> you don't need incoming connections to the guests, and 2) you're not
>> concerned about getting the last fraction of an ounce of performance out of
>> the network.
>>
>> Depending on which of those 3 you decide to use:
>>
>> ==
>> Third step: follow the instructions to either create a bridge interface on
>> the host connected to a physical network interface (for (3)), or to create a
>> libvirt virtual network using one of the two modes ((1) or (2) - actually
>> the stock libvirt config already has a "default" network that is probably
>> adequate for (1), and unless you understand IP routing very well, you'll
>> likely want to avoid (2)).
>>
>> Once the physical network is setup:
>>
>> ==
>> Fourth step: define your guests. In each guest, you'll have an <interface>
>> element, but it will be much simpler than what you've previously tried. For
>> bridged mode, the interface section would look like this:
>>
>>
>> <interface type='bridge'>
>> <source bridge='br0'/>
>> </interface>
>>
>> Depending on the guest, you may want to specify what type of hardware is
>> presented to the guest (default is rtl, which almost always works, but is
>> not the best perfrorming), in particular, if the guest supports virtio-net,
>> you'll want to add this into the <interface> element:
>>
>> <model type='virtio'/>
>>
>> For NATed or routed mode, the guest's interface definition would look like
>> this:
>>
>> <interface type='network'>
>> <source network='default'/>
>> </interface>
>>
>> (replace "default" with the name of the network you've defined, if you've
>> defined your own). In this case also, you can add a <model type='...'/> if
>> appropriate.
>>
>> Note that I don't put anything in the <interface> element about MAC
>> address, target device, or bus address. Those are all setup automatically by
>> libvirt the first time you start the guest, and it will make sure that the
>> guests don't interfere with each other.
>>
>> ==
>> Fifth step: only if you need a particular guest to have a particular fixed
>> IP address, either 1) edit the network config file on the guest, 2) add a
>> static host to the libvirt virtual network definition (giving the MAC
>> address provided to the guest by libvirt during the initial guest startup)
>> with a <host> element added to the <dhcp> element of the network; details
>> are here:
>>
>> http://www.libvirt.org/formatnetwork.html
>>
>> or 3) if you're using the bridged method to connect to the physical
>> network, again either configure the guest's own config file, or add a static
>> host definition to the dhcp server running on your physical network.
>>
>> If you still have problems don't hesitate to send another mail (although,
>> as I said at the top, sending to libvirt-users(a)redhat.com may yield
>> better results than libvir-list(a)redhat.com).
>>
>
>
13 years, 9 months
[libvirt-users] How to retrieve Memory stat of the KVM using python binding with Libvirt API
by arpita k
Hi ,
I am using ubuntu host machine and KVM is present as guest in that
machine.Two virtual machines are there.I am using Python binding to query on
the hypervisor and extract the VM related information.I like to print memory
stat of the VM like SWAP_IN , SWAP_OUT,free memory, mem cached etc.So, the
code, I have written for this, is :
#!/usr/local/bin/python
import libvirt
import sys
conn = libvirt.openReadOnly(None)
if conn == None:
print "Failed to open connection to the hypervisor"
sys.exit(1)
try:
domIds = conn.listDomainsID()
for id in domIds:
dom0 = conn.lookupByID(id)
try:
print "memory stats: %s"% dom0.memoryStats().values()
except:
print 'Failed to find the memory data of this domain'
sys.exit(1)
except:
print 'Failed to find the main domain'
sys.exit(1)
But this code 'dom0.memoryStats().values()' is returning empty list.I need
to collect more information regarding the memory .How should I proceed?
Regards,
Arpita
13 years, 9 months
[libvirt-users] How to use Python Binding with Lbivirt.
by arpita k
HI,
I am using ubuntu host machine and KVM is present as guest in that
machine.Two virtual machines are there.I am using Python binding to query on
the hypervisor and extract the VM related information.
Here is my simple code:
#!/*usr*/local/bin/*python
*
import libvirt
import sys
conn = libvirt.openReadOnly(None)
if conn == None:
print *'Failed to open connection to the hypervisor'
*
sys.exit(1)
try:
domIds = conn.listDomainsID()
for id in domIds:
dom0 = conn.lookupByID(id)
dom0.info()
print *"Domain 0: id %d running %s"* % (dom0.ID(), dom0.OSType())
print dom0.info()
except:
print *'Failed to find the main domain'
*
sys.exit()
The output is :
Domain 0: id 2 running hvm
[1, 131072L, 131072L, 1, 14921710000000L]
Domain 0: id 3 running hvm
[1, 131072L, 131072L, 1, 30880000000L]
Here I am not able to understand these values are represent what type of
information, which value is representing what resource of host machine.Could
you please help me to understand how I could find out CPU,VM ,memory related
information seperately through python binding?.
I didn't find Python binding Reference in the Libvirt site.Could you help me
by providing the Reference link for Python binding?
Thanks in Advance!!
Arpita
13 years, 9 months
[libvirt-users] Question about putting vm in blkio cgroup
by Nikita A Menkovich
Hello,
I have another question about cgroup in libvirt
I create a script that put vm in cgroup for limiting blkio
sudo cgcreate -f 750 -d 750 -a $user:$group -g blkio:$alias
pid=`pgrep $alias`
echo $pid > /dev/cgroup/blkio/$alias/tasks
$virsh schedinfo --set cpu_shares=$cpu $alias
echo "8:0 $disk_io" > /dev/cgroup/blkio/$alias/blkio.throttle.read_bps_device
echo "8:0 $disk_io" > /dev/cgroup/blkio/$alias/blkio.throttle.write_bps_device
For example I write:
8:0 10485760 to /dev/cgroup/blkio/$alias/blkio.throttle.*_bps_device
So there should be limit to 10Mbyte/s to acces to /dev/sda
But when I run hdparm -t /dev/vda or dd to test limits I receive value
~ 70 Mbyte/s
--
Nikita A Menkovich
JID: menkovich(a)gmail.com
13 years, 9 months
[libvirt-users] Serving DHCP and DNS from a KVM guest
by Adam Reid
Hello All,
I am trying to set up a cobbler server running as a guest on an isolated
network. I'm having trouble figuring out how I can forward the DHCP and DNS
traffic to this guest instead of DNSMASQ on the host. So far I have only
tried to get dhcp working by enabling the 'allow-dhcp-server' on a guest
named test and setting the $DHCPSERVER variable through a filterref
parameter element. I figure If I can get this working I can use this filter
as a basis for DNS.
In my guest the filter is applied to the only network interface setting
DHCPSERVER to the IP of my cobbler VM.
<interface type='network'>
<mac address='52:54:00:6b:56:ab'/>
<source network='internal'/>
<target dev='vnet2'/>
<model type='virtio'/>
<filterref filter='allow-dhcp-server'>
<parameter name='DHCPSERVER' value='192.168.100.2'/>
</filterref>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
</interface>
And the internal network is defined as:
<network>
<name>internal</name>
<uuid>c1aef8ea-9d30-7514-5eb4-5ffbc235cffb</uuid>
<bridge name='virbr1' stp='on' delay='0' />
<ip address='192.168.100.1' netmask='255.255.255.0'>
</ip>
</network>
My understanding of the filter is that when it is applied to a hosts
interface it should allow DHCP requests to go to a server other than the
host system. Is this correct? Are guests allowed to serve DHCP to other
guests?
Does anyone have any suggestions or experience with this?
Thanks in advance,
Adam Reid
13 years, 9 months