Re: [libvirt] Relax requirement of bridge source device

2008-11-20 Thread Daniel P. Berrange
On Wed, Nov 19, 2008 at 11:20:08PM -0700, Jim Fehlig wrote:
 Hi All,
 
 I wanted to get folks thoughts on relaxing the requirement for bridge 
 source device in network interface of domain XML, e.g. allowing
 
interface type=bridge
  mac address=aa:bb:cc:cc:ee:ff/
/interface
 
 Currently, virDomainNetDefParseXML() in src/domain_conf.c will fail such 
 configuration.  Since this is common code between backends I'm not sure 
 how allowing this config will affect the various virtualizers.
 
 Xen's vif-bridge script will try to find a bridge if one is not 
 specified, which perhaps is dubious behavior, but nonetheless convenient 
 in migration scenarios where the target host may have a different bridge 
 name (br1 vs br0 for example).  IIRC, qemu's qemu-ifup script is not as 
 forgiving in the absence of a bridge name.

I don't particularly like this idea. While letting it automatically
pick the bridge devices may happen to work in some cases, it'll 
quietly go wrong horribly in other scenarios. Xen's vif-bridge 
has caused real bugs through this behaviour even on a single machine.
eg, its happily automatically picking br0 for months, then someone
adds a new completely unrelated bridge to the machin, say br4, and
the next reboot vif-bridge suddenly decides it prefers br4 for your
guest.   I think it is not unreasonable in the case of migraiton to
require that the bridge names are configured the same on source and
destination machine, and explicitly including bridge names will let
apps using libvirt query the source  destination host before doing
migraiton and verify that br0 on the source is configured to use the
same network as br0 on the destination.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] SolidICE integration

2008-11-20 Thread Daniel P. Berrange
On Wed, Nov 19, 2008 at 01:50:09PM -0500, Shahar Frank wrote:
 Hi All, here is an initial version of the operations required for SolidICE
 and the proposed high level interface.
 
 I would like to discuss how to map it to libvirt calls and what libvirt
 calls are missing.
 
 Thanks,
 
 Shahar Frank
 
 HostLevel
 -
 enumarateLuns():
 return:
 returns all luns visible by the host.
 In case multipathing is enabled then only the multipath
 device should   be in the return list.

libvirt does not yet have support for SCSI FiberChannel, but it will
be added following this forthcoming release. libvirt's storage model
has two core concepts, a 'pool' object, which contains multiple
'volume' objects. There are different types of pool for each type of
storage, so we intend to add a 'scsi' storage pool.

The way it will work is that each SCSI HBA will be seen as its own
storage pool. The LUNs for a HBA will then be volumes within the 
pool.

So for enumerateLuns, a combination of API calls would be relevant.


 -  virConnectFindStoragePoolSources()  with a type='scsi'
 
will discover all available HBAs, and return XML describing
them. 

For each HBA you care about, you would define a storage pool
and active it using

  - virStoragePoolDefineXML()
  - virStoragePoolStart()

Then, for each storage pool you can get the list of LUNs by asking
for its volumes with

 - virStoragePoolListVolumes()

 enumerateISCSILuns(target):
 params:
 target - ISCSI target
 Description:
 enumerate all ISCSI luns on a specific target
 return:
 list of

This will work in exactly the same way as for SCIS, except that instead
of calling virConnectFindStoragePoolSources with type='scsi', you'd 
call it with type='iscsi'. You'd also need to give a 'srcSpec' XML
document with details of the host providing the iSCSI server. With this
libvirt will connect to the iSCSI server, and ask it for all its exported
iSCSI targets. The returned XML will provide details on each target.

For each target you wish to use, then you call virStoragePoolDefinXML
and virStoragePoolStart(), as before.


 getBlockInfo(name or UUID):
 return:
 at least uuid  size

Once you have  a virStorageVolPtr object, you can use the API

  virStorageVolGetInfo
 
this gives you logical capacity, and actual allocation - allocation
may be less than capacity if querying a file based volume like a
sparse file, or qcow2.

To get a persistent name, akin to a UUID, you can use the  API

  virStorageVolGetKey() 

for SCSI LUNS, the volume key will be based off the UUID avialable.

 enumerateVGs():
 return:
 VG UUID list

This is very similar to the other enumerate methods. You'd call

  virConnectFindStoragePoolSources() with type='logical'

this gives you back XML describing all available volume groups
on a machine. For each volume group you want to use, you can
then define a storage pool, and query volumes within it.

 open issues - should we assume ISCSI auto connect or FC login?

libvirt can take care of that when needed, which is why we have
a two step process for accessing a storage pool

 - virStoragePoolDefineXML()  will write out a persistent configuratipon
   file with details of the pool.

 - virStoragePoolCreate() will actually login to the iSCSI target,
   or activate the LVM volume group, or equivalent operations needed
   for the type of storage being accessed. NB 'Create' is probably
   better thought of as 'Start'

You can later call virStoragePoolDestroy() to logout if desired.

If you want login to happen automatically when the machine boots
you can call virStoragePoolSetAutostart() to turn on the autostart
flag.


Authentication is an open, unresolved issue  welcome suggestions
for how to deal with this.  Our original thoughts were to just
embed the iSCSI username/password in the XML configuration file
for the storage pool, but we've not implemented this in the backend
yet.

 StoragePool level
 -
 createVolumeGroup(name, devices):
 params:
 name = name
 devices - a list of UUIDs
 description:
 Should create a volume group out of the UUID list
 In case multipathing is enabled then only the multipath
 device  should be used
 In case it is not a PV yet then a PV is to be created.
 Return:
 Uuid of the VG

This is accomplished with a combination of two methods. First you
define the configuration for the pool, which requires giving the
volume group name, and list of devices to become PVs in the VG.
This is done with virStoragePoolDefineXML().

Then you actually format the PVs  construct the VG by invoking
the virStoragePoolBuild() method. Once this is done, the 
virStoragePoolCreate() method will activate the VG.

 
 removeVolumeGroup(VG):
 params:
 

Re: [libvirt] [PATCH] Xen Events Updated

2008-11-20 Thread Ben Guthro
I see a couple of issues with this patch that I am working out now

Apologies for premature submission.
(Thats what I get for submitting at the end of the day)

New patch to follow shortly

Ben Guthro wrote on 11/19/2008 05:47 PM:
 I finally was able to get back to this patch.
 
 Attached is a new version which detects which xend version it is running 
 under, and adjust appropriately.
 
  configure.in|   13 +
  include/libvirt/virterror.h |1
  po/POTFILES.in  |1
  src/Makefile.am |3
  src/virterror.c |3
  src/xen_inotify.c   |  456 
 
  src/xen_inotify.h   |   31 ++
  src/xen_unified.c   |  192 ++
  src/xen_unified.h   |   59 +
  src/xm_internal.c   |  196 +++---
  src/xs_internal.c   |  437 ++
  src/xs_internal.h   |   51 
  12 files changed, 1367 insertions(+), 76 deletions(-)
 

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] libvirt equivalent config for a kvm command line

2008-11-20 Thread Rajkumar S
Hi,

I had been running kvm in a previous version of Ubuntu with the
following command line:

 /usr/bin/kvm
-hda /mnt/kvm/vm-images-work/nanobsd.img
-net nic,vlan=26,macaddr=52:54:00:12:34:26 -net tap,vlan=26,ifname=tap26
-net nic,vlan=27,macaddr=52:54:00:12:34:27 -net tap,vlan=27,ifname=tap27
-net nic,vlan=28,macaddr=52:54:00:12:34:28 -net tap,vlan=28,ifname=tap28
-m 640 -vnc :26 -usbdevice tablet

The vm shows couple if lines in console and then redirects rest of the
output to serial console. I can see that in ctrl-alt-3 of vncviewer
ctrl-alt-2 gives access to emulation console and 4 gives access to
parallel console.

After upgrading to latest Intrepid Ibex I decided to move to using
virsh to manage my vms. For the above vm I am using the following xml
file.

domain type='kvm'
  namenanobsd/name
  memory262144/memory
  currentMemory262144/currentMemory
  vcpu1/vcpu
  os
typehvm/type
boot dev='hd'/
  /os
  features
acpi/
  /features
  clock offset='localtime'/
  on_poweroffdestroy/on_poweroff
  on_rebootrestart/on_reboot
  on_crashdestroy/on_crash
  devices
emulator/usr/bin/kvm/emulator
disk type='file' device='disk'
  source file='/mnt/kvm/vm-images-work/nanotest.img'/
  target dev='hda' bus='ide'/
/disk
interface type='bridge'
  mac address='52:54:00:12:34:31'/
  source bridge='br0'/
/interface
interface type='bridge'
  mac address='52:54:00:12:34:32'/
  source bridge='br0'/
/interface
interface type='bridge'
  mac address='52:54:00:12:34:33'/
  source bridge='br0'/
/interface
serial type='vc'
  target port='2'/
/serial
console type='pty'
  target port='0'/
/console
input type='mouse' bus='ps2'/
graphics type='vnc' port='5931' listen='192.168.3.3'/
  /devices
/domain

Which produces the following command line.

 /usr/bin/kvm -S -M pc -m 256 -smp 1 -name nanobsd -monitor pty
