[libvirt] LIBVIR_VERSION_NUMBER ?

2008-08-27 Thread Jun Koi
Hi,

According to libvirt.h:

/**
 * LIBVIR_VERSION_NUMBER:
 *
 * Macro providing the version of the library as
 * version * 1,000,000 + minor * 1000 + micro
 */
#define LIBVIR_VERSION_NUMBER 4004

The comment is incorrect, as 4004 is not how it is supposed to be.

So we should fix either the comment (better?), or the version.

Thanks,
Jun

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


[libvirt] libvir: Xen error

2008-08-27 Thread mantra UNIX
 Hello everyone,

 I get the following error when i try to redtart a domain;

 # virsh list
 libvir: Xen error : Domain not found: xenUnifiedDomainLookupByID

 I am using RHEL5.2 on i386, I have searched for the error on web
 and on RedHat but could not find any.

-- 
Regards,
mantra - Instrument of Thought
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: Allow specific FDs to be kept open in virExec()

2008-08-27 Thread Richard W.M. Jones
On Tue, Aug 26, 2008 at 10:41:18AM +0100, Daniel P. Berrange wrote:
 On Thu, Aug 21, 2008 at 02:58:30PM +0100, Daniel P. Berrange wrote:
  With my recent patches to virExec(), all FDs except stdin/out/err are closed
  before the child is exec'd to prevent accidental leaks. Of course I forgot
  the one key place where we need to propagate FDs... The TAP devices passed
  to QEMU.
  
  This patch adds a 'keepfd' parameter to virExec() which allows the caller
  to specify a bitset of file descriptors to keep open, and updates the 
  callers to use this as required. The QEMU driver specifies any TAP fds
  and the LXC driver specifies its PTY this way removing a previous hack.
  
  QEMU networking works again with fix
 
 Changed to use fd_set from sys/select

Yup, +1.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
Read my OCaml programming blog: http://camltastic.blogspot.com/
Fedora now supports 64 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

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


Re: [libvirt] Choose alarm timer feature for kvm

2008-08-27 Thread Richard W.M. Jones
On Sun, Aug 24, 2008 at 08:20:05PM +0100, Daniel P. Berrange wrote:
 On Sun, Aug 24, 2008 at 08:40:46PM +0200, Tiziano M?ller wrote:
  Hi everyone
  
  In KVM it is possible to select the alarm timer being used (dynticks,
  hpet, rtc, unix).
 
 What exactly do these options do ? Is there anything describing the
 pros/cons of the different options  is there a way to determine 
 what the best option is for a particular VM ? 

I've had a long look at the source code in KVM-73 associated with
these timers and have some comments:

- QEMU tests the available timer sources in order and chooses the
first one which works (allegedly the best one).  The order, on
Linux, is:

   Timer  Implementation method
   ---
   (1) dynticks   POSIX timer_create
   (2) hpet   Linux-specific hardware (/dev/hpet) - see below
   (3) rtcold /dev/rtc, millisecond accuracy
   (4) unix POSIX setitimer

- Dynticks is at the top of the list, and has an extra 'rearm'
operation (the others only support starting and stopping timers).  But
I don't understand how this rearm operation is an improvement.

- HPET is second in the list and most accurate.  It's backed by
hardware and has sub-microsecond accuracy.

- It's not clear if dynticks (== timer_create) uses HPET internally in
the kernel?

- I can't see how any of this would affect guests -- except that
choosing a more accurate timer would be in some way 'better' because
the guest would then get more accurate emulation events.

 Basically I'm wondering where/if this should be exposed in the XML
 format, or whether libvirt could/should just internally pick the 
 best one ?

I can't see how libvirt can do any better than qemu/kvm is doing
already.  So unless someone comes along with an argument that using
(eg) hpet is better for Windows guests or something, then I suggest
that libvirt doesn't need to do anything.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [libvirt] Proposed functionality: API to extract host description from saved state, restore with modified XML

2008-08-27 Thread Richard W.M. Jones
On Sun, Aug 24, 2008 at 11:17:50PM -0500, Charles Duffy wrote:
 Would a patch adding API calls to
  - return the XML description of a saved host, given the name
  - restore a saved host with a different description
 be considered welcome?

As I understand it, yes  yes.

 I presume that to maintain backwards compatibility, the latter would be  
 expected to be exposed to clients via a new call, rather than adding a  
 parameter to virDomainRestore(); in communicating with the drivers, on  
 the other hand, my first instinct would be to add an extra parameter to  
 virDrvDomainRestore.

Yes, you cannot change the public API in a non-compatible way.  So
adding a new API call is the only option as I understand it.

You can change internal interfaces as much as you want.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
Read my OCaml programming blog: http://camltastic.blogspot.com/
Fedora now supports 64 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

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


Re: [libvirt] [PATCH] Attempt to detect cdrom change failures

2008-08-27 Thread Richard W.M. Jones
On Mon, Aug 25, 2008 at 01:05:03PM -0400, Cole Robinson wrote:
 Cole Robinson wrote:
  If a 'change' or 'eject' qemu monitor command fails,
  an error message is printed to the monitor of the
  form device {not found, is locked, is not 
  removable}. This is really the only indication we
  have that the command errored out, so scrape the
  monitor reply for \ndevice  and fail if it is
  found.
  
 
 There is an obvious syntax error in the patch (that's
 what I get for changing things last minute and not
 testing)

Seems like a +1 to me.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [libvirt] [PATCH] Fix ejecting cdroms with latest qemu syntax

2008-08-27 Thread Daniel P. Berrange
On Wed, Aug 27, 2008 at 11:48:27AM +0100, Richard W.M. Jones wrote:
 On Mon, Aug 25, 2008 at 01:41:24PM -0400, Cole Robinson wrote:
  Originally, ejecting a cdrom from a qemu guest entailed
  passing 'eject cdrom' to the monitor. But since qemu
  added the -drive option, more than one cdrom can be
  specified, so just using 'cdrom' isn't explicit enough.
  
  The attached patch updates media change/eject to use
  the current qemu syntax. The new generated commands
  look something like eject ide0-cd1, with the name
  derived from device target and bus type.
 
 I'm a bit unclear -- will this break for people using older versions
 of qemu/kvm?

Looks very much like it will. If we're lucky this change in monitor
syntax occurred at the time the -drive command was introduced. In which
case its easy to conditionalize based on the whether that's in use or
not.

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] Fix ejecting cdroms with latest qemu syntax

