Re: [libvirt] Man page patch for BZ 548485

2010-01-14 Thread Matthias Bolte
2010/1/14 David Jorm dj...@redhat.com:
 See https://bugzilla.redhat.com/show_bug.cgi?id=548485

 git diff for the patch:

 ---SNIP---

 --- a/tools/virsh.pod
 +++ b/tools/virsh.pod
 @@ -342,7 +342,9 @@ severed upon restore, as TCP timeouts may have expired.

  =item Bschedinfo optional I--weight Bnumber optional I--cap 
 Bnumber Idomain-id

 -Allows to show (and set) the domain scheduler parameters.
 +Allows you to show (and set) the domain scheduler parameters.
 +
 +BNote: The only parameter currently available for all schedulers is 
 cpu_shares. It has a valid value range of 0-262144.

  BNote: The weight and cap parameters are defined only for the
  XEN_CREDIT scheduler and are now IDEPRECATED.

 ---SNIP---

 I hope that's right, I found that BZ a bit confusing to comprehend. Learning 
 curve.

 David


NACK.

cpu_shares is not available for all schedulers. The set of available
parameters and their valid ranges depends on the hypervisor:

LXC: type = posix, params = cpu_shares
Xen: type = credit, params = weight, cap
ESX: type = allocation, params = reservation, limit, shares
QEMU/KVM: type = posix, params = cpu_shares

Yes, documenting this properly isn't a simple task.

People complain about bad error messages In the bug report. They are
right, the error messages should be improved.

Matthias

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

Re: [libvirt] Man page patch for BZ 548485

2010-01-14 Thread David Jorm
Understood, I will re-implement and re-submit my patch tomorrow. Thanks for the 
info - this kind of detail in the BZ itself would be very useful for me. My job 
is just to document, i'm not a subject matter expert by any stretch.

- Original Message -
From: Matthias Bolte matthias.bo...@googlemail.com
To: David Jorm dj...@redhat.com
Cc: libvir-list@redhat.com
Sent: Thursday, January 14, 2010 8:02:39 PM GMT +10:00 Brisbane
Subject: Re: [libvirt] Man page patch for BZ 548485

2010/1/14 David Jorm dj...@redhat.com:
 See https://bugzilla.redhat.com/show_bug.cgi?id=548485

 git diff for the patch:

 ---SNIP---

 --- a/tools/virsh.pod
 +++ b/tools/virsh.pod
 @@ -342,7 +342,9 @@ severed upon restore, as TCP timeouts may have expired.

  =item Bschedinfo optional I--weight Bnumber optional I--cap 
 Bnumber Idomain-id

 -Allows to show (and set) the domain scheduler parameters.
 +Allows you to show (and set) the domain scheduler parameters.
 +
 +BNote: The only parameter currently available for all schedulers is 
 cpu_shares. It has a valid value range of 0-262144.

  BNote: The weight and cap parameters are defined only for the
  XEN_CREDIT scheduler and are now IDEPRECATED.

 ---SNIP---

 I hope that's right, I found that BZ a bit confusing to comprehend. Learning 
 curve.

 David


NACK.

cpu_shares is not available for all schedulers. The set of available
parameters and their valid ranges depends on the hypervisor:

LXC: type = posix, params = cpu_shares
Xen: type = credit, params = weight, cap
ESX: type = allocation, params = reservation, limit, shares
QEMU/KVM: type = posix, params = cpu_shares

Yes, documenting this properly isn't a simple task.

People complain about bad error messages In the bug report. They are
right, the error messages should be improved.

Matthias

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

Re: [libvirt] Set MAC address for host virtual interface?

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 08:25:47PM -0600, Neil Aggarwal wrote:
 Hello:
 
 Is there a way to set the MAC address for the virtual
 interface on the host?
 
 I have this in my guests's XML file:
interface type='bridge'
  mac address='54:52:00:7d:f8:fc'/
  source bridge='br0'/
  target dev='tkl-joomla'/
/interface
 
 the mac address line controls the guest interface
 but the host interface seems to get a random MAC
 address.

At some time in the past we did set the MAC address on the host interface
too, but it caused networking problems in some configurations so we stopped
doing that.

 This is causing a problem for me since I use Cacti
 to monitor the bandwidth usage of the guest machines.
 Every time I stop and start a guest, Cacti creates a
 new interface and I have to reset the graphs to use
 the new interfaces.

I guess you have Cacti configured to pull stats directly from the TAP
devices on the host ?Cacti has the ability to run scripts to pull
in statistics, so my recommendation would be to add a shell script which
calls the 'domifstat' command in virsh 

   virsh domifstat DOMNAME TAPDEVNAME

Or alternatively a python script which uses the libvirt python API to
get the ifstats from libvirt's API for that. That way you would not be
susceptible to changes in the TAP device setup on the host

There have already been plugins contributed to the Munin, Nagious and
CollectD projects todo exactly this, so it is natural that the same
be done for Cacti

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] Fix event-test segfault for mixed remote/local driver usage

2010-01-14 Thread Daniel P. Berrange
On Thu, Jan 14, 2010 at 03:19:06AM +0100, Matthias Bolte wrote:
 If examples/domain-events/events-c/event-test.c uses a local driver
 for the hyperviror and a remote driver for storage then the segfault
 occurs in remoteDomainEventDispatchFunc because conn-privateData is
 used.
 
 The problem is as follows. The doRemoteOpen function registers
 remoteDomainEventFired as event handle and remoteDomainEventQueueFlush
 as event timeout. The doRemoteOpen function is used in remoteOpen and
 remoteOpenSecondaryDriver. So both handlers are registered for all
 types of remote drivers, but remoteDomainEventQueueFlush always uses
 conn-privateData. That's wrong when remoteDomainEventQueueFlush is
 called for any other driver than the hypervisor driver, it should use
 conn-storagePrivateData for the storage driver for example.
 
 In the common case this doesn't result in a segfault because in the
 common case all drivers for a connection are either all remote or all
 local and conn-privateData and conn-storagePrivateData are the same.
 But in the local Xen case ('event-test xen:///' executed in Domain-0,
 with a libvirtd running in Domain-0) the hypervisor driver is local
 and the storage driver is remote. This results in a mismatch between
 conn-privateData and conn-storagePrivateData. Now the call to
 remoteDomainEventQueueFlush in the context of the storage driver
 results in a segfault, because it assumes that conn-privateData points
 to remote driver private data, but it points to Xen driver private
 data.

The big unanswered question here is why is the remote driver receiving
any events at all in the first place ?  Only the domain APIs emit 
events, and so those will all be coming out via the primary Xen driver.
So even if the xen:/// URI driver uses the remote driver a secondary
driver, it should never be receiving any events.

 
 To fix this, the pointer to the private driver data gets passed as
 opaque parameter instead of the connection pointer. Because some
 functions called by the event handler functions need the connection
 pointer for other purposes than error reporting the connection
 pointer is passed as member of the private remote driver data struct.
 
 Now remoteDomainEventFired and remoteDomainEventQueueFlush have the
 correct private data pointer for the respective calling context.

My inclination would be to skip registering the timer for the
remoteDomainEventQueueFlush method. Then inthe code which recieves
events, explicitly throw them away if eventFlushTimer == -1, and
log a warning message about unexpected events.

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] Fix linkage of virt-aa-helper to libgnu.a

2010-01-14 Thread Daniel P. Berrange
On Thu, Jan 14, 2010 at 03:08:32AM +0100, Matthias Bolte wrote:
 ---
  src/Makefile.am |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/src/Makefile.am b/src/Makefile.am
 index dbf708b..324030b 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -876,9 +876,9 @@ virt_aa_helper_LDFLAGS = $(WARN_CFLAGS)
  virt_aa_helper_LDADD =   \
   $(WARN_CFLAGS)  \
   $(LIBXML_LIBS)  \
 - @top_srcdir@/gnulib/lib/libgnu.la   \
   @top_srcdir@/src/libvirt_conf.la\
 - @top_srcdir@/src/libvirt_util.la
 + @top_srcdir@/src/libvirt_util.la\
 + @top_srcdir@/gnulib/lib/libgnu.la
  virt_aa_helper_CFLAGS =  \
   -...@top_srcdir@/src/conf   \
   -...@top_srcdir@/src/security
 -- 

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] util: Make sure virExec hook failures are raised

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:07PM -0500, Cole Robinson wrote:
 With the introduction virDispatchError, hook function errors are
 never sent through the error callback, so users will never see
 these messages.
 
 Fix this by calling virDispatchError after hook failure.
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  src/util/util.c |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)
 
 diff --git a/src/util/util.c b/src/util/util.c
 index ba6b0db..45ca657 100644
 --- a/src/util/util.c
 +++ b/src/util/util.c
 @@ -557,8 +557,11 @@ __virExec(virConnectPtr conn,
  }
  
  if (hook)
 -if ((hook)(data) != 0)
 +if ((hook)(data) != 0) {
 +VIR_DEBUG0(Hook function failed.);
 +virDispatchError(NULL);
  _exit(1);
 +}
  
  /* The steps above may need todo something privileged, so
   * we delay clearing capabilities until the last minute */
 -- 

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] qemu: Check for ia64 kvm

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:06PM -0500, Cole Robinson wrote:
 From: Dustin Xiong x_k_...@hotmail.com
 
 Ported to current code. Untested, but builds fine.
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  src/qemu/qemu_conf.c |7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index d3da776..0d970d6 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -373,12 +373,19 @@ static const struct qemu_feature_flags const 
 arch_info_x86_64_flags [] = {
  { apic, 1, 0 },
  };
  
 +static const struct qemu_feature_flags const arch_info_ia64_flags [] = {
 +{ acpi, 1, 1 },
 +{ apic, 1, 0 },
 +};