-localtime -boot c
-drive file=/mnt/kvm/vm-images-work/nanotest.img,if=ide,index=0,boot=on
-net nic,macaddr=52:54:00:12:34:31,vlan=0 -net
tap,fd=28,script=,vlan=0,ifname=vnet5
-net nic,macaddr=52:54:00:12:34:32,vlan=1 -net
tap,fd=29,script=,vlan=1,ifname=vnet6
-net nic,macaddr=52:54:00:12:34:33,vlan=2 -net
tap,fd=30,script=,vlan=2,ifname=vnet7
-serial vc -parallel none -usb -vnc  192.168.3.3:31

Problem with this configuration is that the screen freezes after
couple of minuets of booting, I am not sure if this is the problem
with the serial console or actual execution. I can see the serial
console in ctrl-alt-2, but the window size changes. The image works
perfectly in normal PC as well as if I use the previous command line.
I guess I am missing some thing here, but I would be very happy if I
can get the old behaviour back :)

raj

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt equivalent config for a kvm command line

2008-11-20 Thread Cole Robinson
Rajkumar S wrote:
 Hi,
 
 I had been running kvm in a previous version of Ubuntu with the
 following command line:
 
  /usr/bin/kvm
 -hda /mnt/kvm/vm-images-work/nanobsd.img
 -net nic,vlan=26,macaddr=52:54:00:12:34:26 -net tap,vlan=26,ifname=tap26
 -net nic,vlan=27,macaddr=52:54:00:12:34:27 -net tap,vlan=27,ifname=tap27
 -net nic,vlan=28,macaddr=52:54:00:12:34:28 -net tap,vlan=28,ifname=tap28
 -m 640 -vnc :26 -usbdevice tablet
 

snip

 
 Which produces the following command line.
 
  /usr/bin/kvm -S -M pc -m 256 -smp 1 -name nanobsd -monitor pty
 -localtime -boot c
 -drive file=/mnt/kvm/vm-images-work/nanotest.img,if=ide,index=0,boot=on
 -net nic,macaddr=52:54:00:12:34:31,vlan=0 -net
 tap,fd=28,script=,vlan=0,ifname=vnet5
 -net nic,macaddr=52:54:00:12:34:32,vlan=1 -net
 tap,fd=29,script=,vlan=1,ifname=vnet6
 -net nic,macaddr=52:54:00:12:34:33,vlan=2 -net
 tap,fd=30,script=,vlan=2,ifname=vnet7
 -serial vc -parallel none -usb -vnc  192.168.3.3:31
 
 Problem with this configuration is that the screen freezes after
 couple of minuets of booting, I am not sure if this is the problem
 with the serial console or actual execution. I can see the serial
 console in ctrl-alt-2, but the window size changes. The image works
 perfectly in normal PC as well as if I use the previous command line.
 I guess I am missing some thing here, but I would be very happy if I
 can get the old behaviour back :)
 

Could be memory related: previous config had 640 Mb, new config only has
256.

If that isn't the issue, I'd say just boot the new kvm command directly,
and remove pieces to see if there is a blatant culprit: ex. revert the
-drive line to use -hda, try with 0/1/2 nics, etc.

- Cole

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt equivalent config for a kvm command line

2008-11-20 Thread Daniel P. Berrange
On Thu, Nov 20, 2008 at 09:27:58AM -0500, Cole Robinson wrote:
 Rajkumar S wrote:
  Hi,
  
  I had been running kvm in a previous version of Ubuntu with the
  following command line:
  
   /usr/bin/kvm
  -hda /mnt/kvm/vm-images-work/nanobsd.img
  -net nic,vlan=26,macaddr=52:54:00:12:34:26 -net tap,vlan=26,ifname=tap26
  -net nic,vlan=27,macaddr=52:54:00:12:34:27 -net tap,vlan=27,ifname=tap27
  -net nic,vlan=28,macaddr=52:54:00:12:34:28 -net tap,vlan=28,ifname=tap28
  -m 640 -vnc :26 -usbdevice tablet
  
 
 snip
 
  
  Which produces the following command line.
  
   /usr/bin/kvm -S -M pc -m 256 -smp 1 -name nanobsd -monitor pty
  -localtime -boot c
  -drive file=/mnt/kvm/vm-images-work/nanotest.img,if=ide,index=0,boot=on
  -net nic,macaddr=52:54:00:12:34:31,vlan=0 -net
  tap,fd=28,script=,vlan=0,ifname=vnet5
  -net nic,macaddr=52:54:00:12:34:32,vlan=1 -net
  tap,fd=29,script=,vlan=1,ifname=vnet6
  -net nic,macaddr=52:54:00:12:34:33,vlan=2 -net
  tap,fd=30,script=,vlan=2,ifname=vnet7
  -serial vc -parallel none -usb -vnc  192.168.3.3:31
  
  Problem with this configuration is that the screen freezes after
  couple of minuets of booting, I am not sure if this is the problem
  with the serial console or actual execution. I can see the serial
  console in ctrl-alt-2, but the window size changes. The image works
  perfectly in normal PC as well as if I use the previous command line.
  I guess I am missing some thing here, but I would be very happy if I
  can get the old behaviour back :)
  
 
 Could be memory related: previous config had 640 Mb, new config only has
 256.

Yes, that'd be my first thought too.

 
 If that isn't the issue, I'd say just boot the new kvm command directly,
 and remove pieces to see if there is a blatant culprit: ex. revert the
 -drive line to use -hda, try with 0/1/2 nics, etc.

My 2nd bet would be the serial port - worth removing that from the config
because I know there's been QEMU bugs with serial ports before.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt equivalent config for a kvm command line

2008-11-20 Thread Rajkumar S
On Thu, Nov 20, 2008 at 7:57 PM, Cole Robinson [EMAIL PROTECTED] wrote:

 If that isn't the issue, I'd say just boot the new kvm command directly,
 and remove pieces to see if there is a blatant culprit: ex. revert the
 -drive line to use -hda, try with 0/1/2 nics, etc.

I will try this, thanks :)

raj

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] --with-xen=foo

2008-11-20 Thread Ben Guthro
So, when I merged my changes up yesterday to some of the developments going on, 
it would seem that one of the changesets I pulled in had a bit of a reduction 
in configure flexibility.

I'm not yet sure what changeset caused it...but I used to be able to specify an 
external xen tree with the following line in a Makefile...

./autogen.sh --prefix=/usr --with-xen=$(XEN_SRC)/dist/install/usr

This now seems to fail to find that xen tree, as I error out with:

 gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../gnulib/lib -I../gnulib/lib -I../include 
-I../include -I../qemud -I/usr/include/libxml2 -DBINDIR=\/usr/libexec\ 
-DSBINDIR=\/usr/sbin\ -DSYSCONF_DIR=\/etc\ 
-DLOCALEBASEDIR=\/usr/share/locale\ -DLOCAL_STATE_DIR=\/var\ 
-DGETTEXT_PACKAGE=\libvirt\ -Wall -Wformat -Wformat-security 
-Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow 
-Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline 
-Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
-fasynchronous-unwind-tables -g -O2 -MT stats_linux.lo -MD -MP -MF 
.deps/stats_linux.Tpo -c stats_linux.c  -fPIC -DPIC -o .libs/stats_linux.o
stats_linux.c:24:16: error: xs.h: No such file or directory
stats_linux.c: In function 'check_bd_connected':
stats_linux.c:154: warning: implicit declaration of function 'xs_read'
stats_linux.c:154: warning: nested extern declaration of 'xs_read'
stats_linux.c:154: warning: assignment makes pointer from integer without a cast


I assume this has something to do with Daniel B's changes to configure scripts 
recently.

Could you give me a pointer as to where I should be looking?

Ben

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] libvirt equivalent config for a kvm command line

2008-11-20 Thread Rajkumar S
On Thu, Nov 20, 2008 at 8:01 PM, Daniel P. Berrange [EMAIL PROTECTED] wrote:
 My 2nd bet would be the serial port - worth removing that from the config
 because I know there's been QEMU bugs with serial ports before.

Serial could be the issue, I have other vms (normal linux and freebsd)
running in the same box with out any problems. This image has console
in serial. So having serial support is essential. It might be possible
that the machine is running perfectly but the serial console is
frozen.

i had gone through the xml documentation but could not understand the
serial configuration. If some one has an xml fragment for the serial
behavour of my original kvm command line (0 - monitor, 1 - interactive
shell of kvm, 2 - serial0, 3 paralell0) that would be great.

raj

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] --with-xen=foo

2008-11-20 Thread Ben Guthro
I did a git bisect, and as predicted, the culprit seems to be

aac3e1ab15645f1ff491b140ddb249b01397bebd is first bad commit
commit aac3e1ab15645f1ff491b140ddb249b01397bebd 
Author: Daniel P. Berrange [EMAIL PROTECTED]
Date:   Mon Nov 17 10:43:30 2008 +  

Build drivers as libtool convenience libs


Once again, I am faced with my ignorance of how automake magic works.

It looks to me like XEN_CFLAGS is set properly...but clearly they are not being 
passed on while compiling stats_linux.c