2008-08-27 Thread Daniel P. Berrange
On Mon, Aug 25, 2008 at 01:41:24PM -0400, Cole Robinson wrote:
 +
 +int idx = virDiskNameToIndex(newdisk-dst);
 +switch (newdisk-bus) {
 +/* Assume that if we are here, device targets don't exceed hypervisor
 + * limits, and we are already an appropriate device type */
 +case VIR_DOMAIN_DISK_BUS_IDE:
 +/* Device name of the form 'ide{0-1}-cd{0-1}' */
 +ret = asprintf(devname, ide%d-cd%d, ((idx - (idx % 2)) / 2),
 +   (idx % 2));
 +break;
 +case VIR_DOMAIN_DISK_BUS_SCSI:
 +/* Device name of the form 'scsi{bus#}-cd{0-6}
 + * Each bus holds seven devs */
 +ret = asprintf(devname, scsi%d-cd%d, ((idx - (idx % 7)) / 7),
 +(idx % 7));
 +break;
 +case VIR_DOMAIN_DISK_BUS_FDC:
 +/* Device name is 'floppy{0-1}' */
 +ret = asprintf(devname, floppy%d, idx);
 +break;
 +
 +default:
 +qemudReportError(dom-conn, dom, NULL, VIR_ERR_NO_SUPPORT,
 + _(Cannot hotplug device with bus '%s'),
 + virDomainDiskBusTypeToString(newdisk-bus));
 +return -1;
 +}

I think this block could be re-factored a little into one or more helper
methods, because I think we'll need to re-use this for hot-unplug of
disks. I'd suggest a helper to turn the plain integer index into the
(bus,device) index pair

 virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, 
 int *busIdx, 
 int *devIdx);

And then a QEMU specific function

char *virQEMUDeviceName(virDomainDiskDefPtr disk);

and have this call virDiskNameToBusDeviceIndex() and return the 'ide1-2'
type string.

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] virConnectOpenReadOnly?

2008-08-27 Thread Richard W.M. Jones
On Tue, Aug 26, 2008 at 03:45:06PM +0900, Jun Koi wrote:
 According to the comment of virConnectOpenReadOnly, this function has
 some restrictions on available methods to control domains. Could you
 be more specific? What kind of restrictions we are having (compare to
 virConnectOpen())?
 
 And when should we use virConnectOpenReadOnly() instead of virConnectOpen() ?

I don't think the list of restrictions is explicit anywhere, although
the idea of virConnectOpenReadOnly is to allow merely safe status/
monitoring-type operations, and not any operations which could change
the state of the system.  Virt-top, for example, opens all connections
in read-only mode.

In ocaml-libvirt we actually enforce the restriction at compile time.
So at some point a very long time ago I went through the calls in
libvirt to see which ones are restricted.  If you look at:

  
http://hg.et.redhat.com/virt/applications/ocaml-libvirt--devel/?f=6c6fec205451;file=libvirt/libvirt.mli