Hmmm, I'm not sure that those flags make sense on ia64 do they ? Perhaps
someone more knowledgable can confirm, but I thought they were x86 concepts

 +
  /* The archicture tables for supported QEMU archs */
  static const struct qemu_arch_info const arch_info_hvm[] = {
  {  i686,   32, NULL, /usr/bin/qemu,
 /usr/bin/qemu-system-x86_64, arch_info_i686_flags, 4 },
  {  x86_64, 64, NULL, /usr/bin/qemu-system-x86_64,
 NULL, arch_info_x86_64_flags, 2 },
 +{  itanium, 64, NULL, /usr/bin/qemu-system-ia64,
 +   NULL, arch_info_ia64_flags, 2},
  {  arm,32, NULL, /usr/bin/qemu-system-arm,NULL, NULL, 0 },
  {  mips,   32, NULL, /usr/bin/qemu-system-mips,   NULL, NULL, 0 },
  {  mipsel, 32, NULL, /usr/bin/qemu-system-mipsel, NULL, NULL, 0 },



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 v2] Implement path lookup for USB by vendor:product

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:05PM -0500, Cole Robinson wrote:
 Based off how QEMU does it, look through /sys/bus/usb/devices/* for
 matching vendor:product info, and if found, use info from the surrounding
 files to build the device's /dev/bus/usb path.
 
 This fixes USB device assignment by vendor:product when running qemu
 as non-root (well, it should, but for some reason I couldn't reproduce
 the failure people are seeing in [1], but it appears to work properly)
 
 [1] https://bugzilla.redhat.com/show_bug.cgi?id=542450
 
 v2:
 Drop 'bus.addr only' checks in security drivers
 Use various util helpers
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  po/POTFILES.in  |1 +
  src/qemu/qemu_driver.c  |9 +--
  src/security/security_selinux.c |   25 -
  src/security/virt-aa-helper.c   |   32 +--
  src/util/hostusb.c  |  110 +-
  src/util/hostusb.h  |4 +-
  6 files changed, 141 insertions(+), 40 deletions(-)
 
 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index c9c78b6..3b82a74 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -55,6 +55,7 @@ src/uml/uml_conf.c
  src/uml/uml_driver.c
  src/util/bridge.c
  src/util/conf.c
 +src/util/hostusb.c
  src/util/json.c
  src/util/logging.c
  src/util/pci.c
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index deb8adc..f03ce91 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -2105,14 +2105,11 @@ static int 
 qemuDomainSetHostdevUSBOwnership(virConnectPtr conn,
  struct qemuFileOwner owner = { uid, gid };
  int ret = -1;
  
 -/* XXX what todo for USB devs assigned based on product/vendor ? Doom 
 :-( */
 -if (!def-source.subsys.u.usb.bus ||
 -!def-source.subsys.u.usb.device)
 -return 0;
 -
  usbDevice *dev = usbGetDevice(conn,
def-source.subsys.u.usb.bus,
 -  def-source.subsys.u.usb.device);
 +  def-source.subsys.u.usb.device,
 +  def-source.subsys.u.usb.vendor,
 +  def-source.subsys.u.usb.product);
  
  if (!dev)
  goto cleanup;
 diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
 index 000bc8a..cb585ed 100644
 --- a/src/security/security_selinux.c
 +++ b/src/security/security_selinux.c
 @@ -481,20 +481,17 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn,
  
  switch (dev-source.subsys.type) {
  case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
 -if (dev-source.subsys.u.usb.bus  dev-source.subsys.u.usb.device) 
 {
 -usbDevice *usb = usbGetDevice(conn,
 -  dev-source.subsys.u.usb.bus,
 -  dev-source.subsys.u.usb.device);
 +usbDevice *usb = usbGetDevice(conn,
 +  dev-source.subsys.u.usb.bus,
 +  dev-source.subsys.u.usb.device,
 +  dev-source.subsys.u.usb.vendor,
 +  dev-source.subsys.u.usb.product);
  
 -if (!usb)
 -goto done;
 +if (!usb)
 +goto done;
  
 -ret = usbDeviceFileIterate(conn, usb, 
 SELinuxSetSecurityUSBLabel, vm);
 -usbFreeDevice(conn, usb);
 -} else {
 -/* XXX deal with product/vendor better */
 -ret = 0;
 -}
 +ret = usbDeviceFileIterate(conn, usb, SELinuxSetSecurityUSBLabel, 
 vm);
 +usbFreeDevice(conn, usb);
  break;
  }
  
 @@ -556,7 +553,9 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn,
  case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
  usbDevice *usb = usbGetDevice(conn,
dev-source.subsys.u.usb.bus,
 -  dev-source.subsys.u.usb.device);
 +  dev-source.subsys.u.usb.device,
 +  dev-source.subsys.u.usb.vendor,
 +  dev-source.subsys.u.usb.product);
  
  if (!usb)
  goto done;
 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
 index 35b29ad..3c8b49a 100644
 --- a/src/security/virt-aa-helper.c
 +++ b/src/security/virt-aa-helper.c
 @@ -836,24 +836,22 @@ get_files(vahControl * ctl)
  virDomainHostdevDefPtr dev = ctl-def-hostdevs[i];
  switch (dev-source.subsys.type) {
  case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
 -if (dev-source.subsys.u.usb.bus 
 -dev-source.subsys.u.usb.device) {
 -usbDevice *usb = usbGetDevice(NULL,
 -   dev-source.subsys.u.usb.bus,
 -   

Re: [libvirt] [PATCH] qemu: Check for ia64 kvm

2010-01-14 Thread Daniel P. Berrange
On Thu, Jan 14, 2010 at 09:33:39AM +0800, Dustin Xiong wrote:
 
 
  
 
  From: crobi...@redhat.com
  To: libvirt-l...@redhat.com
  CC: x_k_...@hotmail.com; crobi...@redhat.com
  Subject: [PATCH] qemu: Check for ia64 kvm
  Date: Wed, 13 Jan 2010 15:50:06 -0500
  
  From: Dustin Xiong x_k_...@hotmail.com
  
  Ported to current code. Untested, but builds fine.
  
  Signed-off-by: Cole Robinson crobi...@redhat.com
  ---
  src/qemu/qemu_conf.c | 7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)
  
  diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
  index d3da776..0d970d6 100644
  --- a/src/qemu/qemu_conf.c
  +++ b/src/qemu/qemu_conf.c
  @@ -373,12 +373,19 @@ static const struct qemu_feature_flags const 
  arch_info_x86_64_flags [] = {
  { apic, 1, 0 },
  };
  
  +static const struct qemu_feature_flags const arch_info_ia64_flags [] = {
  + { acpi, 1, 1 },
  + { apic, 1, 0 },
  +};
  +
  /* The archicture tables for supported QEMU archs */
  static const struct qemu_arch_info const arch_info_hvm[] = {
  { i686, 32, NULL, /usr/bin/qemu,
  /usr/bin/qemu-system-x86_64, arch_info_i686_flags, 4 },
  { x86_64, 64, NULL, /usr/bin/qemu-system-x86_64,
  NULL, arch_info_x86_64_flags, 2 },
  + { itanium, 64, NULL, /usr/bin/qemu-system-ia64,
  + NULL, arch_info_ia64_flags, 2},
  { arm, 32, NULL, /usr/bin/qemu-system-arm, NULL, NULL, 0 },
  { mips, 32, NULL, /usr/bin/qemu-system-mips, NULL, NULL, 0 },
  { mipsel, 32, NULL, /usr/bin/qemu-system-mipsel, NULL, NULL, 0 },
  -- 
  1.6.5.2
  
 
 
 There another problem when you make the libvirt src on the arch of itanium, 
 you need modify the function clone().
 
On IA-64, a different system call is used:
 
int __clone2(int (*fn)(void *),  void *child_stack_base,
 size_t stack_size, int flags, void *arg, ...
 /* pid_t *pid, struct user_desc *tls, pid_t *ctid */ );
 
The  __clone2() system call operates in the same way as clone(), except
that child_stack_base points to the lowest address of the child's stack
area,  and  stack_size  specifies  the  size of the stack pointed to by
child_stack_base.
 
 
 The function clone() is used in /src/lxc_container.c.

Thanks for the info.  FYI, you can work around it with --without-lxc to disable
build of the LXC driver

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

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


Re: [libvirt] [PATCH] events: Report errors on failure

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:02PM -0500, Cole Robinson wrote:
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  po/POTFILES.in  |1 +
  src/conf/domain_event.c |   36 +---
  2 files changed, 30 insertions(+), 7 deletions(-)
 
 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index 1ab0859..c9c78b6 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -4,6 +4,7 @@ daemon/remote.c
  daemon/stream.c
  src/conf/cpu_conf.c
  src/conf/domain_conf.c
 +src/conf/domain_event.c
  src/conf/interface_conf.c
  src/conf/network_conf.c
  src/conf/node_device_conf.c
 diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
 index 0fa2822..72f499c 100644
 --- a/src/conf/domain_event.c
 +++ b/src/conf/domain_event.c
 @@ -26,6 +26,13 @@
  #include logging.h
  #include datatypes.h
  #include memory.h
 +#include virterror_internal.h
 +
 +#define VIR_FROM_THIS VIR_FROM_NONE
 +
 +#define eventReportError(conn, code, fmt...)\
 +virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__,   \
 + __FUNCTION__, __LINE__, fmt)
  
  
  /**
 @@ -87,6 +94,9 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
  return 0;
  }
  }
 +
 +eventReportError(conn, VIR_ERR_INTERNAL_ERROR, %s,
 + _(could not find event callback for removal));
  return -1;
  }
  
 @@ -140,6 +150,9 @@ int virDomainEventCallbackListMarkDelete(virConnectPtr 
 conn,
  return 0;
  }
  }
 +
 +eventReportError(conn, VIR_ERR_INTERNAL_ERROR, %s,
 + _(could not find event callback for deletion));
  return -1;
  }
  
 @@ -199,13 +212,14 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
  for (n=0; n  cbList-count; n++) {
  if(cbList-callbacks[n]-cb == callback 
 conn == cbList-callbacks[n]-conn) {
 -DEBUG0(WARNING: Callback already tracked);
 +eventReportError(conn, VIR_ERR_INTERNAL_ERROR, %s,
 + _(event callback already tracked));
  return -1;
  }
  }
  /* Allocate new event */
  if (VIR_ALLOC(event)  0) {
 -DEBUG0(Error allocating event);
 +virReportOOMError(conn);
  return -1;
  }
  event-conn = conn;
 @@ -216,7 +230,7 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
  /* Make space on list */
  n = cbList-count;
  if (VIR_REALLOC_N(cbList-callbacks, n + 1)  0) {
 -DEBUG0(Error reallocating list);
 +virReportOOMError(conn);
  VIR_FREE(event);
  return -1;
  }
 @@ -242,8 +256,10 @@ virDomainEventQueuePtr virDomainEventQueueNew(void)
  {
  virDomainEventQueuePtr ret;
  
 -if (VIR_ALLOC(ret)  0)
 +if (VIR_ALLOC(ret)  0) {
 +virReportOOMError(NULL);
  return NULL;
 +}
  
  return ret;
  }
 @@ -254,12 +270,15 @@ virDomainEventPtr virDomainEventNew(int id, const char 
 *name,
  {
  virDomainEventPtr event;
  
 -if (VIR_ALLOC(event)  0)
 +if (VIR_ALLOC(event)  0) {
 +virReportOOMError(NULL);
  return NULL;
 +}
  
  event-type = type;
  event-detail = detail;
  if (!(event-name = strdup(name))) {
 +virReportOOMError(NULL);
  VIR_FREE(event);
  return NULL;
  }
 @@ -318,8 +337,11 @@ virDomainEventQueuePop(virDomainEventQueuePtr evtQueue)
  {
  virDomainEventPtr ret;
  
 -if(!evtQueue || evtQueue-count == 0 )
 +if (!evtQueue || evtQueue-count == 0 ) {
 +eventReportError(NULL, VIR_ERR_INTERNAL_ERROR, %s,
 + _(event queue is empty, nothing to pop));
  return NULL;
 +}
  
  ret = evtQueue-events[0];
  
 @@ -357,7 +379,7 @@ virDomainEventQueuePush(virDomainEventQueuePtr evtQueue,
  /* Make space on queue */
  if (VIR_REALLOC_N(evtQueue-events,
evtQueue-count + 1)  0) {
 -DEBUG0(Error reallocating queue);
 +virReportOOMError(NULL);
  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] daemon: Don't blindly unregister domain events

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:04PM -0500, Cole Robinson wrote:
 The daemon will attempt to unregister domain events on client disconnect,
 even if no events were ever registered. This raises an unneeded error.
 
 Track in the qemu_client structure if events have been registered, and
 check this when performing cleanup.
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  daemon/libvirtd.c |2 +-
  daemon/libvirtd.h |1 +
  daemon/remote.c   |4 
  3 files changed, 6 insertions(+), 1 deletions(-)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index c53ef0a..61a9728 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -1447,7 +1447,7 @@ void qemudDispatchClientFailure(struct qemud_client 
 *client) {
  }
  
  /* Deregister event delivery callback */
 -if(client-conn) {
 +if (client-conn  client-domain_events_registered) {
  DEBUG0(Deregistering to relay remote events);
  virConnectDomainEventDeregister(client-conn, 
 remoteRelayDomainEvent);
  }
 diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
 index e3624c6..2f647f3 100644
 --- a/daemon/libvirtd.h
 +++ b/daemon/libvirtd.h
 @@ -177,6 +177,7 @@ struct qemud_client {
  int watch;
  int readonly:1;
  int closing:1;
 +int domain_events_registered:1;
  
  struct sockaddr_storage addr;
  socklen_t addrlen;
 diff --git a/daemon/remote.c b/daemon/remote.c
 index 41b9974..e39d6d1 100644
 --- a/daemon/remote.c
 +++ b/daemon/remote.c
 @@ -4775,6 +4775,8 @@ remoteDispatchDomainEventsRegister (struct qemud_server 
 *server ATTRIBUTE_UNUSED
  
  if (ret)
  ret-cb_registered = 1;
 +
 +client-domain_events_registered = 1;
  return 0;
  }
  
 @@ -4796,6 +4798,8 @@ remoteDispatchDomainEventsDeregister (struct 
 qemud_server *server ATTRIBUTE_UNUS
  
  if (ret)
  ret-cb_registered = 0;
 +
 +client-domain_events_registered = 0;
  return 0;
  }
  

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] daemon: Fix various error reporting issues

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 03:50:03PM -0500, Cole Robinson wrote:
 Many node device calls weren't properly relaying error messages, and
 domain event registeration was not checking for error.
 
 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
  daemon/remote.c |   38 +-
  1 files changed, 21 insertions(+), 17 deletions(-)
 
 diff --git a/daemon/remote.c b/daemon/remote.c
 index 0b30131..41b9974 100644
 --- a/daemon/remote.c
 +++ b/daemon/remote.c
 @@ -231,7 +231,7 @@ remoteDispatchGetType (struct qemud_server *server 
 ATTRIBUTE_UNUSED,
   */
  ret-type = strdup (type);
  if (!ret-type) {
 -remoteDispatchFormatError (rerr, %s, _(out of memory in strdup));
 +remoteDispatchOOMError(rerr);
  return -1;
  }
  
 @@ -4489,7 +4489,7 @@ remoteDispatchNodeDeviceDumpXml (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4520,7 +4520,7 @@ remoteDispatchNodeDeviceGetParent (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4562,7 +4562,7 @@ remoteDispatchNodeDeviceNumOfCaps (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4591,7 +4591,7 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4634,7 +4634,7 @@ remoteDispatchNodeDeviceDettach (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4661,7 +4661,7 @@ remoteDispatchNodeDeviceReAttach (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4688,7 +4688,7 @@ remoteDispatchNodeDeviceReset (struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4738,7 +4738,7 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server 
 *server ATTRIBUTE_UNUSED,
  
  dev = virNodeDeviceLookupByName(conn, args-name);
  if (dev == NULL) {
 -remoteDispatchFormatError(rerr, %s, _(node_device not found));
 +remoteDispatchConnError(rerr, conn);
  return -1;
  }
  
 @@ -4766,11 +4766,14 @@ remoteDispatchDomainEventsRegister (struct 
 qemud_server *server ATTRIBUTE_UNUSED
  {
  CHECK_CONN(client);
  
 -/* Register event delivery callback */
 -REMOTE_DEBUG(%s,Registering to relay remote events);
 -virConnectDomainEventRegister(conn, remoteRelayDomainEvent, client, 
 NULL);
 +if (virConnectDomainEventRegister(conn,
 +  remoteRelayDomainEvent,
 +  client, NULL)  0) {
 +remoteDispatchConnError(rerr, conn);
 +return -1;
 +}
  
 -if(ret)
 +if (ret)
  ret-cb_registered = 1;
  return 0;
  }
 @@ -4786,11 +4789,12 @@ remoteDispatchDomainEventsDeregister (struct 
 qemud_server *server ATTRIBUTE_UNUS
  {
  CHECK_CONN(client);
  
 -/* Deregister event delivery callback */
 -REMOTE_DEBUG(%s,Deregistering to relay remote events);
 -virConnectDomainEventDeregister(conn, remoteRelayDomainEvent);
 +if (virConnectDomainEventDeregister(conn, remoteRelayDomainEvent)  0) {
 +remoteDispatchConnError(rerr, conn);
 +return -1;
 +}
  
 -if(ret)
 +if (ret)
  ret-cb_registered = 0;
  return 0;
  }
 -- 

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/ :|
|: 

Re: [libvirt] [PATCH] Enhance qemuParseCommandLineKeywords

2010-01-14 Thread Daniel P. Berrange
On Wed, Jan 13, 2010 at 04:48:30PM +0100, Jiri Denemark wrote:
 Current version expects name=value,... list and when an incorrect string
 such as a,b,c=d would be parsed as a,b,c keyword with d value
 without reporting any error, which is probably not the expected
 behavior.
 
 This patch adds an extra argument called allowEmptyValue, which if
 non-zero will permit keywords with no value; a,b=c,,d= will be parsed
 as follows:
 keyword value
 a NULL
 b c
   NULL
 d 
 
 In case allowEmptyValue is zero, the string is required to contain
 name=value pairs only; retvalues is guaranteed to contain non-NULL
 pointers. Now, a,b,c=d will result in an error.
 
 Signed-off-by: Jiri Denemark jdene...@redhat.com
 ---
  src/qemu/qemu_conf.c |   51 ++---
  1 files changed, 31 insertions(+), 20 deletions(-)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index d3da776..9f35217 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -3066,47 +3066,58 @@ static const char *qemuFindEnv(const char **progenv,
  /*
   * Takes a string containing a set of key=value,key=value,key...
   * parameters and splits them up, returning two arrays with
 - * the individual keys and values
 + * the individual keys and values. If allowEmptyValue is nonzero,
 + * the =value part is optional and if a key with no value is found,
 + * NULL is be placed into corresponding place in retvalues.
   */
  static int
  qemuParseCommandLineKeywords(virConnectPtr conn,
   const char *str,
   char ***retkeywords,
 - char ***retvalues)
 + char ***retvalues,
 + int allowEmptyValue)
  {
  int keywordCount = 0;
  int keywordAlloc = 0;
  char **keywords = NULL;
  char **values = NULL;
  const char *start = str;
 +const char *end;
  int i;
  
  *retkeywords = NULL;
  *retvalues = NULL;
 +end = start + strlen(str);
  
  while (start) {
  const char *separator;
  const char *endmark;
  char *keyword;
 -char *value;
 +char *value = NULL;
  
 -if (!(separator = strchr(start, '='))) {
 -qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 - _(malformed keyword arguments in '%s'), str);
 -goto error;
 +if (!(endmark = strchr(start, ',')))
 +endmark = end;
 +if (!(separator = strchr(start, '=')))
 +separator = end;
 +
 +if (separator = endmark) {
 +if (!allowEmptyValue) {
 +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + _(malformed keyword arguments in '%s'), 
 str);
 +goto error;
 +}
 +separator = endmark;
  }
 +
  if (!(keyword = strndup(start, separator - start)))
  goto no_memory;
  
 -separator++;
 -endmark = strchr(separator, ',');
 -
 -value = endmark ?
 -strndup(separator, endmark - separator) :
 -strdup(separator);
 -if (!value) {
 -VIR_FREE(keyword);
 -goto no_memory;
 +if (separator  endmark) {
 +separator++;
 +if (!(value = strndup(separator, endmark - separator))) {
 +VIR_FREE(keyword);
 +goto no_memory;
 +}
  }
  
  if (keywordAlloc == keywordCount) {
 @@ -3123,7 +3134,7 @@ qemuParseCommandLineKeywords(virConnectPtr conn,
  values[keywordCount] = value;
  keywordCount++;
  
 -start = endmark ? endmark + 1 : NULL;
 +start = endmark  end ? endmark + 1 : NULL;
  }
  
  *retkeywords = keywords;
 @@ -3163,7 +3174,7 @@ qemuParseCommandLineDisk(virConnectPtr conn,
  
  if ((nkeywords = qemuParseCommandLineKeywords(conn, val,
keywords,
 -  values))  0)
 +  values, 0))  0)
  return NULL;
  
  if (VIR_ALLOC(def)  0) {
 @@ -3347,7 +3358,7 @@ qemuParseCommandLineNet(virConnectPtr conn,
  if ((nkeywords = qemuParseCommandLineKeywords(conn,
tmp+1,
keywords,
 -  values))  0)
 +  values, 0))  0)
  return NULL;
  } else {
  nkeywords = 0;
 @@ -3420,7 +3431,7 @@ qemuParseCommandLineNet(virConnectPtr conn,
  if ((nkeywords = qemuParseCommandLineKeywords(conn,
nic + strlen(nic,),
  

Re: [libvirt] [PATCH 1/4] Support delay property in interface bridge xml.

2010-01-14 Thread Daniel P. Berrange
On Fri, Jan 01, 2010 at 08:40:23PM -0500, Laine Stump wrote:
 ---
  src/conf/interface_conf.c |   11 +++
  src/conf/interface_conf.h |1 +
  2 files changed, 8 insertions(+), 4 deletions(-)
 
 diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
 index 3c99027..ca82208 100644
 --- a/src/conf/interface_conf.c
 +++ b/src/conf/interface_conf.c
 @@ -801,6 +801,7 @@ virInterfaceDefParseXML(virConnectPtr conn, 
 xmlXPathContextPtr ctxt) {
  }
  VIR_FREE(tmp);
  }
 +def-data.bridge.delay = virXMLPropString(bridge, delay);
  ctxt-node = bridge;
  virInterfaceDefParseBridge(conn, def, ctxt);
  break;
 @@ -1038,12 +1039,14 @@ virInterfaceBridgeDefFormat(virConnectPtr conn, 
 virBufferPtr buf,
  int i;
  int ret = 0;
  
 +virBufferAddLit(buf,   bridge);
  if (def-data.bridge.stp == 1)
 -virBufferAddLit(buf,   bridge stp='on'\n);
 +virBufferAddLit(buf,  stp='on');
  else if (def-data.bridge.stp == 0)
 -virBufferAddLit(buf,   bridge stp='off'\n);
 -else
 -virBufferAddLit(buf,   bridge\n);
 +virBufferAddLit(buf,  stp='off');
 +if (def-data.bridge.delay != NULL)
 +virBufferVSprintf(buf,  delay='%s', def-data.bridge.delay);
 +virBufferAddLit(buf, \n);
  
  for (i = 0;i  def-data.bridge.nbItf;i++) {
  if (virInterfaceBareDevDefFormat(conn, buf, def-data.bridge.itf[i])
 diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
 index 2683eee..4216087 100644
 --- a/src/conf/interface_conf.h
 +++ b/src/conf/interface_conf.h
 @@ -97,6 +97,7 @@ typedef struct _virInterfaceBridgeDef virInterfaceBridgeDef;
  typedef virInterfaceBridgeDef *virInterfaceBridgeDefPtr;
  struct _virInterfaceBridgeDef {
  int stp; /* 0, 1 or -1 if undefined */
 +char *delay;
  int nbItf;   /* number of defined interfaces */
  virInterfaceBareDefPtr *itf;/* interfaces */
  };

ACK

Though, it'd be nice to convert this to an integer.

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] attach_device incompatibility between libvirt and qemu 0.12

2010-01-14 Thread Gerhard Stenzel
Hi, I have a small libvirt-tck test script, in which I create a domain
without a NIC, then use attach_device to add a NIC. And then I do a ping
test to the domain. This stopped working after updating to latest fedora
and libvirt levels. After some hours, I now discovered that downgrading
to qemu 0.11 fixes it. So there seems to be some incompatibility with
qemu 0.12 and latest libvirt.

The expected output with qemu-system-x86-0.11.0-12.fc12.x86_64:

/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t .. 
1..5
# Trying domain lookup by name
ok 1 - the running domain object
# Attaching the new interface d0:f:d0:f:2:1
ok 2 - interface has been attached
# xml contains mac address element (should be 1)
# 1
ok 3 - running domain has an ID  0
# waiting for guests to boot
# PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
# 64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=2.17 ms
# 64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.554 ms
# 64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.510 ms
# 64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=0.508 ms
# 64 bytes from 192.168.1.101: icmp_seq=5 ttl=64 time=0.505 ms
# 64 bytes from 192.168.1.101: icmp_seq=6 ttl=64 time=0.673 ms
# 64 bytes from 192.168.1.101: icmp_seq=7 ttl=64 time=0.528 ms
# 64 bytes from 192.168.1.101: icmp_seq=8 ttl=64 time=0.522 ms
# 64 bytes from 192.168.1.101: icmp_seq=9 ttl=64 time=0.506 ms
# 64 bytes from 192.168.1.101: icmp_seq=10 ttl=64 time=0.546 ms
# 
# --- 192.168.1.101 ping statistics ---
# 10 packets transmitted, 10 received, 0% pacFor the working I see the
following lines in the log:
ket loss, time 9002ms
# rtt min/avg/max/mdev = 0.505/0.703/2.178/0.493 ms
ok 4 - ping 192.168.1.101 test
# cleaning up
# Detaching the 1st interface d0:f:d0:f:2:1
ok 5 - interface has been detached
ok
All tests successful.
Files=1, Tests=5, 20 wallclock secs ( 0.02 usr  0.01 sys +  0.22 cusr
0.15 csys =  0.40 CPU)
Result: PASS

The failing output with qemu-system-x86-0.11.0-12.fc12.x86_64:

/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t .. 
1..5
# Trying domain lookup by name
ok 1 - the running domain object
# Attaching the new interface d0:f:d0:f:2:1
ok 2 - interface has been attached
# xml contains mac address element (should be 1)
# 1
ok 3 - running domain has an ID  0
# waiting for guests to boot
# PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
# From 192.168.1.1 icmp_seq=2 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=3 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=4 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=6 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=7 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=8 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=9 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=10 Destination Host Unreachable
# 
# --- 192.168.1.101 ping statistics ---
# 10 packets transmitted, 0 received, +8 errors, 100% packet loss, time
19000ms
# pipe 3
not ok 4 - ping 192.168.1.101 test

#   Failed test 'ping 192.168.1.101 test'
#
at /usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t
line 82.
# cleaning up
# Detaching the 1st interface d0:f:d0:f:2:1
ok 5 - interface has been detached
# Looks like you failed 1 test of 5.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests 

Test Summary Report
---
/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t
(Wstat: 256 Tests: 5 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
Files=1, Tests=5, 30 wallclock secs ( 0.02 usr  0.02 sys +  0.24 cusr
0.13 csys =  0.41 CPU)
Result: FAIL


I see the following in the debug log:

...
qemuMonitorCommandWithHandler:216 : Send command 'getfd fd-tap.0' for
write with FD 18
...

For the working qemu:
qemuMonitorCommandWithHandler:221 : Receive command reply ret=0 errno=0
0 bytes '(null)'

For the failing qemu:
qemuMonitorCommandWithHandler:221 : Receive command reply ret=0 errno=0
44 bytes 'No file descriptor supplied via SCM_RIGHTS^M
'

Any ideas?

-- 
Best regards, 

Gerhard Stenzel, 
---
IBM Deutschland Research  Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
# -*- perl -*-
#
# Copyright (C) 2010 IBM Corp.
#
# This program is free software; You can redistribute it and/or modify
# it under the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any
# later version
#
# The file LICENSE distributed along with this file provides full
# details of the terms and conditions
#

=pod

=head1 NAME

domain/100-ping-still-working.t - verify machines can be pinged from host

=head1 DESCRIPTION

The test case validates that it is possible to 

Re: [libvirt] [PATCH 2/4] Allow empty bridges in interface xml.

2010-01-14 Thread Daniel P. Berrange
On Fri, Jan 01, 2010 at 08:40:24PM -0500, Laine Stump wrote:
 ---
  src/conf/interface_conf.c |   32 +---
  1 files changed, 17 insertions(+), 15 deletions(-)
 
 diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
 index ca82208..d7821e7 100644
 --- a/src/conf/interface_conf.c
 +++ b/src/conf/interface_conf.c
 @@ -557,28 +557,30 @@ virInterfaceDefParseBridge(virConnectPtr conn, 
 virInterfaceDefPtr def,
  
  bridge = ctxt-node;
  nbItf = virXPathNodeSet(conn, ./interface, ctxt, interfaces);
 -if (nbItf = 0) {
 +if (nbItf  0) {
  virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
 -%s, _(bridge has no interfaces));
 +%s, _(bridge interfaces));
  ret = -1;
  goto error;
  }
 -if (VIR_ALLOC_N(def-data.bridge.itf, nbItf)  0) {
 -virReportOOMError(conn);
 -ret = -1;
 -goto error;
 -}
 -def-data.bridge.nbItf = nbItf;
 -
 -for (i = 0; i  nbItf;i++) {
 -ctxt-node = interfaces[i];
 -itf = virInterfaceDefParseBareInterface(conn, ctxt, 0);
 -if (itf == NULL) {
 +if (nbItf  0) {
 +if (VIR_ALLOC_N(def-data.bridge.itf, nbItf)  0) {
 +virReportOOMError(conn);
  ret = -1;
 -def-data.bridge.nbItf = i;
  goto error;
  }
 -def-data.bridge.itf[i] = itf;
 +def-data.bridge.nbItf = nbItf;
 +
 +for (i = 0; i  nbItf;i++) {
 +ctxt-node = interfaces[i];
 +itf = virInterfaceDefParseBareInterface(conn, ctxt, 0);
 +if (itf == NULL) {
 +ret = -1;
 +def-data.bridge.nbItf = i;
 +goto error;
 +}
 +def-data.bridge.itf[i] = itf;
 +}
  }
  
  error:

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 3/4] Support bond interfaces attached to bridges in interface xml.

2010-01-14 Thread Daniel P. Berrange
On Fri, Jan 01, 2010 at 08:40:25PM -0500, Laine Stump wrote:
 This was accomplished in xml parsing by doing away with the
 stripped-down virInterfaceBareDef object, and just always using
 virInterfaceDef, but with restrictions in certain places (eg, the type
 of subordinate interface allowed in parsing depends on the parent
 interface).
 
 xml formatting was similarly adjusted. In addition, the formatting
 functions keep track of the level of interface nesting, and insert
 extra leading spaces on each line accordingly (using %*s).

Ohh, i didn't know about %*s

 
 The only change in formatted xml from previous (aside frmo supporting
 new combinations of interface types) is that the subordinate ethernet
 interfaces take up 2 lines rather than one, eg:
 
interface type='ethernet' name='eth0'
/interface
 
 instead of:
 
interface type='ethernet' name='eth0'/
 ---
  src/conf/interface_conf.c |  362 
 +++--
  src/conf/interface_conf.h |   13 +--
  2 files changed, 156 insertions(+), 219 deletions(-)
 
 diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
 index d7821e7..6efc8aa 100644
 --- a/src/conf/interface_conf.c
 +++ b/src/conf/interface_conf.c
 @@ -39,21 +39,18 @@ VIR_ENUM_IMPL(virInterface,
VIR_INTERFACE_TYPE_LAST,
ethernet, bridge, bond, vlan )
  
 +static virInterfaceDefPtr
 +virInterfaceDefParseXML(virConnectPtr conn,
 +xmlXPathContextPtr ctxt, int parentIfType);
 +static int
 +virInterfaceDefDevFormat(virConnectPtr conn, virBufferPtr buf,
 + const virInterfaceDefPtr def, int level);
 +
  #define virInterfaceReportError(conn, code, fmt...)  
   \
  virReportErrorHelper(conn, VIR_FROM_INTERFACE, code, __FILE__,   
 \
 __FUNCTION__, __LINE__, fmt)
  
  static
 -void virInterfaceBareDefFree(virInterfaceBareDefPtr def) {
 -if (def == NULL)
 -return;
 -VIR_FREE(def-name);
 -VIR_FREE(def-mac_or_tag);
 -VIR_FREE(def-devname);
 -VIR_FREE(def);
 -}
 -
 -static
  void virInterfaceIpDefFree(virInterfaceIpDefPtr def) {
  if (def == NULL)
  return;
 @@ -90,7 +87,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
  case VIR_INTERFACE_TYPE_BRIDGE:
  for (i = 0;i  def-data.bridge.nbItf;i++) {
  if (def-data.bridge.itf[i] != NULL)
 -virInterfaceBareDefFree(def-data.bridge.itf[i]);
 +virInterfaceDefFree(def-data.bridge.itf[i]);
  else
  break; /* to cope with half parsed data on errors */
  }
 @@ -100,7 +97,7 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
  VIR_FREE(def-data.bond.target);
  for (i = 0;i  def-data.bond.nbItf;i++) {
  if (def-data.bond.itf[i] != NULL)
 -virInterfaceBareDefFree(def-data.bond.itf[i]);
 +virInterfaceDefFree(def-data.bond.itf[i]);
  else
  break; /* to cope with half parsed data on errors */
  }
 @@ -121,11 +118,9 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
  }
  
  static int
 -virInterfaceDefParseBasicAttrs(virConnectPtr conn, virInterfaceDefPtr def,
 -   xmlXPathContextPtr ctxt) {
 +virInterfaceDefParseName(virConnectPtr conn, virInterfaceDefPtr def,
 + xmlXPathContextPtr ctxt) {
  char *tmp;
 -unsigned long mtu;
 -int ret;
  
  tmp = virXPathString(conn, string(./@name), ctxt);
  if (tmp == NULL) {
 @@ -134,6 +129,14 @@ virInterfaceDefParseBasicAttrs(virConnectPtr conn, 
 virInterfaceDefPtr def,
  return(-1);
  }
  def-name = tmp;
 +return(0);
 +}
 +
 +static int
 +virInterfaceDefParseMtu(virConnectPtr conn, virInterfaceDefPtr def,
 +xmlXPathContextPtr ctxt) {
 +unsigned long mtu;
 +int ret;
  
  ret = virXPathULong(conn, string(./mtu/@size), ctxt, mtu);
  if ((ret == -2) || ((ret == 0)  (mtu  10))) {
 @@ -478,80 +481,12 @@ error:
  
  }
  
 -static virInterfaceBareDefPtr
 -virInterfaceDefParseBareInterface(virConnectPtr conn, xmlXPathContextPtr 
 ctxt,
 -  int ethernet_only) {
 -int t;
 -char *name = NULL;
 -char *type = NULL;
 -char *mac_or_tag = NULL;
 -char *devname = NULL;
 -virInterfaceBareDefPtr ret = NULL;
 -
 -type = virXPathString(conn, string(./@type), ctxt);
 -if (type == NULL) {
 -virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
 -%s, _(interface has no type));
 -goto error;
 -}
 -if (STREQ(type, ethernet)) {
 -t = VIR_INTERFACE_TYPE_ETHERNET;
 -name = virXPathString(conn, string(./@name), ctxt);
 -mac_or_tag = virXPathString(conn, string(./mac/@address), ctxt);
 -} else if ((STREQ(type, 

Re: [libvirt] [PATCH 4/4] Update interface.rng and xml test files to match netcf 0.1.5

2010-01-14 Thread Daniel P. Berrange
On Fri, Jan 01, 2010 at 08:40:26PM -0500, Laine Stump wrote:
 The RNG now supports IPv6 and bonds attached to bridges, along with
 some other minor tweaks. All test files from netcf have been copied to
 the test directory and added to the xml2xml and schema tests (and they
 all pass, of course ;-)
 ---
  docs/schemas/interface.rng   |  316 
 ++
  tests/interfaceschemadata/bond-arp.xml   |6 +-
  tests/interfaceschemadata/bond.xml   |6 +-
  tests/interfaceschemadata/bridge-bond.xml|   17 ++
  tests/interfaceschemadata/bridge-empty.xml   |6 +
  tests/interfaceschemadata/bridge-no-address.xml  |3 +-
  tests/interfaceschemadata/bridge-vlan.xml|2 +-
  tests/interfaceschemadata/bridge.xml |5 +-
  tests/interfaceschemadata/bridge42.xml   |3 +-
  tests/interfaceschemadata/ipv6-autoconf-dhcp.xml |7 +
  tests/interfaceschemadata/ipv6-autoconf.xml  |6 +
  tests/interfaceschemadata/ipv6-dhcp.xml  |6 +
  tests/interfaceschemadata/ipv6-local.xml |5 +
  tests/interfaceschemadata/ipv6-static-multi.xml  |8 +
  tests/interfaceschemadata/ipv6-static.xml|7 +
  tests/interfacexml2xmltest.c |9 +
  16 files changed, 288 insertions(+), 124 deletions(-)
  create mode 100644 tests/interfaceschemadata/bridge-bond.xml
  create mode 100644 tests/interfaceschemadata/bridge-empty.xml
  create mode 100644 tests/interfaceschemadata/ipv6-autoconf-dhcp.xml
  create mode 100644 tests/interfaceschemadata/ipv6-autoconf.xml
  create mode 100644 tests/interfaceschemadata/ipv6-dhcp.xml
  create mode 100644 tests/interfaceschemadata/ipv6-local.xml
  create mode 100644 tests/interfaceschemadata/ipv6-static-multi.xml
  create mode 100644 tests/interfaceschemadata/ipv6-static.xml
 
 diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng
 index bed2f0a..a0df9ba 100644
 --- a/docs/schemas/interface.rng
 +++ b/docs/schemas/interface.rng
 @@ -1,7 +1,13 @@
  !-- A Relax NG schema for network interfaces --
  grammar xmlns=http://relaxng.org/ns/structure/1.0;
 + xmlns:v=http://netcf.org/xml/version/1.0;
   datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes;
 -  start
 +  !-- Versions for this schema are simple integers that are incremented
 +   everytime a changed (but backwards compatible) version
 +   is released. The current version is indicated with the v:serial
 +   attribute on the start element.
 +  --
 +  start v:serial=4
  choice
ref name=ethernet-interface/
ref name=bridge-interface/
 @@ -109,12 +115,17 @@
  ref name=on-or-off/
/attribute
  /optional
 -oneOrMore
 +!-- Bridge forward delay (see 'brctl setfd') --
 +optional v:since=2
 +  attribute name=delayref name=timeval//attribute
 +/optional
 +zeroOrMore
choice
  ref name=bare-ethernet-interface/
  ref name=bare-vlan-interface/
 +ref v:since=2 name=bare-bond-interface/
/choice
 -/oneOrMore
 +/zeroOrMore
/element
  /element
/define
 @@ -125,90 +136,105 @@
!--
Bonds
--
 -  define name=bond-interface
 -element name=interface
 -  attribute name=type
 -valuebond/value
 -  /attribute
 -  ref name=name-attr/
 -  ref name=startmode/
 -  ref name=mtu/
 -  ref name=interface-addressing/
 -  element name=bond
 -optional
 -  attribute name=mode
 -choice
 -  valuebalance-rr/value
 -  !-- The primary interface is the first interface child
 -   of the bond element --
 -  valueactive-backup/value
 -  valuebalance-xor/value
 -  valuebroadcast/value
 -  value802.3ad/value
 -  valuebalance-tlb/value
 -  valuebalance-alb/value
 -/choice
 -  /attribute
 -/optional
 +  define name=bond-interface-common
 +attribute name=type
 +  valuebond/value
 +/attribute
 +ref name=name-attr/
 +  /define
  
 -!-- FIXME: add more attributes
 +  define name=bond-element
 +element name=bond
 +  optional
 +attribute name=mode
 +  choice
 +valuebalance-rr/value
 +!-- The primary interface is the first interface child
 + of the bond element --
 +valueactive-backup/value
 +valuebalance-xor/value
 +valuebroadcast/value
 +value802.3ad/value
 +valuebalance-tlb/value
 +valuebalance-alb/value
 +  /choice
 +/attribute
 +  /optional
  
 - mode == 802.3ad
 -   ad_select
 -   lacp_rate
 -   xmit_hash_policy
 +  !-- FIXME: add more attributes
  
 - 

Re: [libvirt] [PATCH v2] Implement path lookup for USB by vendor:product

2010-01-14 Thread Cole Robinson
On 01/13/2010 03:50 PM, Cole Robinson wrote:
 Based off how QEMU does it, look through /sys/bus/usb/devices/* for
 matching vendor:product info, and if found, use info from the surrounding
 files to build the device's /dev/bus/usb path.
 
 This fixes USB device assignment by vendor:product when running qemu
 as non-root (well, it should, but for some reason I couldn't reproduce
 the failure people are seeing in [1], but it appears to work properly)
 
 [1] https://bugzilla.redhat.com/show_bug.cgi?id=542450
 
 v2:
 Drop 'bus.addr only' checks in security drivers
 Use various util helpers
 

Pushed now with my other pending patches (except the ia64 one which had 
comments).

- Cole

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


[libvirt] Using ESX domain XML for V2V

2010-01-14 Thread Matthew Booth
I'm trying to use the ESX driver to extract metadata from ESX in an 
easily digestible form for driving V2V. I've noticed the domain XML 
seems to be missing a few bits:


features/
graphics/
input/

serial/ and console/ are also missing, but that could well be 
because they aren't present.


Is this intentional? Should I be assuming some of the above because it's 
ESX, or is this an omission?


Thanks,

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:   +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

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


[libvirt] ANNOUNCE: A new mailing list for users / admins / app developers

2010-01-14 Thread Daniel P. Berrange
Hi Folks,

We have now created the new mailing list  libvirt-us...@redhat.com 

If you are primarily an end user / admin / application developer of libvirt
then this new list will offer a better signal-2-noise ratio for your
questions  discussions relating to libvirt. ie you won't get patchbombed
every day :-)

The form to subscribe to the new list is here:

   http://www.redhat.com/mailman/listinfo/libvirt-users


libvirt development discussions  patch submission should continue to take
place on this list. I would encourage any developers who like helping out
users to also join the new mailing list so we have knowledgable people to
answer questions that arise there

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] Add docs about new mailing list

2010-01-14 Thread Daniel P. Berrange
* docs/contact.html.in: Document new users mailing list
---
 docs/contact.html.in |   43 ---
 1 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/docs/contact.html.in b/docs/contact.html.in
index 5d055b1..3a0d439 100644
--- a/docs/contact.html.in
+++ b/docs/contact.html.in
@@ -3,15 +3,44 @@
   body
 h1Contacting the development team/h1
 
-h2Mailing list/h2
+h2Mailing lists/h2
 
 p
-  There is a mailing-list a 
href=mailto:libvir-list@redhat.com;libvir-list@redhat.com/a for libvirt,
-  with an  a href=https://www.redhat.com/archives/libvir-list/;on-line 
archive/a.
-  Please subscribe to this list before posting by visiting the
-  a href=https://www.redhat.com/mailman/listinfo/libvir-list;associated 
Web/a
-  page and follow the instructions. Patches with explanations and provided 
as
-  attachments are really appreciated and will be discussed on the mailing 
list.
+  There are two mailing-lists:
+/p
+
+dl
+  dta 
href=https://www.redhat.com/archives/libvir-list/;libvir-list@redhat.com/a/dt
+  ddThis list a place for discussions about the 
strongdevelopment/strong of libvirt. Topics for discussion include
+   ul
+ liNew features for libvirt/li
+ liBug fixing of libvirt/li
+ liNew hypervisor drivers/li
+ liDevelopment of language bindings for libvirt API/li
+ liTesting and documentation of libvirt/li
+   /ul
+  /dd
+
+  dta href=libvirt-us...@redhat.com/a/dt
+  ddThis list a place for discussions involving libvirt 
strongusers/strong. Topics for discussion include
+   ul
+ liUsage of libvirt / virsh/li
+ liAdministration of libvirtd/li
+ liDeployment of libvirt with hypervisors/li
+ liDevelopment of applications on top of / using the libvirt 
API(s)/li
+ liAny other topics along these lines/li
+   /ul
+  /dd
+/dl
+
+p
+  Both mailing lists require that you strongsubscribe before posting to 
the list/strong,
+  otherwise your posting will be blocked by mailman. You can subscribe at 
the linked webpages
+  above.
+/p
+p
+  Patches with explanations and provided as attachments are really 
appreciated and should
+  be directed to the development mailing list will be discussed on the 
mailing list.
   If possible generate the patches by using codegit diff/code in a GIT
   clone.
 /p
-- 
1.6.2.5

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


[libvirt] [PATCH 9/9] Modify virsh commands

2010-01-14 Thread Jim Fehlig
Change all virsh commands that invoke virDomain{Attach,Detach}Device()
to use virDomain{Attach,Detach}DeviceFlags() instead.

Add a --persistent flag to these virsh commands, allowing user to
specify that the domain persisted config be modified as well.
---
 tools/virsh.c |   55 +--
 1 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 1fae5e6..a082b89 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6285,6 +6285,7 @@ static const vshCmdInfo info_attach_device[] = {
 static const vshCmdOptDef opts_attach_device[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(domain name, id or 
uuid)},
 {file,   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(XML file)},
+{persistent, VSH_OT_BOOL, 0, gettext_noop(persist device attachment)},
 {NULL, 0, 0, NULL}
 };
 
@@ -6296,6 +6297,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
 char *buffer;
 int ret = TRUE;
 int found;
+int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT;
 
 if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
 return FALSE;
@@ -6309,13 +6311,18 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
 virDomainFree(dom);
 return FALSE;
 }
+if (vshCommandOptBool(cmd, persistent))
+flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
 
 if (virFileReadAll(from, VIRSH_MAX_XML_FILE, buffer)  0) {
 virDomainFree(dom);
 return FALSE;
 }
 
-ret = virDomainAttachDevice(dom, buffer);
+if (virDomainIsActive(dom))
+   flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+
+ret = virDomainAttachDeviceFlags(dom, buffer, flags);
 VIR_FREE(buffer);
 
 if (ret  0) {
@@ -6343,6 +6350,7 @@ static const vshCmdInfo info_detach_device[] = {
 static const vshCmdOptDef opts_detach_device[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(domain name, id or 
uuid)},
 {file,   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(XML file)},
+{persistent, VSH_OT_BOOL, 0, gettext_noop(persist device detachment)},
 {NULL, 0, 0, NULL}
 };
 
@@ -6354,6 +6362,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
 char *buffer;
 int ret = TRUE;
 int found;
+int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT;
 
 if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
 return FALSE;
@@ -6367,13 +6376,18 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
 virDomainFree(dom);
 return FALSE;
 }
+if (vshCommandOptBool(cmd, persistent))
+flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
 
 if (virFileReadAll(from, VIRSH_MAX_XML_FILE, buffer)  0) {
 virDomainFree(dom);
 return FALSE;
 }
 
-ret = virDomainDetachDevice(dom, buffer);
+if (virDomainIsActive(dom))
+   flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+
+ret = virDomainDetachDeviceFlags(dom, buffer, flags);
 VIR_FREE(buffer);
 
 if (ret  0) {
@@ -6405,6 +6419,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
 {target, VSH_OT_DATA, 0, gettext_noop(target network name)},
 {mac,VSH_OT_DATA, 0, gettext_noop(MAC address)},
 {script, VSH_OT_DATA, 0, gettext_noop(script used to bridge network 
interface)},
+{persistent, VSH_OT_BOOL, 0, gettext_noop(persist interface 
attachment)},
 {NULL, 0, 0, NULL}
 };
 
@@ -6415,6 +6430,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 char *mac, *target, *script, *type, *source;
 int typ, ret = FALSE;
 char *buf = NULL, *tmp = NULL;
+int flags = VIR_DOMAIN_DEVICE_MODIFY_CURRENT;
 
 if (!vshConnectionUsability(ctl, ctl-conn, TRUE))
 goto cleanup;
@@ -6429,6 +6445,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 target = vshCommandOptString(cmd, target, NULL);
 mac = vshCommandOptString(cmd, mac, NULL);
 script = vshCommandOptString(cmd, script, NULL);
+if (vshCommandOptBool(cmd, persistent))
+flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
 
 /* check interface type */
 if (STREQ(type, network)) {
@@ -6489,7 +6507,10 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 if (!buf) goto cleanup;
 strcat(buf, /interface\n);
 
-if (virDomainAttachDevice(dom, buf)) {
+if (virDomainIsActive(dom))
+   flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
+
+if (virDomainAttachDeviceFlags(dom, buf, flags)) {
 goto cleanup;
 } else {
 vshPrint(ctl, %s, _(Interface attached successfully\n));
@@ -6518,6 +6539,7 @@ static const vshCmdOptDef opts_detach_interface[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(domain name, id or 
uuid)},
 {type,   VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop(network interface 
type)},
 {mac,VSH_OT_STRING, 0, gettext_noop(MAC address)},
+{persistent, VSH_OT_BOOL, 0, gettext_noop(persist interface 
detachment)},
 {NULL, 0, 0, NULL}
 };
 
@@ -6534,6 +6556,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
   

[libvirt] [PATCH 0/9] virDomain{Attach,Detach}DeviceFlags patches

2010-01-14 Thread Jim Fehlig
This set implements two new APIs, virDomainAttachDeviceFlags and
virDomainDetachDeviceFlags as discussed here

https://www.redhat.com/archives/libvir-list/2009-December/msg00124.html

Introduce two new APIs

virDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
   unsigned flags)
virDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
   unsigned flags)

with flags being one or more from VIR_DOMAIN_DEVICE_MODIFY_CURRENT,
VIR_DOMAIN_DEVICE_MODIFY_LIVE, VIR_DOMAIN_DEVICE_MODIFY_CONFIG.

If caller specifies CURRENT (default), add or remove the device
depending on the current state of domain.  E.g. if domain is active add
or remove the device to/from live domain, if it is inactive change the
persistent config.  If caller specifies LIVE, only change the active
domain.  If caller specifies CONFIG, only change persistent config -
even if the domain is active.  If caller specifies both LIVE and CONFIG,
then change both.

If a driver can not satisfy the exact requested flags it must return
an error.  E.g if user specified LIVE but the driver can only change
live and persisted config, the driver must fail the request.

The existing virDomain{Attach,Detach}Device is now explicitly restricted
to active domains and is equivalent to
virDomain{Attach,Detach}DeviceFlags(LIVE).

Finally, virsh {attach,detach}-{disk,interface,device} has been modified
to add a --persistent flag in order to set the appropriate flags when
calling the new APIs.


Jim Fehlig (9):
  Restrict virDomain{Attach,Detach}Device to active domains
  Public API
  Internal API
  Public API Implementation
  Wire protocol format
  Remote driver
  Server side dispatcher
  domain{Attach,Detach}DeviceFlags handler for drivers
  Modify virsh commands

 daemon/remote.c  |   53 ++
 include/libvirt/libvirt.h.in |   13 +
 src/driver.h |   10 
 src/esx/esx_driver.c |2 +
 src/libvirt.c|  120 ++
 src/libvirt_public.syms  |6 ++
 src/lxc/lxc_driver.c |2 +
 src/opennebula/one_driver.c  |2 +
 src/openvz/openvz_driver.c   |2 +
 src/phyp/phyp_driver.c   |2 +
 src/qemu/qemu_driver.c   |   26 +
 src/remote/remote_driver.c   |   54 +++
 src/remote/remote_protocol.x |   17 ++-
 src/test/test_driver.c   |2 +
 src/uml/uml_driver.c |2 +
 src/vbox/vbox_tmpl.c |   24 
 src/xen/proxy_internal.c |4 +-
 src/xen/xen_driver.c |   42 +--
 src/xen/xen_driver.h |4 +-
 src/xen/xen_hypervisor.c |4 +-
 src/xen/xen_inotify.c|4 +-
 src/xen/xend_internal.c  |   98 --
 src/xen/xm_internal.c|   30 +++
 src/xen/xs_internal.c|4 +-
 tools/virsh.c|   55 +--
 25 files changed, 523 insertions(+), 59 deletions(-)

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


[libvirt] [PATCH 7/9] Server side dispatcher

2010-01-14 Thread Jim Fehlig
Server side dispatcher for Domain{Attach,Detach}DeviceFlags.
---
 daemon/remote.c |   53 +
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 0b30131..395c060 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -890,6 +890,32 @@ remoteDispatchDomainAttachDevice (struct qemud_server 
*server ATTRIBUTE_UNUSED,
 }
 
 static int
+remoteDispatchDomainAttachDeviceFlags (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+   struct qemud_client *client 
ATTRIBUTE_UNUSED,
+   virConnectPtr conn,
+   remote_message_header *hdr 
ATTRIBUTE_UNUSED,
+   remote_error *rerr,
+   remote_domain_attach_device_flags_args 
*args,
+   void *ret ATTRIBUTE_UNUSED)
+{
+virDomainPtr dom;
+
+dom = get_nonnull_domain (conn, args-dom);
+if (dom == NULL) {
+remoteDispatchConnError(rerr, conn);
+return -1;
+}
+
+if (virDomainAttachDeviceFlags (dom, args-xml, args-flags) == -1) {
+virDomainFree(dom);
+remoteDispatchConnError(rerr, conn);
+return -1;
+}
+virDomainFree(dom);
+return 0;
+}
+
+static int
 remoteDispatchDomainCreate (struct qemud_server *server ATTRIBUTE_UNUSED,
 struct qemud_client *client ATTRIBUTE_UNUSED,
 virConnectPtr conn,
@@ -1015,6 +1041,33 @@ remoteDispatchDomainDetachDevice (struct qemud_server 
*server ATTRIBUTE_UNUSED,
 }
 
 static int
+remoteDispatchDomainDetachDeviceFlags (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+   struct qemud_client *client 
ATTRIBUTE_UNUSED,
+   virConnectPtr conn,
+   remote_message_header *hdr 
ATTRIBUTE_UNUSED,
+   remote_error *rerr,
+   remote_domain_detach_device_flags_args 
*args,
+   void *ret ATTRIBUTE_UNUSED)
+{
+virDomainPtr dom;
+
+dom = get_nonnull_domain (conn, args-dom);
+if (dom == NULL) {
+remoteDispatchConnError(rerr, conn);
+return -1;
+}
+
+if (virDomainDetachDeviceFlags (dom, args-xml, args-flags) == -1) {
+virDomainFree(dom);
+remoteDispatchConnError(rerr, conn);
+return -1;
+}
+
+virDomainFree(dom);
+return 0;
+}
+
+static int
 remoteDispatchDomainDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
  struct qemud_client *client ATTRIBUTE_UNUSED,
  virConnectPtr conn,
-- 
1.6.0.2

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


[libvirt] [PATCH 2/9] Public API

2010-01-14 Thread Jim Fehlig
Definition of public API for virDomain{Attach,Detach}DeviceFlags.
---
 include/libvirt/libvirt.h.in |   13 +
 src/libvirt_public.syms  |6 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index f192fb1..99a5c45 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -845,9 +845,22 @@ int virDomainGetVcpus   
(virDomainPtr domain,
  */
 #define VIR_GET_CPUMAP(cpumaps,maplen,vcpu) (cpumaps[(vcpu)*(maplen)])
 
+
+typedef enum {
+
+   VIR_DOMAIN_DEVICE_MODIFY_CURRENT = 0, /* Modify device allocation based on 
current domain state */
+   VIR_DOMAIN_DEVICE_MODIFY_LIVE = (1  0), /* Modify live device allocation 
*/
+   VIR_DOMAIN_DEVICE_MODIFY_CONFIG = (1  1), /* Modify persisted device 
allocation */
+} virDomainDeviceModifyFlags;
+
 int virDomainAttachDevice(virDomainPtr domain, const char *xml);
 int virDomainDetachDevice(virDomainPtr domain, const char *xml);
 
+int virDomainAttachDeviceFlags(virDomainPtr domain,
+   const char *xml, unsigned int flags);
+int virDomainDetachDeviceFlags(virDomainPtr domain,
+   const char *xml, unsigned int flags);
+
 /*
  * NUMA support
  */
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 0521158..e190d83 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -349,4 +349,10 @@ LIBVIRT_0.7.5 {
 virDomainMemoryStats;
 } LIBVIRT_0.7.3;
 
+LIBVIRT_0.7.6 {
+global:
+virDomainAttachDeviceFlags;
+virDomainDetachDeviceFlags;
+} LIBVIRT_0.7.5;
+
 #  define new API here using predicted next version number 
-- 
1.6.0.2

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


[libvirt] [PATCH 6/9] Remote driver

2010-01-14 Thread Jim Fehlig
Implementation of Domain{Attach,Detach}DeviceFlags in remote driver.
---
 src/remote/remote_driver.c |   54 
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d6f5fce..eb16f62 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3057,6 +3057,32 @@ done:
 }
 
 static int
+remoteDomainAttachDeviceFlags (virDomainPtr domain, const char *xml,
+   unsigned int flags)
+{
+int rv = -1;
+remote_domain_attach_device_flags_args args;
+struct private_data *priv = domain-conn-privateData;
+
+remoteDriverLock(priv);
+
+make_nonnull_domain (args.dom, domain);
+args.xml = (char *) xml;
+args.flags = flags;
+
+if (call (domain-conn, priv, 0, REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS,
+  (xdrproc_t) xdr_remote_domain_attach_device_flags_args, (char *) 
args,
+  (xdrproc_t) xdr_void, (char *) NULL) == -1)
+goto done;
+
+rv = 0;
+
+done:
+remoteDriverUnlock(priv);
+return rv;
+}
+
+static int
 remoteDomainDetachDevice (virDomainPtr domain, const char *xml)
 {
 int rv = -1;
@@ -3081,6 +3107,32 @@ done:
 }
 
 static int
+remoteDomainDetachDeviceFlags (virDomainPtr domain, const char *xml,
+   unsigned int flags)
+{
+int rv = -1;
+remote_domain_detach_device_flags_args args;
+struct private_data *priv = domain-conn-privateData;
+
+remoteDriverLock(priv);
+
+make_nonnull_domain (args.dom, domain);
+args.xml = (char *) xml;
+args.flags = flags;
+
+if (call (domain-conn, priv, 0, REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS,
+  (xdrproc_t) xdr_remote_domain_detach_device_flags_args, (char *) 
args,
+  (xdrproc_t) xdr_void, (char *) NULL) == -1)
+goto done;
+
+rv = 0;
+
+done:
+remoteDriverUnlock(priv);
+return rv;
+}
+
+static int
 remoteDomainGetAutostart (virDomainPtr domain, int *autostart)
 {
 int rv = -1;
@@ -8894,7 +8946,9 @@ static virDriver remote_driver = {
 remoteDomainDefineXML, /* domainDefineXML */
 remoteDomainUndefine, /* domainUndefine */
 remoteDomainAttachDevice, /* domainAttachDevice */
+remoteDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
 remoteDomainDetachDevice, /* domainDetachDevice */
+remoteDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
 remoteDomainGetAutostart, /* domainGetAutostart */
 remoteDomainSetAutostart, /* domainSetAutostart */
 remoteDomainGetSchedulerType, /* domainGetSchedulerType */
-- 
1.6.0.2

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


[libvirt] [PATCH 3/9] Internal API

2010-01-14 Thread Jim Fehlig
Definition of internal API for virDomain{Attach,Detach}DeviceFlags.
---
 src/driver.h |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index c7e4fbf..08fe816 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -192,9 +192,17 @@ typedef int
 (*virDrvDomainAttachDevice)(virDomainPtr domain,
  const char *xml);
 typedef int
+(*virDrvDomainAttachDeviceFlags) (virDomainPtr domain,
+  const char *xml,
+  unsigned int flags);
+typedef int
 (*virDrvDomainDetachDevice)(virDomainPtr domain,
  const char *xml);
 typedef int
+(*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
+  const char *xml,
+  unsigned int flags);
+typedef int
 (*virDrvDomainGetAutostart)(virDomainPtr domain,
  int *autostart);
 typedef int
@@ -419,7 +427,9 @@ struct _virDriver {
 virDrvDomainDefineXML   domainDefineXML;
 virDrvDomainUndefinedomainUndefine;
 virDrvDomainAttachDevice   domainAttachDevice;
+virDrvDomainAttachDeviceFlags  domainAttachDeviceFlags;
 virDrvDomainDetachDevice   domainDetachDevice;
+virDrvDomainDetachDeviceFlags  domainDetachDeviceFlags;
 virDrvDomainGetAutostart   domainGetAutostart;
 virDrvDomainSetAutostart   domainSetAutostart;
 virDrvDomainGetSchedulerType   domainGetSchedulerType;
-- 
1.6.0.2

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


[libvirt] [PATCH 5/9] Wire protocol format

2010-01-14 Thread Jim Fehlig
Definition of wire protocol format for
virDomain{Attach,Detach}DeviceFlags.
---
 src/remote/remote_protocol.x |   17 -
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index bed3940..98953a9 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -708,11 +708,23 @@ struct remote_domain_attach_device_args {
 remote_nonnull_string xml;
 };
 
+struct remote_domain_attach_device_flags_args {
+remote_nonnull_domain dom;
+remote_nonnull_string xml;
+unsigned int flags;
+};
+
 struct remote_domain_detach_device_args {
 remote_nonnull_domain dom;
 remote_nonnull_string xml;
 };
 
+struct remote_domain_detach_device_flags_args {
+remote_nonnull_domain dom;
+remote_nonnull_string xml;
+unsigned int flags;
+};
+
 struct remote_domain_get_autostart_args {
 remote_nonnull_domain dom;
 };
@@ -1641,7 +1653,10 @@ enum remote_procedure {
 REMOTE_PROC_INTERFACE_IS_ACTIVE = 156,
 REMOTE_PROC_GET_LIB_VERSION = 157,
 REMOTE_PROC_CPU_COMPARE = 158,
-REMOTE_PROC_DOMAIN_MEMORY_STATS = 159
+REMOTE_PROC_DOMAIN_MEMORY_STATS = 159,
+REMOTE_PROC_DOMAIN_ATTACH_DEVICE_FLAGS = 160,
+
+REMOTE_PROC_DOMAIN_DETACH_DEVICE_FLAGS = 161
 
 /*
  * Notice how the entries are grouped in sets of 10 ?
-- 
1.6.0.2

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


[libvirt] [PATCH 4/9] Public API Implementation

2010-01-14 Thread Jim Fehlig
Implementation of public API for virDomain{Attach,Detach}DeviceFlags.
---
 src/libvirt.c |  106 
 1 files changed, 98 insertions(+), 8 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 1145561..77f76bc 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5129,7 +5129,6 @@ error:
 int
 virDomainAttachDevice(virDomainPtr domain, const char *xml)
 {
-virConnectPtr conn;
 DEBUG(domain=%p, xml=%s, domain, xml);
 
 virResetLastError();
@@ -5147,17 +5146,63 @@ virDomainAttachDevice(virDomainPtr domain, const char 
*xml)
 virLibDomainError(domain, VIR_ERR_OPERATION_INVALID, __FUNCTION__);
 goto error;
 }
+
+return virDomainAttachDeviceFlags(domain, xml,
+  VIR_DOMAIN_DEVICE_MODIFY_LIVE);
+
+error:
+virDispatchError(domain-conn);
+return -1;
+}
+
+/**
+ * virDomainAttachDeviceFlags:
+ * @domain: pointer to domain object
+ * @xml: pointer to XML description of one device
+ * @flags: an OR'ed set of virDomainDeviceModifyFlags
+ *
+ * Attach a virtual device to a domain, using the flags parameter
+ * to control how the device is attached.  VIR_DOMAIN_DEVICE_MODIFY_CURRENT
+ * specifies that the device allocation is made based on current domain
+ * state.  VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
+ * allocated to the active domain instance only and is not added to the
+ * persisted domain configuration.  VIR_DOMAIN_DEVICE_MODIFY_CONFIG
+ * specifies that the device shall be allocated to the persisted domain
+ * configuration only.  Note that the target hypervisor must return an
+ * error if unable to satisfy flags.  E.g. the hypervisor driver will
+ * return failure if LIVE is specified but it only supports modifying the
+ * persisted device allocation.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+virDomainAttachDeviceFlags(virDomainPtr domain,
+   const char *xml, unsigned int flags)
+{
+virConnectPtr conn;
+DEBUG(domain=%p, xml=%s, flags=%d, domain, xml, flags);
+
+virResetLastError();
+
+if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+return (-1);
+}
+if (domain-conn-flags  VIR_CONNECT_RO) {
+virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+goto error;
+}
 conn = domain-conn;
 
-if (conn-driver-domainAttachDevice) {
+if (conn-driver-domainAttachDeviceFlags) {
 int ret;
-ret = conn-driver-domainAttachDevice (domain, xml);
+ret = conn-driver-domainAttachDeviceFlags(domain, xml, flags);
 if (ret  0)
 goto error;
 return ret;
 }
 
-virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
 
 error:
 virDispatchError(domain-conn);
@@ -5177,7 +5222,6 @@ error:
 int
 virDomainDetachDevice(virDomainPtr domain, const char *xml)
 {
-virConnectPtr conn;
 DEBUG(domain=%p, xml=%s, domain, xml);
 
 virResetLastError();
@@ -5195,17 +5239,63 @@ virDomainDetachDevice(virDomainPtr domain, const char 
*xml)
 virLibDomainError(domain, VIR_ERR_OPERATION_INVALID, __FUNCTION__);
 goto error;
 }
+
+return virDomainDetachDeviceFlags(domain, xml,
+  VIR_DOMAIN_DEVICE_MODIFY_LIVE);
+
+error:
+virDispatchError(domain-conn);
+return -1;
+}
+
+/**
+ * virDomainDetachDeviceFlags:
+ * @domain: pointer to domain object
+ * @xml: pointer to XML description of one device
+ * @flags: an OR'ed set of virDomainDeviceModifyFlags
+ *
+ * Detach a virtual device from a domain, using the flags parameter
+ * to control how the device is detached.  VIR_DOMAIN_DEVICE_MODIFY_CURRENT
+ * specifies that the device allocation is removed based on current domain
+ * state.  VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
+ * deallocated from the active domain instance only and is not from the
+ * persisted domain configuration.  VIR_DOMAIN_DEVICE_MODIFY_CONFIG
+ * specifies that the device shall be deallocated from the persisted domain
+ * configuration only.  Note that the target hypervisor must return an
+ * error if unable to satisfy flags.  E.g. the hypervisor driver will
+ * return failure if LIVE is specified but it only supports removing the
+ * persisted device allocation.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+virDomainDetachDeviceFlags(virDomainPtr domain,
+   const char *xml, unsigned int flags)
+{
+virConnectPtr conn;
+DEBUG(domain=%p, xml=%s, flags=%d, domain, xml, flags);
+
+virResetLastError();
+
+if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+return (-1);
+}
+if (domain-conn-flags  VIR_CONNECT_RO) {
+

[libvirt] [PATCH 1/9] Restrict virDomain{Attach, Detach}Device to active domains

2010-01-14 Thread Jim Fehlig
virDomain{Attach,Detach}Device is now only permitted on active
domains.  Explicitly state this restriction in the API
documentation and enforce it in libvirt frontend.
---
 src/libvirt.c |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index d973907..1145561 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5121,7 +5121,8 @@ error:
  * @domain: pointer to domain object
  * @xml: pointer to XML description of one device
  *
- * Create a virtual device attachment to backend.
+ * Create a virtual device attachment to backend.  This function,
+ * having hotplug semantics, is only allowed on an active domain.
  *
  * Returns 0 in case of success, -1 in case of failure.
  */
@@ -5142,6 +5143,10 @@ virDomainAttachDevice(virDomainPtr domain, const char 
*xml)
 virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
 goto error;
 }
+if (!virDomainIsActive(domain)) {
+virLibDomainError(domain, VIR_ERR_OPERATION_INVALID, __FUNCTION__);
+goto error;
+}
 conn = domain-conn;
 
 if (conn-driver-domainAttachDevice) {
@@ -5164,7 +5169,8 @@ error:
  * @domain: pointer to domain object
  * @xml: pointer to XML description of one device
  *
- * Destroy a virtual device attachment to backend.
+ * Destroy a virtual device attachment to backend.  This function,
+ * having hot-unplug semantics, is only allowed on an active domain.
  *
  * Returns 0 in case of success, -1 in case of failure.
  */
@@ -5185,6 +5191,10 @@ virDomainDetachDevice(virDomainPtr domain, const char 
*xml)
 virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
 goto error;
 }
+if (!virDomainIsActive(domain)) {
+virLibDomainError(domain, VIR_ERR_OPERATION_INVALID, __FUNCTION__);
+goto error;
+}
 conn = domain-conn;
 
 if (conn-driver-domainDetachDevice) {
-- 
1.6.0.2

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


[libvirt] [PATCH 8/9] domain{Attach, Detach}DeviceFlags handler for drivers

2010-01-14 Thread Jim Fehlig
Implementation of domain{Attach,Detach}DeviceFlags handlers
in the drivers.
---
 src/esx/esx_driver.c|2 +
 src/lxc/lxc_driver.c|2 +
 src/opennebula/one_driver.c |2 +
 src/openvz/openvz_driver.c  |2 +
 src/phyp/phyp_driver.c  |2 +
 src/qemu/qemu_driver.c  |   26 +++
 src/test/test_driver.c  |2 +
 src/uml/uml_driver.c|2 +
 src/vbox/vbox_tmpl.c|   24 ++
 src/xen/proxy_internal.c|4 +-
 src/xen/xen_driver.c|   42 +--
 src/xen/xen_driver.h|4 +-
 src/xen/xen_hypervisor.c|4 +-
 src/xen/xen_inotify.c   |4 +-
 src/xen/xend_internal.c |   98 +++
 src/xen/xm_internal.c   |   30 +
 src/xen/xs_internal.c   |4 +-
 17 files changed, 212 insertions(+), 42 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ddda66e..577c1c7 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3443,7 +3443,9 @@ static virDriver esxDriver = {
 esxDomainDefineXML,  /* domainDefineXML */
 esxDomainUndefine,   /* domainUndefine */
 NULL,/* domainAttachDevice */
+NULL,/* domainAttachDeviceFlags */
 NULL,/* domainDetachDevice */
+NULL,/* domainDetachDeviceFlags */
 NULL,/* domainGetAutostart */
 NULL,/* domainSetAutostart */
 esxDomainGetSchedulerType,   /* domainGetSchedulerType */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 86606c7..d80f20c 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2427,7 +2427,9 @@ static virDriver lxcDriver = {
 lxcDomainDefine, /* domainDefineXML */
 lxcDomainUndefine, /* domainUndefine */
 NULL, /* domainAttachDevice */
+NULL, /* domainAttachDeviceFlags */
 NULL, /* domainDetachDevice */
+NULL, /* domainDetachDeviceFlags */
 lxcDomainGetAutostart, /* domainGetAutostart */
 lxcDomainSetAutostart, /* domainSetAutostart */
 lxcGetSchedulerType, /* domainGetSchedulerType */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index ad7faca..509cbc3 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -754,7 +754,9 @@ static virDriver oneDriver = {
 oneDomainDefine, /* domainDefineXML */
 oneDomainUndefine, /* domainUndefine */
 NULL, /* domainAttachDevice */
+NULL, /* domainAttachDeviceFlags */
 NULL, /* domainDetachDevice */
+NULL, /* domainDetachDeviceFlags */
 oneGetAutostart, /* domainGetAutostart */
 NULL, /* domainSetAutostart */
 NULL, /* domainGetSchedulerType */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 196fd8c..b16efef 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1506,7 +1506,9 @@ static virDriver openvzDriver = {
 openvzDomainDefineXML, /* domainDefineXML */
 openvzDomainUndefine, /* domainUndefine */
 NULL, /* domainAttachDevice */
+NULL, /* domainAttachDeviceFlags */
 NULL, /* domainDetachDevice */
+NULL, /* domainDetachDeviceFlags */
 openvzDomainGetAutostart, /* domainGetAutostart */
 openvzDomainSetAutostart, /* domainSetAutostart */
 NULL, /* domainGetSchedulerType */
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index bd5cfc7..5474bda 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1622,7 +1622,9 @@ virDriver phypDriver = {
 NULL,   /* domainDefineXML */
 NULL,   /* domainUndefine */
 NULL,   /* domainAttachDevice */
+NULL,   /* domainAttachDeviceFlags */
 NULL,   /* domainDetachDevice */
+NULL,   /* domainDetachDeviceFlags */
 NULL,   /* domainGetAutostart */
 NULL,   /* domainSetAutostart */
 NULL,   /* domainGetSchedulerType */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index deb8adc..02a6212 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5544,6 +5544,18 @@ cleanup:
 return ret;
 }
 
+static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
+const char *xml,
+unsigned int flags) {
+if (flags  VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
+qemudReportError(dom-conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
+ %s, _(cannot modify the persistent configuration 
of a domain));
+return -1;
+}
+
+return qemudDomainAttachDevice(dom, xml);
+}
+
 static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
   struct qemud_driver *driver,
 

[libvirt] hvm/x86_64 combination not allowed

2010-01-14 Thread Steve Brown
I have a VM that I am able to run using qemu form a command prompt
with no problems.  I want to run it from within libvirt, so I
converted my qemu command to XML using 'virsh domxml-from-native ...'
My problem is that my libvirt does not seem to support the x86_64
architecture, so when I try to launch the VM, the kernel won't built
since it was installed on x86_64.  My os container is as follows (as
imported by virsh):

os
  type arch='i686' machine='pc-0.11'hvm/type
  boot dev='hd'/
/os

However, when I try to change it to this:

os
  type arch='x86_64'hvm/type
  boot dev='hd'/
/os

I get the following message:

error: internal error os type 'hvm'  arch 'x86_64' combination is not supported

I've searched for a proper command line switch to build this option
into libvirt, but I have not had any success.  So how do I get libvirt
to support the x86_64 arch?

Thanks,
Steve

PS:
$ sudo virsh capabilities
capabilities
  host
cpu
  archx86_64/arch
/cpu
migration_features
  live/
  uri_transports
uri_transporttcp/uri_transport
  /uri_transports
/migration_features
  /host
  guest
os_typehvm/os_type
arch name='i686'
  wordsize32/wordsize
  emulator/usr/bin/qemu/emulator
  machinepc-0.11/machine
  machine canonical='pc-0.11'pc/machine
  machinepc-0.10/machine
  machineisapc/machine
  domain type='qemu'
  /domain
/arch
features
  pae/
  nonpae/
  acpi default='on' toggle='yes'/
  apic default='on' toggle='no'/
/features
  /guest
/capabilities

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


[libvirt] [PATCH] Man page BZ 548485

2010-01-14 Thread David Jorm
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -342,7 +342,15 @@ severed upon restore, as TCP timeouts may have expired.
 
 =item Bschedinfo optional I--weight Bnumber optional I--cap Bnumber 
Idomain-id
 
-Allows to show (and set) the domain scheduler parameters.
+Allows you to show (and set) the domain scheduler parameters. The parameters 
available for each hypervisor are:
+
+LXC, QEMU/KVM (posix scheduler): cpu_shares
+
+Xen (credit scheduler): weight, cap
+
+ESX (allocation scheduler): reservation, limit, shares
+
+BNote: The cpu_shares parameter has a valid value range of 0-262144.
 
 BNote: The weight and cap parameters are defined only for the
 XEN_CREDIT scheduler and are now IDEPRECATED.

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


[libvirt] [PATCH] Fix compilation of virt-aa-helper.c

2010-01-14 Thread Matthias Bolte
Commit 5073aa994af460e775cb3e548528e28d7660fcc8 added an additional
'}' to a case block that messed up the block structure of the get_files
function.
---
 src/security/virt-aa-helper.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 3c8b49a..1b0b2cd 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -851,7 +851,6 @@ get_files(vahControl * ctl)
 if (rc != 0)
 goto clean;
 break;
-}
 }
 /* TODO: update so files in /sys are readonly
 case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
-- 
1.6.3.3

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


[libvirt] [PATCH] Man page for LXC BZ 528709

2010-01-14 Thread David Jorm
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -114,6 +114,10 @@ allow to connect locally as root to the daemon supervising 
QEmu and KVM domains
 
 allow to connect locally as a normal user to his own set of QEmu and KVM 
domains
 
+=item lxc:///
+
+connect to a local linux container
+
 =back
 
 For remote access see the documentation page on how to make URIs.

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