Re: [libvirt] Interface driver and ESX support

2009-09-10 Thread Shahar Klein
I'm not sure what you mean about mapping 

lets take the pnics as a study case for me

do I need to define a structure similar to this:
http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html

and also take care for it's allocation?






From: Matthias Bolte matthias.bo...@googlemail.com
To: Shahar Klein shaharkl...@yahoo.com
Cc: Chris Lalancette clala...@redhat.com; libvir-list@redhat.com
Sent: Wednesday, September 9, 2009 1:11:47 PM
Subject: Re: [libvirt] Interface driver and ESX support

2009/9/9 Shahar Klein shaharkl...@yahoo.com:
 I think I understand the mechanism of the VI API
 and the way esx_vi.c is using it
 the surounding is a bit more complex for me
 so
 can you provide the framework?
 I mean
 can you put in the esx_interface_driver.c and h
 and the registration etc...
 and also putting it all into the auto make mechanism(I should learn this
 sometime...)
 I will put in the content into the functions
 for the time being I am registering the esx_driver as the interface driver
 so I can get a fill of it

Well, if you want to give it a try, here you go.

I attached a patch that adds a basic interface driver with open and
close method. The interface driver doesn't need it's own private
driver struct, it just uses the same context already opened by the
main ESX driver.

Listing the available physical NICs should be easy. You'll need to
obtain the HostSystem object and query for its config.network.pnic
property. This is a list of PhysicalNic objects. You'll need to add a
mapping for the PhysicalNic type to the esx_vi_types.[ch]. There is
plenty of examples in the current ESX driver how to do all these
things.

Matthias



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


[libvirt] [PATCH 2/5] Update capabilities schema to allow multiple machines per domain

2009-09-10 Thread Mark McLoughlin
* docs/schemas/capabilities.rng: allow multiple machines per domain
  just like they are allowed for guests
---
 docs/schemas/capability.rng |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index dbfe1c5..a9daa40 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -224,9 +224,9 @@
   optional
ref name='emulator'/
   /optional
-  optional
+  zeroOrMore
ref name='machine'/
-  /optional
+  /zeroOrMore
 /element
   /define
 
-- 
1.6.2.5

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


[libvirt] [PATCH 1/5] Add esx and tcp migration uri transports to capabilities schema

2009-09-10 Thread Mark McLoughlin
* docs/schemas/capabilities.rng: include esx and tcp uri_transport
---
 docs/schemas/capability.rng |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 1e3c5f3..dbfe1c5 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -79,6 +79,8 @@
  oneOrMore
element name='uri_transport'
  choice
+   valueesx/value
+   valuetcp/value
valuexenmigr/value
  /choice
/element
-- 
1.6.2.5

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


[libvirt] [PATCH 3/5] Add arm arch to capabilities schema

2009-09-10 Thread Mark McLoughlin
* docs/schemas/capabilities.rng: add arm and sort arches
---
 docs/schemas/capability.rng |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index a9daa40..3e8944c 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -279,15 +279,16 @@
 
   define name='archnames'
 choice
+  valuearm/value
   valuei686/value
-  valuex86_64/value
-  valueppc/value
-  valueppc64/value
   valueia64/value
-  values390/value
   valuemips/value
   valuemipsel/value
+  valueppc64/value
+  valueppc/value
+  values390/value
   valuesparc/value
+  valuex86_64/value
 /choice
   /define
 
-- 
1.6.2.5

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


[libvirt] [PATCH 4/5] Add a more featureful qemu capabilities test data

2009-09-10 Thread Mark McLoughlin
Things added include

  - x86_64 host
  - Migration features
  - NUMA topology
  - Security model
  - Canonical machine types
  - Domain machine types
  - An arm guest
  - More machine types for mips, mipsel, sparc and ppc
  - An x86_64 xenner guest

This file was generated on a Fedora 12 machine using latest libvirt
and qemu-kvm-0.11.0-rc2

* tests/capabilityschemadata/caps-qemu-kvm.xml: add more features
  to test
---
 tests/capabilityschemadata/caps-qemu-kvm.xml |  114 +-
 1 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/tests/capabilityschemadata/caps-qemu-kvm.xml 
b/tests/capabilityschemadata/caps-qemu-kvm.xml
index a70e1a4..47accde 100644
--- a/tests/capabilityschemadata/caps-qemu-kvm.xml
+++ b/tests/capabilityschemadata/caps-qemu-kvm.xml
@@ -2,8 +2,30 @@
 
   host
 cpu
-  archi686/arch
+  archx86_64/arch
 /cpu
+migration_features
+  live/
+  uri_transports
+uri_transporttcp/uri_transport
+  /uri_transports
+/migration_features
+topology
+  cells num='1'
+cell id='0'
+  cpus num='4'
+cpu id='0'/
+cpu id='1'/
+cpu id='2'/
+cpu id='3'/
+  /cpus
+/cell
+  /cells
+/topology
+secmodel
+  modelselinux/model
+  doi0/doi
+/secmodel
   /host
 
   guest
@@ -11,12 +33,18 @@
 arch name='i686'
   wordsize32/wordsize
   emulator/usr/bin/qemu/emulator
-  machinepc/machine
+  machinepc-0.11/machine
+  machine canonical='pc-0.11'pc/machine
+  machinepc-0.10/machine
   machineisapc/machine
   domain type='qemu'
   /domain
   domain type='kvm'
 emulator/usr/bin/qemu-kvm/emulator
+machinepc-0.11/machine
+machine canonical='pc-0.11'pc/machine
+machinepc-0.10/machine
+machineisapc/machine
   /domain
 /arch
 features
@@ -32,10 +60,19 @@
 arch name='x86_64'
   wordsize64/wordsize
   emulator/usr/bin/qemu-system-x86_64/emulator
-  machinepc/machine
+  machinepc-0.11/machine
+  machine canonical='pc-0.11'pc/machine
+  machinepc-0.10/machine
   machineisapc/machine
   domain type='qemu'
   /domain
+  domain type='kvm'
+emulator/usr/bin/qemu-kvm/emulator
+machinepc-0.11/machine
+machine canonical='pc-0.11'pc/machine
+machinepc-0.10/machine
+machineisapc/machine
+  /domain
 /arch
 features
   acpi default='on' toggle='yes'/
@@ -45,9 +82,44 @@
 
   guest
 os_typehvm/os_type
+arch name='arm'
+  wordsize32/wordsize
+  emulator/usr/bin/qemu-system-arm/emulator
+  machineintegratorcp/machine
+  machinesyborg/machine
+  machinemusicpal/machine
+  machinemainstone/machine
+  machinen800/machine
+  machinen810/machine
+  machinecheetah/machine
+  machinesx1/machine
+  machinesx1-v1/machine
+  machinetosa/machine
+  machineakita/machine
+  machinespitz/machine
+  machineborzoi/machine
+  machineterrier/machine
+  machineconnex/machine
+  machineverdex/machine
+  machinelm3s811evb/machine
+  machinelm3s6965evb/machine
+  machinerealview/machine
+  machineversatilepb/machine
+  machineversatileab/machine
+  domain type='qemu'
+  /domain
+/arch
+  /guest
+
+  guest
+os_typehvm/os_type
 arch name='mips'
   wordsize32/wordsize
   emulator/usr/bin/qemu-system-mips/emulator
+  machinemalta/machine
+  machinemipssim/machine
+  machinemagnum/machine
+  machinepica61/machine
   machinemips/machine
   domain type='qemu'
   /domain
@@ -59,6 +131,10 @@
 arch name='mipsel'
   wordsize32/wordsize
   emulator/usr/bin/qemu-system-mipsel/emulator
+  machinemalta/machine
+  machinemipssim/machine
+  machinemagnum/machine
+  machinepica61/machine
   machinemips/machine
   domain type='qemu'
   /domain
@@ -70,7 +146,18 @@
 arch name='sparc'
   wordsize32/wordsize
   emulator/usr/bin/qemu-system-sparc/emulator
-  machinesun4m/machine
+  machineSS-5/machine
+  machineSS-10/machine
+  machineSS-600MP/machine
+  machineSS-20/machine
+  machineVoyager/machine
+  machineLX/machine
+  machineSS-4/machine
+  machineSPARCClassic/machine
+  machineSPARCbook/machine
+  machineSS-1000/machine
+  machineSS-2000/machine
+  machineSS-2/machine
   domain type='qemu'
   /domain
 /arch
@@ -82,6 +169,10 @@
   wordsize32/wordsize
   emulator/usr/bin/qemu-system-ppc/emulator
   machineg3beige/machine
+  machinempc8544ds/machine
+  machinebamboo/machine
+  machineref405ep/machine
+  machinetaihu/machine
   machinemac99/machine
   machineprep/machine
   domain type='qemu'
@@ -106,4 +197,19 @@
 /features
   /guest
 
+  guest
+os_typexen/os_type
+arch name='x86_64'
+  

Re: [libvirt] [PATCH] Close logfile fd after spawning qemu

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 02:13:56PM +0900, Ryota Ozaki wrote:
 Hi,
 
 This patch closes logfile fd after spawing qemu in qemudStartVMDaemon.
 The fd seems to be closed in the error path, but not in the normal path.
 The fd is passed to virExecDaemonize though, but looks not being closed
 inside it. Eventually, the fd is never closed during libvirtd lifetime.
 
 Thanks,
   ozaki-r
 
 From b3d3e0f24c5df5c7677e539bbc2598f2d7fbc3b8 Mon Sep 17 00:00:00 2001
 From: Ryota Ozaki ozaki.ry...@gmail.com
 Date: Thu, 10 Sep 2009 12:53:56 +0900
 Subject: [PATCH] Close logfile fd after spawning qemu
 
 ---
  src/qemu_driver.c |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 
 diff --git a/src/qemu_driver.c b/src/qemu_driver.c
 index 8f16e72..f2182c4 100644
 --- a/src/qemu_driver.c
 +++ b/src/qemu_driver.c
 @@ -2187,6 +2187,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS,
 qemudSecurityHook, hookData,
 pidfile);
 +close(logfile);
  VIR_FREE(pidfile);
 
  /* wait for qemu process to to show up */

  Hum, it's not quite simple. It's passed down to __virExec()
where it is provided as the stdout/stderr to use, it's not closed
there on the parent though. I guess it's safe to close it at that
point at the end of qemudStartVMDaemon() since only the child can
use it (up to the exec because it is been close on exec'ed).

  So looks fine to me but I would appreciate a second opinion :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] Close logfile fd after spawning qemu

2009-09-10 Thread Mark McLoughlin
On Thu, 2009-09-10 at 11:04 +0200, Daniel Veillard wrote:
 On Thu, Sep 10, 2009 at 02:13:56PM +0900, Ryota Ozaki wrote:
  Hi,
  
  This patch closes logfile fd after spawing qemu in qemudStartVMDaemon.
  The fd seems to be closed in the error path, but not in the normal path.
  The fd is passed to virExecDaemonize though, but looks not being closed
  inside it. Eventually, the fd is never closed during libvirtd lifetime.
  
  Thanks,
ozaki-r
  
  From b3d3e0f24c5df5c7677e539bbc2598f2d7fbc3b8 Mon Sep 17 00:00:00 2001
  From: Ryota Ozaki ozaki.ry...@gmail.com
  Date: Thu, 10 Sep 2009 12:53:56 +0900
  Subject: [PATCH] Close logfile fd after spawning qemu
  
  ---
   src/qemu_driver.c |1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
  
  diff --git a/src/qemu_driver.c b/src/qemu_driver.c
  index 8f16e72..f2182c4 100644
  --- a/src/qemu_driver.c
  +++ b/src/qemu_driver.c
  @@ -2187,6 +2187,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
  VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS,
  qemudSecurityHook, hookData,
  pidfile);
  +close(logfile);
   VIR_FREE(pidfile);
  
   /* wait for qemu process to to show up */
 
   Hum, it's not quite simple.

Indeed. I only had a quick look and wasn't sure. We at least need to set
logfile to -1 after closing it to avoid trying to close it again further
down.

Cheers,
Mark.

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


Re: [libvirt] [PATCH] Reintroduce lzop compression

2009-09-10 Thread Daniel Veillard
On Wed, Sep 09, 2009 at 03:59:22PM -0500, Charles Duffy wrote:

 From 3c4f6568623ed420a9e71da33b9ce74abda289a8 Mon Sep 17 00:00:00 2001
 From: Charles Duffy charles_du...@dell.com
 Date: Wed, 9 Sep 2009 15:53:25 -0500
 Subject: [PATCH] Reintroduce support for lzop compression
 
 lzop was removed due to some confusion over whether it provided functional
 advantages distinct from xz. This has been addressed in the mailing list post
 archived at http://permalink.gmane.org/gmane.comp.emulators.libvirt/16487, and
 support for lzop is re-added here.

  Okay, you clearly made the case for lzop in the list, thanks for
clearing this up, this make sense !

  Applied and pushed,

   thanks !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] Close logfile fd after spawning qemu

2009-09-10 Thread Ryota Ozaki
On Thu, Sep 10, 2009 at 6:04 PM, Daniel Veillardveill...@redhat.com wrote:
  Hum, it's not quite simple. It's passed down to __virExec()
 where it is provided as the stdout/stderr to use, it's not closed
 there on the parent though. I guess it's safe to close it at that
 point at the end of qemudStartVMDaemon() since only the child can
 use it (up to the exec because it is been close on exec'ed).

Hmm, I'm not sure the effect to the child though, it sounds safer.
  ozaki-r


  So looks fine to me but I would appreciate a second opinion :-)

 Daniel

 --
 Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
 dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
 http://veillard.com/ | virtualization library  http://libvirt.org/


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


Re: [libvirt] [PATCH] Fix handling of Xen(ner) detection

2009-09-10 Thread Daniel P. Berrange
On Fri, Sep 04, 2009 at 03:15:53PM +0200, Daniel Veillard wrote:
 On Fri, Aug 28, 2009 at 11:21:07AM +0100, Daniel P. Berrange wrote:
  Latest upstream QEMU can be built with Xen support, which introduces
  a -xen-domid argument. This was  mistakenly detected as -domid due
  to old Xenner support. Adapt to cope with both syntax. Also only
  set domid if the virt type is xen, or the guest type is xen
  
  * src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in
preference to -domid.
 
   Patch looks fine except I had to rebase it
 
  * tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml: Fix domain type
to be xen
 
   But the test are failing for me for example we end up with
 
   os
 type arch='x86_64' machine='pc'xen/type
 boot dev='hd'/
   /os
 
 and that doesn't match ostypehvm nor ostypexen, the first one because
 the value is not hvm the second one because the machine='pc' is not one
 of the accepted attributes values.

Hmm, I did fix all the test cases, because several had bogus XML for
xenner, but I'll re-check this again

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] qemu_driver.c: factor out more duplication

2009-09-10 Thread Jim Meyering
Charles Duffy wrote:
From 3c4f6568623ed420a9e71da33b9ce74abda289a8 Mon Sep 17 00:00:00 2001
 From: Charles Duffy charles_du...@dell.com
 Date: Wed, 9 Sep 2009 15:53:25 -0500
 Subject: [PATCH] Reintroduce support for lzop compression

 lzop was removed due to some confusion over whether it provided functional
 advantages distinct from xz. This has been addressed in the mailing list post
 archived at http://permalink.gmane.org/gmane.comp.emulators.libvirt/16487, and
 support for lzop is re-added here.

 lzop is added to the enum after xz, leaving xz at the position lzma was
 originally in (which is appropriate, as it should handle decompression of
 lzma-format files) and giving lzop back its prior position.

 Documentation in qemu.conf is amended to remove references to lzma and add
 suggestions regarding the tradeoffs made by various compressors.

 Signed-off-by: Charles Duffy char...@dyfis.net
 ---
  libvirt.spec.in   |1 +
  src/qemu.conf |7 ---
  src/qemu_driver.c |9 ++---
  3 files changed, 11 insertions(+), 6 deletions(-)
