Re: [libvirt] [PATCH] pci: Save and restore each devices/functions behind the bus

2012-09-06 Thread Daniel Veillard
On Mon, Sep 03, 2012 at 04:57:01PM +0800, Osier Yang wrote:
 Previously it refuses to do the secondary bus reset as long as
 there is(are) devices/functions behind the same bus, regardless
 of whether the devices/functions are being used or not. And it
 only save and restore the device itself's PCI config space.
 
 But later it was changed to allow the secondary bus reset as long
 as the devices/functions behind the same bus are not being
 used. Unfortunately, it still just saves and restores the device
 itself's PCI config space. It means we will lose the PCI config
 space for the devices share same bus when doing passthrough.
 
 Also, (hope my guess is right) as it assumes the secondary reset
 is allowed unless the device doesn't have devices/functions behind
 the same bus, so it only reads the bridge control register from the
 device, but not the parent.
 
 This patch fixes the problem by finding out all the devices/functions
 behind the same bus of the device to be reset, and save/restore
 PCI config space for all of them. And read the bridge control register
 from the device's parent (bridge) before resetting.
 
 * src/util/pci.c:
   - New helper pciSharesBus to check if two devices share same bus.
 
   - New helper pciDevicesShareBus to return a list containg all of
 the devices/functions which share same bus with the device
 
   - pciTrySecondaryBusReset: Save and restore PCI config space for
 all the devices/functions behind the same bus; Read the bridge
 control register from the device's parent instead before resetting.
 ---
  src/util/pci.c |   80 ---
  1 files changed, 75 insertions(+), 5 deletions(-)
 
 diff --git a/src/util/pci.c b/src/util/pci.c
 index 0742d07..1a9777a 100644
 --- a/src/util/pci.c
 +++ b/src/util/pci.c
 @@ -517,6 +517,39 @@ pciBusContainsActiveDevices(pciDevice *dev,
  return active;
  }
  
 +/*
 + * Check if the @dev and @check share bus.
 + */
 +static int
 +pciSharesBus(pciDevice *dev, pciDevice *check, void *data ATTRIBUTE_UNUSED)
 +{
 +if ((dev-domain == check-domain) 
 +(dev-bus == check-bus) 
 +(dev-slot == check-slot))
 +return 1;
 +
 +return 0;
 +}

  I'm a bit puzzled ... seems to me the function check if the devices