Ben Guthro wrote on 11/20/2008 09:48 AM:
 So, when I merged my changes up yesterday to some of the developments going 
 on, it would seem that one of the changesets I pulled in had a bit of a 
 reduction in configure flexibility.
 
 I'm not yet sure what changeset caused it...but I used to be able to specify 
 an external xen tree with the following line in a Makefile...
 
 ./autogen.sh --prefix=/usr --with-xen=$(XEN_SRC)/dist/install/usr
 
 This now seems to fail to find that xen tree, as I error out with:
 
  gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../gnulib/lib -I../gnulib/lib 
 -I../include -I../include -I../qemud -I/usr/include/libxml2 
 -DBINDIR=\/usr/libexec\ -DSBINDIR=\/usr/sbin\ -DSYSCONF_DIR=\/etc\ 
 -DLOCALEBASEDIR=\/usr/share/locale\ -DLOCAL_STATE_DIR=\/var\ 
 -DGETTEXT_PACKAGE=\libvirt\ -Wall -Wformat -Wformat-security 
 -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow 
 -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline 
 -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
 -fasynchronous-unwind-tables -g -O2 -MT stats_linux.lo -MD -MP -MF 
 .deps/stats_linux.Tpo -c stats_linux.c  -fPIC -DPIC -o .libs/stats_linux.o
 stats_linux.c:24:16: error: xs.h: No such file or directory
 stats_linux.c: In function 'check_bd_connected':
 stats_linux.c:154: warning: implicit declaration of function 'xs_read'
 stats_linux.c:154: warning: nested extern declaration of 'xs_read'
 stats_linux.c:154: warning: assignment makes pointer from integer without a 
 cast
 
 
 I assume this has something to do with Daniel B's changes to configure 
 scripts recently.
 
 Could you give me a pointer as to where I should be looking?
 
 Ben
 
 --
 Libvir-list mailing list
 Libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] --with-xen=foo

2008-11-20 Thread Daniel P. Berrange
On Thu, Nov 20, 2008 at 10:46:25AM -0500, Ben Guthro wrote:
 I did a git bisect, and as predicted, the culprit seems to be
 
 aac3e1ab15645f1ff491b140ddb249b01397bebd is first bad commit
 commit aac3e1ab15645f1ff491b140ddb249b01397bebd 
 Author: Daniel P. Berrange [EMAIL PROTECTED]
 Date:   Mon Nov 17 10:43:30 2008 +  
 
 Build drivers as libtool convenience libs
 
 
 Once again, I am faced with my ignorance of how automake 
 magic works.
 
 It looks to me like XEN_CFLAGS is set properly...but clearly 
 they are not being passed on while compiling stats_linux.c

Argggh. I didn't notice that stats_linux.c had Xen specific
code in it :-(  When I did the refactoring, it changed so
that XEN_CFLAGS/LDFLAGS is only used for the Xen driver code

As a quick workaround, edit the line for

  libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT

to add  $(XEN_CFLAGS)


Meanwhile I'll figure out  why stats_linux.c needs Xen, and move the Xen
specific bit into the Xen driver.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] make install doesn't install to /usr/lib64

2008-11-20 Thread Kenneth Nagin

I am working on a x86_64 machine.  I expected 'make install' to install to
libvirt.so to /usr/lib64.  But it installs to /usr/lib.  Is this a bug or
is it the expected behavior?

Kenneth Nagin



--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] make install doesn't install to /usr/lib64

2008-11-20 Thread Daniel Berrange
On Thu, Nov 20, 2008 at 07:32:56PM +0200, Kenneth Nagin wrote:
 
 I am working on a x86_64 machine.  I expected 'make install' to install to
 libvirt.so to /usr/lib64.  But it installs to /usr/lib.  Is this a bug or
 is it the expected behavior?

That is a distro specific policy, whcih varies from autoconf policy.
So to make it follow the distro policy yuou must supply an explicit
arg to configure,  --libdir=/usr/lib64

As an example, RPM does this automatically if you use the %configure macro,
but if you're doing builds by hand you must add whatever args are needed

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] PATCH: 0/7: Final node device patches to be committed

2008-11-20 Thread Daniel P. Berrange
FYI, this is a repost of the final node device patches I intend to
commit tomorrow. There's a few changes based on Mark's feedback
which  I'll note against each patch...

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 1/7: Public API

2008-11-20 Thread Daniel P. Berrange
This patch contains the public API for node devices. Changes since last
post are

 - Remove the ByCap methods - the main list method now takes an optionally
   NULL, cap arguent. This simplified virsh usage later too which is nice

 - Change VIR_FROM_DEVMONITOR to VIR_FROM_NODEDEV to match rest of public
   naming scheme

 - Remove unused NodeDeviceCreate/Destroy methods. We can re-add them
   when we need them

Daniel

diff -r 2e1f852dff74 include/libvirt/libvirt.h
--- a/include/libvirt/libvirt.h Wed Nov 19 18:00:40 2008 +
+++ b/include/libvirt/libvirt.h Thu Nov 20 17:43:17 2008 +
@@ -995,6 +995,59 @@
  unsigned int flags);
 
 /*
+ * Host device enumeration
+ */
+
+/**
+ * virNodeDevice:
+ *
+ * A virNodeDevice contains a node (host) device details.
+ */
+
+typedef struct _virNodeDevice virNodeDevice;
+
+/**
+ * virNodeDevicePtr:
+ *
+ * A virNodeDevicePtr is a pointer to a virNodeDevice structure.  Get
+ * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or
+ * virNodeDeviceCreate.  Be sure to Call virNodeDeviceFree when done
+ * using a virNodeDevicePtr obtained from any of the above functions to
+ * avoid leaking memory.
+ */
+
+typedef virNodeDevice *virNodeDevicePtr;
+
+
+int virNodeNumOfDevices (virConnectPtr conn,
+ const char *cap,
+ unsigned int flags);
+
+int virNodeListDevices  (virConnectPtr conn,
+ const char *cap,
+ char **const names,
+ int maxnames,
+ unsigned int flags);
+
+virNodeDevicePtrvirNodeDeviceLookupByName (virConnectPtr conn,
+   const char *name);
+
+const char *virNodeDeviceGetName (virNodeDevicePtr dev);
+
+const char *virNodeDeviceGetParent   (virNodeDevicePtr dev);
+
+int virNodeDeviceNumOfCaps   (virNodeDevicePtr dev);
+
+int virNodeDeviceListCaps(virNodeDevicePtr dev,
+  char **const names,
+  int maxnames);
+
+char *  virNodeDeviceGetXMLDesc (virNodeDevicePtr dev,
+ unsigned int flags);
+
+int virNodeDeviceFree   (virNodeDevicePtr dev);
+
+/*
  * Domain Event Notification
  */
 
diff -r 2e1f852dff74 include/libvirt/libvirt.h.in
--- a/include/libvirt/libvirt.h.in  Wed Nov 19 18:00:40 2008 +
+++ b/include/libvirt/libvirt.h.in  Thu Nov 20 17:43:17 2008 +
@@ -995,6 +995,59 @@
  unsigned int flags);
 
 /*
+ * Host device enumeration
+ */
+
+/**
+ * virNodeDevice:
+ *
+ * A virNodeDevice contains a node (host) device details.
+ */
+
+typedef struct _virNodeDevice virNodeDevice;
+
+/**
+ * virNodeDevicePtr:
+ *
+ * A virNodeDevicePtr is a pointer to a virNodeDevice structure.  Get
+ * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or
+ * virNodeDeviceCreate.  Be sure to Call virNodeDeviceFree when done
+ * using a virNodeDevicePtr obtained from any of the above functions to
+ * avoid leaking memory.
+ */
+
+typedef virNodeDevice *virNodeDevicePtr;
+
+
+int virNodeNumOfDevices (virConnectPtr conn,
+ const char *cap,
+ unsigned int flags);
+
+int virNodeListDevices  (virConnectPtr conn,
+ const char *cap,
+ char **const names,
+ int maxnames,
+ unsigned int flags);
+
+virNodeDevicePtrvirNodeDeviceLookupByName (virConnectPtr conn,
+   const char *name);
+
+const char *virNodeDeviceGetName (virNodeDevicePtr dev);
+
+const char *virNodeDeviceGetParent   (virNodeDevicePtr dev);
+
+int virNodeDeviceNumOfCaps   (virNodeDevicePtr dev);
+
+int virNodeDeviceListCaps(virNodeDevicePtr dev,
+  char **const names,
+  int maxnames);
+
+char *  virNodeDeviceGetXMLDesc (virNodeDevicePtr dev,
+ unsigned int flags);
+
+int virNodeDeviceFree   (virNodeDevicePtr dev);
+
+/*
  * Domain Event Notification
  */
 
diff -r 2e1f852dff74 include/libvirt/virterror.h
--- 

Re: [libvirt] PATCH: 2/7: Internal API framework

2008-11-20 Thread Daniel P. Berrange
This is primarily the internal  XML handling for node devices
Changes since last time

 - Remove the duplicate mac address information 
 - Remove unused 'originating_device'

Daniel

diff -r 28bfbe4fa22f src/Makefile.am
--- a/src/Makefile.am   Thu Nov 20 17:37:11 2008 +
+++ b/src/Makefile.am   Thu Nov 20 17:43:01 2008 +
@@ -136,6 +136,10 @@
storage_driver.h storage_driver.c   \
storage_backend.h storage_backend.c
 
+# Network driver generic impl APIs
+NODE_DEVICE_CONF_SOURCES = \
+   node_device_conf.c node_device_conf.h
+
 STORAGE_DRIVER_FS_SOURCES =\
storage_backend_fs.h storage_backend_fs.c
 
@@ -171,7 +175,8 @@
$(DRIVER_SOURCES)   \
$(DOMAIN_CONF_SOURCES)  \
$(NETWORK_CONF_SOURCES) \
-   $(STORAGE_CONF_SOURCES)
+   $(STORAGE_CONF_SOURCES) \
+   $(NODE_DEVICE_CONF_SOURCES)
 
 if WITH_TEST
 if WITH_DRIVER_MODULES