...
  struct qemud_save_header {
  char magic[sizeof(QEMUD_SAVE_MAGIC)-1];
 @@ -4384,6 +4385,8 @@ static int qemudDomainRestore(virConnectPtr conn,
  intermediate_argv[0] = bzip2;
  else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
  intermediate_argv[0] = xz;
 +else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
 +intermediate_argv[0] = lzop;
  else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) {
  qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
   _(Unknown compressed save format %d),

Thanks for that patch.
I'm glad I read it, since it made me realize my clean-up
from yesterday was incomplete.  You should not have had to add
the literal, lzop, in two places.

This completes the job:

From 05b3f087b7ac29cebd22dfdf099f8fb36a31c86a Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Thu, 10 Sep 2009 11:26:00 +0200
Subject: [PATCH] qemu_driver.c: factor out more duplication

* src/qemu_driver.c (qemudDomainRestore): Use the new ...TypeToString
function here, too.

(qemudSaveCompressionTypeToString): Declare.
---
 src/qemu_driver.c |   18 +++---
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 5c2a8ec..256e8e7 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -4379,21 +4379,17 @@ static int qemudDomainRestore(virConnectPtr conn,

 if (header.version == 2) {
 const char *intermediate_argv[3] = { NULL, -dc, NULL };
-if (header.compressed == QEMUD_SAVE_FORMAT_GZIP)
-intermediate_argv[0] = gzip;
-else if (header.compressed == QEMUD_SAVE_FORMAT_BZIP2)
-intermediate_argv[0] = bzip2;
-else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
-intermediate_argv[0] = xz;
-else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
-intermediate_argv[0] = lzop;
-else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) {
+const char *prog = qemudSaveCompressionTypeToString(header.compressed);
+if (prog == NULL) {
 qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
- _(Unknown compressed save format %d),
+ _(Invalid compressed save format %d),
  header.compressed);
 goto cleanup;
 }
-if (intermediate_argv[0] != NULL) {
+
+if (header.compressed != QEMUD_SAVE_FORMAT_RAW)
+intermediate_argv[0] = prog;
+else {
 intermediatefd = fd;
 fd = -1;
 if (virExec(conn, intermediate_argv, NULL, NULL,
--
1.6.5.rc0.164.g5f6b0

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


Re: [libvirt] [PATCH] Fix misc thread locking bugs / bogus warnings

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:33:24PM +0200, Daniel Veillard wrote:
 On Wed, Sep 02, 2009 at 02:11:50PM +0100, Daniel P. Berrange wrote:
  Fix all thread locking bugs reported by object-locking test
  case.
  
  NB, some of the driver locking is getting too coarse. Driver
  mutexes really need to be turned into RW locks instead to
  significantly increase concurrency.
  
  * src/lxc_driver.c: Fix useof driver when unlocked in the methods
lxcDomainGetInfo, lxcSetSchedulerParameters, and
lxcGetSchedulerParameters
  * src/opennebula/one_driver.c: Fix missing unlock in oneDomainUndefine.
Fix use of driver when unlocked in oneDomainGetInfo,
oneGetOSType, oneDomainShutdown
  * src/qemu_driver.c: Fix use of driver when unlocked in
qemudDomainSavem, qemuGetSchedulerType, qemuSetSchedulerParameters
and qemuGetSchedulerParameters
  * src/storage_driver.c: Re-work storagePoolCreate to avoid bogus
lock checking warning. Re-work storageVolumeCreateXMLFrom to
remove a potential NULL de-reference  avoid bogus lock check
warnings
  * src/test.c: Remove testDomainAssignDef since it break lock chekc
warnings.
  * tests/object-locking.ml: Add oneDriverLock, oneDriverUnlock
and one_driver_t methods/types to allow lock checking on the
 OpenNebula drivers



  diff --git a/src/lxc_driver.c b/src/lxc_driver.c
  index bd0cf0e..0ec1e92 100644
  --- a/src/lxc_driver.c
  +++ b/src/lxc_driver.c
  @@ -439,7 +439,6 @@ static int lxcDomainGetInfo(virDomainPtr dom,
   
   lxcDriverLock(driver);
   vm = virDomainFindByUUID(driver-domains, dom-uuid);
  -lxcDriverUnlock(driver);
   
   if (!vm) {
   lxcError(dom-conn, dom, VIR_ERR_INVALID_DOMAIN,
  @@ -470,6 +469,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
   ret = 0;
   
   cleanup:
  +lxcDriverUnlock(driver);
   if (cgroup)
   virCgroupFree(cgroup);
   if (vm)
 
   I'm just surprized by this series of fixes, I though we needed to drop
 locks when calling into errors routines like lxcError ?


No, we only need to drop the virConnect mutex - the driver/domain mutexes
can be held without trouble.  I really need to write some docs for this
mutex stuff 


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] Close logfile fd after spawning qemu

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 10:15:58AM +0100, Mark McLoughlin wrote:
 On Thu, 2009-09-10 at 11:04 +0200, Daniel Veillard wrote:
  On Thu, Sep 10, 2009 at 02:13:56PM +0900, Ryota Ozaki wrote:
   Hi,
   
   This patch closes logfile fd after spawing qemu in qemudStartVMDaemon.
   The fd seems to be closed in the error path, but not in the normal path.
   The fd is passed to virExecDaemonize though, but looks not being closed
   inside it. Eventually, the fd is never closed during libvirtd lifetime.
   
   Thanks,
 ozaki-r
   
   From b3d3e0f24c5df5c7677e539bbc2598f2d7fbc3b8 Mon Sep 17 00:00:00 2001
   From: Ryota Ozaki ozaki.ry...@gmail.com
   Date: Thu, 10 Sep 2009 12:53:56 +0900
   Subject: [PATCH] Close logfile fd after spawning qemu
   
   ---
src/qemu_driver.c |1 +
1 files changed, 1 insertions(+), 0 deletions(-)
   
   diff --git a/src/qemu_driver.c b/src/qemu_driver.c
   index 8f16e72..f2182c4 100644
   --- a/src/qemu_driver.c
   +++ b/src/qemu_driver.c
   @@ -2187,6 +2187,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
   VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS,
   qemudSecurityHook, hookData,
   pidfile);
   +close(logfile);
VIR_FREE(pidfile);
   
/* wait for qemu process to to show up */
  
Hum, it's not quite simple.
 
 Indeed. I only had a quick look and wasn't sure. We at least need to set
 logfile to -1 after closing it to avoid trying to close it again further
 down.

  Okay, the fd is passed by address to virExecDaemonize, since it was
properly initialized it should not be overwritten by __virExec, but as a
safety I think this should be checked for -1 before close. The fd is not
written anywhere, so we are pretty much sure it's a lost fd at this
point and there is no way the application could use it beyond the
function return. I'm just changing the patch slightly to 

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 5c2a8ec..d778a89 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2239,6 +2239,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
 /* No need for 'goto cleanup' now since qemudShutdownVMDaemon does enou
 }
 
+if (logfile != -1)
+close(logfile);
+
 return ret;
 
 cleanup:


 i.e. check for -1 and close only at the non-cleanup return point.
I just commited this.

  thanks !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 02/11] Avoid polling on FDs with no events enabled

2009-09-10 Thread Chris Lalancette
Chris Lalancette wrote:
 Daniel Veillard wrote:
 On Mon, Aug 24, 2009 at 09:51:05PM +0100, Daniel P. Berrange wrote:
 If a file descriptor with events=0 was added to the libvirtd
 event loop, it would still be added to the poll() fds' array.
 While it wouldn't see any POLLIN/OUT events, it'd still get
 triggered for HANGUP/ERROR events which was not in compliance
 with the libvirt events API contract.
   Independantly of the rest of the stream patches this sounds fine to
 push,
 
 Hm, this patch seems to be causing a regression.  If I start up a KVM guest, 
 let
 it completely boot, then run shutdown -h now inside the guest, the guest
 properly shuts down and qemu-kvm exits.  However, it is never removed from the
 list of active guests (i.e. it shows up in virsh list), and the state is 
 set
 to no state.  Reverting just this patch fixes the issue.  I'll look at it 
 some
 more to try to figure out what is happening, but we might want to revert it 
 for
 the time being (since we don't technically need it at the moment).

OK, danpb pointed out the problem.  Don't revert this patch, I'll post a follow
up to fix the problem in a couple of minutes.

-- 
Chris Lalancette

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


Re: [libvirt] [PATCH] qemu_driver.c: factor out more duplication

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 11:34:37AM +0200, Jim Meyering wrote:
 Charles Duffy wrote:
 From 3c4f6568623ed420a9e71da33b9ce74abda289a8 Mon Sep 17 00:00:00 2001
  From: Charles Duffy charles_du...@dell.com
  Date: Wed, 9 Sep 2009 15:53:25 -0500
  Subject: [PATCH] Reintroduce support for lzop compression
 
  lzop was removed due to some confusion over whether it provided functional
  advantages distinct from xz. This has been addressed in the mailing list 
  post
  archived at http://permalink.gmane.org/gmane.comp.emulators.libvirt/16487, 
  and
  support for lzop is re-added here.
 
  lzop is added to the enum after xz, leaving xz at the position lzma was
  originally in (which is appropriate, as it should handle decompression of
  lzma-format files) and giving lzop back its prior position.
 
  Documentation in qemu.conf is amended to remove references to lzma and add
  suggestions regarding the tradeoffs made by various compressors.
 
  Signed-off-by: Charles Duffy char...@dyfis.net
  ---
   libvirt.spec.in   |1 +
   src/qemu.conf |7 ---
   src/qemu_driver.c |9 ++---
   3 files changed, 11 insertions(+), 6 deletions(-)
 ...
   struct qemud_save_header {
   char magic[sizeof(QEMUD_SAVE_MAGIC)-1];
  @@ -4384,6 +4385,8 @@ static int qemudDomainRestore(virConnectPtr conn,
   intermediate_argv[0] = bzip2;
   else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
   intermediate_argv[0] = xz;
  +else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
  +intermediate_argv[0] = lzop;
   else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) {
   qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
_(Unknown compressed save format %d),
 
 Thanks for that patch.
 I'm glad I read it, since it made me realize my clean-up
 from yesterday was incomplete.  You should not have had to add
 the literal, lzop, in two places.
 
 This completes the job:
 
 From 05b3f087b7ac29cebd22dfdf099f8fb36a31c86a Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Thu, 10 Sep 2009 11:26:00 +0200
 Subject: [PATCH] qemu_driver.c: factor out more duplication
 
 * src/qemu_driver.c (qemudDomainRestore): Use the new ...TypeToString
 function here, too.
 
 (qemudSaveCompressionTypeToString): Declare.
 ---
  src/qemu_driver.c |   18 +++---
  1 files changed, 7 insertions(+), 11 deletions(-)
 
 diff --git a/src/qemu_driver.c b/src/qemu_driver.c
 index 5c2a8ec..256e8e7 100644
 --- a/src/qemu_driver.c
 +++ b/src/qemu_driver.c
 @@ -4379,21 +4379,17 @@ static int qemudDomainRestore(virConnectPtr conn,
 
  if (header.version == 2) {
  const char *intermediate_argv[3] = { NULL, -dc, NULL };
 -if (header.compressed == QEMUD_SAVE_FORMAT_GZIP)
 -intermediate_argv[0] = gzip;
 -else if (header.compressed == QEMUD_SAVE_FORMAT_BZIP2)
 -intermediate_argv[0] = bzip2;
 -else if (header.compressed == QEMUD_SAVE_FORMAT_XZ)
 -intermediate_argv[0] = xz;
 -else if (header.compressed == QEMUD_SAVE_FORMAT_LZOP)
 -intermediate_argv[0] = lzop;
 -else if (header.compressed != QEMUD_SAVE_FORMAT_RAW) {
 +const char *prog = 
 qemudSaveCompressionTypeToString(header.compressed);
 +if (prog == NULL) {
  qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
 - _(Unknown compressed save format %d),
 + _(Invalid compressed save format %d),
   header.compressed);
  goto cleanup;
  }
 -if (intermediate_argv[0] != NULL) {
 +
 +if (header.compressed != QEMUD_SAVE_FORMAT_RAW)
 +intermediate_argv[0] = prog;
 +else {
  intermediatefd = fd;
  fd = -1;
  if (virExec(conn, intermediate_argv, NULL, NULL,

  Ah, right :-) ACK !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] 2 patches: dead increment and 4 useless (always-false) disjuncts

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 10:35:07AM +0200, Daniel Veillard wrote:
 On Mon, Sep 07, 2009 at 06:33:13PM +0200, Jim Meyering wrote:
  Daniel Veillard wrote:
   On Mon, Sep 07, 2009 at 05:37:24PM +0200, Jim Meyering wrote:
  
   From 74f57af2010f9cbe2315d625c6502a0b259e6802 Mon Sep 17 00:00:00 2001
   From: Jim Meyering meyer...@redhat.com
   Date: Mon, 7 Sep 2009 10:03:22 +0200
   Subject: [PATCH 1/2] xm_internal.c: remove dead increment of data
  
   * src/xm_internal.c (xenXMDomainConfigParse): Don't increment it.
   ---
src/xm_internal.c |1 -
1 files changed, 0 insertions(+), 1 deletions(-)
  
   diff --git a/src/xm_internal.c b/src/xm_internal.c
   index f206c8c..18613d4 100644
   --- a/src/xm_internal.c
   +++ b/src/xm_internal.c
   @@ -1314,7 +1314,6 @@ xenXMDomainConfigParse(virConnectPtr conn, 
   virConfPtr conf) {
  
if (!(data = strchr(key, '=')) || (data[0] == '\0'))
break;
   -data++;
  
if (graphics-type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
if (STRPREFIX(key, vncunused=)) {
  
 trivial, ACK
  
   From d4db2dfaafbf827d1c8b8626a3dbdaa9f371e479 Mon Sep 17 00:00:00 2001
   From: Jim Meyering meyer...@redhat.com
   Date: Mon, 7 Sep 2009 10:09:20 +0200
   Subject: [PATCH 2/2] xm_internal.c: remove four useless comparisons 
   after strchr
  
   * src/xm_internal.c (xenXMDomainConfigParse): After t=strchr...
   don't test *t; it's known.  This was *not* detected by clang,
   but I spotted it since once instance was in the vicinity of the
   dead increment of data.
   ---
src/xm_internal.c |8 
1 files changed, 4 insertions(+), 4 deletions(-)
  
   diff --git a/src/xm_internal.c b/src/xm_internal.c
   index 18613d4..e7f6a55 100644
   --- a/src/xm_internal.c
   +++ b/src/xm_internal.c
   @@ -862,7 +862,7 @@ xenXMDomainConfigParse(virConnectPtr conn, 
   virConfPtr conf) {
 */
  
/* Extract the source file path*/
   -if (!(offset = strchr(head, ',')) || offset[0] == '\0')
   +if (!(offset = strchr(head, ',')))
goto skipdisk;
if ((offset - head) = (PATH_MAX-1))
goto skipdisk;
   @@ -882,7 +882,7 @@ xenXMDomainConfigParse(virConnectPtr conn, 
   virConfPtr conf) {
head = head + 6;
  
/* Extract the dest device name */
   -if (!(offset = strchr(head, ',')) || offset[0] == '\0')
   +if (!(offset = strchr(head, ',')))
goto skipdisk;
if (VIR_ALLOC_N(disk-dst, (offset - head) + 1)  0)
goto no_memory;
   @@ -1018,7 +1018,7 @@ xenXMDomainConfigParse(virConnectPtr conn, 
   virConfPtr conf) {
char *data;
char *nextkey = strchr(key, ',');
  
   -if (!(data = strchr(key, '=')) || (data[0] == '\0'))
   +if (!(data = strchr(key, '=')))
goto skipnic;
data++;
  
   @@ -1312,7 +1312,7 @@ xenXMDomainConfigParse(virConnectPtr conn, 
   virConfPtr conf) {
nextkey++;
}
  
   -if (!(data = strchr(key, '=')) || (data[0] == '\0'))
   +if (!(data = strchr(key, '=')))
break;
  
if (graphics-type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
  
 Hum, I would like to understand the intent of the person who wrote
   this first, it's like one s trying to handle a case where strchr( ,c)
   could return the pointer to the end of string if c is not found or
   something like that. Weird ...
  
  Dan?
  
  git show 1b0f541704d0172fdbc4c0e075b37dc2e196d4cc
  
  or visit this:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=1b0f541704d0172fdb
  
  e.g.,
  
+/* Extract the source */
+if (!(offset = index(head, ',')) || offset[0] == '\0')
 
   Man index is a bit confusing as it uses NULL to designate the '\0'
 character at the end of the string and the NULL pointer. Maybe this led
 to some confusion,
 
   Your patch sounds right, and Dan probably don't remember the obscure
 details of that patch 2.5 years ago :-)

With the horrible 'xm' driver my policy is always that the test cases
are correct and the driver code is broken unless proven otherwise.

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] Close logfile fd after spawning qemu

2009-09-10 Thread Ryota Ozaki
On Thu, Sep 10, 2009 at 6:35 PM, Daniel Veillardveill...@redhat.com wrote:
 On Thu, Sep 10, 2009 at 10:15:58AM +0100, Mark McLoughlin wrote:
 On Thu, 2009-09-10 at 11:04 +0200, Daniel Veillard wrote:
  On Thu, Sep 10, 2009 at 02:13:56PM +0900, Ryota Ozaki wrote:
   Hi,
  
   This patch closes logfile fd after spawing qemu in qemudStartVMDaemon.
   The fd seems to be closed in the error path, but not in the normal path.
   The fd is passed to virExecDaemonize though, but looks not being closed
   inside it. Eventually, the fd is never closed during libvirtd lifetime.
  
   Thanks,
     ozaki-r
  
   From b3d3e0f24c5df5c7677e539bbc2598f2d7fbc3b8 Mon Sep 17 00:00:00 2001
   From: Ryota Ozaki ozaki.ry...@gmail.com
   Date: Thu, 10 Sep 2009 12:53:56 +0900
   Subject: [PATCH] Close logfile fd after spawning qemu
  
   ---
    src/qemu_driver.c |    1 +
    1 files changed, 1 insertions(+), 0 deletions(-)
  
   diff --git a/src/qemu_driver.c b/src/qemu_driver.c
   index 8f16e72..f2182c4 100644
   --- a/src/qemu_driver.c
   +++ b/src/qemu_driver.c
   @@ -2187,6 +2187,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
                               VIR_EXEC_NONBLOCK | VIR_EXEC_CLEAR_CAPS,
                               qemudSecurityHook, hookData,
                               pidfile);
   +    close(logfile);
        VIR_FREE(pidfile);
  
        /* wait for qemu process to to show up */
 
    Hum, it's not quite simple.

 Indeed. I only had a quick look and wasn't sure. We at least need to set
 logfile to -1 after closing it to avoid trying to close it again further
 down.

  Okay, the fd is passed by address to virExecDaemonize, since it was
 properly initialized it should not be overwritten by __virExec, but as a
 safety I think this should be checked for -1 before close. The fd is not
 written anywhere, so we are pretty much sure it's a lost fd at this
 point and there is no way the application could use it beyond the
 function return. I'm just changing the patch slightly to

 diff --git a/src/qemu_driver.c b/src/qemu_driver.c
 index 5c2a8ec..d778a89 100644
 --- a/src/qemu_driver.c
 +++ b/src/qemu_driver.c
 @@ -2239,6 +2239,9 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         /* No need for 'goto cleanup' now since qemudShutdownVMDaemon does 
 enou
     }

 +    if (logfile != -1)
 +        close(logfile);
 +
     return ret;

  cleanup:


  i.e. check for -1 and close only at the non-cleanup return point.
 I just commited this.

I think it's ok. Thanks!
  ozaki-r


  thanks !

 Daniel

 --
 Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
 dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
 http://veillard.com/ | virtualization library  http://libvirt.org/


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


[libvirt] [PATCH] Fix regression from Avoid polling on FDs with no events

2009-09-10 Thread Chris Lalancette
After the mentioned patch was applied, I noticed that
shutting down a kvm guest from inside (i.e. poweroff) caused
the guest to shutdown, but not removed from the list of
active guests.  DanB pointed out that the problem is that
the virEventAddHandle() call in the qemu driver was asking
to watch for 0 events, not HANGUP | ERROR as it should.  Add
these events so that shutdown works again.

Signed-off-by: Chris Lalancette clala...@redhat.com
---
 src/qemu_driver.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 683fe20..996bfff 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -979,7 +979,8 @@ qemudOpenMonitorCommon(virConnectPtr conn,
 if (ret != 0)
 return ret;
 
-if ((vm-monitorWatch = virEventAddHandle(vm-monitor, 0,
+if ((vm-monitorWatch = virEventAddHandle(vm-monitor,
+  VIR_EVENT_HANDLE_HANGUP | 
VIR_EVENT_HANDLE_ERROR,
   qemudDispatchVMEvent,
   driver, NULL))  0)
 return -1;
-- 
1.6.0.6

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


Re: [libvirt] [PATCH] qemu_driver.c: factor out more duplication

2009-09-10 Thread Jim Meyering
Daniel Veillard wrote:
...
 This completes the job:

 From 05b3f087b7ac29cebd22dfdf099f8fb36a31c86a Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Thu, 10 Sep 2009 11:26:00 +0200
 Subject: [PATCH] qemu_driver.c: factor out more duplication

 * src/qemu_driver.c (qemudDomainRestore): Use the new ...TypeToString
 function here, too.
...
   Ah, right :-) ACK !

Thanks. pushed.

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


Re: [libvirt] [PATCH] Fix regression from Avoid polling on FDs with no events

2009-09-10 Thread Daniel P. Berrange
On Thu, Sep 10, 2009 at 11:50:36AM +0200, Chris Lalancette wrote:
 After the mentioned patch was applied, I noticed that
 shutting down a kvm guest from inside (i.e. poweroff) caused
 the guest to shutdown, but not removed from the list of
 active guests.  DanB pointed out that the problem is that
 the virEventAddHandle() call in the qemu driver was asking
 to watch for 0 events, not HANGUP | ERROR as it should.  Add
 these events so that shutdown works again.
 
 Signed-off-by: Chris Lalancette clala...@redhat.com
 ---
  src/qemu_driver.c |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
 
 diff --git a/src/qemu_driver.c b/src/qemu_driver.c
 index 683fe20..996bfff 100644
 --- a/src/qemu_driver.c
 +++ b/src/qemu_driver.c
 @@ -979,7 +979,8 @@ qemudOpenMonitorCommon(virConnectPtr conn,
  if (ret != 0)
  return ret;
  
 -if ((vm-monitorWatch = virEventAddHandle(vm-monitor, 0,
 +if ((vm-monitorWatch = virEventAddHandle(vm-monitor,
 +  VIR_EVENT_HANDLE_HANGUP | 
 VIR_EVENT_HANDLE_ERROR,
qemudDispatchVMEvent,
driver, NULL))  0)
  return -1;

ACK

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 regression from Avoid polling on FDs with no events

2009-09-10 Thread Chris Lalancette
Daniel P. Berrange wrote:
 On Thu, Sep 10, 2009 at 11:50:36AM +0200, Chris Lalancette wrote:
 After the mentioned patch was applied, I noticed that
 shutting down a kvm guest from inside (i.e. poweroff) caused
 the guest to shutdown, but not removed from the list of
 active guests.  DanB pointed out that the problem is that
 the virEventAddHandle() call in the qemu driver was asking
 to watch for 0 events, not HANGUP | ERROR as it should.  Add
 these events so that shutdown works again.

Thanks, pushed.

-- 
Chris Lalancette

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


Re: [libvirt] [PATCH 1/5] Add esx and tcp migration uri transports to capabilities schema

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 09:59:01AM +0100, Mark McLoughlin wrote:
 * docs/schemas/capabilities.rng: include esx and tcp uri_transport
 ---
  docs/schemas/capability.rng |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
 
 diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
 index 1e3c5f3..dbfe1c5 100644
 --- a/docs/schemas/capability.rng
 +++ b/docs/schemas/capability.rng
 @@ -79,6 +79,8 @@
 oneOrMore
   element name='uri_transport'
 choice
 + valueesx/value
 + valuetcp/value
   valuexenmigr/value
 /choice
   /element

  ACK good catch, I checked the source for potential others
  virCapabilitiesAddHostMigrateTransport() but it looks complete to me
  too now :-)

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 2/5] Update capabilities schema to allow multiple machines per domain

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 09:59:02AM +0100, Mark McLoughlin wrote:
 * docs/schemas/capabilities.rng: allow multiple machines per domain
   just like they are allowed for guests
 ---
  docs/schemas/capability.rng |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
 index dbfe1c5..a9daa40 100644
 --- a/docs/schemas/capability.rng
 +++ b/docs/schemas/capability.rng
 @@ -224,9 +224,9 @@
optional
   ref name='emulator'/
/optional
 -  optional
 +  zeroOrMore
   ref name='machine'/
 -  /optional
 +  /zeroOrMore
  /element
/define
  

  ACK, good catch too !

   thanks !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 3/5] Add arm arch to capabilities schema

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 09:59:03AM +0100, Mark McLoughlin wrote:
 * docs/schemas/capabilities.rng: add arm and sort arches
 ---
  docs/schemas/capability.rng |9 +
  1 files changed, 5 insertions(+), 4 deletions(-)
 
 diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
 index a9daa40..3e8944c 100644
 --- a/docs/schemas/capability.rng
 +++ b/docs/schemas/capability.rng
 @@ -279,15 +279,16 @@
  
define name='archnames'
  choice
 +  valuearm/value
valuei686/value
 -  valuex86_64/value
 -  valueppc/value
 -  valueppc64/value
valueia64/value
 -  values390/value
valuemips/value
valuemipsel/value
 +  valueppc64/value
 +  valueppc/value
 +  values390/value
valuesparc/value
 +  valuex86_64/value
  /choice
/define
  

  ACK too !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 4/5] Add a more featureful qemu capabilities test data

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 09:59:04AM +0100, Mark McLoughlin wrote:
 Things added include
 
   - x86_64 host
   - Migration features
   - NUMA topology
   - Security model
   - Canonical machine types
   - Domain machine types
   - An arm guest
   - More machine types for mips, mipsel, sparc and ppc
   - An x86_64 xenner guest
 
 This file was generated on a Fedora 12 machine using latest libvirt
 and qemu-kvm-0.11.0-rc2
 
 * tests/capabilityschemadata/caps-qemu-kvm.xml: add more features
   to test

  ACK !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 5/5] Add qemu -help test data for qemu-kvm-0.11.0-rc2

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 09:59:05AM +0100, Mark McLoughlin wrote:
 * tests/qemuhelpdata/qemu-kvm-0.11.0-rc2: add data
 
 * tests/qemuhelptest.c: add expected output
 ---
  .gnulib|2 +-
  tests/qemuhelpdata/qemu-kvm-0.11.0-rc2 |  177 
 
  tests/qemuhelptest.c   |   19 
  3 files changed, 197 insertions(+), 1 deletions(-)
  create mode 100644 tests/qemuhelpdata/qemu-kvm-0.11.0-rc2
 
 diff --git a/.gnulib b/.gnulib
 index 28db629..b653eda 16
 --- a/.gnulib
 +++ b/.gnulib
 @@ -1 +1 @@
 -Subproject commit 28db629d4f20b514087389b0339b5ba8c83a707b
 +Subproject commit b653eda3ac4864de205419d9f41eec267cb89eeb

  Not that part please !

 But the new test is a good idea, ACK

  thanks !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCH 04/10] Re-factor qemu test machine allocation code

2009-09-10 Thread Mark McLoughlin
* test/testutilsqemu.c: split out code to testQemuAllocMachines()
  and make use of the ARRAY_CARDINALITY macro
---
 tests/testutilsqemu.c |   30 +-
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index d8854be..d85e4c7 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -7,15 +7,29 @@
 #include testutils.h
 #include memory.h
 
+static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
+{
+virCapsGuestMachinePtr *machines;
+static const char *const x86_machines[] = {
+pc, isapc
+};
+
+machines = virCapabilitiesAllocMachines(x86_machines,
+ARRAY_CARDINALITY(x86_machines));
+if (machines == NULL)
+return NULL;
+
+*nmachines = ARRAY_CARDINALITY(x86_machines);
+
+return machines;
+}
+
 virCapsPtr testQemuCapsInit(void) {
 struct utsname utsname;
 virCapsPtr caps;
 virCapsGuestPtr guest;
 virCapsGuestMachinePtr *machines;
 int nmachines;
-static const char *const x86_machines[] = {
-pc, isapc
-};
 static const char *const xen_machines[] = {
 xenner
 };
@@ -25,8 +39,7 @@ virCapsPtr testQemuCapsInit(void) {
0, 0)) == NULL)
 return NULL;
 
-nmachines = 2;
-if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == 
NULL)
+if ((machines = testQemuAllocMachines(nmachines)) == NULL)
 goto cleanup;
 
 if ((guest = virCapabilitiesAddGuest(caps, hvm, i686, 32,
@@ -43,8 +56,7 @@ virCapsPtr testQemuCapsInit(void) {
   NULL) == NULL)
 goto cleanup;
 
-nmachines = 2;
-if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == 
NULL)
+if ((machines = testQemuAllocMachines(nmachines)) == NULL)
 goto cleanup;
 
 if ((guest = virCapabilitiesAddGuest(caps, hvm, x86_64, 64,
@@ -68,13 +80,13 @@ virCapsPtr testQemuCapsInit(void) {
   NULL) == NULL)
 goto cleanup;
 
-nmachines = 1;
+nmachines = ARRAY_CARDINALITY(xen_machines);
 if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == 
NULL)
 goto cleanup;
 
 if ((guest = virCapabilitiesAddGuest(caps, xen, x86_64, 64,
  /usr/bin/xenner, NULL,
- 1, machines)) == NULL)
+ nmachines, machines)) == NULL)
 goto cleanup;
 machines = NULL;
 
-- 
1.6.2.5

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


[libvirt] [PATCH 01/10] Fix formatting of machine types in capabilities XML

2009-09-10 Thread Mark McLoughlin
* src/capabilities.c: fix machine type formatting in
  virCapabilitiesFormatXML()
---
 src/capabilities.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/capabilities.c b/src/capabilities.c
index 289180d..38fe7fc 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -713,7 +713,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 
 for (k = 0 ; k  caps-guests[i]-arch.domains[j]-info.nmachines 
; k++) {
 virCapsGuestMachinePtr machine = 
caps-guests[i]-arch.domains[j]-info.machines[k];
-virBufferAddLit(xml,   machine);
+virBufferAddLit(xml, machine);
 if (machine-canonical)
 virBufferVSprintf(xml,  canonical='%s', 
machine-canonical);
 virBufferVSprintf(xml, %s/machine\n, machine-name);
-- 
1.6.2.5

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


[libvirt] [PATCH 02/10] Dump qemu driver capabilities if test debugging enabled

2009-09-10 Thread Mark McLoughlin
* src/testutils.[ch]: make testDebug externally available

* src/testutilsqemu.c: if VIR_TEST_DEBUG is set, dump the qemu
  driver capabilities to stderr
---
 tests/testutils.c |3 ++-
 tests/testutils.h |2 ++
 tests/testutilsqemu.c |   14 ++
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index 5072fec..536441a 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -45,8 +45,9 @@
 int) ((T)-tv_sec - (U)-tv_sec)) * 100.0 +\
   ((int) ((T)-tv_usec - (U)-tv_usec))) / 1000.0)
 
+unsigned int testDebug = 0;
+
 static unsigned int testOOM = 0;
-static unsigned int testDebug = 0;
 static unsigned int testCounter = 0;
 
 double
diff --git a/tests/testutils.h b/tests/testutils.h
index 96b246f..f036e0f 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -43,4 +43,6 @@ int virtTestMain(int argc,
 return virtTestMain(argc,argv, func);   \
 }
 
+extern unsigned int testDebug;
+
 #endif /* __VIT_TEST_UTILS_H__ */
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 58707e1..d8854be 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -4,6 +4,8 @@
 #include stdlib.h
 
 #include testutilsqemu.h
+#include testutils.h
+#include memory.h
 
 virCapsPtr testQemuCapsInit(void) {
 struct utsname utsname;
@@ -84,6 +86,18 @@ virCapsPtr testQemuCapsInit(void) {
   NULL) == NULL)
 goto cleanup;
 
+if (testDebug) {
+char *caps_str;
+
+caps_str = virCapabilitiesFormatXML(caps);
+if (!caps_str)
+goto cleanup;
+
+fprintf(stderr, QEMU driver capabilities:\n%s, caps_str);
+
+VIR_FREE(caps_str);
+}
+
 return caps;
 
 cleanup:
-- 
1.6.2.5

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


[libvirt] [PATCH 05/10] Test qemu machine aliases

2009-09-10 Thread Mark McLoughlin
* tests/testutilsqemu.c: make 'pc' an alias for qemu-system-x86_64

* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.*,
  tests/qemuxml2argvtest.c: add a test which uses qemu-system-x86_64
  and make sure the machine type is canonicalized.
---
 .../qemuxml2argv-machine-aliases1.args |1 +
 .../qemuxml2argv-machine-aliases1.xml  |   22 ++
 tests/qemuxml2argvtest.c   |1 +
 tests/testutilsqemu.c  |   31 +++-
 4 files changed, 54 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args 
b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
new file mode 100644
index 000..4f62cb1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
/usr/bin/qemu-system-x86_64 -S -M pc-0.11 -m 214 -smp 1 -nographic -monitor 
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda 
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
new file mode 100644
index 000..039abfd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
@@ -0,0 +1,22 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu1/vcpu
+  os
+type arch='x86_64' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu-system-x86_64/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+/disk
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index edd3744..afaf392 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -190,6 +190,7 @@ mymain(int argc, char **argv)
 unsetenv(LD_LIBRARY_PATH);
 
 DO_TEST(minimal, QEMUD_CMD_FLAG_NAME);
+DO_TEST(machine-aliases1, 0);
 DO_TEST(boot-cdrom, 0);
 DO_TEST(boot-network, 0);
 DO_TEST(boot-floppy, 0);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index d85e4c7..ad58010 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -24,6 +24,35 @@ static virCapsGuestMachinePtr *testQemuAllocMachines(int 
*nmachines)
 return machines;
 }
 
+/* Newer versions of qemu have versioned machine types to allow
+ * compatibility with older releases.
+ * The 'pc' machine type is an alias of the newest machine type.
+ */
+static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
+{
+virCapsGuestMachinePtr *machines;
+char *canonical;
+static const char *const x86_machines[] = {
+pc-0.11, pc, pc-0.10, isapc
+};
+
+if ((canonical = strdup(x86_machines[0])) == NULL)
+return NULL;
+
+machines = virCapabilitiesAllocMachines(x86_machines,
+ARRAY_CARDINALITY(x86_machines));
+if (machines == NULL) {
+VIR_FREE(canonical);
+return NULL;
+}
+
+machines[1]-canonical = canonical;
+
+*nmachines = ARRAY_CARDINALITY(x86_machines);
+
+return machines;
+}
+
 virCapsPtr testQemuCapsInit(void) {
 struct utsname utsname;
 virCapsPtr caps;
@@ -56,7 +85,7 @@ virCapsPtr testQemuCapsInit(void) {
   NULL) == NULL)
 goto cleanup;
 
-if ((machines = testQemuAllocMachines(nmachines)) == NULL)
+if ((machines = testQemuAllocNewerMachines(nmachines)) == NULL)
 goto cleanup;
 
 if ((guest = virCapabilitiesAddGuest(caps, hvm, x86_64, 64,
-- 
1.6.2.5

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


[libvirt] [PATCH 09/10] Simplify and fix qemudCanonicalizeMachine()

2009-09-10 Thread Mark McLoughlin
The algorithm is quite simple:

  If the emulator matches a guest's domain:
if domain has machine type info:
  check the domain's machine type info
else
  check the guest's default machine type info
  else if the emulator matches the guest's default emulator:
 check the guest's default machine type info

The previous implementation was incorrectly falling back to the default
machine type info if the domain's machine type info didn't have an
alias.

* src/qemu_driver.c: simplify and fix qemudCanonicalizeMachine()
---
 src/qemu_driver.c |   33 +++--
 1 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index f2b0bec..fad3939 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -4789,30 +4789,27 @@ qemudCanonicalizeMachine(struct qemud_driver *driver, 
virDomainDefPtr def)
 
 for (i = 0; i  driver-caps-nguests; i++) {
 virCapsGuestPtr guest = driver-caps-guests[i];
+virCapsGuestDomainInfoPtr info;
 int j;
 
 for (j = 0; j  guest-arch.ndomains; j++) {
-virCapsGuestDomainPtr dom = guest-arch.domains[j];
+info = guest-arch.domains[j]-info;
 
-if (dom-info.emulator 
-STREQ(dom-info.emulator, def-emulator)) {
-if (qemudCanonicalizeMachineFromInfo(def, dom-info,
- canonical)  0)
-return -1;
-if (canonical)
-goto out;
-break;
-}
+if (!info-emulator || !STREQ(info-emulator, def-emulator))
+continue;
+
+if (!info-nmachines)
+info = guest-arch.defaultInfo;
+
+if (qemudCanonicalizeMachineFromInfo(def, info, canonical)  0)
+return -1;
+goto out;
 }
 
-/* if we matched one of the domain's emulators, or if
- * we match the default emulator
- */
-if (j  guest-arch.ndomains ||
-(guest-arch.defaultInfo.emulator 
- STREQ(guest-arch.defaultInfo.emulator, def-emulator))) {
-if (qemudCanonicalizeMachineFromInfo(def, guest-arch.defaultInfo,
- canonical)  0)
+info = guest-arch.defaultInfo;
+
+if (info-emulator  STREQ(info-emulator, def-emulator)) {
+if (qemudCanonicalizeMachineFromInfo(def, info, canonical)  0)
 return -1;
 goto out;
 }
-- 
1.6.2.5

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


[libvirt] [PATCH 10/10] Test that domain-specific qemu machine types are used correctly

2009-09-10 Thread Mark McLoughlin
* tests/testutilsqemu.c: add a machine types list for /usr/bin/kvm
  which doesn't have any aliases, while the guest has aliases

* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.*,
  tests/qemuxml2argvtest.c: add a test using /usr/bin/kvm and make
  sure that 'pc' machine type doesn't get canonicalized using the
  aliases in the guest machine type list
---
 .../qemuxml2argv-machine-aliases2.args |1 +
 .../qemuxml2argv-machine-aliases2.xml  |   22 
 tests/qemuxml2argvtest.c   |1 +
 tests/testutilsqemu.c  |9 ++-
 4 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.args 
b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.args
new file mode 100644
index 000..1a7650d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/kvm -S -M 
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait 
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel 
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml
new file mode 100644
index 000..6f62243
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml
@@ -0,0 +1,22 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu1/vcpu
+  os
+type arch='x86_64' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/kvm/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+/disk
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index afaf392..d0cf712 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -191,6 +191,7 @@ mymain(int argc, char **argv)
 
 DO_TEST(minimal, QEMUD_CMD_FLAG_NAME);
 DO_TEST(machine-aliases1, 0);
+DO_TEST(machine-aliases2, 0);
 DO_TEST(boot-cdrom, 0);
 DO_TEST(boot-network, 0);
 DO_TEST(boot-floppy, 0);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index ad58010..9269f5c 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -101,13 +101,18 @@ virCapsPtr testQemuCapsInit(void) {
   0,
   NULL) == NULL)
 goto cleanup;
+
+if ((machines = testQemuAllocMachines(nmachines)) == NULL)
+goto cleanup;
+
 if (virCapabilitiesAddGuestDomain(guest,
   kvm,
   /usr/bin/kvm,
   NULL,
-  0,
-  NULL) == NULL)
+  nmachines,
+  machines) == NULL)
 goto cleanup;
+machines = NULL;
 
 nmachines = ARRAY_CARDINALITY(xen_machines);
 if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == 
NULL)
-- 
1.6.2.5

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


[libvirt] [PATCH 08/10] Probe machine types from kvm binary too

2009-09-10 Thread Mark McLoughlin
Currently we only probe the main qemu binary for machine types, but we
should also probe the kvm binary.

* src/qemu_conf.c: probe kvm binary machines in qemudCapsInitGuest()
---
 src/qemu_conf.c |   50 ++
 1 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 0d498c2..ddf7348 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -710,14 +710,48 @@ qemudCapsInitGuest(virCapsPtr caps,
   NULL) == NULL)
 return -1;
 
-if (haskvm 
-virCapabilitiesAddGuestDomain(guest,
-  kvm,
-  kvmbin,
-  NULL,
-  0,
-  NULL) == NULL)
-return -1;
+if (haskvm) {
+virCapsGuestDomainPtr dom;
+
+if (stat(kvmbin, st) == 0) {
+binary_mtime = st.st_mtime;
+} else {
+char ebuf[1024];
+VIR_WARN(_(Failed to stat %s, most peculiar : %s),
+ binary, virStrerror(errno, ebuf, sizeof(ebuf)));
+binary_mtime = 0;
+}
+
+machines = NULL;
+nmachines = 0;
+
+if (!STREQ(binary, kvmbin)) {
+int probe = 1;
+if (old_caps  binary_mtime)
+probe = !qemudGetOldMachines(hvm, info-arch, 
info-wordsize,
+ kvmbin, binary_mtime,
+ old_caps, machines, 
nmachines);
+if (probe 
+qemudProbeMachineTypes(kvmbin, machines, nmachines)  0)
+return -1;
+}
+
+if ((dom = virCapabilitiesAddGuestDomain(guest,
+ kvm,
+ kvmbin,
+ NULL,
+ nmachines,
+ machines)) == NULL) {
+for (i = 0; i  nmachines; i++) {
+VIR_FREE(machines[i]-name);
+VIR_FREE(machines[i]);
+}
+VIR_FREE(machines);
+return -1;
+}
+
+dom-info.emulator_mtime = binary_mtime;
+}
 } else {
 if (virCapabilitiesAddGuestDomain(guest,
   kvm,
-- 
1.6.2.5

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


[libvirt] [PATCH 07/10] Look up machine types from all domains in qemudGetOldMachines()

2009-09-10 Thread Mark McLoughlin
Rather than just looking at the default domain info, look at all
domains

* src/qemu_conf.c: look at all domains in qemudGetOldMachines()
---
 src/qemu_conf.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 882f9f9..0d498c2 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -554,12 +554,22 @@ qemudGetOldMachines(const char *ostype,
 
 for (i = 0; i  old_caps-nguests; i++) {
 virCapsGuestPtr guest = old_caps-guests[i];
+int j;
 
 if (!STREQ(ostype, guest-ostype) ||
 !STREQ(arch, guest-arch.name) ||
 wordsize != guest-arch.wordsize)
 continue;
 
+for (j = 0; j  guest-arch.ndomains; j++) {
+virCapsGuestDomainPtr dom = guest-arch.domains[j];
+
+if (qemudGetOldMachinesFromInfo(dom-info,
+emulator, emulator_mtime,
+machines, nmachines))
+return 1;
+}
+
 if (qemudGetOldMachinesFromInfo(guest-arch.defaultInfo,
 emulator, emulator_mtime,
 machines, nmachines))
-- 
1.6.2.5

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


[libvirt] [PATCH 06/10] Split up qemudGetOldMachines()

2009-09-10 Thread Mark McLoughlin
We need to look at all the domain infos in guest capabilities, not
just the defaults.

In order to allow that, split out a qemudGetOldMachinesFromInfo()
from qemudGetOldMachines(). We'll make more use of it in the next
patch.

* src/qemu_conf.c: split out qemudGetOldMachinesFromInfo() from
  qemudGetOldMachines()
---
 src/qemu_conf.c |   90 ++
 1 files changed, 50 insertions(+), 40 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index caf518c..882f9f9 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -496,6 +496,51 @@ rewait:
 }
 
 static int
+qemudGetOldMachinesFromInfo(virCapsGuestDomainInfoPtr info,
+const char *emulator,
+time_t emulator_mtime,
+virCapsGuestMachinePtr **machines,
+int *nmachines)
+{
+virCapsGuestMachinePtr *list;
+int i;
+
+if (!info-emulator || !STREQ(emulator, info-emulator))
+return 0;
+
+if (emulator_mtime != info-emulator_mtime) {
+VIR_DEBUG(mtime on %s has changed, refreshing machine types,
+  info-emulator);
+return 0;
+}
+
+if (VIR_ALLOC_N(list, info-nmachines)  0)
+return 0;
+
+for (i = 0; i  info-nmachines; i++) {
+if (VIR_ALLOC(list[i])  0) {
+virCapabilitiesFreeMachines(list, info-nmachines);
+return 0;
+}
+if (info-machines[i]-name 
+!(list[i]-name = strdup(info-machines[i]-name))) {
+virCapabilitiesFreeMachines(list, info-nmachines);
+return 0;
+}
+if (info-machines[i]-canonical 
+!(list[i]-canonical = strdup(info-machines[i]-canonical))) {
+virCapabilitiesFreeMachines(list, info-nmachines);
+return 0;
+}
+}
+
+*machines = list;
+*nmachines = info-nmachines;
+
+return 1;
+}
+
+static int
 qemudGetOldMachines(const char *ostype,
 const char *arch,
 int wordsize,
@@ -509,51 +554,16 @@ qemudGetOldMachines(const char *ostype,
 
 for (i = 0; i  old_caps-nguests; i++) {
 virCapsGuestPtr guest = old_caps-guests[i];
-virCapsGuestDomainInfoPtr info = guest-arch.defaultInfo;
-virCapsGuestMachinePtr *list;
 
 if (!STREQ(ostype, guest-ostype) ||
 !STREQ(arch, guest-arch.name) ||
-wordsize != guest-arch.wordsize ||
-!STREQ(emulator, info-emulator))
+wordsize != guest-arch.wordsize)
 continue;
 
-if (emulator_mtime != info-emulator_mtime) {
-VIR_DEBUG(mtime on %s has changed, refreshing machine types,
-  info-emulator);
-return 0;
-}
-
-/* It sucks to have to dup these, when we're most likely going
- * to free the old caps anyway - except if an error occurs, we'll
- * stick with the old caps.
- * Also, if we get OOM here, just let the caller try and probe
- * the binary directly, which will probably fail too.
- */
-if (VIR_ALLOC_N(list, info-nmachines)  0)
-return 0;
-
-for (i = 0; i  info-nmachines; i++) {
-if (VIR_ALLOC(list[i])  0) {
-virCapabilitiesFreeMachines(list, info-nmachines);
-return 0;
-}
-if (info-machines[i]-name 
-!(list[i]-name = strdup(info-machines[i]-name))) {
-virCapabilitiesFreeMachines(list, info-nmachines);
-return 0;
-}
-if (info-machines[i]-canonical 
-!(list[i]-canonical = strdup(info-machines[i]-canonical))) {
-virCapabilitiesFreeMachines(list, info-nmachines);
-return 0;
-}
-}
-
-*machines = list;
-*nmachines = info-nmachines;
-
-return 1;
+if (qemudGetOldMachinesFromInfo(guest-arch.defaultInfo,
+emulator, emulator_mtime,
+machines, nmachines))
+return 1;
 }
 
 return 0;
-- 
1.6.2.5

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


Re: [libvirt][qemu] unable to start guest under kvm

2009-09-10 Thread Mark McLoughlin

Hi,
Okay, I've got this fixed for certain now. Definitely. I think.

The problem turned out to be that qemudCanonicalizeMachine()
was using the alias in the default machine types if the domain's machine
types didn't have an alias that matched.

We even have a test for this now, so hopefully it'll stay fixed
too :-)

If you want to test this, try the machine-types-fixes branch on:

  git://gitorious.org/~markmc/libvirt/markmc-staging.git

Thanks,
Mark.

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


Re: [libvirt] [PATCH 5/5] Add qemu -help test data for qemu-kvm-0.11.0-rc2

2009-09-10 Thread Mark McLoughlin
On Thu, 2009-09-10 at 13:32 +0200, Daniel Veillard wrote:
 On Thu, Sep 10, 2009 at 09:59:05AM +0100, Mark McLoughlin wrote:
  * tests/qemuhelpdata/qemu-kvm-0.11.0-rc2: add data
  
  * tests/qemuhelptest.c: add expected output
  ---
   .gnulib|2 +-
   tests/qemuhelpdata/qemu-kvm-0.11.0-rc2 |  177 
  
   tests/qemuhelptest.c   |   19 
   3 files changed, 197 insertions(+), 1 deletions(-)
   create mode 100644 tests/qemuhelpdata/qemu-kvm-0.11.0-rc2
  
  diff --git a/.gnulib b/.gnulib
  index 28db629..b653eda 16
  --- a/.gnulib
  +++ b/.gnulib
  @@ -1 +1 @@
  -Subproject commit 28db629d4f20b514087389b0339b5ba8c83a707b
  +Subproject commit b653eda3ac4864de205419d9f41eec267cb89eeb
 
   Not that part please !

Well spotted. Not sure how that happened. I've removed it from the
patches in my staging tree now.

Cheers,
Mark.

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


Re: [libvirt] Resubmission: [PATCH 1/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:19:59PM -0500, Jamie Strandboge wrote:
 On Tue, 08 Sep 2009, Jamie Strandboge wrote:
 
   [PATCH 1*]
   patch_1a_reenable-nonfile-labels.patch:
   When James Morris originally submitted his sVirt patches (as seen in
   libvirt 0.6.1), he did not require on disk labelling for
   virSecurityDomainRestoreImageLabel. A later commit[2] changed this
   behavior to assume on disk labelling, which halts implementations for
   path-based MAC systems such as AppArmor and TOMOYO where
   vm-def-seclabel is required to obtain the label. This patch simply
   adds the 'virDomainObjPtr vm' argument back to *RestoreImageLabel.
   
   patch_1b_optional.patch:
   Due to the above change, 'make syntax-check' fails because
   SELinuxRestoreSecurityImageLabel() does not use the 'virDomainObjPtr
   vm'. patch_1b_optional.patch is a simple patch to fix this by checking
   if vm-def-seclabel == NULL and returns with error if it does. I
   realize this may not be desired in the long term, but it should be
   harmless enough to include.

The 'ATTRIBUTE_UNUSED' anotation takes care of this much better.


 diff -Nurp ./libvirt.orig/src/qemu_driver.c ./libvirt/src/qemu_driver.c
 --- ./libvirt.orig/src/qemu_driver.c  2009-09-08 13:00:00.0 -0500
 +++ ./libvirt/src/qemu_driver.c   2009-09-08 15:32:22.0 -0500
 @@ -6144,7 +6144,7 @@ static int qemudDomainDetachDevice(virDo
   dev-data.disk-bus == VIR_DOMAIN_DISK_BUS_VIRTIO)) {
  ret = qemudDomainDetachPciDiskDevice(dom-conn, vm, dev);
  if (driver-securityDriver)
 -
 driver-securityDriver-domainRestoreSecurityImageLabel(dom-conn, 
 dev-data.disk);
 +
 driver-securityDriver-domainRestoreSecurityImageLabel(dom-conn, vm, 
 dev-data.disk);
  if (qemuDomainSetDeviceOwnership(dom-conn, driver, dev, 1)  0)
  VIR_WARN0(Fail to restore disk device ownership);
  } else if (dev-type == VIR_DOMAIN_DEVICE_NET) {
 diff -Nurp ./libvirt.orig/src/security.h ./libvirt/src/security.h
 --- ./libvirt.orig/src/security.h 2009-08-17 11:00:40.0 -0500
 +++ ./libvirt/src/security.h  2009-09-08 15:32:22.0 -0500
 @@ -32,6 +32,7 @@ typedef virSecurityDriverStatus (*virSec
  typedef int (*virSecurityDriverOpen) (virConnectPtr conn,
virSecurityDriverPtr drv);
  typedef int (*virSecurityDomainRestoreImageLabel) (virConnectPtr conn,
 +   virDomainObjPtr vm,
 virDomainDiskDefPtr disk);
  typedef int (*virSecurityDomainSetImageLabel) (virConnectPtr conn,
 virDomainObjPtr vm,
 diff -Nurp ./libvirt.orig/src/security_selinux.c 
 ./libvirt/src/security_selinux.c
 --- ./libvirt.orig/src/security_selinux.c 2009-09-02 14:34:08.0 
 -0500
 +++ ./libvirt/src/security_selinux.c  2009-09-08 15:32:22.0 -0500
 @@ -354,6 +354,7 @@ SELinuxSetFilecon(virConnectPtr conn, co
  
  static int
  SELinuxRestoreSecurityImageLabel(virConnectPtr conn,
 + virDomainObjPtr vm,
   virDomainDiskDefPtr disk)
  {
  struct stat buf;
 @@ -423,7 +429,8 @@ SELinuxRestoreSecurityLabel(virConnectPt
  int rc = 0;
  if (secdef-imagelabel) {
  for (i = 0 ; i  vm-def-ndisks ; i++) {
 -if (SELinuxRestoreSecurityImageLabel(conn, vm-def-disks[i])  
 0)
 +if (SELinuxRestoreSecurityImageLabel(conn, vm,
 + vm-def-disks[i])  0)
  rc = -1;
  }
  VIR_FREE(secdef-model);


ACK to this part


 diff -Nurp ./libvirt.orig/src/security_selinux.c 
 ./libvirt/src/security_selinux.c
 --- ./libvirt.orig/src/security_selinux.c 2009-09-02 14:34:08.0 
 -0500
 +++ ./libvirt/src/security_selinux.c  2009-09-08 15:32:22.0 -0500
 @@ -364,6 +365,11 @@ SELinuxRestoreSecurityImageLabel(virConn
  char *newpath = NULL;
  const char *path = disk-src;
  
 +if (vm-def-seclabel == NULL)  {
 +virSecurityReportError(conn, VIR_ERR_ERROR, _(seclabel is NULL));
 +return rc;
 +}
 +
  /* Don't restore labels on readoly/shared disks, because
   * other VMs may still be accessing these
   * Alternatively we could iterate over all running

This should have ATTRIBUTE_USED instead


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] Resubmission: [PATCH 2/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:20:43PM -0500, Jamie Strandboge wrote:
 On Tue, 08 Sep 2009, Jamie Strandboge wrote:
 
   [PATCH 2]
   patch_2_security_c.patch:
   Updates src/security.c for AppArmor
   
 
 -- 
 Jamie Strandboge | http://www.canonical.com

 diff -Nurp ./libvirt.orig/src/security.c ./libvirt/src/security.c
 --- ./libvirt.orig/src/security.c 2009-08-17 11:00:40.0 -0500
 +++ ./libvirt/src/security.c  2009-09-08 15:32:22.0 -0500
 @@ -20,10 +20,17 @@
  #include security_selinux.h
  #endif
  
 +#ifdef WITH_SECDRIVER_APPARMOR
 +#include security_apparmor.h
 +#endif
 +
  static virSecurityDriverPtr security_drivers[] = {
  #ifdef WITH_SECDRIVER_SELINUX
  virSELinuxSecurityDriver,
  #endif
 +#ifdef WITH_SECDRIVER_APPARMOR
 +virAppArmorSecurityDriver,
 +#endif
  NULL
  };
  

ACK, but this part should really be part of the next patch, since you
can't apply this  still compile without also applying the next patch

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


[libvirt] [PATCH 03/10] Canonicalize the qemu machine type in qemuxml2argvtest

2009-09-10 Thread Mark McLoughlin
This doesn't have any affect on the current tests because we don't have
any machine aliases in the current test data.

* src/qemu_conf.h, src/qemu_driver.c: expose qemudCanonicalizeMachine()
  for the tests

* tests/qemuxml2argvtest.c: canonicalize the machine type
---
 src/qemu_conf.h  |3 +++
 src/qemu_driver.c|7 +++
 tests/qemuxml2argvtest.c |3 +++
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index 9fa4559..ed91d2c 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -194,6 +194,9 @@ int qemudProbeMachineTypes  (const char *binary,
  virCapsGuestMachinePtr **machines,
  int *nmachines);
 
+int qemudCanonicalizeMachine(struct qemud_driver *driver,
+ virDomainDefPtr def);
+
 virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
  virCapsPtr caps,
  const char **progenv,
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index ae112d8..f2b0bec 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -4781,10 +4781,9 @@ qemudCanonicalizeMachineDirect(virDomainDefPtr def, char 
**canonical)
 return 0;
 }
 
-static int
-qemudCanonicalizeMachine(virConnectPtr conn, virDomainDefPtr def)
+int
+qemudCanonicalizeMachine(struct qemud_driver *driver, virDomainDefPtr def)
 {
-struct qemud_driver *driver = conn-privateData;
 char *canonical = NULL;
 int i;
 
@@ -4875,7 +4874,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, 
const char *xml) {
 }
 }
 
-if (qemudCanonicalizeMachine(conn, def)  0)
+if (qemudCanonicalizeMachine(driver, def)  0)
 goto cleanup;
 
 if (!(vm = virDomainAssignDef(conn,
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d1cef0e..edd3744 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -56,6 +56,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
 QEMUD_CMD_FLAG_NO_REBOOT |
 extraFlags;
 
+if (qemudCanonicalizeMachine(driver, vmdef)  0)
+goto fail;
+
 if (qemudBuildCommandLine(NULL, driver,
   vmdef, monitor_chr, flags,
   argv, qenv,
-- 
1.6.2.5

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


Re: [libvirt] Resubmission: [PATCH 5/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:22:56PM -0500, Jamie Strandboge wrote:
 diff -Nurp ./libvirt.orig/examples/apparmor/usr.sbin.libvirtd 
 ./libvirt/examples/apparmor/usr.sbin.libvirtd
 --- ./libvirt.orig/examples/apparmor/usr.sbin.libvirtd1969-12-31 
 18:00:00.0 -0600
 +++ ./libvirt/examples/apparmor/usr.sbin.libvirtd 2009-09-08 
 15:32:22.0 -0500
 @@ -0,0 +1,39 @@
 +# Last Modified: Mon Jul  6 17:23:58 2009
 +#include tunables/global
 +...@{libvirt}=libvirt
 +
 +/usr/sbin/libvirtd {
 +  #include abstractions/base
 +
 +  capability kill,
 +  capability net_admin,
 +  capability net_raw,
 +  capability setgid,
 +  capability sys_admin,
 +  capability sys_module,
 +  capability sys_ptrace,

I'm fairly sure libvirtd will need more  than this set of capabilities.
We tried to limit this in the C code a few months back, but gave up
because we ended up requiring about 2/3s of all capabilities and once
you allow net_admin  sys_admin its game over for security benefits.
You'll certainly have broken functionality without sys_nice, sys_chroot,
setuid, setpcap, mknod, dac_override, dac_read_search, fowner, chown

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] Resubmission: [PATCH 6/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:23:34PM -0500, Jamie Strandboge wrote:
 On Tue, 08 Sep 2009, Jamie Strandboge wrote:
 
   [PATCH 6]
   patch_6_autoconf.patch:
   Updates Makefile.am and configure.in for AppArmor. It is based on and
   should operate the same as the SELinux configuration.
   
 
 -- 
 Jamie Strandboge | http://www.canonical.com

 diff -Nurp ./libvirt.orig/configure.in ./libvirt/configure.in
 --- ./libvirt.orig/configure.in   2009-09-08 12:59:59.0 -0500
 +++ ./libvirt/configure.in2009-09-08 15:32:22.0 -0500
 @@ -799,6 +799,84 @@ fi
  AM_CONDITIONAL([WITH_SECDRIVER_SELINUX], [test $with_secdriver_selinux != 
 no])
  
  
 +dnl AppArmor
 +AC_ARG_WITH([apparmor],
 +  [  --with-apparmoruse AppArmor to manage security],
 +  [],
 +  [with_apparmor=check])
 +
 +APPARMOR_CFLAGS=
 +APPARMOR_LIBS=
 +if test $with_apparmor != no; then
 +  old_cflags=$CFLAGS
 +  old_libs=$LIBS
 +  if test $with_apparmor = check; then
 +AC_CHECK_HEADER([sys/apparmor.h],[],[with_apparmor=no])
 +AC_CHECK_LIB([apparmor], [aa_change_profile],[],[with_apparmor=no])
 +AC_CHECK_LIB([apparmor], [aa_change_hat],[],[with_apparmor=no])
 +if test $with_apparmor != no; then
 +  with_apparmor=yes
 +fi
 +  else
 +fail=0
 +AC_CHECK_HEADER([sys/apparmor.h],[],[fail=1])
 +AC_CHECK_LIB([apparmor], [aa_change_profile],[],[fail=1])
 +AC_CHECK_LIB([apparmor], [aa_change_hat],[],[fail=1])
 +test $fail = 1 
 +  AC_MSG_ERROR([You must install the AppArmor development package in 
 order to compile libvirt])
 +  fi
 +  CFLAGS=$old_cflags
 +  LIBS=$old_libs
 +fi
 +if test $with_apparmor = yes; then
 +  APPARMOR_LIBS=-lapparmor
 +  AC_DEFINE_UNQUOTED([HAVE_APPARMOR], 1, [whether AppArmor is available for 
 security])
 +  AC_DEFINE_UNQUOTED([APPARMOR_DIR], /etc/apparmor.d, [path to apparmor 
 directory])
 +  AC_DEFINE_UNQUOTED([APPARMOR_PROFILES_PATH], 
 /sys/kernel/security/apparmor/profiles, [path to kernel profiles])
 +  AC_DEFINE_UNQUOTED([VIRT_AA_HELPER_PATH], $prefix/bin/virt-aa-helper, 
 [path to virt-aa-helper])
 +fi
 +AM_CONDITIONAL([HAVE_APPARMOR], [test $with_apparmor != no])
 +AC_SUBST([APPARMOR_CFLAGS])
 +AC_SUBST([APPARMOR_LIBS])
 +
 +
 +AC_ARG_WITH([secdriver-apparmor],
 +  [  --with-secdriver-apparmor use AppArmor security driver],
 +  [],
 +  [with_secdriver_apparmor=check])
 +
 +if test $with_apparmor != yes ; then
 +  if test $with_secdriver_apparmor = check ; then
 +with_secdriver_apparmor=no
 +  else
 +AC_MSG_ERROR([You must install the AppArmor development package in order 
 to compile libvirt])
 +  fi
 +else
 +  old_cflags=$CFLAGS
 +  old_libs=$LIBS
 +  CFLAGS=$CFLAGS $APPARMOR_CFLAGS
 +  LIBS=$CFLAGS $APPARMOR_LIBS
 +
 +  fail=0
 +  AC_CHECK_FUNC([change_hat], [], [fail=1])
 +  AC_CHECK_FUNC([aa_change_profile], [], [fail=1])
 +  CFLAGS=$old_cflags
 +  LIBS=$old_libs
 +
 +  if test $fail = 1 ; then
 +if test $with_secdriver_apparmor = check ; then
 +  with_secdriver_apparmor=no
 +else
 +  AC_MSG_ERROR([You must install the AppArmor development package in 
 order to compile libvirt])
 +fi
 +  else
 +with_secdriver_apparmor=yes
 +AC_DEFINE_UNQUOTED([WITH_SECDRIVER_APPARMOR], 1, [whether AppArmor 
 security driver is available])
 +  fi
 +fi
 +AM_CONDITIONAL([WITH_SECDRIVER_APPARMOR], [test $with_secdriver_apparmor 
 != no])
 +
 +
  
  dnl NUMA lib
  AC_ARG_WITH([numactl],
 @@ -1706,6 +1784,7 @@ AC_MSG_NOTICE([])
  AC_MSG_NOTICE([Security Drivers])
  AC_MSG_NOTICE([])
  AC_MSG_NOTICE([ SELinux: $with_secdriver_selinux])
 +AC_MSG_NOTICE([ AppArmor: $with_secdriver_apparmor])
  AC_MSG_NOTICE([])
  AC_MSG_NOTICE([Driver Loadable Modules])
  AC_MSG_NOTICE([])
 @@ -1753,6 +1832,11 @@ AC_MSG_NOTICE([ selinux: $SELINUX_CFLAGS
  else
  AC_MSG_NOTICE([ selinux: no])
  fi
 +if test $with_apparmor = yes ; then
 +AC_MSG_NOTICE([ apparmor: $APPARMOR_CFLAGS $APPARMOR_LIBS])
 +else
 +AC_MSG_NOTICE([ apparmor: no])
 +fi
  if test $with_numactl = yes ; then
  AC_MSG_NOTICE([ numactl: $NUMACTL_CFLAGS $NUMACTL_LIBS])
  else
 diff -Nurp ./libvirt.orig/src/Makefile.am ./libvirt/src/Makefile.am
 --- ./libvirt.orig/src/Makefile.am2009-09-08 13:00:00.0 -0500
 +++ ./libvirt/src/Makefile.am 2009-09-08 15:32:22.0 -0500
 @@ -9,6 +9,7 @@ INCLUDES = \
  $(LIBSSH2_CFLAGS) \
  $(XEN_CFLAGS) \
  $(SELINUX_CFLAGS) \
 +$(APPARMOR_CFLAGS) \
  $(DRIVER_MODULE_CFLAGS) \
  -DLIBDIR=\$(libdir)\ \
  -DBINDIR=\$(libexecdir)\ \
 @@ -216,6 +217,8 @@ SECURITY_DRIVER_SOURCES = 
 \
  SECURITY_DRIVER_SELINUX_SOURCES =\
   security_selinux.h security_selinux.c
  
 +SECURITY_DRIVER_APPARMOR_SOURCES =   \
 + security_apparmor.h security_apparmor.c
  
  NODE_DEVICE_DRIVER_SOURCES = \
   node_device.c node_device.h
 @@ -527,6 

Re: [libvirt] Resubmission: [PATCH 4/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:22:14PM -0500, Jamie Strandboge wrote:
 On Tue, 08 Sep 2009, Jamie Strandboge wrote:
 
   [PATCH 4]
   patch_4_tests.patch:
   Adds tests for virt-aa-helper and the security driver. secaatest.c is
   identical to seclabeltest.c except it initializes the 'apparmor' driver
   instead of 'selinux'. These tests are integrated into 'make check' and
   pass.
   
 
 -- 
 Jamie Strandboge | http://www.canonical.com

 diff -Nurp ./libvirt.orig/tests/Makefile.am ./libvirt/tests/Makefile.am
 --- ./libvirt.orig/tests/Makefile.am  2009-08-17 11:00:40.0 -0500
 +++ ./libvirt/tests/Makefile.am   2009-09-08 15:32:22.0 -0500
 @@ -77,6 +77,10 @@ if WITH_SECDRIVER_SELINUX
  noinst_PROGRAMS += seclabeltest
  endif
  
 +if WITH_SECDRIVER_APPARMOR
 +noinst_PROGRAMS += secaatest
 +endif
 +
  if WITH_CIL
  noinst_PROGRAMS += object-locking
  endif
 @@ -112,6 +116,9 @@ test_scripts +=   \
   virsh-synopsis
  endif
  
 +if WITH_SECDRIVER_APPARMOR
 +test_scripts += virt-aa-helper-test
 +endif
  EXTRA_DIST += $(test_scripts)
  
  TESTS = virshtest \
 @@ -138,6 +145,10 @@ if WITH_SECDRIVER_SELINUX
  TESTS += seclabeltest
  endif
  
 +if WITH_SECDRIVER_APPARMOR
 +TESTS += secaatest
 +endif
 +
  if WITH_LIBVIRTD
  noinst_PROGRAMS += eventtest
  TESTS += eventtest
 @@ -255,6 +266,14 @@ else
  EXTRA_DIST += seclabeltest.c
  endif
  
 +if WITH_SECDRIVER_APPARMOR
 +secaatest_SOURCES = \
 + secaatest.c
 +secaatest_LDADD = ../src/libvirt_driver_security.la $(LDADDS)
 +else
 +EXTRA_DIST += secaatest.c
 +endif
 +
  qparamtest_SOURCES = \
   qparamtest.c testutils.h testutils.c
  qparamtest_LDADD = $(LDADDS)
 diff -Nurp ./libvirt.orig/tests/secaatest.c ./libvirt/tests/secaatest.c
 --- ./libvirt.orig/tests/secaatest.c  1969-12-31 18:00:00.0 -0600
 +++ ./libvirt/tests/secaatest.c   2009-09-08 15:32:22.0 -0500
 @@ -0,0 +1,45 @@
 +#include config.h
 +
 +#include unistd.h
 +#include stdlib.h
 +#include stdio.h
 +#include string.h
 +#include errno.h
 +#include security.h
 +
 +int
 +main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
 +{
 +int ret;
 +
 +const char *doi, *model;
 +virSecurityDriverPtr security_drv;
 +
 +ret = virSecurityDriverStartup (security_drv, apparmor);
 +if (ret == -1)
 +{
 +fprintf (stderr, Failed to start security driver);
 +exit (-1);
 +}
 +/* No security driver wanted to be enabled: just return */
 +if (ret == -2)
 +return 0;
 +
 +model = virSecurityDriverGetModel (security_drv);
 +if (!model)
 +{
 +fprintf (stderr, Failed to copy secModel model: %s,
 + strerror (errno));
 +exit (-1);
 +}
 +
 +doi = virSecurityDriverGetDOI (security_drv);
 +if (!doi)
 +{
 +fprintf (stderr, Failed to copy secModel DOI: %s,
 + strerror (errno));
 +exit (-1);
 +}
 +
 +return 0;
 +}
 diff -Nurp ./libvirt.orig/tests/virt-aa-helper-test 
 ./libvirt/tests/virt-aa-helper-test
 --- ./libvirt.orig/tests/virt-aa-helper-test  1969-12-31 18:00:00.0 
 -0600
 +++ ./libvirt/tests/virt-aa-helper-test   2009-09-08 15:32:22.0 
 -0500
 @@ -0,0 +1,100 @@
 +#!/bin/sh
 +set -e
 +
 +output=/dev/null
 +use_valgrind=
 +ld_library_path=
 +if [ ! -z $1 ]  [ $1 = -d ]; then
 +output=/dev/stdout
 +shift
 +fi
 +
 +exe=../src/virt-aa-helper
 +if [ ! -z $1 ]; then
 +if [ $1 = -v ]; then
 +use_valgrind=yes
 +exe=./src/.libs/virt-aa-helper
 +ld_library_path=./src/.libs
 +else
 +exe=$1
 +fi
 +shift
 +fi
 +
 +if [ ! -x $exe ]; then
 +echo Could not find '$exe'
 +exit 1
 +fi
 +
 +echo testing `basename $exe` $output
 +if [ $use_valgrind = yes ]; then
 +exe=valgrind --error-exitcode=2 --track-origins=yes $exe
 +fi
 +
 +extra_args=--dryrun
 +errors=0
 +
 +tmpdir=`mktemp -d`
 +trap rm -rf $tmpdir EXIT HUP INT QUIT TERM
 +
 +disk1=$tmpdir/1.img
 +disk2=$tmpdir/2.img
 +relative_disk1=$tmpdir/./../`basename $tmpdir`//./1.img
 +nonexistent=$tmpdir/nonexistant.img
 +bad_disk=/etc/passwd
 +valid_uuid=libvirt-----0123456789ab
 +valid_name=foo
 +nonexistent_uuid=libvirt-----0001
 +touch $disk1 $disk2
 +
 +testme() {
 +expected=$1
 +outstr=$2
 +args=$3
 +echo -n   $outstr:  $output
 +echo  '$extra_args $args':  $output
 +set +e
 +LD_LIBRARY_PATH=$ld_library_path $exe $extra_args $args $output 21
 +rc=$?
 +set -e
 +if [ $rc = $expected ]; then
 +echo pass $output
 +else
 +echo FAIL: exited with '$rc' $output
 +errors=$(($errors + 1))
 +fi
 +}
 +
 +# Expected failures
 +echo Expected failures: $output
 +testme 1 invalid arg -z
 +testme 1 invalid case -A
 +testme 1 not enough args -c
 +testme 1 missing name -c -n -u $valid_uuid $disk1
 +testme 1 bad name -c -n foo[a-z] -u $valid_uuid $disk1
 +testme 1 no -u 

Re: [libvirt] [PATCH 01/10] Fix formatting of machine types in capabilities XML

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:09PM +0100, Mark McLoughlin wrote:
 * src/capabilities.c: fix machine type formatting in
   virCapabilitiesFormatXML()
 ---
  src/capabilities.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/capabilities.c b/src/capabilities.c
 index 289180d..38fe7fc 100644
 --- a/src/capabilities.c
 +++ b/src/capabilities.c
 @@ -713,7 +713,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
  
  for (k = 0 ; k  
 caps-guests[i]-arch.domains[j]-info.nmachines ; k++) {
  virCapsGuestMachinePtr machine = 
 caps-guests[i]-arch.domains[j]-info.machines[k];
 -virBufferAddLit(xml,   machine);
 +virBufferAddLit(xml, machine);
  if (machine-canonical)
  virBufferVSprintf(xml,  canonical='%s', 
 machine-canonical);
  virBufferVSprintf(xml, %s/machine\n, machine-name);

  ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 02/10] Dump qemu driver capabilities if test debugging enabled

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:10PM +0100, Mark McLoughlin wrote:
 * src/testutils.[ch]: make testDebug externally available
 
 * src/testutilsqemu.c: if VIR_TEST_DEBUG is set, dump the qemu
   driver capabilities to stderr

  ACK, useful !

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 03/10] Canonicalize the qemu machine type in qemuxml2argvtest

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:11PM +0100, Mark McLoughlin wrote:
 This doesn't have any affect on the current tests because we don't have
 any machine aliases in the current test data.
 
 * src/qemu_conf.h, src/qemu_driver.c: expose qemudCanonicalizeMachine()
   for the tests
 
 * tests/qemuxml2argvtest.c: canonicalize the machine type
 ---
  src/qemu_conf.h  |3 +++
  src/qemu_driver.c|7 +++
  tests/qemuxml2argvtest.c |3 +++
  3 files changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu_conf.h b/src/qemu_conf.h
 index 9fa4559..ed91d2c 100644
 --- a/src/qemu_conf.h
 +++ b/src/qemu_conf.h
 @@ -194,6 +194,9 @@ int qemudProbeMachineTypes  (const char 
 *binary,
   virCapsGuestMachinePtr **machines,
   int *nmachines);
  
 +int qemudCanonicalizeMachine(struct qemud_driver *driver,
 + virDomainDefPtr def);
 +
  virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
   virCapsPtr caps,
   const char **progenv,
 diff --git a/src/qemu_driver.c b/src/qemu_driver.c
 index ae112d8..f2b0bec 100644
 --- a/src/qemu_driver.c
 +++ b/src/qemu_driver.c
 @@ -4781,10 +4781,9 @@ qemudCanonicalizeMachineDirect(virDomainDefPtr def, 
 char **canonical)
  return 0;
  }
  
 -static int
 -qemudCanonicalizeMachine(virConnectPtr conn, virDomainDefPtr def)
 +int
 +qemudCanonicalizeMachine(struct qemud_driver *driver, virDomainDefPtr def)
  {
 -struct qemud_driver *driver = conn-privateData;
  char *canonical = NULL;
  int i;
  
 @@ -4875,7 +4874,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr 
 conn, const char *xml) {
  }
  }
  
 -if (qemudCanonicalizeMachine(conn, def)  0)
 +if (qemudCanonicalizeMachine(driver, def)  0)
  goto cleanup;
  
  if (!(vm = virDomainAssignDef(conn,
 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
 index d1cef0e..edd3744 100644
 --- a/tests/qemuxml2argvtest.c
 +++ b/tests/qemuxml2argvtest.c
 @@ -56,6 +56,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
  QEMUD_CMD_FLAG_NO_REBOOT |
  extraFlags;
  
 +if (qemudCanonicalizeMachine(driver, vmdef)  0)
 +goto fail;
 +
  if (qemudBuildCommandLine(NULL, driver,
vmdef, monitor_chr, flags,
argv, qenv,

  Okay, the patch to source is minor, and this will help later on
  testing, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 04/10] Re-factor qemu test machine allocation code

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:12PM +0100, Mark McLoughlin wrote:
 * test/testutilsqemu.c: split out code to testQemuAllocMachines()
   and make use of the ARRAY_CARDINALITY macro
 ---
  tests/testutilsqemu.c |   30 +-
  1 files changed, 21 insertions(+), 9 deletions(-)

  cleanup, ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 05/10] Test qemu machine aliases

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:13PM +0100, Mark McLoughlin wrote:
 * tests/testutilsqemu.c: make 'pc' an alias for qemu-system-x86_64
 
 * tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.*,
   tests/qemuxml2argvtest.c: add a test which uses qemu-system-x86_64
   and make sure the machine type is canonicalized.
 ---
  .../qemuxml2argv-machine-aliases1.args |1 +
  .../qemuxml2argv-machine-aliases1.xml  |   22 ++
  tests/qemuxml2argvtest.c   |1 +
  tests/testutilsqemu.c  |   31 
 +++-
  4 files changed, 54 insertions(+), 1 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
 
 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args 
 b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
 new file mode 100644
 index 000..4f62cb1
 --- /dev/null
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
 @@ -0,0 +1 @@
 +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test 
 /usr/bin/qemu-system-x86_64 -S -M pc-0.11 -m 214 -smp 1 -nographic -monitor 
 unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda 
 /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml 
 b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
 new file mode 100644
 index 000..039abfd
 --- /dev/null
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
 @@ -0,0 +1,22 @@
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
 +  memory219200/memory
 +  currentMemory219200/currentMemory
 +  vcpu1/vcpu
 +  os
 +type arch='x86_64' machine='pc'hvm/type
 +boot dev='hd'/
 +  /os
 +  clock offset='utc'/
 +  on_poweroffdestroy/on_poweroff
 +  on_rebootrestart/on_reboot
 +  on_crashdestroy/on_crash
 +  devices
 +emulator/usr/bin/qemu-system-x86_64/emulator
 +disk type='block' device='disk'
 +  source dev='/dev/HostVG/QEMUGuest1'/
 +  target dev='hda' bus='ide'/
 +/disk
 +  /devices
 +/domain
 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
 index edd3744..afaf392 100644
 --- a/tests/qemuxml2argvtest.c
 +++ b/tests/qemuxml2argvtest.c
 @@ -190,6 +190,7 @@ mymain(int argc, char **argv)
  unsetenv(LD_LIBRARY_PATH);
  
  DO_TEST(minimal, QEMUD_CMD_FLAG_NAME);
 +DO_TEST(machine-aliases1, 0);
  DO_TEST(boot-cdrom, 0);
  DO_TEST(boot-network, 0);
  DO_TEST(boot-floppy, 0);
 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
 index d85e4c7..ad58010 100644
 --- a/tests/testutilsqemu.c
 +++ b/tests/testutilsqemu.c
 @@ -24,6 +24,35 @@ static virCapsGuestMachinePtr *testQemuAllocMachines(int 
 *nmachines)
  return machines;
  }
  
 +/* Newer versions of qemu have versioned machine types to allow
 + * compatibility with older releases.
 + * The 'pc' machine type is an alias of the newest machine type.
 + */
 +static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
 +{
 +virCapsGuestMachinePtr *machines;
 +char *canonical;
 +static const char *const x86_machines[] = {
 +pc-0.11, pc, pc-0.10, isapc
 +};
 +
 +if ((canonical = strdup(x86_machines[0])) == NULL)
 +return NULL;
 +
 +machines = virCapabilitiesAllocMachines(x86_machines,
 +ARRAY_CARDINALITY(x86_machines));
 +if (machines == NULL) {
 +VIR_FREE(canonical);
 +return NULL;
 +}
 +
 +machines[1]-canonical = canonical;
 +
 +*nmachines = ARRAY_CARDINALITY(x86_machines);
 +
 +return machines;
 +}
 +
  virCapsPtr testQemuCapsInit(void) {
  struct utsname utsname;
  virCapsPtr caps;
 @@ -56,7 +85,7 @@ virCapsPtr testQemuCapsInit(void) {
NULL) == NULL)
  goto cleanup;
  
 -if ((machines = testQemuAllocMachines(nmachines)) == NULL)
 +if ((machines = testQemuAllocNewerMachines(nmachines)) == NULL)
  goto cleanup;
  
  if ((guest = virCapabilitiesAddGuest(caps, hvm, x86_64, 64,

  ACK, more tests is good,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] Resubmission: [PATCH 3/6] sVirt AppArmor security driver

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 04:21:23PM -0500, Jamie Strandboge wrote:
 diff -Nurp ./libvirt.orig/src/security_apparmor.c 
 ./libvirt/src/security_apparmor.c
 --- ./libvirt.orig/src/security_apparmor.c1969-12-31 18:00:00.0 
 -0600
 +++ ./libvirt/src/security_apparmor.c 2009-09-08 15:32:42.0 -0500

 +/*
 + * profile_status returns '-1' on error, '0' if loaded
 + *
 + * If check_enforcing is set to '1', then returns '-1' on error, '0' if
 + * loaded in complain mode, and '1' if loaded in enforcing mode.
 + */
 +static int
 +profile_status(const char *str, const int check_enforcing)
 +{
 +char ebuf[1024];
 +char *content = NULL;
 +char *tmp = NULL;
 +char *etmp = NULL;
 +int rc = -1;
 +
 +/* create string that is 'str \0' for accurate matching */
 +if (VIR_ALLOC_N(tmp, strlen(str) + 2)  0) {
 +virSecurityReportError(NULL, VIR_ERR_ERROR,
 +   _
 +   (%s: could not allocate memory for string),
 +   __func__);
 +return rc;
 +}
 +sprintf(tmp, %s , str);
 +
 +if (check_enforcing != 0) {
 +/* create string that is 'str (enforce)\0' for accurate matching */
 +if (VIR_ALLOC_N(etmp, strlen(str) + 11)  0) {
 +virSecurityReportError(NULL, VIR_ERR_ERROR,
 +   _(%s: could not allocate memory for 
 + string), __func__);
 +VIR_FREE(tmp);
 +return rc;
 +}
 +sprintf(etmp, %s (enforce), str);
 +}

Can you replace the VIR_ALLOC_N + sprintf  calls with just virAsprintf()
which is safer wrt future changes because it is guarenteed to automatically
allocate the correct amount of memory without us needing to hardcode it.
Likewise for future instances of ALLOC+printf in this patch.

 +
 +if (virFileReadAll(APPARMOR_PROFILES_PATH, MAX_FILE_LEN, content)  0) {
 +virSecurityReportError(NULL, VIR_ERR_ERROR,
 +   _
 +   (%s: Failed to read AppArmor profiles list 
 +%s: %s), __func__,
 +   APPARMOR_PROFILES_PATH, virStrerror(errno,
 +   ebuf,
 +   sizeof
 +   ebuf));

I realize you're just copying the existing SELinux code style here, but
unfortunately the SELinux driver code was not following our best practices
for error reporting. Any place where you have an 'errno' value should call
the generic  virReportSystemError() function, and not use virStrerror().
Also, there's no need to ever pass __func__ to any error reporting APIs
since we capture function, filename  lineno automatically in all cases.

 +static int
 +load_profile(const char *profile, virDomainObjPtr vm,
 + const char *skip_disk)
 +{
 +const char **argv;
 +int rc = -1;
 +int offset;
 +size_t i;
 +size_t len;
 +int create;
 +int j;
 +
 +create = 1;
 +offset = 6;
 +if (profile_status_file(profile) = 0)
 +create = 0;
 +len = offset + vm-def-ndisks + 1;
 +
 +if (VIR_ALLOC_N(argv, len)  0) {
 +virSecurityReportError(NULL, VIR_ERR_ERROR,
 +   _(%s: could not allocate memory),
 +   __func__);
 +return rc;
 +}
 +
 +argv[0] = VIRT_AA_HELPER_PATH;
 +argv[2] = (char *) -u;
 +argv[3] = profile;
 +argv[4] = (char *) -n;
 +argv[5] = vm-def-name;
 +
 +if (create == 0)
 +argv[1] = (char *) -r;
 +else
 +argv[1] = (char *) -c;
 +
 +/* add disks to argv, skipping skip_disk if it is defined. */
 +j = 0;
 +for (i = 0; i  vm-def-ndisks; i++) {
 +if (vm-def-disks[i]-src == NULL || (skip_disk != NULL 
 +   STREQ(skip_disk,
 + vm-def-
 + disks[i]-src))) {
 +continue;
 +}
 +if (offset + j = len - 1)
 +break;
 +argv[offset + j] = vm-def-disks[i]-src;
 +j++;
 +}
 +argv[offset + j] = NULL;
 +
 +if (virRun(NULL, argv, NULL) == 0)
 +rc = 0;
 +
 +VIR_FREE(argv);
 +return rc;
 +}

IMHO the way data is passed from the security driver to the aa-helper program
is sub-optimal  requires too much unneccessary code. As you add in support
for USB  PCI device labelling you'll have a large number of additional args
to pass to the helper. We'll likely add even more later for serial/parallel
device assignment  other config options. In effect we'll end up inventing a
entirely new custom data interchange format for this helper, when we already
have a perfect one for the job the 

Re: [libvirt] [PATCH 06/10] Split up qemudGetOldMachines()

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:14PM +0100, Mark McLoughlin wrote:
 We need to look at all the domain infos in guest capabilities, not
 just the defaults.
 
 In order to allow that, split out a qemudGetOldMachinesFromInfo()
 from qemudGetOldMachines(). We'll make more use of it in the next
 patch.
 
 * src/qemu_conf.c: split out qemudGetOldMachinesFromInfo() from
   qemudGetOldMachines()
 ---
  src/qemu_conf.c |   90 ++
  1 files changed, 50 insertions(+), 40 deletions(-)
 

  Hum, I really had to convince myself this was really functionally
equivalent, but yes, ACK

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 07/10] Look up machine types from all domains in qemudGetOldMachines()

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:15PM +0100, Mark McLoughlin wrote:
 Rather than just looking at the default domain info, look at all
 domains
 
 * src/qemu_conf.c: look at all domains in qemudGetOldMachines()
 ---

  I'm not entierely clear of what this actually does, but it sounds
fine. Not 100% sure though,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 08/10] Probe machine types from kvm binary too

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:16PM +0100, Mark McLoughlin wrote:
 Currently we only probe the main qemu binary for machine types, but we
 should also probe the kvm binary.
 
 * src/qemu_conf.c: probe kvm binary machines in qemudCapsInitGuest()
 ---
  src/qemu_conf.c |   50 ++
  1 files changed, 42 insertions(+), 8 deletions(-)
 

  ACK, IIRC we have a bug about this, right ?

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 09/10] Simplify and fix qemudCanonicalizeMachine()

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:17PM +0100, Mark McLoughlin wrote:
 The algorithm is quite simple:
 
   If the emulator matches a guest's domain:
 if domain has machine type info:
   check the domain's machine type info
 else
   check the guest's default machine type info
   else if the emulator matches the guest's default emulator:
  check the guest's default machine type info
 
 The previous implementation was incorrectly falling back to the default
 machine type info if the domain's machine type info didn't have an
 alias.
 
 * src/qemu_driver.c: simplify and fix qemudCanonicalizeMachine()
 ---
  src/qemu_driver.c |   33 +++--
  1 files changed, 15 insertions(+), 18 deletions(-)

  That looks simpler, I'm a bit worried about landing this so close to
0.7.1 release though, but I guess we have good reasons,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH 10/10] Test that domain-specific qemu machine types are used correctly

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 12:35:18PM +0100, Mark McLoughlin wrote:
 * tests/testutilsqemu.c: add a machine types list for /usr/bin/kvm
   which doesn't have any aliases, while the guest has aliases
 
 * tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.*,
   tests/qemuxml2argvtest.c: add a test using /usr/bin/kvm and make
   sure that 'pc' machine type doesn't get canonicalized using the
   aliases in the guest machine type list
 ---
  .../qemuxml2argv-machine-aliases2.args |1 +
  .../qemuxml2argv-machine-aliases2.xml  |   22 
 
  tests/qemuxml2argvtest.c   |1 +
  tests/testutilsqemu.c  |9 ++-
  4 files changed, 31 insertions(+), 2 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.args
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.xml
 

  ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] libvir: QEMU error : remoteDomainProcessEvent: unmarshalling msg

2009-09-10 Thread Daniel P. Berrange
On Mon, Sep 07, 2009 at 05:46:51PM +0300, Kenneth Nagin wrote:
 Chris Lalancette clala...@redhat.com wrote on 07/09/2009 17:29:10:

  Kenneth Nagin wrote:
   I am monitoring events using the example event monitor, event-test,
 but
   remoteDomainProcessEvent is outputing an unmarshalling msg error
   when creating a VM.
  
   I've installed libvirt 0.6.5.  It is configured without  XEN; otherwise
 it
   is the default configuration.
  
   Any suggestions on how to overcome the problem?
 
  Hm, it seems to work without problems for me, but I'm running the git tip
 of
  libvirt.  I would suggest:
 
  1)  Trying out the newest version of libvirt to see if the problem
  is fixed in there
  2)  Give us more information about what kind of guests you are running
 (I'm
  assuming KVM), how you are running the event-test, and your test
 environment.
 I'm running KVM-87.  I'm just running event-test with the default
 parameter.
 My test environment is just creating a VM with virsh. It creates
 successful.
 The event-test worked fine with libvirt 0.5.1 and KVM-84.

Can you try the latest libvirt GIT codebase. There's been quite alot of
change since 0.6.5 in GIT and it may well have (accidentally) fixed the
problem you see. I'm unable to reproduce it myself, but there's always
the possiblity of a race condition somewhere that only certain people
would hit.

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: [PATCH] also allow use of XZ for Qemu image compression

2009-09-10 Thread Charles Duffy

Jim Meyering wrote:

Daniel Veillard wrote:

  Hum, I realize that support of LZOP was added after 0.7.0, so we never
made a release with it (well except for git snapshot which may have been
pushed).
  I wonder if the best is not to just drop the lzop option altogether
and stick xz as a package dependancy until we have found a way to
provide at the API level which compression options are actually
available.

  Opinions ?


Dropping lzop sounds good.  It seems lzop is not very popular.
We don't need that many choices.


lzop may not be popular, but it is distinct -- a minimum of 3x faster 
than every other compressor offered as an option.


As the decision to use compression at all is offered as a disk space vs 
performance tradeoff, having an option with minimal performance impact 
is crucial inasmuch as it makes compression valuable to users for whom 
the tradeoff otherwise might not have made sense at all.


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


Re: [libvirt] [PATCH 09/10] Simplify and fix qemudCanonicalizeMachine()

2009-09-10 Thread Mark McLoughlin
On Thu, 2009-09-10 at 14:13 +0200, Daniel Veillard wrote:
 On Thu, Sep 10, 2009 at 12:35:17PM +0100, Mark McLoughlin wrote:
  The algorithm is quite simple:
  
If the emulator matches a guest's domain:
  if domain has machine type info:
check the domain's machine type info
  else
check the guest's default machine type info
else if the emulator matches the guest's default emulator:
   check the guest's default machine type info
  
  The previous implementation was incorrectly falling back to the default
  machine type info if the domain's machine type info didn't have an
  alias.
  
  * src/qemu_driver.c: simplify and fix qemudCanonicalizeMachine()
  ---
   src/qemu_driver.c |   33 +++--
   1 files changed, 15 insertions(+), 18 deletions(-)
 
   That looks simpler, I'm a bit worried about landing this so close to
 0.7.1 release though, but I guess we have good reasons,

Yeah - it's basically a blocker for people like Anton who's installed
kvm is newer than the installed qemu.

Pushing now

Cheers,
Mark.

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


[libvirt] Trouble booting Xen VM with NFS root file system

2009-09-10 Thread Matthias Schmidt
Hi,

I'm currently trying to boot a Xen VM with the root file system on NFS
via libvirt.  Previously we used a small python script and xm create to
boot a number of VMs (which worked fine).  Now I'm trying to integrate
that functionality in a python project which uses libvirt, but
sadly booting the VMs fail.

The small script constructs a Xen command line which looks like the
following:

create =(/usr/sbin/xm create /foo.cfg \
 kernel=%s ramdisk=%s memory=64\
 root=/dev/nfs nfs_server=%s nfs_root=%s name=%s vif='mac=%s'\
 dhcp='dhcp' vcpus=1 extra='init=/stateless.sh xencons=tty1'\
 )%(vm_kernel, vm_ramdisk, vm_nfs_server, vm_nfs_root, hostname, vif)

kernel and ramdisk are the path to the installed version, vm_nfs_server is the
IP address of the NFS server and vm_nfs_root the path to the operating system
installation (which is a Debian Linux).  Firing up the script brings up
all VMs with a read-only NFS root file system.

Now I tried to do this with libvirt, but all attempts failed with the
following error popping up after the VM boots (after a certain
time(out)):

Gave up waiting for root device.  Common problems:
 - Boot args (cat /proc/cmdline)
   - Check rootdelay= (did the system wait long enough?)
   - Check root= (did the system wait for the right device?)
 - Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/nfs does not exist. Dropping to a shell!

BusyBox v1.10.2 (Debian 1:1.10.2-2) built-in shell (ash)
Enter 'help' for a list of built-in commands.
/bin/sh: can't access tty; job control turned off
(initramfs) cat /proc/cmdline
 root=/dev/nfs nfs_server=10.0.0.150 nfs_root=/opt/xge/util/ph 
vif=mac=1A:00:00:00:00:64 dhcp=dhcp extra=init=./stateless.sh xencons=tty

The cmdline looks the same as in the script, but booting won't work.  I
can provide the libvirt XML used to boot the VM and further information
if that is necessary.
 
Cheers

Matthias

PS: I'm using Xen 3.2.1, Kernel 2.6.26 and libvirt 0.6.3 from Debian
here.

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


[libvirt] [PATCH] Fix use of dlopen modules

2009-09-10 Thread Daniel P. Berrange
Remove the bogus dependancy between node_device.c  storage_backend.c
by moving the virWaitForDevices into util.h where it can be shared
safely

* src/storage_backend_disk.c, src/storage_backend_logical.c,
  src/storage_backend_mpath.c, src/storage_backend_scsi.c: Replace
  virStorageBackendWaitForDevices with virFileWaitForDevices
* src/storage_backend.c, src/storage_backend.h: Remove
  virStorageBackendWaitForDevices, virWaitForDevices
* src/util.h, src/util.c: Add virFileWaitForDevices
* configure.in: Move xmlrpc check further down after pkgconfig
  is detected
* src/Makefile.am: Add missing XMLRPC_CFLAGS/LIBS to opennebula
* src/libvirt_private.syms: Add many missing exports
---
 configure.in  |6 +++---
 src/Makefile.am   |4 ++--
 src/libvirt_private.syms  |   14 +-
 src/node_device.c |4 ++--
 src/storage_backend.c |   31 ---
 src/storage_backend.h |2 --
 src/storage_backend_disk.c|4 ++--
 src/storage_backend_logical.c |2 +-
 src/storage_backend_mpath.c   |2 +-
 src/storage_backend_scsi.c|4 ++--
 src/util.c|   27 +++
 src/util.h|2 ++
 12 files changed, 55 insertions(+), 47 deletions(-)

diff --git a/configure.in b/configure.in
index 060eb50..120f7e7 100644
--- a/configure.in
+++ b/configure.in
@@ -463,6 +463,9 @@ if test $with_qemu = yes -o $with_lxc = yes ; then
 fi
 
 
+dnl Need to test if pkg-config exists
+PKG_PROG_PKG_CONFIG
+
 dnl OpenNebula driver Compilation setting
 dnl
 
@@ -491,9 +494,6 @@ AC_SUBST([XMLRPC_CFLAGS])
 AC_SUBST([XMLRPC_LIBS])
 
 
-dnl Need to test if pkg-config exists
-PKG_PROG_PKG_CONFIG
-
 dnl ==
 dnl find libxml2 library, borrowed from xmlsec
 dnl ==
diff --git a/src/Makefile.am b/src/Makefile.am
index 628edc5..02c1f74 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -396,8 +396,8 @@ noinst_LTLIBRARIES += libvirt_driver_one.la
 # Stateful, so linked to daemon instead
 #libvirt_la_LIBADD  += libvirt_driver_one.la
 endif
-libvirt_driver_one_la_CFLAGS = $(ONE_LIBS)
-libvirt_driver_one_la_LDFLAGS = $(ONE_LIBS)
+libvirt_driver_one_la_CFLAGS = $(XMLRPC_CFLAGS)
+libvirt_driver_one_la_LDFLAGS = $(XMLRPC_LIBS)
 #libvirt_driver_one_la_CFLAGS  = -DWITH_ONE
 if WITH_DRIVER_MODULES
 libvirt_driver_one_la_LDFLAGS += -module -avoid-version
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8dd279d..06192fc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -10,6 +10,7 @@ virBufferAdd;
 virBufferAddChar;
 virBufferContentAndReset;
 virBufferError;
+virBufferURIEncodeString;
 
 
 # caps.h
@@ -167,7 +168,16 @@ virHashSize;
 virInterfaceDefFormat;
 virInterfaceDefParseFile;
 virInterfaceDefParseString;
+virInterfaceDefParseNode;
 virInterfaceDefFree;
+virInterfaceFindByName;
+virInterfaceFindByMACString;
+virInterfaceAssignDef;
+virInterfaceRemove;
+virInterfaceObjLock;
+virInterfaceObjUnlock;
+virInterfaceObjListFree;
+
 
 # interface_driver.h
 interfaceRegister;
@@ -214,6 +224,7 @@ virRegisterNetworkDriver;
 virRegisterStateDriver;
 virRegisterStorageDriver;
 virRegisterDeviceMonitor;
+virRegisterSecretDriver;
 
 
 # logging.h
@@ -410,6 +421,7 @@ virGetUserName;
 virGetUserID;
 virGetGroupID;
 virFileFindMountPoint;
+virFileWaitForDevices;
 
 
 # uuid.h
@@ -421,7 +433,7 @@ virUUIDParse;
 # virterror_internal.h
 virReportErrorHelper;
 virErrorMsg;
-virRaiseError;
+virRaiseErrorFull;
 virReportSystemErrorFull;
 virReportOOMErrorFull;
 virStrerror;
diff --git a/src/node_device.c b/src/node_device.c
index ded203f..69e15b6 100644
--- a/src/node_device.c
+++ b/src/node_device.c
@@ -35,7 +35,7 @@
 #include node_device_conf.h
 #include node_device_hal.h
 #include node_device.h
-#include storage_backend.h /* For virWaitForDevices */
+#include util.h
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
 
@@ -599,7 +599,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const 
char *wwpn)
 
 while ((now - start)  LINUX_NEW_DEVICE_WAIT_TIME) {
 
-virWaitForDevices(conn);
+virFileWaitForDevices(conn);
 
 dev = nodeDeviceLookupByWWN(conn, wwnn, wwpn);
 
diff --git a/src/storage_backend.c b/src/storage_backend.c
index 5e04f35..0a20255 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -630,31 +630,6 @@ virStorageBackendGetBuildVolFromFunction(virConnectPtr 
conn,
 return virStorageBackendCreateRaw;
 }
 
-#if defined(UDEVADM) || defined(UDEVSETTLE)
-void virWaitForDevices(virConnectPtr conn)
-{
-#ifdef UDEVADM
-const char *const settleprog[] = { UDEVADM, settle, NULL };
-#else
-const char *const settleprog[] = { UDEVSETTLE, NULL };
-#endif
-int exitstatus;
-
-if (access(settleprog[0], X_OK) != 0)
-return;
-
-/*
- * NOTE: we ignore errors 

Re: [libvirt] [PATCH] Fix use of dlopen modules

2009-09-10 Thread Daniel Veillard
On Thu, Sep 10, 2009 at 02:31:00PM +0100, Daniel P. Berrange wrote:
 Remove the bogus dependancy between node_device.c  storage_backend.c
 by moving the virWaitForDevices into util.h where it can be shared
 safely
 
 * src/storage_backend_disk.c, src/storage_backend_logical.c,
   src/storage_backend_mpath.c, src/storage_backend_scsi.c: Replace
   virStorageBackendWaitForDevices with virFileWaitForDevices
 * src/storage_backend.c, src/storage_backend.h: Remove
   virStorageBackendWaitForDevices, virWaitForDevices
 * src/util.h, src/util.c: Add virFileWaitForDevices
 * configure.in: Move xmlrpc check further down after pkgconfig
   is detected
 * src/Makefile.am: Add missing XMLRPC_CFLAGS/LIBS to opennebula
 * src/libvirt_private.syms: Add many missing exports
 ---
  configure.in  |6 +++---
  src/Makefile.am   |4 ++--
  src/libvirt_private.syms  |   14 +-
  src/node_device.c |4 ++--
  src/storage_backend.c |   31 ---
  src/storage_backend.h |2 --
  src/storage_backend_disk.c|4 ++--
  src/storage_backend_logical.c |2 +-
  src/storage_backend_mpath.c   |2 +-
  src/storage_backend_scsi.c|4 ++--
  src/util.c|   27 +++
  src/util.h|2 ++
  12 files changed, 55 insertions(+), 47 deletions(-)
 
 diff --git a/configure.in b/configure.in
 index 060eb50..120f7e7 100644
 --- a/configure.in
 +++ b/configure.in
 @@ -463,6 +463,9 @@ if test $with_qemu = yes -o $with_lxc = yes ; then
  fi
  
  
 +dnl Need to test if pkg-config exists
 +PKG_PROG_PKG_CONFIG
 +
  dnl OpenNebula driver Compilation setting
  dnl
  
 @@ -491,9 +494,6 @@ AC_SUBST([XMLRPC_CFLAGS])
  AC_SUBST([XMLRPC_LIBS])
  
  
 -dnl Need to test if pkg-config exists
 -PKG_PROG_PKG_CONFIG
 -
  dnl 
 ==
  dnl find libxml2 library, borrowed from xmlsec
  dnl 
 ==
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 628edc5..02c1f74 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -396,8 +396,8 @@ noinst_LTLIBRARIES += libvirt_driver_one.la
  # Stateful, so linked to daemon instead
  #libvirt_la_LIBADD  += libvirt_driver_one.la
  endif
 -libvirt_driver_one_la_CFLAGS = $(ONE_LIBS)
 -libvirt_driver_one_la_LDFLAGS = $(ONE_LIBS)
 +libvirt_driver_one_la_CFLAGS = $(XMLRPC_CFLAGS)
 +libvirt_driver_one_la_LDFLAGS = $(XMLRPC_LIBS)
  #libvirt_driver_one_la_CFLAGS  = -DWITH_ONE
  if WITH_DRIVER_MODULES
  libvirt_driver_one_la_LDFLAGS += -module -avoid-version

 Okay, those 2 are really unrelated, but ACK

 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 8dd279d..06192fc 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -10,6 +10,7 @@ virBufferAdd;
  virBufferAddChar;
  virBufferContentAndReset;
  virBufferError;
 +virBufferURIEncodeString;
  
  
  # caps.h
 @@ -167,7 +168,16 @@ virHashSize;
  virInterfaceDefFormat;
  virInterfaceDefParseFile;
  virInterfaceDefParseString;
 +virInterfaceDefParseNode;
  virInterfaceDefFree;
 +virInterfaceFindByName;
 +virInterfaceFindByMACString;
 +virInterfaceAssignDef;
 +virInterfaceRemove;
 +virInterfaceObjLock;
 +virInterfaceObjUnlock;
 +virInterfaceObjListFree;
 +
  
  # interface_driver.h
  interfaceRegister;
 @@ -214,6 +224,7 @@ virRegisterNetworkDriver;
  virRegisterStateDriver;
  virRegisterStorageDriver;
  virRegisterDeviceMonitor;
 +virRegisterSecretDriver;
  
  
  # logging.h
 @@ -410,6 +421,7 @@ virGetUserName;
  virGetUserID;
  virGetGroupID;
  virFileFindMountPoint;
 +virFileWaitForDevices;
  
  
  # uuid.h
 @@ -421,7 +433,7 @@ virUUIDParse;
  # virterror_internal.h
  virReportErrorHelper;
  virErrorMsg;
 -virRaiseError;
 +virRaiseErrorFull;
  virReportSystemErrorFull;
  virReportOOMErrorFull;
  virStrerror;

 ACK

 diff --git a/src/node_device.c b/src/node_device.c
 index ded203f..69e15b6 100644
 --- a/src/node_device.c
 +++ b/src/node_device.c
 @@ -35,7 +35,7 @@
  #include node_device_conf.h
  #include node_device_hal.h
  #include node_device.h
 -#include storage_backend.h /* For virWaitForDevices */
 +#include util.h
  
  #define VIR_FROM_THIS VIR_FROM_NODEDEV
  
 @@ -599,7 +599,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, 
 const char *wwpn)
  
  while ((now - start)  LINUX_NEW_DEVICE_WAIT_TIME) {
  
 -virWaitForDevices(conn);
 +virFileWaitForDevices(conn);
  
  dev = nodeDeviceLookupByWWN(conn, wwnn, wwpn);
  
 diff --git a/src/storage_backend.c b/src/storage_backend.c
 index 5e04f35..0a20255 100644
 --- a/src/storage_backend.c
 +++ b/src/storage_backend.c
 @@ -630,31 +630,6 @@ virStorageBackendGetBuildVolFromFunction(virConnectPtr 
 conn,
  return virStorageBackendCreateRaw;
  }
  
 -#if defined(UDEVADM) || defined(UDEVSETTLE)
 -void virWaitForDevices(virConnectPtr conn)
 

Re: [libvirt] [PATCH] Fix use of dlopen modules

2009-09-10 Thread Daniel P. Berrange
On Thu, Sep 10, 2009 at 03:57:07PM +0200, Daniel Veillard wrote:
 On Thu, Sep 10, 2009 at 02:31:00PM +0100, Daniel P. Berrange wrote:
  Remove the bogus dependancy between node_device.c  storage_backend.c
  by moving the virWaitForDevices into util.h where it can be shared
  safely
  
  * src/storage_backend_disk.c, src/storage_backend_logical.c,
src/storage_backend_mpath.c, src/storage_backend_scsi.c: Replace
virStorageBackendWaitForDevices with virFileWaitForDevices
  * src/storage_backend.c, src/storage_backend.h: Remove
virStorageBackendWaitForDevices, virWaitForDevices
  * src/util.h, src/util.c: Add virFileWaitForDevices
  * configure.in: Move xmlrpc check further down after pkgconfig
is detected
  * src/Makefile.am: Add missing XMLRPC_CFLAGS/LIBS to opennebula
  * src/libvirt_private.syms: Add many missing exports
  ---
   configure.in  |6 +++---
   src/Makefile.am   |4 ++--
   src/libvirt_private.syms  |   14 +-
   src/node_device.c |4 ++--
   src/storage_backend.c |   31 ---
   src/storage_backend.h |2 --
   src/storage_backend_disk.c|4 ++--
   src/storage_backend_logical.c |2 +-
   src/storage_backend_mpath.c   |2 +-
   src/storage_backend_scsi.c|4 ++--
   src/util.c|   27 +++
   src/util.h|2 ++
   12 files changed, 55 insertions(+), 47 deletions(-)
  
  diff --git a/configure.in b/configure.in
  index 060eb50..120f7e7 100644
  --- a/configure.in
  +++ b/configure.in
  @@ -463,6 +463,9 @@ if test $with_qemu = yes -o $with_lxc = yes ; 
  then
   fi
   
   
  +dnl Need to test if pkg-config exists
  +PKG_PROG_PKG_CONFIG
  +
   dnl OpenNebula driver Compilation setting
   dnl
   
  @@ -491,9 +494,6 @@ AC_SUBST([XMLRPC_CFLAGS])
   AC_SUBST([XMLRPC_LIBS])
   
   
  -dnl Need to test if pkg-config exists
  -PKG_PROG_PKG_CONFIG
  -
   dnl 
  ==
   dnl find libxml2 library, borrowed from xmlsec
   dnl 
  ==
  diff --git a/src/Makefile.am b/src/Makefile.am
  index 628edc5..02c1f74 100644
  --- a/src/Makefile.am
  +++ b/src/Makefile.am
  @@ -396,8 +396,8 @@ noinst_LTLIBRARIES += libvirt_driver_one.la
   # Stateful, so linked to daemon instead
   #libvirt_la_LIBADD  += libvirt_driver_one.la
   endif
  -libvirt_driver_one_la_CFLAGS = $(ONE_LIBS)
  -libvirt_driver_one_la_LDFLAGS = $(ONE_LIBS)
  +libvirt_driver_one_la_CFLAGS = $(XMLRPC_CFLAGS)
  +libvirt_driver_one_la_LDFLAGS = $(XMLRPC_LIBS)
   #libvirt_driver_one_la_CFLAGS  = -DWITH_ONE
   if WITH_DRIVER_MODULES
   libvirt_driver_one_la_LDFLAGS += -module -avoid-version
 
  Okay, those 2 are really unrelated, but ACK

They are related actually. OpenNebula has always needed XMLRPC linker
flags, but this mistake was preventing it seeing them directly. By
accident it still worked though, probably because some other thing w
link to also pulls in the XMLRPC libs. When built as a dlopen'able
module though this bug was exposed.

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 01/10] Add usage to secret docs

2009-09-10 Thread Daniel P. Berrange
On Tue, Sep 08, 2009 at 10:43:30AM +0200, Daniel Veillard wrote:
 On Mon, Sep 07, 2009 at 04:12:36PM +0200, Miloslav Trma?? wrote:
  * docs/formatsecret.html.in, docs/formatsecret.html: Document usage
type='volume', replacing stand-alone volume.
  * docs/schemas/secret.rng: Update schema to require usage
type='volume'
 
   Okay, sounds fine and if we need to change the format we need to do
 it before the release,
 
   ACK,

I pushed this change

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 08/10] Consolidate cont into qemudMonitorSendCont()

2009-09-10 Thread Daniel P. Berrange
On Mon, Sep 07, 2009 at 04:12:43PM +0200, Miloslav Trma?? wrote:
 The interface allows qemudMonitorSendCont() to report errors that are
 not overridden by its callers.
 
 Also fix a potential infinite loop in qemuDomainCoreDump() if sending
 cont repeatedly fails.
 
 Changes since the fourth submission:
 - Replace the error_reported parameter by using virGetLastError() in
   callers
 
 * src/qemu_driver.c (qemudMonitorSendCont): New function.
   (qemudAutostartConfigs): Reset error before each call to
   qemudStartVMDaemon().
   (qemudInitCpus, qemudDomainResume, qemudDomainCoreDump,
   qemudDomainRestore, qemudDomainMigratePerform,
   qemudDomainMigrateFinish2): Use qemudMonitorSendCont().
 ---
  src/qemu_driver.c |   79 +++-
  1 files changed, 41 insertions(+), 38 deletions(-)

ACK, pushed this change

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 02/10] Add VIR_SECRET_GET_VALUE_INTERNAL_CALL.

2009-09-10 Thread Daniel P. Berrange
On Mon, Sep 07, 2009 at 04:12:37PM +0200, Miloslav Trma?? wrote:
 Add a VIR_SECRET_GET_VALUE_INTERNAL_CALL flag value, replacing the
 originally separate libvirt_internal_call parameter.  The flag is used
 to differentiate external virSecretGetValue() calls from internal calls
 by libvirt drivers that need to use the secret even if it is private.
 
 * src/libvirt_internal.h (VIR_SECRET_GET_VALUE_FLAGS_MASK): New
   definition.
 * src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): New definition.
 * src/libvirt.c (virSecretGetValue): Don't allow the user to specify
   internal flags.
 * src/remote_internal.c (remoteSecretGetValue): Don't allow send
   internal flags over RPC.
 ---
  src/driver.h   |   12 
  src/libvirt.c  |2 ++
  src/libvirt_internal.h |3 +++
  src/remote_internal.c  |3 ++-
  4 files changed, 19 insertions(+), 1 deletions(-)
 
 diff --git a/src/driver.h b/src/driver.h
 index 042c4af..28d7848 100644
 --- a/src/driver.h
 +++ b/src/driver.h
 @@ -12,6 +12,8 @@
  #include libxml/uri.h
  
  #include internal.h
 +#include libvirt_internal.h
 +
  /*
   * List of registered drivers numbers
   */
 @@ -802,6 +804,16 @@ struct _virDeviceMonitor {
  virDrvNodeDeviceDestroy deviceDestroy;
  };
  
 +enum {
 +/* This getValue call is inside libvirt, override the private flag.
 +   This flag can not be set by outside callers. */
 +VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1  16
 +};
 +
 +/* Make sure ... INTERNAL_CALL can not be set by the caller */
 +verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL 
 +VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
 +
  typedef virSecretPtr
  (*virDrvSecretLookupByUUIDString)(virConnectPtr conn,
const char *uuid);
 diff --git a/src/libvirt.c b/src/libvirt.c
 index 45619e2..96d204c 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 @@ -9066,6 +9066,8 @@ virSecretGetValue(virSecretPtr secret, size_t 
 *value_size, unsigned int flags)
  goto error;
  }
  
 +flags = VIR_SECRET_GET_VALUE_FLAGS_MASK;
 +
  if (conn-secretDriver != NULL  conn-secretDriver-getValue != NULL) {
  unsigned char *ret;
  
 diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
 index 6976f34..60564d2 100644
 --- a/src/libvirt_internal.h
 +++ b/src/libvirt_internal.h
 @@ -27,6 +27,9 @@
  /* bits 16 and above of virDomainXMLFlags are for internal use */
  #define VIR_DOMAIN_XML_FLAGS_MASK 0x
  
 +/* Bits 16 and above of virSecretGetValue flags are for internal use */
 +#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0x
 +
  #ifdef WITH_LIBVIRTD
  int virStateInitialize(int privileged);
  int virStateCleanup(void);
 diff --git a/src/remote_internal.c b/src/remote_internal.c
 index 3dd4609..745b128 100644
 --- a/src/remote_internal.c
 +++ b/src/remote_internal.c
 @@ -76,6 +76,7 @@
  # define AI_ADDRCONFIG 0
  #endif
  
 +#include libvirt_internal.h
  #include virterror_internal.h
  #include logging.h
  #include datatypes.h
 @@ -6595,7 +6596,7 @@ remoteSecretGetValue (virSecretPtr secret, size_t 
 *value_size,
  remoteDriverLock (priv);
  
  make_nonnull_secret (args.secret, secret);
 -args.flags = flags;
 +args.flags = flags  VIR_SECRET_GET_VALUE_FLAGS_MASK;
  
  memset (ret, 0, sizeof (ret));
  if (call (secret-conn, priv, 0, REMOTE_PROC_SECRET_GET_VALUE,

This is redundant, since libvirt.c has already masked the flags out by the
time we get here

I think the mask lives better in driver.h, so going to push the following
slight re-arrangement instead (also moving the existing flag)

Regards,
Daniel

commit 94a7da7de17a6355bcfc4ffce4b0c1053a5eb081
Author: Miloslav Trmač m...@redhat.com
Date:   Fri Aug 14 21:42:19 2009 +0200

Mask out flags used internally for virSecretGetValue

Add a VIR_SECRET_GET_VALUE_INTERNAL_CALL flag value, replacing the
originally separate libvirt_internal_call parameter.  The flag is used
to differentiate external virSecretGetValue() calls from internal calls
by libvirt drivers that need to use the secret even if it is private.

* src/libvirt_internal.h Remove VIR_DOMAIN_XML_FLAGS_MASK
* src/driver.h Add VIR_SECRET_GET_VALUE_FLAGS_MASK constant and
  VIR_SECRET_GET_VALUE_INTERNAL_CALL. Re-add the
  VIR_DOMAIN_XML_FLAGS_MASK constant
* src/libvirt.c (virSecretGetValue): Don't allow the user to specify
  internal flags.

diff --git a/src/driver.h b/src/driver.h
index 042c4af..447b7a2 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -802,6 +802,22 @@ struct _virDeviceMonitor {
 virDrvNodeDeviceDestroy deviceDestroy;
 };
 
+/* bits 16 and above of virDomainXMLFlags are for internal use */
+#define VIR_DOMAIN_XML_FLAGS_MASK 0x
+
+/* Bits 16 and above of virSecretGetValue flags are for internal use */
+#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0x
+
+enum {
+/* This getValue call is inside libvirt, override the private flag.
+   This flag can not be set by 

Re: [libvirt] Interface driver and ESX support

2009-09-10 Thread Matthias Bolte
2009/9/10 Shahar Klein shaharkl...@yahoo.com:
 I'm not sure what you mean about mapping
 lets take the pnics as a study case for me
 do I need to define a structure similar to this:
 http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PhysicalNic.html
 and also take care for it's allocation?


Yes, you need to implement the mapping (a better word may be
'binding') of this VI API type to a C type, that also includes to care
about its allocation. You'll need to implement at least this set of
function in esx_vi_types.[ch]:

esxVI_PhysicalNic_Alloc()
esxVI_PhysicalNic_Free()
esxVI_PhysicalNic_CastFromAnyType()
esxVI_PhysicalNic_CastListFromAnyType()
esxVI_PhysicalNic_Deserialize()
esxVI_PhysicalNic_DeserializeList()

You could use the binding for the HostCpuIdInfo type, but
unfortunately I haven't published the code for it yet. This code also
includes some essential helper functions for
esxVI_PhysicalNic_CastListFromAnyType().

Beside the PhysicalNic type, you may also have to bind the types of
its members like PhysicalNicLinkInfo, PhysicalNicSpec and
HostIpConfig, if you need or care about the information provided by
them.

The binding for HostCpuIdInfo is part of a larger set of patches that
add some new features to ESX driver, but the patches needs some
cleanup first. I may have some time later this evening to clean them
up and post them.

PS: You should refer to version 2.5 of the VI API [1] and not 4.0,
because the complete VI API mapping is currently based on version 2.5.
At some point I'll have to properly distinguish between version 2.5
and 4.0, but currently I would like to stick to version 2.5 only.

[1] http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/

Matthias

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


[libvirt] [RFC,PATCH] network: add 'netboot' option to dhcp config

2009-09-10 Thread Jeremy Kerr
Currently, libvirtd will start a dnsmasq process for the virtual
network, but (aside from killing the dnsmasq process and replacing it),
there's no way to define tftp boot options.

This change introduces a 'netboot' tag to the dhcp configuration:

 network
   namedefault/name
   bridge name=virbr%d /
   forward/
   ip address=192.168.122.1 netmask=255.255.255.0
 dhcp
   range start=192.168.122.2 end=192.168.122.254 /
   netboot root=/srv/tftp file=pxeboot.img/
 /dhcp
   /ip
 /network

When root= and file= attributes are present, these are passed to the
arguments to dnsmasq:

 dnsmasq [...] --enable-tftp --tftp-root /srv/tftp --dhcp-boot pxeboot.img

At present, only local tftp servers are supported (ie, dnsmasq runs as
the tftp server), but we could improve this in future by adding a
server= attribute.

Signed-off-by: Jeremy Kerr j...@ozlabs.org

---
 docs/formatnetwork.html.in |6 ++
 docs/schemas/network.rng   |6 ++
 src/network_conf.c |   28 
 src/network_conf.h |9 +
 src/network_driver.c   |   10 ++
 5 files changed, 59 insertions(+)

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index fd68430..3186498 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -138,6 +138,12 @@
name to be given that host by the DHCP server (via the
 codename/code attribute).  span class=sinceSince 0.4.5/span
   /dd
+  dtcodenetboot/code/dt
+  ddThe optional codenetboot/code element specified network boot
+options to be provided by the DHCP server. Two attributes are
+required: coderoot/code (the root path of the TFTP server), and
+codefile/code (the file to be used for the boot image).
+  /dd
 /dl
 
 h2a name=examplesExample configuration/a/h2
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index a4281a5..571e916 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -76,6 +76,12 @@
 attribute name=iptext//attribute
   /element
 /zeroOrMore
+   optional
+ element name=netboot
+   attribute name=roottext//attribute
+   attribute name=filetext//attribute
+ /element
+   /optional
   /element
 /element
   /optional
diff --git a/src/network_conf.c b/src/network_conf.c
index 3764bb4..87bb5e4 100644
--- a/src/network_conf.c
+++ b/src/network_conf.c
@@ -115,6 +115,9 @@ void virNetworkDefFree(virNetworkDefPtr def)
 }
 VIR_FREE(def-hosts);
 
+VIR_FREE(def-tftproot);
+VIR_FREE(def-bootfile);
+
 VIR_FREE(def);
 }
 
@@ -299,6 +302,24 @@ virNetworkDHCPRangeDefParseXML(virConnectPtr conn,
 def-hosts[def-nhosts].name = (char *)name;
 def-hosts[def-nhosts].ip = (char *)ip;
 def-nhosts++;
+
+} else if (cur-type == XML_ELEMENT_NODE 
+xmlStrEqual(cur-name, BAD_CAST netboot)) {
+xmlChar *root, *file;
+
+if (!(root = xmlGetProp(cur, BAD_CAST root))) {
+cur = cur-next;
+continue;
+}
+
+if (!(file = xmlGetProp(cur, BAD_CAST file))) {
+cur = cur-next;
+xmlFree(root);
+continue;
+}
+
+def-tftproot = (char *)root;
+def-bootfile = (char *)file;
 }
 
 cur = cur-next;
@@ -621,6 +642,13 @@ char *virNetworkDefFormat(virConnectPtr conn,
 virBufferVSprintf(buf, ip='%s' , def-hosts[i].ip);
 virBufferAddLit(buf, /\n);
 }
+if (virNetworkDefProvidesNetboot(def)) {
+virBufferAddLit(buf,   netboot);
+virBufferEscapeString(buf,  root='%s', def-tftproot);
+virBufferEscapeString(buf,  file='%s', def-bootfile);
+virBufferAddLit(buf,  /\n);
+}
+
 virBufferAddLit(buf, /dhcp\n);
 }
 
diff --git a/src/network_conf.h b/src/network_conf.h
index 4076f9a..f6f7c1e 100644
--- a/src/network_conf.h
+++ b/src/network_conf.h
@@ -78,8 +78,17 @@ struct _virNetworkDef {
 
 unsigned int nhosts; /* Zero or more dhcp hosts */
 virNetworkDHCPHostDefPtr hosts;
+
+char *tftproot;
+char *bootfile;
 };
 
+static inline int
+virNetworkDefProvidesNetboot(const virNetworkDefPtr def)
+{
+return def-tftproot  def-bootfile;
+}
+
 typedef struct _virNetworkObj virNetworkObj;
 typedef virNetworkObj *virNetworkObjPtr;
 struct _virNetworkObj {
diff --git a/src/network_driver.c b/src/network_driver.c
index 49855bf..cf462f2 100644
--- a/src/network_driver.c
+++ b/src/network_driver.c
@@ -400,6 +400,8 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
 (2 * network-def-nranges) + /* --dhcp-range 10.0.0.2,10.0.0.254 */
 /*  --dhcp-host 01:23:45:67:89:0a,hostname,10.0.0.3 */
 (2 * network-def-nhosts) +
+/* --enable-tftp