share the same slot on the same bus, not just sharing of the same bus

 +/*
 + * Return all the devices/functions share same bus with @dev
 + * as a list.
 + */
 +static pciDeviceList *
 +pciDevicesShareBus(pciDevice *dev)
 +{
 +pciDevice *match = NULL;
 +pciDeviceList *pcis = NULL;
 +
 +if (!(pcis = pciDeviceListNew()))
 +return NULL;
 +
 +if (pciIterDevices(pciSharesBus, dev, match, NULL))
 +pciDeviceListAdd(pcis, match);
 +
 +return pcis;
 +}
 +
  /* Is @check the parent of @dev ? */
  static int
  pciIsParent(pciDevice *dev, pciDevice *check, void *data)
 @@ -604,6 +637,9 @@ pciTrySecondaryBusReset(pciDevice *dev,
  uint8_t config_space[PCI_CONF_LEN];
  uint16_t ctl;
  int ret = -1;
 +pciDeviceList *list = NULL;
 +uint8_t (*config_spaces)[PCI_CONF_LEN];
 +int i;
  
  /* Refuse to do a secondary bus reset if there are other
   * devices/functions behind the bus are used by the host
 @@ -628,10 +664,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
  
  VIR_DEBUG(%s %s: doing a secondary bus reset, dev-id, dev-name);
  
 -/* Save and restore the device's config space; we only do this
 - * for the supplied device since we refuse to do a reset if there
 - * are multiple devices/functions
 - */
 +/* Save the device's config space */
  if (pciRead(dev, 0, config_space, PCI_CONF_LEN)  0) {
  virReportError(VIR_ERR_INTERNAL_ERROR,
 _(Failed to read PCI config space for %s),
 @@ -639,10 +672,29 @@ pciTrySecondaryBusReset(pciDevice *dev,
  goto out;
  }
  
 +/* Save the config space of devices behind the same bus  */
 +if ((list = pciDevicesShareBus(dev))) {
 +if (VIR_ALLOC_N(config_spaces, list-count)  0) {
 +virReportOOMError();
 +goto out;
 +}
 +
 +for (i = 0; i  list-count; i++) {
 +pciDevice *pci = list-devs[i];
 +
 +if (pciRead(pci, 0, config_spaces[i], PCI_CONF_LEN)  0) {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(Failed to read PCI config space for %s),
 +   pci-name);
 +goto out;
 +}
 +}
 +}
 +
  /* Read the control register, set the reset flag, wait 200ms,
   * unset the reset flag and wait 200ms.
   */
 -ctl = pciRead16(dev, PCI_BRIDGE_CONTROL);
 +ctl = pciRead16(parent, PCI_BRIDGE_CONTROL);
  
  pciWrite16(parent, PCI_BRIDGE_CONTROL, ctl | PCI_BRIDGE_CTL_RESET);
  
 @@ -652,14 +704,32 @@ pciTrySecondaryBusReset(pciDevice *dev,
  
  usleep(200 * 1000); /* sleep 200ms */
  
 +/* Restore the 

Re: [libvirt] [PATCH V4] implement offline migration

2012-09-06 Thread Kamezawa Hiroyuki

(2012/09/06 14:32), liguang wrote:

Hello, Eric  Daniel

在 2012-09-05三的 11:08 -0600,Eric Blake写道:

On 09/05/2012 02:48 AM, Daniel P. Berrange wrote:


I really don't like the general design of this patch, even
ignoring all the code bugs. I think this entire patch is
really just a solution in search of a problem. Offline migration
is already possible with existing libvirt APIs:


I agree that the existing patches are making too many assumptions and
not honoring flags correctly; but I'm still not sure why the user must
decompose offline migration into a sequence of calls...


yes, my original thought was to do all things together.





domsrc = virDomainLookupByName(connsrc, someguest);
xml = virDomainGetXMLDesc(domsrc);
domdst virDomainDefine(conndst, xml);



Um, maybe you mean offline migration is just redefinition of domain at
target side, but what about disk images the domain used without sharing
files between source and target, do we have to take a look at this case?


Which can also be done already

virStorageVolDownload + virStorageVolUpload


...when a single virMigrate API could do the same decomposition as
syntactic sugar, if the patch were cleaned up to actually obey flags.
That is, why must virMigrate be a live-only operation, forcing
virt-manager and all other wrappers to re-implement the same giant
sequence of API calls for offline migration?



so, libvirt may prefer APIs do one thing only?
maybe I have to just migrate the definition.



Can you try to move the definition in an atomic way ?
copy to the dest + delete the original with preventing other ops to the
target vm. I hope virsh migrate can support this move of definition

Thanks,
-Kame


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

Re: [libvirt] [PATCH v0] qemu: Add sandbox support.

2012-09-06 Thread Daniel Veillard
On Mon, Sep 03, 2012 at 02:03:39PM +0200, Ján Tomko wrote:
 QEMU (since 1.2-rc0) supports setting up a syscall whitelist through
 libseccomp on linux kernel from 3.5-rc1. This is enabled by specifying
 -sandbox on on qemu command line.
 
 This patch detects this capability by searching for -sandbox in qemu
 help output and runs qemu with -sandbox on if sandbox is set to non-zero
 in qemu.conf.
 
 ---
 Should this option be in qemu.conf, or would it be better to set it
 per-domain in the XML?
 ---
  src/qemu/qemu.conf   |6 ++
  src/qemu/qemu_capabilities.c |3 +++
  src/qemu/qemu_capabilities.h |1 +
  src/qemu/qemu_command.c  |3 +++
  src/qemu/qemu_conf.c |5 +
  src/qemu/qemu_conf.h |1 +
  6 files changed, 19 insertions(+), 0 deletions(-)
 
 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
 index d3175fa..47e510e 100644
 --- a/src/qemu/qemu.conf
 +++ b/src/qemu/qemu.conf
 @@ -375,3 +375,9 @@
  #
  #keepalive_interval = 5
  #keepalive_count = 5
 +
 +
 +
 +# Enable this to use seccomp syscall whitelisting in QEMU.
 +#
 +#sandbox = 1
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 2ba7956..b0728e8 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -176,6 +176,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
disable-s3,
  
disable-s4, /* 105 */
 +  sandbox
  );
  
  struct qemu_feature_flags {
 @@ -1139,6 +1140,8 @@ qemuCapsComputeCmdFlags(const char *help,
  }
  if (strstr(help, -smbios type))
  qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
 +if (strstr(help, -sandbox))
 +qemuCapsSet(flags, QEMU_CAPS_SANDBOX);
  
  if ((netdev = strstr(help, -netdev))) {
  /* Disable -netdev on 0.12 since although it exists,
 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
 index a7b3a06..0066901 100644
 --- a/src/qemu/qemu_capabilities.h
 +++ b/src/qemu/qemu_capabilities.h
 @@ -141,6 +141,7 @@ enum qemuCapsFlags {
  QEMU_CAPS_IOLIMITS   = 103, /* -device ...logical_block_size  
 co */
  QEMU_CAPS_DISABLE_S3 = 104, /* S3 BIOS Advertisement on/off */
  QEMU_CAPS_DISABLE_S4 = 105, /* S4 BIOS Advertisement on/off */
 +QEMU_CAPS_SANDBOX= 106, /* -sandbox */
  
  QEMU_CAPS_LAST,   /* this must always be the last item */
  };
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index e739f34..737d4d9 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -6462,6 +6462,9 @@ qemuBuildCommandLine(virConnectPtr conn,
   ? qemucmd-env_value[i] : );
  }
  
 +if (driver-sandbox  qemuCapsGet(qemuCaps, QEMU_CAPS_SANDBOX))
 +virCommandAddArgList(cmd, -sandbox, on, NULL);
 +
  return cmd;
  
   no_memory:
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index e9e15c5..a367fcd 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -129,6 +129,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
  
  driver-keepAliveInterval = 5;
  driver-keepAliveCount = 5;
 +driver-sandbox = false;
  
  /* Just check the file is readable before opening it, otherwise
   * libvirt emits an error.
 @@ -570,6 +571,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
  CHECK_TYPE(keepalive_count, VIR_CONF_LONG);
  if (p) driver-keepAliveCount = p-l;
  
 +p = virConfGetValue(conf, sandbox);
 +CHECK_TYPE(sandbox, VIR_CONF_LONG);
 +if (p) driver-sandbox = p-l;
 +
  virConfFree (conf);
  return 0;
  }
 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
 index ac285f6..f1b6465 100644
 --- a/src/qemu/qemu_conf.h
 +++ b/src/qemu/qemu_conf.h
 @@ -152,6 +152,7 @@ struct qemud_driver {
  
  int keepAliveInterval;
  unsigned int keepAliveCount;
 +bool sandbox;
  };
  
  typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef;

  As-is the patch looks fine to me, now the real question as you pointed
out is do we want to enforce that at the guest level.
  In general, if available sandboxing should be turned on unless we hit
a bug, so if it work as expected, it should always be on, which to me
would be an indication to have that as a global default for the driver
(and on by default).
  If you have to rely on the user explicit setting to activate it, it
won't be activated, if security implementations are good enough they
are better off as default settings IMHO,

  So ACK to this, except I would change src/qemu/qemu.conf patch to
enable it by default, i.e. remove the leading # ... then testing will
tell us if we can keep it on.

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

Re: [libvirt] [PATCH v0] qemu: Add sandbox support.

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 02:27:19PM +0800, Daniel Veillard wrote:
 On Mon, Sep 03, 2012 at 02:03:39PM +0200, Ján Tomko wrote:
  QEMU (since 1.2-rc0) supports setting up a syscall whitelist through
  libseccomp on linux kernel from 3.5-rc1. This is enabled by specifying
  -sandbox on on qemu command line.
  
  This patch detects this capability by searching for -sandbox in qemu
  help output and runs qemu with -sandbox on if sandbox is set to non-zero
  in qemu.conf.
[...]
   As-is the patch looks fine to me, now the real question as you pointed
 out is do we want to enforce that at the guest level.
   In general, if available sandboxing should be turned on unless we hit
 a bug, so if it work as expected, it should always be on, which to me
 would be an indication to have that as a global default for the driver
 (and on by default).
   If you have to rely on the user explicit setting to activate it, it
 won't be activated, if security implementations are good enough they
 are better off as default settings IMHO,
 
   So ACK to this, except I would change src/qemu/qemu.conf patch to
 enable it by default, i.e. remove the leading # ... then testing will
 tell us if we can keep it on.

  I just asked Chris Evans the vsftpd maintainer since I know he added
support for it, except for a couple of bugs on Fedora he activated it by
default if the kernel supports it, and things seems to work just fine.

  So yeah I would keep that a global setting and activated by default,
if there are bugs in the kernel or the qemu side we may revisit this
but let's see first what kind of bugs pop up, and at the distro level
it's easy to switch back to off if there is serious problems.

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] Bug:libvirtd boot up blocked in NAT network setup

2012-09-06 Thread Wenchao Xia
Hello, guys
  I met a strange problem in libvirt+kvm massive deployment case. What
shows is that libvirtd will not respond to any virsh calls, with debug
I found that libvirtd was blocked at the step to setup default nat
network, that is command iptables -table nat x.
  In terminal, I found command iptables -L will also block, and
brctl show shows that about 160 tap devices vnetXXX were attached
to virbr0. After I deleted these tap devices, things become normal, But
when I re-create them and attach these tap device to virbr0, it can't
be reproduced. There are too server met this problem in test, so I think
it is not a hardware problem. Does someone have experience this before?

information:
server: RH6.2
libvirt: libvirt-0.9.4
kernel: 2.6.32


-- 
Best Regards

Wenchao Xia

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


Re: [libvirt] Compile libvirt on Solaris

2012-09-06 Thread Daniel Veillard
On Tue, Sep 04, 2012 at 04:26:55AM +, Yang Zhou (yangzho) wrote:
 Hi Experts,
 
 I am compiling libvirt 0.9.9 on Solaris 9. But got following errors when run 
 ./configure --with-esx --with-qemu
 ---
 checking for library containing dlopen... -ldl
 checking for xen_vm_start in -lxenserver... no
 checking for libxl_domain_create_new in -lxenlight... no
 checking for xs_read in -lxenstore... no
 checking linux/kvm.h usability... no
 checking linux/kvm.h presence... no
 checking for linux/kvm.h... no
 checking for shell that supports  redirection... /bin/sh
 checking linux/param.h usability... no
 checking linux/param.h presence... no
 checking for linux/param.h... no
 configure: error: You must install kernel-headers in order to compile libvirt 
 with QEMU or LXC support
 bash-2.05$
 
 
 After look at configure, it's found the headers of linux/param.h,
 linux/sockios.h. linux/if_bridge.h and linux/if_tun.h are
 required. Obviously these files are missing on Solaris platform. Anybody
 can help how to solve this issue?

  I'm not sure we still have an active maintainer on Solaris, John Levon
didn't posted here for ages ...

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] Define DYNLIB_NAME on OpenBSD.

2012-09-06 Thread Daniel Veillard
On Tue, Sep 04, 2012 at 04:56:13PM +0200, Jasper Lievisse Adriaanse wrote:
 From 05dd99030d865127c874d1b489b9c17412bdbb3b Mon Sep 17 00:00:00 2001
 From: Jasper Lievisse Adriaanse jas...@humppa.nl
 Date: Tue, 4 Sep 2012 16:48:51 +0200
 Subject: [PATCH] Define DYNLIB_NAME on OpenBSD.
 
 ---
  src/vbox/vbox_XPCOMCGlue.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
 index e7e9c37..63470ae 100644
 --- a/src/vbox/vbox_XPCOMCGlue.c
 +++ b/src/vbox/vbox_XPCOMCGlue.c
 @@ -48,7 +48,7 @@
  
 /***
  *   Defined Constants And Macros 
   *
  
 ***/
 -#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || 
 defined(__FreeBSD__)
 +#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || 
 defined(__FreeBSD__) || defined(__OpenBSD__)
  # define DYNLIB_NAMEVBoxXPCOMC.so
  #elif defined(__APPLE__)
  # define DYNLIB_NAMEVBoxXPCOMC.dylib

  This one is a no-brainer, ACK 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] build: improved handling of execinfo.h, BSD net/if.h

2012-09-06 Thread Daniel Veillard
On Wed, Sep 05, 2012 at 04:39:28PM -0600, Eric Blake wrote:
 FreeBSD and OpenBSD have a net/if.h that is not self-contained;
 and mingw lacks the header altogether.  But gnulib has just taken
 care of that for us, so we might as well simplify our code.  In
 the process, I got a syntax-check failure if we don't also take
 the gnulib execinfo module.
 
 * .gnulib: Update to latest, for execinfo and net_if.
 * bootstrap.conf (gnulib_modules): Add execinfo and net_if modules.
 * configure.ac: Let gnulib check for headers.  Simplify check for
 'struct ifreq', while also including enough prereq headers.
 * src/internal.h (IF_NAMESIZE): Drop, now that gnulib guarantees it.
 * src/nwfilter/nwfilter_learnipaddr.h: Use correct header for
 IF_NAMESIZE.
 * src/util/virnetdev.c (includes): Assume net/if.h exists.
 * src/util/virnetdevbridge.c (includes): Likewise.
 * src/util/virnetdevtap.c (includes): Likewise.
 * src/util/logging.c (includes): Assume execinfo.h exists.
 (virLogStackTraceToFd): Handle gnulib's fallback implementation.
 ---
 
 Successfully tested on Fedora and FreeBSD; I'm still trying to also
 test a cross-compile to mingw.  Gnulib changes amount to:
 
 * .gnulib 271dd74...440a1db (36):
net_if: new module
readutmp: fix non-portable UT_PID use
update from texinfo
fts: reduce two or more trailing slashes to just one, usually
fts: when there is no risk of overlap, use memcpy, not memmove
autoupdate
autoupdate
manywarnings: update the list of all warnings
* lib/stdbool.in.h (_Bool) [__cplusplus]: bool, not _Bool.
stdbool: be more compatible with mixed C/C++ compiles
revert last change: it was not needed
tests: test-vc-list-files-git.sh: skip if git is not available
gnulib-tool: Remove no-op option --no-changelog.
autoupdate
doc: remove fdl-1.2.texi
execinfo: port to FreeBSD
xstrtol.h: avoid _Noreturn is not at beginning of declaration warning
doc: do not use @acronym
stdnoreturn: port to newer GCCs
pipe-filter: fix comment typo
execinfo: new module
extern-inline: support old GCC 'inline'
maint.mk: avoid redundant file name in message
timer-time: fix link order when static linking on glibc
timespec: omit unnecessary AC_C_INLINE
stat-time: omit unnecessary AC_C_INLINE
ignore-value: omit unnecessary AC_C_INLINE
sys_select: avoid 'static inline'
mktime: avoid 'static inline'
autoupdate
gnulib-tool: Improve coding style.
gnulib-tool: Fix indentation.
gnulib-tool: Remove old file names from .cvsignore, .gitignore.
test-parse-datetime: avoid glibc leap-second glitch
autoupdate
gnulib-tool: Fix indentation of generated gnulib-comp.m4 file.
 
  .gnulib |  2 +-
  bootstrap.conf  |  2 ++
  configure.ac| 23 +++
  src/internal.h  |  4 
  src/nwfilter/nwfilter_learnipaddr.h |  2 ++
  src/util/logging.c  | 22 +-
  src/util/virnetdev.c|  4 +---
  src/util/virnetdevbridge.c  |  6 ++
  src/util/virnetdevtap.c |  4 +---
  9 files changed, 25 insertions(+), 44 deletions(-)
 
 diff --git a/.gnulib b/.gnulib
 index 271dd74..440a1db 16
 --- a/.gnulib
 +++ b/.gnulib
 @@ -1 +1 @@
 -Subproject commit 271dd74fdf54ec2a03e73a5173b0b5697f6088f1
 +Subproject commit 440a1dbe523e37f206252cb034c3a62f26867e42
 diff --git a/bootstrap.conf b/bootstrap.conf
 index 7fefb69..2847c0b 100644
 --- a/bootstrap.conf
 +++ b/bootstrap.conf
 @@ -38,6 +38,7 @@ count-one-bits
  crypto/md5
  dirname-lgpl
  environ
 +execinfo
  fclose
  fcntl
  fcntl-h
 @@ -70,6 +71,7 @@ manywarnings
  mkstemp
  mkstemps
  mktempd
 +net_if
  netdb
  nonblocking
  openpty
 diff --git a/configure.ac b/configure.ac
 index cb91e7d..47a72b9 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -186,8 +186,7 @@ LIBS=$old_libs
  dnl Availability of various common headers (non-fatal if missing).
  AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
 -  sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h \
 -  net/if.h execinfo.h])
 +  sys/un.h sys/syscall.h netinet/tcp.h ifaddrs.h libtasn1.h])
 
  dnl We need to decide at configure time if libvirt will use real atomic
  dnl operations (lock free) or emulated ones with a mutex.
 @@ -245,20 +244,12 @@ AM_CONDITIONAL([WITH_ATOMIC_OPS_PTHREAD],[test 
 $atomic_ops = pthread])
  AC_MSG_RESULT([$atomic_ops])
 
 
 -
 -AC_MSG_CHECKING([for struct ifreq in net/if.h])
 -AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
 -   [[
 - #include net/if.h
 -   ]],
 -   [[
 - struct ifreq ifr;
 -   ]])],[
 - AC_DEFINE([HAVE_STRUCT_IFREQ],[],[Defined if struct ifreq existsin 
 net/if.h])
 - AC_MSG_RESULT([yes])
 -   ],[
 - AC_MSG_RESULT([yes])
 -   ])
 +AC_CHECK_TYPE([struct ifreq],
 +  [AC_DEFINE([HAVE_STRUCT_IFREQ],[1],
 +[Defined if struct 

Re: [libvirt] Libvir JNA report SIGSEGV

2012-09-06 Thread Daniel Veillard
On Wed, Sep 05, 2012 at 08:59:07AM +, Benjamin Wang (gendwang) wrote:
 Hi,
   I try to verify the JNA with concurrent situation but meet some problems. 
 The following is my example code:
 public static void testcase1() throws LibvirtException
 {
 Connect conn=null;
 Connect conn1=null;
 
 //connect to the hypervisor
 conn = new 
 Connect(esx://10.74.125.68:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 System.out.println(conn.getVersion());
 
 //connect to the hypervisor
 conn1 = new 
 Connect(esx://10.74.125.90:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 System.out.println(conn1.getVersion());
 
 
 while(true)
 {
 int[] array = new int[1];
 Long version = conn.getVersion();
 Long version1 = conn1.getVersion();
 
 try
 {
  Thread.sleep(1000);
 }
 catch(Exception e)
 {
 }
 }
 }
 
 When I add line int[] array = new int[1], then the following error 
 will be generated very quickly:
 # An unexpected error has been detected by Java Runtime Environment:
 #
 #  SIGSEGV (0xb) at pc=0x003f9b07046e, pid=30049, tid=1109510464
 #
 # Java VM: OpenJDK 64-Bit Server VM (1.6.0-b09 mixed mode linux-amd64)
 # Problematic frame:
 # C  [libc.so.6+0x7046e]
 #
 # An error report file with more information is saved as:
 
 I have tried to write the similar code as following. It works well.
 static void virXenBasic_TC001(void)
 {
 virConnectPtr conn = NULL;
 virConnectPtr conn1 = NULL;
 unsigned long version = 0;
 unsigned long version1 = 0;
 char *hostname = NULL;
 
 conn = virConnectOpenAuth(esx://10.74.125.21/?no_verify=1, 
 virConnectAuthPtrDefault, 0);
 if (conn == NULL) {
 fprintf(stderr, Failed to open connection to qemu:///system\n);
 return;
 }
 
 conn1 = virConnectOpenAuth(esx://192.168.119.40/?no_verify=1, 
 virConnectAuthPtrDefault, 0);
 if (conn1 == NULL) {
 fprintf(stderr, Failed to open connection to qemu:///system\n);
 return;
 }
 
 while(true)
 {
 hostname = malloc(sizeof(char) * 1);
 virConnectGetVersion(conn, version);
 virConnectGetVersion(conn, version1);
 free(hostname);
 sleep(1);
 }
 return;
 }

Maybe you need to increase the stack or memory size of you java process or
something, that doesn't look related to libvirt at all in my opinion.
Well maybe the bindings fails somewhere at checking for an allocation
error, but is it in JNA ?

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 JNA report SIGSEGV

2012-09-06 Thread Benjamin Wang (gendwang)
Hi,
   The problem only occurs in JNA part. The pure c libvirt works well.  Even If 
I only create a connection outside of the loop, the 
problem can still happen. The following is the easiest problem to reproduce 
this problem

public static void testcase1() throws LibvirtException
{
Connect conn=null;

//connect to the hypervisor
conn = new 
Connect(esx://10.74.125.69:443/?no_verify=1transport=https, new 
ConnectAuthDefault(), 0);

while(true)
{
int[] array = new int[1];

try
{
Thread.sleep(1000);
}
catch(Exception e){}
}
}

B.R.
Benjamin Wang

-Original Message-
From: Daniel Veillard [mailto:veill...@redhat.com] 
Sent: 2012年9月6日 15:49
To: Benjamin Wang (gendwang)
Cc: libvir-list@redhat.com; Yang Zhou (yangzho)
Subject: Re: [libvirt] Libvir JNA report SIGSEGV

On Wed, Sep 05, 2012 at 08:59:07AM +, Benjamin Wang (gendwang) wrote:
 Hi,
   I try to verify the JNA with concurrent situation but meet some problems. 
 The following is my example code:
 public static void testcase1() throws LibvirtException
 {
 Connect conn=null;
 Connect conn1=null;
 
 //connect to the hypervisor
 conn = new 
 Connect(esx://10.74.125.68:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 System.out.println(conn.getVersion());
 
 //connect to the hypervisor
 conn1 = new 
 Connect(esx://10.74.125.90:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 System.out.println(conn1.getVersion());
 
 
 while(true)
 {
 int[] array = new int[1];
 Long version = conn.getVersion();
 Long version1 = conn1.getVersion();
 
 try
 {
  Thread.sleep(1000);
 }
 catch(Exception e)
 {
 }
 }
 }
 
 When I add line int[] array = new int[1], then the following error 
 will be generated very quickly:
 # An unexpected error has been detected by Java Runtime Environment:
 #
 #  SIGSEGV (0xb) at pc=0x003f9b07046e, pid=30049, tid=1109510464 # 
 # Java VM: OpenJDK 64-Bit Server VM (1.6.0-b09 mixed mode linux-amd64) 
 # Problematic frame:
 # C  [libc.so.6+0x7046e]
 #
 # An error report file with more information is saved as:
 
 I have tried to write the similar code as following. It works well.
 static void virXenBasic_TC001(void)
 {
 virConnectPtr conn = NULL;
 virConnectPtr conn1 = NULL;
 unsigned long version = 0;
 unsigned long version1 = 0;
 char *hostname = NULL;
 
 conn = virConnectOpenAuth(esx://10.74.125.21/?no_verify=1, 
 virConnectAuthPtrDefault, 0);
 if (conn == NULL) {
 fprintf(stderr, Failed to open connection to qemu:///system\n);
 return;
 }
 
 conn1 = virConnectOpenAuth(esx://192.168.119.40/?no_verify=1, 
 virConnectAuthPtrDefault, 0);
 if (conn1 == NULL) {
 fprintf(stderr, Failed to open connection to qemu:///system\n);
 return;
 }
 
 while(true)
 {
 hostname = malloc(sizeof(char) * 1);
 virConnectGetVersion(conn, version);
 virConnectGetVersion(conn, version1);
 free(hostname);
 sleep(1);
 }
 return;
 }

Maybe you need to increase the stack or memory size of you java process or 
something, that doesn't look related to libvirt at all in my opinion.
Well maybe the bindings fails somewhere at checking for an allocation error, 
but is it in JNA ?

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] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Wido den Hollander

Hi,

At the CloudStack project we are switching to Maven for building and 
resolving external dependencies.


In the central Maven repository [0] the latest version of libvirt-java 
is however 0.4.7


Could 0.4.8 be uploaded to this repository?

Thank you,

Wido

[0]: http://search.maven.org/#search|ga|1|org.libvirt

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


Re: [libvirt] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 10:18:22AM +0200, Wido den Hollander wrote:
 Hi,
 
 At the CloudStack project we are switching to Maven for building and
 resolving external dependencies.
 
 In the central Maven repository [0] the latest version of
 libvirt-java is however 0.4.7
 
 Could 0.4.8 be uploaded to this repository?
 
 Thank you,
 
 Wido
 
 [0]: http://search.maven.org/#search|ga|1|org.libvirt

  it's maven which should fetch data from libvirt.org
and i though I had updated everything as needed:

   http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/
   http://libvirt.org/maven2/org/libvirt/libvirt/maven-metadata-local.xml

 if you can get an idea why it is not fetching then I will fix,
but I have tried to set everything up, and didn't got feedback that
it was broken or anything,

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] Compile libvirt on Solaris

2012-09-06 Thread Daniel P. Berrange
On Thu, Sep 06, 2012 at 03:22:12PM +0800, Daniel Veillard wrote:
 On Tue, Sep 04, 2012 at 04:26:55AM +, Yang Zhou (yangzho) wrote:
  Hi Experts,
  
  I am compiling libvirt 0.9.9 on Solaris 9. But got following errors when 
  run ./configure --with-esx --with-qemu
  ---
  checking for library containing dlopen... -ldl
  checking for xen_vm_start in -lxenserver... no
  checking for libxl_domain_create_new in -lxenlight... no
  checking for xs_read in -lxenstore... no
  checking linux/kvm.h usability... no
  checking linux/kvm.h presence... no
  checking for linux/kvm.h... no
  checking for shell that supports  redirection... /bin/sh
  checking linux/param.h usability... no
  checking linux/param.h presence... no
  checking for linux/param.h... no
  configure: error: You must install kernel-headers in order to compile 
  libvirt with QEMU or LXC support
  bash-2.05$
  
  
  After look at configure, it's found the headers of linux/param.h,
  linux/sockios.h. linux/if_bridge.h and linux/if_tun.h are
  required. Obviously these files are missing on Solaris platform. Anybody
  can help how to solve this issue?
 
   I'm not sure we still have an active maintainer on Solaris, John Levon
 didn't posted here for ages ...

Even then, he only attempted to have the legacy Xen driver work on
Solaris, never the QEMU driver.

So basically if someone wants the QEMU driver to work on Solaris, they'll
need to go through and figure out all the non-portable bits and send us
patches to fix them.

IIRC, this particular kernel-headers message is because we need to be
able to create  pass TAP devices, and configure bridge devices. This
will need to be ported to Solaris' interfaces since this stuff is
non-portable

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] Compile libvirt on Solaris

2012-09-06 Thread Yang Zhou (yangzho)
Thanks for your answer! I realized actually I don't need to compile QEMU driver 
because the libvirt client is using Remote driver to talk with libvirtd and 
then libvirtd will call QUME driver in KVM hypervisor. So I removed the 
--with-qume and trying compiling again only with --with-esx. This time the 
error happens on la symbols as followings:

../src/conf/nwfilter_conf.h:600: warning: parameter has incomplete type
  CCLD   libvirt_driver_security.la
  CCLD   libvirt.la
ld: fatal: libvirt.syms: 1616: symbol `virEventAddHandle' is already defined in 
file: libvirt.syms
collect2: ld returned 1 exit status
*** Error code 1
The following command caused the error:
echo   CCLD   libvirt.la;/bin/bash ../libtool --silent --tag=CC
--mode=link gcc -std=gnu99 -DIN_LIBVIRT 
-I/export/home/yangzhou/hypervisor/libxml2/include/libxml2  
-Wall -W -Wformat-y2k -Wformat-security -Winit-self -Wunused 
-Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith 
-Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return 
-Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes 
-Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute 
-Wredundant-decls -Wnested-externs -Winline -Winvalid-pch 
-Wdisabled-optimization -Wpacked-bitfield-compat -Wmultichar 
-Wdeprecated-declarations -Wdiv-by-zero -Wendif-labels -Wextra 
-Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 
-Wmultichar -Wno-sign-compare -Wno-format-nonliteral -Wp,-D_FORTIFY_SOURCE=2 
-fexceptions -fasynchronous-unwind-tables -funit-at-a-time  

  -g -O2 -Wl,-M -Wl,libvirt.syms  -version-info 9:9:9  -Wl,-z -Wl,nodelete  
-o libvirt.la -rpath /export/home/yangzhou/hypervisor/libvirt/lib
libvirt_util.la libvirt_conf.la  libvirt_cpu.la libvirt_vmx.la   
libvirt_driver.la libvirt_driver_test.la libvirt_driver_remote.la  
libvirt_driver_vmware.la libvirt_driver_vbox.la   libvirt_driver_esx.la 
libvirt_driver_security.la  ../gnulib/lib/libgnu.la  
-L/export/home/yangzhou/hypervisor/libxml2/lib -lxml2 -lpthread -lz -liconv -lm 
-lsocket -lnsl-lnsl -lintl
make: Fatal error: Command failed for target `libvirt.la'
Current working directory /export/home/tools/libvirt/src
*** Error code 1
make: Fatal error: Command failed for target `all'
Current working directory /export/home/tools/libvirt/src
*** Error code 1
The following command caused the error:
fail= failcom='exit 1'; \
for f in x $MAKEFLAGS; do \
  case $f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
  esac; \
done; \
dot_seen=no; \
target=`echo all-recursive | sed s/-recursive//`; \
list='gnulib/lib include src daemon tools docs gnulib/tests  python tests po 
examples/domain-events/events-c examples/hellolibvirt  examples/dominfo 
examples/domsuspend examples/python examples/apparmor  examples/xml/nwfilter 
examples/openauth examples/systemtap'; for subdir in $list; do \
  echo Making $target in $subdir; \
  if test $subdir = .; then \
dot_seen=yes; \
local_target=$target-am; \
  else \
local_target=$target; \
  fi; \
  (CDPATH=${ZSH_VERSION+.}:  cd $subdir  make  $local_target) \
  || eval $failcom; \
done; \
if test $dot_seen = no; then \
  make  $target-am || exit 1; \
fi; test -z $fail
make: Fatal error: Command failed for target `all-recursive'
Current working directory /export/home/tools/libvirt
*** Error code 1
make: Fatal error: Command failed for target `all'
bash-3.00#
-

It looks like the symbols are duplicated in ./src/libvirt.la. So I tried to 
remove duplicated symbols manually and tried the make again. Then new errors 
happened as followings.

bash-3.00# make
make  all-recursive
Making all in gnulib/lib
make  all-recursive
Making all in include
Making all in libvirt
Making all in src
  GENlibvirt.def
make  all-am
  CCLD   libvirt.la
Undefined   first referenced
 symbol in file
networkNotifyActualDevice   libvirt.syms
networkAllocateActualDevice libvirt.syms
networkGetNetworkAddresslibvirt.syms
networkBuildDhcpDaemonCommandLine   libvirt.syms
networkReleaseActualDevice  libvirt.syms
ld: warning: Symbol referencing errors
  CC libvirt_qemu_la-libvirt-qemu.lo
  CCLD   libvirt-qemu.la
Undefined   first referenced
 symbol in file
_fini   
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/crti.o  (symbol has no 

Re: [libvirt] Libvir JNA report SIGSEGV

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 07:53:24AM +, Benjamin Wang (gendwang) wrote:
 Hi,
The problem only occurs in JNA part. The pure c libvirt works well.  Even 
 If I only create a connection outside of the loop, the 
 problem can still happen. The following is the easiest problem to reproduce 
 this problem
 
 public static void testcase1() throws LibvirtException
 {
 Connect conn=null;
 
 //connect to the hypervisor
 conn = new 
 Connect(esx://10.74.125.69:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 
 while(true)
 {
   int[] array = new int[1];
   
   try
   {
   Thread.sleep(1000);
   }
   catch(Exception e){}
 }
 }

  Then it's a java bug. The loop doesn't call or use libvirt in any way.
If it crashes in the loop it's java crashing to me !

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 JNA report SIGSEGV

2012-09-06 Thread Benjamin Wang (gendwang)
Hi,
  Actually I also did another test as following. When I comment the new 
Connet, the program works well. So this is the problem related to
Libvirt JNA. If I manually run the garbage collection for this program, it 
still works well. But if I run the garbage collection for the last problem,
It will crash. I guess this problem is caused by ConnectAuth callback. When 
garbage collection is executed, the callback memory is moved.

B.R.
Benjamin Wang


 public static void testcase1() throws LibvirtException
 { 
 while(true)
 {
   int[] array = new int[1];
   
   try
   {
   Thread.sleep(1000);
   }
   catch(Exception e){}
 }
 }
-Original Message-
From: Daniel Veillard [mailto:veill...@redhat.com] 
Sent: 2012年9月6日 16:53
To: Benjamin Wang (gendwang)
Cc: libvir-list@redhat.com
Subject: Re: [libvirt] Libvir JNA report SIGSEGV

On Thu, Sep 06, 2012 at 07:53:24AM +, Benjamin Wang (gendwang) wrote:
 Hi,
The problem only occurs in JNA part. The pure c libvirt works well.  
 Even If I only create a connection outside of the loop, the problem 
 can still happen. The following is the easiest problem to reproduce 
 this problem
 
 public static void testcase1() throws LibvirtException
 {
 Connect conn=null;
 
 //connect to the hypervisor
 conn = new 
 Connect(esx://10.74.125.69:443/?no_verify=1transport=https, new 
 ConnectAuthDefault(), 0);
 
 while(true)
 {
   int[] array = new int[1];
   
   try
   {
   Thread.sleep(1000);
   }
   catch(Exception e){}
 }
 }

  Then it's a java bug. The loop doesn't call or use libvirt in any way.
If it crashes in the loop it's java crashing to me !

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] [PATCHv6 0/2] Implementation of virConnectListAllDomains() for esx and hyperv

2012-09-06 Thread Peter Krempa

On 09/06/12 07:24, Daniel Veillard wrote:

On Fri, Aug 31, 2012 at 05:36:51PM +0200, Peter Krempa wrote:

Yet another respin updated and rebased to current head.

Both drivers are compile tested but I don't have the infrastructure do a
functional test.

Peter Krempa (2):
   hyperv: Add implementation for virConnectListAllDomains()
   esx: Add implementation for virConnectListAllDomains()

  src/esx/esx_driver.c   | 194 +
  src/hyperv/hyperv_driver.c | 135 +++
  2 files changed, 329 insertions(+)


   I was hoping to see feedback on actual users, but since we are at v6
and nobody replied, let's push them and see

   ACK,


Yep, let's just test it in the wild :). I corrected a bug that would 
create empty lists on ESX if some filters were used that I found during 
a last self-review and pushed the series. Thanks.


Peter



Daniel



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


[libvirt] [PATCH v2 0/9] improve virBitmap

2012-09-06 Thread Hu Tao
In many places we store bitmap info in a chunk of data
(pointed to by a char *), and have redundant codes to
set/unset bits. This series extends virBitmap, and convert
those codes to use virBitmap.

changes:

v2:
  - fix bug in qemuSetupCgroupForEmulator
  - new function virBitmapNextSetBit
  - virBitmapcmp - virBitmapEqual
  - virBitmap: store bits in little endian format
  - some improvements of virBitmap
  - fix some memory leaks

Hu Tao (9):
  fix bug in qemuSetupCgroupForEmulator
  New functions for virBitmap
  use virBitmap to store cpupin info
  use virBitmap to store cpu affinity info
  use virBitmap to store numa nodemask info.
  use virBitmap to store cpumask info.
  use virBitmap to store cells' cpumask info.
  use virBitmap to store nodeinfo.
  remove virDomainCpuSetFormat and virDomainCpuSetParse

 .gitignore   |1 +
 src/conf/cpu_conf.c  |   17 +-
 src/conf/cpu_conf.h  |3 +-
 src/conf/domain_conf.c   |  392 ++---
 src/conf/domain_conf.h   |   18 +-
 src/libvirt_private.syms |   14 +-
 src/lxc/lxc_controller.c |   56 ++---
 src/nodeinfo.c   |   26 +--
 src/nodeinfo.h   |6 +-
 src/parallels/parallels_driver.c |5 +-
 src/qemu/qemu_cgroup.c   |   18 +-
 src/qemu/qemu_cgroup.h   |2 +-
 src/qemu/qemu_command.c  |   43 +---
 src/qemu/qemu_driver.c   |  168 +++---
 src/qemu/qemu_process.c  |  141 
 src/test/test_driver.c   |5 +-
 src/util/bitmap.c|  451 +-
 src/util/bitmap.h|   34 +++
 src/util/processinfo.c   |   36 +--
 src/util/processinfo.h   |9 +-
 src/vmx/vmx.c|   36 +--
 tests/Makefile.am|7 +-
 tests/cpuset |2 +-
 tests/virbitmaptest.c|  233 
 24 files changed, 1034 insertions(+), 689 deletions(-)
 create mode 100644 tests/virbitmaptest.c

-- 
1.7.10.2

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


[libvirt] [PATCH v2 3/9] use virBitmap to store cpupin info

2012-09-06 Thread Hu Tao
---
 src/conf/domain_conf.c   |  148 +++---
 src/conf/domain_conf.h   |6 +-
 src/libvirt_private.syms |1 +
 src/qemu/qemu_cgroup.c   |3 +-
 src/qemu/qemu_driver.c   |   29 +
 src/qemu/qemu_process.c  |   21 ---
 6 files changed, 81 insertions(+), 127 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8952b69..b07b6b7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -52,6 +52,7 @@
 #include netdev_bandwidth_conf.h
 #include netdev_vlan_conf.h
 #include device_conf.h
+#include bitmap.h
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -1510,10 +1511,9 @@ virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int 
nvcpupin)
 for (i = 0; i  nvcpupin; i++) {
 if (VIR_ALLOC(ret[i])  0)
 goto no_memory;
-if (VIR_ALLOC_N(ret[i]-cpumask, VIR_DOMAIN_CPUMASK_LEN)  0)
-goto no_memory;
 ret[i]-vcpuid = src[i]-vcpuid;
-memcpy(ret[i]-cpumask, src[i]-cpumask, VIR_DOMAIN_CPUMASK_LEN);
+if ((ret[i]-cpumask = virBitmapCopy(src[i]-cpumask)) == NULL)
+goto no_memory;
 }
 
 return ret;
@@ -1522,7 +1522,7 @@ no_memory:
 if (ret) {
 for ( ; i = 0; --i) {
 if (ret[i]) {
-VIR_FREE(ret[i]-cpumask);
+virBitmapFree(ret[i]-cpumask);
 VIR_FREE(ret[i]);
 }
 }
@@ -1534,8 +1534,17 @@ no_memory:
 }
 
 void
-virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr *def,
-int nvcpupin)
+virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def)
+{
+if (def) {
+virBitmapFree(def-cpumask);
+VIR_FREE(def);
+}
+}
+
+void
+virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def,
+ int nvcpupin)
 {
 int i;
 
@@ -1543,8 +1552,7 @@ virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr *def,
 return;
 
 for(i = 0; i  nvcpupin; i++) {
-VIR_FREE(def[i]-cpumask);
-VIR_FREE(def[i]);
+virDomainVcpuPinDefFree(def[i]);
 }
 
 VIR_FREE(def);
@@ -1668,7 +1676,9 @@ void virDomainDefFree(virDomainDefPtr def)
 
 virCPUDefFree(def-cpu);
 
-virDomainVcpuPinDefFree(def-cputune.vcpupin, def-cputune.nvcpupin);
+virDomainVcpuPinDefArrayFree(def-cputune.vcpupin, def-cputune.nvcpupin);
+
+virDomainVcpuPinDefFree(def-cputune.emulatorpin);
 
 VIR_FREE(def-numatune.memory.nodemask);
 
@@ -8025,12 +8035,8 @@ virDomainVcpuPinDefParseXML(const xmlNodePtr node,
 char *set = tmp;
 int cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
 
-if (VIR_ALLOC_N(def-cpumask, cpumasklen)  0) {
-virReportOOMError();
-goto error;
-}
-if (virDomainCpuSetParse(set, 0, def-cpumask,
- cpumasklen)  0)
+if (virBitmapParse(set, 0, def-cpumask,
+   cpumasklen)  0)
goto error;
 VIR_FREE(tmp);
 } else {
@@ -8465,18 +8471,11 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 goto error;
 }
 
-if (VIR_ALLOC(def-cputune.emulatorpin)  0) {
-goto no_memory;
-}
+def-cputune.emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt,
+   def-maxvcpus, 
1);
 
-virDomainVcpuPinDefPtr emulatorpin = NULL;
-emulatorpin = virDomainVcpuPinDefParseXML(nodes[0], ctxt,
-  def-maxvcpus, 1);
-
-if (!emulatorpin)
+if (!def-cputune.emulatorpin)
 goto error;
-
-def-cputune.emulatorpin = emulatorpin;
 }
 VIR_FREE(nodes);
 
@@ -11093,34 +11092,6 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
 return NULL;
 }
 
-static char *bitmapFromBytemap(unsigned char *bytemap, int maplen)
-{
-char *bitmap = NULL;
-int i;
-
-if (VIR_ALLOC_N(bitmap, VIR_DOMAIN_CPUMASK_LEN)  0) {
-virReportOOMError();
-goto cleanup;
-}
-
-/* Reset bitmap to all 0s. */
-for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++)
-bitmap[i] = 0;
-
-/* Convert bitmap (bytemap) to bitmap, which is byte map? */
-for (i = 0; i  maplen; i++) {
-int cur;
-
-for (cur = 0; cur  8; cur++) {
-if (bytemap[i]  (1  cur))
-bitmap[i * 8 + cur] = 1;
-}
-}
-
-cleanup:
-return bitmap;
-}
-
 int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list,
 int *nvcpupin,
 unsigned char *cpumap,
@@ -11128,20 +11099,21 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr 
**vcpupin_list,
 int vcpu)
 {
 virDomainVcpuPinDefPtr vcpupin = NULL;
-char *cpumask = NULL;
 
 if (!vcpupin_list)
 return -1;
 
-if ((cpumask = bitmapFromBytemap(cpumap, maplen)) == NULL)
-return -1;
-
 vcpupin = 

[libvirt] [PATCH v2 6/9] use virBitmap to store cpumask info.

2012-09-06 Thread Hu Tao
---
 src/conf/domain_conf.c   |   24 +---
 src/conf/domain_conf.h   |3 +--
 src/lxc/lxc_controller.c |   14 ++
 src/parallels/parallels_driver.c |3 +--
 src/qemu/qemu_process.c  |   12 +---
 src/test/test_driver.c   |5 -
 src/vmx/vmx.c|   36 ++--
 tests/cpuset |2 +-
 8 files changed, 45 insertions(+), 54 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a02b805..7321268 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8391,14 +8391,12 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 if (def-placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
 tmp = virXPathString(string(./vcpu[1]/@cpuset), ctxt);
 if (tmp) {
-char *set = tmp;
-def-cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
-if (VIR_ALLOC_N(def-cpumask, def-cpumasklen)  0) {
-goto no_memory;
-}
-if (virDomainCpuSetParse(set, 0, def-cpumask,
- def-cpumasklen)  0)
+if (virBitmapParse(tmp, 0, def-cpumask,
+   VIR_DOMAIN_CPUMASK_LEN)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   %s, _(topology cpuset syntax error));
 goto error;
+}
 VIR_FREE(tmp);
 }
 }
@@ -13007,7 +13005,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 unsigned char *uuid;
 char uuidstr[VIR_UUID_STRING_BUFLEN];
 const char *type = NULL;
-int n, allones = 1;
+int n;
 int i;
 bool blkio = false;
 
@@ -13136,17 +13134,13 @@ virDomainDefFormatInternal(virDomainDefPtr def,
   /memoryBacking\n, NULL);
 }
 
-for (n = 0 ; n  def-cpumasklen ; n++)
-if (def-cpumask[n] != 1)
-allones = 0;
-
 virBufferAddLit(buf,   vcpu);
 virBufferAsprintf(buf,  placement='%s',
   
virDomainCpuPlacementModeTypeToString(def-placement_mode));
-if (!allones) {
+
+if (def-cpumask  !virBitmapIsAllSet(def-cpumask)) {
 char *cpumask = NULL;
-if ((cpumask =
- virDomainCpuSetFormat(def-cpumask, def-cpumasklen)) == NULL)
+if ((cpumask = virBitmapFormat(def-cpumask)) == NULL)
 goto cleanup;
 virBufferAsprintf(buf,  cpuset='%s', cpumask);
 VIR_FREE(cpumask);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 975c565..042b518 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1614,8 +1614,7 @@ struct _virDomainDef {
 unsigned short vcpus;
 unsigned short maxvcpus;
 int placement_mode;
-int cpumasklen;
-char *cpumask;
+virBitmapPtr cpumask;
 
 struct {
 unsigned long shares;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index acaed60..0c5dc39 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -490,9 +490,9 @@ static int 
virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
  */
 static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
 {
-int i, hostcpus, maxcpu = CPU_SETSIZE;
+int hostcpus, maxcpu = CPU_SETSIZE;
 virNodeInfo nodeinfo;
-virBitmapPtr cpumap;
+virBitmapPtr cpumap, cpumapToSet;
 
 VIR_DEBUG(Setting CPU affinity);
 
@@ -509,12 +509,10 @@ static int 
virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
 if (!cpumap)
 return -1;
 
+cpumapToSet = cpumap;
+
 if (ctrl-def-cpumask) {
-/* XXX why don't we keep 'cpumask' in the libvirt cpumap
- * format to start with ?!?! */
-for (i = 0 ; i  maxcpu  i  ctrl-def-cpumasklen ; i++)
-if (ctrl-def-cpumask[i])
-ignore_value(virBitmapSetBit(cpumap, i));
+cpumapToSet = ctrl-def-cpumask;
 } else {
 /* You may think this is redundant, but we can't assume libvirtd
  * itself is running on all pCPUs, so we need to explicitly set
@@ -527,7 +525,7 @@ static int 
virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
  * so use '0' to indicate our own process ID. No threads are
  * running at this point
  */
-if (virProcessInfoSetAffinity(0 /* Self */, cpumap)  0) {
+if (virProcessInfoSetAffinity(0 /* Self */, cpumapToSet)  0) {
 virBitmapFree(cpumap);
 return -1;
 }
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 0d8dcb8..66456d1 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -1407,8 +1407,7 @@ parallelsApplyChanges(virDomainObjPtr dom, 
virDomainDefPtr new)
 return -1;
 }
 
-if (old-cpumasklen != new-cpumasklen ||
-(memcmp(old-cpumask, new-cpumask, old-cpumasklen))) {
+if (!virBitmapEqual(old-cpumask, 

[libvirt] [PATCH v2 1/9] fix bug in qemuSetupCgroupForEmulator

2012-09-06 Thread Hu Tao
Should not return 0 when failed to setup cgroup.
---
 src/qemu/qemu_cgroup.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 5b42793..c95cc77 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -691,13 +691,15 @@ int qemuSetupCgroupForEmulator(struct qemud_driver 
*driver,
 }
 
 if (def-cputune.emulatorpin 
-qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) 
-qemuSetupCgroupEmulatorPin(cgroup_emulator, def-cputune.emulatorpin) 
 0)
+qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
+rc = qemuSetupCgroupEmulatorPin(cgroup_emulator, 
def-cputune.emulatorpin);
+if (rc  0)
 goto cleanup;
+}
 
 if (period || quota) {
 if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
-if (qemuSetupCgroupVcpuBW(cgroup_emulator, period, quota)  0)
+if ((rc = qemuSetupCgroupVcpuBW(cgroup_emulator, period, quota))  
0)
 goto cleanup;
 }
 }
-- 
1.7.10.2

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


[libvirt] [PATCH v2 2/9] New functions for virBitmap

2012-09-06 Thread Hu Tao
In many places we store bitmap info in a chunk of data
(pointed to by a char *), and have redundant codes to
set/unset bits. This patch extends virBitmap, and convert
those codes to use virBitmap in subsequent patches.
---
 .gitignore   |1 +
 src/libvirt_private.syms |   11 ++
 src/util/bitmap.c|  451 +-
 src/util/bitmap.h|   34 
 tests/Makefile.am|7 +-
 tests/virbitmaptest.c|  233 
 6 files changed, 731 insertions(+), 6 deletions(-)
 create mode 100644 tests/virbitmaptest.c

diff --git a/.gitignore b/.gitignore
index 5041ddf..4851a83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,6 +156,7 @@
 /tests/utiltest
 /tests/viratomictest
 /tests/virauthconfigtest
+/tests/virbitmaptest
 /tests/virbuftest
 /tests/virdrivermoduletest
 /tests/virhashtest
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65067d6..028b65c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -7,11 +7,22 @@
 
 # bitmap.h
 virBitmapAlloc;
+virBitmapAllocFromData;
+virBitmapClearAll;
 virBitmapClearBit;
+virBitmapCopy;
+virBitmapEqual;
+virBitmapFormat;
 virBitmapFree;
 virBitmapGetBit;
+virBitmapIsAllSet;
+virBitmapNextSetBit;
+virBitmapParse;
+virBitmapSetAll;
 virBitmapSetBit;
+virBitmapSize;
 virBitmapString;
+virBitmapToData;
 
 
 # buf.h
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 53a8a38..2ca417a 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -33,11 +33,14 @@
 #include bitmap.h
 #include memory.h
 #include buf.h
+#include util.h
+#include c-ctype.h
 
 
 struct _virBitmap {
-size_t size;
-unsigned long *map;
+size_t size;/* size in bits */
+size_t size2;   /* size in LONGs */
+unsigned long *map; /* bits are stored in little-endian format */
 };
 
 
@@ -76,6 +79,7 @@ virBitmapPtr virBitmapAlloc(size_t size)
 }
 
 bitmap-size = size;
+bitmap-size2 = sz;
 return bitmap;
 }
 
@@ -129,6 +133,12 @@ int virBitmapClearBit(virBitmapPtr bitmap, size_t b)
 return 0;
 }
 
+/* Helper function. caller must ensure b  bitmap-size */
+static bool virBitmapIsSet(virBitmapPtr bitmap, size_t b)
+{
+return !!(bitmap-map[VIR_BITMAP_UNIT_OFFSET(b)]  VIR_BITMAP_BIT(b));
+}
+
 /**
  * virBitmapGetBit:
  * @bitmap: Pointer to bitmap
@@ -145,7 +155,7 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool 
*result)
 if (bitmap-size = b)
 return -1;
 
-*result = !!(bitmap-map[VIR_BITMAP_UNIT_OFFSET(b)]  VIR_BITMAP_BIT(b));
+*result = virBitmapIsSet(bitmap, b);
 return 0;
 }
 
@@ -164,8 +174,7 @@ char *virBitmapString(virBitmapPtr bitmap)
 
 virBufferAddLit(buf, 0x);
 
-sz = (bitmap-size + VIR_BITMAP_BITS_PER_UNIT - 1) /
-  VIR_BITMAP_BITS_PER_UNIT;
+sz = bitmap-size2;
 
 while (sz--) {
 virBufferAsprintf(buf, %0*lx,
@@ -180,3 +189,435 @@ char *virBitmapString(virBitmapPtr bitmap)
 
 return virBufferContentAndReset(buf);
 }
+
+/**
+ * virBitmapFormat:
+ * @bitmap: the bitmap
+ *
+ * This function is the counterpart of virBitmapParse. This function creates
+ * a human-readable string representing the bits in bitmap.
+ *
+ * See virBitmapParse for the format of @str.
+ *
+ * Returns the string on success or NULL otherwise. Caller should call
+ * VIR_FREE to free the string.
+ */
+char *virBitmapFormat(virBitmapPtr bitmap)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+int first = -1;
+int start, cur;
+int ret;
+bool isset;
+
+if (!bitmap)
+return NULL;
+
+cur = 0;
+start = -1;
+while (cur  bitmap-size) {
+ret = virBitmapGetBit(bitmap, cur, isset);
+if (ret != 0)
+goto error;
+else if (isset) {
+if (start == -1)
+start = cur;
+} else if (start != -1) {
+if (!first)
+virBufferAddLit(buf, ,);
+else
+first = 0;
+if (cur == start + 1)
+virBufferAsprintf(buf, %d, start);
+else
+virBufferAsprintf(buf, %d-%d, start, cur - 1);
+start = -1;
+}
+cur++;
+}
+
+if (start != -1) {
+if (!first)
+virBufferAddLit(buf, ,);
+if (cur == start + 1)
+virBufferAsprintf(buf, %d, start);
+else
+virBufferAsprintf(buf, %d-%d, start, cur - 1);
+}
+
+if (virBufferError(buf)) {
+error:
+virBufferFreeAndReset(buf);
+return NULL;
+}
+
+return virBufferContentAndReset(buf);
+}
+
+/**
+ * virBitmapParse:
+ * @str: points to a string representing a human-readable bitmap
+ * @bitmap: a bitmap created from @str
+ * @bitmapSize: the upper limit of num of bits in created bitmap
+ *
+ * This function is the counterpart of virBitmapFormat. This function creates
+ * a bitmap, in which bits are set according to the content of @str.
+ *
+ * @str is a comma 

[libvirt] [PATCH v2 4/9] use virBitmap to store cpu affinity info

2012-09-06 Thread Hu Tao
---
 src/lxc/lxc_controller.c |   23 +
 src/qemu/qemu_driver.c   |   62 -
 src/qemu/qemu_process.c  |   86 --
 src/util/processinfo.c   |   36 ++-
 src/util/processinfo.h   |9 ++---
 5 files changed, 84 insertions(+), 132 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index e5aea11..ac8ce94 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -493,8 +493,7 @@ static int 
virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
 {
 int i, hostcpus, maxcpu = CPU_SETSIZE;
 virNodeInfo nodeinfo;
-unsigned char *cpumap;
-int cpumaplen;
+virBitmapPtr cpumap;
 
 VIR_DEBUG(Setting CPU affinity);
 
@@ -507,37 +506,33 @@ static int 
virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
 
-cpumaplen = VIR_CPU_MAPLEN(maxcpu);
-if (VIR_ALLOC_N(cpumap, cpumaplen)  0) {
-virReportOOMError();
+cpumap = virBitmapAlloc(maxcpu);
+if (!cpumap)
 return -1;
-}
 
 if (ctrl-def-cpumask) {
 /* XXX why don't we keep 'cpumask' in the libvirt cpumap
  * format to start with ?!?! */
 for (i = 0 ; i  maxcpu  i  ctrl-def-cpumasklen ; i++)
 if (ctrl-def-cpumask[i])
-VIR_USE_CPU(cpumap, i);
+ignore_value(virBitmapSetBit(cpumap, i));
 } else {
 /* You may think this is redundant, but we can't assume libvirtd
  * itself is running on all pCPUs, so we need to explicitly set
  * the spawned LXC instance to all pCPUs if no map is given in
  * its config file */
-for (i = 0 ; i  maxcpu ; i++)
-VIR_USE_CPU(cpumap, i);
+virBitmapSetAll(cpumap);
 }
 
-/* We are pressuming we are running between fork/exec of LXC
+/* We are presuming we are running between fork/exec of LXC
  * so use '0' to indicate our own process ID. No threads are
  * running at this point
  */
-if (virProcessInfoSetAffinity(0, /* Self */
-  cpumap, cpumaplen, maxcpu)  0) {
-VIR_FREE(cpumap);
+if (virProcessInfoSetAffinity(0 /* Self */, cpumap)  0) {
+virBitmapFree(cpumap);
 return -1;
 }
-VIR_FREE(cpumap);
+virBitmapFree(cpumap);
 
 return 0;
 }
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bdff4bb..e96c3b8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -92,6 +92,7 @@
 #include virnodesuspend.h
 #include virtime.h
 #include virtypedparam.h
+#include bitmap.h
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -3710,10 +3711,10 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
 virNodeInfo nodeinfo;
 int ret = -1;
 qemuDomainObjPrivatePtr priv;
-bool canResetting = true;
+bool doReset = false;
 int newVcpuPinNum = 0;
 virDomainVcpuPinDefPtr *newVcpuPin = NULL;
-int pcpu;
+virBitmapPtr pcpumap = NULL;
 
 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
   VIR_DOMAIN_AFFECT_CONFIG, -1);
@@ -3749,15 +3750,16 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
 maxcpu = maplen * 8;
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
+
+pcpumap = virBitmapAllocFromData(cpumap, maplen);
+if (!pcpumap)
+goto cleanup;
+
 /* pinning to all physical cpus means resetting,
  * so check if we can reset setting.
  */
-for (pcpu = 0; pcpu  hostcpus; pcpu++) {
-if ((cpumap[pcpu/8]  (1  (pcpu % 8))) == 0) {
-canResetting = false;
-break;
-}
-}
+if (virBitmapIsAllSet(pcpumap))
+doReset = true;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 
@@ -3800,8 +3802,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
 goto cleanup;
 }
 } else {
-if (virProcessInfoSetAffinity(priv-vcpupids[vcpu],
-  cpumap, maplen, maxcpu)  0) {
+if (virProcessInfoSetAffinity(priv-vcpupids[vcpu], pcpumap)  0) {
 virReportError(VIR_ERR_SYSTEM_ERROR,
_(failed to set cpu affinity for vcpu %d),
vcpu);
@@ -3809,7 +3810,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
 }
 }
 
-if (canResetting) {
+if (doReset) {
 if (virDomainVcpuPinDel(vm-def, vcpu)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(failed to delete vcpupin xml of 
@@ -3834,7 +3835,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom,
 
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 
-if (canResetting) {
+if (doReset) {
 if (virDomainVcpuPinDel(persistentDef, vcpu)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(failed to delete vcpupin xml of 
@@ -3874,6 

[libvirt] [PATCH v2 7/9] use virBitmap to store cells' cpumask info.

2012-09-06 Thread Hu Tao
---
 src/conf/cpu_conf.c |   17 ++---
 src/conf/cpu_conf.h |3 ++-
 src/qemu/qemu_command.c |   43 +++
 3 files changed, 15 insertions(+), 48 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 87e9540..9fe93e6 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -83,7 +83,7 @@ virCPUDefFree(virCPUDefPtr def)
 virCPUDefFreeModel(def);
 
 for (i = 0 ; i  def-ncells ; i++) {
-VIR_FREE(def-cells[i].cpumask);
+virBitmapFree(def-cells[i].cpumask);
 VIR_FREE(def-cells[i].cpustr);
 }
 VIR_FREE(def-cells);
@@ -164,11 +164,10 @@ virCPUDefCopy(const virCPUDefPtr cpu)
 copy-cells[i].cellid = cpu-cells[i].cellid;
 copy-cells[i].mem = cpu-cells[i].mem;
 
-if (VIR_ALLOC_N(copy-cells[i].cpumask,
-VIR_DOMAIN_CPUMASK_LEN)  0)
+copy-cells[i].cpumask = virBitmapCopy(cpu-cells[i].cpumask);
+
+if (!copy-cells[i].cpumask)
 goto no_memory;
-memcpy(copy-cells[i].cpumask, cpu-cells[i].cpumask,
-   VIR_DOMAIN_CPUMASK_LEN);
 
 if (!(copy-cells[i].cpustr = strdup(cpu-cells[i].cpustr)))
 goto no_memory;
@@ -454,7 +453,6 @@ virCPUDefParseXML(const xmlNodePtr node,
 
 for (i = 0 ; i  n ; i++) {
 char *cpus, *memory;
-int cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
 int ret, ncpus = 0;
 
 def-cells[i].cellid = i;
@@ -466,11 +464,8 @@ virCPUDefParseXML(const xmlNodePtr node,
 }
 def-cells[i].cpustr = cpus;
 
-if (VIR_ALLOC_N(def-cells[i].cpumask, cpumasklen)  0)
-goto no_memory;
-
-ncpus = virDomainCpuSetParse(cpus, 0, def-cells[i].cpumask,
- cpumasklen);
+ncpus = virBitmapParse(cpus, 0, def-cells[i].cpumask,
+   VIR_DOMAIN_CPUMASK_LEN);
 if (ncpus = 0)
 goto error;
 def-cells_cpus += ncpus;
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 601e208..4e03fd2 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -27,6 +27,7 @@
 # include util.h
 # include buf.h
 # include xml.h
+# include bitmap.h
 
 # define VIR_CPU_VENDOR_ID_LENGTH 12
 
@@ -92,7 +93,7 @@ typedef struct _virCellDef virCellDef;
 typedef virCellDef *virCellDefPtr;
 struct _virCellDef {
int cellid;
-   char *cpumask;  /* CPUs that are part of this node */
+   virBitmapPtr cpumask;   /* CPUs that are part of this node */
char *cpustr;   /* CPUs stored in string form for dumpxml */
unsigned int mem;   /* Node memory in kB */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a83d6de..5fb607f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4260,54 +4260,25 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
 return virBufferContentAndReset(buf);
 }
 
-static void
-qemuBuildNumaCPUArgStr(char *cpumask, virBufferPtr buf)
-{
-int i, first, last;
-int cpuSet = 0;
-
-first = last = 0;
-for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++) {
-if (cpumask[i]) {
-if (cpuSet) {
-last = i;
-} else {
-first = last = i;
-cpuSet = 1;
-}
-} else {
-if (!cpuSet)
-continue;
-if (first == last)
-virBufferAsprintf(buf, %d,, first);
-else
-virBufferAsprintf(buf, %d-%d,, first, last);
-cpuSet = 0;
-}
-}
-
-if (cpuSet) {
-if (first == last)
-virBufferAsprintf(buf, %d,, first);
-else
-virBufferAsprintf(buf, %d-%d,, first, last);
-}
-}
-
 static int
 qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd)
 {
 int i;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
+char *cpumask;
 
 for (i = 0; i  def-cpu-ncells; i++) {
 virCommandAddArg(cmd, -numa);
 virBufferAsprintf(buf, node,nodeid=%d, def-cpu-cells[i].cellid);
 virBufferAddLit(buf, ,cpus=);
-qemuBuildNumaCPUArgStr(def-cpu-cells[i].cpumask, buf);
+cpumask = virBitmapFormat(def-cpu-cells[i].cpumask);
+if (cpumask) {
+virBufferAsprintf(buf, %s, cpumask);
+VIR_FREE(cpumask);
+}
 def-cpu-cells[i].mem = VIR_DIV_UP(def-cpu-cells[i].mem,
 1024) * 1024;
-virBufferAsprintf(buf, mem=%d, def-cpu-cells[i].mem / 1024);
+virBufferAsprintf(buf, ,mem=%d, def-cpu-cells[i].mem / 1024);
 
 if (virBufferError(buf))
 goto error;
-- 
1.7.10.2

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


Re: [libvirt] NFS over RDMA small block DIRECT_IO bug

2012-09-06 Thread Andrew Holway

On Sep 5, 2012, at 4:02 PM, Avi Kivity wrote:

 On 09/04/2012 03:04 PM, Myklebust, Trond wrote:
 On Tue, 2012-09-04 at 11:31 +0200, Andrew Holway wrote:
 Hello.
 
 # Avi Kivity avi(a)redhat recommended I copy kvm in on this. It would also 
 seem relevent to libvirt. #
 
 I have a Centos 6.2 server and Centos 6.2 client.
 
 [root@store ~]# cat /etc/exports 
 /dev/shm
 10.149.0.0/16(rw,fsid=1,no_root_squash,insecure)(I have tried with non 
 tempfs targets also)
 
 
 [root@node001 ~]# cat /etc/fstab 
 store.ibnet:/dev/shm /mnt nfs  
 rdma,port=2050,defaults 0 0
 
 
 I wrote a little for loop one liner that dd'd the centos net install image 
 to a file called 'hello' then checksummed that file. Each iteration uses a 
 different block size.
 
 Non DIRECT_IO seems to work fine. DIRECT_IO with 512byte, 1K and 2K block 
 sizes get corrupted.
 
 
 That is expected behaviour. DIRECT_IO over RDMA needs to be page aligned
 so that it can use the more efficient RDMA READ and RDMA WRITE memory
 semantics (instead of the SEND/RECEIVE channel semantics).
 
 Shouldn't subpage requests fail then?  O_DIRECT block requests fail for
 subsector writes, instead of corrupting your data.

But silent data corruption is so much fun!!

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


[libvirt] [PATCH v2 8/9] use virBitmap to store nodeinfo.

2012-09-06 Thread Hu Tao
---
 src/nodeinfo.c |   26 +++---
 src/nodeinfo.h |6 +++---
 src/qemu/qemu_driver.c |   19 ---
 3 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index e3d4a24..e6b259d 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -737,10 +737,10 @@ cleanup:
  * and max cpu is 7. The map file shows 0-4,6-7. This function parses
  * it and returns cpumap.
  */
-static char *
+static virBitmapPtr
 linuxParseCPUmap(int *max_cpuid, const char *path)
 {
-char *map = NULL;
+virBitmapPtr map = NULL;
 char *str = NULL;
 int max_id = 0, i;
 
@@ -749,20 +749,16 @@ linuxParseCPUmap(int *max_cpuid, const char *path)
 goto error;
 }
 
-if (VIR_ALLOC_N(map, VIR_DOMAIN_CPUMASK_LEN)  0) {
-virReportOOMError();
-goto error;
-}
-if (virDomainCpuSetParse(str, 0, map,
- VIR_DOMAIN_CPUMASK_LEN)  0) {
+if (virBitmapParse(str, 0, map,
+   VIR_DOMAIN_CPUMASK_LEN)  0) {
 goto error;
 }
 
-for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++) {
-if (map[i]) {
-max_id = i;
-}
+i = -1;
+while ((i = virBitmapNextSetBit(map, i))  0) {
+max_id = i;
 }
+
 *max_cpuid = max_id;
 
 VIR_FREE(str);
@@ -770,7 +766,7 @@ linuxParseCPUmap(int *max_cpuid, const char *path)
 
 error:
 VIR_FREE(str);
-VIR_FREE(map);
+virBitmapFree(map);
 return NULL;
 }
 #endif
@@ -909,14 +905,14 @@ int nodeGetMemoryStats(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 #endif
 }
 
-char *
+virBitmapPtr
 nodeGetCPUmap(virConnectPtr conn ATTRIBUTE_UNUSED,
   int *max_id ATTRIBUTE_UNUSED,
   const char *mapname ATTRIBUTE_UNUSED)
 {
 #ifdef __linux__
 char *path;
-char *cpumap;
+virBitmapPtr cpumap;
 
 if (virAsprintf(path, SYSFS_SYSTEM_PATH /cpu/%s, mapname)  0) {
 virReportOOMError();
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index 12090e2..182b0b6 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -46,7 +46,7 @@ int nodeGetCellsFreeMemory(virConnectPtr conn,
int maxCells);
 unsigned long long nodeGetFreeMemory(virConnectPtr conn);
 
-char *nodeGetCPUmap(virConnectPtr conn,
-int *max_id,
-const char *mapname);
+virBitmapPtr nodeGetCPUmap(virConnectPtr conn,
+   int *max_id,
+   const char *mapname);
 #endif /* __VIR_NODEINFO_H__*/
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3340928..d271caf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13482,8 +13482,8 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
  int start_cpu,
  unsigned int ncpus)
 {
-char *map = NULL;
-char *map2 = NULL;
+virBitmapPtr map = NULL;
+virBitmapPtr map2 = NULL;
 int rv = -1;
 int i, id, max_id;
 char *pos;
@@ -13495,6 +13495,7 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
 virTypedParameterPtr ent;
 int param_idx;
 unsigned long long cpu_time;
+bool result;
 
 /* return the number of supported params */
 if (nparams == 0  ncpus != 0)
@@ -13533,7 +13534,9 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
 id = start_cpu + ncpus - 1;
 
 for (i = 0; i = id; i++) {
-if (!map[i]) {
+if (virBitmapGetBit(map, i, result)  0)
+goto cleanup;
+if (!result) {
 cpu_time = 0;
 } else if (virStrToLong_ull(pos, pos, 10, cpu_time)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
@@ -13565,7 +13568,7 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
 
 /* Check that the mapping of online cpus didn't change mid-parse.  */
 map2 = nodeGetCPUmap(domain-conn, max_id, present);
-if (!map2 || memcmp(map, map2, VIR_DOMAIN_CPUMASK_LEN) != 0) {
+if (!map2 || !virBitmapEqual(map, map2)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(the set of online cpus changed while reading));
 goto cleanup;
@@ -13573,7 +13576,9 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
 
 sum_cpu_pos = sum_cpu_time;
 for (i = 0; i = id; i++) {
-if (!map[i])
+if (virBitmapGetBit(map, i, result)  0)
+goto cleanup;
+if (!result)
 cpu_time = 0;
 else
 cpu_time = *(sum_cpu_pos++);
@@ -13591,8 +13596,8 @@ qemuDomainGetPercpuStats(virDomainPtr domain,
 cleanup:
 VIR_FREE(sum_cpu_time);
 VIR_FREE(buf);
-VIR_FREE(map);
-VIR_FREE(map2);
+virBitmapFree(map);
+virBitmapFree(map2);
 return rv;
 }
 
-- 
1.7.10.2

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


[libvirt] [PATCH v2 5/9] use virBitmap to store numa nodemask info.

2012-09-06 Thread Hu Tao
---
 src/conf/domain_conf.c   |   24 +---
 src/conf/domain_conf.h   |2 +-
 src/lxc/lxc_controller.c |   25 
 src/parallels/parallels_driver.c |2 +-
 src/qemu/qemu_cgroup.c   |7 ++---
 src/qemu/qemu_cgroup.h   |2 +-
 src/qemu/qemu_driver.c   |   58 ++
 src/qemu/qemu_process.c  |   52 --
 8 files changed, 65 insertions(+), 107 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b07b6b7..a02b805 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1680,7 +1680,7 @@ void virDomainDefFree(virDomainDefPtr def)
 
 virDomainVcpuPinDefFree(def-cputune.emulatorpin);
 
-VIR_FREE(def-numatune.memory.nodemask);
+virBitmapFree(def-numatune.memory.nodemask);
 
 virSysinfoDefFree(def-sysinfo);
 
@@ -8520,19 +8520,10 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 
 nodeset = virXMLPropString(cur, nodeset);
 if (nodeset) {
-char *set = nodeset;
-int nodemasklen = VIR_DOMAIN_CPUMASK_LEN;
-
-if (VIR_ALLOC_N(def-numatune.memory.nodemask,
-nodemasklen)  0) {
-virReportOOMError();
-goto error;
-}
-
-/* nodeset uses the same syntax as cpuset. */
-if (virDomainCpuSetParse(set, 0,
- def-numatune.memory.nodemask,
- nodemasklen)  0) {
+if (virBitmapParse(nodeset,
+   0,
+   def-numatune.memory.nodemask,
+   VIR_DOMAIN_CPUMASK_LEN)  0) {
 VIR_FREE(nodeset);
 goto error;
 }
@@ -8574,7 +8565,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr 
caps,
 
 /* Ignore 'nodeset' if 'placement' is 'auto' finally */
 if (placement_mode == 
VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_AUTO)
-VIR_FREE(def-numatune.memory.nodemask);
+virBitmapFree(def-numatune.memory.nodemask);
 
 /* Copy 'placement' of numatune to vcpu if its 
'placement'
  * is not specified and 'placement' of numatune is 
specified.
@@ -13242,8 +13233,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 
 if (def-numatune.memory.placement_mode ==
 VIR_DOMAIN_NUMATUNE_MEM_PLACEMENT_MODE_STATIC) {
-nodemask = virDomainCpuSetFormat(def-numatune.memory.nodemask,
- VIR_DOMAIN_CPUMASK_LEN);
+nodemask = virBitmapFormat(def-numatune.memory.nodemask);
 if (nodemask == NULL) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(failed to format nodeset for 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bb3721c..975c565 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1560,7 +1560,7 @@ typedef struct _virDomainNumatuneDef virDomainNumatuneDef;
 typedef virDomainNumatuneDef *virDomainNumatuneDefPtr;
 struct _virDomainNumatuneDef {
 struct {
-char *nodemask;
+virBitmapPtr nodemask;
 int mode;
 int placement_mode; /* enum virDomainNumatuneMemPlacementMode */
 } memory;
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index ac8ce94..acaed60 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -418,20 +418,19 @@ static int 
virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
 
 /* Convert nodemask to NUMA bitmask. */
 nodemask_zero(mask);
-for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; i++) {
-if (ctrl-def-numatune.memory.nodemask[i]) {
-if (i  NUMA_NUM_NODES) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(Host cannot support NUMA node %d), i);
-return -1;
-}
-if (i  maxnode  !warned) {
-VIR_WARN(nodeset is out of range, there is only %d NUMA 
- nodes on host, maxnode);
-warned = true;
-}
-nodemask_set(mask, i);
+i = -1;
+while ((i = virBitmapNextSetBit(ctrl-def-numatune.memory.nodemask, i))  
0) {
+if (i  NUMA_NUM_NODES) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(Host cannot support NUMA node %d), i);
+return -1;
+}
+if (i  maxnode  !warned) {
+VIR_WARN(nodeset is out of range, there is 

[libvirt] [PATCH v2 9/9] remove virDomainCpuSetFormat and virDomainCpuSetParse

2012-09-06 Thread Hu Tao
virBitmap is recommanded to store cpuset info, and
virBitmapFormat/virBitmapParse can do the format/parse
jobs.
---
 src/conf/domain_conf.c   |  196 --
 src/conf/domain_conf.h   |7 --
 src/libvirt_private.syms |2 -
 3 files changed, 205 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7321268..f28fdfa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -40,7 +40,6 @@
 #include uuid.h
 #include util.h
 #include buf.h
-#include c-ctype.h
 #include logging.h
 #include nwfilter_conf.h
 #include storage_file.h
@@ -10848,201 +10847,6 @@ int 
virDomainDefAddImplicitControllers(virDomainDefPtr def)
 return 0;
 }
 
-
-/
- **
- * Parser and converter for the CPUset strings used in libvirt*
- **
- /
-/**
- * virDomainCpuNumberParse
- * @str: pointer to the char pointer used
- * @maxcpu: maximum CPU number allowed
- *
- * Parse a CPU number
- *
- * Returns the CPU number or -1 in case of error. @str will be
- * updated to skip the number.
- */
-static int
-virDomainCpuNumberParse(const char **str, int maxcpu)
-{
-int ret = 0;
-const char *cur = *str;
-
-if (!c_isdigit(*cur))
-return -1;
-
-while (c_isdigit(*cur)) {
-ret = ret * 10 + (*cur - '0');
-if (ret = maxcpu)
-return -1;
-cur++;
-}
-*str = cur;
-return ret;
-}
-
-/**
- * virDomainCpuSetFormat:
- * @conn: connection
- * @cpuset: pointer to a char array for the CPU set
- * @maxcpu: number of elements available in @cpuset
- *
- * Serialize the cpuset to a string
- *
- * Returns the new string NULL in case of error. The string needs to be
- * freed by the caller.
- */
-char *
-virDomainCpuSetFormat(char *cpuset, int maxcpu)
-{
-virBuffer buf = VIR_BUFFER_INITIALIZER;
-int start, cur;
-int first = 1;
-
-if (!cpuset || maxcpu = 0 || maxcpu  10)
-return NULL;
-
-cur = 0;
-start = -1;
-while (cur  maxcpu) {
-if (cpuset[cur]) {
-if (start == -1)
-start = cur;
-} else if (start != -1) {
-if (!first)
-virBufferAddLit(buf, ,);
-else
-first = 0;
-if (cur == start + 1)
-virBufferAsprintf(buf, %d, start);
-else
-virBufferAsprintf(buf, %d-%d, start, cur - 1);
-start = -1;
-}
-cur++;
-}
-if (start != -1) {
-if (!first)
-virBufferAddLit(buf, ,);
-if (maxcpu == start + 1)
-virBufferAsprintf(buf, %d, start);
-else
-virBufferAsprintf(buf, %d-%d, start, maxcpu - 1);
-}
-
-if (virBufferError(buf)) {
-virBufferFreeAndReset(buf);
-virReportOOMError();
-return NULL;
-}
-
-return virBufferContentAndReset(buf);
-}
-
-/**
- * virDomainCpuSetParse:
- * @conn: connection
- * @str: a CPU set string pointer
- * @sep: potential character used to mark the end of string if not 0
- * @cpuset: pointer to a char array for the CPU set
- * @maxcpu: number of elements available in @cpuset
- *
- * Parse the cpu set, it will set the value for enabled CPUs in the @cpuset
- * to 1, and 0 otherwise. The syntax allows comma separated entries; each
- * can be either a CPU number, ^N to unset that CPU, or N-M for ranges.
- *
- * Returns the number of CPU found in that set, or -1 in case of error.
- * @cpuset is modified accordingly to the value parsed.
- */
-int
-virDomainCpuSetParse(const char *str, char sep,
- char *cpuset, int maxcpu)
-{
-const char *cur;
-int ret = 0;
-int i, start, last;
-int neg = 0;
-
-if (!str || !cpuset || maxcpu = 0 || maxcpu  10)
-return -1;
-
-cur = str;
-virSkipSpaces(cur);
-if (*cur == 0)
-goto parse_error;
-
-/* initialize cpumap to all 0s */
-for (i = 0; i  maxcpu; i++)
-cpuset[i] = 0;
-ret = 0;
-
-while (*cur != 0  *cur != sep) {
-/*
- * 3 constructs are allowed:
- * - N   : a single CPU number
- * - N-M : a range of CPU numbers with N  M
- * - ^N  : remove a single CPU number from the current set
- */
-if (*cur == '^') {
-cur++;
-neg = 1;
-}
-
-if (!c_isdigit(*cur))
-goto parse_error;
-start = virDomainCpuNumberParse(cur, maxcpu);
-if (start  0)
-goto parse_error;
-virSkipSpaces(cur);
-if (*cur == ',' || *cur == 0 || *cur == sep) {
-if (neg) {
-if (cpuset[start] == 1) {
-   

Re: [libvirt] Libvir JNA report SIGSEGV

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 09:06:14AM +, Benjamin Wang (gendwang) wrote:
 Hi,
   Actually I also did another test as following. When I comment the new 
 Connet, the program works well. So this is the problem related to
 Libvirt JNA. If I manually run the garbage collection for this program, it 
 still works well. But if I run the garbage collection for the last problem,
 It will crash. I guess this problem is caused by ConnectAuth callback. When 
 garbage collection is executed, the callback memory is moved.

  Okay, maybe some memory need to be pinned in some ways, I take patches !

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] An introduction to the libvirt-designer library

2012-09-06 Thread Daniel P. Berrange
People might have noticed Michal's patches[1] for the libvirt-designer
and wondered wtf.com that is. This is an attempt to explain it...

If you are familiar with the code in virt-install (also used by virt-manager)
you'll know it has a bunch of internal classes / APIs for dealing with
libvirt configuration, particularly wrt guest domains. If you're also
familiar with other apps like GNOME Boxes, VDSM/oVirt, OpenStack, then
you'll know that these apps have roughly the same needs as virt-install
and virt-manager wrt libvirt configuration. The virt-install internal
APIs though cannot practically be used by these apps since they were
never really designed with broad re-use in mind.

Obviously in such scenarios it is desirable to share code across apps
instead of having them all reinvent the wheel. The libvirt-gconfig
library was the first part in an attempt to address this problem by
providing a formal API for creating  reading libvirt configurations
without having to know anything about XML. This library is completely
policy-free, restricting itself to direct/explicit manipulation
of the configuration attributes. This deals with some of functionality
found in the virt-install internal APIs.

The libosinfo library [2] provides an API for discovering supportable
and optimal hardware for operating systems  hypervisors. This replaces
the OS configuration data tables found inside virt-install.

The next step is to provide a policy-driven API for configurating virtual
machines. When configuring a virtual machine,  parameters can be
roughly split into two groups - guest hardware config and host interaction
config. The idea behind the libvirt-designer API is that when creating or
changing a guest config, application developers should only need to care
about the host interaction config. The guest hardware config can be
figured out automatically on their behalf using data obtained from the
libosinfo library.

As an example, consider adding a disk to a guest. Traditionally an app
developer needs to

 - Choose what virtual hardware to use
 - Figure out guest device name
 - Set the host filename
 - Choose optimal I/O parameters (cache mode, driver type, etc, etc)

With the libvirt-designer APIs, an app developer will need to

 - Set the host filename

The rest of the points will be filled in automatically, though the app
developer will still get the opportunity to further customize the
defaults via the existing libvirt-gconfig APIs.

As mentioned above the libvirt-designer library is binding together the
libvirt-gconfig and libosinfo APIs. It explicitly does *not* directly
depend on libvirt or libvirt-gobject. This is to try to allow the
libvirt-designer library to be used by a wide variety of applications,
no matter how they are interacting with libvirt. eg if they use the
CIM, SNMP or QMF bindings to libvirt they can still use libvirt-designer
to build their XML configurations.

The intent is that there is yet another library, so far called
libvirt-builder, which binds together the libvirt-designer and
libvirt-gobject APIs, to actually automate some of the lifecycle
management and VM provisioning tasks. Since it will use libvirt-gobject,
this final library would not be accessible to apps using CIM/SNMP/QMF
bindings. With this library, we would have more or less complete
coverage of all the important tasks found in the virt-install
internal APIs, which can be reused by other apps. There is of course
still quite a long way to go before we get there, since we're aiming to
build this all up incrementally from the bottom up.

The hope is that in the near term, GNOME Boxes will be able to start
taking advantage of some of the code provided by libvirt-designer,
since it already uses libvirt-gconfig  libosinfo. In addition as
more functionality appears we'll be able to start changing virt-install
to switch it over to these APIs in favour of its internal code.

Regards,
Daniel

[1] https://www.redhat.com/archives/libvir-list/2012-September/msg00214.html
[2] https://fedorahosted.org/libosinfo
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] [PATCH] events: Fix domain event race on client disconnect

2012-09-06 Thread Christophe Fergeau
GNOME Boxes sometimes stops getting domain events from libvirtd, even
after restarting it. Further investigation in libvirtd shows that
events are properly queued with virDomainEventStateQueue, but the
timer virDomainEventTimer which flushes the events and sends them to
the clients never gets called. Looking at the event queue in gdb
shows that it's non-empty and that its size increases with each new
events.

virDomainEventTimer is set up in virDomainEventStateRegister[ID]
when going from 0 client connecte to 1 client connected, but is
initially disabled. The timer is removed in
virDomainEventStateRegister[ID] when the last client is disconnected
(going from 1 client connected to 0).

This timer (which handles sending the events to the clients) is
enabled in virDomainEventStateQueue when queueing an event on an
empty queue (queue containing 0 events). It's disabled in
virDomainEventStateFlush after flushing the queue (ie removing all
the elements from it). This way, no extra work is done when the queue
is empty, and when the next event comes up, the timer will get
reenabled because the queue will go from 0 event to 1 event, which
triggers enabling the timer.

However, with this Boxes bug, we have a client connected (Boxes), a
non-empty queue (there are events waiting to be sent), but a disabled
timer, so something went wrong.

When Boxes connects (it's the only client connecting to the libvirtd
instance I used for debugging), the event timer is not set as expected
(state-timer == -1 when virDomainEventStateRegisterID is called),
but at the same time the event queue is not empty. In other words,
we had no clients connected, but pending events. This also explains
why the timer never gets enabled as this is only done when an event
is queued on an empty queue.

I think this can happen if an event gets queued using
virDomainEventStateQueue and the client disconnection happens before
the event timer virDomainEventTimer gets a chance to run and flush
the event. In this situation, virDomainEventStateDeregister[ID] will
get called with a non-empty event queue, the timer will be destroyed
if this was the only client connected. Then, when other clients connect
at a later time, they will never get notified about domain events as
the event timer will never get enabled because the timer is only
enabled if the event queue is empty when virDomainEventStateRegister[ID]
gets called, which will is no longer the case.

To avoid this issue, this commit makes sure to remove all events from
the event queue when the last client in unregistered. As there is
no longer anyone interested in receiving these events, these events
are stale so there is no need to keep them around. A client connecting
later will have no interest in getting events that happened before it
got connected.
---
 src/conf/domain_event.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 43ecdcf..7ab973b 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -525,13 +525,13 @@ void virDomainEventFree(virDomainEventPtr event)
 }
 
 /**
- * virDomainEventQueueFree:
+ * virDomainEventQueueClear:
  * @queue: pointer to the queue
  *
- * Free the memory in the queue. We process this like a list here
+ * Removes all elements from the queue
  */
 static void
-virDomainEventQueueFree(virDomainEventQueuePtr queue)
+virDomainEventQueueClear(virDomainEventQueuePtr queue)
 {
 int i;
 if (!queue)
@@ -541,6 +541,22 @@ virDomainEventQueueFree(virDomainEventQueuePtr queue)
 virDomainEventFree(queue-events[i]);
 }
 VIR_FREE(queue-events);
+queue-count = 0;
+}
+
+/**
+ * virDomainEventQueueFree:
+ * @queue: pointer to the queue
+ *
+ * Free the memory in the queue. We process this like a list here
+ */
+static void
+virDomainEventQueueFree(virDomainEventQueuePtr queue)
+{
+if (!queue)
+return;
+
+virDomainEventQueueClear(queue);
 VIR_FREE(queue);
 }
 
@@ -1559,6 +1575,7 @@ virDomainEventStateDeregister(virConnectPtr conn,
 state-timer != -1) {
 virEventRemoveTimeout(state-timer);
 state-timer = -1;
+virDomainEventQueueClear(state-queue);
 }
 
 virDomainEventStateUnlock(state);
@@ -1596,6 +1613,7 @@ virDomainEventStateDeregisterID(virConnectPtr conn,
 state-timer != -1) {
 virEventRemoveTimeout(state-timer);
 state-timer = -1;
+virDomainEventQueueClear(state-queue);
 }
 
 virDomainEventStateUnlock(state);
-- 
1.7.11.4

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


Re: [libvirt] [PATCH 1/1 V2] Migrate per-port data for Open vSwitch ports during Qemu Live Migration

2012-09-06 Thread Kyle Mestery (kmestery)
On Sep 6, 2012, at 12:35 AM, Daniel Veillard wrote:
 On Tue, Sep 04, 2012 at 04:35:24PM -0400, Kyle Mestery wrote:
 Add the ability to migrate per-port data on Open vSwitch
 ports during qemu live migration. A controller can use this
 to store data relating to each port, and have it migrated
 with the virtual machine and populated on the destination
 host.
 
 Signed-off-by: Kyle Mestery kmest...@cisco.com
 Cc: Laine Stump la...@laine.org
 []
 +static void qemuMigrationCookieOvsPortDataXMLFormat(virBufferPtr buf,
 +
 qemuMigrationCookieOvsPortDataPtr optr)
 +{
 +int i;
 +
 +virBufferAsprintf(buf,   ovsportdata nnets='%d'\n, optr-nnets);
 +if (optr-nnets  0)
 +virBufferAsprintf(buf, vifs\n);
 +for (i = 0; i  optr-nnets; i++) {
 +virBufferAsprintf(buf,   vif num='%d' portdata='%s'/\n,
 +  i, optr-portdata[i]);
 +}
 +if (optr-nnets  0)
 +virBufferAsprintf(buf, /vifs\n);
 +
 +virBufferAddLit(buf,   /ovsportdata\n);
 +}
 
  I'm not specialist of the networking layer, but it looks to me that
 this should work (but can someone explain the error scenario if the
 receiving end don't understand the extra XML passed in the migration
 data ?). My main concern is tying that generic mechanism to OVS, seems
 to me this should be split in 2 patches:
   - one patch adding the generic framework to adding XML networking
 related data to the XML passed along the domain in the migration
   - one patch using that generic mechanism to carry the OpenVSwitch 
 per port data
 The first part defining the data extension etc ought to be generic
 (but probably network related) and the second part specific to OVS
 
  Laine, am I off track ?
 
 Daniel


Thanks for the review Daniel. Laine and I spoke offline, and he had similar
comments to you. I will rework the patch as you describe above, and incorporate
any additional comments Laine has as well.

Thanks!
Kyle

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


Re: [libvirt] Libvir JNA report SIGSEGV

2012-09-06 Thread Benjamin Wang (gendwang)
Hi,
   I have looked into the code for several days. But I didn't find the root 
cause. Because even if I only call new Connect, the problem
will occur. So this should be related to Connect.java or 
ConnectAuthDefault.java. Would you take a quick at the issue and give some 
prompt?
Then I can try to fix this. Thanks!

B.R.
Benjamin Wang

-Original Message-
From: Daniel Veillard [mailto:veill...@redhat.com] 
Sent: 2012年9月6日 19:05
To: Benjamin Wang (gendwang)
Cc: libvir-list@redhat.com
Subject: Re: [libvirt] Libvir JNA report SIGSEGV

On Thu, Sep 06, 2012 at 09:06:14AM +, Benjamin Wang (gendwang) wrote:
 Hi,
   Actually I also did another test as following. When I comment the 
 new Connet, the program works well. So this is the problem related 
 to Libvirt JNA. If I manually run the garbage collection for this program, it 
 still works well. But if I run the garbage collection for the last problem, 
 It will crash. I guess this problem is caused by ConnectAuth callback. When 
 garbage collection is executed, the callback memory is moved.

  Okay, maybe some memory need to be pinned in some ways, I take patches !

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] RFC: take two on live update of network configuration

2012-09-06 Thread Daniel P. Berrange
On Tue, Aug 21, 2012 at 11:26:08PM -0400, Laine Stump wrote:
 We need a way to update the elements of a network without being
 required to restart the network before the changes take effect. I had
 previously thought I could just use a new virNetworkDefineXMLFlags with
 an optional flag set to mean take effect immediately, but have been
 discouraged from that approach.
 
 Instead, I'm considering something similar to
 virDomain(Attach|Update|Detach)DeviceFlags, but this could be more
 complicated because I would like to be able to update *anything* within
 the network definition hierarchy, not just the direct subelements of one
 level in the hierarchy (as is the case for those existing functions).
 
 Here's an example of an existing network (note that this isn't a legal
 network - you can't have an ip element and an interface pool (or a
 bridge name and an interface pool) in the same network; this is just so
 I can use a single example), and some of the things we might want to do
 with it:
 
 network
   nametest1/name
   uuid2d39a0ba-ac4b-6097-114c-50f8bccc277c/uuid
   forward mode='bridge'/
   bridge name='virbr5' stp='on' delay='0' /
   mac address='52:54:00:38:81:4D'/
   domain name='example.com'/
   forward mode='private'/
 interface dev=eth20/
 interface dev=eth21/
 interface dev=eth22/
 interface dev=eth23/
 interface dev=eth24/
   /forward
   portgroup name='engineering' default='yes'
 virtualport type='802.1Qbh'
   parameters profileid='test'/
 /virtualport
 bandwidth
   inbound average='1000' peak='5000' burst='5120'/
   outbound average='1000' peak='5000' burst='5120'/
 /bandwidth
   /portgroup/b
   portgroup name='sales'
 virtualport type='802.1Qbh'
   parameters profileid='salestest'/
 /virtualport
 bandwidth
   inbound average='500' peak='2000' burst='2560'/
   outbound average='128' peak='256' burst='256'/
 /bandwidth
   /portgroup/b
   dns
 txt name=example value=example value /
 srv service='name' protocol='tcp' domain='test-domain-name' target='.' 
 port='1024' priority='10' weight='10'/
 host ip='192.168.122.2'
   hostnamemyhost/hostname
   hostnamemyhostalias/hostname
 /host
   /dns
   ip address='10.24.75.1' netmask='255.255.255.0'
 dhcp
   range start='10.24.75.128' end='10.24.75.254' /
   host mac='52:54:3e:77:e2:ed' name='X.example.com' ip='10.24.75.10' /
   host mac='52:54:3e:77:e2:ef' name='Y.example.com' ip='10.24.75.11' /
   host mac='52:54:34:77:e2:f0' name='Z.example.com' ip='10.24.75.12' /
   host mac='52:54:3e:77:e2:f1' name='A.example.com' ip='10.24.75.13' /
 /dhcp
   /ip
   ip address='192.168.4.1' netmask='255.255.255.0'/
 /network
 
 Some things we might want to do to this (the first three have already
 been requested):
 
 1) add or remove an interface from the interface pool, i.e. a particular
 interface sub-element of the (one and only) forward element.
 
 2) add/remove/modify a portgroup entry (i.e. a specific sub-element of
 network)
 
 3) add/remove/modify a static host entry from the dhcp section of a
 particular ip (so, a particular host sub-element of a particular
 ip element)
 
 Some others:
 
 4) add/modify/remove a host (or a txt or an srv in the dns section
 4) add/modify/remove the domain
 5) add/modify/remove an entire ip element
 6) turn stp on/off in the bridge element
 
 I can see three possible methods of providing this functionality:
 
 ===
 OPTION 1) Have a single API:
 
 virNetworkUpdate(virNetworkPtr network,
  const char *xml, unsigned, int flags)
 
 This function would take an entire network specification as an arg,
 and replace the entire existing config. This would allow changing
 anything, but would also require reading the entire config beforehand.

Not only that, it requires that you basically write a diff command
for the entire network XML. eg you need to compare both the new and
old config to figure out what's added, what's removed, and what's
changed. Further from that, you then need to decide which changes
are legal and which aren't.

Then when you come to actually performing the changes, you might
get 1/2 way through some changes and fail. Rolling back what you
have already done is not practical, since rollback could fail
too. Carrying on its obvious not reasonable, since we need to
report an error about what went wrong. So now we have to merge
the bits we did change with the existing config - you can't simply
replace the entire old config with the new one.

IMHO this is pretty non-trivial and not a route I think we should
go down.

 ===
 OPTION 2) have a separate API for each different type of element we may want 
 to
 change, e.g.:
 
 
 virNetworkUpdateForwardInterface(virNetworkPtr network,
  const char *xml,
  unsigned int flags);
 virNetworkUpdatePortgroup(virNetworkPtr network,
   

Re: [libvirt] NFS over RDMA small block DIRECT_IO bug

2012-09-06 Thread Myklebust, Trond
On Thu, 2012-09-06 at 12:14 +0200, Andrew Holway wrote:
 On Sep 5, 2012, at 4:02 PM, Avi Kivity wrote:
 
  On 09/04/2012 03:04 PM, Myklebust, Trond wrote:
  On Tue, 2012-09-04 at 11:31 +0200, Andrew Holway wrote:
  Hello.
  
  # Avi Kivity avi(a)redhat recommended I copy kvm in on this. It would 
  also seem relevent to libvirt. #
  
  I have a Centos 6.2 server and Centos 6.2 client.
  
  [root@store ~]# cat /etc/exports 
  /dev/shm  
  10.149.0.0/16(rw,fsid=1,no_root_squash,insecure)(I have tried with 
  non tempfs targets also)
  
  
  [root@node001 ~]# cat /etc/fstab 
  store.ibnet:/dev/shm /mnt nfs  
  rdma,port=2050,defaults 0 0
  
  
  I wrote a little for loop one liner that dd'd the centos net install 
  image to a file called 'hello' then checksummed that file. Each iteration 
  uses a different block size.
  
  Non DIRECT_IO seems to work fine. DIRECT_IO with 512byte, 1K and 2K block 
  sizes get corrupted.
  
  
  That is expected behaviour. DIRECT_IO over RDMA needs to be page aligned
  so that it can use the more efficient RDMA READ and RDMA WRITE memory
  semantics (instead of the SEND/RECEIVE channel semantics).
  
  Shouldn't subpage requests fail then?  O_DIRECT block requests fail for
  subsector writes, instead of corrupting your data.
 
 But silent data corruption is so much fun!!

A couple of RDMA folks are looking into why this is happening. I'm
hoping they will get back to me soon.

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
trond.mykleb...@netapp.com
www.netapp.com


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


Re: [libvirt] [PATCH 09/10 v5] list: Use virConnectListAllStoragePools in virsh

2012-09-06 Thread Osier Yang

On 2012年09月06日 01:17, Laine Stump wrote:


On 09/05/2012 12:52 PM, Eric Blake wrote:

On 09/05/2012 12:36 AM, Osier Yang wrote:

+++ b/tools/virsh-pool.c
@@ -36,6 +36,7 @@
  #include memory.h
  #include util.h
  #include xml.h
+#include conf/storage_conf.h

I'm not sure if virsh is supposed to be able to use conf/*.h files;
you're not the first offender, but the more we do this, the more we are
admitting that our public API is insufficient.  I'm wondering if we
should move the filter group constants into libvirt.h, and make them
part of the public API...


For the constants, yeah, we have to move them to public if not want to
include the conf headers in client side.



Yes. (or whatever it takes to not use non-public .h files in virsh).
virsh should only use the public libvirt API; if it needs something
that's private to libvirt, either that piece of code should be
rewritten, or the public API should be enhanced.


Agreed for sure, I didn't notice that when creating the patches though.

 (But, as you say, Osier

isn't the first offender, so it's okay to let this temporarily slip by).


Thanks, I will push the set, and see if can I create a later patch
to fix that.



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


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

Re: [libvirt] [PATCH V3] Add proxy FS support to libvirt

2012-09-06 Thread Daniel P. Berrange
On Thu, Aug 23, 2012 at 02:36:40PM +0530, M. Mohan Kumar wrote:
 From: M. Mohan Kumar mo...@in.ibm.com
 
 A new FS driver type 'proxy' is added to QEMU 9p server. This patch adds
 support for using proxy FS driver from libvirt.
 
 QEMU proxy FS driver uses socket for communicating between helper and qemu
 proxy FS driver. Proxy helper (a stand alone binary part of qemu) is invoked
 with one of the descriptors created using socketpair call and the share path.
 Similarly QEMU is invoked with another descriptor created using the same
 socketpair system call and with other required FS driver parameters.
 
 Need for proxy FS driver
 
 Pass through security model in QEMU 9p server has following issues:
 1) TOCTTOU vulnerability: Following symbolic links in the server could
 provide access to files beyond 9p export path.
 
 2) Running QEMU with root privilege could be a security issue (pass
 through security model needs root privilege).
 
 Proxy FS driver is implemented to solve these issues.
 
 Proxy FS uses chroot + socket combination for securing the vulnerability
 known with following symbolic links. Intention of adding a new filesystem
 type is to allow qemu to run in non-root mode, but doing privileged
 operations in a chroot environment using socket IO.
 
 Proxy helper is invoked with root privileges and chroots into 9p export path.
 QEMU proxy fs driver sends filesystem request to proxy helper and receives the
 response from it.
 
 Proxy helper is designed such a way that it needs only few capabilities 
 related
 to filesystem operations (such as CAP_DAC_OVERRIDE, CAP_FOWNER, etc) and all
 other capabilities are dropped (CAP_SYS_CHROOT, etc)
 
 Proxy patches
 http://permalink.gmane.org/gmane.comp.emulators.qemu/128735
 
 Signed-off-by: M. Mohan Kumar mo...@in.ibm.com
 ---
 Changes from previous version V3
 * Addressed Daniel's review comments
 
 Changes from previous version V2
 * Rebased on top of current libvirt git level
 
 Changes from previous version
 * Remove the xml node for specifying the virtfs-proxy-helper path, now it is
 determined from qemu binary path.
 
  docs/formatdomain.html.in|2 +
  src/conf/domain_conf.c   |3 +-
  src/conf/domain_conf.h   |2 +-

Opps, forgot to mention in previous reviews that you must
update docs/schemas/domaincommon.rng to list the new attribute

 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 5472267..88b7e87 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -144,7 +144,6 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
ich9-ahci,
no-acpi,
fsdev-readonly,
 -
virtio-blk-pci.scsi, /* 80 */
blk-sg-io,
drive-copy-on-read,

Bogus whitespace removal

 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 4ca3047..3f78635 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -46,6 +46,7 @@
  #include sys/utsname.h
  #include sys/stat.h
  #include fcntl.h
 +#include libgen.h

You don't use any functions from this header, so it can be removed.

 @@ -2632,9 +2634,59 @@ error:
  return NULL;
  }
  
 +/*
 + * Invokes the Proxy Helper with one of the socketpair as its parameter
 + *
 + */
 +static int qemuInvokeProxyHelper(const char *emulator, int sock, const char 
 *path)
 +{
 +#define HELPER virtfs-proxy-helper
 +int ret_val, status;
 +virCommandPtr cmd;
 +char *helper, *dname, *dp;
 +
 +dp = strdup(emulator);
 +if (!dp) {
 +virReportOOMError();
 +return -1;

This doesn't close 'sock' like other error paths do

 +}
 +dname = strrchr(dp, '/');
 +if (!dname) {
 +VIR_FREE(dp);
 +VIR_FORCE_CLOSE(sock);
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(Unable to get path details from %s), dp);
 +return -1;
 +}
 +*dname = '\0';
 +if (virAsprintf(helper, %s/%s, dp, HELPER)  0) {
 +VIR_FREE(dp);
 +VIR_FORCE_CLOSE(sock);
 +virReportOOMError();
 +return -1;
 +}
 +
 +cmd = virCommandNewArgList(helper, NULL);
 +virCommandAddArg(cmd, -f);
 +virCommandAddArgFormat(cmd, %d, sock);
 +virCommandAddArg(cmd, -p);
 +virCommandAddArgFormat(cmd, %s, path);
 +virCommandTransferFD(cmd, sock);
 +virCommandDaemonize(cmd);
 +ret_val = virCommandRun(cmd, status);
 +if (ret_val  0) {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +_(%s can't execute), helper);
 +VIR_FORCE_CLOSE(sock);
 +}
 +virCommandFree(cmd);
 +VIR_FREE(helper);
 +VIR_FREE(dp);
 +return ret_val;
 +}
  
  char *qemuBuildFSStr(virDomainFSDefPtr fs,
 - virBitmapPtr qemuCaps ATTRIBUTE_UNUSED)
 + virBitmapPtr qemuCaps ATTRIBUTE_UNUSED, int qemuSocket)
  {
  virBuffer opt = VIR_BUFFER_INITIALIZER;
  const char 

[libvirt] [PATCHv3 0/4] Add range checking for scheduler tunables

2012-09-06 Thread Peter Krempa
This version improves virsh so that it doesn't update all tunables
but only those that changed (and now correctly).

This series contains a new patch that adds a helper to deal
with typed parameters.

Regarding typed parameters: Shouldn't we make the helpers to deal
with them public?

(Patches 1 and 2 didn't change to v2)

Peter Krempa (4):
  qemu: clean up qemuSetSchedulerParametersFlags()
  qemu: Add range checking for scheduler tunables when changed by API
  util: Add helper to assign typed params from string
  virsh: Update only changed scheduler tunables

 src/libvirt_private.syms |   1 +
 src/qemu/qemu_driver.c   |  96 ---
 src/util/virtypedparam.c |  97 
 src/util/virtypedparam.h |   6 ++
 tools/virsh-domain.c | 164 +--
 5 files changed, 236 insertions(+), 128 deletions(-)

-- 
1.7.12

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


[libvirt] [PATCHv3 2/4] qemu: Add range checking for scheduler tunables when changed by API

2012-09-06 Thread Peter Krempa
The quota and period tunables for cpu scheduler accept only a certain
range of values. When changing the live configuration invalid values get
rejected. This check is not performed when changing persistent config.

This patch adds a separate range check, that improves error messages
when changing live config and adds the check for persistent config.
This check is done only when using the API. It is still possible to
specify invalid values in the XML.
---
 src/qemu/qemu_driver.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4b8b751..8e8e00c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -106,6 +106,11 @@
 #define QEMU_NB_TOTAL_CPU_STAT_PARAM 3
 #define QEMU_NB_PER_CPU_STAT_PARAM 2

+#define QEMU_SCHED_MIN_PERIOD  1000LL
+#define QEMU_SCHED_MAX_PERIOD   100LL
+#define QEMU_SCHED_MIN_QUOTA   1000LL
+#define QEMU_SCHED_MAX_QUOTA  18446744073709551LL
+
 #if HAVE_LINUX_KVM_H
 # include linux/kvm.h
 #endif
@@ -7790,6 +7795,15 @@ cleanup:
 return -1;
 }

+#define SCHED_RANGE_CHECK(VAR, NAME, MIN, MAX)  \
+if (((VAR)  0  (VAR)  (MIN)) || (VAR)  (MAX)) {\
+virReportError(VIR_ERR_INVALID_ARG, \
+   _(value of '%s' is out of range [%lld, %lld]), \
+   NAME, MIN, MAX); \
+rc = -1;\
+goto cleanup;   \
+}
+
 static int
 qemuSetSchedulerParametersFlags(virDomainPtr dom,
 virTypedParameterPtr params,
@@ -7876,6 +7890,9 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 vmdef-cputune.shares = value_ul;

 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
+SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD,
+  QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
+
 if (flags  VIR_DOMAIN_AFFECT_LIVE  value_ul) {
 if ((rc = qemuSetVcpusBWLive(vm, group, value_ul, 0)))
 goto cleanup;
@@ -7887,6 +7904,9 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 vmdef-cputune.period = params[i].value.ul;

 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
+SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA,
+  QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
+
 if (flags  VIR_DOMAIN_AFFECT_LIVE  value_l) {
 if ((rc = qemuSetVcpusBWLive(vm, group, 0, value_l)))
 goto cleanup;
@@ -7898,6 +7918,9 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 vmdef-cputune.quota = value_l;

 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD)) {
+SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
+  QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
+
 if (flags  VIR_DOMAIN_AFFECT_LIVE  value_ul) {
 if ((rc = qemuSetEmulatorBandwidthLive(vm, group, value_ul, 
0)))
 goto cleanup;
@@ -7909,6 +7932,9 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 vmdef-cputune.emulator_period = value_ul;

 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA)) {
+SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA,
+  QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
+
 if (flags  VIR_DOMAIN_AFFECT_LIVE  value_l) {
 if ((rc = qemuSetEmulatorBandwidthLive(vm, group, 0, value_l)))
 goto cleanup;
@@ -7944,6 +7970,7 @@ cleanup:
 qemuDriverUnlock(driver);
 return ret;
 }
+#undef SCHED_RANGE_CHECK

 static int
 qemuSetSchedulerParameters(virDomainPtr dom,
-- 
1.7.12

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


[libvirt] [PATCHv3 1/4] qemu: clean up qemuSetSchedulerParametersFlags()

2012-09-06 Thread Peter Krempa
This patch tries to clean the code up a little bit and shorten very long
lines.

The apparent semantic change from moving the condition before calling
the setter function is a non-issue here as the setter function is a
no-op when called with both arguments zero.
---
 src/qemu/qemu_driver.c | 69 +++---
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b12d9bc..4b8b751 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7801,6 +7801,8 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
 virCgroupPtr group = NULL;
 virDomainObjPtr vm = NULL;
 virDomainDefPtr vmdef = NULL;
+unsigned long long value_ul;
+long long value_l;
 int ret = -1;
 int rc;

@@ -7857,74 +7859,65 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,

 for (i = 0; i  nparams; i++) {
 virTypedParameterPtr param = params[i];
+value_ul = param-value.ul;
+value_l = param-value.l;

 if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
-rc = virCgroupSetCpuShares(group, params[i].value.ul);
-if (rc != 0) {
+if ((rc = virCgroupSetCpuShares(group, value_ul))) {
 virReportSystemError(-rc, %s,
  _(unable to set cpu shares 
tunable));
 goto cleanup;
 }
-
-vm-def-cputune.shares = params[i].value.ul;
+vm-def-cputune.shares = value_ul;
 }

-if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
-vmdef-cputune.shares = params[i].value.ul;
-}
+if (flags  VIR_DOMAIN_AFFECT_CONFIG)
+vmdef-cputune.shares = value_ul;
+
 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
-if (flags  VIR_DOMAIN_AFFECT_LIVE) {
-rc = qemuSetVcpusBWLive(vm, group, params[i].value.ul, 0);
-if (rc != 0)
+if (flags  VIR_DOMAIN_AFFECT_LIVE  value_ul) {
+if ((rc = qemuSetVcpusBWLive(vm, group, value_ul, 0)))
 goto cleanup;

-if (params[i].value.ul)
-vm-def-cputune.period = params[i].value.ul;
+vm-def-cputune.period = value_ul;
 }

-if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
+if (flags  VIR_DOMAIN_AFFECT_CONFIG)
 vmdef-cputune.period = params[i].value.ul;
-}
+
 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
-if (flags  VIR_DOMAIN_AFFECT_LIVE) {
-rc = qemuSetVcpusBWLive(vm, group, 0, params[i].value.l);
-if (rc != 0)
+if (flags  VIR_DOMAIN_AFFECT_LIVE  value_l) {
+if ((rc = qemuSetVcpusBWLive(vm, group, 0, value_l)))
 goto cleanup;

-if (params[i].value.l)
-vm-def-cputune.quota = params[i].value.l;
+vm-def-cputune.quota = value_l;
 }

-if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
-vmdef-cputune.quota = params[i].value.l;
-}
+if (flags  VIR_DOMAIN_AFFECT_CONFIG)
+vmdef-cputune.quota = value_l;
+
 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD)) {
-if (flags  VIR_DOMAIN_AFFECT_LIVE) {
-rc = qemuSetEmulatorBandwidthLive(vm, group, 
params[i].value.ul, 0);
-if (rc != 0)
+if (flags  VIR_DOMAIN_AFFECT_LIVE  value_ul) {
+if ((rc = qemuSetEmulatorBandwidthLive(vm, group, value_ul, 
0)))
 goto cleanup;

-if (params[i].value.ul)
-vm-def-cputune.emulator_period = params[i].value.ul;
+vm-def-cputune.emulator_period = value_ul;
 }

-if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
-vmdef-cputune.emulator_period = params[i].value.ul;
-}
+if (flags  VIR_DOMAIN_AFFECT_CONFIG)
+vmdef-cputune.emulator_period = value_ul;
+
 } else if (STREQ(param-field, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA)) {
-if (flags  VIR_DOMAIN_AFFECT_LIVE) {
-rc = qemuSetEmulatorBandwidthLive(vm, group, 0, 
params[i].value.l);
-if (rc != 0)
+if (flags  VIR_DOMAIN_AFFECT_LIVE  value_l) {
+if ((rc = qemuSetEmulatorBandwidthLive(vm, group, 0, value_l)))
 goto cleanup;

-if (params[i].value.l)
-vm-def-cputune.emulator_quota = params[i].value.l;
+vm-def-cputune.emulator_quota = value_l;
 }

-if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
-vmdef-cputune.emulator_quota = 

[libvirt] [PATCHv3 3/4] util: Add helper to assign typed params from string

2012-09-06 Thread Peter Krempa
This patch adds a helper to deal with assigning values to
virTypedParameter structures from strings. The helper parses the value
from the string and assigns it to the corresponding union value.
---
New in series.
---
 src/libvirt_private.syms |  1 +
 src/util/virtypedparam.c | 97 
 src/util/virtypedparam.h |  6 +++
 3 files changed, 104 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65067d6..c8dcece 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1734,6 +1734,7 @@ virTimeStringThenRaw;
 virTypedParameterArrayClear;
 virTypedParameterArrayValidate;
 virTypedParameterAssign;
+virTypedParameterAssignFromStr;


 # viruri.h
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index d68d79f..89a0caa 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -181,3 +181,100 @@ cleanup:
 va_end(ap);
 return ret;
 }
+
+/* Assign name, type, and convert the argument from a const string.
+ * In case of a string, the string is copied.
+ * Return 0 on success, -1 after an error message on failure.  */
+int
+virTypedParameterAssignFromStr(virTypedParameterPtr param, const char *name,
+   int type, const char *val)
+{
+int ret = -1;
+
+if (!val) {
+virReportError(VIR_ERR_INVALID_ARG, _(NULL value for field '%s'),
+   name);
+goto cleanup;
+}
+
+if (virStrcpyStatic(param-field, name) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR, _(Field name '%s' too long),
+   name);
+goto cleanup;
+}
+
+param-type = type;
+switch (type) {
+case VIR_TYPED_PARAM_INT:
+if (virStrToLong_i(val, NULL, 10, param-value.i)  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid value for field '%s': expected int),
+   name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_UINT:
+if (virStrToLong_ui(val, NULL, 10, param-value.ui)  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid value for field '%s': 
+ expected unsigned int),
+   name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_LLONG:
+if (virStrToLong_ll(val, NULL, 10, param-value.l)  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid value for field '%s': 
+ expected long long),
+   name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_ULLONG:
+if (virStrToLong_ull(val, NULL, 10, param-value.ul)  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid value for field '%s': 
+ expected long long),
+   name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_DOUBLE:
+if (virStrToDouble(val, NULL, param-value.d)  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid value for field '%s': 
+ expected double),
+   name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_BOOLEAN:
+if (STRCASEEQ(val, true) ||
+STREQ(val, 1)) {
+param-value.b = true;
+} else if (STRCASEEQ(val, false) ||
+ STREQ(val, 0)) {
+param-value.b = false;
+} else {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Invalid boolean value for field '%s'), name);
+goto cleanup;
+}
+break;
+case VIR_TYPED_PARAM_STRING:
+if (!(param-value.s = strdup(val))) {
+virReportOOMError();
+goto cleanup;
+}
+break;
+default:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected type %d for field %s), type, name);
+goto cleanup;
+}
+
+ret = 0;
+cleanup:
+return ret;
+}
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index f117b84..581201c 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -35,4 +35,10 @@ int virTypedParameterAssign(virTypedParameterPtr param, 
const char *name,
 int type, /* TYPE arg */ ...)
 ATTRIBUTE_RETURN_CHECK;

+int virTypedParameterAssignFromStr(virTypedParameterPtr param,
+   const char *name,
+   int type,
+   const char *val)
+ATTRIBUTE_RETURN_CHECK;
+
 #endif /* __VIR_TYPED_PARAM_H */
-- 
1.7.12

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


[libvirt] [PATCHv3 4/4] virsh: Update only changed scheduler tunables

2012-09-06 Thread Peter Krempa
When setting the cpu tunables in virsh you are able to update only a
subset of them. Virsh while doing the update updated all of the
tunables, changed ones with new values and unchanged with old ones.
This is unfortunate as it:
a) might overwrite some other change by a race condition (unprobable)
b) fails with range checking as some of the old values saved might be
   out of range

This patch changes the update procedure so that only the changed value
is updated on the host.

This patch also fixes a very unprobable memory leak if the daemon would
return a string tunable parameter, as the typed parameter array was not
cleared.
---
Diff to v2:
- handle legacy xen parameters correctly
- create copy of parameters that should be updated (allows multiple parameter 
update)
- simplify the update code using the new helper
---
 tools/virsh-domain.c | 164 +++
 1 file changed, 74 insertions(+), 90 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 4684466..33229d6 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3292,95 +3292,79 @@ static const vshCmdOptDef opts_schedinfo[] = {

 static int
 cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
-   virTypedParameterPtr param)
+   virTypedParameterPtr src_params, int nsrc_params,
+   virTypedParameterPtr *update_params)
 {
-const char *data = NULL;
-
-/* Legacy 'weight' parameter */
-if (STREQ(param-field, weight) 
-param-type == VIR_TYPED_PARAM_UINT 
-vshCommandOptBool(cmd, weight)) {
-int val;
-if (vshCommandOptInt(cmd, weight, val) = 0) {
-vshError(ctl, %s, _(Invalid value of weight));
-return -1;
-} else {
-param-value.ui = val;
+const char *set_arg;
+char *set_field = NULL;
+char *set_val = NULL;
+
+virTypedParameterPtr param;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+size_t params_size = 0;
+int ret = -1;
+int rv;
+int val;
+int i;
+
+if (vshCommandOptString(cmd, set, set_arg)  0) {
+set_field = vshStrdup(ctl, set_arg);
+if (!(set_val = strchr(set_field, '='))) {
+vshError(ctl, %s, _(Invalid syntax for --set, expecting 
name=value));
+goto cleanup;
 }
-return 1;
+
+*set_val = '\0';
+set_val++;
 }

-/* Legacy 'cap' parameter */
-if (STREQ(param-field, cap) 
-param-type == VIR_TYPED_PARAM_UINT 
-vshCommandOptBool(cmd, cap)) {
-int val;
-if (vshCommandOptInt(cmd, cap, val) = 0) {
-vshError(ctl, %s, _(Invalid value of cap));
-return -1;
-} else {
-param-value.ui = val;
+for (i = 0; i  nsrc_params; i++) {
+param = (src_params[i]);
+if (VIR_RESIZE_N(params, params_size, nparams, 1)  0) {
+virReportOOMError();
+goto cleanup;
 }
-return 1;
-}

-if (vshCommandOptString(cmd, set, data)  0) {
-char *val = strchr(data, '=');
-int match = 0;
-if (!val) {
-vshError(ctl, %s, _(Invalid syntax for --set, expecting 
name=value));
-return -1;
+/* Legacy 'weight' and 'cap'  parameter */
+if (param-type == VIR_TYPED_PARAM_UINT 
+(STREQ(param-field, weight) || STREQ(param-field, cap)) 
+(rv = vshCommandOptInt(cmd, param-field, val)) != 0) {
+if (rv  0) {
+vshError(ctl, _(Invalid value of %s), param-field);
+goto cleanup;
+}
+
+if (virTypedParameterAssign((params[nparams++]),
+param-field,
+param-type,
+val)  0)
+goto cleanup;
+
+continue;
 }
-*val = '\0';
-match = STREQ(data, param-field);
-*val = '=';
-val++;

-if (!match)
-return 0;

-switch (param-type) {
-case VIR_TYPED_PARAM_INT:
-if (virStrToLong_i(val, NULL, 10, param-value.i)  0) {
-vshError(ctl, %s,
- _(Invalid value for parameter, expecting an int));
-return -1;
-}
-break;
-case VIR_TYPED_PARAM_UINT:
-if (virStrToLong_ui(val, NULL, 10, param-value.ui)  0) {
-vshError(ctl, %s,
- _(Invalid value for parameter, expecting an unsigned 
int));
-return -1;
-}
-break;
-case VIR_TYPED_PARAM_LLONG:
-if (virStrToLong_ll(val, NULL, 10, param-value.l)  0) {
-vshError(ctl, %s,
- _(Invalid value for parameter, expecting a long 
long));
-return -1;
-}
-break;
-case 

Re: [libvirt] [RFC] [PATCH v2 1/6] add configure option --with-fuse for libvirt

2012-09-06 Thread Glauber Costa
On 09/06/2012 05:53 AM, Gao feng wrote:
 于 2012年09月05日 20:42, Daniel P. Berrange 写道:
 On Wed, Sep 05, 2012 at 05:41:40PM +0800, Gao feng wrote:
 Hi Daniel  Glauber

 于 2012年07月31日 17:27, Daniel P. Berrange 写道:
 Hi Gao,

 I'm wondering if you are planning to attend the Linux Plumbers Conference
 in San Diego at the end of August ?  Glauber is going to be giving a talk
 on precisely the subject of virtualizing /proc in containers which is
 exactly what your patch is looking at

   https://blueprints.launchpad.net/lpc/+spec/lpc2012-cont-proc

 I'll review your patches now, but I think I'd like to wait to hear what
 Glauber talks about at LPC before we try to merge this support in libvirt,
 so we have an broadly agreed long term strategy for /proc between all the
 interested userspace  kernel guys.

 I did not attend the LPC,so can you tell me what's the situation of the
 /proc virtualization?

 I think maybe we should just apply this patchset first,and wait for somebody
 sending patches to implement /proc virtualization.

 So there were three main approaches discussed

  1. FUSE based /proc + a real hidden /.proc. The FUSE /proc provides custom
 handling of various files like meminfo, otherwise forwards I/O requests
 through to the hidden /.proc files. This was the original proof of
 concept.

  2. One FUSE filesystem for all containers + a real /proc. Bind mount files
 from the FUSE filesystem into the container's /proc. This is what Glauber
 has done.

  3. One FUSE filesystem per container + a real /proc. Bind mount files from
 the FUSE filesystem into the container's /proc. This is what your patch
 is doing

 Options 2  3 have a clear a win over option 1 in efficiency terms, since
 they avoid doubling the I/O required for the majority of files.

 Glaubar thinks it is perferrable to have a single FUSE filesystem that
 has one sub-directory for each container. Then bind mount the appropriate
 sub dir into each container.

 I kinda like the way you have done things, having a private FUSE filesystem
 per container, for security reasons. By having the FUSE backend be part of
 the libvirt_lxc process we have strictly isolated each containers' 
 environment.

 If we wanted a single shared FUSE for all containers, we'd need to have some
 single shared daemon to maintain it. This could not be libvirtd itself, since
 we need the containers  their filesystems to continue to work when libvirtd
 itself is not running. We could introduce a separate libvirt_fused which
 provided a shared filesystem, but this still has the downside that any
 flaw in its impl could provide a way for one container to attack another
 container
 
 Agree,if we choose the option 2,we have to organize the sub-directory for each
 container in fuse,it will make fuse filesystem complicated.
 

So, according to Daniel Lezcano, that tried it once, FUSE is very fork
intensive, and having one mount per-container would lead to bad
performance. But I have to admit I have never measured it myself. I
would be curious to see any numbers for a large deployment, to see if
that complication is worth the gain.




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

Re: [libvirt] [PATCH 1/6] list: Define new API virConnectListAllSecrets

2012-09-06 Thread Osier Yang

On 2012年09月05日 22:57, Eric Blake wrote:

On 09/05/2012 12:28 AM, Osier Yang wrote:

This is to list the secret objects. No flags are supported


Any reason we aren't allowing a filter on ephemeral=yes/no and
private=yes/no from the secret XML?


Just because of I didn't notice those two properties. :-)

That is, I think you can usefully

introduce two sets of filters based on those two binary properties of a
secret.



Will post a v5, per secret API is on the top of the whole series,
there is time space before the other APIs are reviewed.

Regards,
Osier

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

[libvirt] [PATCH] Fix location of SELinux mount during RPM builds

2012-09-06 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

When building RPMs the host kernel cannot be assumed to match
the target OS kernel. Thus auto-detecting /selinux vs
/sys/fs/selinux based on the host kernel can result in the
wrong choice (eg F18 builds on a RHEL6 host kernel)
---
 libvirt.spec.in | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 044b00f..fb35934 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1222,6 +1222,15 @@ of recent versions of Linux (and other OSes).
 %if 0%{?enable_autotools}
 autoreconf -if
 %endif
+
+%if %{with_selinux}
+%if %{?fedora} = 17 || %{?rhel} = 7
+%define with_selinux_mount --with-selinux-mount=/sys/fs/cgroup
+%else
+%define with_selinux_mount --with-selinux-mount=/selinux
+%endif
+%endif
+
 %configure %{?_without_xen} \
%{?_without_qemu} \
%{?_without_openvz} \
@@ -1254,6 +1263,7 @@ autoreconf -if
%{?_without_capng} \
%{?_without_netcf} \
%{?_without_selinux} \
+   %{?_with_selinux_mount} \
%{?_without_hal} \
%{?_without_udev} \
%{?_without_yajl} \
-- 
1.7.11.2

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


[libvirt] [PATCH] Don't assume use of /sys/fs/cgroup

2012-09-06 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The introduction of /sys/fs/cgroup came in fairly recent kernels.
Prior to that time distros would pick a custom directory like
/cgroup or /dev/cgroup. We need to auto-detect where this is,
rather than hardcoding it
---
 src/lxc/lxc_container.c | 71 +
 src/util/cgroup.h   |  2 --
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index f3a4622..9bc5610 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1307,7 +1307,8 @@ static void lxcContainerCGroupFree(struct 
lxcContainerCGroup *mounts,
 
 
 static int lxcContainerIdentifyCGroups(struct lxcContainerCGroup **mountsret,
-   size_t *nmountsret)
+   size_t *nmountsret,
+   char **root)
 {
 FILE *procmnt = NULL;
 struct mntent mntent;
@@ -1321,8 +1322,9 @@ static int lxcContainerIdentifyCGroups(struct 
lxcContainerCGroup **mountsret,
 
 *mountsret = NULL;
 *nmountsret = 0;
+*root = NULL;
 
-VIR_DEBUG(Finding cgroups mount points under %s, VIR_CGROUP_SYSFS_MOUNT);
+VIR_DEBUG(Finding cgroups mount points of type cgroup);
 
 if (!(procmnt = setmntent(/proc/mounts, r))) {
 virReportSystemError(errno, %s,
@@ -1332,10 +1334,24 @@ static int lxcContainerIdentifyCGroups(struct 
lxcContainerCGroup **mountsret,
 
 while (getmntent_r(procmnt, mntent, mntbuf, sizeof(mntbuf)) != NULL) {
 VIR_DEBUG(Got %s, mntent.mnt_dir);
-if (STRNEQ(mntent.mnt_type, cgroup) ||
-!STRPREFIX(mntent.mnt_dir, VIR_CGROUP_SYSFS_MOUNT))
+if (STRNEQ(mntent.mnt_type, cgroup))
 continue;
 
+if (!*root) {
+char *tmp;
+if (!(*root = strdup(mntent.mnt_dir))) {
+virReportOOMError();
+goto cleanup;
+}
+tmp = strrchr(*root, '/');
+*tmp = '\0';
+} else if (!STRPREFIX(mntent.mnt_dir, *root)) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Cgroup %s is not mounted under %s),
+   mntent.mnt_dir, *root);
+goto cleanup;
+}
+
 /* Skip named mounts with no controller since they're
  * for application use only ie systemd */
 if (strstr(mntent.mnt_opts, name=))
@@ -1349,14 +1365,14 @@ static int lxcContainerIdentifyCGroups(struct 
lxcContainerCGroup **mountsret,
 virReportOOMError();
 goto cleanup;
 }
-VIR_DEBUG(Grabbed %s, mntent.mnt_dir);
+VIR_DEBUG(Grabbed '%s', mntent.mnt_dir);
 }
 
-VIR_DEBUG(Checking for symlinks in %s, VIR_CGROUP_SYSFS_MOUNT);
-if (!(dh = opendir(VIR_CGROUP_SYSFS_MOUNT))) {
+VIR_DEBUG(Checking for symlinks in %s, *root);
+if (!(dh = opendir(*root))) {
 virReportSystemError(errno,
  _(Unable to read directory %s),
- VIR_CGROUP_SYSFS_MOUNT);
+ *root);
 goto cleanup;
 }
 
@@ -1370,7 +1386,7 @@ static int lxcContainerIdentifyCGroups(struct 
lxcContainerCGroup **mountsret,
 continue;
 
 VIR_DEBUG(Checking entry %s, dent-d_name);
-if (virAsprintf(path, %s/%s, VIR_CGROUP_SYSFS_MOUNT, dent-d_name) 
 0) {
+if (virAsprintf(path, %s/%s, *root, dent-d_name)  0) {
 virReportOOMError();
 goto cleanup;
 }
@@ -1410,25 +1426,28 @@ cleanup:
 endmntent(procmnt);
 VIR_FREE(path);
 
-if (ret  0)
+if (ret  0) {
 lxcContainerCGroupFree(mounts, nmounts);
+VIR_FREE(*root);
+}
 return ret;
 }
 
 
 static int lxcContainerMountCGroups(struct lxcContainerCGroup *mounts,
 size_t nmounts,
-char * sec_mount_options)
+const char *root,
+char *sec_mount_options)
 {
 size_t i;
 char *opts = NULL;
 
-VIR_DEBUG(Mounting cgroups at '%s', VIR_CGROUP_SYSFS_MOUNT);
+VIR_DEBUG(Mounting cgroups at '%s', root);
 
-if (virFileMakePath(VIR_CGROUP_SYSFS_MOUNT)  0) {
+if (virFileMakePath(root)  0) {
 virReportSystemError(errno,
  _(Unable to create directory %s),
- VIR_CGROUP_SYSFS_MOUNT);
+ root);
 return -1;
 }
 
@@ -1438,11 +1457,11 @@ static int lxcContainerMountCGroups(struct 
lxcContainerCGroup *mounts,
 return -1;
 }
 
-if (mount(tmpfs, VIR_CGROUP_SYSFS_MOUNT, tmpfs, 
MS_NOSUID|MS_NODEV|MS_NOEXEC, opts)  0) {
+if (mount(tmpfs, root, tmpfs, MS_NOSUID|MS_NODEV|MS_NOEXEC, opts)  0) 
{
 VIR_FREE(opts);
 virReportSystemError(errno,
  _(Failed to 

Re: [libvirt] [PATCH 2/5] list: Implement RPC calls for virConnectListAllNWFilters

2012-09-06 Thread Peter Krempa

On 09/05/12 08:02, Osier Yang wrote:

The RPC generator doesn't support returning list of object yet, this patch
do the work manually.

   * daemon/remote.c:
 Implemente the server side handler remoteDispatchConnectListAllNWFilters.

   * src/remote/remote_driver.c:
 Add remote driver handler remoteConnectListAllNWFilters.

   * src/remote/remote_protocol.x:
 New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS and
 structs to represent the args and ret for it.

   * src/remote_protocol-structs: Likewise.
---
  daemon/remote.c  |   54 
  src/remote/remote_driver.c   |   63 ++
  src/remote/remote_protocol.x |   13 -
  src/remote_protocol-structs  |   12 
  4 files changed, 141 insertions(+), 1 deletions(-)




diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b1671ae..2afe5b0 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2907,6 +2907,68 @@ done:
  return rv;
  }

+static int
+remoteConnectListAllNWFilters(virConnectPtr conn,
+  virNWFilterPtr **filters,
+  unsigned int flags)
+{
+int rv = -1;
+int i;
+virNWFilterPtr *tmp_filters = NULL;
+remote_connect_list_all_nwfilters_args args;
+remote_connect_list_all_nwfilters_ret ret;
+
+struct private_data *priv = conn-privateData;
+
+remoteDriverLock(priv);
+
+args.need_results = !!filters;
+args.flags = flags;
+
+memset(ret, 0, sizeof(ret));
+if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS,
+ (xdrproc_t) xdr_remote_connect_list_all_nwfilters_args,
+ (char *) args,
+ (xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret,
+ (char *) ret) == -1)
+goto done;
+
+if (filters) {
+if (VIR_ALLOC_N(tmp_filters, ret.filters.filters_len + 1)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+for (i = 0; i  ret.filters.filters_len; i++) {
+tmp_filters[i] = get_nonnull_nwfilter (conn, 
ret.filters.filters_val[i]);


Space before function arguments.


+if (!tmp_filters[i]) {
+virReportOOMError();
+goto cleanup;
+}
+}
+*filters = tmp_filters;
+tmp_filters = NULL;
+}
+
+rv = ret.ret;
+
+cleanup:
+if (tmp_filters) {
+for (i = 0; i  ret.filters.filters_len; i++)
+if (tmp_filters[i])
+virNWFilterFree(tmp_filters[i]);
+VIR_FREE(tmp_filters);
+}
+
+xdr_free((xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret, (char *) 
ret);
+
+done:
+remoteDriverUnlock(priv);
+return rv;
+}

  /*--*/

@@ -6012,6 +6074,7 @@ static virNWFilterDriver nwfilter_driver = {
  .undefine = remoteNWFilterUndefine, /* 0.8.0 */
  .numOfNWFilters   = remoteNumOfNWFilters, /* 0.8.0 */
  .listNWFilters= remoteListNWFilters, /* 0.8.0 */
+.listAllNWFilters = remoteConnectListAllNWFilters, /* 0.10.2 */
  };




Otherwise looks OK.

Peter

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


Re: [libvirt] [PATCH 06/10] list: Add helper to convert strings separated by ', ' to array

2012-09-06 Thread Osier Yang

On 2012年09月06日 00:24, Eric Blake wrote:

On 09/04/2012 09:16 AM, Osier Yang wrote:

tools/virsh.c: New helper function vshStringToArray.
tools/virsh.h: Declare vshStringToArray.
tools/virsh-domain.c: use the helper in cmdUndefine.
---
  tools/virsh-domain.c |   19 ++-
  tools/virsh.c|   44 
  tools/virsh.h|1 +
  3 files changed, 47 insertions(+), 17 deletions(-)


ACK.  This is a nice refactor for later use.

But down the road, do we want to borrow a leaf from qemu's book, and
allow for users to input ',,' for a literal comma that does not separate
options?  If so, then we should merge in the double comma handling from
vshParseSnapshotDiskspec (virsh-snapshot.c) into this function, and have
that function also refactored to use this helper.  Without something
like that, users cannot input a literal comma when listing
comma-separated arguments.



That will be nice, but seems useless for virsh now, the only two
commands which have option accepts multiple values are undefine
and pool-list. For domain undefine, the volumes can't have ',' in
the name (see the schema), for pool-list, pool types can't have ','
either.

Regards,
Osier

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

Re: [libvirt] [PATCH 0/5 v4] Atomic API to list network filters

2012-09-06 Thread Peter Krempa

On 09/05/12 08:02, Osier Yang wrote:

v3 - v4:
   * Just rebase on the top, and split the patches from v3's large set.

Osier Yang (5):
   list: Define new API virConnectListAllNWFilters
   list: Implement RPC calls for virConnectListAllNWFilters
   list: Implement listAllNWFilters
   list: Expose virConnectListAllNWFilters to Python binding
   list: Use virConnectListAllNWFilters in virsh



This series looks ok in overall so ACK if nobody else has any comments. 
(For example any filter flags. I just checked the code.)


Peter

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


Re: [libvirt] [PATCH 08/10] list: Change MATCH for common use in virsh

2012-09-06 Thread Osier Yang

On 2012年09月06日 00:30, Eric Blake wrote:

On 09/04/2012 09:16 AM, Osier Yang wrote:

Move definition of MATCH from virsh-domain-monitor.c into
virsh.h for further use.
---
  tools/virsh-domain-monitor.c |2 --
  tools/virsh.h|2 ++
  2 files changed, 2 insertions(+), 2 deletions(-)



Not quite right.


+++ b/tools/virsh.h
@@ -47,6 +47,8 @@

  # define GETTIMEOFDAY(T) gettimeofday(T, NULL)

+# define MATCH(FLAG) (flags  (FLAG))


If you're going to make the macro reusable, I think it would be better
to put it in the VSH_ namespace, and update all existing callers.



Changed to VSH_MATCH when pushing, with all MATCH replaced by VSH_MATCH
in virsh-domain-monitor.c.

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

Re: [libvirt] [PATCH 5/5] list: Use virConnectListAllNWFilters in virsh

2012-09-06 Thread Peter Krempa

On 09/05/12 08:02, Osier Yang wrote:

tools/virsh-nwfilter.c:
   * vshNWFilterSorter to sort network filters by name

   * vshNWFilterListFree to free the network filter objects list.

   * vshNWFilterListCollect to collect the network filter objects, trying
 to use new API first, fall back to older APIs if it's not supported.
---
  tools/virsh-nwfilter.c |  163 +++-
  1 files changed, 134 insertions(+), 29 deletions(-)

diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 5169d38..57cf2b7 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -190,6 +190,134 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
  return ret;
  }

+static int
+vshNWFilterSorter(const void *a, const void *b)
+{
+virNWFilterPtr *fa = (virNWFilterPtr *) a;
+virNWFilterPtr *fb = (virNWFilterPtr *) b;
+
+if (*fa  !*fb)
+return -1;
+
+if (!*fa)
+return *fb != NULL;
+
+return vshStrcasecmp(virNWFilterGetName(*fa),
+  virNWFilterGetName(*fb));


Bad indentation.


+}
+
+struct vshNWFilterList {
+virNWFilterPtr *filters;
+size_t nfilters;
+};
+typedef struct vshNWFilterList *vshNWFilterListPtr;
+
+static void
+vshNWFilterListFree(vshNWFilterListPtr list)
+{
+int i;
+
+if (list  list-nfilters) {
+for (i = 0; i  list-nfilters; i++) {
+if (list-filters[i])
+virNWFilterFree(list-filters[i]);
+}
+VIR_FREE(list-filters);
+}
+VIR_FREE(list);
+}
+
+static vshNWFilterListPtr
+vshNWFilterListCollect(vshControl *ctl,
+   unsigned int flags)
+{
+vshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list));
+int i;
+int ret;
+virNWFilterPtr filter;
+bool success = false;
+size_t deleted = 0;
+int nfilters = 0;
+char **names = NULL;
+
+/* try the list with flags support (0.10.2 and later) */
+if ((ret = virConnectListAllNWFilters(ctl-conn,
+  list-filters,
+  flags)) = 0) {
+list-nfilters = ret;
+goto finished;
+}
+
+/* check if the command is actually supported */
+if (last_error  last_error-code == VIR_ERR_NO_SUPPORT) {
+vshResetLibvirtError();
+goto fallback;
+}
+
+/* there was an error during the call */
+vshError(ctl, %s, _(Failed to list node filters));
+goto cleanup;
+
+
+fallback:
+/* fall back to old method (0.9.13 and older) */
+vshResetLibvirtError();
+
+nfilters = virConnectNumOfNWFilters(ctl-conn);
+if (nfilters  0) {
+vshError(ctl, %s, _(Failed to count network filters));
+goto cleanup;
+}
+
+if (nfilters == 0)
+return list;
+
+names = vshMalloc(ctl, sizeof(char *) * nfilters);
+
+nfilters = virConnectListNWFilters(ctl-conn, names, nfilters);
+if (nfilters  0) {
+vshError(ctl, %s, _(Failed to list network filters));
+goto cleanup;
+}
+
+list-filters = vshMalloc(ctl, sizeof(virNWFilterPtr) * (nfilters));


Brackets are not necessary around nfilters.


+list-nfilters = 0;
+
+/* get the network filters */
+for (i = 0; i  nfilters ; i++) {
+if (!(filter = virNWFilterLookupByName(ctl-conn, names[i])))
+continue;
+list-filters[list-nfilters++] = filter;
+}
+
+/* truncate network filters that weren't found */
+deleted = nfilters - list-nfilters;
+
+finished:
+/* sort the list */
+if (list-filters  list-nfilters)
+qsort(list-filters, list-nfilters,
+  sizeof(*list-filters), vshNWFilterSorter);
+
+/* truncate the list for not found filter objects */
+if (deleted)
+VIR_SHRINK_N(list-filters, list-nfilters, deleted);
+
+success = true;
+
+cleanup:
+for (i = 0; i  nfilters; i++)
+VIR_FREE(names[i]);
+VIR_FREE(names);
+
+if (!success) {
+vshNWFilterListFree(list);
+list = NULL;
+}
+
+return list;
+}
+
  /*
   * nwfilter-list command
   */



Otherwise looks OK.

Peter

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


Re: [libvirt] [PATCH 09/10 v5] list: Use virConnectListAllStoragePools in virsh

2012-09-06 Thread Osier Yang

On 2012年09月06日 00:52, Eric Blake wrote:

On 09/05/2012 12:36 AM, Osier Yang wrote:

tools/virsh-pool.c:
   * vshStoragePoolSorter to sort the pool list by pool name.

   * struct vshStoragePoolList to present the pool list, pool info
 is collected by list-poolinfo if 'details' is specified by
 user.

   * vshStoragePoolListFree to free the pool list

   * vshStoragePoolListCollect to collect the pool list, new API
 virStorageListAllPools is tried first, if it's not supported,
 fall back to older APIs.

   * New options --persistent, --transient, --autostart, --no-autostart
 and --type for pool-list. --persistent or --transient is to filter
 the returned pool list by whether the pool is persistent or not.
 --autostart or --no-autostart is to filter the returned pool list
 by whether the pool is autostarting or not. --type is to filter
 the pools by pool types. E.g.

 % virsh pool-list --all --persistent --type dir,disk

tools/virsh.pod:
* Add documentations for the new options.
---


If you rename things to VSH_MATCH in 8/10, then this patch will be impacted.


+++ b/tools/virsh-pool.c
@@ -36,6 +36,7 @@
  #include memory.h
  #include util.h
  #include xml.h
+#include conf/storage_conf.h


I'm not sure if virsh is supposed to be able to use conf/*.h files;
you're not the first offender, but the more we do this, the more we are
admitting that our public API is insufficient.  I'm wondering if we
should move the filter group constants into libvirt.h, and make them
part of the public API...

Regardless of what we decide about the above, though, I think it would
be independent cleanup patches and doesn't affect this patch.


+static vshStoragePoolListPtr
+vshStoragePoolListCollect(vshControl *ctl,
+  unsigned int flags)
+{
+vshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list));
+int i;
+int ret;
+char **names = NULL;
+virStoragePoolPtr pool;
+bool success = false;
+size_t deleted = 0;
+int persistent;
+int autostart;
+int nActivePools = 0;
+int nInactivePools = 0;
+int nAllPools = 0;
+
+/* try the list with flags support (0.10.0 and later) */


0.10.2


Updated when pushing.





+
+if (last_error  last_error-code ==  VIR_ERR_INVALID_ARG) {


Why two spaces after ==?


+
+fallback:
+/* fall back to old method (0.9.13 and older) */


0.10.1


Updated when pushing.




@@ -563,6 +790,11 @@ static const vshCmdInfo info_pool_list[] = {
  static const vshCmdOptDef opts_pool_list[] = {
  {inactive, VSH_OT_BOOL, 0, N_(list inactive pools)},
  {all, VSH_OT_BOOL, 0, N_(list inactive  active pools)},
+{transient, VSH_OT_BOOL, 0, N_(list transient pools)},
+{persistent, VSH_OT_BOOL, 0, N_(list persistent pools)},
+{autostart, VSH_OT_BOOL, 0, N_(list pools with autostart enabled)},
+{no-autostart, VSH_OT_BOOL, 0, N_(list pools with autostart disabled)},
+{type, VSH_OT_STRING, 0, N_(only list pool of specified type(s) (if 
supported))},


Missing a plural, and the parenthetical '(if supported)' doesn't add any
value.  Maybe:

N_(filter pools by type (multiple types separated by commas))


Likewise.




+if (type) {
+int poolType = -1;
+char **poolTypes = NULL;
+int npoolTypes = 0;
+
+npoolTypes = vshStringToArray((char *)type,poolTypes);
+
+for (i = 0; i  npoolTypes; i++) {
+if ((poolType = virStoragePoolTypeFromString(poolTypes[i]))  0) {
+vshError(ctl, %s, _(Invalid pool type));


Hmm.  What happens if we add new pool types in the future?  If libvirt
0.10.3 supports the new pool type 'foo', but I am connecting with virsh
0.10.2 as the client, then I am unable to specify the pool type, even
though it is valid to the server.  But I don't have any good suggestions
on how to make the full list of supported pool types available, and
which bits they map to, unless we do something like add a new API to
return a list of supported pool types and then have this virsh function
consult that list instead of hard-coding the list at the time of the
libvirt release when virsh was compiled.  Probably not worth the effort.


+case VIR_STORAGE_POOL_RBD:
+flags |= VIR_CONNECT_LIST_STORAGE_POOLS_RBD;
+break;
+default:
+break;


If we hit the default case, that means that conf/storage_conf.h has
added new pool types but we forgot to update this case statement to cope
with them.  I think you want to raise an error here instead of doing
silent fallthrough, so that we can diagnose such an issue.


Added ...

vshError(ctl, %s, _(Unknown pool type));

... when pushing.




+++ b/tools/virsh.pod
@@ -2185,13 +2185,33 @@ variables, and defaults to Cvi.

  Returns basic information about the Ipool  object.

-=item Bpool-list  [I--inactive  | I--all] [I--details]
+=item Bpool-list  [I--inactive] [I--all]
+   [I--persistent] [I--transient]

Re: [libvirt] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Wido den Hollander

On 09/06/2012 10:38 AM, Daniel Veillard wrote:

On Thu, Sep 06, 2012 at 10:18:22AM +0200, Wido den Hollander wrote:

Hi,

At the CloudStack project we are switching to Maven for building and
resolving external dependencies.

In the central Maven repository [0] the latest version of
libvirt-java is however 0.4.7

Could 0.4.8 be uploaded to this repository?

Thank you,

Wido

[0]: http://search.maven.org/#search|ga|1|org.libvirt


   it's maven which should fetch data from libvirt.org
and i though I had updated everything as needed:

http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/
http://libvirt.org/maven2/org/libvirt/libvirt/maven-metadata-local.xml

  if you can get an idea why it is not fetching then I will fix,
but I have tried to set everything up, and didn't got feedback that
it was broken or anything,



I added libvirt.org as a manual repository and while fetching the 
dependencies I saw:


[INFO] snapshot org.apache.cloudstack:xapi:5.6.100-1-SNAPSHOT: checking 
for updates from libvirt-org
Downloading: 
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom

1K downloaded  (libvirt-0.4.8.pom)
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for 
org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom - IGNORING
[INFO] snapshot org.apache.cloudstack:cloud-server:4.0.0-SNAPSHOT: 
checking for updates from libvirt-org
Downloading: 
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar

69K downloaded  (libvirt-0.4.8.jar)
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for 
org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar - IGNORING


A tcpdump shows me it is looking for:
* libvirt-0.4.8.pom.md5
* libvirt-0.4.8.pom.sha1
* libvirt-0.4.8.jar.md5
* libvirt-0.4.8.pom.sha1

These files are not available. (404)

Could it be that the central Maven repository requires the checksum to work?

Wido


Daniel



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


[libvirt] [PATCH] Remove duplicate symbols and add test case

2012-09-06 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

When the event symbols were added to the public API, not all
of them were removed from the private exports list. Solaris
gets unhappy when there are duplicated symbols. Extend the
symfile check to test for this scenario
---
 src/check-symfile.pl | 13 +
 src/libvirt_private.syms |  2 --
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/check-symfile.pl b/src/check-symfile.pl
index 454fed3..c0b7ec7 100755
--- a/src/check-symfile.pl
+++ b/src/check-symfile.pl
@@ -5,9 +5,11 @@ die syntax: $0 SYMFILE ELFLIB(S) unless int(@ARGV) = 2;
 my $symfile = shift @ARGV;
 my @elflibs = @ARGV;
 
-my @wantsyms;
+my %wantsyms;
 my %gotsyms;
 
+my $ret = 0;
+
 open SYMFILE, $symfile or die cannot read $symfile: $!;
 
 while (SYMFILE) {
@@ -21,7 +23,12 @@ while (SYMFILE) {
 
 die malformed line $_ unless /^\s*(\S+);$/;
 
-push @wantsyms, $1;
+if (exists $wantsyms{$1}) {
+   print STDERR Symbol $1 is listed twice\n;
+   $ret = 1;
+} else {
+   $wantsyms{$1} = 1;
+}
 }
 close SYMFILE;
 
@@ -37,8 +44,6 @@ foreach my $elflib (@elflibs) {
 close NM;
 }
 
-my $ret = 0;
-
 foreach my $sym (@wantsyms) {
 next if exists $gotsyms{$sym};
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65067d6..72d2095 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1177,8 +1177,6 @@ virDirCreate;
 virDoubleToStr;
 virEnumFromString;
 virEnumToString;
-virEventAddHandle;
-virEventRemoveHandle;
 virFileAbsPath;
 virFileAccessibleAs;
 virFileBuildPath;
-- 
1.7.11.2

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


Re: [libvirt] Compile libvirt on Solaris

2012-09-06 Thread Daniel P. Berrange
On Thu, Sep 06, 2012 at 08:46:33AM +, Yang Zhou (yangzho) wrote:
 Thanks for your answer! I realized actually I don't need to compile QEMU 
 driver because the libvirt client is using Remote driver to talk with 
 libvirtd and then libvirtd will call QUME driver in KVM hypervisor. So I 
 removed the --with-qume and trying compiling again only with --with-esx. 
 This time the error happens on la symbols as followings:
 
 ../src/conf/nwfilter_conf.h:600: warning: parameter has incomplete type
   CCLD   libvirt_driver_security.la
   CCLD   libvirt.la
 ld: fatal: libvirt.syms: 1616: symbol `virEventAddHandle' is already defined 
 in file: libvirt.syms
 collect2: ld returned 1 exit status

I've posted a patch for this, copying you on the mail.


 It looks like the symbols are duplicated in ./src/libvirt.la. So I tried to 
 remove duplicated symbols manually and tried the make again. Then new errors 
 happened as followings.
 
 bash-3.00# make
 make  all-recursive
 Making all in gnulib/lib
 make  all-recursive
 Making all in include
 Making all in libvirt
 Making all in src
   GENlibvirt.def
 make  all-am
   CCLD   libvirt.la
 Undefined   first referenced
  symbol in file
 networkNotifyActualDevice   libvirt.syms
 networkAllocateActualDevice libvirt.syms
 networkGetNetworkAddresslibvirt.syms
 networkBuildDhcpDaemonCommandLine   libvirt.syms
 networkReleaseActualDevice  libvirt.syms
 ld: warning: Symbol referencing errors

With current GIT these symbols are no longer exported. I see you were
compiling a old 0.9.9 release of libvirt. Please retry building the
current GIT release instead - we're not doing fixes for 0.9.9.

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


Re: [libvirt] [PATCH v4 00/10] Atomic API to list storage pools

2012-09-06 Thread Osier Yang

On 2012年09月04日 23:16, Osier Yang wrote:

Think the subject tells enough after 3 rounds, so ommits words here.

v3 - v4:
   * Just rebase on the top:
 - Version changes
 - rebase after virsh split cleanups

1/10 ~ 2/10 are ACK'ed in v3, but for easy viewing, they are still
posted.

Osier Yang (10):
   list: Define new API virStorageListAllStoragePools
   list: Add helpers for listing storage pool objects
   list: Implement the RPC calls for virConnectListAllStoragePools
   list: Implement listAllStoragePools for storage driver
   list: Implement listAllStoragePools for test driver
   list: Add helper to convert strings separated by ', ' to array
   virsh: Fix the wrong doc for pool-list
   list: Change MATCH for common use in virsh
   list: Use virConnectListAllStoragePools in virsh
   python: Expose virStorageListAllStoragePools to python binding

  daemon/remote.c   |   54 +++
  include/libvirt/libvirt.h.in  |   33 ++
  python/generator.py   |5 +-
  python/libvirt-override-api.xml   |6 +
  python/libvirt-override-virConnect.py |   12 +
  python/libvirt-override.c |   47 +++
  src/conf/storage_conf.c   |  116 ++
  src/conf/storage_conf.h   |   35 ++
  src/driver.h  |5 +
  src/libvirt.c |  112 ++-
  src/libvirt_private.syms  |1 +
  src/libvirt_public.syms   |5 +
  src/remote/remote_driver.c|   64 
  src/remote/remote_protocol.x  |   13 +-
  src/remote_protocol-structs   |   12 +
  src/storage/storage_driver.c  |   18 +
  src/test/test_driver.c|   17 +
  tools/virsh-domain-monitor.c  |2 -
  tools/virsh-domain.c  |   19 +-
  tools/virsh-pool.c|  631 -
  tools/virsh.c |   44 +++
  tools/virsh.h |3 +
  tools/virsh.pod   |   33 ++-
  23 files changed, 1249 insertions(+), 38 deletions(-)



Thanks for the reviewing, now I pushed the set with all the
pointed out nits fixed.

Regards,
Osier

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

Re: [libvirt] [PATCH] Remove duplicate symbols and add test case

2012-09-06 Thread Osier Yang

On 2012年09月06日 22:47, Daniel P. Berrange wrote:

From: Daniel P. Berrangeberra...@redhat.com

When the event symbols were added to the public API, not all
of them were removed from the private exports list. Solaris
gets unhappy when there are duplicated symbols. Extend the
symfile check to test for this scenario
---
  src/check-symfile.pl | 13 +
  src/libvirt_private.syms |  2 --
  2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/check-symfile.pl b/src/check-symfile.pl
index 454fed3..c0b7ec7 100755
--- a/src/check-symfile.pl
+++ b/src/check-symfile.pl
@@ -5,9 +5,11 @@ die syntax: $0 SYMFILE ELFLIB(S) unless int(@ARGV)= 2;
  my $symfile = shift @ARGV;
  my @elflibs = @ARGV;

-my @wantsyms;
+my %wantsyms;
  my %gotsyms;

+my $ret = 0;
+
  open SYMFILE, $symfile or die cannot read $symfile: $!;

  while (SYMFILE) {
@@ -21,7 +23,12 @@ while (SYMFILE) {

  die malformed line $_ unless /^\s*(\S+);$/;

-push @wantsyms, $1;
+if (exists $wantsyms{$1}) {
+   print STDERR Symbol $1 is listed twice\n;
+   $ret = 1;
+} else {
+   $wantsyms{$1} = 1;
+}
  }
  close SYMFILE;

@@ -37,8 +44,6 @@ foreach my $elflib (@elflibs) {
  close NM;
  }

-my $ret = 0;
-
  foreach my $sym (@wantsyms) {
  next if exists $gotsyms{$sym};

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65067d6..72d2095 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1177,8 +1177,6 @@ virDirCreate;
  virDoubleToStr;
  virEnumFromString;
  virEnumToString;
-virEventAddHandle;
-virEventRemoveHandle;
  virFileAbsPath;
  virFileAccessibleAs;
  virFileBuildPath;


ACK.

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

Re: [libvirt] [PATCH] Remove duplicate symbols and add test case

2012-09-06 Thread Laine Stump
On 09/06/2012 10:47 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com

 When the event symbols were added to the public API, not all
 of them were removed from the private exports list. Solaris
 gets unhappy when there are duplicated symbols. Extend the
 symfile check to test for this scenario
 ---
  src/check-symfile.pl | 13 +
  src/libvirt_private.syms |  2 --
  2 files changed, 9 insertions(+), 6 deletions(-)

 diff --git a/src/check-symfile.pl b/src/check-symfile.pl
 index 454fed3..c0b7ec7 100755
 --- a/src/check-symfile.pl
 +++ b/src/check-symfile.pl
 @@ -5,9 +5,11 @@ die syntax: $0 SYMFILE ELFLIB(S) unless int(@ARGV) = 2;
  my $symfile = shift @ARGV;
  my @elflibs = @ARGV;
  
 -my @wantsyms;
 +my %wantsyms;
  my %gotsyms;
  
 +my $ret = 0;
 +
  open SYMFILE, $symfile or die cannot read $symfile: $!;
  
  while (SYMFILE) {
 @@ -21,7 +23,12 @@ while (SYMFILE) {
  
  die malformed line $_ unless /^\s*(\S+);$/;
  
 -push @wantsyms, $1;
 +if (exists $wantsyms{$1}) {
 + print STDERR Symbol $1 is listed twice\n;
 + $ret = 1;
 +} else {
 + $wantsyms{$1} = 1;
 +}
  }
  close SYMFILE;
  
 @@ -37,8 +44,6 @@ foreach my $elflib (@elflibs) {
  close NM;
  }
  
 -my $ret = 0;
 -
  foreach my $sym (@wantsyms) {
  next if exists $gotsyms{$sym};
  
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 65067d6..72d2095 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1177,8 +1177,6 @@ virDirCreate;
  virDoubleToStr;
  virEnumFromString;
  virEnumToString;
 -virEventAddHandle;
 -virEventRemoveHandle;
  virFileAbsPath;
  virFileAccessibleAs;
  virFileBuildPath;

ACK.

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


[libvirt] [PATCH 1/4] Fix docs for PM event callbacks

2012-09-06 Thread Jiri Denemark
PM{Suspend,Wakeup} event callbacks were designed with a reason parameter
which could be used in the future. However, we do not transfer the
reason over RPC and thus we can never use it in the future. Make it
explicit in the docs.
---
 include/libvirt/libvirt.h.in | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index cfe5047..44c1649 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3902,8 +3902,7 @@ typedef void 
(*virConnectDomainEventTrayChangeCallback)(virConnectPtr conn,
  * virConnectDomainEventPMWakeupCallback:
  * @conn: connection object
  * @dom: domain on which the event occurred
- * @reason: reason why the callback was called, unused currently,
- *  always passes 0
+ * @reason: unused, will always be 0
  * @opaque: application specified data
  *
  * This callback occurs when the guest is waken up.
@@ -3920,8 +3919,7 @@ typedef void 
(*virConnectDomainEventPMWakeupCallback)(virConnectPtr conn,
  * virConnectDomainEventPMSuspendCallback:
  * @conn: connection object
  * @dom: domain on which the event occurred
- * @reason: reason why the callback was called, unused currently,
- *  always passes 0
+ * @reason: unused, will always be 0
  * @opaque: application specified data
  *
  * This callback occurs when the guest is waken up.
-- 
1.7.12

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


Re: [libvirt] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Wido den Hollander

On 09/06/2012 05:04 PM, Daniel Veillard wrote:

On Thu, Sep 06, 2012 at 04:47:45PM +0200, Wido den Hollander wrote:

On 09/06/2012 10:38 AM, Daniel Veillard wrote:
I added libvirt.org as a manual repository and while fetching the
dependencies I saw:

[INFO] snapshot org.apache.cloudstack:xapi:5.6.100-1-SNAPSHOT:
checking for updates from libvirt-org
Downloading:
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom
1K downloaded  (libvirt-0.4.8.pom)
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for
org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom - IGNORING
[INFO] snapshot org.apache.cloudstack:cloud-server:4.0.0-SNAPSHOT:
checking for updates from libvirt-org
Downloading:
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar
69K downloaded  (libvirt-0.4.8.jar)
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for
org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar - IGNORING


   haha, thanks !!!


A tcpdump shows me it is looking for:
* libvirt-0.4.8.pom.md5
* libvirt-0.4.8.pom.sha1
* libvirt-0.4.8.jar.md5
* libvirt-0.4.8.pom.sha1

These files are not available. (404)

Could it be that the central Maven repository requires the checksum to work?


   I'm surprized because in 0.4.7 there is no such checksums,

 http://libvirt.org/maven2/org/libvirt/libvirt/0.4.7/



Searching on the web I found that since Maven 2.1 the checksum checking 
is more strict, but I'm not 100% sure about that.



I added them to 0.4.8, could you retry ?



Yes, it works!

Downloading: 
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom

1K downloaded  (libvirt-0.4.8.pom)
[INFO] snapshot org.apache.cloudstack:cloud-server:4.0.0-SNAPSHOT: 
checking for updates from libvirt-org
Downloading: 
http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar

69K downloaded  (libvirt-0.4.8.jar)

Wido


thanks !

Daniel



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


[libvirt] [PATCH 3/4] Add PMSUSPENDED life cycle event

2012-09-06 Thread Jiri Denemark
While PMSUSPENDED state was added a long time ago, we didn't have
corresponding life cycle event.
---
 examples/domain-events/events-c/event-test.c   | 10 ++
 examples/domain-events/events-python/event-test.py |  4 +++-
 include/libvirt/libvirt.h.in   | 14 ++
 src/qemu/qemu_process.c| 12 ++--
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/examples/domain-events/events-c/event-test.c 
b/examples/domain-events/events-c/event-test.c
index fc4d575..cde60fb 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -90,6 +90,9 @@ const char *eventToString(int event) {
 case VIR_DOMAIN_EVENT_SHUTDOWN:
 ret = Shutdown;
 break;
+case VIR_DOMAIN_EVENT_PMSUSPENDED:
+ret = PMSuspended;
+break;
 }
 return ret;
 }
@@ -193,6 +196,13 @@ static const char *eventDetailToString(int event, int 
detail) {
 break;
 }
 break;
+case VIR_DOMAIN_EVENT_PMSUSPENDED:
+switch ((virDomainEventPMSuspendedDetailType) detail) {
+case VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY:
+ret = Memory;
+break;
+}
+break;
 }
 return ret;
 }
diff --git a/examples/domain-events/events-python/event-test.py 
b/examples/domain-events/events-python/event-test.py
index e3b6ed2..fd71acd 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -436,7 +436,8 @@ def eventToString(event):
  Suspended,
  Resumed,
  Stopped,
- Shutdown );
+ Shutdown,
+ PMSuspended );
 return eventStrings[event];
 
 def detailToString(event, detail):
@@ -448,6 +449,7 @@ def detailToString(event, detail):
 ( Unpaused, Migrated, Snapshot ),
 ( Shutdown, Destroyed, Crashed, Migrated, Saved, Failed, 
Snapshot),
 ( Finished )
+( Memory, )
 )
 return eventStrings[event][detail]
 
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 44c1649..19b13a7 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2812,6 +2812,7 @@ typedef enum {
 VIR_DOMAIN_EVENT_RESUMED = 4,
 VIR_DOMAIN_EVENT_STOPPED = 5,
 VIR_DOMAIN_EVENT_SHUTDOWN = 6,
+VIR_DOMAIN_EVENT_PMSUSPENDED = 7,
 
 #ifdef VIR_ENUM_SENTINELS
 VIR_DOMAIN_EVENT_LAST
@@ -2929,6 +2930,19 @@ typedef enum {
 } virDomainEventShutdownDetailType;
 
 /**
+ * virDomainEventPMSuspendedDetailType:
+ *
+ * Details about the 'pmsuspended' lifecycle event
+ */
+typedef enum {
+VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY = 0, /* Guest was PM suspended to 
memory */
+
+#ifdef VIR_ENUM_SENTINELS
+VIR_DOMAIN_EVENT_PMSUSPENDED_LAST
+#endif
+} virDomainEventPMSuspendedDetailType;
+
+/**
  * virConnectDomainEventCallback:
  * @conn: virConnect connection
  * @dom: The domain on which the event occurred
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 93653c6..77d679a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1120,6 +1120,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 {
 struct qemud_driver *driver = qemu_driver;
 virDomainEventPtr event = NULL;
+virDomainEventPtr lifecycleEvent = NULL;
 
 virDomainObjLock(vm);
 event = virDomainEventPMSuspendNewFromObj(vm);
@@ -1131,6 +1132,10 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 
 virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED,
  VIR_DOMAIN_PMSUSPENDED_UNKNOWN);
+lifecycleEvent =
+virDomainEventNewFromObj(vm,
+ VIR_DOMAIN_EVENT_PMSUSPENDED,
+ VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);
 
 if (virDomainSaveStatus(driver-caps, driver-stateDir, vm)  0) {
 VIR_WARN(Unable to save status on vm %s after suspend event,
@@ -1143,9 +1148,12 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 
 virDomainObjUnlock(vm);
 
-if (event) {
+if (event || lifecycleEvent) {
 qemuDriverLock(driver);
-qemuDomainEventQueue(driver, event);
+if (event)
+qemuDomainEventQueue(driver, event);
+if (lifecycleEvent)
+qemuDomainEventQueue(driver, lifecycleEvent);
 qemuDriverUnlock(driver);
 }
 
-- 
1.7.12

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


[libvirt] [PATCH 0/4] Fix PM events

2012-09-06 Thread Jiri Denemark
PM related events suffered from quite a lot of issues. The only thing that
actually worked was STARTED life cycle event with WAKEUP detail.

Jiri Denemark (4):
  Fix docs for PM event callbacks
  Fix PMSuspend and PMWakeup events
  Add PMSUSPENDED life cycle event
  examples: Fix event detail printing in python test

 daemon/remote.c|  2 ++
 examples/domain-events/events-c/event-test.c   | 14 --
 examples/domain-events/events-python/event-test.py |  8 +---
 include/libvirt/libvirt.h.in   | 20 
 python/libvirt-override.c  |  4 ++--
 src/qemu/qemu_process.c| 12 ++--
 6 files changed, 47 insertions(+), 13 deletions(-)

-- 
1.7.12

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


Re: [libvirt] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 04:47:45PM +0200, Wido den Hollander wrote:
 On 09/06/2012 10:38 AM, Daniel Veillard wrote:
 I added libvirt.org as a manual repository and while fetching the
 dependencies I saw:
 
 [INFO] snapshot org.apache.cloudstack:xapi:5.6.100-1-SNAPSHOT:
 checking for updates from libvirt-org
 Downloading:
 http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom
 1K downloaded  (libvirt-0.4.8.pom)
 [WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for
 org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom - IGNORING
 [INFO] snapshot org.apache.cloudstack:cloud-server:4.0.0-SNAPSHOT:
 checking for updates from libvirt-org
 Downloading:
 http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar
 69K downloaded  (libvirt-0.4.8.jar)
 [WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for
 org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar - IGNORING

  haha, thanks !!!

 A tcpdump shows me it is looking for:
 * libvirt-0.4.8.pom.md5
 * libvirt-0.4.8.pom.sha1
 * libvirt-0.4.8.jar.md5
 * libvirt-0.4.8.pom.sha1
 
 These files are not available. (404)
 
 Could it be that the central Maven repository requires the checksum to work?

  I'm surprized because in 0.4.7 there is no such checksums,

http://libvirt.org/maven2/org/libvirt/libvirt/0.4.7/

I added them to 0.4.8, could you retry ?

   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 4/4] examples: Fix event detail printing in python test

2012-09-06 Thread Jiri Denemark
If there is only one detail string for a particular event, we need to pu
comma after the string otherwise the string itself will be taken as a
list and only its first character will be printed out. For example,

myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown F

instead of the desired

myDomainEventCallback1 EVENT: Domain fedora17(12) Shutdown Finished
---
 examples/domain-events/events-python/event-test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/domain-events/events-python/event-test.py 
b/examples/domain-events/events-python/event-test.py
index fd71acd..3e314bf 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -443,12 +443,12 @@ def eventToString(event):
 def detailToString(event, detail):
 eventStrings = (
 ( Added, Updated ),
-( Removed ),
+( Removed, ),
 ( Booted, Migrated, Restored, Snapshot, Wakeup ),
 ( Paused, Migrated, IOError, Watchdog, Restored, Snapshot 
),
 ( Unpaused, Migrated, Snapshot ),
 ( Shutdown, Destroyed, Crashed, Migrated, Saved, Failed, 
Snapshot),
-( Finished )
+( Finished, ),
 ( Memory, )
 )
 return eventStrings[event][detail]
-- 
1.7.12

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


[libvirt] [PATCH 2/4] Fix PMSuspend and PMWakeup events

2012-09-06 Thread Jiri Denemark
The unused reason parameter of PM{Suspend,Wakeup} event callbacks was
completely ignored in lot of places and those events were not actually
working at all.
---
 daemon/remote.c  | 2 ++
 examples/domain-events/events-c/event-test.c | 4 ++--
 python/libvirt-override.c| 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 24928f4..8942c72 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -536,6 +536,7 @@ static int remoteRelayDomainEventTrayChange(virConnectPtr 
conn ATTRIBUTE_UNUSED,
 
 static int remoteRelayDomainEventPMWakeup(virConnectPtr conn ATTRIBUTE_UNUSED,
   virDomainPtr dom,
+  int reason ATTRIBUTE_UNUSED,
   void *opaque) {
 virNetServerClientPtr client = opaque;
 remote_domain_event_pmwakeup_msg data;
@@ -558,6 +559,7 @@ static int remoteRelayDomainEventPMWakeup(virConnectPtr 
conn ATTRIBUTE_UNUSED,
 
 static int remoteRelayDomainEventPMSuspend(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr dom,
+   int reason ATTRIBUTE_UNUSED,
void *opaque) {
 virNetServerClientPtr client = opaque;
 remote_domain_event_pmsuspend_msg data;
diff --git a/examples/domain-events/events-c/event-test.c 
b/examples/domain-events/events-c/event-test.c
index 347ee5a..fc4d575 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -377,7 +377,7 @@ static int myDomainEventPMWakeupCallback(virConnectPtr conn 
ATTRIBUTE_UNUSED,
  int reason ATTRIBUTE_UNUSED,
  void *opaque ATTRIBUTE_UNUSED)
 {
-printf(%s EVENT: Domain %s(%d) system pmwakeup,
+printf(%s EVENT: Domain %s(%d) system pmwakeup\n,
__func__, virDomainGetName(dom), virDomainGetID(dom));
 return 0;
 }
@@ -387,7 +387,7 @@ static int myDomainEventPMSuspendCallback(virConnectPtr 
conn ATTRIBUTE_UNUSED,
   int reason ATTRIBUTE_UNUSED,
   void *opaque ATTRIBUTE_UNUSED)
 {
-printf(%s EVENT: Domain %s(%d) system pmsuspend,
+printf(%s EVENT: Domain %s(%d) system pmsuspend\n,
__func__, virDomainGetName(dom), virDomainGetID(dom));
 return 0;
 }
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 65e8c69..3e9ee89 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5285,7 +5285,7 @@ 
libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSE
 /* Call the Callback Dispatcher */
 pyobj_ret = PyObject_CallMethod(pyobj_conn,
 
(char*)_dispatchDomainEventPMWakeupCallback,
-(char*)OO,
+(char*)OiO,
 pyobj_dom,
 reason,
 pyobj_cbData);
@@ -5332,7 +5332,7 @@ 
libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUS
 /* Call the Callback Dispatcher */
 pyobj_ret = PyObject_CallMethod(pyobj_conn,
 
(char*)_dispatchDomainEventPMSuspendCallback,
-(char*)OO,
+(char*)OiO,
 pyobj_dom,
 reason,
 pyobj_cbData);
-- 
1.7.12

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


Re: [libvirt] [PATCH] Define DYNLIB_NAME on OpenBSD.

2012-09-06 Thread Eric Blake
On 09/06/2012 01:39 AM, Daniel Veillard wrote:
 On Tue, Sep 04, 2012 at 04:56:13PM +0200, Jasper Lievisse Adriaanse wrote:
 From 05dd99030d865127c874d1b489b9c17412bdbb3b Mon Sep 17 00:00:00 2001
 From: Jasper Lievisse Adriaanse jas...@humppa.nl
 Date: Tue, 4 Sep 2012 16:48:51 +0200
 Subject: [PATCH] Define DYNLIB_NAME on OpenBSD.

 -#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || 
 defined(__FreeBSD__)
 +#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || 
 defined(__FreeBSD__) || defined(__OpenBSD__)
  # define DYNLIB_NAMEVBoxXPCOMC.so
  #elif defined(__APPLE__)
  # define DYNLIB_NAMEVBoxXPCOMC.dylib
 
   This one is a no-brainer, ACK and pushed,

Agreed, although using \ line continuation for keeping within 80 columns
might have been nice.  My usual aversion to platform defines rather than
feature-based configure checks doesn't really apply to this patch,
because I don't know how to write a configure check to determine
preferred dnylib naming, short of doing platform-specific checks in the
first place.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [RFC PATCH v1 1/2] Qemu/Gluster: Add Gluster protocol as supported network disk formats.

2012-09-06 Thread Bharata B Rao
On Wed, Sep 5, 2012 at 8:45 PM, Eric Blake ebl...@redhat.com wrote:
 On 09/05/2012 09:08 AM, Bharata B Rao wrote:
 On Wed, Sep 5, 2012 at 7:03 PM, Jiri Denemark jdene...@redhat.com wrote:
 @@ -1042,6 +1043,13 @@
  attribute name=port
ref name=unsignedInt/
  /attribute
 +attribute name=transport
 +  choice
 +valuesocket/value
 +valueunix/value
 +valuerdma/value

 This could be a bit confusing as socket is too generic, after all unix is 
 also
 a socket. Could we change the values tcp, unix, rdma or something
 similar depending on what socket was supposed to mean?

 That is how gluster calls it and hence I am using the same in QEMU and
 the same is true here too. This is something for gluster developers to
 decide if they want to change socket to something more specific like
 tcp as you suggest.

 Just because gluster calls it a confusing name does not mean we have to
 repeat the confusion in libvirt - it is feasible to have a mapping where
 we name it 'tcp' in the XML but map that to 'socket' in the command line
 that eventually reaches gluster.  The question then becomes whether
 using sensible naming in libvirt, but no longer directly mapped to
 underlying gluster naming, will be the cause of its own set of headaches.

Vijay - would really like to have your inputs here...

- While the transport-type for a volume is shown as tcp in gluster
volume info, libgfapi forces me to use transport=socket to access the
same volume from QEMU. So does socket mean tcp really ? If so,
should I just switch over to using transport=tcp from QEMU ? If not,
can you explain a bit about the difference b/n socket and tcp
transport types ?

- Also apart from socket (or tcp ?), rdma and unix, are there any
other transport options that QEMU should care about ?

- Are rdma and unix transport types operational at the moment ? If
not, do you see them being used in gluster any time in the future ?
The reason behind asking this is to check if we are spending effort in
defining semantics in QEMU for a transport type that is never going to
be used in gluster. Also I see that gluster volume create supports
tcp and rdma but doesn't list unix as an option.

Regards,
Bharata.

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


Re: [libvirt] [libvirt-java] Upload 0.4.8 to central Maven repository

2012-09-06 Thread Daniel Veillard
On Thu, Sep 06, 2012 at 05:08:21PM +0200, Wido den Hollander wrote:
 On 09/06/2012 05:04 PM, Daniel Veillard wrote:
 On Thu, Sep 06, 2012 at 04:47:45PM +0200, Wido den Hollander wrote:
 A tcpdump shows me it is looking for:
 * libvirt-0.4.8.pom.md5
 * libvirt-0.4.8.pom.sha1
 * libvirt-0.4.8.jar.md5
 * libvirt-0.4.8.pom.sha1
 
 These files are not available. (404)
 
 Could it be that the central Maven repository requires the checksum to work?
 
I'm surprized because in 0.4.7 there is no such checksums,
 
  http://libvirt.org/maven2/org/libvirt/libvirt/0.4.7/
 
 
 Searching on the web I found that since Maven 2.1 the checksum
 checking is more strict, but I'm not 100% sure about that.
 
 I added them to 0.4.8, could you retry ?
 
 
 Yes, it works!
 
 Downloading:
 http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.pom
 1K downloaded  (libvirt-0.4.8.pom)
 [INFO] snapshot org.apache.cloudstack:cloud-server:4.0.0-SNAPSHOT:
 checking for updates from libvirt-org
 Downloading:
 http://libvirt.org/maven2/org/libvirt/libvirt/0.4.8/libvirt-0.4.8.jar
 69K downloaded  (libvirt-0.4.8.jar)

  Ah, cool, now i hope the main raven repository is gonna refetch the
data. I think they do that daily, I just hope they will refetch if
in case of error if the timestamp didn't change.
  In any case i will have to do a libvirt-java release soon, then
we can push the next version to the main repo,

  thanks again !

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] list: fix typo in virsh patch

2012-09-06 Thread Eric Blake
A last minute rename in an earlier patch to virsh.h was not properly
reflected when rebasing virsh-pool.c.

* tools/virsh-pool.c (vshStoragePoolListCollect): Use VSH_MATCH,
not MATCH.
---

Pushing under the build-breaker rule.

 tools/virsh-pool.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 365d035..15d1883 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -642,15 +642,15 @@ fallback:
 vshResetLibvirtError();

 /* There is no way to get the pool type */
-if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)) {
+if (VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)) {
 vshError(ctl, %s, _(Filtering using --type is not supported 
   by this libvirt));
 goto cleanup;
 }

 /* Get the number of active pools */
-if (!MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
-MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
+if (!VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
+VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
 if ((nActivePools = virConnectNumOfStoragePools(ctl-conn))  0) {
 vshError(ctl, %s, _(Failed to get the number of active pools 
));
 goto cleanup;
@@ -658,8 +658,8 @@ fallback:
 }

 /* Get the number of inactive pools */
-if (!MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
-MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE)) {
+if (!VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
+VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE)) {
 if ((nInactivePools = virConnectNumOfDefinedStoragePools(ctl-conn))  
0) {
 vshError(ctl, %s, _(Failed to get the number of inactive 
pools));
 goto cleanup;
@@ -674,8 +674,8 @@ fallback:
 names = vshMalloc(ctl, sizeof(char *) * nAllPools);

 /* Retrieve a list of active storage pool names */
-if (!MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
-MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
+if (!VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
+VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
 if (virConnectListStoragePools(ctl-conn,
names, nActivePools)  0) {
 vshError(ctl, %s, _(Failed to list active pools));
@@ -684,8 +684,8 @@ fallback:
 }

 /* Add the inactive storage pools to the end of the name list */
-if (!MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
-MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
+if (!VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ACTIVE) ||
+VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)) {
 if (virConnectListDefinedStoragePools(ctl-conn,
   names[nActivePools],
   nInactivePools)  0) {
@@ -720,26 +720,26 @@ filter:
 pool = list-pools[i];

 /* persistence filter */
-if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT)) {
+if (VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_PERSISTENT)) {
 if ((persistent = virStoragePoolIsPersistent(pool))  0) {
 vshError(ctl, %s, _(Failed to get pool persistence info));
 goto cleanup;
 }

-if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT)  
persistent) ||
-  (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT)  
!persistent)))
+if (!((VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT)  
persistent) ||
+  (VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT)  
!persistent)))
 goto remove_entry;
 }

 /* autostart filter */
-if (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART)) {
+if (VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART)) {
 if (virStoragePoolGetAutostart(pool, autostart)  0) {
 vshError(ctl, %s, _(Failed to get pool autostart state));
 goto cleanup;
 }

-if (!((MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART)  
autostart) ||
-  (MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART)  
!autostart)))
+if (!((VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART)  
autostart) ||
+  (VSH_MATCH(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART)  
!autostart)))
 goto remove_entry;
 }

-- 
1.7.11.4

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


Re: [libvirt] [PATCH] Remove duplicate symbols and add test case

2012-09-06 Thread Eric Blake
On 09/06/2012 08:47 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 When the event symbols were added to the public API, not all
 of them were removed from the private exports list. Solaris
 gets unhappy when there are duplicated symbols. Extend the
 symfile check to test for this scenario
 ---
  src/check-symfile.pl | 13 +
  src/libvirt_private.syms |  2 --
  2 files changed, 9 insertions(+), 6 deletions(-)

This breaks 'syntax-check' due to TABs, I'm pushing the obvious fix.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v0] qemu: Add sandbox support.

2012-09-06 Thread Corey Bryant



On 09/06/2012 02:45 AM, Daniel Veillard wrote:

On Thu, Sep 06, 2012 at 02:27:19PM +0800, Daniel Veillard wrote:

On Mon, Sep 03, 2012 at 02:03:39PM +0200, Ján Tomko wrote:

QEMU (since 1.2-rc0) supports setting up a syscall whitelist through
libseccomp on linux kernel from 3.5-rc1. This is enabled by specifying
-sandbox on on qemu command line.

This patch detects this capability by searching for -sandbox in qemu
help output and runs qemu with -sandbox on if sandbox is set to non-zero
in qemu.conf.

[...]

   As-is the patch looks fine to me, now the real question as you pointed
out is do we want to enforce that at the guest level.
   In general, if available sandboxing should be turned on unless we hit
a bug, so if it work as expected, it should always be on, which to me
would be an indication to have that as a global default for the driver
(and on by default).
   If you have to rely on the user explicit setting to activate it, it
won't be activated, if security implementations are good enough they
are better off as default settings IMHO,

   So ACK to this, except I would change src/qemu/qemu.conf patch to
enable it by default, i.e. remove the leading # ... then testing will
tell us if we can keep it on.


   I just asked Chris Evans the vsftpd maintainer since I know he added
support for it, except for a couple of bugs on Fedora he activated it by
default if the kernel supports it, and things seems to work just fine.

   So yeah I would keep that a global setting and activated by default,
if there are bugs in the kernel or the qemu side we may revisit this
but let's see first what kind of bugs pop up, and at the distro level
it's easy to switch back to off if there is serious problems.

Daniel



We turned this off by default in QEMU 1.2.  The thought was that we'd 
get more testing coverage.  It's a tough feature to test completely, and 
if a syscall was missed in the whitelist, then your guest is dead.  The 
plan is to turn it on by default in QEMU 1.3.  Perhaps you want to do 
something similar in libvirt?


--
Regards,
Corey

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


Re: [libvirt] [PATCH 1/1 V2] Migrate per-port data for Open vSwitch ports during Qemu Live Migration

2012-09-06 Thread Laine Stump
On 09/04/2012 04:35 PM, Kyle Mestery wrote:
 Add the ability to migrate per-port data on Open vSwitch
 ports during qemu live migration. A controller can use this
 to store data relating to each port, and have it migrated
 with the virtual machine and populated on the destination
 host.

Good job in figuring this out!


 Signed-off-by: Kyle Mestery kmest...@cisco.com
 Cc: Laine Stump la...@laine.org
 ---
  src/qemu/qemu_migration.c | 246 
 +-
  1 file changed, 244 insertions(+), 2 deletions(-)

 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
 index 1b21ef6..8c1a8f1 100644
 --- a/src/qemu/qemu_migration.c
 +++ b/src/qemu/qemu_migration.c
 @@ -70,6 +70,7 @@ enum qemuMigrationCookieFlags {
  QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
  QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
  QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
 +QEMU_MIGRATION_COOKIE_FLAG_OVS_PORT_DATA,
  
  QEMU_MIGRATION_COOKIE_FLAG_LAST
  };
 @@ -77,12 +78,13 @@ enum qemuMigrationCookieFlags {
  VIR_ENUM_DECL(qemuMigrationCookieFlag);
  VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
 -  graphics, lockstate, persistent);
 +  graphics, lockstate, persistent, ovsportdata);
  
  enum qemuMigrationCookieFeatures {
  QEMU_MIGRATION_COOKIE_GRAPHICS  = (1  
 QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
  QEMU_MIGRATION_COOKIE_LOCKSTATE = (1  
 QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE),
  QEMU_MIGRATION_COOKIE_PERSISTENT = (1  
 QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT),
 +QEMU_MIGRATION_COOKIE_OVS_PORT_DATA = (1  
 QEMU_MIGRATION_COOKIE_FLAG_OVS_PORT_DATA),
  };
  
  typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
 @@ -95,6 +97,19 @@ struct _qemuMigrationCookieGraphics {
  char *tlsSubject;
  };
  
 +typedef struct _qemuMigrationCookieOvsPortData 
 qemuMigrationCookieOvsPortData;
 +typedef qemuMigrationCookieOvsPortData *qemuMigrationCookieOvsPortDataPtr;
 +struct _qemuMigrationCookieOvsPortData {
 +/* How many virtual NICs are we saving data for? */
 +int nnets;
 +
 +/*
 + * Array of pointers to saved data. Each VIF will have it's own
 + * data to transfer.
 + */
 +char **portdata;
 +};
 +
  typedef struct _qemuMigrationCookie qemuMigrationCookie;
  typedef qemuMigrationCookie *qemuMigrationCookiePtr;
  struct _qemuMigrationCookie {
 @@ -120,6 +135,9 @@ struct _qemuMigrationCookie {
  
  /* If (flags  QEMU_MIGRATION_COOKIE_PERSISTENT) */
  virDomainDefPtr persistent;
 +
 +/* If (flags  QEMU_MIGRATION_COOKIE_OVS_PORT_DATA) */
 +qemuMigrationCookieOvsPortDataPtr ovsportdata;
  };
  
  static void qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphicsPtr 
 grap)
 @@ -132,6 +150,24 @@ static void 
 qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphicsPtr grap)
  }
  
  
 +static void 
 qemuMigrationCookieOvsPortDataFree(qemuMigrationCookieOvsPortDataPtr
 +   ovsportdata)
 +{
 +int i;
 +
 +if (!ovsportdata)
 +return;
 +
 +for (i = 0; i  ovsportdata-nnets; i++) {
 +VIR_FREE(ovsportdata-portdata[i]);
 +}
 +
 +VIR_FREE(ovsportdata-portdata);
 +
 +VIR_FREE(ovsportdata);
 +}
 +
 +
  static void qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
  {
  if (!mig)
 @@ -140,6 +176,10 @@ static void 
 qemuMigrationCookieFree(qemuMigrationCookiePtr mig)
  if (mig-flags  QEMU_MIGRATION_COOKIE_GRAPHICS)
  qemuMigrationCookieGraphicsFree(mig-graphics);
  
 +if (mig-flags  QEMU_MIGRATION_COOKIE_OVS_PORT_DATA) {
 +qemuMigrationCookieOvsPortDataFree(mig-ovsportdata);
 +}
 +
  VIR_FREE(mig-localHostname);
  VIR_FREE(mig-remoteHostname);
  VIR_FREE(mig-name);
 @@ -256,6 +296,60 @@ error:
  }
  
  
 +static qemuMigrationCookieOvsPortDataPtr
 +qemuMigrationCookieOvsPortDataAlloc(struct qemud_driver *driver 
 ATTRIBUTE_UNUSED,
 +virDomainDefPtr def)
 +{
 +qemuMigrationCookieOvsPortDataPtr mig;
 +int i;
 +virCommandPtr cmd = NULL;
 +virDomainNetDefPtr netptr;
 +
 +if (VIR_ALLOC(mig)  0)
 +goto no_memory;
 +
 +mig-nnets = def-nnets;
 +
 +if (VIR_ALLOC_N(mig-portdata, def-nnets)  0)
 +goto no_memory;
 +
 +for (i = 0; i  def-nnets; i++) {
 +virNetDevVPortProfilePtr vport = 
 virDomainNetGetActualVirtPortProfile(def-nets[i]);
 +netptr = def-nets[i];
 +
 +if (vport  vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
 +if (VIR_ALLOC(mig-portdata[i])  0)
 +goto no_memory;
 +
 +cmd = virCommandNewArgList(OVSVSCTL, get, Interface,
 +   netptr-ifname, 
 external_ids:PortData,
 +   NULL);
 +
 +virCommandSetOutputBuffer(cmd, mig-portdata[i]);
 +
 +/* Run the command */
 +if 

Re: [libvirt] [PATCH v0] qemu: Add sandbox support.

2012-09-06 Thread Corey Bryant



On 09/06/2012 02:27 AM, Daniel Veillard wrote:

On Mon, Sep 03, 2012 at 02:03:39PM +0200, Ján Tomko wrote:

QEMU (since 1.2-rc0) supports setting up a syscall whitelist through
libseccomp on linux kernel from 3.5-rc1. This is enabled by specifying
-sandbox on on qemu command line.

This patch detects this capability by searching for -sandbox in qemu
help output and runs qemu with -sandbox on if sandbox is set to non-zero
in qemu.conf.

---
Should this option be in qemu.conf, or would it be better to set it
per-domain in the XML?
---
  src/qemu/qemu.conf   |6 ++
  src/qemu/qemu_capabilities.c |3 +++
  src/qemu/qemu_capabilities.h |1 +
  src/qemu/qemu_command.c  |3 +++
  src/qemu/qemu_conf.c |5 +
  src/qemu/qemu_conf.h |1 +
  6 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index d3175fa..47e510e 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -375,3 +375,9 @@
  #
  #keepalive_interval = 5
  #keepalive_count = 5
+
+
+
+# Enable this to use seccomp syscall whitelisting in QEMU.
+#
+#sandbox = 1
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2ba7956..b0728e8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -176,6 +176,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
disable-s3,

disable-s4, /* 105 */
+  sandbox
  );

  struct qemu_feature_flags {
@@ -1139,6 +1140,8 @@ qemuCapsComputeCmdFlags(const char *help,
  }
  if (strstr(help, -smbios type))
  qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
+if (strstr(help, -sandbox))
+qemuCapsSet(flags, QEMU_CAPS_SANDBOX);

  if ((netdev = strstr(help, -netdev))) {
  /* Disable -netdev on 0.12 since although it exists,
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a7b3a06..0066901 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -141,6 +141,7 @@ enum qemuCapsFlags {
  QEMU_CAPS_IOLIMITS   = 103, /* -device ...logical_block_size  co 
*/
  QEMU_CAPS_DISABLE_S3 = 104, /* S3 BIOS Advertisement on/off */
  QEMU_CAPS_DISABLE_S4 = 105, /* S4 BIOS Advertisement on/off */
+QEMU_CAPS_SANDBOX= 106, /* -sandbox */

  QEMU_CAPS_LAST,   /* this must always be the last item */
  };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e739f34..737d4d9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6462,6 +6462,9 @@ qemuBuildCommandLine(virConnectPtr conn,
   ? qemucmd-env_value[i] : );
  }

+if (driver-sandbox  qemuCapsGet(qemuCaps, QEMU_CAPS_SANDBOX))
+virCommandAddArgList(cmd, -sandbox, on, NULL);
+
  return cmd;

   no_memory:
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e9e15c5..a367fcd 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -129,6 +129,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,

  driver-keepAliveInterval = 5;
  driver-keepAliveCount = 5;
+driver-sandbox = false;

  /* Just check the file is readable before opening it, otherwise
   * libvirt emits an error.
@@ -570,6 +571,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
  CHECK_TYPE(keepalive_count, VIR_CONF_LONG);
  if (p) driver-keepAliveCount = p-l;

+p = virConfGetValue(conf, sandbox);
+CHECK_TYPE(sandbox, VIR_CONF_LONG);
+if (p) driver-sandbox = p-l;
+
  virConfFree (conf);
  return 0;
  }
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index ac285f6..f1b6465 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -152,6 +152,7 @@ struct qemud_driver {

  int keepAliveInterval;
  unsigned int keepAliveCount;
+bool sandbox;
  };

  typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef;


   As-is the patch looks fine to me, now the real question as you pointed
out is do we want to enforce that at the guest level.
   In general, if available sandboxing should be turned on unless we hit
a bug, so if it work as expected, it should always be on, which to me
would be an indication to have that as a global default for the driver
(and on by default).
   If you have to rely on the user explicit setting to activate it, it
won't be activated, if security implementations are good enough they
are better off as default settings IMHO,


I agree, it should be on by default and turned off only if there's a 
problem with the syscall whitelist.  However, note what I said in my 
previous email that we don't plan to default to on until QEMU 1.3.


--
Regards,
Corey



   So ACK to this, except I would change src/qemu/qemu.conf patch to
enable it by default, i.e. remove the leading # ... then testing will
tell us if we can keep it on.

Daniel



--
libvir-list mailing list
libvir-list@redhat.com

[libvirt] need help/clarification about git and patches.

2012-09-06 Thread Gene Czarcinski
Using git is more than a little different way of doing business for me.  
My usual way to create and apply a patch is to rebuild a src.rpm.  This 
way I have a lot less changes of screwing something up because of ignorance.


It it a little while but I finally cloned a copy of libvirt.git.  I 
applied a patch to remove the --filterwin2k [one fixup because a test 
file changed slightly.  I then ran git diff and produce a new patch.


OK, now what?  I did the git commit and then tried to do the git 
send-email like it says in your hacking document ...

   git: 'send-email' is not a git command.

I am going to do what I believe is the right thing to do and submit the 
patch but there needs to be a bit more info as to how we should do things.


Gene

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


[libvirt] [PATCH] remove dnsmasq command line parameter --filterwin2k

2012-09-06 Thread Gene Czarcinski

  This patch removed the --filterwin2k dnsmasq command line
  parameter which was unnecessary for domain specification,
  possibly blocked some usage, and was command line clutter.

  Gene Czarcinski g...@czarc.net



diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 53eebed..808c843 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -543,7 +543,7 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
 /* need to specify local even if no domain specified */
 virCommandAddArgFormat(cmd, --local=/%s/,
network-def-domain ? network-def-domain 
: );

-virCommandAddArgList(cmd, --domain-needed, --filterwin2k, NULL);
+virCommandAddArg(cmd, --domain-needed);

 if (pidfile)
 virCommandAddArgPair(cmd, --pid-file, pidfile);
diff --git a/tests/networkxml2argvdata/isolated-network.argv 
b/tests/networkxml2argvdata/isolated-network.argv

index 276f42a..048c72b 100644
--- a/tests/networkxml2argvdata/isolated-network.argv
+++ b/tests/networkxml2argvdata/isolated-network.argv
@@ -1,5 +1,5 @@
 @DNSMASQ@ --strict-order --bind-interfaces \
---local=// --domain-needed --filterwin2k --conf-file= \
+--local=// --domain-needed --conf-file= \
 --except-interface lo --dhcp-option=3 --no-resolv \
 --listen-address 192.168.152.1 \
 --dhcp-range 192.168.152.2,192.168.152.254 \
diff --git a/tests/networkxml2argvdata/nat-network-dns-hosts.argv 
b/tests/networkxml2argvdata/nat-network-dns-hosts.argv

index 8040e2a..03a0676 100644
--- a/tests/networkxml2argvdata/nat-network-dns-hosts.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-hosts.argv
@@ -1,4 +1,4 @@
 @DNSMASQ@ --strict-order --bind-interfaces --domain=example.com \
---local=/example.com/ --domain-needed --filterwin2k \
+--local=/example.com/ --domain-needed \
 --conf-file= --except-interface lo --listen-address 192.168.122.1 \
 --expand-hosts --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
diff --git 
a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv 
b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv

index bb50fd6..a1e4200 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --bind-interfaces \
---local=// --domain-needed --filterwin2k --conf-file= \
+--local=// --domain-needed --conf-file= \
 --except-interface lo \
 --srv-host=name.tcp. \
 --listen-address 192.168.122.1 \
diff --git a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv 
b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv

index 36498f2..8af38c4 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
@@ -1,7 +1,7 @@
 @DNSMASQ@ \
 --strict-order \
 --bind-interfaces \
---local=// --domain-needed --filterwin2k --conf-file= \
+--local=// --domain-needed --conf-file= \
 --except-interface lo \
 --srv-host=name.tcp.test-domain-name,.,1024,10,10 \
 --listen-address 192.168.122.1 \
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv 
b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv

index 2a6c799..404b56a 100644
--- a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
@@ -1,5 +1,5 @@
 @DNSMASQ@ --strict-order --bind-interfaces \
---local=// --domain-needed --filterwin2k --conf-file= \
+--local=// --domain-needed --conf-file= \
 --except-interface lo '--txt-record=example,example value' \
 --listen-address 192.168.122.1 --listen-address 192.168.123.1 \
 --listen-address 2001:db8:ac10:fe01::1 \
diff --git a/tests/networkxml2argvdata/nat-network.argv 
b/tests/networkxml2argvdata/nat-network.argv

index 265b931..1dc8f73 100644
--- a/tests/networkxml2argvdata/nat-network.argv
+++ b/tests/networkxml2argvdata/nat-network.argv
@@ -1,5 +1,5 @@
 @DNSMASQ@ --strict-order --bind-interfaces \
---local=// --domain-needed --filterwin2k --conf-file= \
+--local=// --domain-needed --conf-file= \
 --except-interface lo --listen-address 192.168.122.1 \
 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 \
 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 \
diff --git a/tests/networkxml2argvdata/netboot-network.argv 
b/tests/networkxml2argvdata/netboot-network.argv

index 4f998d5..5a85ec2 100644
--- a/tests/networkxml2argvdata/netboot-network.argv
+++ b/tests/networkxml2argvdata/netboot-network.argv
@@ -1,5 +1,5 @@
 @DNSMASQ@ --strict-order --bind-interfaces --domain=example.com \
---local=/example.com/ --domain-needed --filterwin2k --conf-file= \
+--local=/example.com/ --domain-needed --conf-file= \
 --except-interface lo --listen-address 192.168.122.1 \
 --dhcp-range 192.168.122.2,192.168.122.254 \
 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
diff --git 

Re: [libvirt] need help/clarification about git and patches.

2012-09-06 Thread Eric Blake
On 09/06/2012 09:59 AM, Gene Czarcinski wrote:
 Using git is more than a little different way of doing business for me. 
 My usual way to create and apply a patch is to rebuild a src.rpm.  This
 way I have a lot less changes of screwing something up because of
 ignorance.
 
 It it a little while but I finally cloned a copy of libvirt.git.  I
 applied a patch to remove the --filterwin2k [one fixup because a test
 file changed slightly.  I then ran git diff and produce a new patch.

Seems reasonable.  If the instructions in HACKING could use an
improvement, let us know what we can do to make it better.

 
 OK, now what?  I did the git commit and then tried to do the git
 send-email like it says in your hacking document ...
git: 'send-email' is not a git command.

Ah, that's because 'git send-email' is not packaged with 'git' in
Fedora.  You want to also install the 'git-email' package.  (Why it
isn't shipped as part of the core git package is beyond me, but I'm not
the package maintainer.)

 
 I am going to do what I believe is the right thing to do and submit the
 patch but there needs to be a bit more info as to how we should do things.

Feel free to ask questions like this.  Sounds like our HACKING should
mention the 'git-email' package on Fedora, for starters.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] build: improved handling of execinfo.h, BSD net/if.h

2012-09-06 Thread Eric Blake
On 09/06/2012 01:41 AM, Daniel Veillard wrote:
 On Wed, Sep 05, 2012 at 04:39:28PM -0600, Eric Blake wrote:
 FreeBSD and OpenBSD have a net/if.h that is not self-contained;
 and mingw lacks the header altogether.  But gnulib has just taken
 care of that for us, so we might as well simplify our code.  In
 the process, I got a syntax-check failure if we don't also take
 the gnulib execinfo module.



   ACK, let's push that sooner than later :-)

Thanks; pushed.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [libvirt-designer][PATCH 3/4] virtxml: Detect OS from given ISO

2012-09-06 Thread Michal Privoznik
In some cases telling OS version is redundant as ISO image
with specified OS is passed some arguments later as disk.
Don't require --os then.
---
 examples/virtxml.c |   76 ---
 1 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/examples/virtxml.c b/examples/virtxml.c
index 468bc2a..131c462 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -253,6 +253,67 @@ add_iface(gpointer data,
 }
 }
 
+static OsinfoOs *
+guess_os_from_disk(GList *disk_str_list)
+{
+OsinfoOs *ret = NULL;
+GList *tmp = g_list_first(disk_str_list);
+OsinfoLoader *loader = osinfo_loader_new();
+GError *error = NULL;
+OsinfoDb *db;
+
+osinfo_loader_process_default_path(loader, error);
+if (error) {
+print_error(Error loading libosinfo data: %s, error-message);
+goto cleanup;
+}
+
+db = osinfo_loader_get_db(loader);
+
+while (tmp) {
+char *path = (char *) tmp-data;
+char *sep = strchr(path, ',');
+OsinfoMedia *media = NULL;
+OsinfoMedia *matched_media = NULL;
+
+if (sep) {
+path = g_strndup(path, sep-path);
+}
+
+media = osinfo_media_create_from_location(path, NULL, error);
+if (error) {
+/* don't report error but silently continue to next disk */
+print_error(%s, error-message);
+g_error_free(error);
+error = NULL;
+tmp = g_list_next(tmp);
+continue;
+}
+
+ret = osinfo_db_guess_os_from_media(db, media, matched_media);
+
+if (sep)
+g_free(path);
+
+if (ret) {
+g_object_ref(ret);
+break;
+}
+
+tmp = g_list_next(tmp);
+}
+
+cleanup:
+g_clear_object(loader);
+return ret;
+}
+
+static OsinfoPlatform *
+guess_platform_from_connect(virConnectPtr conn)
+{
+return NULL;
+}
+
 #define CHECK_ERROR \
 if (error) {\
 print_error(%s, error-message);  \
@@ -371,10 +432,6 @@ main(int argc, char *argv[])
 }
 }
 
-if (!os_str) {
-print_error(Operating system was not specified);
-exit(EXIT_FAILURE);
-}
 if (!platform_str) {
 print_error(Platform was not specified);
 exit(EXIT_FAILURE);
@@ -391,10 +448,19 @@ main(int argc, char *argv[])
 goto cleanup;
 }
 
-os = osinfo_os_new(os_str);
 platform = osinfo_platform_new(platform_str);
 caps = gvir_config_capabilities_new_from_xml(caps_str, NULL);
 
+if (os_str) {
+os = osinfo_os_new(os_str);
+} else {
+os = guess_os_from_disk(disk_str_list);
+if (!os) {
+print_error(Operating system was not specified and could not be 
guessed);
+exit(EXIT_FAILURE);
+}
+}
+
 domain = gvir_designer_domain_new(os, platform, caps);
 
 gvir_designer_domain_setup_machine(domain, error);
-- 
1.7.8.6

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


[libvirt] [libvirt-designer][PATCH 0/4] Yet another functional extension

2012-09-06 Thread Michal Privoznik
This time aimed on virtxml tool to make it user friendlier a little bit.

Michal Privoznik (4):
  Implement resources setting
  Cleanup double error setting and operating on empty list
  virtxml: Detect OS from given ISO
  virtxml: Detect platform from libvirt connection URI

 examples/virtxml.c |  200 
 libvirt-designer/libvirt-designer-domain.c |  113 +++-
 libvirt-designer/libvirt-designer-domain.h |8 +
 libvirt-designer/libvirt-designer.sym  |3 +-
 4 files changed, 292 insertions(+), 32 deletions(-)

-- 
1.7.8.6

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


[libvirt] [libvirt-designer][PATCH 4/4] virtxml: Detect platform from libvirt connection URI

2012-09-06 Thread Michal Privoznik
as in nearly all cases users will install the guest
on current libvirt we've just obtained capabilities from.
---
 examples/virtxml.c |  119 ++-
 1 files changed, 88 insertions(+), 31 deletions(-)

diff --git a/examples/virtxml.c b/examples/virtxml.c
index 131c462..3e00e09 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -37,6 +37,9 @@
 #define print_error(...) \
 print_error_impl(__FUNCTION__, __LINE__, __VA_ARGS__)
 
+OsinfoLoader *loader = NULL;
+OsinfoDb *db = NULL;
+
 static void
 print_error_impl(const char *funcname,
  size_t linenr,
@@ -74,12 +77,11 @@ print_usage(const char *progname)
progname);
 }
 
-static OsinfoDb *
-get_default_osinfo_db(void)
+static gboolean
+load_osinfo(void)
 {
 GError *err = NULL;
-OsinfoLoader *loader = NULL;
-OsinfoDb *ret = NULL;
+gboolean ret = FALSE;
 
 loader = osinfo_loader_new();
 osinfo_loader_process_default_path(loader, err);
@@ -88,8 +90,9 @@ get_default_osinfo_db(void)
 goto cleanup;
 }
 
-ret = osinfo_loader_get_db(loader);
-g_object_ref(ret);
+db = osinfo_loader_get_db(loader);
+g_object_ref(db);
+ret = TRUE;
 
 cleanup:
 g_object_unref(loader);
@@ -99,11 +102,10 @@ cleanup:
 static int
 print_oses(void)
 {
-OsinfoDb *db = get_default_osinfo_db();
 OsinfoOsList *list;
 int i;
 
-if (!db)
+if (!db  !load_osinfo())
 return EXIT_FAILURE;
 
 list = osinfo_db_get_os_list(db);
@@ -121,19 +123,16 @@ print_oses(void)
 }
 
 g_object_unref(list);
-g_object_unref(db);
-
 return EXIT_SUCCESS;
 }
 
 static int
 print_platforms(void)
 {
-OsinfoDb *db = get_default_osinfo_db();
 OsinfoPlatformList *list;
 int i;
 
-if (!db)
+if (!db  !load_osinfo())
 return EXIT_FAILURE;
 
 list = osinfo_db_get_platform_list(db);
@@ -152,8 +151,6 @@ print_platforms(void)
 }
 
 g_object_unref(list);
-g_object_unref(db);
-
 return EXIT_SUCCESS;
 }
 
@@ -258,17 +255,10 @@ guess_os_from_disk(GList *disk_str_list)
 {
 OsinfoOs *ret = NULL;
 GList *tmp = g_list_first(disk_str_list);
-OsinfoLoader *loader = osinfo_loader_new();
 GError *error = NULL;
-OsinfoDb *db;
 
-osinfo_loader_process_default_path(loader, error);
-if (error) {
-print_error(Error loading libosinfo data: %s, error-message);
-goto cleanup;
-}
-
-db = osinfo_loader_get_db(loader);
+if (!db  !load_osinfo())
+exit(EXIT_FAILURE);
 
 while (tmp) {
 char *path = (char *) tmp-data;
@@ -304,14 +294,75 @@ guess_os_from_disk(GList *disk_str_list)
 }
 
 cleanup:
-g_clear_object(loader);
+return ret;
+}
+
+static OsinfoPlatform *
+find_platform_by_short_id(const char *short_id)
+{
+OsinfoPlatform *ret = NULL;
+OsinfoPlatformList *list = NULL;
+int i;
+
+if (!db  !load_osinfo())
+return NULL;
+
+list = osinfo_db_get_platform_list(db);
+
+for (i = 0; i  osinfo_list_get_length(OSINFO_LIST(list)); i++) {
+OsinfoPlatform *ent = 
OSINFO_PLATFORM(osinfo_list_get_nth(OSINFO_LIST(list), i));
+const char *id = osinfo_entity_get_param_value(OSINFO_ENTITY(ent),
+   
OSINFO_PRODUCT_PROP_SHORT_ID);
+
+if (id 
+!strcmp(id, short_id)) {
+ret = ent;
+g_object_ref(ret);
+break;
+}
+}
+
+g_object_unref(list);
 return ret;
 }
 
 static OsinfoPlatform *
 guess_platform_from_connect(virConnectPtr conn)
 {
-return NULL;
+OsinfoPlatform *ret = NULL;
+const char *hv_type = virConnectGetType(conn);
+unsigned long ver, major, minor, release;
+int tmp;
+char *short_id = NULL, *type = NULL;
+
+tmp = virConnectGetVersion(conn, ver);
+if (!hv_type || tmp  0) {
+print_error(Unable to get hypervisor and its version);
+exit(EXIT_FAILURE);
+}
+
+/* do some mappings:
+ * QEMU - kvm
+ * Xen - xen
+ */
+type = g_ascii_strdown(hv_type, -1);
+if (!strcmp(type, qemu)) {
+g_free(type);
+type = g_strdup(kvm);
+}
+
+major = ver / 100;
+ver %= 100;
+minor = ver / 1000;
+release = ver % 1000 ;
+
+short_id = g_strdup_printf(%s-%lu.%lu.%lu, type, major, minor, release);
+
+ret = find_platform_by_short_id(short_id);
+
+g_free(short_id);
+g_free(type);
+return ret;
 }
 
 #define CHECK_ERROR \
@@ -432,11 +483,6 @@ main(int argc, char *argv[])
 }
 }
 
-if (!platform_str) {
-print_error(Platform was not specified);
-exit(EXIT_FAILURE);
-}
-
 conn = virConnectOpenAuth(connect_uri, virConnectAuthPtrDefault, 
VIR_CONNECT_RO);
 if (!conn) {
 print_error(Unable to connect to libvirt);
@@ -448,7 +494,6 @@ main(int argc, char *argv[])
 goto cleanup;
 }
 
-platform = 

[libvirt] [libvirt-designer][PATCH 1/4] Implement resources setting

2012-09-06 Thread Michal Privoznik
Users can choose between minimum and recommended values
for VCPU count and amount of RAM. Moreover, recommended
values should inherit defaults from the minimum.
---
 examples/virtxml.c |   27 +++-
 libvirt-designer/libvirt-designer-domain.c |   98 +++-
 libvirt-designer/libvirt-designer-domain.h |8 ++
 libvirt-designer/libvirt-designer.sym  |3 +-
 4 files changed, 132 insertions(+), 4 deletions(-)

diff --git a/examples/virtxml.c b/examples/virtxml.c
index 87929b2..468bc2a 100644
--- a/examples/virtxml.c
+++ b/examples/virtxml.c
@@ -69,6 +69,8 @@ print_usage(const char *progname)
source and FORMAT is its 
format\n
  -i | --interface=NETWORK[,ARG=VAL]add interface with NETWORK 
source.\n
Possible ARGs: 
mac,link={up,down}\n,
+ -r | --resource={minimal|recommended} Set minimal or recommended 
values for\n
+   cpu count and RAM 
amount.\n,
progname);
 }
 
@@ -276,6 +278,7 @@ main(int argc, char *argv[])
 char *connect_uri = NULL;
 GList *disk_str_list = NULL;
 GList *iface_str_list = NULL;
+gchar *resources = NULL;
 int arg;
 
 struct option opt[] = {
@@ -288,6 +291,7 @@ main(int argc, char *argv[])
 {architecture, required_argument, NULL, 'a'},
 {disk, required_argument, NULL, 'd'},
 {interface, required_argument, NULL, 'i'},
+{resource, required_argument, NULL, 'r'},
 {NULL, 0, NULL, 0}
 };
 
@@ -297,7 +301,7 @@ main(int argc, char *argv[])
 /* Standard (non-command) options. The leading + ensures that no
  * argument reordering takes place, so that command options are
  * not confused with top-level virsh options. */
-while ((arg = getopt_long(argc, argv, +hc:o:p:a:d:i:, opt, NULL)) != -1) 
{
+while ((arg = getopt_long(argc, argv, +hc:o:p:a:d:i:r:, opt, NULL)) != 
-1) {
 char *progname;
 switch (arg) {
 case 'h':
@@ -347,6 +351,18 @@ main(int argc, char *argv[])
 case 'i':
 iface_str_list = g_list_append(iface_str_list, optarg);
 break;
+case 'r':
+if (!strcmp(optarg, minimal) ||
+!strcmp(optarg, min)) {
+resources = GVIR_DESIGNER_DOMAIN_RESOURCES_MINIMAL;
+} else if (!strcmp(optarg, recommended) ||
+   !strcmp(optarg, rec)) {
+resources = GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED;
+} else {
+print_error(Unknown resources value: '%s', optarg);
+exit(EXIT_FAILURE);
+}
+break;
 default:
 print_error(Something has gone tragically wrong);
 case '?':
@@ -389,6 +405,15 @@ main(int argc, char *argv[])
 CHECK_ERROR;
 }
 
+if (resources) {
+gvir_designer_domain_setup_resources(domain, resources, error);
+CHECK_ERROR;
+} else {
+gvir_designer_domain_setup_resources(domain,
+ 
GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED,
+ NULL);
+}
+
 g_list_foreach(disk_str_list, add_disk, domain);
 
 g_list_foreach(iface_str_list, add_iface, domain);
diff --git a/libvirt-designer/libvirt-designer-domain.c 
b/libvirt-designer/libvirt-designer-domain.c
index 5a10836..0411da4 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -213,9 +213,15 @@ GVirDesignerDomain *gvir_designer_domain_new(OsinfoOs *os,
  OsinfoPlatform *platform,
  GVirConfigCapabilities *caps)
 {
+OsinfoOs *os_found = NULL;
+OsinfoPlatform *platform_found = NULL;
+
+os_found = osinfo_db_get_os(osinfo_db, 
osinfo_entity_get_id(OSINFO_ENTITY(os)));
+platform_found = osinfo_db_get_platform(osinfo_db, 
osinfo_entity_get_id(OSINFO_ENTITY(platform)));
+
 return GVIR_DESIGNER_DOMAIN(g_object_new(GVIR_DESIGNER_TYPE_DOMAIN,
- os, os,
- platform, platform,
+ os, os_found,
+ platform, platform_found,
  capabilities, caps,
  NULL));
 }
@@ -960,3 +966,91 @@ 
gvir_designer_domain_add_interface_network(GVirDesignerDomain *design,
 
 return ret;
 }
+
+static void
+gvir_designer_domain_get_resources(OsinfoResourcesList *list,
+   const gchar *design_arch,
+   gint *design_n_cpus,
+   gint64 *design_ram)
+{
+int i;
+
+if (!list)
+  

[libvirt] [libvirt-designer][PATCH 2/4] Cleanup double error setting and operating on empty list

2012-09-06 Thread Michal Privoznik
and virtio disks can be advertised as PCI bus devices.
---
 libvirt-designer/libvirt-designer-domain.c |   15 ---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libvirt-designer/libvirt-designer-domain.c 
b/libvirt-designer/libvirt-designer-domain.c
index 0411da4..4046d8c 100644
--- a/libvirt-designer/libvirt-designer-domain.c
+++ b/libvirt-designer/libvirt-designer-domain.c
@@ -688,6 +688,9 @@ 
gvir_designer_domain_get_supported_disk_bus_types(GVirDesignerDomain *design)
 
 dev_list = osinfo_os_get_devices_by_property(priv-os, class, block, 
TRUE);
 
+if (!dev_list)
+goto cleanup;
+
 for (i = 0; i  osinfo_list_get_length(OSINFO_LIST(dev_list)); i++) {
 OsinfoDevice *dev = 
OSINFO_DEVICE(osinfo_list_get_nth(OSINFO_LIST(dev_list), i));
 const gchar *bus = osinfo_device_get_bus_type(dev);
@@ -699,6 +702,7 @@ 
gvir_designer_domain_get_supported_disk_bus_types(GVirDesignerDomain *design)
 ret = g_hash_table_get_keys(bus_hash);
 ret = g_list_copy(ret);
 
+cleanup:
 g_hash_table_destroy(bus_hash);
 return ret;
 }
@@ -811,18 +815,23 @@ gvir_designer_domain_add_disk_full(GVirDesignerDomain 
*design,
 goto error;
 
 item = g_list_first(bus_str_list);
-bus_str_list = item-data;
+bus_str = item-data;
+if (!bus_str)
+goto error;
 }
 
+g_clear_error(error);
 
 disk = gvir_config_domain_disk_new();
 gvir_config_domain_disk_set_type(disk, type);
 gvir_config_domain_disk_set_source(disk, path);
 gvir_config_domain_disk_set_driver_name(disk, qemu);
-gvir_config_domain_disk_set_driver_type(disk, format);
+if (format)
+gvir_config_domain_disk_set_driver_type(disk, format);
 if (g_str_equal(bus_str, ide)) {
 bus = GVIR_CONFIG_DOMAIN_DISK_BUS_IDE;
-} else if (g_str_equal(bus_str, virtio)) {
+} else if (g_str_equal(bus_str, virtio) ||
+   g_str_equal(bus_str, pci)) {
 bus = GVIR_CONFIG_DOMAIN_DISK_BUS_VIRTIO;
 } else if (g_str_equal(bus_str, sata)) {
 bus = GVIR_CONFIG_DOMAIN_DISK_BUS_SATA;
-- 
1.7.8.6

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


Re: [libvirt] need help/clarification about git and patches.

2012-09-06 Thread Daniel P. Berrange
On Thu, Sep 06, 2012 at 11:59:10AM -0400, Gene Czarcinski wrote:
 Using git is more than a little different way of doing business for
 me.  My usual way to create and apply a patch is to rebuild a
 src.rpm.  This way I have a lot less changes of screwing something
 up because of ignorance.
 
 It it a little while but I finally cloned a copy of libvirt.git.  I
 applied a patch to remove the --filterwin2k [one fixup because a
 test file changed slightly.  I then ran git diff and produce a new
 patch.
 
 OK, now what?  I did the git commit and then tried to do the git
 send-email like it says in your hacking document ...
git: 'send-email' is not a git command.

Slightly annoyingly, the 'send-email' command requires that you have
installed the 'git-email' RPM too.

One other tip the first time you try 'git send-email' is to test
it using your own private email address, rather than the mailing
list address :-)


 I am going to do what I believe is the right thing to do and submit
 the patch but there needs to be a bit more info as to how we should
 do things.

Yep, once you get used to its way of working, I'm sure you'll
find using GIT a nicer approach than patching the RPMs each
tine.


FYI in case you don't already know, you can also run libvirt builds
directly from the source tree, rather than needing to run 'make intsall'
or install an updated RPM every time.  my usual way of working is to
just stop the libvirtd process fro mthe RPM and then run

 $ cd $LIBVIRT_GIT
 $ ./autogen.sh --system
 $ make
 $ su -
 # ./daemon/libvirtd


You can also run  ./tools/virsh, and if you want to test external
apps with the libvirt client / python bindings you can set:

  export LD_LIBRARY_PATH=$LIBVIRT_GIT/src/.libs
  export PYTHONPATH=$LIBVIRT_GIT/python:$LIBVIRT_GIT/python/.libs

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

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


[libvirt] SCSI command passthrough

2012-09-06 Thread Geert Jansen

Hi,

i'm trying to pass through SCSI commands from a guest to a host. Both 
guest and host are RHEL 6.3. The relevant section in my XML is:


  devices
disk type='block' device='lun'
  driver name='qemu' type='raw' cache='none'/
  source dev='/dev/sdb'/
  target dev='sdb' bus='scsi'/
  address type='drive' controller='0' bus='0' target='1' unit='0'/
/disk
controller type='scsi' index='0' model='virtio-scsi'
  address type='pci' domain='0x' bus='0x00' slot='0x05' 
function='0x0'/

/controller
  ...
  /devices

Commands that are whitelisted by the host kernel come through (e.g. 
sg_inq), but other commands don't (e.g. sg_persist).


I need sg_persist so i tried making qemu-kvm setuid root. This works.

Is there a better way to allow arbitrary SCSI commands, perferably on a 
per-VM basis, rather than making qemu setuid root?


Regards,
Geert

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


Re: [libvirt] [PATCH] remove dnsmasq command line parameter --filterwin2k

2012-09-06 Thread Eric Blake
On 09/06/2012 10:08 AM, Gene Czarcinski wrote:
   This patch removed the --filterwin2k dnsmasq command line
   parameter which was unnecessary for domain specification,
   possibly blocked some usage, and was command line clutter.
 
   Gene Czarcinski g...@czarc.net
 

ACK and pushed.  'git am' didn't like the mail (it came through with
horrible whitespace corruption), so I had to hand-apply the entire patch
(manual tweak of bridge-driver.c, then a sed script to touch up the 9
test files), but I don't mind helping out on a first message while you
are still learning git.  But expect a request for a repost if this
happens on future patches :)

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] docs: point out git send-email location, be more stern about make check

2012-09-06 Thread Laine Stump
An email came to libvir-list wondering why the git send-email command
was missing in spite of having git installed; this is due to the
send-email command being in a sub-package of the main git package.

While touching the hacking file, I thought it would be useful to 1)
indicate the location of the source (docs/hacking.html.in) in the
message at the top of HACKING, and also to make the note about running
make check and make syntax-check a bit more stern.
---
 HACKING  | 22 ++
 docs/hacking.html.in | 29 ++---
 docs/hacking2.xsl|  3 ++-
 3 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/HACKING b/HACKING
index 804d54c..ab1a329 100644
--- a/HACKING
+++ b/HACKING
@@ -1,5 +1,6 @@
 -*- buffer-read-only: t -*- vi: set ro:
-DO NOT EDIT THIS FILE!  IT IS GENERATED AUTOMATICALLY!
+DO NOT EDIT THIS FILE!  IT IS GENERATED AUTOMATICALLY
+from docs/hacking.html.in!
 
 
 
@@ -32,11 +33,14 @@ Then, when you want to post your patches:
 
   git pull --rebase
   (fix any conflicts)
-  git send-email --cover-letter --no-chain-reply-to --annotate 
--to=libvir-list@redhat.com master
+  git send-email --cover-letter --no-chain-reply-to --annotate \
+ --to=libvir-list@redhat.com master
 
-For a single patch you can omit --cover-letter, but series of a two or more
-patches needs a cover letter. If you get tired of typing
---to=libvir-list@redhat.com designation you can set it in git config:
+(Note that the git send-email subcommand is usually not in the main git
+package, but part of a sub-package called git-email.) For a single patch you
+can omit --cover-letter, but series of a two or more patches needs a cover
+letter. If you get tired of typing --to=libvir-list@redhat.com designation
+you can set it in git config:
 
   git config sendemail.to libvir-list@redhat.com
 
@@ -56,9 +60,11 @@ though).
 (3) Split large changes into a series of smaller patches, self-contained if
 possible, with an explanation of each patch and an explanation of how the
 sequence of patches fits together. Moreover, please keep in mind that it's
-required to be able to compile cleanly after each patch. A feature does not
-have to work until the end of a series, as long as intermediate patches don't
-cause test-suite failures.
+required to be able to compile cleanly (*including* make check and make
+syntax-check) after each patch. A feature does not have to work until the end
+of a series, but intermediate patches must compile and not cause test-suite
+failures (this is to preserve the usefulness of git bisect, among other
+things).
 
 
 
diff --git a/docs/hacking.html.in b/docs/hacking.html.in
index ca02669..1917b78 100644
--- a/docs/hacking.html.in
+++ b/docs/hacking.html.in
@@ -31,11 +31,15 @@
 pre
   git pull --rebase
   (fix any conflicts)
-  git send-email --cover-letter --no-chain-reply-to --annotate 
--to=libvir-list@redhat.com master
-/pre
-pFor a single patch you can omit code--cover-letter/code, but
-series of a two or more patches needs a cover letter. If you get tired
-of typing code--to=libvir-list@redhat.com/code designation you can
+  git send-email --cover-letter --no-chain-reply-to --annotate \
+ --to=libvir-list@redhat.com master
+/pre
+p(Note that the git send-email subcommand is usually not
+in the main git package, but part of a sub-package called
+git-email.) For a single patch you can omit
+code--cover-letter/code, but series of a two or more
+patches needs a cover letter. If you get tired of typing
+code--to=libvir-list@redhat.com/code designation you can
 set it in git config:/p
 pre
   git config sendemail.to libvir-list@redhat.com
@@ -55,12 +59,15 @@
   /li
 
   lipSplit large changes into a series of smaller patches,
-self-contained if possible, with an explanation of each patch and an
-explanation of how the sequence of patches fits together. Moreover,
-please keep in mind that it's required to be able to compile cleanly
-after each patch.  A feature does not have to work until the end of a
-series, as long as intermediate patches don't cause test-suite
-failures./p
+self-contained if possible, with an explanation of each patch
+and an explanation of how the sequence of patches fits
+together. Moreover, please keep in mind that it's required to
+be able to compile cleanly (bincluding/b codemake
+check/code and codemake syntax-check/code) after each
+patch.  A feature does not have to work until the end of a
+series, but intermediate patches must compile and not cause
+test-suite failures (this is to preserve the usefulness
+of codegit bisect/code, among other things)./p
   /li
 
   liMake sure your patches apply against libvirt GIT.  Developers
diff --git a/docs/hacking2.xsl b/docs/hacking2.xsl
index 

Re: [libvirt] need help/clarification about git and patches.

2012-09-06 Thread Laine Stump
On 09/06/2012 11:59 AM, Gene Czarcinski wrote:
 Using git is more than a little different way of doing business for
 me.  My usual way to create and apply a patch is to rebuild a
 src.rpm.  This way I have a lot less changes of screwing something up
 because of ignorance.

My experience is the opposite - I usually end up screwing something up
if I try to mess with a src.rpm :-)


 It it a little while but I finally cloned a copy of libvirt.git.  I
 applied a patch to remove the --filterwin2k [one fixup because a
 test file changed slightly.  I then ran git diff and produce a new
 patch.

 OK, now what?  I did the git commit and then tried to do the git
 send-email like it says in your hacking document ...
git: 'send-email' is not a git command.

On Fedora and RHEL (I'm not sure about other platforms) git's
send-email subcommand is in a sub-package of git called git-email.
See if your distro's package system can install a package with that name.


 I am going to do what I believe is the right thing to do and submit
 the patch but there needs to be a bit more info as to how we should do
 things.

A note pointing out that the git-email package also needs to be
installed is a good idea. I've just sent a patch to libvir-list that
adds that (and while I was touching the file, made it more insistent
that people run make check and make syntax-check :-))

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


Re: [libvirt] [PATCH 1/1 V2] Migrate per-port data for Open vSwitch ports during Qemu Live Migration

2012-09-06 Thread Daniel P. Berrange
On Thu, Sep 06, 2012 at 11:58:52AM -0400, Laine Stump wrote:
 On 09/04/2012 04:35 PM, Kyle Mestery wrote:
  Add the ability to migrate per-port data on Open vSwitch
  ports during qemu live migration. A controller can use this
  to store data relating to each port, and have it migrated
  with the virtual machine and populated on the destination
  host.
 
  +static int
  +qemuMigrationCookieAddOvsPortData(qemuMigrationCookiePtr mig,
  +  struct qemud_driver *driver,
  +  virDomainObjPtr dom)
  +{
  +if (mig-flags  QEMU_MIGRATION_COOKIE_OVS_PORT_DATA) {
  +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
  +   _(Migration ovs port data data already present));
  +return -1;
  +}
  +
  +if (dom-def-nnets = 1) {
  +if (!(mig-ovsportdata = qemuMigrationCookieOvsPortDataAlloc(
  +driver, dom-def)))
  +return -1;
  +mig-flags |= QEMU_MIGRATION_COOKIE_OVS_PORT_DATA;
  +}
  +
  +return 0;
  +}
  +
   
   static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,

  qemuMigrationCookieGraphicsPtr grap)
  @@ -389,6 +504,25 @@ static void 
  qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
   }
   
   
  +static void qemuMigrationCookieOvsPortDataXMLFormat(virBufferPtr buf,
  +
  qemuMigrationCookieOvsPortDataPtr optr)
  +{
  +int i;
  +
  +virBufferAsprintf(buf,   ovsportdata nnets='%d'\n, optr-nnets);
 
 A minor point - is there a reason for including nnets here, when it can
 be implied from the number of vif elements and/or their num attributes?
 
 But beyond that, I'm thinking we might want a more generic toplevel
 element name (similar to the graphics one being called graphics even
 though it could be used for vnc or spice), so that in the future it
 could be passed to / retrieved from a separate network driver/daemon
 without regard (within the migration code at least) to the specific type
 of the interface (or at least allow for the migration code to get
 multiple types without needing to clutter the namespace).
 
 In the end, what we're really doing here is sending a last-instant
 update to the state of the domain's network interface. Thinking of it in
 that way, it would be really nice if it mimicked the network element
 of the domain XML as much as possible, to make explanations easier and
 make future additions more automatic, but I'm not sure how far we want
 to go in that direction, since the network element of the domain is
 unnecessarily complex for this specific job (e.g. it has both the
 configuration (which could be type='network') *and* the actual network
 connection that's used (which could have a different type if the config
 type is 'network'). Another difference specific to this case is that, in
 order to detect an interface that uses Open vSwitch, you need to look
 both for type='bridge' and for virtualport type='openvswitch'.
 
 So, to take this to the very end of that road of reasoning, how bad of
 an idea would it be to make the cookie for each interface be the full
 live XML of that interface, then just include the portdata inside
 virtualport for every interface that has virtualport
 type='openvswitch'?

I'm not sure I entirely like the idea of duplicating the full live
network interface XML that we've already sent across, mostly because
it is duplicating a whole lot of information.

 The advantage of doing it this way is that this would automatically
 handle any other need for last-minute interface state change info we
 might encounter in the future (as long as 1) the desired information is
 included in virDomainNetDef and handled by the standard
 parser/formatter, and 2) the cookie eating code did something with that
 data), and we could just call the parse/format functions in src/conf
 rather than needing our own. (A side effect is that virsh dumpxml
 $myguest would display the portdata for every Open vSwitch interface.
 Not having seen the length of the data, I don't know if that's a plus or
 a minus :-)

Admittedly from a position of ignorance about what the data is, I would
tend to view this data as internal technical implementation data and
not really relevant to app developers/users. AFAIK, it isn't data that
an app developer would want to interpret or manipulate - just opaque
state to be passed across at migration.

Considering your point about generality though, I think we could argue
that the top level element name could be something different. Eg instead
of ovsportdata perhaps,  interfacestate type='bridge|direct|etc'
where type matches the types on interface in the domain XML, and then
subelements which vary per type as needed.

  +if (optr-nnets  0)
  +virBufferAsprintf(buf, vifs\n);
 
 Stepping back from my larger change idea above, does having the extra
 

Re: [libvirt] [PATCH] remove dnsmasq command line parameter --filterwin2k

2012-09-06 Thread Gene Czarcinski

On 09/06/2012 01:00 PM, Eric Blake wrote:

On 09/06/2012 10:08 AM, Gene Czarcinski wrote:

   This patch removed the --filterwin2k dnsmasq command line
   parameter which was unnecessary for domain specification,
   possibly blocked some usage, and was command line clutter.

   Gene Czarcinski g...@czarc.net


ACK and pushed.  'git am' didn't like the mail (it came through with
horrible whitespace corruption), so I had to hand-apply the entire patch
(manual tweak of bridge-driver.c, then a sed script to touch up the 9
test files), but I don't mind helping out on a first message while you
are still learning git.  But expect a request for a repost if this
happens on future patches :)

I expect the the problem must be that I am using thunderbird as my 
regular email client.  Now that I have more info about  using git 
send-email, maybe next time will be better.


I am sorry that this caused you more work.  I thought about attaching 
the patch but the hacker document specifically requested inline and 
attached patches.


Gene

Gene

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


Re: [libvirt] need help/clarification about git and patches.

2012-09-06 Thread Laine Stump

On 09/06/2012 12:53 PM, Daniel P. Berrange wrote:
 FYI in case you don't already know, you can also run libvirt builds
 directly from the source tree, rather than needing to run 'make intsall'
 or install an updated RPM every time.  my usual way of working is to
 just stop the libvirtd process fro mthe RPM and then run

  $ cd $LIBVIRT_GIT
  $ ./autogen.sh --system
  $ make
  $ su -
  # ./daemon/libvirtd

There is one small difference to running it this way rather than as a
system service - it will be running in an unconfined/unrestricted state,
so some things that may have otherwise failed due to a lack of
permission, will succeed. So if you've changed anything related to what
external programs are called, or what files/devices are accessed, it's
usually a good idea to make a final test with a proper install (I tend
to do that by running make rpm followed by an install of the rpms -
there are yet other problems that don't show up if you simply run make
install...)

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


Re: [libvirt] [PATCH] docs: point out git send-email location, be more stern about make check

2012-09-06 Thread Jiri Denemark
On Thu, Sep 06, 2012 at 13:24:24 -0400, Laine Stump wrote:
 An email came to libvir-list wondering why the git send-email command
 was missing in spite of having git installed; this is due to the
 send-email command being in a sub-package of the main git package.
 
 While touching the hacking file, I thought it would be useful to 1)
 indicate the location of the source (docs/hacking.html.in) in the
 message at the top of HACKING, and also to make the note about running
 make check and make syntax-check a bit more stern.
 ---
...
 diff --git a/docs/hacking.html.in b/docs/hacking.html.in
 index ca02669..1917b78 100644
 --- a/docs/hacking.html.in
 +++ b/docs/hacking.html.in
 @@ -31,11 +31,15 @@
  pre
git pull --rebase
(fix any conflicts)
 -  git send-email --cover-letter --no-chain-reply-to --annotate 
 --to=libvir-list@redhat.com master
 -/pre
 -pFor a single patch you can omit code--cover-letter/code, but
 -series of a two or more patches needs a cover letter. If you get 
 tired
 -of typing code--to=libvir-list@redhat.com/code designation you 
 can
 +  git send-email --cover-letter --no-chain-reply-to --annotate \
 + --to=libvir-list@redhat.com master
 +/pre
 +p(Note that the git send-email subcommand is usually not
 +in the main git package, but part of a sub-package called
 +git-email.) For a single patch you can omit

IMHO this sounds too Fedora-centric. How about the following (with possible
stylistic and grammatical changes to make it sound better to native speakers)
:-)

(Note that the git send-email subcommand may not be in the main git
package and using it may require installing of a separate package. This
package is called git-email in Fedora.) ...

 +code--cover-letter/code, but series of a two or more
 +patches needs a cover letter. If you get tired of typing
 +code--to=libvir-list@redhat.com/code designation you can
  set it in git config:/p
  pre
git config sendemail.to libvir-list@redhat.com

ACK with the nit addressed.

Jirka

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


Re: [libvirt] need help/clarification about git and patches.

2012-09-06 Thread Gene Czarcinski
Rather than cluttering up the mailing list, I am going to combine the 
helpful replies into a single response.  I am going to edit this to 
reduce clutter.


On 09/06/2012 01:26 PM, Laine Stump wrote:

On 09/06/2012 11:59 AM, Gene Czarcinski wrote:

Using git is more than a little different way of doing business for
me.  My usual way to create and apply a patch is to rebuild a
src.rpm.  This way I have a lot less changes of screwing something up
because of ignorance.

My experience is the opposite - I usually end up screwing something up
if I try to mess with a src.rpm :-)


When you are deep into working on a large project such as libvirt, git 
is the way to go.  If you are just trying to create a small bugfix, then 
rpm can take care of all the extra stuff so that you get code that will 
work.  Besides, after working with rpm for over 15 years, you get 
comfortable with its ways.


snip
On Fedora and RHEL (I'm not sure about other platforms) git's 
send-email subcommand is in a sub-package of git called 
git-email. See if your distro's package system can install a 
package with that name. 
I do not remember actually selecting the git package ... but, in the 
future, I will remember that I will also need the git-mail package.


I do suggest that the hacking get updated with this info.

On 09/06/2012 12:53 PM, Daniel P. Berrange wrote:


One other tip the first time you try 'git send-email' is to test
it using your own private email address, rather than the mailing
list address :-)
Oh yes, this is definitely something to do!  I suggest this also be 
added to the hacking document.


On 09/06/2012 12:31 PM, Eric Blake wrote:

 Seems reasonable.  If the instructions in HACKING could use an
 improvement, let us know what we can do to make it better.

One other minor detail.  It you have been using git for a while, what 
the hacking document says makes sense ... but it is not quite 
complete.  I realize that this document is about libvirt hacking and not 
a user's manual for git, but a little more info would be extremely useful.


Something like the following:

0. If on Fedora or RHEL, install the  git-mail package.

1. create a directory such as git-dev where you will have the 
repositories and then cd to that directory.


2. Do:
git init
git --global user.email m...@here.com
git --global user.name Your Name
git clone git://libvirt.org/libvirt.git

[That last one was interesting because I had no idea where it was]

Note:  To use the git send-email ..., you will likely need to set a 
number of options such as

  git config sendemail.to m...@here.com


Thanks for your patience.

Gene

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


Re: [libvirt] [PATCH 1/7] list: Define new API virConnectListAllNodeDevices

2012-09-06 Thread Peter Krempa

On 09/05/12 07:34, Osier Yang wrote:

This is to list the node device objects, supports to filter the results
by capability types.

include/libvirt/libvirt.h.in: Declare enum virConnectListAllNodeDeviceFlags
   and virConnectListAllNodeDevices.
python/generator.py: Skip auto-generating
src/driver.h: (virDrvConnectListAllNodeDevices)
src/libvirt.c: Implement the public API
src/libvirt_public.syms: Export the symbol to public
---
  include/libvirt/libvirt.h.in |   25 +
  python/generator.py  |1 +
  src/driver.h |4 +++
  src/libvirt.c|   62 ++
  src/libvirt_public.syms  |1 +
  5 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 9226f3e..96d0760 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2834,6 +2834,31 @@ int virNodeListDevices  
(virConnectPtr conn,
   char **const names,
   int maxnames,
   unsigned int flags);
+/*
+ * virConnectListAllNodeDevices:
+ *
+ * Flags used to filter the returned node devices. Flags in each group
+ * are exclusive.
+ */
+typedef enum {
+/* Reserved the first 6 bits for the possibility of persistent
+ * node device support in future.
+ */


Huh, I think reserving some bits doesn't make sense. If we add 
something, we might just add it at the end and nothing will happen. And 
if you will need to add more than 6 bits of filters, than you'll need to 
split it.



+
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM= 1  6,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV   = 1  7,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV   = 1  8,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE = 1  9,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET   = 1  10,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST = 1  11,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET   = 1  12,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI  = 1  13,
+VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE   = 1  14,
+} virConnectListAllNodeDeviceFlags;


Also it probably would be better to add a comment to (at least some of 
those) flags. For example I don't know the difference between 
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI and the other two SCSI filters.



+
+int virConnectListAllNodeDevices (virConnectPtr conn,
+  virNodeDevicePtr 
**devices,
+  unsigned int flags);

  virNodeDevicePtrvirNodeDeviceLookupByName (virConnectPtr conn,
 const char *name);
diff --git a/python/generator.py b/python/generator.py
index 8f6e455..a8e4ec6 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -464,6 +464,7 @@ skip_function = (
  'virStoragePoolListAllVolumes', # overridden in virStoragePool.py
  'virConnectListAllNetworks', # overridden in virConnect.py
  'virConnectListAllInterfaces', # overridden in virConnect.py
+'virConnectListAllNodeDevices', # overridden in virConnect.py

  'virStreamRecvAll', # Pure python libvirt-override-virStream.py
  'virStreamSendAll', # Pure python libvirt-override-virStream.py
diff --git a/src/driver.h b/src/driver.h
index 518e9d4..34a94af 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1483,6 +1483,9 @@ typedef int (*virDevMonListDevices)(virConnectPtr conn,
  char **const names,
  int maxnames,
  unsigned int flags);
+typedef int (*virDevMonListAllNodeDevices)(virConnectPtr conn,
+   virNodeDevicePtr **devices,
+   unsigned int flags);

  typedef virNodeDevicePtr (*virDevMonDeviceLookupByName)(virConnectPtr conn,
  const char *name);
@@ -1516,6 +1519,7 @@ struct _virDeviceMonitor {
  virDrvClose close;
  virDevMonNumOfDevices   numOfDevices;
  virDevMonListDeviceslistDevices;
+virDevMonListAllNodeDevices listAllNodeDevices;


In case of this API the old one actually does list all devices as this 
one does and has no races, but It's horrible to use.



  virDevMonDeviceLookupByName deviceLookupByName;
  virDevMonDeviceGetXMLDesc   deviceGetXMLDesc;
  virDevMonDeviceGetParentdeviceGetParent;
diff --git a/src/libvirt.c b/src/libvirt.c
index 90ed7ff..b8d0bec 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -13793,6 +13793,66 @@ error:
  return -1;
  }

+/**
+ * virConnectListAllNodeDevices:
+ * @conn: Pointer to the hypervisor 

Re: [libvirt] [PATCH 2/7] list: Implemente RPC calls for virConnectListAllNodeDevices

2012-09-06 Thread Peter Krempa

s/Implemente/Implement/ in subject

On 09/05/12 07:34, Osier Yang wrote:

The RPC generator doesn't support returning list of object yet, this patch
do the work manually.


s/do/does/



   * daemon/remote.c:
 Implemente the server side handler remoteDispatchConnectListAllNodeDevices.

   * src/remote/remote_driver.c:
 Add remote driver handler remoteConnectListAllNodeDevices.

   * src/remote/remote_protocol.x:
 New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES and
---
  daemon/remote.c  |   53 ++
  src/remote/remote_driver.c   |   64 ++
  src/remote/remote_protocol.x |   13 -
  src/remote_protocol-structs  |   12 
  4 files changed, 141 insertions(+), 1 deletions(-)



It's getting pretty mechanic after this many APIs :). ACK with the 
commit message fixed.


Peter

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


Re: [libvirt] [PATCH 3/7] list: Add helpers for listing node devices

2012-09-06 Thread Peter Krempa

On 09/05/12 07:34, Osier Yang wrote:

src/conf/node_device_conf.h:
   * New macro VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP
   * Declare virNodeDeviceList

src/conf/node_device_conf.c:
   * New helpers virNodeDeviceCapMatch, virNodeDeviceMatch.
 virNodeDeviceCapMatch looks up the list of all the caps the device
 support, to see if the device support the cap type.
   * Implement virNodeDeviceList

src/libvirt_private.syms:
   * Export virNodeDeviceList
   * Export virNodeDevCapTypeFromString
---
  src/conf/node_device_conf.c |  103 +++
  src/conf/node_device_conf.h |   16 +++
  src/libvirt_private.syms|2 +
  3 files changed, 121 insertions(+), 0 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 048c70c..60462b8 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1432,3 +1432,106 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj)
  {
  virMutexUnlock(obj-lock);
  }
+
+static bool
+virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
+  int type)
+{
+virNodeDevCapsDefPtr cap = NULL;
+
+for (cap = devobj-def-caps; cap; cap = cap-next) {
+if (type == cap-type)
+return true;
+}
+
+return false;
+}
+
+#define MATCH(FLAG) (flags  (FLAG))


I probably couldn't resist the temptation to abuse the MATCH macro to 
get rid of half of the lines below. But this is not worth the effort and 
what you have is correct.



+static bool
+virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
+   unsigned int flags)
+{
+/* filter by cap type */
+if (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP)) {
+if (!((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SYSTEM))
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_PCI_DEV))   
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_USB_DEV))   
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_USB_INTERFACE)) 
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_NET))   
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI_HOST)) 
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI_TARGET))   
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI))  
||
+  (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE) 
+   virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_STORAGE
+return false;
+}
+
+return true;
+}
+#undef MATCH
+
+int
+virNodeDeviceList(virConnectPtr conn,
+  virNodeDeviceObjList devobjs,
+  virNodeDevicePtr **devices,
+  unsigned int flags)
+{
+virNodeDevicePtr *tmp_devices = NULL;
+virNodeDevicePtr device = NULL;
+int ndevices = 0;
+int ret = -1;
+int i;
+
+if (devices) {
+if (VIR_ALLOC_N(tmp_devices, devobjs.count + 1)  0) {
+virReportOOMError();
+goto cleanup;
+}
+}
+
+for (i = 0; i  devobjs.count; i++) {
+virNodeDeviceObjPtr devobj = devobjs.objs[i];
+virNodeDeviceObjLock(devobj);
+if (virNodeDeviceMatch(devobj, flags)) {
+if (devices) {
+if (!(device = virGetNodeDevice(conn,
+devobj-def-name))) {
+virNodeDeviceObjUnlock(devobj);
+goto cleanup;
+}
+tmp_devices[ndevices] = device;
+}
+ndevices++;
+}
+virNodeDeviceObjUnlock(devobj);
+}
+
+if (tmp_devices) {
+/* trim the array to the final size */
+ignore_value(VIR_REALLOC_N(tmp_devices, ndevices + 1));
+*devices = tmp_devices;
+tmp_devices = NULL;
+}
+
+ret = ndevices;
+
+cleanup:
+if (tmp_devices) {
+for (i = 0; i  ndevices; i++) {
+if (tmp_devices[i])
+virNodeDeviceFree(tmp_devices[i]);
+}
+}
+
+VIR_FREE(tmp_devices);
+return ret;
+}
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 41c9fcc..b8ee881 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -261,4 +261,20 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
  void virNodeDeviceObjLock(virNodeDeviceObjPtr obj);
  void 

Re: [libvirt] [PATCH 3/7] list: Add helpers for listing node devices

2012-09-06 Thread Peter Krempa

On 09/06/12 22:40, Peter Krempa wrote:

index 7464c59..43928f1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -852,6 +852,7 @@ virPortGroupFindByName;


  # node_device_conf.h
+a;


Is this related directly to this API adition? If not, split it out. (Do
a separate patch doing this change and then rebase)


Gah; I probably confused thunderbird with vim ...

The context I'm refering to is:

--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -852,6 +852,7 @@ virPortGroupFindByName;


 # node_device_conf.h
+virNodeDevCapTypeFromString;
 virNodeDevCapTypeToString;
 virNodeDevCapsDefFree;
 virNodeDeviceAssignDef;






  virNodeDevCapTypeToString;
  virNodeDevCapsDefFree;
  virNodeDeviceAssignDef;
@@ -865,6 +866,7 @@ virNodeDeviceFindBySysfsPath;


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


Re: [libvirt] RFC: take two on live update of network configuration

2012-09-06 Thread Eric Blake
On 09/06/2012 07:43 AM, Daniel P. Berrange wrote:

 ===
 OPTION 3) Again, a single API, but with an added nodespec arg which would
 be used to describe the parent node you of the node you want added/updated 
 to:


 3) Can you think of a situation where this wouldn't work?
 
 In a libvirt API where you don't use XML directly.
 
 
 The thing I like about option 3 is that you are just passing in little
 snippets of XML to either add/remove/modify.  But we need to figure out
 a better way todo this, without using XPath markers IMHO.

Option 4

Instead of an arbitrary XPath marker, can we come up with an enum of
possible change sites?  That would mean the user doesn't have quite as
much flexibility (passing an int instead of string), but we are still
extensible as new changeable sites make sense (add another enum
constant).  There's still some disambiguation needed, but I suppose you
could obtain that by passing (a subset of) the original XML sufficient
to provide the context necessary.

For example,

 /* full text of host element to add to dhcp, embedded in
  * enough partial context from the original xml as to find the
  * right dhcp to add it to */
 virNetworkUpdate(VIR_NETWORK_UPDATE_DHCP,
network
  ip address='10.24.75.1'
dhcp
  host mac='00:16:3e:77:e2:ed' 
  name='X.example.com' ip='10.24.75.10'/
/dhcp
  /ip
/network,
  VIR_NETWORK_UPDATE_ADD | VIR_NETWORK_UPDATE_LIVE
  | VIR_NETWORK_UPDATE_CONFIG);

Not sure I like it any better, but at least it's more targetted than
option 1 (you can't change arbitrary code, just the section highlighted
by the enum value and the choice of add, remove, or replace), so the
diff'ing is a bit easier.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 4/7] list: Implement listAllNodeDevices

2012-09-06 Thread Peter Krempa

On 09/05/12 07:34, Osier Yang wrote:

This simply implements listAllNodeDevices using helper virNodeDeviceList

src/node_device/node_device_driver.h:
   * Declare nodeListAllNodeDevices.

src/node_device/node_device_driver.c:
   * Implement nodeListAllNodeDevices.

src/node_device/node_device_hal.c:
   * Hook listAllNodeDevices to nodeListAllNodeDevices.

src/node_device/node_device_udev.c
   * Hook listAllNodeDevices to nodeListAllNodeDevices.
---
  src/node_device/node_device_driver.c |   15 +++
  src/node_device/node_device_driver.h |3 +++
  src/node_device/node_device_hal.c|1 +
  src/node_device/node_device_udev.c   |1 +
  4 files changed, 20 insertions(+), 0 deletions(-)



Looks reasonable. ACK.

Peter

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


Re: [libvirt] [PATCH 1/5] list: Define new API virConnectListAllNWFilters

2012-09-06 Thread Eric Blake
On 09/05/2012 12:02 AM, Osier Yang wrote:
 This is to list the network fitler objects. No flags are supported

s/fitler/filter/


  
 +/**
 + * virConnectListAllNWFilters:
 + * @conn: Pointer to the hypervisor connection.
 + * @filters: Pointer to a variable to store the array containing the network
 + *   filter objects or NULL if the list is not required (just returns
 + *   number of network filters).
 + * @flags: extra flags; not used yet, so callers should always pass 0
 + *
 + * Collect the list of network filters, and allocate an array to store those
 + * objects.

Maybe it's worth filtering on whether a filter is just references to
other filters, contains rules, or contains both.  But for that to be
useful, it would also be nice to have an API where, given an individual
virNWFilterPtr, we can then return a list of all other virNWFilterPtr
that were pulled in by reference (that is, similar to snapshots, have an
API sufficiently powerful to reconstruct the tree of filter references).
 So I'm okay with this version going in with no flag support for now.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 5/7] list: Expose virConnectListAllNodeDevices to Python binding

2012-09-06 Thread Peter Krempa

On 09/05/12 07:34, Osier Yang wrote:

The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.

python/libvirt-override-api.xml: Document

python/libvirt-override-virConnect.py:
   * Implementation for listAllNodeDevices.

python/libvirt-override.c: Implementation for the wrapper.
---
  python/libvirt-override-api.xml   |6 
  python/libvirt-override-virConnect.py |   12 
  python/libvirt-override.c |   48 +
  3 files changed, 66 insertions(+), 0 deletions(-)



ACK, again a patern-matched review.

Peter

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


  1   2   >