diff -r 28bfbe4fa22f src/node_device_conf.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/src/node_device_conf.cThu Nov 20 17:43:01 2008 +
@@ -0,0 +1,404 @@
+/*
+ * node_device_conf.c: config handling for node devices
+ *
+ * Copyright (C) 2008 Virtual Iron Software, Inc.
+ * Copyright (C) 2008 David F. Lively
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: David F. Lively [EMAIL PROTECTED]
+ */
+
+#include config.h
+
+#include unistd.h
+#include errno.h
+
+#include virterror_internal.h
+#include memory.h
+
+#include node_device_conf.h
+#include memory.h
+#include xml.h
+#include util.h
+#include buf.h
+#include uuid.h
+
+
+VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
+  system,
+  pci,
+  usb_device,
+  usb,
+  net,
+  block,
+  scsi_host,
+  scsi,
+  storage);
+
+VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
+  80203,
+  80211);
+
+
+#define virNodeDeviceLog(msg...) fprintf(stderr, msg)
+
+virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs,
+const char *name)
+{
+unsigned int i;
+
+for (i = 0; i  devs-count; i++)
+if (STREQ(devs-objs[i]-def-name, name))
+return devs-objs[i];
+
+return NULL;
+}
+
+
+void virNodeDeviceDefFree(virNodeDeviceDefPtr def)
+{
+virNodeDevCapsDefPtr caps;
+
+if (!def)
+return;
+
+VIR_FREE(def-name);
+VIR_FREE(def-parent);
+
+caps = def-caps;
+while (caps) {
+virNodeDevCapsDefPtr next = caps-next;
+virNodeDevCapsDefFree(caps);
+caps = next;
+}
+
+VIR_FREE(def);
+}
+
+void virNodeDeviceObjFree(virNodeDeviceObjPtr dev)
+{
+if (!dev)
+return;
+
+virNodeDeviceDefFree(dev-def);
+if (dev-privateFree)
+(*dev-privateFree)(dev-privateData);
+
+VIR_FREE(dev);
+}
+
+void virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs)
+{
+unsigned int i;
+for (i = 0 ; i  devs-count ; i++)
+virNodeDeviceObjFree(devs-objs[i]);
+VIR_FREE(devs-objs);
+devs-count = 0;
+}
+
+virNodeDeviceObjPtr virNodeDeviceAssignDef(virConnectPtr conn,
+   virNodeDeviceObjListPtr devs,
+   const virNodeDeviceDefPtr def)
+{
+virNodeDeviceObjPtr device;
+
+if ((device = virNodeDeviceFindByName(devs, def-name))) {
+virNodeDeviceDefFree(device-def);
+device-def = def;
+return device;
+}
+
+if (VIR_ALLOC(device)  0) {
+virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+return NULL;
+}
+
+device-def = def;
+
+if (VIR_REALLOC_N(devs-objs, devs-count+1)  0) {
+device-def = NULL;
+virNodeDeviceObjFree(device);
+virNodeDeviceReportError(conn, VIR_ERR_NO_MEMORY, NULL);
+return NULL;
+}
+devs-objs[devs-count++] = device;
+
+return device;
+
+}
+
+void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs,
+  

Re: [libvirt] PATCH: 3/7: Main HAL DeviceKit impl

2008-11-20 Thread Daniel P. Berrange

The internal impl for HAL and devicekit

Changes since last time

 - Fix broken logic in devicekit NIC interfac checks
 - Disable DeviceKit by default

Daniel

diff -r c51d78efb84a configure.in
--- a/configure.in  Thu Nov 20 17:43:18 2008 +
+++ b/configure.in  Thu Nov 20 17:47:42 2008 +
@@ -1105,6 +1105,108 @@
 LV_LIBTOOL_OBJDIR=${lt_cv_objdir-.}
 AC_SUBST([LV_LIBTOOL_OBJDIR])
 
+dnl HAL or DeviceKit library for host device enumeration
+HAL_REQUIRED=0.0
+HAL_CFLAGS=
+HAL_LIBS=
+AC_ARG_WITH([hal],
+  [  --with-hal use HAL for host device enumeration],
+  [],
+  [with_hal=check])
+
+if test $with_libvirtd = no ; then
+  with_hal=no
+fi
+if test x$with_hal = xyes -o x$with_hal = xcheck; then
+  PKG_CHECK_MODULES(HAL, hal = $HAL_REQUIRED,
+[with_hal=yes], [
+if test x$with_hal = xcheck ; then
+   with_hal=no
+else
+   AC_MSG_ERROR(
+ [You must install hal-devel = $HAL_REQUIRED to compile libvirt])
+fi
+  ])
+  if test x$with_hal = xyes ; then
+AC_DEFINE_UNQUOTED([HAVE_HAL], 1,
+  [use HAL for host device enumeration])
+
+old_CFLAGS=$CFLAGS
+old_LDFLAGS=$LDFLAGS
+CFLAGS=$CFLAGS $HAL_CFLAGS
+LDFLAGS=$LDFLAGS $HAL_LIBS
+AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no])
+CFLAGS=$old_CFLAGS
+LDFLAGS=$old_LDFLAGS
+  fi
+fi
+AM_CONDITIONAL([HAVE_HAL], [test x$with_hal = xyes])
+AC_SUBST([HAL_CFLAGS])
+AC_SUBST([HAL_LIBS])
+
+DEVKIT_REQUIRED=0.0
+DEVKIT_CFLAGS=
+DEVKIT_LIBS=
+AC_ARG_WITH([devkit],
+  [  --with-devkit  use DeviceKit for host device enumeration],
+  [],
+  [with_devkit=no])
+
+if test $with_libvirtd = no ; then
+  with_devkit=no
+fi
+
+dnl Extra check needed while devkit pkg-config info missing glib2 dependency
+PKG_CHECK_MODULES(GLIB2, glib-2.0 = 0.0,,[
+  if test x$with_devkit = xcheck; then
+with_devkit=no
+  elif test x$with_devkit = xyes; then
+AC_MSG_ERROR([required package DeviceKit requires package glib-2.0])
+  fi])
+
+if test x$with_devkit = xyes -o x$with_devkit = xcheck; then
+  PKG_CHECK_MODULES(DEVKIT, devkit-gobject = $DEVKIT_REQUIRED,
+[with_devkit=yes], [
+if test x$with_devkit = xcheck ; then
+   with_devkit=no
+else
+   AC_MSG_ERROR(
+ [You must install DeviceKit-devel = $DEVKIT_REQUIRED to compile 
libvirt])
+fi
+  ])
+  if test x$with_devkit = xyes ; then
+AC_DEFINE_UNQUOTED([HAVE_DEVKIT], 1,
+  [use DeviceKit for host device enumeration])
+
+dnl Add glib2 flags explicitly while devkit pkg-config info missing glib2 
dependency
+DEVKIT_CFLAGS=$GLIB2_CFLAGS $DEVKIT_CFLAGS
+DEVKIT_LIBS=$GLIB2_LIBS $DEVKIT_LIBS
+
+dnl Add more flags apparently required for devkit to work properly
+DEVKIT_CFLAGS=$DEVKIT_CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
+
+old_CFLAGS=$CFLAGS
+old_LDFLAGS=$LDFLAGS
+CFLAGS=$CFLAGS $DEVKIT_CFLAGS
+LDFLAGS=$LDFLAGS $DEVKIT_LIBS
+AC_CHECK_FUNCS([devkit_client_connect],,[with_devkit=no])
+CFLAGS=$old_CFLAGS
+LDFLAGS=$old_LDFLAGS
+  fi
+fi
+AM_CONDITIONAL([HAVE_DEVKIT], [test x$with_devkit = xyes])
+AC_SUBST([DEVKIT_CFLAGS])
+AC_SUBST([DEVKIT_LIBS])
+
+with_nodedev=no;
+if test $with_devkit = yes -o $with_hal = yes;
+then
+  with_nodedev=yes
+  AC_DEFINE_UNQUOTED([WITH_NODE_DEVICES], 1, [with node device driver])
+fi
+AM_CONDITIONAL([WITH_NODE_DEVICES], [test $with_nodedev = yes])
+
+
 # very annoying
 rm -f COPYING
 cp COPYING.LIB COPYING
@@ -1196,6 +1298,16 @@
 else
 AC_MSG_NOTICE([  xen: no])
 fi
+if test $with_hal = yes ; then
+AC_MSG_NOTICE([  hal: $HAL_CFLAGS $HAL_LIBS])
+else
+AC_MSG_NOTICE([  hal: no])
+fi
+if test $with_devkit = yes ; then
+AC_MSG_NOTICE([  devkit: $DEVKIT_CFLAGS $DEVKIT_LIBS])
+else
+AC_MSG_NOTICE([  devkit: no])
+fi
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Test suite])
 AC_MSG_NOTICE([])
diff -r c51d78efb84a po/POTFILES.in
--- a/po/POTFILES.inThu Nov 20 17:43:18 2008 +
+++ b/po/POTFILES.inThu Nov 20 17:47:42 2008 +
@@ -13,6 +13,7 @@
 src/lxc_driver.c
 src/network_conf.c
 src/network_driver.c
+src/node_device.c
 src/openvz_conf.c
 src/openvz_driver.c
 src/proxy_internal.c
diff -r c51d78efb84a qemud/Makefile.am
--- a/qemud/Makefile.am Thu Nov 20 17:43:18 2008 +
+++ b/qemud/Makefile.am Thu Nov 20 17:47:42 2008 +
@@ -111,6 +111,10 @@
 if WITH_NETWORK
 libvirtd_LDADD += ../src/libvirt_driver_network.la
 endif
