[libvirt-users] Python 3.2 support for libvirt API?
by Patrick Wilbur
Hey all,
I apologize if this has been asked many times already (new to the list).
I'm trying to write a Python script that makes use of the libvirt API, and
I'm trying my best to make the script both Python 2.x and 3.x compatible.
Is the libvirt module available for Python 3.x yet, and, if so, what is
the module name that I need to import? What is the package name to install
on my OS (Ubuntu 11.10)?
Thanks in advance,
Pat Wilbur
--
Patrick F. Wilbur
Researcher, Consultant, Educator,
Computer Science Graduate at Clarkson University
patrick.wilbur(a)gmail.com
wilburpf(a)clarkson.edu
Check out our book: http://runningxen.com
Consulting: http://pfwilbur.com
My website: http://pdub.net
12 years, 7 months
[libvirt-users] libvirt, lxc, "/dev/log" ENOENT
by dennis jenkins
Hello.
I am experimenting with LXC via libvirt on my Gentoo development
system. I can start the LXC domain and connect to its console. However, I
am unable to login as root. I've used "chroot" and "passwd" from the host
system to explicitly set the root password. Still no luck. So I began
debugging....
I ran "strace" on the container's "login" process (after agetty exec'd
login). I noticed that it was unable to open "/dev/log". Sure enough the
unix domain socket did not exist inside the container (as seen from outside
the container). So I tweaked my host's syslog-ng.conf file to create this
socket. My hope was to monitor the log events generated by the login
process. So the log device certainly exists (and it tests ok with the
'logger' command):
The LXC file-system was created with the "lxc-gentoo" script (
http://lxc-gentoo.sourceforge.net/). The only changes that I've made to
the container's file system is to change roots' password
($rootfs/etc/shadow) and configure syslog-ng to create a logging socket at
$rootfs/dev/log.
I've even edit "$rootfs/etc/shadow" and completely removed root's
password hash. I still can't log into the account from "virsh console". I
thought that maybe I was unable to authenticate because the "login" process
cannot log success/failure to /dev/log. However, I know from experience
that on other Gentoo systems I can login as root even when syslog-ng is
kaput, and /dev/log does not exist.
"/etc/pam.d" inside the container is byte-for-byte the same as my host
system, and I can authenticate as root from the physical console.
I have a few main questions:
1) Is my domain configured correctly?
2) Why is the container unable to write to the "/dev/log" provided from
outside the container?
3) Why am I unable to authenticate as the "root" user?
Thank you for your time.
ostara ~ # virsh -c lxc:/// start dwj-lnx-dev
Domain dwj-lnx-dev started
ostara ~ # virsh -c lxc:/// console dwj-lnx-dev
Connected to domain dwj-lnx-dev
Escape character is ^]
INIT: version 2.88 booting
Gentoo Linux; http://www.gentoo.org/
Copyright 1999-2009 Gentoo Foundation; Distributed under the GPLv2
Press I to enter interactive boot mode
* Skipping mount of /proc as it's already mounted
* Skipping mount of /sys as it's already mounted
* Using existing device nodes in /dev ... [
ok ]
* Skipping mount of /dev/pts as it's already mounted
* Remounting root filesystem read-only ...
mount: / is busy [
!! ]
* Skipping root filesystem check (fstab's passno == 0) ... [
ok ]
* Checking all filesystems ... [
ok ]
* Mounting local filesystems ...
mount: mount point /dev/shm does not exist
* Some local filesystem failed to mount [
!! ]
* Mounting USB device filesystem (usbfs) ... [
ok ]
* Activating (possible) swap ... [
ok ]
* Setting system clock using the hardware clock [UTC] ... [
ok ]
* Configuring kernel parameters ...
error: "Read-only file system" setting key "net.ipv4.conf.default.rp_filter"
error: "Read-only file system" setting key "net.ipv4.conf.all.rp_filter" [
ok ]
* Cleaning /var/lock, /var/run ... [
ok ]
* Wiping /tmp directory ... [
ok ]
* Starting lo
* Bringing up lo
* 127.0.0.1/8 [
ok ]
* Adding routes
* 127.0.0.0/8 ... [
ok ]
INIT: Entering runlevel: 3
* Starting eth0
* Bringing up eth0
* 192.168.2.199 [
ok ]
* Adding routes
* default via 192.168.2.1 ... [
ok ]
* Mounting network filesystems ... [
ok ]
/lib64/rcscripts/sh/rc-services.sh: line 412: /etc/init.d/udev-postmount:
Permission denied
* Starting local ... [
ok ]
This is ostara.unknown_domain (Linux x86_64 3.2.12-gentoo) 23:06:09
ostara login:
ostara ~ # virsh -c lxc:/// version
Compiled against library: libvir 0.9.11
Using library: libvir 0.9.11
Using API: LXC 0.9.11
Running hypervisor: LXC 3.2.12
ostara ~ # ls -l /vm/lxc/dwj-lnx-dev/dev/log
srw-rw-rw- 1 root root 0 May 14 17:31 /vm/lxc/dwj-lnx-dev/dev/log
ostara ~ # logger -s /vm/lxc/dwj-lnx-dev/dev/log "CAPYBARA"
djenkins: /vm/lxc/dwj-lnx-dev/dev/log CAPYBARA
ostara ~ # tail -n 100 /var/log/messages | grep CAPYBARA
May 14 17:58:57 localhost djenkins: /vm/lxc/dwj-lnx-dev/dev/log CAPYBARA
(lots of strace setup omitted):
Buried about 60% down in the strace output is the attempt by "login" inside
the container to access "/dev/log", which failed (ENOENT).
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
lseek(3, 0, SEEK_CUR) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=720, ...}) = 0
mmap(NULL, 720, PROT_READ, MAP_SHARED, 3, 0) = 0x7fc6ccb66000
lseek(3, 720, SEEK_SET) = 720
munmap(0x7fc6ccb66000, 720) = 0
close(3) = 0
time([1337035715]) = 1337035715
socket(PF_FILE, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_FILE, path="/dev/log"}, 110) = -1 ENOENT (No such
file or directory)
close(3) = 0
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7fc6ccb66000
write(1, "\n", 1) = 1
write(1, "Login incorrect\n", 16) = 16
time(NULL) = 1337035715
This is my domain config:
ostara ~ # virsh -c lxc:/// dumpxml dwj-lnx-dev
<domain type='lxc'>
<name>dwj-lnx-dev</name>
<uuid>fbcd8c3a-9939-12b4-727d-5d3526bc448f</uuid>
<memory unit='KiB'>500000</memory>
<currentMemory unit='KiB'>500000</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/vm/lxc/dwj-lnx-dev'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='52:54:00:3e:d9:7c'/>
<source bridge='br0'/>
</interface>
<console type='pty'>
<target type='lxc' port='0'/>
</console>
</devices>
</domain>
12 years, 7 months
[libvirt-users] Script execution at Boot
by vipul borikar
I am using KVM on RHEL 6.1.
When i try to run a RHEL 5.5 Guest using virt-manager the a shell script
put under rc.local runs properly.
But when i try to run Guest using cmd line the script doesn't run. I mean
it gives error code as 1 .
The commands like echo works but executing another shell script under
rc.local file doesn't run and gives return code as 1.
I know its weird question .. but just was curious is there any parameter in
xml file which affects the
environment of the boot sequence ???
I can give the both the xml file if needed.
--
Thanks
Vipul Borikar
"Our task must be to free ourselves...by widening our circle of compassion
to embrace all living creatures and the whole of nature and its beauty."
12 years, 7 months
[libvirt-users] Permission issue with cgroups
by Antonio Carlos Salzvedel Furtado Junior
Hello libvirt users,
I'm using the cgroup with QEMU guests. At /etc/libvirt/qemu.conf, I have
the following parameter:
cgroup_controllers = [ "cpu" ]
This controller is successfully mounted and libvirt is able to create
subgroups for each VM, it's really great the cgroups support in libvirt.
The problem is that I can only set the parameters of a given cgroup under
the cpu controller if I'm logged in as root. I want another user to have
that permission as well.
I tried to modify the file /etc/cgconfig.conf to change the permissions.
The file is exactly this:
group libvirt {
perm {
admin {
uid = opennebula;
gid = opennebula;
}
task {
uid = root;
gid = root;
}
}
cpu {
cpu.shares=512;
}
}
This configuration above does not seem to modify any of the administration
permissions. Only the root can edit the parameters under libvirt.
The cpu entry was added just to check whether this configuration was read
by cgroups at all. The 'cpu.shares' does change in group libvirt.
I was careful to start libvirt only after the service cgconfig was
restarted.
Thanks in advance,
Antonio Carlos Furtado
12 years, 7 months
[libvirt-users] libvirtd fails to start on f16 64bit
by Chad Roberts
Hello,
For quite some time, my libvirtd was working great. I came back today to fire-up a VM, but noticed that libvirtd was not running. When I try to start it, I get the following error...
libvirtd: symbol lookup error: libvirtd: undefined symbol: avahi_client_new
Can anyone shed some light on what my problem may be?
Thanks,
Chad
12 years, 7 months
[libvirt-users] segfault with libvirt-0.9.11.3-1
by ovirt@qip.ru
Hi, ALL
On fedora16 hosts with vdsm-4.9.6
after libvirtd daemon started in messages there are too many errors even if no one VM's running, and vdsmd not started
May 11 14:44:59 kvm02 kernel: [ 6670.207465] virsh[11015]: segfault at 38 ip 00007f047a52c535 sp 00007fffe3cb0e50 error 4 in libvirt.so.0.9.11[7f047a4bb000+2fd000]
May 11 14:44:59 kvm02 kernel: [ 6670.227244] virsh[11018]: segfault at 38 ip 00007f7afe3e6535 sp 00007fff41983d00 error 4 in libvirt.so.0.9.11[7f7afe375000+2fd000]
May 11 14:45:09 kvm02 kernel: [ 6680.662175] virsh[11201]: segfault at 38 ip 00007ffe6c129535 sp 00007fffa82c5720 error 4 in libvirt.so.0.9.11[7ffe6c0b8000+2fd000]
May 11 14:45:09 kvm02 kernel: [ 6680.679462] virsh[11204]: segfault at 38 ip 00007f9f3c596535 sp 00007fff7cc6c580 error 4 in libvirt.so.0.9.11[7f9f3c525000+2fd000]
May 11 14:45:09 kvm02 kernel: [ 6680.696003] virsh[11207]: segfault at 38 ip 00007fa06fb01535 sp 00007fff23cb2260 error 4 in libvirt.so.0.9.11[7fa06fa90000+2fd000]
May 11 14:45:09 kvm02 kernel: [ 6680.720678] virsh[11213]: segfault at 38 ip 00007fe557d0b535 sp 00007fff15262720 error 4 in libvirt.so.0.9.11[7fe557c9a000+2fd000]
May 11 14:45:09 kvm02 kernel: [ 6680.740552] virsh[11216]: segfault at 38 ip 00007f9dc1507535 sp 00007fff71795540 error 4 in libvirt.so.0.9.11[7f9dc1496000+2fd000]
May 11 14:45:20 kvm02 kernel: [ 6691.200793] virsh[11431]: segfault at 38 ip 00007f595f11e535 sp 00007fffc620f660 error 4 in libvirt.so.0.9.11[7f595f0ad000+2fd000]
May 11 14:45:20 kvm02 kernel: [ 6691.220691] virsh[11434]: segfault at 38 ip 00007fa843d8c535 sp 00007fff611a4d60 error 4 in libvirt.so.0.9.11[7fa843d1b000+2fd000]
May 11 14:45:20 kvm02 kernel: [ 6691.237276] virsh[11437]: segfault at 38 ip 00007f7ece215535 sp 00007fffe0d9ff60 error 4 in libvirt.so.0.9.11[7f7ece1a4000+2fd000]
May 11 14:45:20 kvm02 kernel: [ 6691.258537] virsh[11443]: segfault at 38 ip 00007f6bc89f2535 sp 00007fff95244620 error 4 in libvirt.so.0.9.11[7f6bc8981000+2fd000]
May 11 14:45:20 kvm02 kernel: [ 6691.278057] virsh[11446]: segfault at 38 ip 00007f4c16f36535 sp 00007fff35394480 error 4 in libvirt.so.0.9.11[7f4c16ec5000+2fd000]
May 11 14:45:31 kvm02 kernel: [ 6701.766999] virsh[11660]: segfault at 38 ip 00007f8b64ce7535 sp 00007fffac3014c0 error 4 in libvirt.so.0.9.11[7f8b64c76000+2fd000]
May 11 14:45:31 kvm02 kernel: [ 6701.786796] virsh[11663]: segfault at 38 ip 00007f6184ead535 sp 00007fff790ccd50 error 4 in libvirt.so.0.9.11[7f6184e3c000+2fd000]
May 11 14:45:31 kvm02 kernel: [ 6701.806817] virsh[11666]: segfault at 38 ip 00007f5aa114f535 sp 00007fffb3d06d60 error 4 in libvirt.so.0.9.11[7f5aa10de000+2fd000]
May 11 14:45:31 kvm02 kernel: [ 6701.831577] virsh[11672]: segfault at 38 ip 00007f2d6d123535 sp 00007fff3f45e820 error 4 in libvirt.so.0.9.11[7f2d6d0b2000+2fd000]
May 11 14:45:31 kvm02 kernel: [ 6701.851596] virsh[11675]: segfault at 38 ip 00007f8160f16535 sp 00007ffff211d210 error 4 in libvirt.so.0.9.11[7f8160ea5000+2fd000]
During compilation I saw this error
PASS: start
PASS: undefine
PASS: vcpupin
TEST: virsh-all
........................................ 40
........................................ 80
.../virsh-all: line 34: 14498 Segmentation fault $abs_top_builddir/tools/virsh -c $test_url $i < /dev/null > /dev/null 2>&1
...................................... 120
........................................ 160
............................ 188 OK
PASS: virsh-all
PASS: virsh-optparse
PASS: virsh-schedinfo
but compilation finished and all rpms were created
environment:
[root@kvm02 ~]# uname -a
Linux kvm02 3.3.4-3.fc16.x86_64 #1 SMP Thu May 3 14:46:44 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@kvm02 ~]# rpm -q qemu-kvm
qemu-kvm-0.15.1-4.fc16.x86_64
[root@kvm02 ~]# rpm -q libvirt
libvirt-0.9.11.3-1.fc16.x86_64
[root@kvm02 ~]# rpm -q vdsm
vdsm-4.9.6-0.163.git0633cd2.fc16.x86_64
How is it possible to correct this?
--
12 years, 7 months
[libvirt-users] listing active and defined vs inactive and defined domains
by John Wayne
i am trying to list active + defined and inactive + defined domains using libvirt 0.9.4
i can get active domains using:
def s_activedomains(conn):
#get active domain ids
numofdomains=libvirt.virConnect.numOfDomains(conn)
activedomains=libvirt.virConnect.listDomainsID(conn)
return activedomains
i am stuck on how to get inactive domains
the example listed here http://libvirt.org/guide/html/Application_Development_Guide-Guest_Do... under example 4.4 and example 4.5 seems to be outdated
looking at /usr/lib64/python2.6/site-packages/libvirt.py, line 2337 says that "Note that this won't work for inactive domains which have an ID of -1"
i think example 4.5 is wrong because if inactive domains have an id of -1, then i can't call virDomainLookupBy{Name,ID}
12 years, 7 months
[libvirt-users] Forward port 4444 to a static-IP VM
by Sean Abbott
I'm attempting to set up a selenium grid on virtual machines. The
default NAT is good enough for almost everything, but I need to be able
to send my hub VM requests on port 4444.
I've attempted to get this going by adding the following to my iptables
firewall:
-t nat -A PREROUTING -p tcp --dport 4444 -j DNAT --to-destination
192.168.122.107:4444
-t filter -A FORWARD -m state -d 192.168.122.107 --state
NEW,RELATED,ESTABLISHED -j ACCEPT
And...it's not working.
I can hit the port and make requests from the host.
Help, please?
Thanks!
sean
12 years, 7 months
[libvirt-users] serial console
by John Wayne
hi,
when creating a domain using libvirt python api, how would i tell libvirt to use a unique serial port number for domains?
in the libvirt.virConnect.defineXML(conn,domainxml) call when i create the domainxml object, i need to ensure that the part below has a unique # for target port
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
currently the domains running on hypervisors have target port numbers such as 1,2,3 and so on.
thanks
12 years, 7 months
[libvirt-users] virsh console logging and pty usage
by Doug Goldstein
Is it possible to both log the serial console and to actually use it?
A few of the VMs I've got are configured as follows:
<serial type='file'>
<source path='/var/log/libvirt/qemu/serial/bb-2.6.18-128.el5-x86_64.log'/>
<target port='0'/>
</serial>
<console type='file'>
<source path='/var/log/libvirt/qemu/serial/bb-2.6.18-128.el5-x86_64.log'/>
<target type='serial' port='0'/>
</console>
Because people are hoping to capture the logs after the fact to see if
there was any console output which could help them debug an issue.
However, if you need to connect to the console of the VM its
impossible (e.g. it needs the root password for a fsck).
Any suggestions to allow logging but allow it to be usable via "virsh
console" as well?
Thanks.
--
Doug Goldstein
12 years, 7 months