then any calls which have the phantom type[1] of [`W] t require
write access.

Rich.

[1] http://camltastic.blogspot.com/2008/05/phantom-types.html

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/

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


Re: [libvirt] Proposed functionality: API to extract host description from saved state, restore with modified XML

2008-08-27 Thread Daniel P. Berrange
On Sun, Aug 24, 2008 at 11:17:50PM -0500, Charles Duffy wrote:
 I'm looking for the ability to restore a snapshot saved with 
 domain.save(), with disk images pointing at a different location (in my 
 particular use case, pointing at a an empty copy-and-write image 
 backending into a snapshot of the old disk state). Further, as I may run 
 multiple copies of the same host at once (from the same initial state, 
 against different copy-on-write disk images backending into the same 
 read-only store, into different disconnected networks), the UUID as well 
 as the name may need to be changed.
 
 I could just rewrite the header of the saved-state file, but this has a 
 few disadvantages:
  - To mimic the copy-on-write behavior of the disk images, I would need 
 to copy the entire saved-domain file. I'm trying to minimize the time 
 and disk penalty of snapshot/restore, so this is suboptimal.

That will need to be done anyway for Xen save images.

  - My code is dependent on the file format used by the particular 
 backend, and may break when that backend is revved.

Yep, that's clearly a problem - you shouldn't rely on the save image
format at all - that's hypervisor version dependant and has no guarentees
whatsoever about it remaining the same.

 Would a patch adding API calls to
  - return the XML description of a saved host, given the name
  - restore a saved host with a different description
 be considered welcome?

I'm guessing you mean 'guest' instead of 'host' throughout here.

My overall concern with this idea, is that its basically introducing a
psuedo-snapshot capability onto the restore API, and is really a nasty
hack which I don't believe we can implement on all hypervisors.

Hypervisors may well have formal snapshot APIs we can call into, but
the hack of extracting XML  restoring a saved image using new XML
may prove impossible to map onto the hypervisors snapshot API. Thus
I'm inclined to say we don't want this capability. Instead I'd like 
us to have a real snapshot API, which we can directly map onto the
underlying hypervisor's snapshot capability, or do an internal hack
impl based on save images as you suggest - but not expose this detail
in the API.

 I presume that to maintain backwards compatibility, the latter would be 
 expected to be exposed to clients via a new call, rather than adding a 
 parameter to virDomainRestore(); in communicating with the drivers, on 
 the other hand, my first instinct would be to add an extra parameter to 
 virDrvDomainRestore.

Yes, anything in libvirt/libvirt.h is append-only. No changes are allowed
to this file because we have to maintain ABI. For anything in the src/
directory, changes are allowed within reason - we merely have to be
careful with things that map onto the remote protocol which is another
ABI.

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] Re: [augeas-devel] PATCH: Add a augeas lens for libvirtd.conf

2008-08-27 Thread Richard W.M. Jones

Dan pointed out that you have your own DFA implementation.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

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


[libvirt] Re: [augeas-devel] PATCH: Add a augeas lens for libvirtd.conf

2008-08-27 Thread Daniel P. Berrange
On Tue, Aug 26, 2008 at 09:40:41PM +, David Lutterkort wrote:
 On Tue, 2008-08-26 at 21:05 +0100, Daniel P. Berrange wrote:
  diff -u -p -r1.51 Makefile.am
  --- qemud/Makefile.am   20 Aug 2008 20:48:35 -  1.51
  +++ qemud/Makefile.am   26 Aug 2008 20:03:48 -
  @@ -24,6 +24,8 @@ EXTRA_DIST =  
  \
  libvirtd.policy \
  libvirtd.sasl   \
  libvirtd.sysconf\
  +libvirtd.aug\
  +test_libvirtd.aug   \
  $(AVAHI_SOURCES)\
  $(DAEMON_SOURCES)
   
  @@ -56,6 +58,12 @@ sbin_PROGRAMS = libvirtd
   confdir = $(sysconfdir)/libvirt/
   conf_DATA = libvirtd.conf
   
  +augeasdir = $(datadir)/augeas/lenses
  +augeas_DATA = libvirtd.aug
  +
  +augeastestsdir = $(datadir)/augeas/lenses/tests
  +augeastests_DATA = test_libvirtd.aug
  +
   libvirtd_SOURCES = $(DAEMON_SOURCES)
 
 You might also add a test that runs 
 augparse -I . test_libvirtd.aug
 during 'make check'

Yep, I've added a check-local rule for that in this new patch.

  +   let array_sep  = del /,[ \t\n]*/ , 
  +   let array_start = del /\[[ \t\n]*/ [ 
  +   let array_end = del /\]/  ]
 
 Augeas should throw an error here, but doesn't ;) The default value you
 give as the second argument of del really should match the first
 (regexp) argument.

Ahh, nice catch.

  +   let str_val = del /\/ \ . store /[^\]*/ . del /\/ \
  +   let bool_val = store /0|1/
  +   let str_array_element = [ str_val ] . del /[ \t\n]*/ 
  +   let str_array_val = array_start . ( str_array_element . ( array_sep . 
  str_array_element ) * ) ? . array_end
 
 You should really have some sort of label on each array element/str val
 (either the same for all of them using 'label' or just consecutive
 numbers using 'seq') - without that, you won't be able to get to
 individual entries through the public API.

I've changed that to which looks to give gives each element a unique ID

   let str_array_element = [ seq el . str_val ] . del /[ \t\n]*/ 
   let str_array_val = counter el . array_start . ( str_array_element . ( 
array_sep . str_array_element ) * ) ? . array_end

  +   let comment = [ label comment . del /#[ \t]*/ #  .  store /([^ 
  \t\n][^\n]*)?/ . del /\n/ \n ]
 
 We've been trying to label all comments as '#comment'; it's not an issue
 for libvirt, but with some other file formats, using 'comment' leads to
 conflicts with actual entries. Would be good to stick to that
 convention.

Ok, I was just copying one of the existing lens on my system. I've changed
it to #comment now


  +   let empty = [ label empty . del /[ \t]*\n/  ]
 
 Do you really care that empty entries show up in the tree ? If you don't
 want to see them, you can remove the 'label' from the above, and
 possibly also the '[ .. ]'.

Ok, this gets fun. I don't particularly want the label or tree node.
I can remove the label OK, but that gives anonymous tree nods. If
I remove the [...], then I end up with

test -x /usr/bin/augparse  /usr/bin/augparse -I . test_libvirtd.aug
./libvirtd.aug:63.3-.43:Failed to compile lns
./libvirtd.aug:63.13-.43:exception: ambiguous tree iteration
  'ca_file/' can be split into
  '|=|ca_file/'

 and
  'ca_file/|=|'

Iterated lens: ./libvirtd.aug:63.15-.39

test_libvirtd.aug:253.8-.20:Could not load module Libvirtd for Libvirtd.lns
test_libvirtd.aug:253.8-.20:Undefined variable Libvirtd.lns
test_libvirtd.aug: error: Loading failed

And I'm utterly stuck on what this means / how to fix it. I didn't
expect removing the square brackets to change the DFA.

  diff -N qemud/test_libvirtd.aug
  --- /dev/null   1 Jan 1970 00:00:00 -
  +++ qemud/test_libvirtd.aug 26 Aug 2008 20:03:48 -
  @@ -0,0 +1,484 @@
  +module Test_libvirtd =
  +   let conf1 = # Master libvirt daemon configuration file
 
 I've been thinking that we need to have some function that reads a file
 and returns a string so we don't have to clutter tests with these long
 strings. But for now, that's what it is :(

Yes, that would be very nice - and/or supporting use of HERE documents
for strings, so I don't have to escape   throughout the embedded config
file

 
  +{ tls_allowed_dn_list
  + { = DN1}
  + { = DN2}
  +}
 
 This happens because str_array_element produces tree nodes without
 labels. Users won't have a way to change e.g. the 'DN1' value to 'myDN'
 since you can't address a node without a label through the public API.

This now has integer keys.

One other useful improvement would be for the test suite to only print
out sections of the tree which differ. In debugging this it printed
out a 400 line 'Expected' tree structure, and then a 400 line 'Actual'
tree structure and wanted me to play Where's Waldo to find the typo.

It would be good to trim the leading 

Re: [libvirt] PATCH: Allow specific FDs to be kept open in virExec()

2008-08-27 Thread Daniel P. Berrange
On Wed, Aug 27, 2008 at 10:21:44AM +0100, Richard W.M. Jones wrote:
 On Tue, Aug 26, 2008 at 10:41:18AM +0100, Daniel P. Berrange wrote:
  On Thu, Aug 21, 2008 at 02:58:30PM +0100, Daniel P. Berrange wrote:
   With my recent patches to virExec(), all FDs except stdin/out/err are 
   closed
   before the child is exec'd to prevent accidental leaks. Of course I forgot
   the one key place where we need to propagate FDs... The TAP devices passed
   to QEMU.
   
   This patch adds a 'keepfd' parameter to virExec() which allows the caller
   to specify a bitset of file descriptors to keep open, and updates the 
   callers to use this as required. The QEMU driver specifies any TAP fds
   and the LXC driver specifies its PTY this way removing a previous hack.
   
   QEMU networking works again with fix
  
  Changed to use fd_set from sys/select
 
 Yup, +1.

Ok, committed this change - QEMU networking should work again 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


Re: [libvirt] PATCH: REmove bogus call to virStateInit in openvz driver

2008-08-27 Thread Daniel P. Berrange
On Tue, Aug 19, 2008 at 03:55:54PM +0200, Daniel Veillard wrote:
 On Tue, Aug 19, 2008 at 02:12:39PM +0100, Daniel P. Berrange wrote:
  For some unknown reason there is a call to virStateInitialize() in the 
  openvz driver's open method. This is absolutely forbidden - this API is
  only intended for use by the daemon. This patch removes this bogus call
  and makes it call the openvz setup APIs directly.
 
   Okay, I think I understand the problem, +1

Comitted this now, it was causing problems with the daemon too, preventing
automatic shutdowns.

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: Handle case of no domains in openvz driver

2008-08-27 Thread Daniel P. Berrange
On Tue, Aug 19, 2008 at 03:56:35PM +0200, Daniel Veillard wrote:
 On Tue, Aug 19, 2008 at 02:14:04PM +0100, Daniel P. Berrange wrote:
  If running the openvz driver on a machine with no containers currently
  defined, it throws an error
  
# ./src/virsh --connect openvz:///system list
libvir: OpenVZ error : internal error Failed to parse vzlist output
 Id Name State
--
 
   Looks okay, +1

Comitted this too.

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] Error compiling libvirt 0.4.4

2008-08-27 Thread Richard W.M. Jones
On Wed, Aug 27, 2008 at 10:42:38AM -0300, Everton P. Alexandre wrote:
  Richard W.M. Jones [EMAIL PROTECTED] escreveu: On Thu, Aug 21, 2008 at 
  06:57:40PM -0300, Everton P. Alexandre wrote:
   In file included from /usr/include/xen/dom0_ops.h:31,
from xen_unified.c:29:
   /usr/include/xen/xen.h:578: error: expected '=', ',', ';', 'asm' or 
   '__attribute__' before 'char'
  
  Did you find out what was causing this?

 No, I don't. Did this problem happen with you?

No.

Does it still happen for you?  Have you tried the latest version from
CVS?

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
Read my OCaml programming blog: http://camltastic.blogspot.com/
Fedora now supports 64 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

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


Re: [libvirt] PATCH: 4/4: Add pivot_root support to container

2008-08-27 Thread Daniel P. Berrange
On Wed, Aug 13, 2008 at 10:57:11AM -0700, Dan Smith wrote:

[snip huge pile of code]

 I'd really like to see this mondo if block broken out into at least an
 lxcPivotRoot() function, if not further.  This is pretty long and
 hairy, IMHO.

That is very true. I've re-factored it into a whole bunch of funtions
now, so take a look at this

 lxc_container.c |  337 +---
 util.c  |   12 -
 2 files changed, 301 insertions(+), 48 deletions(-)

Daniel

diff -r 831362089d7c src/lxc_container.c
--- a/src/lxc_container.c   Wed Aug 27 13:04:30 2008 +0100
+++ b/src/lxc_container.c   Wed Aug 27 13:21:35 2008 +0100
@@ -1,10 +1,12 @@
 /*
  * Copyright IBM Corp. 2008
+ * Copyright Red Hat 2008
  *
  * lxc_container.c: file description
  *
  * Authors:
  *  David L. Leskovec dlesko at linux.vnet.ibm.com
+ *  Daniel P. Berrange [EMAIL PROTECTED]
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,10 +28,18 @@
 #include fcntl.h
 #include limits.h
 #include stdlib.h
+#include stdio.h
 #include sys/ioctl.h
 #include sys/mount.h
 #include sys/wait.h
 #include unistd.h
+#include mntent.h
+
+/* Yes, we want linux private one, for _syscall2() macro */
+#include linux/unistd.h
+
+/* For MS_MOVE */
+#include linux/fs.h
 
 #include lxc_container.h
 #include util.h
@@ -103,23 +113,15 @@
  *
  * Returns 0 on success or -1 in case of error
  */
-static int lxcContainerSetStdio(int control, const char *ttyPath)
+static int lxcContainerSetStdio(int control, int ttyfd)
 {
 int rc = -1;
-int ttyfd;
 int open_max, i;
 
 if (setsid()  0) {
 lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
  _(setsid failed: %s), strerror(errno));
-goto error_out;
-}
-
-ttyfd = open(ttyPath, O_RDWR|O_NOCTTY);
-if (ttyfd  0) {
-lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _(open(%s) failed: %s), ttyPath, strerror(errno));
-goto error_out;
+goto cleanup;
 }
 
 if (ioctl(ttyfd, TIOCSCTTY, NULL)  0) {
@@ -156,9 +158,6 @@
 rc = 0;
 
 cleanup:
-close(ttyfd);
-
-error_out:
 return rc;
 }
 
@@ -221,6 +220,7 @@
 return 0;
 }
 
+
 /**
  * lxcEnableInterfaces:
  * @vm: Pointer to vm structure
@@ -251,6 +251,279 @@
 return rc;
 }
 
+
+//_syscall2(int, pivot_root, char *, newroot, const char *, oldroot)
+extern int pivot_root(const char * new_root,const char * put_old);
+
+static int lxcContainerChildMountSort(const void *a, const void *b)
+{
+  const char **sa = (const char**)a;
+  const char **sb = (const char**)b;
+
+  /* Delibrately reversed args - we need to unmount deepest
+ children first */
+  return strcmp(*sb, *sa);
+}
+
+static int lxcContainerPivotRoot(virDomainFSDefPtr root)
+{
+char *oldroot;
+
+/* First step is to ensure the new root itself is
+   a mount point */
+if (mount(root-src, root-src, NULL, MS_BIND, NULL)  0) {
+lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(failed to bind new root %s: %s),
+ root-src, strerror(errno));
+return -1;
+}
+
+if (asprintf(oldroot, %s/.oldroot, root-src)  0) {
+oldroot = NULL;
+lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+return -1;
+}
+
+if (virFileMakePath(oldroot)  0) {
+VIR_FREE(oldroot);
+lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(failed to create %s: %s),
+ oldroot, strerror(errno));
+return -1;
+}
+
+/* The old root directory will live at /.oldroot after
+ * this and will soon be unmounted completely */
+if (pivot_root(root-src, oldroot)  0) {
+VIR_FREE(oldroot);
+lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(failed to pivot root %s to %s: %s),
+ oldroot, root-src, strerror(errno));
+return -1;
+}
+VIR_FREE(oldroot);
+
+/* CWD is undefined after pivot_root, so go to / */
+if (chdir(/)  0) {
+return -1;
+}
+
+return 0;
+}
+
+static int lxcContainerPopulateDevices(void)
+{
+int i;
+const struct {
+int maj;
+int min;
+mode_t mode;
+const char *path;
+} devs[] = {
+{ 1, 3, 0666, /dev/null },
+{ 1, 5, 0666, /dev/zero },
+{ 1, 7, 0666, /dev/full },
+{ 5, 1, 0600, /dev/console },
+{ 1, 8, 0666, /dev/random },
+{ 1, 9, 0666, /dev/urandom },
+};
+
+if (virFileMakePath(/dev)  0 ||
+mount(none, /dev, tmpfs, 0, NULL)  0) {
+lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(failed to mount /dev tmpfs for container: %s),
+ strerror(errno));
+return -1;
+}
+/* Move old devpts into container, since we have to
+   connect to the master ptmx which was opened in
+   the parent.
+   XXX This sucks, we need 

Re: [libvirt] libvir: Xen error

2008-08-27 Thread mantra UNIX
Richard,

1.0

Using virt-manager console to login into the guest-os and issues the init
0

2.0

Once the guest was shutdown, i ran the following command to check the stuats
of the guest(s)

2.1

# xm list
Error: Device 0 not connected
Usage: xm list [options] [Domain, ...]

List information about all/some domains.
  -l, --long Output all VM details in SXP
  --labelInclude security labels
2.2

# virsh list
 Id Name State
--
  0 Domain-0 running
  2 pranav   blocked
  4 prabhas  blocked
libvir: Xen Daemon error : internal error domain information incomplete,
missing name

2.3
# /etc/init.d/xend restart
restart xend:  [  OK  ]

2.4
# xm list
Name  ID Mem(MiB) VCPUs State   Time(s)
Domain-0   0  512 2 r-  21558.2
prabhas4  127 1 -b 29.1
pranav 2  511 1 -b   5105.0

2.5

# virsh list
 Id Name State
--
  0 Domain-0 running
  2 pranav   running
  4 prabhas  blocked
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByID


2.6

# xm list --long
(domain
(domid 0)
(uuid ----)
(vcpus 2)
(cpu_weight 1.0)
(memory 513)
(shadow_memory 0)
(maxmem 513)
(features )
(name Domain-0)
(on_poweroff destroy)
(on_reboot restart)
(on_crash restart)
(state r-)
(shutdown_reason poweroff)
(cpu_time 21561.3876054)
(online_vcpus 2)
)
(domain
(domid 4)
(uuid 7db51eef-1452-b99e-9473-fc0589a330ca)
(vcpus 1)
(cpu_weight 1.0)
(memory 128)
(shadow_memory 0)
(maxmem 256)
(features )
(name def)
(on_poweroff destroy)
(on_reboot restart)
(on_crash restart)
(image
(linux
(kernel /var/lib/xen/boot_kernel.zBuMFJ)
(ramdisk /var/lib/xen/boot_ramdisk.YYHeU7)
(args 'ro root=/dev/rootvg/root_lv console=tty
console=xvc0,9600n8')
)
)
(device
(vif
(backend 0)
(script vif-bridge)
(ip 192.168.122.3)
(mac 00:16:3e:7a:ef:c9)
)
)
(device
(tap
(backend 0)
(dev xvda:disk)
(uname tap:aio:/guestos/def.img)
(mode w)
)
)
(state -b)
(shutdown_reason poweroff)
(cpu_time 29.117509912)
(online_vcpus 1)
(up_time 5442.33996201)
(start_time 1219848257.23)
)
(domain
(domid 2)
(uuid 0dbedfec-cf93-118f-6209-1e62f6f0f0db)
(vcpus 1)
(cpu_weight 1.0)
(memory 512)
(shadow_memory 0)
(maxmem 1252)
(features )
(name abc)
(on_poweroff destroy)
(on_reboot restart)
(on_crash restart)
(image
(linux
(ramdisk /var/lib/xen/boot_ramdisk.n6dsY3)
(kernel /var/lib/xen/boot_kernel.WQ20K4)
(args 'ro root=/dev/rootvg/root_lv console=tty
console=xvc0,9600n8')
)
)
(device
(vif
(backend 0)
(script vif-bridge)
(ip 192.168.122.2)
(mac 00:16:3e:7a:ef:c8)
)
)
(device
(tap
(backend 0)
(dev xvda:disk)
(uname tap:aio:/guestos/abc.img)
(mode w)
)
)
(state -b)
(shutdown_reason poweroff)
(cpu_time 5105.61669922)
(online_vcpus 1)
(up_time 130216.548227)
(start_time 1219723483.04)
)


3.0

/var/log/xen/xend.log:

[2008-08-27 09:44:37 xend 12004] DEBUG (DevController:476)
hotplugStatusCallback /local/domain/0/backend/tap/5/51712/hotplug-status.
[2008-08-27 09:44:37 xend 12004] DEBUG (DevController:490)
hotplugStatusCallback 1.
[2008-08-27 09:44:37 xend 12004] DEBUG (DevController:143) Waiting for
devices vtpm.
[2008-08-27 09:44:37 xend 12004] INFO (XendDomain:380) Domain f9 (5)
unpaused.
[2008-08-27 11:10:39 xend.XendDomainInfo 12004] INFO (XendDomainInfo:947)
Domain has shutdown: name=f9 id=5 reason=poweroff.
[2008-08-27 11:10:39 xend.XendDomainInfo 12004] DEBUG (XendDomainInfo:1560)
XendDomainInfo.destroy: domid=5
[2008-08-27 11:10:39 xend.XendDomainInfo 12004] DEBUG (XendDomainInfo:1568)
XendDomainInfo.destroyDomain(5)
[2008-08-27 11:14:09 xend 12003] INFO (SrvDaemon:190) Xend stopped due to
signal 15.
[2008-08-27 11:14:09 xend 1816] INFO (SrvDaemon:283) Xend Daemon started
[2008-08-27 11:14:09 xend 1816] INFO (SrvDaemon:287) Xend changeset:
unavailable.
[2008-08-27 11:14:09 xend.XendDomainInfo 1816] DEBUG (XendDomainInfo:222)
XendDomainInfo.recreate({'paused': 0, 'cpu_time': 21556121997234L,
'ssidref': 0, 'hvm': 0, 'shutdown_reason': 0, 'dying': 0, 'mem_kb': 524372L,
'domid': 0, 'max_vcpu_id': 1, 'crashed': 0, 'running': 1, 

[libvirt] PATCH: Switch openvz driver to domain APIs

2008-08-27 Thread Daniel P. Berrange
This patch is the minimum effort port of the OpenVZ driver over to the
new generic domain XML routines. It basically removes all the existing
config format stuff from openvz_conf, defines a set of openvz capabilities
and implements the DumpXML method too. This is enough to get all the core
libvirt functions working. The biggest flaw I see currently is that the
openvz driver doesn't load the existing device config for networks or
filesystems of existing VMs, so you can't see that info in the XML dump

Daniel

diff -r e270be59a80f src/openvz_conf.c
--- a/src/openvz_conf.c Wed Aug 27 17:03:25 2008 +0100
+++ b/src/openvz_conf.c Wed Aug 27 17:26:08 2008 +0100
@@ -40,39 +40,29 @@
 #include limits.h
 #include errno.h
 #include string.h
-
-#include libxml/parser.h
-#include libxml/tree.h
-#include libxml/xpath.h
-#include libxml/uri.h
-
-#include internal.h
-
-#include openvz_driver.h
+#include sys/utsname.h
+
 #include openvz_conf.h
 #include uuid.h
 #include buf.h
 #include memory.h
 #include util.h
-#include xml.h
-#include domain_conf.h
 
 static char *openvzLocateConfDir(void);
-static struct openvz_vm_def *openvzParseXML(virConnectPtr conn, xmlDocPtr xml);
 static int openvzGetVPSUUID(int vpsid, char *uuidstr);
-static int openvzSetUUID(int vpsid);
 static int openvzLocateConfFile(int vpsid, char *conffile, int maxlen);
+static int openvzAssignUUIDs(void);
 
 void
 openvzError (virConnectPtr conn, virErrorNumber code, const char *fmt, ...)
 {
 va_list args;
-char errorMessage[OPENVZ_MAX_ERROR_LEN];
+char errorMessage[1024];
 const char *errmsg;
 
 if (fmt) {
 va_start(args, fmt);
-vsnprintf(errorMessage, OPENVZ_MAX_ERROR_LEN-1, fmt, args);
+vsnprintf(errorMessage, sizeof(errorMessage)-1, fmt, args);
 va_end(args);
 } else {
 errorMessage[0] = '\0';
@@ -84,46 +74,6 @@ openvzError (virConnectPtr conn, virErro
  errmsg, errorMessage);
 }
 
-struct openvz_vm
-*openvzFindVMByID(const struct openvz_driver *driver, int id) {
-struct openvz_vm *vm = driver-vms;
-
-while (vm) {
-if (vm-vpsid == id)
-return vm;
-vm = vm-next;
-}
-
-return NULL;
-}
-
-struct openvz_vm
-*openvzFindVMByUUID(const struct openvz_driver *driver,
-   const unsigned char *uuid) {
-struct openvz_vm *vm = driver-vms;
-
-while (vm) {
-if (!memcmp(vm-vmdef-uuid, uuid, VIR_UUID_BUFLEN))
-return vm;
-vm = vm-next;
-}
-
-return NULL;
-}
-
-struct openvz_vm
-*openvzFindVMByName(const struct openvz_driver *driver,
-   const char *name) {
-struct  openvz_vm *vm = driver-vms;
-
-while (vm) {
-if (STREQ(vm-vmdef-name, name))
-return vm;
-vm = vm-next;
-}
-
-return NULL;
-}
 
 int
 strtoI(const char *str)
@@ -135,6 +85,43 @@ strtoI(const char *str)
 
 return val;
 }
+
+virCapsPtr openvzCapsInit(void)
+{
+struct utsname utsname;
+virCapsPtr caps;
+virCapsGuestPtr guest;
+
+uname(utsname);
+
+if ((caps = virCapabilitiesNew(utsname.machine,
+   0, 0)) == NULL)
+goto no_memory;
+
+if ((guest = virCapabilitiesAddGuest(caps,
+ exe,
+ utsname.machine,
+ sizeof(int) == 4 ? 32 : 8,
+ NULL,
+ NULL,
+ 0,
+ NULL)) == NULL)
+goto no_memory;
+
+if (virCapabilitiesAddGuestDomain(guest,
+  openvz,
+  NULL,
+  NULL,
+  0,
+  NULL) == NULL)
+goto no_memory;
+return caps;
+
+no_memory:
+virCapabilitiesFree(caps);
+return NULL;
+}
+
 
 /* function checks MAC address is empty
return 0 - empty
@@ -164,438 +151,105 @@ char *openvzMacToString(const unsigned c
 return strdup(str);
 }
 
-void
-openvzRemoveInactiveVM(struct openvz_driver *driver, struct openvz_vm *vm)
-{
-driver-num_inactive--;
-openvzFreeVM(driver, vm, 1);
-}
-
-/* Free all memory associated with a openvz_vm_def structure */
-void
-openvzFreeVMDef(struct openvz_vm_def *def)
-{
-if (def) {
-virDomainNetDefFree(def-net);
-}
-}
-
-/* Free all memory associated with a openvz_vm structure
- * @checkCallee == 0 then openvzFreeDriver() is callee else some other function
- */
-void
-openvzFreeVM(struct openvz_driver *driver, struct openvz_vm *vm,
- int checkCallee)
-{
-struct openvz_vm *vms;
-
-if (!vm  !driver)
-return;
-vms = driver-vms;
-if (checkCallee) {
-if (vms == vm)
-driver-vms = vm-next;
-else 

Re: [libvirt] libvir: Xen error

2008-08-27 Thread Richard W.M. Jones
On Wed, Aug 27, 2008 at 11:28:17AM -0500, mantra UNIX wrote:
 Once the guest was shutdown, i ran the following command to check the stuats
 of the guest(s)
[...]
 # xm list
 Error: Device 0 not connected
 Usage: xm list [options] [Domain, ...]
[...]
 # virsh list
  Id Name State
 --
   0 Domain-0 running
   2 pranav   blocked
   4 prabhas  blocked
 libvir: Xen Daemon error : internal error domain information incomplete,
 missing name

That looks nasty.  What versions of everything are you running
(eg. libvirt, xen, kernel-xen, etc.)?  Is this standard RHEL 5.2 or
have you installed anything?

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


RE: [libvirt] Writing a new driver for libvirt

2008-08-27 Thread Orr, David-P64407
Thanks for the response.  I will look that the functions that you have
pointed out for the other drivers here and see how they would be
implemented for ours.  Based on your description I think we would use a
stateless driver, since there are external tools and configurations
available.

To answer your question, it is actually a version of VMware Workstation
with a Hypervisor added to it.  This is for our TVE product here at
General Dynamics; here is a link to the product description:

http://www.gdc4s.com/content/detail.cfm?item=35a995b0-b3b7-4097-9324-2c5
0008b3a75

Another question, how mature is the CIM interface of libvirt.  I have
not had much time to look at it yet, but we would be using it for remote
management.

David Orr
General Dynamics
Software Engineer
[EMAIL PROTECTED]

|-Original Message-
|From: Daniel P. Berrange [mailto:[EMAIL PROTECTED]
|Sent: Wednesday, August 27, 2008 10:03 AM
|To: Orr, David-P64407
|Cc: libvir-list@redhat.com
|Subject: Re: [libvirt] Writing a new driver for libvirt
|
|On Wed, Aug 27, 2008 at 09:47:40AM -0700, Orr, David-P64407 wrote:
| Hey all,
|
| I am new to libvirt and have been asked to look at the possibility of
| writing a libvirt driver for a hypervisor we are using.  I am
wondering
| if someone can give me the basics on what is involved in
accomplishing
| this task, what are the basics of writing a new driver?  I have
looked
| at the documentation posted and been poking around the code and just
| wanted to ask someone to point me in the right direction.
|
|There are essentially two types of libvirt driver styles. First one I
|call 'stateless', where libvirt doesn't maintain any persistent info
|itself, and just talks to the hypervisor / external tools to implement
|every API. The second style is 'stateful', where libvirt directly
manages
|everything, including persistence of the domain configuration info.
|
|Examples of stateless drivers are  Xen, and OpenVZ.
|
|Examples of stateful drivers are QEMU, LXC
|
|As for choosing which style to use, it depends on the hypervisor in
|question.
|If your hypervisor has ability to storage persistent configuration
data,
|and
|make that available to libvirt, then stateless is the best approac
because
|it provides interoperability with existing tools for that hypervisor.
|
|As for actually implementing things, you can take an incremental
approach,
|adding impls for individual methods as you go. The 'struct _virDriver'
|in src/driver.h file lists all the  APIs you need for a complete impl
|of libvirt on a hypervisor, but you certainly don't need to have all of
|them to get something useful working.
|
|I'd recommend starting with Probe, Open, Close, NumOfDomains,
ListDomains
|and DomainGetInfo. That should be enough to get 'virsh list' working.
|
|Then, add  NumOfDefinedDomains and ListDefinedDomain. That will get the
|virsh list --inactive  command working
|
|Then add  NodeGetInfo and GetCapabilities, which lets 'virsh nodeinfo'
|and 'virsh capabilities' to work.
|
|Then add  DomainDumpXML  to allow a domain config to be queried via
|virsh dumpxml
|
|And then add
DomainCreateLinux/DomainCreate/DomainDefine/DomainUndefine
|to allow new domains to be created, started, and deleted.
|
|At this point you'll have a pretty good impl working. Anything else
beyond
|this point is just a nice bonus.
|
|For parsing XML file, the 'src/domain_conf.h' file APIs should be used.
|There are other useful APIs for internal use in util.h, capabilities.h,
|buf.h, and memory.h.
|
|Also look at the HACKING file for general guidelines.
|
|Finally, ask questions on this list for anything you don't understand.
|The task of writing new hypervisor drivers is not at all documented
|but there are lots of people who can advise you
|
|
|Out of interest. what hypervisor are you using ?
|
|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: 4/4: Add pivot_root support to container

2008-08-27 Thread Daniel P. Berrange
On Wed, Aug 27, 2008 at 01:32:13PM -0700, Dan Smith wrote:
 DB +static int lxcContainerMountNewFS(virDomainDefPtr vmDef)
 DB +{
 DB +virDomainFSDefPtr tmp;
 DB +
 DB +/* Pull in rest of container's mounts */
 DB +for (tmp = vmDef-fss; tmp; tmp = tmp-next) {
 DB +char *src;
 DB +if (STREQ(tmp-dst, /))
 DB +continue;
 DB +// XXX fix
 DB +if (tmp-type != VIR_DOMAIN_FS_TYPE_MOUNT)
 DB +continue;
 DB +
 DB +if (asprintf(src, /.oldroot/%s, tmp-src)  0)
 DB +return -1;
 DB +
 DB +if (virFileMakePath(tmp-dst)  0 ||
 DB +mount(src, tmp-dst, NULL, MS_BIND, NULL)  0) {
 DB +VIR_FREE(src);
 DB +lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 DB + _(failed to mount %s at %s for container: %s),
 DB + tmp-src, tmp-dst, strerror(errno));
 DB +return -1;
 DB +}
 DB +VIR_FREE(src);
 DB +}
 DB +return -1;
 
 Shouldn't this be return 0?  AFAICT, this means this function will
 always fail and thus any domain with a root target will fail to start.
 If I change this to return 0 I'm able to start such guests, with
 properly pivoted roots.

Yes, it clearly should be return 0.

 On a more general note, it seems like there are a lot of places where
 failures trigger a return -1 that rolls completely up the stack with
 no error information getting logged.  Since you have the excellent
 per-container logging functionality, can we increase the verbosity a
 little so that there is some way to diagnose where things are failing?
 Thus far, I've just started sprinkling fprintf()'s into the code until I
 start to narrow things down.  I'd be glad to help with that after this
 goes in.

The newly improved virExec() API which LXC now uses ensures that libvirt's
error callback is reset to the default in child processes. This means that
any call to virRaiseError in the child is turned into a fprintf(stderr...).
We also wire the container stdout/err to /var/log/libvirt/lxc/NAME.log
So if everything is operating as I expect, all the lxcError() calls in
this code should result in log messages being written out to /var/log.


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] Re: [augeas-devel] PATCH: Add a augeas lens for libvirtd.conf

2008-08-27 Thread David Lutterkort
On Wed, 2008-08-27 at 12:03 +0100, Richard W.M. Jones wrote:
 Out of interest, do you ever hit the 16 bit limit in the size of
 compiled regexps?  The bytecode used to represent compiled GNU
 regexps has (or perhaps had) a 16 bit limit in the jump offsets, which
 I hit a few years back.  Had to switch to using a flex-compiled
 pattern matcher in the end.

No, I haven't run into that. Was that with the 'old' GNU regex
implementation (before ~ 2002) or with the current one ?

David


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


Re: [libvirt] Re: [augeas-devel] PATCH: Add a augeas lens for libvirtd.conf

2008-08-27 Thread David Lutterkort
On Wed, 2008-08-27 at 12:15 +0100, Richard W.M. Jones wrote:
 Dan pointed out that you have your own DFA implementation.

Actually, libf does everything but matching - it does all the regexp
calculations needed for the typechecker; for matching, I use GNU regex.

David


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


[libvirt] Re: [augeas-devel] PATCH: Add a augeas lens for libvirtd.conf

2008-08-27 Thread David Lutterkort
On Wed, 2008-08-27 at 12:31 +0100, Daniel P. Berrange wrote:
 On Tue, Aug 26, 2008 at 09:40:41PM +, David Lutterkort wrote:
  On Tue, 2008-08-26 at 21:05 +0100, Daniel P. Berrange wrote:
  
   +   let empty = [ label empty . del /[ \t]*\n/  ]
  
  Do you really care that empty entries show up in the tree ? If you don't
  want to see them, you can remove the 'label' from the above, and
  possibly also the '[ .. ]'.
 
 Ok, this gets fun. I don't particularly want the label or tree node.
 I can remove the label OK, but that gives anonymous tree nods. 

Thinking about this some more, anonymous (or labelled) nodes are
probably your best bet here, because:

 If I remove the [...], then I end up with
 
 test -x /usr/bin/augparse  /usr/bin/augparse -I . test_libvirtd.aug
 ./libvirtd.aug:63.3-.43:Failed to compile lns
 ./libvirtd.aug:63.13-.43:exception: ambiguous tree iteration
   'ca_file/' can be split into
   '|=|ca_file/'
 
  and
   'ca_file/|=|'
 
 Iterated lens: ./libvirtd.aug:63.15-.39
 
 test_libvirtd.aug:253.8-.20:Could not load module Libvirtd for Libvirtd.lns
 test_libvirtd.aug:253.8-.20:Undefined variable Libvirtd.lns
 test_libvirtd.aug: error: Loading failed
 
 And I'm utterly stuck on what this means / how to fix it. I didn't
 expect removing the square brackets to change the DFA.

The error message is admittedly obtuse (though I am not sure how to
improve it, suggestions welcome) 

What Augeas is telling you (or trying to, atleast) is that when it goes
to write a tree back into the file (that's why it mentions 'tree
iteration') it has a choice, and doesn't know what to do in the lens on
line 63, columns 3 - 43, which is the toplevel 'lns' lens:

 let lns = ( record | comment | empty ) *

The '|=|' mark in the error message shows where Augeas thinks it could
split a tree with a single node 'ca_file': either into (no node,
cafile/) or (cafile/, no node) .. what makes this error message doubly
heinous is that there's no good notation for 'no node' - it's the empty
string in the error message.

The issue is that when it sees a tree with a single node 'ca_file' it
doesn't know whether to process that as a single 'record' or as a
'record . empty' or 'empty . record', since all of these match the tree
with a single 'ca_file' entry, simply because the 'empty' lens now
leaves no traces in the tree that it had been used. 

When you define 'empty' as '[ eol ]', Augeas knows how to process that
tree since every time 'empty' should be used, there must be a node in
the tree with a NULL label, so a single tree node 'ca_file' can only be
processed by using 'record', and not 'record . empty' or similar.

As I said, the simplest way around this is to define 'empty' as
'[ eol ]' - you could also try to change things so that empty lines are
pulled into record or comment entries, but that's probably more trouble
than it's worth.

  I've been thinking that we need to have some function that reads a file
  and returns a string so we don't have to clutter tests with these long
  strings. But for now, that's what it is :(
 
 Yes, that would be very nice - and/or supporting use of HERE documents
 for strings, so I don't have to escape   throughout the embedded config
 file

One more note on this: to get started, pulling in a whole config file
and checking that that gets processed in a reasonable way is deifnitely
the best thing to do. Over time, as you make changes to the file format
and/or fix bugs in the lens, you're probably better off writing small
tests that check for one particular thing (the test_shellvars.aug in
Augeas hg is a good example for this)

I put a ticket into Trac for this[1]

 One other useful improvement would be for the test suite to only print
 out sections of the tree which differ. In debugging this it printed
 out a 400 line 'Expected' tree structure, and then a 400 line 'Actual'
 tree structure and wanted me to play Where's Waldo to find the typo.
 
 It would be good to trim the leading and trailing nodes which are the
 same

Yeah, I've run into this before, too. Yet another ticket[2]

  All in all, very nice, and I am really glad that upstream is shipping a
  lens :)
 
 Just discovered one minor issue. The Fedora RPM guidelines require that
 an RPM either own a directory, or require an RPM that owns it, and two
 RPMs aren't allowed to own the same directory. I don't want/need to
 depend on Augeas directly, but equally I need someone to own the
 /usr/share/augeas/lens directory. Wonder if that directory should be put
 into the 'filesystem'  RPM  ?

Yeah, that's the only feasible solution. I'll need to figure out what
the process for that is.

David

[1] http://fedorahosted.org/augeas/ticket/10
[2] http://fedorahosted.org/augeas/ticket/11


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


[libvirt] [PATCH] xen: fix domain lookup after define

2008-08-27 Thread Cole Robinson
Defining a xen domain will succeed, but report
error because we weren't properly passing the
domain's name to the post-define lookup.

Attached patch fixes this, and also adds a
debug statement to show the sexpr we create
from the passed xml.

Thanks,
Cole
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 2a687c3..124ee8b 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -4270,7 +4270,6 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
 virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) 
{
 int ret;
 char *sexpr;
-char *name = NULL;
 virDomainPtr dom;
 xenUnifiedPrivatePtr priv;
 virDomainDefPtr def;
@@ -4292,15 +4291,17 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr 
conn, const char *xmlDesc) {
 goto error;
 }
 
+DEBUG(Defining w/ sexpr: \n%s, sexpr);
+
 ret = xend_op(conn, , op, new, config, sexpr, NULL);
 VIR_FREE(sexpr);
 if (ret != 0) {
 virXendError(conn, VIR_ERR_XEN_CALL,
- _(Failed to create inactive domain %s\n), name);
+ _(Failed to create inactive domain %s\n), def-name);
 goto error;
 }
 
-dom = virDomainLookupByName(conn, name);
+dom = virDomainLookupByName(conn, def-name);
 if (dom == NULL) {
 goto error;
 }
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Use gcc style for structure fields declaration

2008-08-27 Thread Nguyen Anh Quynh
Hi,

This patch uses gcc style to declare fields in virDriver structures.
This also makes it easier to spot bugs.

$ diffstat fix3.patch
 lxc_driver.c|  118 ++--
 openvz_driver.c |  118 ++--
 qemu_driver.c   |  126 
 test.c  |  118 ++--
 4 files changed, 240 insertions(+), 240 deletions(-)


Thanks,
Quynh


fix3.patch
Description: Binary data
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] Use gcc style for structure fields declaration

2008-08-27 Thread Atsushi SAKAI
Hi, Quynh

Good catch!
 +1

Thanks
Atsushi SAKAI


Nguyen Anh Quynh [EMAIL PROTECTED] wrote:

 Hi,
 
 This patch uses gcc style to declare fields in virDriver structures.
 This also makes it easier to spot bugs.
 
 $ diffstat fix3.patch
  lxc_driver.c|  118 ++--
  openvz_driver.c |  118 ++--
  qemu_driver.c   |  126 
 
  test.c  |  118 ++--
  4 files changed, 240 insertions(+), 240 deletions(-)
 
 
 Thanks,
 Quynh


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


[libvirt] Exposing some unique features?

2008-08-27 Thread Nguyen Anh Quynh
Hi,

Though libvirt tries very hard to hide the difference between
hypervisors behind an abstraction layer, there are still differences
that we might want to expose to the users. For example, QEMU has the
monitor interface, which provides some unique functions. Users might
want to have access to the monitor interface and send command to it
(like gdbserver command?).

So how can we expose such information? We can have a new driver
function, which return an opaque structure. The content of the
structure is of course depends on the hypervisor type.

One problem is that this might be dangerous if users relies on the
QEMU monitor to execute some functions that should be done under
control.

Idea?

Thanks,
Quynh

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


Re: [libvirt] Exposing some unique features?

2008-08-27 Thread Atsushi SAKAI
Hi, Quynh

Did you see the libvirt access control feature?
http://libvirt.org/auth.html
You mean current access control feature is not enough for your use.


Thanks
Atsushi SAKAI





Nguyen Anh Quynh [EMAIL PROTECTED] wrote:

 Hi,
 
 Though libvirt tries very hard to hide the difference between
 hypervisors behind an abstraction layer, there are still differences
 that we might want to expose to the users. For example, QEMU has the
 monitor interface, which provides some unique functions. Users might
 want to have access to the monitor interface and send command to it
 (like gdbserver command?).
 
 So how can we expose such information? We can have a new driver
 function, which return an opaque structure. The content of the
 structure is of course depends on the hypervisor type.
 
 One problem is that this might be dangerous if users relies on the
 QEMU monitor to execute some functions that should be done under
 control.
 
 Idea?
 
 Thanks,
 Quynh
 
 --
 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