+
+if WITH_NODE_DEVICES
+libvirtd_LDADD += ../src/libvirt_driver_nodedev.la
+endif
 endif
 
 libvirtd_LDADD += ../src/libvirt.la
diff -r c51d78efb84a qemud/qemud.c
--- a/qemud/qemud.c Thu Nov 20 17:43:18 2008 +
+++ b/qemud/qemud.c Thu Nov 20 17:47:42 2008 +
@@ -78,6 +78,9 @@
 #endif
 #ifdef WITH_STORAGE_DIR
 #include storage_driver.h
+#endif
+#ifdef WITH_NODE_DEVICES
+#include node_device.h
 #endif
 #endif
 
@@ -763,6 +766,7 @@
 virDriverLoadModule(uml);
 virDriverLoadModule(network);
 virDriverLoadModule(storage);
+virDriverLoadModule(nodedev);
 #else
 #ifdef WITH_QEMU
 qemuRegister();

Re: [libvirt] PATCH: 4/7: Remove driver API calls

2008-11-20 Thread Daniel P. Berrange
This provides the remote driver implementation for node device APIs

This is basically just fixing up to add the optional 'cap' arg
to the List methods, and remove the Create/Destroy/ByCap methods

Daniel

diff -r acc38454f32d qemud/remote.c
--- a/qemud/remote.cThu Nov 20 16:16:37 2008 +
+++ b/qemud/remote.cThu Nov 20 16:26:13 2008 +
@@ -67,6 +67,7 @@
 static void make_nonnull_network (remote_nonnull_network *net_dst, 
virNetworkPtr net_src);
 static void make_nonnull_storage_pool (remote_nonnull_storage_pool *pool_dst, 
virStoragePoolPtr pool_src);
 static void make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, 
virStorageVolPtr vol_src);
+static void make_nonnull_node_device (remote_nonnull_node_device *dev_dst, 
virNodeDevicePtr dev_src);
 
 #include remote_dispatch_prototypes.h
 
@@ -3723,6 +3724,213 @@
 }
 
 
+/***
+ * NODE INFO APIS
+ **/
+
+static int
+remoteDispatchNodeNumOfDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
+struct qemud_client *client,
+remote_message_header *req,
+remote_node_num_of_devices_args *args,
+remote_node_num_of_devices_ret *ret)
+{
+CHECK_CONN(client);
+
+ret-num = virNodeNumOfDevices (client-conn,
+args-cap ? *args-cap : NULL,
+args-flags);
+if (ret-num == -1) return -1;
+
+return 0;
+}
+
+
+static int
+remoteDispatchNodeListDevices (struct qemud_server *server ATTRIBUTE_UNUSED,
+   struct qemud_client *client,
+   remote_message_header *req,
+   remote_node_list_devices_args *args,
+   remote_node_list_devices_ret *ret)
+{
+CHECK_CONN(client);
+
+if (args-maxnames  REMOTE_NODE_DEVICE_NAME_LIST_MAX) {
+remoteDispatchError (client, req,
+ %s, _(maxnames  
REMOTE_NODE_DEVICE_NAME_LIST_MAX));
+return -2;
+}
+
+/* Allocate return buffer. */
+if (VIR_ALLOC_N(ret-names.names_val, args-maxnames)  0) {
+remoteDispatchSendError(client, req, VIR_ERR_NO_MEMORY, NULL);
+return -2;
+}
+
+ret-names.names_len =
+virNodeListDevices (client-conn,
+args-cap ? *args-cap : NULL,
+ret-names.names_val, args-maxnames, args-flags);
+if (ret-names.names_len == -1) {
+VIR_FREE(ret-names.names_val);
+return -1;
+}
+
+return 0;
+}
+
+
+static int
+remoteDispatchNodeDeviceLookupByName (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+  struct qemud_client *client,
+  remote_message_header *req,
+  remote_node_device_lookup_by_name_args 
*args,
+  remote_node_device_lookup_by_name_ret 
*ret)
+{
+virNodeDevicePtr dev;
+
+CHECK_CONN(client);
+
+dev = virNodeDeviceLookupByName (client-conn, args-name);
+if (dev == NULL) return -1;
+
+make_nonnull_node_device (ret-dev, dev);
+virNodeDeviceFree(dev);
+return 0;
+}
+
+
+static int
+remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client,
+ remote_message_header *req,
+ remote_node_device_dump_xml_args *args,
+ remote_node_device_dump_xml_ret *ret)
+{
+virNodeDevicePtr dev;
+CHECK_CONN(client);
+
+dev = virNodeDeviceLookupByName(client-conn, args-name);
+if (dev == NULL) {
+remoteDispatchError (client, req, %s, _(node_device not found));
+return -2;
+}
+
+/* remoteDispatchClientRequest will free this. */
+ret-xml = virNodeDeviceGetXMLDesc (dev, args-flags);
+if (!ret-xml) {
+virNodeDeviceFree(dev);
+return -1;
+}
+virNodeDeviceFree(dev);
+return 0;
+}
+
+
+static int
+remoteDispatchNodeDeviceGetParent (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+   struct qemud_client *client,
+   remote_message_header *req,
+   remote_node_device_get_parent_args *args,
+   remote_node_device_get_parent_ret *ret)
+{
+virNodeDevicePtr dev;
+const char *parent;
+CHECK_CONN(client);
+
+dev = virNodeDeviceLookupByName(client-conn, args-name);
+if (dev == NULL) {
+remoteDispatchError (client, req, %s, _(node_device not found));
+return -2;
+}
+
+parent = virNodeDeviceGetParent(dev);
+
+if (parent == NULL) {
+ret-parent 

Re: [libvirt] PATCH: 5/7: virsh interface

2008-11-20 Thread Daniel P. Berrange
This provides the virsh binding. The main changes is to the
list method to not call ByCaps anymore. And I've actually
really renamed the commands this time !

Daniel

diff -r 9a1d48518cac src/virsh.c
--- a/src/virsh.c   Thu Nov 20 16:26:13 2008 +
+++ b/src/virsh.c   Thu Nov 20 16:43:40 2008 +
@@ -4415,6 +4415,94 @@
 vshPrint(ctl, _(Running hypervisor: %s %d.%d.%d\n),
  hvType, major, minor, rel);
 }
+return TRUE;
+}
+
+/*
+ * nodedev-list command
+ */
+static const vshCmdInfo info_node_list_devices[] = {
+{syntax, nodedev-list [--cap capability]},
+{help, gettext_noop(enumerate devices on this host)},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_node_list_devices[] = {
+{cap, VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop(capability name)},
+{NULL, 0, 0, NULL}
+};
+
+static int
+cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+{
+char *cap;
+char **devices;
+int found, num_devices, i;
+
+if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
+return FALSE;
+
+cap = vshCommandOptString(cmd, cap, found);
+if (!found)
+cap = NULL;
+
+num_devices = virNodeNumOfDevices(ctl-conn, cap, 0);
+if (num_devices  0) {
+vshError(ctl, FALSE, %s, _(Failed to count node devices));
+return FALSE;
+} else if (num_devices == 0) {
+return TRUE;
+}
+
+devices = vshMalloc(ctl, sizeof(char *) * num_devices);
+num_devices =
+virNodeListDevices(ctl-conn, cap, devices, num_devices, 0);
+if (num_devices  0) {
+vshError(ctl, FALSE, %s, _(Failed to list node devices));
+free(devices);
+return FALSE;
+}
+for (i = 0; i  num_devices; i++) {
+vshPrint(ctl, %s\n, devices[i]);
+free(devices[i]);
+}
+free(devices);
+return TRUE;
+}
+
+/*
+ * nodedev-dumpxml command
+ */
+static const vshCmdInfo info_node_device_dumpxml[] = {
+{syntax, nodedev-dumpxml device},
+{help, gettext_noop(node device details in XML)},
+{desc, gettext_noop(Output the node device details as an XML dump to 
stdout.)},
+{NULL, NULL}
+};
+
+
+static const vshCmdOptDef opts_node_device_dumpxml[] = {
+{device, VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(device key)},
+{NULL, 0, 0, NULL}
+};
+
+static int
+cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
+{
+const char *name;
+virNodeDevicePtr device;
+
+if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
+return FALSE;
+if (!(name = vshCommandOptString(cmd, device, NULL)))
+return FALSE;
+if (!(device = virNodeDeviceLookupByName(ctl-conn, name))) {
+vshError(ctl, FALSE, %s '%s', _(Could not find matching device), 
name);
+return FALSE;
+}
+
+vshPrint(ctl, %s\n, virNodeDeviceGetXMLDesc(device, 0));
+virNodeDeviceFree(device);
 return TRUE;
 }
 
@@ -5570,6 +5658,9 @@
 {net-uuid, cmdNetworkUuid, opts_network_uuid, info_network_uuid},
 {nodeinfo, cmdNodeinfo, NULL, info_nodeinfo},
 
+{nodedev-list, cmdNodeListDevices, opts_node_list_devices, 
info_node_list_devices},
+{nodedev-dumpxml, cmdNodeDeviceDumpXML, opts_node_device_dumpxml, 
info_node_device_dumpxml},
+
 {pool-autostart, cmdPoolAutostart, opts_pool_autostart, 
info_pool_autostart},
 {pool-build, cmdPoolBuild, opts_pool_build, info_pool_build},
 {pool-create, cmdPoolCreate, opts_pool_create, info_pool_create},

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 6/7: Python binding

2008-11-20 Thread Daniel P. Berrange
This is the python API, again just changed to cope with removal of the
ByCaps API calls


Daniel

diff -r 105e73557ef8 python/generator.py
--- a/python/generator.py   Thu Nov 20 16:27:06 2008 +
+++ b/python/generator.py   Thu Nov 20 16:43:08 2008 +
@@ -260,6 +260,11 @@
 'const virConnectPtr':  ('O', virConnect, virConnectPtr, 
virConnectPtr),
 'virConnect *':  ('O', virConnect, virConnectPtr, virConnectPtr),
 'const virConnect *':  ('O', virConnect, virConnectPtr, 
virConnectPtr),
+
+'virNodeDevicePtr':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'const virNodeDevicePtr':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'virNodeDevice *':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
+'const virNodeDevice *':  ('O', virNodeDevice, virNodeDevicePtr, 
virNodeDevicePtr),
 }
 
 py_return_types = {
@@ -318,6 +323,8 @@
 'virDomainBlockPeek',
 'virDomainMemoryPeek',
 'virEventRegisterImpl',
+'virNodeListDevices',
+'virNodeDeviceListCaps',
 )
 
 
@@ -601,6 +608,8 @@
 virStoragePool *: (._o, virStoragePool(self, _obj=%s), 
virStoragePool),
 virStorageVolPtr: (._o, virStorageVol(self, _obj=%s), 
virStorageVol),
 virStorageVol *: (._o, virStorageVol(self, _obj=%s), 
virStorageVol),
+virNodeDevicePtr: (._o, virNodeDevice(self, _obj=%s), 
virNodeDevice),
+virNodeDevice *: (._o, virNodeDevice(self, _obj=%s), 
virNodeDevice),
 virConnectPtr: (._o, virConnect(_obj=%s), virConnect),
 virConnect *: (._o, virConnect(_obj=%s), virConnect),
 }
@@ -608,7 +617,8 @@
 converter_type = {
 }
 
-primary_classes = [virDomain, virNetwork, virStoragePool, 
virStorageVol, virConnect]
+primary_classes = [virDomain, virNetwork, virStoragePool, 
virStorageVol,
+   virConnect, virNodeDevice ]
 
 classes_ancestor = {
 }
@@ -617,6 +627,7 @@
 virNetwork: virNetworkFree,
 virStoragePool: virStoragePoolFree,
 virStorageVol: virStorageVolFree,
+virNodeDevice : virNodeDeviceFree
 }
 
 functions_noexcept = {
@@ -626,6 +637,8 @@
 'virStoragePoolGetName': True,
 'virStorageVolGetName': True,
 'virStorageVolGetkey': True,
+'virNodeDeviceGetName': True,
+'virNodeDeviceGetParent': True,
 }
 
 reference_keepers = {
@@ -706,6 +719,13 @@
 elif name[0:13] == virStorageVol:
 func = name[13:]
 func = string.lower(func[0:1]) + func[1:]
+elif name[0:13] == virNodeDevice:
+if name[13:16] == Get:
+func = string.lower(name[16]) + name[17:]
+elif name[13:19] == Lookup or name[13:] == Create:
+func = string.lower(name[3]) + name[4:]
+else:
+func = string.lower(name[13]) + name[14:]
 elif name[0:7] == virNode:
 func = name[7:]
 func = string.lower(func[0:1]) + func[1:]
@@ -958,7 +978,7 @@
else:
txt.write(Class %s()\n % (classname))
classes.write(class %s:\n % (classname))
-if classname in [ virDomain, virNetwork, virStoragePool, 
virStorageVol ]:
+if classname in [ virDomain, virNetwork, virStoragePool, 
virStorageVol, virNodeDevice ]:
 classes.write(def __init__(self, conn, _obj=None):\n)
 else:
 classes.write(def __init__(self, _obj=None):\n)
@@ -966,7 +986,7 @@
list = reference_keepers[classname]
for ref in list:
classes.write(self.%s = None\n % ref[1])
-if classname in [ virDomain, virNetwork ]:
+if classname in [ virDomain, virNetwork, virNodeDevice ]:
 classes.write(self._conn = conn\n)
 elif classname in [ virStorageVol, virStoragePool ]:
 classes.write(self._conn = conn\n + \
diff -r 105e73557ef8 python/libvir.c
--- a/python/libvir.c   Thu Nov 20 16:27:06 2008 +
+++ b/python/libvir.c   Thu Nov 20 16:43:08 2008 +
@@ -1466,6 +1466,90 @@
 return(py_retval);
 }
 
+static PyObject *
+libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
+   PyObject *args) {
+PyObject *py_retval;
+char **names = NULL;
+int c_retval, i;
+virConnectPtr conn;
+PyObject *pyobj_conn;
+char *cap;
+unsigned int flags;
+
+if (!PyArg_ParseTuple(args, (char *)Ozi:virNodeListDevices,
+  pyobj_conn, cap, flags))
+return(NULL);
+conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+c_retval = virNodeNumOfDevices(conn, cap, flags);
+if (c_retval  0)
+return VIR_PY_NONE;
+
+if (c_retval) {
+names = malloc(sizeof(*names) * c_retval);
+if (!names)
+return VIR_PY_NONE;
+c_retval = virNodeListDevices(conn, cap, names, c_retval, flags);
+if (c_retval  0) {
+free(names);
+return VIR_PY_NONE;
+}
+}

Re: [libvirt] PATCH: 0/7: Final node device patches to be committed

2008-11-20 Thread Daniel P. Berrange
On Thu, Nov 20, 2008 at 05:49:50PM +, Daniel P. Berrange wrote:
 FYI, this is a repost of the final node device patches I intend to
 commit tomorrow. There's a few changes based on Mark's feedback
 which  I'll note against each patch...

As an example, here is the complete output from a box of mine with all
patches applied. I'm happy with committing to this XML long term, with
the expectation that we may define a formal naming scheme for devices
later to replace the non-guarenteed HAL/DevKit naming.


# ./virsh nodedev-list
computer
net_00_e0_81_b0_2d_8e
net_00_e0_81_b0_2d_8f
pci_1002_94c3
pci_1002_aa10
pci_1022_1200
pci_1022_1200_0
pci_1022_1201
pci_1022_1201_0
pci_1022_1202
pci_1022_1202_0
pci_1022_1203
pci_1022_1203_0
pci_1022_1204
pci_1022_1204_0
pci_1033_125
pci_1033_125_0
pci_104c_8023
pci_10de_361
pci_10de_364
pci_10de_368
pci_10de_368_0
pci_10de_369
pci_10de_369_0
pci_10de_36c
pci_10de_36d
pci_10de_36e
pci_10de_36e_scsi_host
pci_10de_36e_scsi_host_scsi_device_lun0
pci_10de_370
pci_10de_371
pci_10de_372
pci_10de_372_0
pci_10de_376
pci_10de_376_0
pci_10de_377
pci_10de_377_0
pci_10de_378
pci_10de_378_0
pci_10de_37f
pci_10de_37f_0
pci_10de_37f_1
pci_10de_37f_scsi_host
pci_10de_37f_scsi_host_scsi_device_lun0
platform_floppy_0_storage_platform_floppy
storage_model_DVD_A__DH20A4P
storage_serial_SATA_WDC_WD3200AAKS__WD_WCASE0223035
usb_device_1d6b_1__00_02_0
usb_device_1d6b_1__00_02_0_if0
usb_device_1d6b_2__00_02_1
usb_device_1d6b_2__00_02_1_if0


And for each of those the XML is:

device
  namecomputer/name
  capability type='system'
hardware
  vendorTyan Computer Corporation/vendor
  versionREFERENCE/version
  serial0123456789/serial
  uuid----/uuid
/hardware
firmware
  vendorPhoenix Technologies Ltd./vendor
  version2.05.2915/version
  release_date04/04/2008/release_date
/firmware
  /capability
/device


device
  namenet_00_e0_81_b0_2d_8e/name
  parentpci_10de_372/parent
  capability type='net'
interfaceeth0/interface
address00:e0:81:b0:2d:8e/address
capability type='80203'/
  /capability
/device


device
  namenet_00_e0_81_b0_2d_8f/name
  parentpci_10de_372_0/parent
  capability type='net'
interfaceeth1/interface
address00:e0:81:b0:2d:8f/address
capability type='80203'/
  /capability
/device


device
  namepci_1002_94c3/name
  parentpci_10de_377/parent
  capability type='pci'
domain0/domain
bus6/bus
slot0/slot
function0/function
product id='38083'RV610 video device [Radeon HD 2400 PRO]/product
vendor id='4098'ATI Technologies Inc/vendor
  /capability
/device


device
  namepci_1002_aa10/name
  parentpci_10de_377/parent
  capability type='pci'
domain0/domain
bus6/bus
slot0/slot
function1/function
product id='43536'RV610 audio device [Radeon HD 2400 PRO]/product
vendor id='4098'ATI Technologies Inc/vendor
  /capability
/device


device
  namepci_1022_1200/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot24/slot
function0/function
product id='4608'Family 10h [Opteron, Athlon64, Sempron] HyperTransport 
Configuration/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1200_0/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot25/slot
function0/function
product id='4608'Family 10h [Opteron, Athlon64, Sempron] HyperTransport 
Configuration/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1201/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot24/slot
function1/function
product id='4609'Family 10h [Opteron, Athlon64, Sempron] Address 
Map/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1201_0/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot25/slot
function1/function
product id='4609'Family 10h [Opteron, Athlon64, Sempron] Address 
Map/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1202/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot24/slot
function2/function
product id='4610'Family 10h [Opteron, Athlon64, Sempron] DRAM 
Controller/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1202_0/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus
slot25/slot
function2/function
product id='4610'Family 10h [Opteron, Athlon64, Sempron] DRAM 
Controller/product
vendor id='4130'Advanced Micro Devices [AMD]/vendor
  /capability
/device


device
  namepci_1022_1203/name
  parentcomputer/parent
  capability type='pci'
domain0/domain
bus0/bus

Re: [libvirt] PATCH: 7/7: Misc fixes

2008-11-20 Thread Mark McLoughlin
On Thu, 2008-11-20 at 18:03 +, Daniel P. Berrange wrote:

  case VIR_NODE_DEV_CAP_STORAGE:
 +virBufferVSprintf(buf, block%s/blocke\n,
^

Minore tpyo hero

Cheers,
Mark.

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] --with-xen=foo

2008-11-20 Thread Daniel P. Berrange
On Thu, Nov 20, 2008 at 01:27:40PM -0500, Ben Guthro wrote:
 I tried this...didn't seem to help:

Sorry, not paying close enough attention. In fact this file was
built in an earlier module. Find the line which says

libvirt_driver_la_SOURCES = \
$(DRIVER_SOURCES)   \
$(DOMAIN_CONF_SOURCES)  \
$(NETWORK_CONF_SOURCES) \
$(STORAGE_CONF_SOURCES) \
$(NODE_DEVICE_CONF_SOURCES)

And add in a line following that

libvirt_driver_la_CFLAGS = $(XEN_CFLAGS)


Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: 9/12: HAL/DevitKit node device impl

2008-11-20 Thread Daniel P. Berrange
On Fri, Nov 14, 2008 at 02:57:09PM -0500, David Lively wrote:
 
   +(void)get_int_prop(ctx, udi, pci.vendor_id, (int 
   *)d-pci_dev.vendor);
   +if (get_str_prop(ctx, udi, pci.vendor, d-pci_dev.vendor_name) != 
   0)
   +(void)get_str_prop(ctx, udi, info.vendor, 
   d-pci_dev.vendor_name);
   +(void)get_int_prop(ctx, udi, pci.product_id, (int 
   *)d-pci_dev.product);
   +if (get_str_prop(ctx, udi, pci.product, d-pci_dev.product_name) 
   != 0)
   +(void)get_str_prop(ctx, udi, info.product, 
   d-pci_dev.product_name);
  
  By the way - vendor and product IDs are normally quoted in hex, not
  decimal - e.g. I'd know my NIC is 8086:10de, not 32902:4318
  
  I guess most other integer values in libvirt XML are decimal, but might
  be worth adding a hex format for this?
 
 I'd prefer hex for vid/pid as well; I just stuck with decimal since the
 rest of libvirt does.  If this does get changed to output hex, I'd only
 request that we prefix hex numbers with 0x so people don't have to
 remember which attrs are dumped in hex and which in decimal.

I've included the 0x prefix  padded to 4 digits minimum. Looks much nicer
now :-)

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Fix UML syntax

2008-11-20 Thread Ben Guthro
various changes to fix make syntax-check succeed with new UML driver
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3f8fdd2..d9f3abe 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,6 +28,8 @@ src/storage_backend_logical.c
 src/storage_conf.c
 src/storage_driver.c
 src/test.c
+src/uml_conf.c
+src/uml_driver.c
 src/util.c
 src/uuid.c
 src/virsh.c
diff --git a/src/uml_conf.h b/src/uml_conf.h
index 1213df1..69794bc 100644
--- a/src/uml_conf.h
+++ b/src/uml_conf.h
@@ -64,11 +64,11 @@ struct uml_driver {
 virCapsPtr  umlCapsInit   (void);
 
 int umlBuildCommandLine   (virConnectPtr conn,
-   struct uml_driver *driver,
-   virDomainObjPtr dom,
-   const char ***retargv,
-   const char ***retenv,
-   int **tapfds,
-   int *ntapfds);
+   struct uml_driver *driver,
+   virDomainObjPtr dom,
+   const char ***retargv,
+   const char ***retenv,
+   int **tapfds,
+   int *ntapfds);
 
 #endif /* __UML_CONF_H */
diff --git a/src/uml_driver.c b/src/uml_driver.c
index ac0c32c..d5530d9 100644
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -51,7 +51,6 @@
 
 #include uml_driver.h
 #include uml_conf.h
-#include c-ctype.h
 #include event.h
 #include buf.h
 #include util.h
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Xen Events Updated

2008-11-20 Thread Ben Guthro
New xen events patch attached. This removes a couple unnecessary changes from 
my prior patch, but remains functionally the same as the last version.

This will emit the following events for Xen:

STARTED
STOPPED
ADDED
REMOVED
diff --git a/configure.in b/configure.in
index 21931a1..a38592a 100644
--- a/configure.in
+++ b/configure.in
@@ -147,6 +147,8 @@ fi
 dnl Allow to build without Xen, QEMU/KVM, test or remote driver
 AC_ARG_WITH([xen],
 [  --with-xen  add XEN support (on)],[],[with_xen=yes])
+AC_ARG_WITH([xen-inotify],
+[  --with-xen-inotify  add XEN inotify support (on)],[],[with_xen_inotify=yes])
 AC_ARG_WITH([qemu],
 [  --with-qemu add QEMU/KVM support (on)],[],[with_qemu=yes])
 AC_ARG_WITH([uml],
@@ -335,6 +337,17 @@ AC_SUBST([XEN_CFLAGS])
 AC_SUBST([XEN_LIBS])
 
 dnl
+dnl check for kernel headers required by xen_inotify
+dnl
+if test $with_xen_inotify != no; then
+AC_CHECK_HEADER([linux/inotify.h],[],[with_xen_inotify=no])
+fi
+if test $with_xen_inotify = yes; then
+AC_DEFINE_UNQUOTED([WITH_XEN_INOTIFY], 1,[whether Xen inotify sub-driver is enabled])
+fi
+AM_CONDITIONAL([WITH_XEN_INOTIFY], [test $with_xen_inotify = yes])
+
+dnl
 dnl check for kernel headers required by src/bridge.c
 dnl
 if test $with_qemu = yes -o $with_lxc = yes ; then
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 868f1a3..1bce719 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -59,6 +59,7 @@ typedef enum {
 VIR_FROM_NETWORK,   /* Error from network config */
 VIR_FROM_DOMAIN,/* Error from domain config */
 VIR_FROM_UML,   /* Error at the UML driver */
+VIR_FROM_XEN_INOTIFY, /* Error from xen inotify layer */
 } virErrorDomain;
 
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3f8fdd2..5804be6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -32,6 +32,7 @@ src/util.c
 src/uuid.c
 src/virsh.c
 src/virterror.c
+src/xen_inotify.c
 src/xen_internal.c
 src/xend_internal.c
 src/xm_internal.c
diff --git a/src/Makefile.am b/src/Makefile.am
index b2c7e3f..3520130 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,6 +94,9 @@ XEN_DRIVER_SOURCES =		\
 		xend_internal.c xend_internal.h			\
 		xm_internal.c xm_internal.h			\
 		xs_internal.c xs_internal.h
+if WITH_XEN_INOTIFY
+XEN_DRIVER_SOURCES += xen_inotify.c xen_inotify.h
+endif
 
 LXC_DRIVER_SOURCES =		\
 		lxc_conf.c lxc_conf.h\
diff --git a/src/virterror.c b/src/virterror.c
index 46a7d15..40bbdf1 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -262,6 +262,9 @@ virDefaultErrorFunc(virErrorPtr err)
 case VIR_FROM_XENSTORE:
 dom = Xen Store ;
 break;
+case VIR_FROM_XEN_INOTIFY:
+dom = Xen Inotify ;
+break;
 case VIR_FROM_DOM:
 dom = Domain ;
 break;
diff --git a/src/xen_inotify.c b/src/xen_inotify.c
new file mode 100644
index 000..ff5898e
--- /dev/null
+++ b/src/xen_inotify.c
@@ -0,0 +1,456 @@
+/*
+ * xen_inofify.c: Xen notification of xml file activity in the
+ *following dirs:
+ */etc/xen
+ */var/lib/xend/domains
+ *
+ * Copyright (C) 2008 VirtualIron
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Ben Guthro
+ */
+#include config.h
+#include dirent.h
+#include sys/inotify.h
+
+#include virterror_internal.h
+#include datatypes.h
+#include driver.h
+#include memory.h
+#include event.h
+#include xen_unified.h
+#include conf.h
+#include domain_conf.h
+#include xen_inotify.h
+#include xend_internal.h
+#include logging.h
+#include uuid.h
+
+#include xm_internal.h /* for xenXMDomainConfigParse */
+
+#define virXenInotifyError(conn, code, fmt...) \
+virReportErrorHelper(NULL, VIR_FROM_XEN_INOTIFY, code, __FILE__,  \
+   __FUNCTION__, __LINE__, fmt)
+
+#define LIBVIRTD_DOMAINS_DIR /var/lib/xend/domains
+static const char *configDir= NULL;
+static int  useXenConfigCache = 0;
+static xenUnifiedDomainInfoListPtr configInfoList = NULL;
+
+/* declared in xm_internal.c */
+virHashTablePtr xenXMGetConfigCache(void);
+char *xenXMGetConfigDir(void);
+int xenXMConfigCacheRefresh (virConnectPtr conn);
+int 

Re: [libvirt] Relax requirement of bridge source device

2008-11-20 Thread Jim Fehlig
Daniel P. Berrange wrote:
 On Wed, Nov 19, 2008 at 11:20:08PM -0700, Jim Fehlig wrote:
   
 Hi All,

 I wanted to get folks thoughts on relaxing the requirement for bridge 
 source device in network interface of domain XML, e.g. allowing

interface type=bridge
  mac address=aa:bb:cc:cc:ee:ff/
/interface

 Currently, virDomainNetDefParseXML() in src/domain_conf.c will fail such 
 configuration.  Since this is common code between backends I'm not sure 
 how allowing this config will affect the various virtualizers.

 Xen's vif-bridge script will try to find a bridge if one is not 
 specified, which perhaps is dubious behavior, but nonetheless convenient 
 in migration scenarios where the target host may have a different bridge 
 name (br1 vs br0 for example).  IIRC, qemu's qemu-ifup script is not as 
 forgiving in the absence of a bridge name.
 

 I don't particularly like this idea. While letting it automatically
 pick the bridge devices may happen to work in some cases, it'll 
 quietly go wrong horribly in other scenarios. Xen's vif-bridge 
 has caused real bugs through this behaviour even on a single machine.
 eg, its happily automatically picking br0 for months, then someone
 adds a new completely unrelated bridge to the machin, say br4, and
 the next reboot vif-bridge suddenly decides it prefers br4 for your
 guest.

Yep, have seen this behavior when leaving source unspecified.

I think it is not unreasonable in the case of migraiton to
 require that the bridge names are configured the same on source and
 destination machine, and explicitly including bridge names will let
 apps using libvirt query the source  destination host before doing
 migraiton and verify that br0 on the source is configured to use the
 same network as br0 on the destination.
   

Agreed.  Thanks for the feedback Daniel.

Jim

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] fix libvirtd crash in qemu driver

2008-11-20 Thread David Lively
I noticed that the following sequence of events would crash libvirtd
when using the qemu driver:
  (1) establish a connection that successfully registers for domain  
  events (either of the event-test programs will do, though the
  python one is currently broken -- another patch on the way for 
  that)
  (2) close this connection
  (3) open another connection
  (4) do something (like start a domain) that issues a domain event

The problem is that qemudClose() isn't removing registered domain event
callbacks when the connection closes.  This patch does that, and fixes
the crash.

Dave


 domain_event.c |   38 ++
 domain_event.h |3 +++
 qemu_driver.c  |5 -
 3 files changed, 45 insertions(+), 1 deletion(-)

commit d70494a2c2ebdf985943020cc84f22713904719a
Author: David Lively [EMAIL PROTECTED]
Date:   Thu Nov 20 16:34:32 2008 -0500

vi-patch: qemu-driver-close-fix

Fix a bug in the QEMU driver causing libvirtd crashes.  When closing
a connection, remove the DomainEvent callbacks associated with
the connection.

diff --git a/src/domain_event.c b/src/domain_event.c
index 85ca9b7..d5f5415 100644
--- a/src/domain_event.c
+++ b/src/domain_event.c
@@ -88,6 +88,44 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
 }
 
 /**
+ * virDomainEventCallbackListRemoveConn:
+ * @conn: pointer to the connection
+ * @cbList: the list
+ *
+ * Internal function to remove all of a given connection's callback
+ * from a virDomainEventCallbackListPtr
+ */
+int
+virDomainEventCallbackListRemoveConn(virConnectPtr conn,
+ virDomainEventCallbackListPtr cbList)
+{
+int old_count = cbList-count;
+int i;
+for (i = 0 ; i  cbList-count ; i++) {
+if(cbList-callbacks[i]-conn == conn) {
+virFreeCallback freecb = cbList-callbacks[i]-freecb;
+if (freecb)
+(*freecb)(cbList-callbacks[i]-opaque);
+virUnrefConnect(cbList-callbacks[i]-conn);
+VIR_FREE(cbList-callbacks[i]);
+
+if (i  (cbList-count - 1))
+memmove(cbList-callbacks + i,
+cbList-callbacks + i + 1,
+sizeof(*(cbList-callbacks)) *
+(cbList-count - (i + 1)));
+cbList-count--;
+i--;
+}
+}
+if (cbList-count  old_count 
+VIR_REALLOC_N(cbList-callbacks, cbList-count)  0) {
+; /* Failure to reduce memory allocation isn't fatal */
+}
+return 0;
+}
+
+/**
  * virDomainEventCallbackListAdd:
  * @conn: pointer to the connection
  * @cbList: the list
diff --git a/src/domain_event.h b/src/domain_event.h
index cfec1e1..454d084 100644
--- a/src/domain_event.h
+++ b/src/domain_event.h
@@ -55,6 +55,9 @@ int virDomainEventCallbackListRemove(virConnectPtr conn,
  virDomainEventCallbackListPtr cbList,
  virConnectDomainEventCallback callback);
 
+int virDomainEventCallbackListRemoveConn(virConnectPtr conn,
+	 virDomainEventCallbackListPtr cbList);
+
 /**
  * Dispatching domain events that come in while
  * in a call / response rpc
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 5ad60f1..7bec116 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1235,7 +1235,10 @@ static virDrvOpenStatus qemudOpen(virConnectPtr conn,
 }
 
 static int qemudClose(virConnectPtr conn) {
-/*struct qemud_driver *driver = (struct qemud_driver *)conn-privateData;*/
+struct qemud_driver *driver = (struct qemud_driver *)conn-privateData;
+
+/* Get rid of callbacks registered for this conn */
+virDomainEventCallbackListRemoveConn(conn, driver-domainEventCallbacks);
 
 conn-privateData = NULL;
 
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] fix EventImpl-related error paths in remote driver

2008-11-20 Thread David Lively
This patch makes the remote driver behave properly in the face of:
  (a) no registered EventImpl, or
  (b) an EventImpl that returns failure from AddHandle/Timeout

In both cases, we now cleanup properly (rather than always passing bogus
values to virEventRemoveHandle/Timeout) and fail attempts to register
for domain events (w/VIR_ERR_NO_SUPPORT rather than blissfully continue
when we can't possibly deliver events).

Dave


 remote_internal.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)
commit 02239f3e0fedf1c3860826f13efe356223b38e3c
Author: David Lively [EMAIL PROTECTED]
Date:   Thu Nov 20 16:35:08 2008 -0500

vi-patch: remote-refuse-useless-event-registration

Made the remote driver's DomainEventRegister return an error if events
not supported (e.g., because there's no proper EventImpl registered).
Also, cleanup properly in this case, both in doRemoteOpen and
doRemoteClose.

diff --git a/src/remote_internal.c b/src/remote_internal.c
index 7ca6ec1..7124d0a 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -773,6 +773,7 @@ doRemoteOpen (virConnectPtr conn,
  conn, NULL))  0) {
 DEBUG0(virEventAddTimeout failed: No addTimeoutImpl defined. 
 continuing without events.);
+virEventRemoveHandle(priv-watch);
 }
 }
 /* Successful. */
@@ -1209,10 +1210,12 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
   (xdrproc_t) xdr_void, (char *) NULL) == -1)
 return -1;
 
-/* Remove handle for remote events */
-virEventRemoveHandle(priv-sock);
-/* Remove timout */
-virEventRemoveTimeout(priv-eventFlushTimer);
+if (priv-eventFlushTimer = 0) {
+/* Remove timeout */
+virEventRemoveTimeout(priv-eventFlushTimer);
+/* Remove handle for remote events */
+virEventRemoveHandle(priv-watch);
+}
 
 /* Close socket. */
 if (priv-uses_tls  priv-session) {
@@ -4481,6 +4484,10 @@ static int remoteDomainEventRegister (virConnectPtr conn,
 {
 struct private_data *priv = conn-privateData;
 
+if (priv-eventFlushTimer  0) {
+ error (conn, VIR_ERR_NO_SUPPORT, _(no event support));
+ return -1;
+}
 if (virDomainEventCallbackListAdd(conn, priv-callbackList,
   callback, opaque, freecb)  0) {
  error (conn, VIR_ERR_RPC, _(adding cb to list));
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Allow rpm to build without uml

2008-11-20 Thread Ben Guthro
Allow to build minimal rpm without uml
diff --git a/libvirt.spec.in b/libvirt.spec.in
index cfd4a66..91af843 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -10,6 +10,7 @@
 %define with_polkit0%{!?_without_polkit:0}
 %define with_python0%{!?_without_python:1}
 %define with_libvirtd  0%{!?_without_libvirtd:1}
+%define with_uml   0%{!?_without_uml:1}
 
 # Xen is available only on i386 x86_64 ia64
 %ifnarch i386 i686 x86_64 ia64
@@ -197,6 +198,10 @@ of recent versions of Linux (and other OSes).
 %define _without_libvirtd --without-libvirtd
 %endif
 
+%if ! %{with_uml}
+%define _without_uml --without-uml
+%endif
+
 %configure %{?_without_xen} \
%{?_without_qemu} \
%{?_without_openvz} \
@@ -206,6 +211,7 @@ of recent versions of Linux (and other OSes).
%{?_without_polkit} \
%{?_without_python} \
%{?_without_libvirtd} \
+   %{?_without_uml} \
--with-init-script=redhat \
--with-qemud-pid-file=%{_localstatedir}/run/libvirt_qemud.pid \
--with-remote-file=%{_localstatedir}/run/libvirtd.pid
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list