[libvirt] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Daniel Veillard
On Tue, Oct 30, 2012 at 10:13:35PM +0100, Guido Günther wrote:
 
 Looks good now on the Debian buildds:
 
 https://buildd.debian.org/status/package.php?p=libvirtsuite=experimental

  Great !
I just tagged rc3 in git and pushed tarball and rpms to the usual
location:
  ftp://libvirt.org/libvirt/

 Seems that we are in good shape for the final 1.0.0 release which I
will do early Friday unless something really bad shows up in the
meantime. Please be careful with pushing patches in the next 2 days
especially for anything which could affect portability :-)
 Let's test this for 2 more days !

  thanks in advance,

Daniel

-- 
Daniel Veillard  | Open Source and Standards, Red Hat
veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
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 1/2] qemu: Enhance QMP detection of KVM state

2012-10-31 Thread Martin Kletzander
On 10/31/2012 12:44 AM, Eric Blake wrote:
 On 10/28/2012 06:55 AM, Martin Kletzander wrote:
 When there is no 'qemu-kvm' binary and the emulator used for a machine
 is, for example, 'qemu-system-x86_64' that, by default, runs without
 kvm enabled, libvirt still supplies '-no-kvm' option to this process,
 even though it does not recognize such option (making the start of a
 domain fail in that case).

 This patch adds QMP querying for KVM state using 'query-kvm' state,
 but does not set any of QEMU_CAPS_KVM and QEMU_CAPS_ENABLE_KVM flags.
 That functionality is done in different patch in order to be able to
 compare two possibilities and chose the better one without looking at
 the part of the code that's exactly the same for both of them (this
 patch).
 

 +static int
 +qemuCapsProbeQMPKVMState(qemuCapsPtr caps,
 + qemuMonitorPtr mon)
 +{
 +bool enabled = false;
 +bool present = false;
 +
 +if (!qemuCapsGet(caps, QEMU_CAPS_KVM))
 +return 0;
 +
 +if (qemuMonitorGetKVMState(mon, enabled, present)  0)
 +return -1;
 +
 +/* Youre right, this code does nothing, you must have checked out
 + * some weird commit.  Go back to your room and think about what
 + * you've done, young (wo)man. */
 
 Since this cute comment disappears in either 2/2 approach, I would
 probably rather see this series squashed into a single commit when
 finally going upstream.  That would also mean deleting the second
 paragraph of the commit message.
 
 
 +int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
 +   bool *enabled,
 +   bool *present)
 +{
 +int ret;
 +virJSONValuePtr cmd = NULL;
 +virJSONValuePtr reply = NULL;
 +virJSONValuePtr data = NULL;
 +
 +if (!(cmd = qemuMonitorJSONMakeCommand(query-kvm, NULL)))
 +return -1;
 +
 +ret = qemuMonitorJSONCommand(mon, cmd, reply);
 +
 +if (ret == 0) {
 +if (qemuMonitorJSONHasError(reply, CommandNotFound))
 +goto cleanup;
 
 This relies on the caller to pre-initialize *enabled and *present to
 false; it might be better to explicitly repeat that setting here so that
 this function guarantees that the values are always correct on
 successful return even if the caller forgot to initialize.  But right
 now, the only caller happens to pre-initialize, so it's not a show-stopper.
 
 ACK, once I pick which of the 2/2 variants I like best :)
 

I squashed both in, fixed the huge amount of typos, added the explicit
setting to false for the bools in qemuMonitorJSONGetKVMState(), double
checked and pushed.  Thanks very much.

Martin

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


[libvirt] Using Generic Ethernet type with custom networking without lowering the host security level

2012-10-31 Thread Ishimoto, Ryu
Hi Everyone,

I wanted to ask a question about the 'generic ethernet' NIC type.  If I
understand its security concerns correctly, because it expects QEMU to
execute scripts to bring up/down the interface, it requires that the host
security level is lowered to allow QEMU to perform privileged operations.
 While this is definitely not desirable, I'm have a situation where I want
to use libvirt to work with a custom networking solution that is neither
Linux bridge or OpenVSwitch.  Currently, to make this happen, I would
create a tap interface myself, configure it(like adding it to the
datapath), and inform libvirt of this interface as a generic ethernet type
with script attribute set to ''.  In order to make this work without the
security issue mentioned, I would like to suggest a new device type(or just
a modification of generic ethernet type) in which libvirt accepts an
interface name, opens it and gets its fd, and passes the fd to QEMU.  QEMU
does not run any scripts and expects the tap interface to be already open.
 Another solution might be to allow custom scripts to be plugged into
libvirt that allows you to add an interface to a bridge instead of running
brctl or ovs-vsctl.  The latter solution lets libvirt create the tap
interface, whereas the former requires that the tap is 'plugged' into the
network before libvirt takes control for the VM to have connectivity when
it launches.  I prefer the former because it seems less disruptive while
providing similar features.

I would be more than happy to send a patch for this, and I apologize that
this lacks details, but I just wanted to first make sure that what I'm
suggesting here makes sense and that I'm not missing something critical, as
I am fairly new to libvirt.

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

Re: [libvirt] [Libvirt-announce] Availability of Release Candidate 2 for 1.0.0

2012-10-31 Thread Justin Clift
On 29/10/2012, at 2:19 PM, Daniel Veillard wrote:
  The tree is now tagged (v1.0.0-rc2) and the tarball (and rpms) are
 available at the usual place:

Also works in OSX (using Xcode 4.1).

+ Justin

--
Aeolus Community Manager
http://www.aeolusproject.org

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


[libvirt] [PATCH] util: Improve error reporting from absolutePathFromBaseFile helper

2012-10-31 Thread Peter Krempa
There are multiple reasons canonicalize_file_name() used in
absolutePathFromBaseFile helper can fail. This patch enhances error
reporting from that helper.
---
 src/util/storage_file.c | 35 ---
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index e0b4178..f4c2943 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -530,22 +530,36 @@ qedGetBackingStore(char **res,
 static char *
 absolutePathFromBaseFile(const char *base_file, const char *path)
 {
-char *res;
-char *tmp;
-size_t d_len = dir_len (base_file);
+char *res = NULL;
+char *tmp = NULL;
+size_t d_len = dir_len(base_file);

 /* If path is already absolute, or if dirname(base_file) is .,
just return a copy of path.  */
-if (*path == '/' || d_len == 0)
-return canonicalize_file_name(path);
+if (*path == '/' || d_len == 0) {
+if (!(res = canonicalize_file_name(path)))
+virReportSystemError(errno,
+ _(Can't canonicalize path '%s'), path);
+
+goto cleanup;
+}

 /* Ensure that the following cast-to-int is valid.  */
-if (d_len  INT_MAX)
-return NULL;
+if (d_len  INT_MAX) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   Directory name too long: '%s', base_file);
+goto cleanup;
+}

-if (virAsprintf(tmp, %.*s/%s, (int) d_len, base_file, path)  0)
-return NULL;
-res = canonicalize_file_name(tmp);
+if (virAsprintf(tmp, %.*s/%s, (int) d_len, base_file, path)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+if (!(res = canonicalize_file_name(tmp)))
+virReportSystemError(errno, _(Can't canonicalize path '%s'), path);
+
+cleanup:
 VIR_FREE(tmp);
 return res;
 }
@@ -713,7 +727,6 @@ virStorageFileGetMetadataFromBuf(int format,
 meta-backingStoreRaw = meta-backingStore;
 meta-backingStore = absolutePathFromBaseFile(path, backing);
 if (meta-backingStore == NULL) {
-virReportOOMError();
 VIR_FREE(backing);
 return -1;
 }
-- 
1.7.12.4

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


Re: [libvirt] [PATCH v5 1/6] add a configure option --with-fuse to prepare introduction of fuse support for libvirt lxc

2012-10-31 Thread Gao feng
Hi Daniel

Can you review this patch?
Any comment is welcomed.

Thanks
Gao

于 2012年10月25日 18:38, Gao feng 写道:
 add a configure option --with-fuse to prepare introduction
 of fuse support for libvirt lxc.
 
 With help from Daniel
 
 Signed-off-by: Gao feng gaof...@cn.fujitsu.com
 ---
  configure.ac|   36 
  libvirt.spec.in |9 +
  2 files changed, 45 insertions(+), 0 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
 index 8810efd..0cac7fd 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -115,6 +115,7 @@ LIBSSH2_REQUIRED=1.0
  LIBSSH2_TRANSPORT_REQUIRED=1.3
  LIBBLKID_REQUIRED=2.17
  DBUS_REQUIRED=1.0.0
 +FUSE_REQUIRED=2.8.6
  
  dnl Checks for C compiler.
  AC_PROG_CC
 @@ -1857,6 +1858,36 @@ AC_SUBST([CAPNG_CFLAGS])
  AC_SUBST([CAPNG_LIBS])
  
  
 +dnl libfuse
 +AC_ARG_WITH([fuse],
 +  AC_HELP_STRING([--with-fuse], [use libfuse to proivde fuse filesystem 
 support for libvirt lxc]),
 +  [],
 +  [with_fuse=check])
 +dnl
 +dnl This check looks for 'fuse'
 +dnl
 +FUSE_CFLAGS=
 +FUSE_LIBS=
 +if test x$with_fuse != xno; then
 +  PKG_CHECK_MODULES([FUSE], [fuse = $FUSE_REQUIRED],
 +[with_fuse=yes], [
 +if test x$with_fuse = xcheck ; then
 +with_fuse=no
 +else
 +AC_MSG_ERROR(
 +  [You must install fuse Library to compile libvirt])
 +fi
 +  ])
 +  if test x$with_fuse = xyes ; then
 +FUSE_LIBS=-lfuse
 +FUSE_CFLAGS=-D_FILE_OFFSET_BITS=64
 +AC_DEFINE_UNQUOTED([HAVE_FUSE], 1, [whether fuse is available for 
 libvirt lxc])
 +  fi
 +fi
 +AM_CONDITIONAL([HAVE_FUSE], [test x$with_fuse = xyes])
 +AC_SUBST([FUSE_CFLAGS])
 +AC_SUBST([FUSE_LIBS])
 +
  
  dnl virsh libraries
  AC_CHECK_HEADERS([readline/readline.h])
 @@ -3161,6 +3192,11 @@ AC_MSG_NOTICE([   capng: $CAPNG_CFLAGS $CAPNG_LIBS])
  else
  AC_MSG_NOTICE([   capng: no])
  fi
 +if test $with_fuse = yes ; then
 +AC_MSG_NOTICE([fuse: $FUSE_CFLAGS $FUSE_LIBS])
 +else
 +AC_MSG_NOTICE([fuse: no])
 +fi
  if test $with_xen = yes ; then
  AC_MSG_NOTICE([ xen: $XEN_CFLAGS $XEN_LIBS])
  else
 diff --git a/libvirt.spec.in b/libvirt.spec.in
 index 511949e..8fe0d77 100644
 --- a/libvirt.spec.in
 +++ b/libvirt.spec.in
 @@ -93,6 +93,7 @@
  # A few optional bits off by default, we enable later
  %define with_polkit0%{!?_without_polkit:0}
  %define with_capng 0%{!?_without_capng:0}
 +%define with_fuse  0%{!?_without_fuse:0}
  %define with_netcf 0%{!?_without_netcf:0}
  %define with_udev  0%{!?_without_udev:0}
  %define with_hal   0%{!?_without_hal:0}
 @@ -503,6 +504,9 @@ BuildRequires: numactl-devel
  %if %{with_capng}
  BuildRequires: libcap-ng-devel = 0.5.0
  %endif
 +%if %{with_fuse}
 +BuildRequires: fuse-devel = 2.8.6
 +%endif
  %if %{with_phyp} || %{with_libssh2_transport}
  %if %{with_libssh2_transport}
  BuildRequires: libssh2-devel = 1.3.0
 @@ -1186,6 +1190,10 @@ of recent versions of Linux (and other OSes).
  %define _without_capng --without-capng
  %endif
  
 +%if ! %{with_fuse}
 +%define _without_fuse --without-fuse
 +%endif
 +
  %if ! %{with_netcf}
  %define _without_netcf --without-netcf
  %endif
 @@ -1289,6 +1297,7 @@ autoreconf -if
 %{?_without_numactl} \
 %{?_without_numad} \
 %{?_without_capng} \
 +   %{?_without_fuse} \
 %{?_without_netcf} \
 %{?_without_selinux} \
 %{?_with_selinux_mount} \
 


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

Re: [libvirt] [PATCH] util: Improve error reporting from absolutePathFromBaseFile helper

2012-10-31 Thread Martin Kletzander
On 10/31/2012 11:19 AM, Peter Krempa wrote:
 There are multiple reasons canonicalize_file_name() used in
 absolutePathFromBaseFile helper can fail. This patch enhances error
 reporting from that helper.
 ---
  src/util/storage_file.c | 35 ---
  1 file changed, 24 insertions(+), 11 deletions(-)
 
 diff --git a/src/util/storage_file.c b/src/util/storage_file.c
 index e0b4178..f4c2943 100644
 --- a/src/util/storage_file.c
 +++ b/src/util/storage_file.c
 @@ -530,22 +530,36 @@ qedGetBackingStore(char **res,
  static char *
  absolutePathFromBaseFile(const char *base_file, const char *path)
  {
 -char *res;
 -char *tmp;
 -size_t d_len = dir_len (base_file);
 +char *res = NULL;
 +char *tmp = NULL;
 +size_t d_len = dir_len(base_file);
 
  /* If path is already absolute, or if dirname(base_file) is .,
 just return a copy of path.  */
 -if (*path == '/' || d_len == 0)
 -return canonicalize_file_name(path);
 +if (*path == '/' || d_len == 0) {
 +if (!(res = canonicalize_file_name(path)))
 +virReportSystemError(errno,
 + _(Can't canonicalize path '%s'), path);
 +
 +goto cleanup;
 +}
 
  /* Ensure that the following cast-to-int is valid.  */
 -if (d_len  INT_MAX)
 -return NULL;
 +if (d_len  INT_MAX) {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   Directory name too long: '%s', base_file);

Forgot to gettext here: _(Directory name too long: '%s')

 +goto cleanup;
 +}
 
 -if (virAsprintf(tmp, %.*s/%s, (int) d_len, base_file, path)  0)
 -return NULL;
 -res = canonicalize_file_name(tmp);
 +if (virAsprintf(tmp, %.*s/%s, (int) d_len, base_file, path)  0) {
 +virReportOOMError();
 +goto cleanup;
 +}
 +
 +if (!(res = canonicalize_file_name(tmp)))
 +virReportSystemError(errno, _(Can't canonicalize path '%s'), path);
 +
 +cleanup:
  VIR_FREE(tmp);
  return res;
  }
 @@ -713,7 +727,6 @@ virStorageFileGetMetadataFromBuf(int format,
  meta-backingStoreRaw = meta-backingStore;
  meta-backingStore = absolutePathFromBaseFile(path, backing);
  if (meta-backingStore == NULL) {
 -virReportOOMError();
  VIR_FREE(backing);
  return -1;
  }
 

ACK with that fixed,

Martin

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


Re: [libvirt] [PATCH] util: Improve error reporting from absolutePathFromBaseFile helper

2012-10-31 Thread Peter Krempa

On 10/31/12 11:40, Martin Kletzander wrote:

On 10/31/2012 11:19 AM, Peter Krempa wrote:

There are multiple reasons canonicalize_file_name() used in
absolutePathFromBaseFile helper can fail. This patch enhances error
reporting from that helper.
---
  src/util/storage_file.c | 35 ---
  1 file changed, 24 insertions(+), 11 deletions(-)



Thanks; I added the gettext macro and pushed.

Peter

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


Re: [libvirt] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Dave Allan
On Wed, Oct 31, 2012 at 04:26:54PM +0800, Daniel Veillard wrote:
 On Tue, Oct 30, 2012 at 10:13:35PM +0100, Guido Günther wrote:
  
  Looks good now on the Debian buildds:
  
  https://buildd.debian.org/status/package.php?p=libvirtsuite=experimental
 
   Great !
 I just tagged rc3 in git and pushed tarball and rpms to the usual
 location:
   ftp://libvirt.org/libvirt/
 
  Seems that we are in good shape for the final 1.0.0 release which I
 will do early Friday unless something really bad shows up in the
 meantime. Please be careful with pushing patches in the next 2 days
 especially for anything which could affect portability :-)
  Let's test this for 2 more days !

I don't know if it's still valid, but BZ 871756 was filed today saying
that builds fail on uclibc based distros.  I'm commenting in the BZ
that it'd be helpful for the reporter to chime in here.

Dave

   thanks in advance,
 
 Daniel
 
 -- 
 Daniel Veillard  | Open Source and Standards, Red Hat
 veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
 http://veillard.com/ | virtualization library  http://libvirt.org/
 
 --
 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] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Leonardo Arena
Hi,

I was invited to show up here regarding BZ 871756. I'm the maintainer of
libvirt on Alpine Linux [1], an uclibc-based distro.

If you need more info, testing, etc. just let me know.

Cheers,
leonardo

P.S. Sorry if I've broken the thread

[1] http://alpinelinux.org/


signature.asc
Description: This is a digitally signed message part
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] jna problem

2012-10-31 Thread Matthieu Simonin
Hello, 

Since this morning i got this exception throwed by the libvirt-java : 

java.lang.UnsatisfiedLinkError: com.sun.jna.Native.pointerSize()I 
at com.sun.jna.Native.pointerSize(Native Method) 

What could be the problem ? Is it related to an update of my distribution ? 

Bye, 

Matt 


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

Re: [libvirt] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Martin Kletzander
On 10/31/2012 01:29 PM, Leonardo Arena wrote:
 Hi,
 
 I was invited to show up here regarding BZ 871756. I'm the maintainer of
 libvirt on Alpine Linux [1], an uclibc-based distro.
 

Hi, thanks for looking at it.  It's good to hear there is only one
function missing when building on uclibc.  Although it's a pity there is
no replacement for that in uclibc, there is in gnulib (which we use,
anyway) and I think that adding a gnulib module would be safer, but
probably I'm not the best one to decide upon that.

Anyone else to correct me?  In case anyone wants to have a look, here
are the links to ease the search:

Bug:  https://bugzilla.redhat.com/show_bug.cgi?id=871756
Diff: https://bugzilla.redhat.com/attachment.cgi?id=636010

 If you need more info, testing, etc. just let me know.
 

If you could try that with the gnulib module and send it as a patch, we
could maybe have it in 1.0.0.

Martin

 Cheers,
 leonardo
 
 P.S. Sorry if I've broken the thread
 
 [1] http://alpinelinux.org/

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


Re: [libvirt] dhcp6, radvd, ip6tables, etc. (update)

2012-10-31 Thread Gene Czarcinski

On 10/30/2012 02:28 PM, Laine Stump wrote:

I now realize that I am going to need to get into virsh net-update
since I am adding things to the xml specification and net-update will
need to differentiate between dhcp4 and dhcp6 changes.

Another thought that occurs to me is whether there has any
consideration been given having a virsh net-restart which would just
restart dnsmasq and radvd.  Typing stuff in for the command line of
net-update is a little prone to typos.

You can always put them in (temporary) files:-)


   Wouldn't having net-edit and net-restart do what is intended for
net-update.  Maybe there is a way to have net-update do the equivalent
of net-edit/net-restart.  For example, if you only did virsh
net-update network it would do it.

Oh so close and yet so far.

I have given the man-page for net-update a closer reading and now 
realize that I can use a terporary file and that scratch one of my 
itches.  As I read through that documentation I saw the --parent-index 
which allows you to select which ip definition you are changing.  Oh 
boy, this looks good.  I can use that to select if I am updating the 
ipv4 or ipv6 specification. Sounds good!  Too bad it does not work that 
way.  You check the family and if it is not ipv4, you quit.


Going with a minimum change, I propose changing that test to allow ipv4 
or ipv6.


BTW, there seem to be a number of things that do not work in 
net-update.  Aside from dns-host, is there anything else that is not 
there yet?


Also, I am updating and re-basing my patches against v1.0.0-rc2.  Is 
that a good choice for now?


Gene

Gene

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


Re: [libvirt] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Eric Blake
On 10/31/2012 06:29 AM, Leonardo Arena wrote:
 Hi,
 
 I was invited to show up here regarding BZ 871756. I'm the maintainer of
 libvirt on Alpine Linux [1], an uclibc-based distro.
 
 If you need more info, testing, etc. just let me know.

 --- a/src/util/logging.c
 +++ b/src/util/logging.c
 @@ -58,6 +58,11 @@
  
  #define VIR_FROM_THIS VIR_FROM_NONE
  
 +#ifdef __UCLIBC__
 +/* uclibc does not implement mkostemp GNU extention */
 +#define mkostemp(x,y) mkstemp(x)
 +#endif
 +
  VIR_ENUM_DECL(virLogSource)
  VIR_ENUM_IMPL(virLogSource, VIR_LOG_FROM_LAST,
file,

NACK.  Rather, we should be using gnulib's mkostemp - I'm working on the
patch, and will post it shortly.  If you could test my version, that
would be much appreciated.

-- 
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] build: prefer mkostemp for multi-thread safety

2012-10-31 Thread Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=871756

Commit cd1e8d1 assumed that systems new enough to have journald
also have mkostemp; but this is not true for uclibc.

For that matter, use of mkstemp[s] is unsafe in a multi-threaded
program.  We should prefer mkostemp[s] in the first place.

* bootstrap.conf (gnulib_modules): Add mkostemp, mkostemps; drop
mkstemp and mkstemps.
* cfg.mk (sc_prohibit_mkstemp): New syntax check.
* tools/virsh.c (vshEditWriteToTempFile): Adjust caller.
* src/qemu/qemu_driver.c (qemuDomainScreenshot)
(qemudDomainMemoryPeek): Likewise.
* src/secret/secret_driver.c (replaceFile): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
---
 bootstrap.conf | 4 ++--
 cfg.mk | 6 ++
 src/qemu/qemu_driver.c | 8 
 src/secret/secret_driver.c | 4 ++--
 src/vbox/vbox_tmpl.c   | 4 ++--
 tools/virsh.c  | 2 +-
 6 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 5d391fd..59dd258 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -69,8 +69,8 @@ listen
 localeconv
 maintainer-makefile
 manywarnings
-mkstemp
-mkstemps
+mkostemp
+mkostemps
 mktempd
 net_if
 netdb
diff --git a/cfg.mk b/cfg.mk
index 50e6a50..cda04e4 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -339,6 +339,12 @@ sc_prohibit_fork_wrappers:
halt='use virCommand for child processes'   \
  $(_sc_search_regexp)

+# Prefer mkostemp with O_CLOEXEC.
+sc_prohibit_mkstemp:
+   @prohibit='[^]\mkstemps? *\(' \
+   halt='use mkostemp with O_CLOEXEC instead of mkstemp'   \
+ $(_sc_search_regexp)
+
 # access with X_OK accepts directories, but we can't exec() those.
 # access with F_OK or R_OK is okay, though.
 sc_prohibit_access_xok:
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3980c10..5baa1e7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3485,8 +3485,8 @@ qemuDomainScreenshot(virDomainPtr dom,
 goto endjob;
 }

-if ((tmp_fd = mkstemp(tmp)) == -1) {
-virReportSystemError(errno, _(mkstemp(\%s\) failed), tmp);
+if ((tmp_fd = mkostemp(tmp, O_CLOEXEC)) == -1) {
+virReportSystemError(errno, _(mkostemp(\%s\) failed), tmp);
 goto endjob;
 }
 unlink_tmp = true;
@@ -9230,9 +9230,9 @@ qemudDomainMemoryPeek (virDomainPtr dom,
 }

 /* Create a temporary filename. */
-if ((fd = mkstemp (tmp)) == -1) {
+if ((fd = mkostemp(tmp, O_CLOEXEC)) == -1) {
 virReportSystemError(errno,
- _(mkstemp(\%s\) failed), tmp);
+ _(mkostemp(\%s\) failed), tmp);
 goto endjob;
 }

diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 9ce1e33..51e1e46 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -171,9 +171,9 @@ replaceFile(const char *filename, void *data, size_t size)
 virReportOOMError();
 goto cleanup;
 }
-fd = mkstemp (tmp_path);
+fd = mkostemp(tmp_path, O_CLOEXEC);
 if (fd == -1) {
-virReportSystemError(errno, _(mkstemp('%s') failed), tmp_path);
+virReportSystemError(errno, _(mkostemp('%s') failed), tmp_path);
 goto cleanup;
 }
 if (fchmod(fd, S_IRUSR | S_IWUSR) != 0) {
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 32a903e..6f245da 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -9157,8 +9157,8 @@ vboxDomainScreenshot(virDomainPtr dom,
 return NULL;
 }

-if ((tmp_fd = mkstemp(tmp)) == -1) {
-virReportSystemError(errno, _(mkstemp(\%s\) failed), tmp);
+if ((tmp_fd = mkostemp(tmp, O_CLOEXEC)) == -1) {
+virReportSystemError(errno, _(mkostemp(\%s\) failed), tmp);
 VIR_FREE(tmp);
 VBOX_RELEASE(machine);
 return NULL;
diff --git a/tools/virsh.c b/tools/virsh.c
index f0ec625..5388c9e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -565,7 +565,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
 vshError(ctl, %s, _(out of memory));
 return NULL;
 }
-fd = mkstemps(ret, 4);
+fd = mkostemps(ret, 4, O_CLOEXEC);
 if (fd == -1) {
 vshError(ctl, _(mkstemps: failed to create temporary file: %s),
  virStrerror(errno, ebuf, sizeof(ebuf)));
-- 
1.7.11.7

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


Re: [libvirt] [PATCH] nodeinfo: Add workaround if kernel reports bogous numa topology.

2012-10-31 Thread George-Cristian Bîrzan
On Wed, Oct 31, 2012 at 4:50 PM, George-Cristian Bîrzan g...@birzan.orgwrote:

 on 0.10.2:

 [root@host34 libvirt]# virsh nodeinfo
 CPU model:   x86_64
 CPU(s):  24
 CPU frequency:   2200 MHz
 CPU socket(s):   1
 Core(s) per socket:  6
 Thread(s) per core:  1
 NUMA cell(s):4
 Memory size: 131971020 KiB

 and http://birzan.org/capabilities4-newlibvirt.txt

 This has made the problem even worse, as we now can only use 6 cores out
 of 24 by default (libvirt pins qemus to the CPUs is sees available, so we
 have to manually taskset them after starting).


I should check before I let my mouth run. This actually fixed the problem,
we now get all 24 CPUs:

virsh # vcpuinfo 08867271-d458-43dc-8a03-807e83d107b4
VCPU:   0
CPU:9
State:  running
CPU time:   1.3s
CPU Affinity:   


To give you an example from the 'broken' host (still with 0.10.2):

[root@host29 ~]# virsh vcpuinfo 17db9ebb-691b-47e1-bbf4-c9e3c1388d4f
VCPU:   0
CPU:3
State:  running
CPU time:   3103.2s
CPU Affinity:   

VCPU:   1
CPU:1
State:  running
CPU time:   3460.4s
CPU Affinity:   


-- 
George-Cristian Bîrzan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] nodeinfo: Add workaround if kernel reports bogous numa topology.

2012-10-31 Thread George-Cristian Bîrzan
On Tue, Oct 30, 2012 at 10:08 PM, Eric Blake ebl...@redhat.com wrote:

 Both bitmaps show all 24 cores, so hwloc is able to read sysfs and
 determine the existence of 2 sockets with 12 nodes each, and where the
 12 nodes are numbered 0-5 twice according to which bank of cache they
 are tied to.  Which version of libvirt is this tested on where libvirt
 was only reporting 12 cores, because I thought we already patched that
 with commit 80533ca in 0.10.0.  That is, I think proc1.png should result
 in:

 $ virsh nodeinfo
 CPU model:   x86_64
 CPU(s):  24
 CPU frequency:   2200 MHz
 CPU socket(s):   2
 Core(s) per socket:  12
 Thread(s) per core:  1
 NUMA cell(s):1
 Memory size: 8047272 KiB


(Just for clarity, I am the original reporter, sorry I couldn't answer
earlier, I subscribed to the list too late and didn't want to break the
thread)

On the host with 1 NUMA cell, with libvrit 0.10.2 I get:

[root@host29 ~]# virsh nodeinfo
CPU model:   x86_64
CPU(s):  24
CPU frequency:   2200 MHz
CPU socket(s):   2
Core(s) per socket:  6
Thread(s) per core:  1
NUMA cell(s):1
Memory size: 131971548 KiB

Furthermore, to answer the question at the bottom of your email,
http://birzan.org/capabilities1.txt has this info.


 and proc4.png would _ideally_ result in:

 $ virsh nodeinfo
 CPU model:   x86_64
 CPU(s):  24
 CPU frequency:   2200 MHz
 CPU socket(s):   2
 Core(s) per socket:  12
 Thread(s) per core:  1
 NUMA cell(s):4
 Memory size: 8047272 KiB


[root@host34 ~]# virsh nodeinfo
CPU model:   x86_64
CPU(s):  24
CPU frequency:   2200 MHz
CPU socket(s):   2
Core(s) per socket:  6
Thread(s) per core:  1
NUMA cell(s):1
Memory size: 131971020 kB

And http://birzan.org/capabilities4.txt

This is on 0.9.11.5, on 0.10.2:

[root@host34 libvirt]# virsh nodeinfo
CPU model:   x86_64
CPU(s):  24
CPU frequency:   2200 MHz
CPU socket(s):   1
Core(s) per socket:  6
Thread(s) per core:  1
NUMA cell(s):4
Memory size: 131971020 KiB

and http://birzan.org/capabilities4-newlibvirt.txt

This has made the problem even worse, as we now can only use 6 cores out of
24 by default (libvirt pins qemus to the CPUs is sees available, so we have
to manually taskset them after starting).


 I think the CPU _is_ reporting the complete NUMA topology through sysfs,
 but that we are probably consolidating information from the wrong files
 and therefore getting confused.

 The sysfs is tarred up in http://birzan.org/sysdevicessystem.tar.gz for
host29 (the one with 1 numa cell in capabilities) and
http://birzan.org/sysdevicessystem-34.tar.gz


 Also, what does the 'virsh capabilities' report for the topology
 section?  Whereas 'virsh nodeinfo' is constrained by back-compat to give
 a lame answer for number of NUMA cells, at least 'virsh capabilities'
 should be showing a reasonable representation of the machine's topology.


I answered this above. If you need any more info, feel free to ask.


-- 
George-Cristian Bîrzan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] qemu: Fix EmulatorPinInfo without emulatorpin

2012-10-31 Thread Martin Kletzander
https://bugzilla.redhat.com/show_bug.cgi?id=871312

Recent fixes made almost all the right steps to make emulator pinned
to the cpuset of the whole domain in case emulatorpin isn't
specified, but qemudDomainGetEmulatorPinInfo still reports all the
CPUs even when cpuset is specified.  This patch fixes that.
---
 src/qemu/qemu_driver.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3980c10..8b5f06a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4352,7 +4352,6 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
 virDomainDefPtr targetDef = NULL;
 int ret = -1;
 int maxcpu, hostcpus, pcpu;
-virDomainVcpuPinDefPtr emulatorpin = NULL;
 virBitmapPtr cpumask = NULL;
 bool pinned;

@@ -4394,14 +4393,15 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
 cpumaps[maplen - 1] = (1  maxcpu % 8) - 1;
 }

-/* If no emulatorpin, all cpus should be used */
-emulatorpin = targetDef-cputune.emulatorpin;
-if (!emulatorpin) {
+if (targetDef-cputune.emulatorpin) {
+cpumask = targetDef-cputune.emulatorpin-cpumask;
+} else if (targetDef-cpumask) {
+cpumask = targetDef-cpumask;
+} else {
 ret = 0;
 goto cleanup;
 }

-cpumask = emulatorpin-cpumask;
 for (pcpu = 0; pcpu  maxcpu; pcpu++) {
 if (virBitmapGetBit(cpumask, pcpu, pinned)  0)
 goto cleanup;
-- 
1.7.12.4

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


Re: [libvirt] [PATCH] qemu: Fix EmulatorPinInfo without emulatorpin

2012-10-31 Thread Jiri Denemark
On Wed, Oct 31, 2012 at 16:03:53 +0100, Martin Kletzander wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=871312
 
 Recent fixes made almost all the right steps to make emulator pinned
 to the cpuset of the whole domain in case emulatorpin isn't
 specified, but qemudDomainGetEmulatorPinInfo still reports all the
 CPUs even when cpuset is specified.  This patch fixes that.
 ---
  src/qemu/qemu_driver.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

ACK

Jirka

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


Re: [libvirt] [PATCH] qemu: Fix EmulatorPinInfo without emulatorpin

2012-10-31 Thread Martin Kletzander
On 10/31/2012 04:11 PM, Jiri Denemark wrote:
 On Wed, Oct 31, 2012 at 16:03:53 +0100, Martin Kletzander wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=871312

 Recent fixes made almost all the right steps to make emulator pinned
 to the cpuset of the whole domain in case emulatorpin isn't
 specified, but qemudDomainGetEmulatorPinInfo still reports all the
 CPUs even when cpuset is specified.  This patch fixes that.
 ---
  src/qemu/qemu_driver.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)
 
 ACK
 
 Jirka
 

Thanks, pushed.

Martin

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


Re: [libvirt] [PATCH 0/5] Structured error logging and syslog support

2012-10-31 Thread Miloslav Trmac
Hello,
- Original Message -
 This is sort of a v2 of the Structured syslog series.
 
 Patches 1-4 allow callers virLogMessage to add arbitrary additional data,
 and use it in virRaiseErrorFull and its callers.  This data is sent
 to journal (and ignored for other outputs).

Any comments on the series, or at least on 1-4?  Even a hell no, go away 
would be beneficial. :)

Thank you,
Mirek

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


Re: [libvirt] [PATCH] build: prefer mkostemp for multi-thread safety

2012-10-31 Thread Martin Kletzander
On 10/31/2012 03:42 PM, Eric Blake wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=871756
 
 Commit cd1e8d1 assumed that systems new enough to have journald
 also have mkostemp; but this is not true for uclibc.
 
 For that matter, use of mkstemp[s] is unsafe in a multi-threaded
 program.  We should prefer mkostemp[s] in the first place.
 
 * bootstrap.conf (gnulib_modules): Add mkostemp, mkostemps; drop
 mkstemp and mkstemps.
 * cfg.mk (sc_prohibit_mkstemp): New syntax check.
 * tools/virsh.c (vshEditWriteToTempFile): Adjust caller.
 * src/qemu/qemu_driver.c (qemuDomainScreenshot)
 (qemudDomainMemoryPeek): Likewise.
 * src/secret/secret_driver.c (replaceFile): Likewise.
 * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
 ---
  bootstrap.conf | 4 ++--
  cfg.mk | 6 ++
  src/qemu/qemu_driver.c | 8 
  src/secret/secret_driver.c | 4 ++--
  src/vbox/vbox_tmpl.c   | 4 ++--
  tools/virsh.c  | 2 +-
  6 files changed, 17 insertions(+), 11 deletions(-)
 
[...]
 diff --git a/tools/virsh.c b/tools/virsh.c
 index f0ec625..5388c9e 100644
 --- a/tools/virsh.c
 +++ b/tools/virsh.c
 @@ -565,7 +565,7 @@ vshEditWriteToTempFile(vshControl *ctl, const char *doc)
  vshError(ctl, %s, _(out of memory));
  return NULL;
  }
 -fd = mkstemps(ret, 4);
 +fd = mkostemps(ret, 4, O_CLOEXEC);
  if (fd == -1) {
  vshError(ctl, _(mkstemps: failed to create temporary file: %s),

This message should be changed as well.

   virStrerror(errno, ebuf, sizeof(ebuf)));
 

ACK with that changed.

Martin

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


[libvirt] [PATCH] docs: libvirtd no longer uses abstract namespace

2012-10-31 Thread Eric Blake
Commit 905be03d2 quit using the abstract namespace, but didn't
update the --help text to match.

* daemon/libvirtd.c (daemonUsage): Correct socket listing.
---

See also:
https://www.redhat.com/archives/libvirt-users/2012-October/msg00152.html

 daemon/libvirtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index d5f3e4c..624831a 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -936,7 +936,7 @@ libvirt management daemon:\n), argv0);
   $XDG_CONFIG_HOME/libvirt/libvirtd.conf\n\
 \n\
 Sockets:\n\
-  $XDG_RUNTIME_DIR/libvirt/libvirt-sock (in UNIX abstract namespace)\n\
+  $XDG_RUNTIME_DIR/libvirt/libvirt-sock\n\
 \n\
 TLS:\n\
   CA certificate: $HOME/.pki/libvirt/cacert.pem\n\
-- 
1.7.11.7

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


Re: [libvirt] [PATCH 0/5] Structured error logging and syslog support

2012-10-31 Thread Daniel P. Berrange
On Wed, Oct 31, 2012 at 11:38:43AM -0400, Miloslav Trmac wrote:
 Hello,
 - Original Message -
  This is sort of a v2 of the Structured syslog series.
  
  Patches 1-4 allow callers virLogMessage to add arbitrary additional data,
  and use it in virRaiseErrorFull and its callers.  This data is sent
  to journal (and ignored for other outputs).
 
 Any comments on the series, or at least on 1-4?  Even a hell no, go
 away would be beneficial. :)

I've been away for much of the past two weeks, but this is on my todo
list to review real soon.

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] [PATCH] gitignore: Ignore 'tags'

2012-10-31 Thread Michal Privoznik
---
 .gitignore |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 98ce398..79a055b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -193,6 +193,7 @@ results.log
 stamp-h
 stamp-h.in
 stamp-h1
+tags
 !/gnulib/lib/Makefile.am
 !/gnulib/tests/Makefile.am
 !/m4/virt-*.m4
-- 
1.7.8.6

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


Re: [libvirt] dhcp6, radvd, ip6tables, etc. (update)

2012-10-31 Thread Laine Stump
On 10/31/2012 10:24 AM, Gene Czarcinski wrote:
 On 10/30/2012 02:28 PM, Laine Stump wrote:
 I now realize that I am going to need to get into virsh net-update
 since I am adding things to the xml specification and net-update will
 need to differentiate between dhcp4 and dhcp6 changes.
 
 Another thought that occurs to me is whether there has any
 consideration been given having a virsh net-restart which would just
 restart dnsmasq and radvd.  Typing stuff in for the command line of
 net-update is a little prone to typos.
 You can always put them in (temporary) files:-)

Wouldn't having net-edit and net-restart do what is intended for
 net-update.  Maybe there is a way to have net-update do the equivalent
 of net-edit/net-restart.  For example, if you only did virsh
 net-update network it would do it.
 Oh so close and yet so far.

 I have given the man-page for net-update a closer reading and now
 realize that I can use a terporary file and that scratch one of my
 itches.  As I read through that documentation I saw the --parent-index
 which allows you to select which ip definition you are changing.

That was the most troublesome part of that entire API, and I'm still not
really happy with the way it works, but every other possibility we could
think of had more problems.

   Oh boy, this looks good.  I can use that to select if I am updating
 the ipv4 or ipv6 specification. Sounds good!  Too bad it does not work
 that way.  You check the family and if it is not ipv4, you quit.

That's just a safeguard to enforce the ipv4-only status of dhcp in the
current libvirt. Just remove that restriction from the function
virNetworkDefUpdateIP() as a part of your patch adding ipv6 dhcp support.


 Going with a minimum change, I propose changing that test to allow
 ipv4 or ipv6.

Since those are the only two supported, and it has to be one or the
other, just remove that part of the check.



 BTW, there seem to be a number of things that do not work in
 net-update.  Aside from dns-host, is there anything else that is not
 there yet?

Look at the functions whose names start with virNetworkDefUpdate in
network_conf.c. Those for not-yet-implemented sections will be a shell
with just a call to virNetworkDefUpdateNoSupport(). As of today, these
are implemented: ip-dhcp-host, ip-dhcp-range, forward-interface, and
portgroup.


The patchset that initially added the virNetworkUpdate API added the
toplevel API itself, the backend infrastructure, and the specific
function for as many of the defined sections as I could get implemented
prior to the 0.10.2 release. The reason for this is that 1) the next
release of Fedora 18 will be based on 0.10.2, 2) there will never be a
full rebase to a newer libvirt, 3) new public APIs cannot be backported
as individual patches, but 4) code that simply adds functionality in the
backend *can* be backported to older releases as individual patches. So,
by pushing the API plus backend for 4 essential sections (according to a
couple people requesting the functionality), we were able to guarantee
that the API would be available in Fedora 18. (If there had been more
time before the 0.10.2 release, I would have implemented backends for
more of the sections)


 Also, I am updating and re-basing my patches against v1.0.0-rc2.  Is
 that a good choice for now?

You really should follow upstream git master rather than sticking to a
particular snapshot. Any patches that you send to the list should be
rebased to the head of git master anyway. Without exception, any patch
that is applied to libvirt is first applied to the head of git master,
and then later cherry-picked to one of the -maint branches for exporting
to a distro build (at least this is the case for Fedora). Since you'll
have to rebase to that eventually anyway, it's usually much easier to
periodically rebase against git master as you go, and deal with small
merge conflicts as they arise, rather than waiting until the end and
suddenly having a large number of conflicting conflicts (or at least
more confusing).

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


Re: [libvirt] [PATCH] gitignore: Ignore 'tags'

2012-10-31 Thread Martin Kletzander
On 10/31/2012 04:48 PM, Michal Privoznik wrote:
 ---
  .gitignore |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 
 diff --git a/.gitignore b/.gitignore
 index 98ce398..79a055b 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -193,6 +193,7 @@ results.log
  stamp-h
  stamp-h.in
  stamp-h1
 +tags
  !/gnulib/lib/Makefile.am
  !/gnulib/tests/Makefile.am
  !/m4/virt-*.m4
 

ACK,

Martin

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


Re: [libvirt] [PATCH] gitignore: Ignore 'tags'

2012-10-31 Thread Eric Blake
On 10/31/2012 09:48 AM, Michal Privoznik wrote:
 ---
  .gitignore |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
 
 diff --git a/.gitignore b/.gitignore
 index 98ce398..79a055b 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -193,6 +193,7 @@ results.log
  stamp-h
  stamp-h.in
  stamp-h1
 +tags

ACK.

  !/gnulib/lib/Makefile.am
  !/gnulib/tests/Makefile.am
  !/m4/virt-*.m4
 

-- 
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] docs: libvirtd no longer uses abstract namespace

2012-10-31 Thread Martin Kletzander
On 10/31/2012 04:48 PM, Eric Blake wrote:
 Commit 905be03d2 quit using the abstract namespace, but didn't
 update the --help text to match.
 
 * daemon/libvirtd.c (daemonUsage): Correct socket listing.
 ---
 
 See also:
 https://www.redhat.com/archives/libvirt-users/2012-October/msg00152.html
 
  daemon/libvirtd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
 index d5f3e4c..624831a 100644
 --- a/daemon/libvirtd.c
 +++ b/daemon/libvirtd.c
 @@ -936,7 +936,7 @@ libvirt management daemon:\n), argv0);
$XDG_CONFIG_HOME/libvirt/libvirtd.conf\n\
  \n\
  Sockets:\n\
 -  $XDG_RUNTIME_DIR/libvirt/libvirt-sock (in UNIX abstract namespace)\n\
 +  $XDG_RUNTIME_DIR/libvirt/libvirt-sock\n\
  \n\
  TLS:\n\
CA certificate: $HOME/.pki/libvirt/cacert.pem\n\
 

That's right, I didn't realize we still have it there when I was doing
something with it some time ago.  ACK,

Martin

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


Re: [libvirt] [PATCH] gitignore: Ignore 'tags'

2012-10-31 Thread Michal Privoznik
On 31.10.2012 17:01, Eric Blake wrote:
 On 10/31/2012 09:48 AM, Michal Privoznik wrote:
 ---
  .gitignore |1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

 diff --git a/.gitignore b/.gitignore
 index 98ce398..79a055b 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -193,6 +193,7 @@ results.log
  stamp-h
  stamp-h.in
  stamp-h1
 +tags
 
 ACK.
 
  !/gnulib/lib/Makefile.am
  !/gnulib/tests/Makefile.am
  !/m4/virt-*.m4

 

Thanks, pushed.

Michal

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


Re: [libvirt] [PATCH] build: prefer mkostemp for multi-thread safety

2012-10-31 Thread Eric Blake
On 10/31/2012 09:45 AM, Martin Kletzander wrote:
 On 10/31/2012 03:42 PM, Eric Blake wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=871756

 Commit cd1e8d1 assumed that systems new enough to have journald
 also have mkostemp; but this is not true for uclibc.

 For that matter, use of mkstemp[s] is unsafe in a multi-threaded
 program.  We should prefer mkostemp[s] in the first place.

 -fd = mkstemps(ret, 4);
 +fd = mkostemps(ret, 4, O_CLOEXEC);
  if (fd == -1) {
  vshError(ctl, _(mkstemps: failed to create temporary file: %s),
 
 This message should be changed as well.
 
   virStrerror(errno, ebuf, sizeof(ebuf)));

 
 ACK with that changed.

Fixed and pushed.  Hopefully Leonardo can give libvirt.git a test (since
we probably won't have any more rc builds between now and 1.0.0 on Friday).

-- 
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] docs: libvirtd no longer uses abstract namespace

2012-10-31 Thread Eric Blake
On 10/31/2012 10:02 AM, Martin Kletzander wrote:
 On 10/31/2012 04:48 PM, Eric Blake wrote:
 Commit 905be03d2 quit using the abstract namespace, but didn't
 update the --help text to match.

 * daemon/libvirtd.c (daemonUsage): Correct socket listing.
 ---

 See also:
 https://www.redhat.com/archives/libvirt-users/2012-October/msg00152.html


 
 That's right, I didn't realize we still have it there when I was doing
 something with it some time ago.  ACK,
 

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] [PATCH] Fix arch detection for qemu-system-i386 with QMP

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

QEMU uses 'i386' for its 32-bit x86 architecture, but libvirt
wants that to be 'i686', so we must fix it up

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/qemu/qemu_capabilities.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9f15162..271273c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2327,6 +2327,14 @@ qemuCapsInitQMP(qemuCapsPtr caps,
 if (!(caps-arch = qemuMonitorGetTargetArch(mon)))
 goto cleanup;
 
+/* Map i386, i486, i586 to i686.  */
+if (caps-arch[0] == 'i' 
+caps-arch[1] != '\0' 
+caps-arch[2] == '8' 
+caps-arch[3] == '6' 
+caps-arch[4] == '\0')
+caps-arch[1] = '6';
+
 /* Currently only x86_64 and i686 support PCI-multibus. */
 if (STREQLEN(caps-arch, x86_64, 6) ||
 STREQLEN(caps-arch, i686, 4)) {
-- 
1.7.12.1

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


[libvirt] [PATCH] Don't assume pid_t is the same size as an int

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

virPidFileReadPathIfAlive passed in an 'int *' where a 'pid_t *'
was expected, which breaks on Mingw64 targets. Also a few places
were using '%d' for formatting pid_t, change them to '%lld' and
force a cast to the longer type as done elsewhere in the same
file.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/util/virpidfile.c |  4 ++--
 src/util/virprocess.c | 13 +++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index cb8a992..90a79c5 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -206,7 +206,7 @@ int virPidFileReadPathIfAlive(const char *path,
   pid_t *pid,
   const char *binPath)
 {
-int ret, retPid;
+int ret;
 bool isLink;
 char *procPath = NULL;
 char *procLink = NULL;
@@ -215,7 +215,7 @@ int virPidFileReadPathIfAlive(const char *path,
 char *resolvedProcLink = NULL;
 const char deletedText[] =  (deleted);
 size_t deletedTextLen = strlen(deletedText);
-
+pid_t retPid;
 
 /* only set this at the very end on success */
 *pid = -1;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 4bb7ebc..f8a8a49 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -250,7 +250,7 @@ virProcessKillPainfully(pid_t pid, bool force)
 int i, ret = -1;
 const char *signame = TERM;
 
-VIR_DEBUG(vpid=%d force=%d, pid, force);
+VIR_DEBUG(vpid=%lld force=%d, (long long)pid, force);
 
 /* This loop sends SIGTERM, then waits a few iterations (10 seconds)
  * to see if it dies. If the process still hasn't exited, and
@@ -265,8 +265,8 @@ virProcessKillPainfully(pid_t pid, bool force)
 if (i == 0) {
 signum = SIGTERM; /* kindly suggest it should exit */
 } else if ((i == 50)  force) {
-VIR_DEBUG(Timed out waiting after SIGTERM to process %d, 
-  sending SIGKILL, pid);
+VIR_DEBUG(Timed out waiting after SIGTERM to process %lld, 
+  sending SIGKILL, (long long)pid);
 /* No SIGKILL kill on Win32 ! Use SIGABRT instead which our
  * virProcessKill proc will handle more or less like SIGKILL */
 #ifdef WIN32
@@ -283,8 +283,8 @@ virProcessKillPainfully(pid_t pid, bool force)
 if (virProcessKill(pid, signum)  0) {
 if (errno != ESRCH) {
 virReportSystemError(errno,
- _(Failed to terminate process %d with 
SIG%s),
- pid, signame);
+ _(Failed to terminate process %lld with 
SIG%s),
+ (long long)pid, signame);
 goto cleanup;
 }
 ret = signum == SIGTERM ? 0 : 1;
@@ -294,7 +294,8 @@ virProcessKillPainfully(pid_t pid, bool force)
 usleep(200 * 1000);
 }
 
-VIR_DEBUG(Timed out waiting after SIGKILL to process %d, pid);
+VIR_DEBUG(Timed out waiting after SIGKILL to process %lld,
+  (long long)pid);
 
 cleanup:
 return ret;
-- 
1.7.11.7

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


Re: [libvirt] Availability of Release Candidate 3 for 1.0.0

2012-10-31 Thread Daniel P. Berrange
On Wed, Oct 31, 2012 at 04:26:54PM +0800, Daniel Veillard wrote:
 On Tue, Oct 30, 2012 at 10:13:35PM +0100, Guido Günther wrote:
  
  Looks good now on the Debian buildds:
  
  https://buildd.debian.org/status/package.php?p=libvirtsuite=experimental
 
   Great !
 I just tagged rc3 in git and pushed tarball and rpms to the usual
 location:
   ftp://libvirt.org/libvirt/
 
  Seems that we are in good shape for the final 1.0.0 release which I
 will do early Friday unless something really bad shows up in the
 meantime. Please be careful with pushing patches in the next 2 days
 especially for anything which could affect portability :-)
  Let's test this for 2 more days !

Doesn't build on Mingw64, but I've sent the patches for it.

Also 32-bit qemu guests are broken with latest QEMU, also sent
a fix for that.


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] [PATCHv2 1/3] qemu, lxc: Change host CPU detection logic.

2012-10-31 Thread Viktor Mihajlovski
The drivers for QEMU and LXC use virNodeGetInfo to determine the
number of host CPUs. This approach can lead to a wrong (too small)
number if one or more CPUs are offline.
It is better to use nodeGetCPUCount on Linux hosts.
---
V2 Changes:
Use nodeGetCPUCount as suggested by Eric, nodeGetCPUMap is too
heavyweight.

 src/lxc/lxc_controller.c |  8 +++-
 src/qemu/qemu_driver.c   | 14 +-
 src/qemu/qemu_process.c  |  8 +++-
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index a41c903..ed3d3d0 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -492,17 +492,15 @@ static int 
virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
 static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
 {
 int hostcpus, maxcpu = CPU_SETSIZE;
-virNodeInfo nodeinfo;
 virBitmapPtr cpumap, cpumapToSet;
 
 VIR_DEBUG(Setting CPU affinity);
 
-if (nodeGetInfo(NULL, nodeinfo)  0)
-return -1;
-
 /* setaffinity fails if you set bits for CPUs which
  * aren't present, so we have to limit ourselves */
-hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
+if ((hostcpus = nodeGetCPUCount())  0)
+return -1;
+
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3980c10..6ae33d3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4097,7 +4097,6 @@ qemudDomainGetVcpuPinInfo(virDomainPtr dom,
 
 struct qemud_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm = NULL;
-virNodeInfo nodeinfo;
 virDomainDefPtr targetDef = NULL;
 int ret = -1;
 int maxcpu, hostcpus, vcpu, pcpu;
@@ -4133,9 +4132,9 @@ qemudDomainGetVcpuPinInfo(virDomainPtr dom,
 /* Coverity didn't realize that targetDef must be set if we got here.  */
 sa_assert(targetDef);
 
-if (nodeGetInfo(dom-conn, nodeinfo)  0)
+if ((hostcpus = nodeGetCPUCount())  0)
 goto cleanup;
-hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
+
 maxcpu = maplen * 8;
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
@@ -4348,7 +4347,6 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
 {
 struct qemud_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm = NULL;
-virNodeInfo nodeinfo;
 virDomainDefPtr targetDef = NULL;
 int ret = -1;
 int maxcpu, hostcpus, pcpu;
@@ -4381,9 +4379,9 @@ qemudDomainGetEmulatorPinInfo(virDomainPtr dom,
 /* Coverity didn't realize that targetDef must be set if we got here. */
 sa_assert(targetDef);
 
-if (nodeGetInfo(dom-conn, nodeinfo)  0)
+if ((hostcpus = nodeGetCPUCount())  0)
 goto cleanup;
-hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
+
 maxcpu = maplen * 8;
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
@@ -4425,7 +4423,6 @@ qemudDomainGetVcpus(virDomainPtr dom,
 int maplen) {
 struct qemud_driver *driver = dom-conn-privateData;
 virDomainObjPtr vm;
-virNodeInfo nodeinfo;
 int i, v, maxcpu, hostcpus;
 int ret = -1;
 qemuDomainObjPrivatePtr priv;
@@ -4451,10 +4448,9 @@ qemudDomainGetVcpus(virDomainPtr dom,
 
 priv = vm-privateData;
 
-if (nodeGetInfo(dom-conn, nodeinfo)  0)
+if ((hostcpus = nodeGetCPUCount())  0)
 goto cleanup;
 
-hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
 maxcpu = maplen * 8;
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3ac5282..74e43b8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1902,15 +1902,13 @@ qemuPrepareCpumap(struct qemud_driver *driver,
   virBitmapPtr nodemask)
 {
 int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
-virNodeInfo nodeinfo;
 virBitmapPtr cpumap = NULL;
 
-if (nodeGetInfo(NULL, nodeinfo)  0)
-return NULL;
-
 /* setaffinity fails if you set bits for CPUs which
  * aren't present, so we have to limit ourselves */
-hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
+if ((hostcpus = nodeGetCPUCount())  0)
+return NULL;
+
 if (maxcpu  hostcpus)
 maxcpu = hostcpus;
 
-- 
1.7.12.4

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


[libvirt] [PATCHv2 0/3] Use virNodeGetCPUMap where appropriate

2012-10-31 Thread Viktor Mihajlovski
This series concludes the introduction of the virNodeGetCPUMap API
by replacing calls to virNodeGetInfo used only for the purpose
of computing the maximum number of node CPUs (which has the potential
to yield the incorrect number).
Most prominently, with patch 3/3 the output of virsh vcpuinfo will
now be correct for domains on hosts with offline CPUs

V2 Changes:
Rework based on Eric's feedback:
- Use nodeGetCPUCount instead of nodeGetCPUMap
- Avoid code bloat by computing node CPU count in a helper function

Viktor Mihajlovski (3):
  qemu, lxc: Change host CPU detection logic.
  python: Use virNodeGetCPUMap where possible
  virsh: Use virNodeGetCPUMap if possible

 python/libvirt-override.c | 87 ---
 src/lxc/lxc_controller.c  |  8 ++---
 src/qemu/qemu_driver.c| 14 +++-
 src/qemu/qemu_process.c   |  8 ++---
 tools/virsh-domain.c  | 32 -
 5 files changed, 86 insertions(+), 63 deletions(-)

-- 
1.7.12.4

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


[libvirt] [PATCHv2 2/3] python: Use virNodeGetCPUMap where possible

2012-10-31 Thread Viktor Mihajlovski
Modified the places where virNodeGetInfo was used for the purpose
of obtaining the maximum node CPU number. Transparently falling
back to virNodeGetInfo in case of failure.
Wrote a utility function getPyNodeCPUCount for that purpose.

Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
---
V2 Changes:
Implemented Eric Blake's suggestion to remove code bloat 
introduced by first patch version.
New helper function getPyNodeCPUCount is now used to calculate
the number of node CPUs.

 python/libvirt-override.c | 87 ---
 1 file changed, 52 insertions(+), 35 deletions(-)

diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index cd48227..3528997 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -253,6 +253,39 @@ cleanup:
 return NULL;
 }
 
+/*
+ * Utility function to retrieve the number of node CPUs present.
+ * It first tries virGetNodeCPUMap, which will return the
+ * number reliably, if available.
+ * As a fallback and for compatibility with backlevel libvirt
+ * versions virGetNodeInfo will be called to calculate the
+ * CPU number, which has the potential to return a too small
+ * number if some host CPUs are offline.
+ */
+static int
+getPyNodeCPUCount(virConnectPtr conn) {
+int i_retval;
+virNodeInfo nodeinfo;
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (i_retval  0) {
+/* fallback: use nodeinfo */
+LIBVIRT_BEGIN_ALLOW_THREADS;
+i_retval = virNodeGetInfo(conn, nodeinfo);
+LIBVIRT_END_ALLOW_THREADS;
+if (i_retval  0)
+goto cleanup;
+
+i_retval = VIR_NODEINFO_MAXCPUS(nodeinfo);
+}
+
+cleanup:
+return i_retval;
+}
+
 /
  * *
  * Statistics  *
@@ -1338,22 +1371,18 @@ libvirt_virDomainGetVcpus(PyObject *self 
ATTRIBUTE_UNUSED,
 virDomainPtr domain;
 PyObject *pyobj_domain, *pyretval = NULL, *pycpuinfo = NULL, *pycpumap = 
NULL;
 PyObject *error = NULL;
-virNodeInfo nodeinfo;
 virDomainInfo dominfo;
 virVcpuInfoPtr cpuinfo = NULL;
 unsigned char *cpumap = NULL;
 size_t cpumaplen, i;
-int i_retval;
+int i_retval, cpunum;
 
 if (!PyArg_ParseTuple(args, (char *)O:virDomainGetVcpus,
   pyobj_domain))
 return NULL;
 domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
-LIBVIRT_BEGIN_ALLOW_THREADS;
-i_retval = virNodeGetInfo(virDomainGetConnect(domain), nodeinfo);
-LIBVIRT_END_ALLOW_THREADS;
-if (i_retval  0)
+if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain)))  0)
 return VIR_PY_INT_FAIL;
 
 LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1365,7 +1394,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
 if (VIR_ALLOC_N(cpuinfo, dominfo.nrVirtCpu)  0)
 return PyErr_NoMemory();
 
-cpumaplen = VIR_CPU_MAPLEN(VIR_NODEINFO_MAXCPUS(nodeinfo));
+cpumaplen = VIR_CPU_MAPLEN(cpunum);
 if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
 VIR_ALLOC_N(cpumap, dominfo.nrVirtCpu * cpumaplen)  0) {
 error = PyErr_NoMemory();
@@ -1423,11 +1452,11 @@ libvirt_virDomainGetVcpus(PyObject *self 
ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 for (i = 0 ; i  dominfo.nrVirtCpu ; i++) {
-PyObject *info = PyTuple_New(VIR_NODEINFO_MAXCPUS(nodeinfo));
+PyObject *info = PyTuple_New(cpunum);
 int j;
 if (info == NULL)
 goto cleanup;
-for (j = 0 ; j  VIR_NODEINFO_MAXCPUS(nodeinfo) ; j++) {
+for (j = 0 ; j  cpunum ; j++) {
 PyObject *item = NULL;
 if ((item = PyBool_FromLong(VIR_CPU_USABLE(cpumap, cpumaplen, i, 
j))) == NULL ||
 PyTuple_SetItem(info, j, item)  0) {
@@ -1467,9 +1496,8 @@ libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
 virDomainPtr domain;
 PyObject *pyobj_domain, *pycpumap;
 PyObject *ret = NULL;
-virNodeInfo nodeinfo;
 unsigned char *cpumap;
-int cpumaplen, i, vcpu, tuple_size;
+int cpumaplen, i, vcpu, tuple_size, cpunum;
 int i_retval;
 
 if (!PyArg_ParseTuple(args, (char *)OiO:virDomainPinVcpu,
@@ -1477,10 +1505,7 @@ libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
 return NULL;
 domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
-LIBVIRT_BEGIN_ALLOW_THREADS;
-i_retval = virNodeGetInfo(virDomainGetConnect(domain), nodeinfo);
-LIBVIRT_END_ALLOW_THREADS;
-if (i_retval  0)
+if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain)))  0)
 return VIR_PY_INT_FAIL;
 
 if (PyTuple_Check(pycpumap)) {
@@ -1492,7 +1517,7 @@ libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
return ret;
 }
 
-

Re: [libvirt] [PATCH 3/3] virsh: Use virNodeGetCPUMap if possible

2012-10-31 Thread Viktor Mihajlovski

On 10/31/2012 02:30 AM, Eric Blake wrote:


This looks correct.  However, it may be easier to write a helper
function vshGetCPUCount, rather than copying and pasting this code into
multiple places.  I'm okay giving this an ACK, but since I've already
asked for a v2 of patch 1, you might want to do a v2 of this as well.
Oh, and I guess the same comment applies to the python code in 2/3.



Thanks for the comments, I have to agree in all points.
New series underway.

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

IBM Deutschland Research  Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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


[libvirt] [PATCHv2 3/3] virsh: Use virNodeGetCPUMap if possible

2012-10-31 Thread Viktor Mihajlovski
Modified the places where virNodeGetInfo was used for the purpose
of obtaining the maximum node CPU number. Transparently falling
back to virNodeGetInfo in case of failure.
Wrote utility function vshNodeGetCPUCount to compute node CPU
number.

Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
---
V2 Changes:
Implemented Eric Blake's suggestion to remove code bloat 
introduced by first patch version.
New helper function vshNodeGetCPUCount is now used to calculate
the number of node CPUs.

 tools/virsh-domain.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 255669f..59289f1 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -126,6 +126,26 @@ vshDomainVcpuStateToString(int state)
 }
 
 /*
+ * Determine number of CPU nodes present by trying
+ * virNodeGetCPUMap and falling back to virNodeGetInfo
+ * if needed.
+ */
+static int
+vshNodeGetCPUCount(virConnectPtr conn)
+{
+int ret;
+virNodeInfo nodeinfo;
+
+if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0))  0) {
+/* fall back to nodeinfo */
+if (virNodeGetInfo(conn, nodeinfo) == 0) {
+ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
+}
+}
+return ret;
+}
+
+/*
  * attach-device command
  */
 static const vshCmdInfo info_attach_device[] = {
@@ -4497,7 +4517,6 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
 {
 virDomainInfo info;
 virDomainPtr dom;
-virNodeInfo nodeinfo;
 virVcpuInfoPtr cpuinfo;
 unsigned char *cpumaps;
 int ncpus, maxcpu;
@@ -4508,7 +4527,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
 if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
 return false;
 
-if (virNodeGetInfo(ctl-conn, nodeinfo) != 0) {
+if ((maxcpu = vshNodeGetCPUCount(ctl-conn))  0) {
 virDomainFree(dom);
 return false;
 }
@@ -4519,7 +4538,6 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
 }
 
 cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu);
-maxcpu = VIR_NODEINFO_MAXCPUS(nodeinfo);
 cpumaplen = VIR_CPU_MAPLEN(maxcpu);
 cpumaps = vshMalloc(ctl, info.nrVirtCpu * cpumaplen);
 
@@ -4645,7 +4663,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 {
 virDomainInfo info;
 virDomainPtr dom;
-virNodeInfo nodeinfo;
 int vcpu = -1;
 const char *cpulist = NULL;
 bool ret = true;
@@ -4695,7 +4712,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 
-if (virNodeGetInfo(ctl-conn, nodeinfo) != 0) {
+if ((maxcpu = vshNodeGetCPUCount(ctl-conn))  0) {
 virDomainFree(dom);
 return false;
 }
@@ -4712,7 +4729,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
 return false;
 }
 
-maxcpu = VIR_NODEINFO_MAXCPUS(nodeinfo);
 cpumaplen = VIR_CPU_MAPLEN(maxcpu);
 
 /* Query mode: show CPU affinity information then exit.*/
@@ -4864,7 +4880,6 @@ static bool
 cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
 {
 virDomainPtr dom;
-virNodeInfo nodeinfo;
 const char *cpulist = NULL;
 bool ret = true;
 unsigned char *cpumap = NULL;
@@ -4905,12 +4920,11 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd)
 }
 query = !cpulist;
 
-if (virNodeGetInfo(ctl-conn, nodeinfo) != 0) {
+if ((maxcpu = vshNodeGetCPUCount(ctl-conn))  0) {
 virDomainFree(dom);
 return false;
 }
 
-maxcpu = VIR_NODEINFO_MAXCPUS(nodeinfo);
 cpumaplen = VIR_CPU_MAPLEN(maxcpu);
 
 /* Query mode: show CPU affinity information then exit.*/
-- 
1.7.12.4

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


[libvirt] [PATCH 02/11] virdbus: Add virDBusGetSessionBus helper

2012-10-31 Thread Daniel P. Berrange
From: Alexander Larsson al...@redhat.com

This splits out some common code from virDBusGetSystemBus and
uses it to implement a new virDBusGetSessionBus helper.
---
 src/libvirt_private.syms |  1 +
 src/util/virdbus.c   | 84 
 src/util/virdbus.h   |  1 +
 3 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 59d6de0..cc1aaf5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1324,6 +1324,7 @@ virConsoleOpen;
 
 # virdbus.h
 virDBusGetSystemBus;
+virDBusGetSessionBus;
 
 
 # virdomainlist.h
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 4acce12..2dc7265 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -32,40 +32,49 @@
 #ifdef HAVE_DBUS
 
 static DBusConnection *systembus = NULL;
-static virOnceControl once = VIR_ONCE_CONTROL_INITIALIZER;
-static DBusError dbuserr;
+static DBusConnection *sessionbus = NULL;
+static virOnceControl systemonce = VIR_ONCE_CONTROL_INITIALIZER;
+static virOnceControl sessiononce = VIR_ONCE_CONTROL_INITIALIZER;
+static DBusError systemdbuserr;
+static DBusError sessiondbuserr;
 
 static dbus_bool_t virDBusAddWatch(DBusWatch *watch, void *data);
 static void virDBusRemoveWatch(DBusWatch *watch, void *data);
 static void virDBusToggleWatch(DBusWatch *watch, void *data);
 
-static void virDBusSystemBusInit(void)
+static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
 {
+DBusConnection *bus;
+
 /* Allocate and initialize a new HAL context */
 dbus_connection_set_change_sigpipe(FALSE);
 dbus_threads_init_default();
 
-dbus_error_init(dbuserr);
-if (!(systembus = dbus_bus_get(DBUS_BUS_SYSTEM, dbuserr)))
-return;
+dbus_error_init(dbuserr);
+if (!(bus = dbus_bus_get(type, dbuserr)))
+return NULL;
 
-dbus_connection_set_exit_on_disconnect(systembus, FALSE);
+dbus_connection_set_exit_on_disconnect(bus, FALSE);
 
 /* Register dbus watch callbacks */
-if (!dbus_connection_set_watch_functions(systembus,
+if (!dbus_connection_set_watch_functions(bus,
  virDBusAddWatch,
  virDBusRemoveWatch,
  virDBusToggleWatch,
- NULL, NULL)) {
-systembus = NULL;
-return;
+ bus, NULL)) {
+return NULL;
 }
+return bus;
 }
 
+static void virDBusSystemBusInit(void)
+{
+systembus = virDBusBusInit (DBUS_BUS_SYSTEM, systemdbuserr);
+}
 
 DBusConnection *virDBusGetSystemBus(void)
 {
-if (virOnce(once, virDBusSystemBusInit)  0) {
+if (virOnce(systemonce, virDBusSystemBusInit)  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(Unable to run one time DBus initializer));
 return NULL;
@@ -74,7 +83,7 @@ DBusConnection *virDBusGetSystemBus(void)
 if (!systembus) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(Unable to get DBus system bus connection: %s),
-   dbuserr.message ? dbuserr.message : watch setup 
failed);
+   systemdbuserr.message ? systemdbuserr.message : watch 
setup failed);
 return NULL;
 }
 
@@ -82,13 +91,45 @@ DBusConnection *virDBusGetSystemBus(void)
 }
 
 
+static void virDBusSessionBusInit(void)
+{
+sessionbus = virDBusBusInit (DBUS_BUS_SESSION, sessiondbuserr);
+}
+
+DBusConnection *virDBusGetSessionBus(void)
+{
+if (virOnce(sessiononce, virDBusSessionBusInit)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(Unable to run one time DBus initializer));
+return NULL;
+}
+
+if (!sessionbus) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Unable to get DBus session bus connection: %s),
+   sessiondbuserr.message ? sessiondbuserr.message : 
watch setup failed);
+return NULL;
+}
+
+return sessionbus;
+}
+
+struct virDBusWatch
+{
+int watch;
+DBusConnection *bus;
+};
+
 static void virDBusWatchCallback(int fdatch ATTRIBUTE_UNUSED,
  int fd ATTRIBUTE_UNUSED,
  int events, void *opaque)
 {
 DBusWatch *watch = opaque;
+struct virDBusWatch *info;
 int dbus_flags = 0;
 
+info = dbus_watch_get_data(watch);
+
 if (events  VIR_EVENT_HANDLE_READABLE)
 dbus_flags |= DBUS_WATCH_READABLE;
 if (events  VIR_EVENT_HANDLE_WRITABLE)
@@ -100,7 +141,7 @@ static void virDBusWatchCallback(int fdatch 
ATTRIBUTE_UNUSED,
 
 (void)dbus_watch_handle(watch, dbus_flags);
 
-while (dbus_connection_dispatch(systembus) == DBUS_DISPATCH_DATA_REMAINS)
+while (dbus_connection_dispatch(info-bus) == DBUS_DISPATCH_DATA_REMAINS)
 /* keep dispatching while data remains 

[libvirt] [PATCH 06/11] Make QEMU perform managed save of all VMs on stop of libvirtd

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

When the virStateStop() method is invoked, perform a managed
save of all VMs currently running

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/qemu/qemu_driver.c | 69 ++
 1 file changed, 69 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 229d5ae..3690c40 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -970,6 +970,74 @@ qemuActive(void) {
 return active;
 }
 
+
+/*
+ * qemuStop:
+ *
+ * Save any VMs in preparation for shutdown
+ *
+ */
+static int
+qemuStop(void) {
+int ret = -1;
+const char *uri;
+virConnectPtr conn;
+int numDomains;
+size_t i;
+int state;
+virDomainPtr *domains = NULL;
+unsigned int *flags = NULL;
+
+qemuDriverLock(qemu_driver);
+uri = qemu_driver-privileged ?
+qemu:///system :
+qemu:///session;
+qemuDriverUnlock(qemu_driver);
+
+if (!(conn = virConnectOpen(uri)))
+return -1;
+
+if ((numDomains = virConnectListAllDomains(conn,
+   domains,
+   
VIR_CONNECT_LIST_DOMAINS_ACTIVE))  0)
+goto cleanup;
+
+if (VIR_ALLOC_N(flags, numDomains)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+/* First we pause all VMs to make them stop dirtying
+   pages, etc. We remember if any VMs were paused so
+   we can restore that on resume. */
+for (i = 0 ; i  numDomains ; i++) {
+flags[i] = VIR_DOMAIN_SAVE_RUNNING;
+if (virDomainGetState(domains[i], state, NULL, 0) == 0) {
+if (state == VIR_DOMAIN_PAUSED) {
+flags[i] = VIR_DOMAIN_SAVE_PAUSED;
+}
+}
+virDomainSuspend(domains[i]);
+}
+
+/* Then we save the VMs to disk */
+for (i = 0 ; i  numDomains ; i++)
+if (virDomainManagedSave(domains[i], flags[i])  0)
+ret = -1;
+
+VIR_FREE(domains);
+VIR_FREE(flags);
+
+ret = 0;
+ cleanup:
+for (i = 0 ; i  numDomains ; i++)
+virDomainFree(domains[i]);
+VIR_FREE(domains);
+VIR_FREE(flags);
+
+return ret;
+}
+
 /**
  * qemuShutdown:
  *
@@ -14613,6 +14681,7 @@ static virStateDriver qemuStateDriver = {
 .cleanup = qemuShutdown,
 .reload = qemuReload,
 .active = qemuActive,
+.stop = qemuStop,
 };
 
 int qemuRegister(void) {
-- 
1.7.12.1

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


[libvirt] [00/11] Automatically shutdown VMs on session quit

2012-10-31 Thread Daniel P. Berrange
This is a followup to Alex's original proposal:

  https://www.redhat.com/archives/libvir-list/2012-October/msg00365.html

The core idea  concepts are the same as in Alex's patch, but I
realized I could take the opportunity to refactor part of libvirtd
to improve life in general.

The state drivers currently have an 'active' method which is polled
on every iteration of the event loop to determine if any resources
(such as VMs) are active. This is the kind of information we need
to inhibit host shutdown/suspend, but it is not being made available
in an easily consumable way. The key idea I had was to remove the
'active' method from the state drivers and instead pass in a callback
to the 'startup' method in the state driver. This so called 'inhibit'
callback is used by drivers to signal when they have resources
active. This callback is used both to inhibit shutdown of libvirtd
(when the --timeout arg is used), and to inhibit shutdown of the
host OS itself.

The state driver also gains a 'stop' method which is intended to
stop any resources which are causing the shutdown inhibition. In
other words, to save any VMs to disk.

One of the side effects of this change is that the --timeout param
to libvirtd actually now works much better. Only running VMs cause
libvirtd shutdown to be inhibited. Networks / storage pools no
longer inhibit it.

This is obviously targetted at post-1.0.0

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


[libvirt] [PATCH 04/11] Alphabetically sort libvirt_daemon.syms

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Sort the symbols listed in libvirt_daemon.syms

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/libvirt_daemon.syms | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libvirt_daemon.syms b/src/libvirt_daemon.syms
index eb6e594..7c914fa 100644
--- a/src/libvirt_daemon.syms
+++ b/src/libvirt_daemon.syms
@@ -3,8 +3,8 @@
 #
 
 # libvirt_internal.h
-virStateInitialize;
+virRegisterStateDriver;
+virStateActive;
 virStateCleanup;
+virStateInitialize;
 virStateReload;
-virStateActive;
-virRegisterStateDriver;
-- 
1.7.12.1

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


[libvirt] [PATCH 11/11] Fix arch detection for qemu-system-i386 with QMP

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

QEMU uses 'i386' for its 32-bit x86 architecture, but libvirt
wants that to be 'i686', so we must fix it up

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/qemu/qemu_capabilities.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9f15162..271273c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2327,6 +2327,14 @@ qemuCapsInitQMP(qemuCapsPtr caps,
 if (!(caps-arch = qemuMonitorGetTargetArch(mon)))
 goto cleanup;
 
+/* Map i386, i486, i586 to i686.  */
+if (caps-arch[0] == 'i' 
+caps-arch[1] != '\0' 
+caps-arch[2] == '8' 
+caps-arch[3] == '6' 
+caps-arch[4] == '\0')
+caps-arch[1] = '6';
+
 /* Currently only x86_64 and i686 support PCI-multibus. */
 if (STREQLEN(caps-arch, x86_64, 6) ||
 STREQLEN(caps-arch, i686, 4)) {
-- 
1.7.12.1

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


[libvirt] [PATCH 01/11] s/qemud/qemu/ in QEMU driver sources

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Change some legacy function names to use 'qemu' as their
prefix instead of 'qemud' which was a hang over from when
the QEMU driver ran inside a separate daemon

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/qemu/qemu_conf.c |   4 +-
 src/qemu/qemu_conf.h |   4 +-
 src/qemu/qemu_driver.c   | 539 ++-
 src/qemu/qemu_monitor_text.c |   6 +-
 src/qemu/qemu_process.c  |   2 +-
 5 files changed, 279 insertions(+), 276 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8f3922f..4c71e03 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -72,8 +72,8 @@ void qemuDriverUnlock(struct qemud_driver *driver)
 }
 
 
-int qemudLoadDriverConfig(struct qemud_driver *driver,
-  const char *filename) {
+int qemuLoadDriverConfig(struct qemud_driver *driver,
+ const char *filename) {
 virConfPtr conf;
 virConfValuePtr p;
 char *user;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 2c7f70c..4c729e4 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -176,8 +176,8 @@ struct _qemuDomainCmdlineDef {
 
 void qemuDriverLock(struct qemud_driver *driver);
 void qemuDriverUnlock(struct qemud_driver *driver);
-int qemudLoadDriverConfig(struct qemud_driver *driver,
-  const char *filename);
+int qemuLoadDriverConfig(struct qemud_driver *driver,
+ const char *filename);
 
 struct qemuDomainDiskInfo {
 bool removable;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 267bbf1..229d5ae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -136,14 +136,14 @@
 
 static void processWatchdogEvent(void *data, void *opaque);
 
-static int qemudShutdown(void);
+static int qemuShutdown(void);
 
 static int qemuDomainObjStart(virConnectPtr conn,
   struct qemud_driver *driver,
   virDomainObjPtr vm,
   unsigned int flags);
 
-static int qemudDomainGetMaxVcpus(virDomainPtr dom);
+static int qemuDomainGetMaxVcpus(virDomainPtr dom);
 
 static void qemuDomainManagedSaveLoad(void *payload,
   const void *n ATTRIBUTE_UNUSED,
@@ -588,12 +588,12 @@ static void qemuDomainNetsRestart(void *payload,
 }
 
 /**
- * qemudStartup:
+ * qemuStartup:
  *
  * Initialization function for the QEmu daemon
  */
 static int
-qemudStartup(int privileged) {
+qemuStartup(int privileged) {
 char *base = NULL;
 char *driverConf = NULL;
 int rc;
@@ -746,7 +746,7 @@ qemudStartup(int privileged) {
  virStrerror(-rc, ebuf, sizeof(ebuf)));
 }
 
-if (qemudLoadDriverConfig(qemu_driver, driverConf)  0) {
+if (qemuLoadDriverConfig(qemu_driver, driverConf)  0) {
 goto error;
 }
 VIR_FREE(driverConf);
@@ -907,11 +907,11 @@ error:
 VIR_FREE(driverConf);
 VIR_FREE(membase);
 VIR_FREE(mempath);
-qemudShutdown();
+qemuShutdown();
 return -1;
 }
 
-static void qemudNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
+static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
 {
 struct qemud_driver *driver = opaque;
 
@@ -926,13 +926,13 @@ static void qemudNotifyLoadDomain(virDomainObjPtr vm, int 
newVM, void *opaque)
 }
 
 /**
- * qemudReload:
+ * qemuReload:
  *
  * Function to restart the QEmu daemon, it will recheck the configuration
  * files and update its state and the networking
  */
 static int
-qemudReload(void) {
+qemuReload(void) {
 if (!qemu_driver)
 return 0;
 
@@ -942,14 +942,14 @@ qemudReload(void) {
 qemu_driver-configDir,
 qemu_driver-autostartDir,
 0, QEMU_EXPECTED_VIRT_TYPES,
-qemudNotifyLoadDomain, qemu_driver);
+qemuNotifyLoadDomain, qemu_driver);
 qemuDriverUnlock(qemu_driver);
 
 return 0;
 }
 
 /**
- * qemudActive:
+ * qemuActive:
  *
  * Checks if the QEmu daemon is active, i.e. has an active domain or
  * an active network
@@ -957,7 +957,7 @@ qemudReload(void) {
  * Returns 1 if active, 0 otherwise
  */
 static int
-qemudActive(void) {
+qemuActive(void) {
 int active = 0;
 
 if (!qemu_driver)
@@ -971,12 +971,12 @@ qemudActive(void) {
 }
 
 /**
- * qemudShutdown:
+ * qemuShutdown:
  *
  * Shutdown the QEmu daemon, it will stop all active domains and networks
  */
 static int
-qemudShutdown(void) {
+qemuShutdown(void) {
 int i;
 
 if (!qemu_driver)
@@ -1045,9 +1045,9 @@ qemudShutdown(void) {
 }
 
 
-static virDrvOpenStatus qemudOpen(virConnectPtr conn,
-  virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-  unsigned int flags)
+static virDrvOpenStatus qemuOpen(virConnectPtr conn,
+   

[libvirt] [PATCH 03/11] Change bridge driver to use named initializers with virDriverState

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/network/bridge_driver.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3dbf009..cad19be 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3295,11 +3295,11 @@ static virNetworkDriver networkDriver = {
 };
 
 static virStateDriver networkStateDriver = {
-Network,
-networkStartup,
-networkShutdown,
-networkReload,
-networkActive,
+.name = Network,
+.initialize  = networkStartup,
+.cleanup = networkShutdown,
+.reload = networkReload,
+.active = networkActive,
 };
 
 int networkRegister(void) {
-- 
1.7.12.1

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


[libvirt] [PATCH 08/11] Replace polling for active VMs with signalling by drivers

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Currently to deal with auto-shutdown libvirtd must periodically
poll all stateful drivers. Thus sucks because it requires
acquiring both the driver lock and locks on every single virtual
machine. Instead pass in a inhibit callback to virStateInitialize
which drivers can invoke whenever they want to inhibit shutdown
due to existance of active VMs.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 daemon/libvirtd.c  | 30 --
 src/Makefile.am|  2 ++
 src/driver.h   |  7 ---
 src/libvirt.c  | 29 +
 src/libvirt_internal.h |  8 ++--
 src/libvirt_private.syms   |  2 ++
 src/libxl/libxl_conf.h |  5 +
 src/libxl/libxl_driver.c   | 26 --
 src/lxc/lxc_conf.h |  5 +
 src/lxc/lxc_driver.c   | 29 ++---
 src/lxc/lxc_process.c  | 12 
 src/network/bridge_driver.c| 33 -
 src/node_device/node_device_hal.c  | 14 +++---
 src/node_device/node_device_udev.c | 12 +++-
 src/nwfilter/nwfilter_driver.c | 26 +++---
 src/qemu/qemu_conf.h   |  4 
 src/qemu/qemu_driver.c | 30 ++
 src/qemu/qemu_process.c| 16 
 src/remote/remote_driver.c |  4 +++-
 src/rpc/virnetserver.c | 29 +
 src/rpc/virnetserver.h |  7 ---
 src/secret/secret_driver.c |  5 +++--
 src/storage/storage_driver.c   | 32 +++-
 src/uml/uml_conf.h |  3 +++
 src/uml/uml_driver.c   | 37 ++---
 src/xen/xen_driver.c   |  4 +++-
 26 files changed, 176 insertions(+), 235 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 624831a..b1b3ef7 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -584,16 +584,6 @@ error:
 }
 
 
-static int daemonShutdownCheck(virNetServerPtr srv ATTRIBUTE_UNUSED,
-   void *opaque ATTRIBUTE_UNUSED)
-{
-if (virStateActive())
-return 0;
-
-return 1;
-}
-
-
 /*
  * Set up the logging environment
  * By default if daemonized all errors go to the logfile libvirtd.log,
@@ -772,6 +762,18 @@ static int daemonSetupSignals(virNetServerPtr srv)
 return 0;
 }
 
+
+static void daemonInhibitCallback(bool inhibit, void *opaque)
+{
+virNetServerPtr srv = opaque;
+
+if (inhibit)
+virNetServerAddShutdownInhibition(srv);
+else
+virNetServerRemoveShutdownInhibition(srv);
+}
+
+
 static void daemonRunStateInit(void *opaque)
 {
 virNetServerPtr srv = opaque;
@@ -780,7 +782,9 @@ static void daemonRunStateInit(void *opaque)
  * This is deliberately done after telling the parent process
  * we're ready, since it can take a long time and this will
  * seriously delay OS bootup process */
-if (virStateInitialize(virNetServerIsPrivileged(srv))  0) {
+if (virStateInitialize(virNetServerIsPrivileged(srv),
+   daemonInhibitCallback,
+   srv)  0) {
 VIR_ERROR(_(Driver state initialization failed));
 /* Ensure the main event loop quits */
 kill(getpid(), SIGTERM);
@@ -1269,9 +1273,7 @@ int main(int argc, char **argv) {
 if (timeout != -1) {
 VIR_DEBUG(Registering shutdown timeout %d, timeout);
 virNetServerAutoShutdown(srv,
- timeout,
- daemonShutdownCheck,
- NULL);
+ timeout);
 }
 
 if ((daemonSetupSignals(srv))  0) {
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f32263..9ebd6e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1596,12 +1596,14 @@ libvirt_net_rpc_server_la_SOURCES = \
rpc/virnetserver.h rpc/virnetserver.c
 libvirt_net_rpc_server_la_CFLAGS = \
$(AVAHI_CFLAGS) \
+   $(DBUS_CFLAGS) \
$(XDR_CFLAGS) \
$(AM_CFLAGS) \
$(POLKIT_CFLAGS)
 libvirt_net_rpc_server_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(AVAHI_LIBS) \
+   $(DBUS_LIBS) \
$(POLKIT_LIBS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS)
diff --git a/src/driver.h b/src/driver.h
index 622ed87..632f80e 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1487,10 +1487,12 @@ struct _virStorageDriver {
 };
 
 # ifdef WITH_LIBVIRTD
-typedef int (*virDrvStateInitialize) (bool privileged);
+
+typedef int (*virDrvStateInitialize) (bool privileged,
+

[libvirt] [PATCH 09/11] Inhibit desktop shutdown while any virtual machines are running

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Use the freedesktop inhibition DBus service to prevent host
shutdown or session logout while any VMs are running.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/rpc/virnetserver.c | 110 +
 1 file changed, 110 insertions(+)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index b108399..aaf98a9 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -27,6 +27,10 @@
 #include string.h
 #include fcntl.h
 
+#ifdef HAVE_DBUS
+# include dbus/dbus.h
+#endif
+
 #include virnetserver.h
 #include logging.h
 #include memory.h
@@ -37,6 +41,7 @@
 #include virfile.h
 #include event.h
 #include virnetservermdns.h
+#include virdbus.h
 
 #ifndef SA_SIGINFO
 # define SA_SIGINFO 0
@@ -102,6 +107,8 @@ struct _virNetServer {
 
 unsigned int autoShutdownTimeout;
 size_t autoShutdownInhibitions;
+bool autoShutdownCallingInhibit;
+int autoShutdownInhibitFd;
 
 virNetServerClientPrivNew clientPrivNew;
 virNetServerClientPrivPreExecRestart clientPrivPreExecRestart;
@@ -391,6 +398,7 @@ virNetServerPtr virNetServerNew(size_t min_workers,
 srv-clientPrivFree = clientPrivFree;
 srv-clientPrivOpaque = clientPrivOpaque;
 srv-privileged = geteuid() == 0 ? true : false;
+srv-autoShutdownInhibitFd = -1;
 
 if (mdnsGroupName 
 !(srv-mdnsGroupName = strdup(mdnsGroupName))) {
@@ -716,10 +724,104 @@ void virNetServerAutoShutdown(virNetServerPtr srv,
 }
 
 
+#ifdef HAVE_DBUS
+static void virNetServerGotInhibitReply(DBusPendingCall *pending,
+void *opaque)
+{
+virNetServerPtr srv = opaque;
+DBusMessage *reply;
+int fd;
+
+virNetServerLock(srv);
+srv-autoShutdownCallingInhibit = false;
+
+VIR_DEBUG(srv=%p, srv);
+
+reply = dbus_pending_call_steal_reply(pending);
+if (reply == NULL)
+goto cleanup;
+
+if (dbus_message_get_args(reply, NULL,
+  DBUS_TYPE_UNIX_FD, fd,
+  DBUS_TYPE_INVALID)) {
+if (srv-autoShutdownInhibitions) {
+srv-autoShutdownInhibitFd = fd;
+} else {
+/* We stopped the last VM since we made the inhibit call */
+VIR_FORCE_CLOSE(fd);
+}
+}
+dbus_message_unref(reply);
+
+cleanup:
+virNetServerUnlock(srv);
+}
+
+
+/* As per: http://www.freedesktop.org/wiki/Software/systemd/inhibit */
+static void virNetServerCallInhibit(virNetServerPtr srv,
+const char *what,
+const char *who,
+const char *why,
+const char *mode)
+{
+DBusMessage *message;
+DBusPendingCall *pendingReply;
+DBusConnection *systemBus;
+
+VIR_DEBUG(srv=%p what=%s who=%s why=%s mode=%s,
+  srv, NULLSTR(what), NULLSTR(who), NULLSTR(why), NULLSTR(mode));
+
+if (!(systemBus = virDBusGetSystemBus()))
+return;
+
+/* Only one outstanding call at a time */
+if (srv-autoShutdownCallingInhibit)
+return;
+
+message = dbus_message_new_method_call(org.freedesktop.login1,
+   /org/freedesktop/login1,
+   org.freedesktop.login1.Manager,
+   Inhibit);
+if (message == NULL)
+return;
+
+dbus_message_append_args(message,
+ DBUS_TYPE_STRING, what,
+ DBUS_TYPE_STRING, who,
+ DBUS_TYPE_STRING, why,
+ DBUS_TYPE_STRING, mode,
+ DBUS_TYPE_INVALID);
+
+pendingReply = NULL;
+if (dbus_connection_send_with_reply(systemBus, message,
+pendingReply,
+25*1000)) {
+dbus_pending_call_set_notify(pendingReply,
+ virNetServerGotInhibitReply,
+ srv, NULL);
+srv-autoShutdownCallingInhibit = true;
+}
+dbus_message_unref(message);
+}
+#endif
+
 void virNetServerAddShutdownInhibition(virNetServerPtr srv)
 {
 virNetServerLock(srv);
 srv-autoShutdownInhibitions++;
+
+VIR_DEBUG(srv=%p inhibitions=%zu, srv, srv-autoShutdownInhibitions);
+
+#ifdef HAVE_DBUS
+if (srv-autoShutdownInhibitions == 1)
+virNetServerCallInhibit(srv,
+shutdown,
+_(Libvirt),
+_(Virtual machines need to be saved),
+delay);
+#endif
+
 virNetServerUnlock(srv);
 }
 
@@ -728,6 +830,12 @@ void virNetServerRemoveShutdownInhibition(virNetServerPtr 
srv)
 {
 virNetServerLock(srv);
 srv-autoShutdownInhibitions--;
+
+VIR_DEBUG(srv=%p inhibitions=%zu, 

[libvirt] [PATCH 07/11] Turn some dual-state int parameters into booleans

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The virStateInitialize method and several cgroups methods were
using an 'int privileged' parameter or similar for dual-state
values. These are better represented with the bool type.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/driver.h   |  2 +-
 src/libvirt.c  |  4 ++--
 src/libvirt_internal.h |  2 +-
 src/libxl/libxl_driver.c   |  2 +-
 src/lxc/lxc_driver.c   |  4 ++--
 src/network/bridge_driver.c|  2 +-
 src/node_device/node_device_hal.c  |  2 +-
 src/node_device/node_device_udev.c |  2 +-
 src/nwfilter/nwfilter_driver.c |  2 +-
 src/parallels/parallels_storage.c  |  2 +-
 src/qemu/qemu_conf.h   |  2 +-
 src/qemu/qemu_driver.c |  2 +-
 src/remote/remote_driver.c |  6 +++---
 src/secret/secret_driver.c |  2 +-
 src/storage/storage_driver.c   |  2 +-
 src/uml/uml_conf.h |  2 +-
 src/uml/uml_driver.c   |  2 +-
 src/util/cgroup.c  | 34 ++
 src/util/cgroup.h  | 10 +-
 src/xen/xen_driver.c   |  6 +++---
 20 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index 7d5a367..622ed87 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1487,7 +1487,7 @@ struct _virStorageDriver {
 };
 
 # ifdef WITH_LIBVIRTD
-typedef int (*virDrvStateInitialize) (int privileged);
+typedef int (*virDrvStateInitialize) (bool privileged);
 typedef int (*virDrvStateCleanup) (void);
 typedef int (*virDrvStateReload) (void);
 typedef int (*virDrvStateActive) (void);
diff --git a/src/libvirt.c b/src/libvirt.c
index f13bf69..0847f5f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -789,13 +789,13 @@ virRegisterStateDriver(virStateDriverPtr driver)
 
 /**
  * virStateInitialize:
- * @privileged: set to 1 if running with root privilege, 0 otherwise
+ * @privileged: set to true if running with root privilege, false otherwise
  *
  * Initialize all virtualization drivers.
  *
  * Returns 0 if all succeed, -1 upon any failure.
  */
-int virStateInitialize(int privileged) {
+int virStateInitialize(bool privileged) {
 int i;
 
 if (virInitialize()  0)
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index a39aaa4..b85a29d 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -28,7 +28,7 @@
 # include internal.h
 
 # ifdef WITH_LIBVIRTD
-int virStateInitialize(int privileged);
+int virStateInitialize(bool privileged);
 int virStateCleanup(void);
 int virStateReload(void);
 int virStateActive(void);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index f4e9aa6..6e59d9f 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -834,7 +834,7 @@ libxlShutdown(void)
 }
 
 static int
-libxlStartup(int privileged) {
+libxlStartup(bool privileged) {
 const libxl_version_info *ver_info;
 char *log_file = NULL;
 virCommandPtr cmd;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 2072f00..1b5e642 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -69,7 +69,7 @@
 
 #define LXC_NB_MEM_PARAM  3
 
-static int lxcStartup(int privileged);
+static int lxcStartup(bool privileged);
 static int lxcShutdown(void);
 virLXCDriverPtr lxc_driver = NULL;
 
@@ -1397,7 +1397,7 @@ error:
 }
 
 
-static int lxcStartup(int privileged)
+static int lxcStartup(bool privileged)
 {
 char *ld;
 int rc;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index cad19be..326665e 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -279,7 +279,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection 
ATTRIBUTE_UNUSED,
  * Initialization function for the QEmu daemon
  */
 static int
-networkStartup(int privileged) {
+networkStartup(bool privileged) {
 char *base = NULL;
 #ifdef HAVE_FIREWALLD
 DBusConnection *sysbus = NULL;
diff --git a/src/node_device/node_device_hal.c 
b/src/node_device/node_device_hal.c
index ff73db0..953e1d3 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -588,7 +588,7 @@ static void device_prop_modified(LibHalContext *ctx 
ATTRIBUTE_UNUSED,
 
 
 
-static int halDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
+static int halDeviceMonitorStartup(bool privileged ATTRIBUTE_UNUSED)
 {
 LibHalContext *hal_ctx = NULL;
 char **udi = NULL;
diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index 943e020..1f2efa9 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1604,7 +1604,7 @@ out:
 return ret;
 }
 
-static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
+static int udevDeviceMonitorStartup(bool privileged ATTRIBUTE_UNUSED)
 {
 udevPrivate *priv = NULL;
 struct udev *udev = NULL;
diff --git 

Re: [libvirt] dhcp6, radvd, ip6tables, etc. (update)

2012-10-31 Thread Gene Czarcinski

On 10/31/2012 11:53 AM, Laine Stump wrote:

That's just a safeguard to enforce the ipv4-only status of dhcp in the
current libvirt. Just remove that restriction from the function
virNetworkDefUpdateIP() as a part of your patch adding ipv6 dhcp support.


OK, removing the ipv4 test has net-update ipv6 working as well as ipv4 does.

Observation: this is definitely a work-in-progress.  I only tried 
ip-dhcp-range and ip-dhcp-host.  The ip-dhcp-range produced the expected 
in the the xml was updated and dnsmasq was restarted.  With 
ip-dhcp-host, it only did the right thing if the network was down. If it 
was started, nothing much happened.


A suggestion, before F18 goes with 0.10.2, I suggest that the virsh 
man-page be updated.  Currently, you would think that all of the stuff 
worked.  Clearly, it does not.  At best, users will be confused.  I 
suggest listing the functions that are planned but not currently 
implemented.


Speaking of documentation.  This should be updated for DHCPv6:
http://libvirt.org/http://libvirt.org/formatnetwork.html and there is 
docs/http://libvirt.org/formatnetwork.html.in in the git. However, it is 
not clear what the process is for changing/updating the documentation.  
Doing a grep on the log does not show a lot of commits being performed 
on it.


While a lot of using IPv6/DHCP6 is straight-forward, there are a couple 
of twists such as not specifying a MAC address for a v6 dhcp-host 
specification.


One other thing.  I am thinking about a separate patch which will 
replace radvd with dnsmasq doing the work.  I first need to look into 
dsnamsq a bit more to understand if and how it could do the job.  Given 
it could, a small change for dnsmasq would eliminate the need for radvd.


I know there is some touchiness about this so I am thinking of adding a 
special xml keyword which would switch between radvd and dnsmasq.


BTW, I am assuming this is all post v1.0.0.  I have currently completed 
the dhcp6 patch (net-update was the last  piece) but I need to let 
things work for a while to see if I missed anything.  If anyone wants to 
look at these patches, I can post them to this list or send them 
direct.  However, I want to wait until v1.0.0 gets released before 
submitting them for review, etc.


Gene

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


[libvirt] [PATCH 05/11] Introduce a 'stop' method to virDriverState

2012-10-31 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

To allow actions to be performed in libvirtd when the host
shuts down, or user session exits, introduce a 'stop'
method to virDriverState. This will do things like saving
the VM state to a file.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 src/driver.h|  2 ++
 src/libvirt.c   | 18 ++
 src/libvirt_daemon.syms |  1 +
 src/libvirt_internal.h  |  1 +
 4 files changed, 22 insertions(+)

diff --git a/src/driver.h b/src/driver.h
index 7ba66ad..7d5a367 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1491,6 +1491,7 @@ typedef int (*virDrvStateInitialize) (int privileged);
 typedef int (*virDrvStateCleanup) (void);
 typedef int (*virDrvStateReload) (void);
 typedef int (*virDrvStateActive) (void);
+typedef int (*virDrvStateStop) (void);
 
 typedef struct _virStateDriver virStateDriver;
 typedef virStateDriver *virStateDriverPtr;
@@ -1501,6 +1502,7 @@ struct _virStateDriver {
 virDrvStateCleanup cleanup;
 virDrvStateReload  reload;
 virDrvStateActive  active;
+virDrvStateStopstop;
 };
 # endif
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 2a01b80..f13bf69 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -869,6 +869,24 @@ int virStateActive(void) {
 return ret;
 }
 
+/**
+ * virStateStop:
+ *
+ * Run each virtualization driver's stop method.
+ *
+ * Returns 0 if successful, -1 on failure
+ */
+int virStateStop(void) {
+int i, ret = 0;
+
+for (i = 0 ; i  virStateDriverTabCount ; i++) {
+if (virStateDriverTab[i]-stop 
+virStateDriverTab[i]-stop())
+ret = 1;
+}
+return ret;
+}
+
 #endif
 
 
diff --git a/src/libvirt_daemon.syms b/src/libvirt_daemon.syms
index 7c914fa..dde77a6 100644
--- a/src/libvirt_daemon.syms
+++ b/src/libvirt_daemon.syms
@@ -8,3 +8,4 @@ virStateActive;
 virStateCleanup;
 virStateInitialize;
 virStateReload;
+virStateStop;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 71483e4..a39aaa4 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -32,6 +32,7 @@ int virStateInitialize(int privileged);
 int virStateCleanup(void);
 int virStateReload(void);
 int virStateActive(void);
+int virStateStop(void);
 # endif
 
 /* Feature detection.  This is a libvirt-private interface for determining
-- 
1.7.12.1

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


[libvirt] [PATCH 10/11] Shut down session libvirtd cleanly on host shutdown/user logout

2012-10-31 Thread Daniel P. Berrange
From: Alexander Larsson al...@redhat.com

When the session dies or when the system is going to be shut down
we issue a virStateStop() call to instruct drivers to prepare to
be stopped. This will remove any previously acquire inhibitions.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 daemon/libvirtd.c | 84 +++
 1 file changed, 84 insertions(+)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b1b3ef7..40c411c 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -98,6 +98,11 @@
 
 #include configmake.h
 
+#ifdef HAVE_DBUS
+# include dbus/dbus.h
+# include virdbus.h
+#endif
+
 #if HAVE_SASL
 virNetSASLContextPtr saslCtxt = NULL;
 #endif
@@ -774,6 +779,65 @@ static void daemonInhibitCallback(bool inhibit, void 
*opaque)
 }
 
 
+#ifdef HAVE_DBUS
+static DBusConnection *sessionBus;
+static DBusConnection *systemBus;
+
+static void daemonStopWorker(void *opaque)
+{
+virNetServerPtr srv = opaque;
+
+VIR_DEBUG(Begin stop srv=%p, srv);
+
+ignore_value(virStateStop());
+
+VIR_DEBUG(Completed stop srv=%p, srv);
+
+/* Exit libvirtd cleanly */
+virNetServerQuit(srv);
+}
+
+
+/* We do this in a thread to not block the main loop */
+static void daemonStop(virNetServerPtr srv)
+{
+virThread thr;
+virObjectRef(srv);
+if (virThreadCreate(thr, false, daemonStopWorker, srv)  0)
+virObjectUnref(srv);
+}
+
+
+static DBusHandlerResult handleSessionMessageFunc(DBusConnection *connection 
ATTRIBUTE_UNUSED,
+  DBusMessage *message,
+  void *opaque)
+{
+virNetServerPtr srv = opaque;
+
+VIR_DEBUG(srv=%p, srv);
+
+if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, Disconnected))
+daemonStop(srv);
+
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusHandlerResult handleSystemMessageFunc(DBusConnection *connection 
ATTRIBUTE_UNUSED,
+ DBusMessage *message,
+ void *opaque)
+{
+virNetServerPtr srv = opaque;
+
+VIR_DEBUG(srv=%p, srv);
+
+if (dbus_message_is_signal(message, org.freedesktop.login1.Manager, 
PrepareForShutdown))
+daemonStop(srv);
+
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+#endif
+
+
 static void daemonRunStateInit(void *opaque)
 {
 virNetServerPtr srv = opaque;
@@ -792,6 +856,26 @@ static void daemonRunStateInit(void *opaque)
 return;
 }
 
+#ifdef HAVE_DBUS
+/* Tie the non-priviledged libvirtd to the session/shutdown lifecycle */
+if (!virNetServerIsPrivileged(srv)) {
+
+sessionBus = virDBusGetSessionBus();
+if (sessionBus != NULL)
+dbus_connection_add_filter(sessionBus,
+   handleSessionMessageFunc, srv, NULL);
+
+systemBus = virDBusGetSystemBus();
+if (systemBus != NULL) {
+dbus_connection_add_filter(systemBus,
+   handleSystemMessageFunc, srv, NULL);
+dbus_bus_add_match(systemBus,
+   type='signal',sender='org.freedesktop.login1', 
interface='org.freedesktop.login1.Manager',
+   NULL);
+}
+}
+#endif
+
 /* Only now accept clients from network */
 virNetServerUpdateServices(srv, true);
 virObjectUnref(srv);
-- 
1.7.12.1

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


[libvirt] Is possible that cpu_maps.xml changed during different releases?

2012-10-31 Thread Jiang, Yunhong
Hi, all
I have two questions to the cpu_maps.xml in different releases, hope 
someone can give me some hints:

a) Will it be possible that the features defined in cpu_maps.xml for 
one specific CPU model (like Nehalem) will be different? For example, one 
feature is not listed for Nehalem in release x.y, and added in release x.y+1?

2) Is the format of the cpu_maps.xml fine defined or will be it changed 
during releases? I asked this because currently the features defined in the 
capabilities only list features not included in the definition in cpu_maps.xml 
for the corresponding model. So if I want to get the full features supported by 
the host, I have to parse the capabilities and the cpu_maps.xml. I didn't find 
the definition for cpu_maps.xml format, although the capabilities format is 
well defined in 
http://libvirt.org/guide/html/Application_Development_Guide-Connections-Capability_Info.html.

Thanks
--jyh

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


[libvirt] [Libvirt] Support for HyperV Server 2012?

2012-10-31 Thread Mark Ashton
Hi All,

According to libvirt.org The libvirt Microsoft Hyper-V driver can
manage Hyper-V 2008 R2..
I have verified this after enabling HyperV in libvirt, building libvirt
(+openwsman) and performing some management against a server running
Hyper-V 2008 R2.

What is the current level of support for Microsoft Hyper-V Server 2012?
Are there plans to support Microsoft Hyper-V Server 2012 in a future
release? If so, when is this likely to happen?

Thanks in advance!

Kind Regards,

Mark

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


Re: [libvirt] [PATCH] Fix arch detection for qemu-system-i386 with QMP

2012-10-31 Thread Eric Blake
On 10/31/2012 10:50 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 QEMU uses 'i386' for its 32-bit x86 architecture, but libvirt
 wants that to be 'i686', so we must fix it up
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/qemu/qemu_capabilities.c | 8 
  1 file changed, 8 insertions(+)

ACK.

 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index 9f15162..271273c 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -2327,6 +2327,14 @@ qemuCapsInitQMP(qemuCapsPtr caps,
  if (!(caps-arch = qemuMonitorGetTargetArch(mon)))
  goto cleanup;
  
 +/* Map i386, i486, i586 to i686.  */
 +if (caps-arch[0] == 'i' 
 +caps-arch[1] != '\0' 
 +caps-arch[2] == '8' 
 +caps-arch[3] == '6' 
 +caps-arch[4] == '\0')
 +caps-arch[1] = '6';
 +
  /* Currently only x86_64 and i686 support PCI-multibus. */
  if (STREQLEN(caps-arch, x86_64, 6) ||
  STREQLEN(caps-arch, i686, 4)) {
 

-- 
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] Don't assume pid_t is the same size as an int

2012-10-31 Thread Eric Blake
On 10/31/2012 11:02 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 virPidFileReadPathIfAlive passed in an 'int *' where a 'pid_t *'
 was expected, which breaks on Mingw64 targets. Also a few places
 were using '%d' for formatting pid_t, change them to '%lld' and
 force a cast to the longer type as done elsewhere in the same
 file.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/util/virpidfile.c |  4 ++--
  src/util/virprocess.c | 13 +++--
  2 files changed, 9 insertions(+), 8 deletions(-)

ACK.

-- 
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] build: Fix RPM build for non-x86 platforms

2012-10-31 Thread Viktor Mihajlovski
Make the post install script for the lock-sanlock package optional
to prevent break on non-x86 platforms.

Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
---
 libvirt.spec.in |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 41d2628..f8ede3f 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1568,12 +1568,13 @@ fi
 /bin/systemctl try-restart libvirt-guests.service /dev/null 21 || :
 %endif
 
+%if %{with_sanlock}
 %post lock-sanlock
 if getent group sanlock  /dev/null ; then
 chmod 0770 %{_localstatedir}/lib/libvirt/sanlock
 chown root:sanlock %{_localstatedir}/lib/libvirt/sanlock
 fi
-
+%endif
 
 %files
 %defattr(-, root, root)
-- 
1.7.0.4

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


[libvirt] [libvirt-glib] gobject: Add GVirDomainRebootFlags

2012-10-31 Thread Zeeshan Ali (Khattak)
From: Zeeshan Ali (Khattak) zeesha...@gnome.org

Add flags to be used with gvir_domain_reboot().
---
 libvirt-gobject/libvirt-gobject-domain.c |  2 +-
 libvirt-gobject/libvirt-gobject-domain.h | 13 +
 libvirt-gobject/libvirt-gobject.sym  |  5 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index 8ade3ea..c1ba5ce 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -688,7 +688,7 @@ gboolean gvir_domain_shutdown(GVirDomain *dom,
 /**
  * gvir_domain_reboot:
  * @dom: the domain
- * @flags:  the flags
+ * @flags: the %GVirDomainRebootFlags flags
  */
 gboolean gvir_domain_reboot(GVirDomain *dom,
 guint flags,
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index 6e7b10d..bd0cfc0 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -158,6 +158,19 @@ typedef enum {
 GVIR_DOMAIN_SNAPSHOT_ATOMIC   = VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC,
 } GVirDomainSnapshotCreateFlags;
 
+/**
+ * GVirDomainRebootFlags:
+ * @GVIR_DOMAIN_REBOOT_NONE: No flags, hypervisor choice
+ * @GVIR_DOMAIN_REBOOT_ACPI_POWER_BTN: Send ACPI event
+ * @GVIR_DOMAIN_REBOOT_GUEST_AGENT: Use guest agent
+ *
+ */
+typedef enum {
+GVIR_DOMAIN_REBOOT_NONE   = 0,
+GVIR_DOMAIN_REBOOT_ACPI_POWER_BTN = VIR_DOMAIN_REBOOT_ACPI_POWER_BTN,
+GVIR_DOMAIN_REBOOT_GUEST_AGENT= VIR_DOMAIN_REBOOT_GUEST_AGENT,
+} GVirDomainRebootFlags;
+
 typedef struct _GVirDomainInfo GVirDomainInfo;
 struct _GVirDomainInfo
 {
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index 3a40a8a..444a891 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -204,4 +204,9 @@ LIBVIRT_GOBJECT_0.1.3 {
 gvir_domain_wakeup_finish;
 } LIBVIRT_GOBJECT_0.1.2;
 
+LIBVIRT_GOBJECT_0.1.4 {
+  global:
+   gvir_domain_reboot_flags_get_type;
+} LIBVIRT_GOBJECT_0.1.3;
+
 #  define new API here using predicted next version number 
-- 
1.7.12.1

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


Re: [libvirt] [PATCH 01/20] snapshot: new XML for external system checkpoint

2012-10-31 Thread Eric Blake
On 10/25/2012 08:56 PM, Osier Yang wrote:
 On 2012年10月26日 06:42, Eric Blake wrote:
 On 10/23/2012 09:41 PM, Osier Yang wrote:
 On 2012年10月23日 23:12, Peter Krempa wrote:
 From: Eric Blakeebl...@redhat.com

 Eachdomainsnapshot   can now contain an optionalmemory
 element that describes how the VM state was handled, similar
 to disk snapshots.  The new element will always appear in
 output; for back-compat, an input that lacks the element will
 assume 'no' or 'internal' according to the domain state.



 So for 0.10.2, I plan to implement this table of combinations,

 1.0.0, now (I'm assuming that this part of the series is worth pushing
 for 1.0.0, even though Peter's series missed the rc1 freeze date)...

 Does anyone else have arguments on whether the rest of this series
 should be in or out of the next release?
 
 I think it's safe to push.

We missed rc3; and I'm still reviewing the series.  This series has to
be 1.0.1 material 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 06/20] snapshot: Add flag to enable creating checkpoints in paused state

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 The default behavior while creating external checkpoints is to let the
 guest run while the memory state is caputred. This leads to a larger
 save file but minimizes the time needed to take the checkpoint.
 
 This patch adds a flag that causes the guest to be paused before taking
 the snapshot.

For this patch, I'm going to review the updated version at
 git fetch git://pipo.sk/pipo/libvirt.git snap-revert

 
 commit 8cf5a508f0ef37308ce7601b1632a2fb0853233f
 Author: Peter Krempa pkre...@redhat.com
 Date:   Tue Oct 9 12:11:56 2012 +0200
 
 snapshot: Add flag to enable creating checkpoints in live state
 
 The default behavior while creating external checkpoints is to pause the
 guest while the memory state is captured. We want the users to sacrifice
 space saving for creating the memory save image while the guest is live
 to minimize downtime.
 
 This patch adds a flag that causes the guest not to be paused before
 taking the snapshot.
  *include/libvirt/libvirt.h.in:
 - add new paused reason: VIR_DOMAIN_PAUSED_SNAPSHOT
 - add new flag for takin snapshot: VIR_DOMAIN_SNAPSHOT_CREATE_LIVE

s/takin/taking/

  *tools/virsh-domain-monitor.c:
 - add string representation for VIR_DOMAIN_PAUSED_SNAPSHOT
  *tools/virsh-snapshot.c:
 - add support for VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
  *tools/virsh.pod:
 - add docs for --live option added to use
 VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag

This misses examples/domain-events/events-c/event-test.c, which also
needs updates.

 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 2b17cef..d520144 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -179,6 +179,7 @@ typedef enum {
  VIR_DOMAIN_PAUSED_WATCHDOG = 6, /* paused due to a watchdog event */
  VIR_DOMAIN_PAUSED_FROM_SNAPSHOT = 7, /* paused after restoring from 
 snapshot */
  VIR_DOMAIN_PAUSED_SHUTTING_DOWN = 8, /* paused during shutdown process */
 +VIR_DOMAIN_PAUSED_SNAPSHOT = 9,  /* paused while creating a snaphot 
 */

s/snaphot/snapshot/

At first, I wondered why you weren't reusing _FROM_SNAPSHOT, but after
looking through the series, now I know - you need distinct states to
know across libvirtd restarts whether the pause was temporary (due to
taking the snapshot) or end result (the snapshot itself requested paused
state when being restored).  Makes sense.

 +++ b/tools/virsh-snapshot.c
 @@ -127,6 +127,7 @@ static const vshCmdOptDef opts_snapshot_create[] = {
  {reuse-external, VSH_OT_BOOL, 0, N_(reuse any existing external 
 files)},
  {quiesce, VSH_OT_BOOL, 0, N_(quiesce guest's file systems)},
  {atomic, VSH_OT_BOOL, 0, N_(require atomic operation)},
 +{pause, VSH_OT_BOOL, 0, N_(pause guest before taking snapshot)},

Stale - this line should be talking about live.

 +++ b/tools/virsh.pod
 @@ -2594,7 +2594,7 @@ used to represent properties of snapshots.
 
  =item Bsnapshot-create Idomain [Ixmlfile] {[I--redefine 
 [I--current]]
  | [I--no-metadata] [I--halt] [I--disk-only] [I--reuse-external]
 -[I--quiesce] [I--atomic]}
 +[I--quiesce] [I--atomic] [I--live]}
 
  Create a snapshot for domain Idomain with the properties specified in
  Ixmlfile.  Normally, the only properties settable for a domain snapshot
 @@ -2647,6 +2647,10 @@ this.  If this flag is not specified, then some 
 hypervisors may fail
  after partially performing the action, and Bdumpxml must be used to
  see whether any partial changes occurred.
 
 +If I--live is specified, libvirt takes the snapshot while the guest is
 +running. This increases the size of the memory image of the external
 +checkpoint.

Should we also mention that it is not supported with internal
checkpoint, and/or mention that it is silently ignored for offline
snapshots?

Patch looks okay once those issues are fixed, but since I reviewed an
unposted later version of your patch straight from your git tree, it
will help to see a v2 series with the fixes incorporated rather than
giving ACK 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 07/20] snapshot: qemu: Add async job type for snapshots

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 The new external system checkpoints will require an async job while the
 snapshot is taken. This patch adds QEMU_ASYNC_JOB_SNAPSHOT to track this
 job type.
 ---
  src/qemu/qemu_domain.c  |  3 +++
  src/qemu/qemu_domain.h  |  1 +
  src/qemu/qemu_process.c | 19 +++
  3 files changed, 23 insertions(+)
 
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
 index 4e6a5e9..3642bc1 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
 @@ -65,6 +65,7 @@ VIR_ENUM_IMPL(qemuDomainAsyncJob, QEMU_ASYNC_JOB_LAST,
migration in,
save,
dump,
 +  snapshot,
  );
 
 
 @@ -81,6 +82,7 @@ qemuDomainAsyncJobPhaseToString(enum qemuDomainAsyncJob job,
  case QEMU_ASYNC_JOB_DUMP:
  case QEMU_ASYNC_JOB_NONE:
  case QEMU_ASYNC_JOB_LAST:
 +case QEMU_ASYNC_JOB_SNAPSHOT:
  ; /* fall through */

I'd rather see the case labels with _NONE and _LAST at the bottom; float
this up to be next to _DUMP.

  }
 
 @@ -103,6 +105,7 @@ qemuDomainAsyncJobPhaseFromString(enum qemuDomainAsyncJob 
 job,
  case QEMU_ASYNC_JOB_DUMP:
  case QEMU_ASYNC_JOB_NONE:
  case QEMU_ASYNC_JOB_LAST:
 +case QEMU_ASYNC_JOB_SNAPSHOT:

Ditto.

Otherwise, looks reasonable.  I'll have to see later on if there are any
race cases.  Remember, if the _LIVE flag is not used, we pause up front;
but when the _LIVE flag IS used, qemu will pause itself when the
migration completes; and since this is all about state recovery when
libvirtd restarts, it is feasible that the migration completed instead
of being canceled, and that the reason we see the guest paused is
because qemu left it that way rather than us explicitly pausing it.

-- 
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 08/20] snapshot: qemu: Rename qemuDomainSnapshotCreateActive

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 By now, libvirt supported only internal snapshots for active guests.

s/By/Before/

 This patch renames this function to qemuDomainSnapshotCreateActiveInternal
 to prepare the grounds for external active snapshots.
 ---
  src/qemu/qemu_driver.c | 15 ---
  1 file changed, 8 insertions(+), 7 deletions(-)
 

ACK

-- 
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 06/20] snapshot: Add flag to enable creating checkpoints in paused state

2012-10-31 Thread Eric Blake
On 10/31/2012 04:12 PM, Eric Blake wrote:
 On 10/23/2012 09:12 AM, Peter Krempa wrote:
 The default behavior while creating external checkpoints is to let the
 guest run while the memory state is caputred. This leads to a larger
 save file but minimizes the time needed to take the checkpoint.

 This patch adds a flag that causes the guest to be paused before taking
 the snapshot.
 
 For this patch, I'm going to review the updated version at
  git fetch git://pipo.sk/pipo/libvirt.git snap-revert
 
 This patch adds a flag that causes the guest not to be paused before
 taking the snapshot.
  *include/libvirt/libvirt.h.in:
 - add new paused reason: VIR_DOMAIN_PAUSED_SNAPSHOT
 - add new flag for takin snapshot: VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
 
 s/takin/taking/
 
  *tools/virsh-domain-monitor.c:
 - add string representation for VIR_DOMAIN_PAUSED_SNAPSHOT
  *tools/virsh-snapshot.c:
 - add support for VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
  *tools/virsh.pod:
 - add docs for --live option added to use
 VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag
 
 This misses examples/domain-events/events-c/event-test.c, which also
 needs updates.

Also, this missed a mention of the new flag in src/libvirt.c.

 Should we also mention that it is not supported with internal
 checkpoint, and/or mention that it is silently ignored for offline
 snapshots?

The fact that _LIVE and internal snapshots don't mix is a qemu
limitation, but not a limitation inherent in the API as available in
src/libvirt.c, so it will be interesting to see how you word things.

-- 
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 09/20] snapshot: qemu: Add support for external checkpoints

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 This patch adds support to take external system checkpoints.
 
 The functionality is layered on top of the previous disk-only snapshot
 code. When the checkpoint is requested the domain memory is saved to the
 memory image file using live migration to file. (The user may specify to
 do take the memory image while the guest is paused with the
 VIR_DOMAIN_SNAPSHOT_CREATE_PAUSE flag.)

Outdated comment, but looks like you've touched that up on your git tree.

 This operation pauses the guest.
 After the guest is paused the disk snapshot is taken.

The guest will pause either because _LIVE was not present (we paused up
front), or because qemu will pause the domain when live migration
converges.  Then, while the guest is paused, we take the disk snapshot,
then resume the guest, and voila! external snapshot!

 
 The memory save image shares format with the image created by
 virDomainSave() API.

Hmm, wonder if we should document somewhere that:

virDomainSave(dom, /path/to/file)

is now shorthand for:

virDomainSnapshotCreate(dom, 
domainsnapshot
  memory file='/path/to/file'/
  disks
disk name='vda' snapshot='no'/ !-- etc. for each disk --
  /disks
/domainsnapshot
, VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)

It also makes me wonder if virDomainSaveFlags should learn a _LIVE flag.

Consider what happens when you save domain memory but not disks, and
then let the domain continue running - since you didn't snapshot disks,
then any modification made to the disks will invalidate the saved
memory.  That said, it is possible to create a domain that only uses
read-only disks and stores everything in tmpfs.  In fact, one of my
favorite test cases while working on block-commit was a domain based on
a live iso image - precisely because I can then attach any number
(including 0) of other disks which won't be touched by the live OS, at
which point you really can make a case for a live ram-only snapshot.

 +static int
 +qemuDomainSnapshotCreateActiveExternal(virConnectPtr conn,
 +   struct qemud_driver *driver,
 +   virDomainObjPtr *vmptr,
 +   virDomainSnapshotObjPtr snap,
 +   unsigned int flags)
 +{
 +bool resume = false;
 +int ret = -1;
 +virDomainObjPtr vm = *vmptr;
 +qemuDomainObjPrivatePtr priv = vm-privateData;
 +char *xml = NULL;
 +bool memory = snap-def-memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
 +bool atomic = !!(flags  VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC);
 +bool transaction = qemuCapsGet(priv-caps, QEMU_CAPS_TRANSACTION);
 +
 +if (qemuDomainObjBeginAsyncJobWithDriver(driver, vm,
 + QEMU_ASYNC_JOB_SNAPSHOT)  0)
  goto cleanup;


Hmm, here we are starting an async job that can be canceled any time we
drop locks.  But the biggest part of this job is waiting for the
migration to file to complete; once that part is done, we will drop
locks several more times while issuing a 'transaction' or a series of
disk snapshot monitor commands, and I don't think the cancellation code
is prepared to handle that case.  I wonder if we need to separate this
into two jobs - one async to do the migration to file, and one sync to
do the disk snapshots, so that we only allow cancellation during the
first half (the second half is fast enough that we aren't starving
access to the domain in the process).


 +/* we need to resume the guest only if it was previously running */
 +if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
 +resume = true;

I haven't checked closely - does this new async job allow the user to
pause and continue the guest at will?  I know with live migration we
allow the client to pause the guest if they are tired of waiting on
things to converge (in fact, virsh even has a migrate option that
auto-pauses the guest if things take too long).  Hmm, while I know we
can pause a live migration, what I don't know is if we allow resuming a
guest while migration is ongoing.

I'm worried that we are missing the interaction that allows a user to
pause a live snapshot if things aren't converging fast enough.  I would
be okay if our design is that, for the initial implementation, we reject
pause and resume attempts during a migration, and add that ability
later, but it is something we need to keep in mind.  And it does make
the question of whether to resume a bit trickier - it is no longer a
matter of whether the guest was running before we started the snapshot,
but also whether the guest has been paused later on during a live
snapshot.  Similar to live migration, I'm assuming that it is always
safe to pause, but that once things are paused, we probably want to
reject resuming until the snapshot operation completes.

 +
 +/* For multiple disks, libvirt must pause externally to get all
 + * snapshots to be at the 

[libvirt] [PATCH v3 2/2] init qemu_driver's qemuImgBinary field

2012-10-31 Thread liguang
Signed-off-by: liguang lig.f...@cn.fujitsu.com
---
 src/qemu/qemu_domain.c |2 +-
 src/qemu/qemu_driver.c |3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 17ae3b9..ac16772 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1654,7 +1654,7 @@ qemuDomainSnapshotForEachQcow2Raw(struct qemud_driver 
*driver,
 int i;
 bool skipped = false;
 
-qemuimgarg[0] = qemuFindQemuImgBinary(driver);
+qemuimgarg[0] = driver-qemuImgBinary;
 if (qemuimgarg[0] == NULL) {
 /* qemuFindQemuImgBinary set the error */
 return -1;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 97ad23e..882e95a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -624,6 +624,9 @@ qemudStartup(int privileged) {
 if (!qemu_driver-domainEventState)
 goto error;
 
+/*find kvm-img or qemu-img*/
+qemuFindQemuImgBinary(qemu_driver);
+
 /* read the host sysinfo */
 if (privileged)
 qemu_driver-hostsysinfo = virSysinfoRead();
-- 
1.7.1

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


[libvirt] [PATCH v3 1/2] helper of copy-storage-* features

2012-10-31 Thread liguang
help to create disk images copy-storage-* required,
try to do non-shared migration without bothering to
create disk images at target by hand.

consider this situation:
1. non-shared migration
   virsh migrate --copy-storage-all ...
2. migration fails
3. create disk images required
   qemu-img create ...
4  migration run smoothly
so, try do remove step 2, 3, 4

this kind of usage had been discussed before,
http://www.redhat.com/archives/libvir-list/2011-December/msg00451.html

maybe there're some flaws:
- It did not handle more about complete situations
  suggested by Daniel P. Berrange,
  https://www.redhat.com/archives/libvir-list/2012-October/msg00407.html
  but may try to take care of them later.
  so, now only normal disk image files be handled.
- for creation of disk images, size was setting as 0x boldly,
  hope it can consolidate qemu, haven't constructed a comfortable
  idea to solve it.

v2:
  1. handle disk encrytion case
  2. check kvm-img  qemu-img
  3. set disk image size to 0xfffK bytes blindly

v3:
1.use qemuImgBinary to create disk image
2.set max size for different disk image format respectively
  qcow and qcow2: 1PiB
  qed:64TiB
  raw:1TiB
  from qemu's setting,
  qcow and qcow2's max size is 2EiB,
  qed's max size is 64TiB
  raw's max size is 1TiB

Signed-off-by: liguang lig.f...@cn.fujitsu.com
---
 src/qemu/qemu_migration.c |  122 -
 1 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index db69a0a..80abb51 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -49,6 +49,7 @@
 #include storage_file.h
 #include viruri.h
 #include hooks.h
+#include dirname.h
 
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
@@ -70,6 +71,7 @@ enum qemuMigrationCookieFlags {
 QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
 QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
 QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
+QEMU_MIGRATION_COOKIE_FLAG_COPYSTORAGE,
 
 QEMU_MIGRATION_COOKIE_FLAG_LAST
 };
@@ -77,12 +79,13 @@ enum qemuMigrationCookieFlags {
 VIR_ENUM_DECL(qemuMigrationCookieFlag);
 VIR_ENUM_IMPL(qemuMigrationCookieFlag,
   QEMU_MIGRATION_COOKIE_FLAG_LAST,
-  graphics, lockstate, persistent);
+  graphics, lockstate, persistent, copystorage);
 
 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_COPYSTORAGE = (1  
QEMU_MIGRATION_COOKIE_FLAG_COPYSTORAGE),
 };
 
 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -439,6 +442,9 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
 virBufferAdjustIndent(buf, -2);
 }
 
+if (mig-flags  QEMU_MIGRATION_COOKIE_COPYSTORAGE)
+virBufferAsprintf(buf,   copystorage/\n);
+
 virBufferAddLit(buf, /qemu-migration\n);
 return 0;
 }
@@ -662,6 +668,11 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
 VIR_FREE(nodes);
 }
 
+if ((flags  QEMU_MIGRATION_COOKIE_COPYSTORAGE)) {
+if (virXPathBoolean(count(./copystorage)  0, ctxt))
+mig-flags |= QEMU_MIGRATION_COOKIE_COPYSTORAGE;
+}
+
 return 0;
 
 error:
@@ -721,6 +732,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
 qemuMigrationCookieAddPersistent(mig, dom)  0)
 return -1;
 
+if (flags  QEMU_MIGRATION_COOKIE_COPYSTORAGE)
+mig-flags |= QEMU_MIGRATION_COOKIE_COPYSTORAGE;
+
 if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
 return -1;
 
@@ -1168,6 +1182,14 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
 QEMU_MIGRATION_COOKIE_LOCKSTATE)  0)
 goto cleanup;
 
+if (flags  (VIR_MIGRATE_NON_SHARED_DISK |
+ VIR_MIGRATE_NON_SHARED_INC)) {
+if (qemuMigrationBakeCookie(mig, driver, vm,
+cookieout, cookieoutlen,
+QEMU_MIGRATION_COOKIE_COPYSTORAGE)  0)
+goto cleanup;
+}
+
 if (xmlin) {
 if (!(def = virDomainDefParseString(driver-caps, xmlin,
 QEMU_EXPECTED_VIRT_TYPES,
@@ -1215,6 +1237,89 @@ qemuMigrationPrepareCleanup(struct qemud_driver *driver,
 qemuDomainObjDiscardAsyncJob(driver, vm);
 }
 
+/*
+  if gen_del is 1, find out disk images migration required,
+  so try to generate them at target,
+  if gen_del is 0, delete disk images generated before.
+*/
+static int qemuMigrationHandleDiskFiles(struct qemud_driver *driver,
+virDomainDefPtr def, int gen_del)
+{
+char *tmp_dir = NULL, *outbuf = NULL;
+char *img_tool = driver-qemuImgBinary;
+virCommandPtr cmd = NULL;
+   

Re: [libvirt] dhcp6, radvd, ip6tables, etc. (update)

2012-10-31 Thread Laine Stump
On 10/30/2012 05:35 PM, Gene Czarcinski wrote:

 About being compatible with old code.  I see the dhcp6 patches and
 this potential patch as being based on v1.0.0 and not being
 back-ported.  So I am not sure I see a potential conflict.

Being able to backport patches to older libvirt releases is not the
issue we are concerned about - that is actually usually not an important
consideration. What *is* important is the ability to build and run the
new libvirt releases on older platforms. For example, if the upstream
release containing your patches were built on CentOS6.3 or RHEL6.3, the
dhcp6 functionality wouldn't be available, because those distros are
stuck at dnsmasq-2.48. That's okay as long as all the pre-existing
functionality still works properly on those distros. Eliminating radvd
in favor of using dnsmasq for ipv6 ra and autoconf would *not* be
acceptable, though, because if the release containing that patch were
built on RHEL6/CentOS6, it would mean a regression in behavior, since
IPv6 autoconf/ra would cease to work.

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


Re: [libvirt] dhcp6, radvd, ip6tables, etc. (update)

2012-10-31 Thread Laine Stump
On 10/31/2012 03:11 PM, Gene Czarcinski wrote:
 On 10/31/2012 11:53 AM, Laine Stump wrote:
 That's just a safeguard to enforce the ipv4-only status of dhcp in the
 current libvirt. Just remove that restriction from the function
 virNetworkDefUpdateIP() as a part of your patch adding ipv6 dhcp
 support.

 OK, removing the ipv4 test has net-update ipv6 working as well as ipv4
 does.

 Observation: this is definitely a work-in-progress.  I only tried
 ip-dhcp-range and ip-dhcp-host.  The ip-dhcp-range produced the
 expected in the the xml was updated and dnsmasq was restarted.  With
 ip-dhcp-host, it only did the right thing if the network was down. If
 it was started, nothing much happened.

Most likely because, according to what you recently wrote, the dhcp
hosts file isn't reread when a SIGHUP is sent to dnsmasq.


 A suggestion, before F18 goes with 0.10.2, I suggest that the virsh
 man-page be updated.  Currently, you would think that all of the stuff
 worked.  Clearly, it does not.  At best, users will be confused.  I
 suggest listing the functions that are planned but not currently
 implemented.

A valid point.

Note that it's not vanilla 0.10.2 that's currently in F18, it's the
0.20.2-maint branch, which is 0.10.2 plus some bugfixes deemed worthy of
backporting. Patches can be added to that branch at any time during the
lifetime of F18 (and even beyond if some other distro is using that
release for their builds), but they are only bugfixes (adding the
backend for missing sections could be seen as fixing a bug, if we
*really* wanted to :-).


 Speaking of documentation.  This should be updated for DHCPv6:
 http://libvirt.org/http://libvirt.org/formatnetwork.html and there is
 docs/http://libvirt.org/formatnetwork.html.in in the git. However, it
 is not clear what the process is for changing/updating the documentation.

Just edit formatnetwork.html.in and make that edit a part of the same
patch that makes the new functionality available. Your patch would be
NACKed without that anyway.

 Doing a grep on the log does not show a lot of commits being performed
 on it.

Any change to the network XML is not accepted for a push unless a change
to formatnetwork.html.in accompanies it. Any low patch volume on the
file is due to there being infrequent changes in the XML.


 While a lot of using IPv6/DHCP6 is straight-forward, there are a
 couple of twists such as not specifying a MAC address for a v6
 dhcp-host specification.



 I know there is some touchiness about this so I am thinking of adding
 a special xml keyword which would switch between radvd and dnsmasq.

I'm not sure whether that would be appropriate, or to instead have an
autoconf option that would enact the change at compile time.



 BTW, I am assuming this is all post v1.0.0.

We've been in freeze for the last week, and at this point only simple
fixes to very serious bugs are being pushed. New functionality is
definnitely post-1.0.0

   I have currently completed the dhcp6 patch (net-update was the last 
 piece) but I need to let things work for a while to see if I missed
 anything.  If anyone wants to look at these patches, I can post them
 to this list or send them direct.  However, I want to wait until
 v1.0.0 gets released before submitting them for review, etc.

You can submit things for review now, they just won't be pushed until
after the release is cut.

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


Re: [libvirt] [PATCH] build: Fix RPM build for non-x86 platforms

2012-10-31 Thread Eric Blake
On 10/31/2012 03:21 PM, Viktor Mihajlovski wrote:
 Make the post install script for the lock-sanlock package optional
 to prevent break on non-x86 platforms.
 
 Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
 ---
  libvirt.spec.in |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
 
 diff --git a/libvirt.spec.in b/libvirt.spec.in
 index 41d2628..f8ede3f 100644
 --- a/libvirt.spec.in
 +++ b/libvirt.spec.in
 @@ -1568,12 +1568,13 @@ fi
  /bin/systemctl try-restart libvirt-guests.service /dev/null 21 || :
  %endif
  
 +%if %{with_sanlock}
  %post lock-sanlock
  if getent group sanlock  /dev/null ; then
  chmod 0770 %{_localstatedir}/lib/libvirt/sanlock
  chown root:sanlock %{_localstatedir}/lib/libvirt/sanlock
  fi
 -
 +%endif

ACK and 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

Re: [libvirt] [PATCHv2 3/3] virsh: Use virNodeGetCPUMap if possible

2012-10-31 Thread Hu Tao
On Wed, Oct 31, 2012 at 06:20:58PM +0100, Viktor Mihajlovski wrote:
 Modified the places where virNodeGetInfo was used for the purpose
 of obtaining the maximum node CPU number. Transparently falling
 back to virNodeGetInfo in case of failure.
 Wrote utility function vshNodeGetCPUCount to compute node CPU
 number.
 
 Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
 ---
 V2 Changes:
 Implemented Eric Blake's suggestion to remove code bloat 
 introduced by first patch version.
 New helper function vshNodeGetCPUCount is now used to calculate
 the number of node CPUs.
 
  tools/virsh-domain.c | 32 +++-
  1 file changed, 23 insertions(+), 9 deletions(-)
 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 255669f..59289f1 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -126,6 +126,26 @@ vshDomainVcpuStateToString(int state)
  }
  
  /*
 + * Determine number of CPU nodes present by trying
 + * virNodeGetCPUMap and falling back to virNodeGetInfo
 + * if needed.
 + */
 +static int
 +vshNodeGetCPUCount(virConnectPtr conn)
 +{
 +int ret;
 +virNodeInfo nodeinfo;
 +
 +if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0))  0) {
 +/* fall back to nodeinfo */
 +if (virNodeGetInfo(conn, nodeinfo) == 0) {
 +ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
 +}

Isn't VIR_NODEINFO_MAXCPUS buggy? Either don't fall back to nodeinfo
or fix it.


-- 
Thanks,
Hu Tao

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


Re: [libvirt] [PATCHv2 1/3] qemu, lxc: Change host CPU detection logic.

2012-10-31 Thread Eric Blake
On 10/31/2012 11:20 AM, Viktor Mihajlovski wrote:
 The drivers for QEMU and LXC use virNodeGetInfo to determine the
 number of host CPUs. This approach can lead to a wrong (too small)
 number if one or more CPUs are offline.
 It is better to use nodeGetCPUCount on Linux hosts.
 ---
 V2 Changes:
 Use nodeGetCPUCount as suggested by Eric, nodeGetCPUMap is too
 heavyweight.

Hmm, while reading this patch series, I realized that my initial RPC
implementation always requests the number of online processors over the
wire, even though you've now proven that calling virNodeGetCPUMap(conn,
NULL, NULL, 0) is useful.  I'll see about getting in a followup patch to
optimize the on-the-wire call to avoid wasted effort of collecting a
bitmap just to determine the number of online CPUs when we really only
care about the max cpu number.

Meanwhile, on to this patch:

 @@ -492,17 +492,15 @@ static int 
 virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
  static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
  {
  int hostcpus, maxcpu = CPU_SETSIZE;
 -virNodeInfo nodeinfo;
  virBitmapPtr cpumap, cpumapToSet;
  
  VIR_DEBUG(Setting CPU affinity);
  
 -if (nodeGetInfo(NULL, nodeinfo)  0)
 -return -1;
 -
  /* setaffinity fails if you set bits for CPUs which
   * aren't present, so we have to limit ourselves */

Question - does setaffinity fail if you request setting a CPU that is
present but offline?  In that case, we would need the CPU map instead of
just the count of max cpus.  But in the meantime, I'm okay with your patch.

ACK, and will push shortly.

-- 
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] [PATCHv2 3/3] virsh: Use virNodeGetCPUMap if possible

2012-10-31 Thread Eric Blake
On 10/31/2012 08:58 PM, Hu Tao wrote:
 On Wed, Oct 31, 2012 at 06:20:58PM +0100, Viktor Mihajlovski wrote:
 Modified the places where virNodeGetInfo was used for the purpose
 of obtaining the maximum node CPU number. Transparently falling
 back to virNodeGetInfo in case of failure.
 Wrote utility function vshNodeGetCPUCount to compute node CPU
 number.


 +static int
 +vshNodeGetCPUCount(virConnectPtr conn)
 +{
 +int ret;
 +virNodeInfo nodeinfo;
 +
 +if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0))  0) {
 +/* fall back to nodeinfo */
 +if (virNodeGetInfo(conn, nodeinfo) == 0) {
 +ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
 +}
 
 Isn't VIR_NODEINFO_MAXCPUS buggy? Either don't fall back to nodeinfo
 or fix it.

Hmm, and I just realized another issue - on the RHEL 5 box I tested,
there is no /sys/devices/system/cpu/possible, so virNodeGetCPUCount()
currently fails, even though virNodeGetInfo() succeeded.  I'm going to
hold off pushing this series until after 1.0.0, to avoid any chance of a
last-minute unintentional regression.

You were asking about VIR_NODEINFO_MAXCPUS:

#define VIR_NODEINFO_MAXCPUS(nodeinfo)
((nodeinfo).nodes*(nodeinfo).sockets*(nodeinfo).cores*(nodeinfo).threads)

I can confirm that virNodeGetInfo misbehaves if enough trailing cpus are
offline, and therefore agree that we need to fix that API:

# virsh nodeinfo
CPU model:   x86_64
CPU(s):  2
CPU frequency:   2801 MHz
CPU socket(s):   1
Core(s) per socket:  2
Thread(s) per core:  1
NUMA cell(s):1
Memory size: 3941792 KiB

# echo 0  /sys/devices/system/cpu/cpu1/online

# virsh nodeinfo
CPU model:   x86_64
CPU(s):  1
CPU frequency:   2801 MHz
CPU socket(s):   1
Core(s) per socket:  1
Thread(s) per core:  1
NUMA cell(s):1
Memory size: 3941792 KiB

That just changed things from 2 to 1.  No fun.

-- 
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] libvirt can not get right stats of a rbd pool

2012-10-31 Thread libvirt
i do not think so.i am asking ceph-developers,but no answers
exact info of my storage.ceph'data dir  is in /home
1.df -lh
/dev/mapper/vg_ceph1-lv_home
  143G   23G  114G  17% /home
2.df -lh
/dev/mapper/vg_ceph2-lv_home
  144G   23G  114G  17% /home

23+23=64G,  it is impossible  489G.

'rados df -p cloud ' can give right stat.
referring its  implement maybe be right. 

2012-11-01



libvirt



发件人:Wido den Hollander
发送时间:2012-10-29 22:40
主题:Re: [libvirt] libvirt can not get right stats of a rbd pool
收件人:Daniel P. Berrangeberra...@redhat.com
抄送:yuelibv...@163.com,libvirtlibvir-list@redhat.com



On 10/29/2012 03:33 PM, Daniel P. Berrange wrote: 
 On Fri, Oct 26, 2012 at 11:04:05AM +0800, yue wrote: 
 Allocation exceed Capacity ,but Available  is  not 0. 
 
 #virsh pool-info 2361a6d4-0edc-3534-87ae-e7ee09199921 
 Name:   2361a6d4-0edc-3534-87ae-e7ee09199921 
 UUID:   2361a6d4-0edc-3534-87ae-e7ee09199921 
 State:  running 
 Persistent: yes 
 Autostart:  no 
 Capacity:   285.57 GiB 
 Allocation: 489.89 GiB 
 Available:  230.59 GiB 
 
 Hmm, these values do look a little bit suspect, but I don't know 
 enough about RBD to suggest what might be going wrong. I'm copying 
 Wido who wrote this code originally  thus might have an idea. 
 

I think I know where this is coming from, a little background about RBD. 

RBD is a disk device striped over 4MB RADOS objects inside a Ceph  
cluster. RBD devices are sparse, which means that (RADOS) objects get  
created whenever a write comes. 

When a read comes for a non-existing object 4MB of nothing is returned. 

However, when you do: $ rbd info disk1 

You will get that the object COULD be 100GB, but that doesn't mean it  
actually occupies 100GB of disk space. 

The problem is that you can't (at this point) find out how much space a  
RBD device actually occupies. Yes, it can be done, but that should not  
be done in the libvirt driver and it is pretty heavy for the Ceph cluster. 

Also, a RBD device of 100GB could take up 300GB of space when your  
replication is set to 3x. 

What you are seeing there is that you over provisioned your Ceph cluster  
by creating images which exceed 285GB in total. 

Wido 

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

Re: [libvirt] [PATCH 14/20] snapshot: qemu: Add support for external inactive snapshots

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 This patch adds support for external disk snapshots of inactive domains.
 The snapshot is created by calling
  qemu-img create -o backing_file=/path/to/disk /path/snapshot_file

This doesn't match the actual code, which also adds '-f format'
arguments.  Also, see below about an incomplete argument.

 on each of the disks selected for snapshotting.


 +/* The domain is expected to be locked and inactive. */
 +static int
 +qemuDomainSnapshotCreateInactiveExternal(struct qemud_driver *driver,
 + virDomainObjPtr vm,
 + virDomainSnapshotObjPtr snap,
 + bool reuse)
 +{
 +const char *qemuimgarg[] = { NULL, create, -f, NULL, -o, NULL, 
 NULL, NULL };

This seems awkward.  I guess I see why you're preparing the list up
front (because we are creating different commands in a loop, and because
of copy-and-paste from earlier code), but I wonder if it would be
simpler to create a virCommand from scratch on each iteration of the
loop instead of reusing qemuimgarg.


 +
 +if (snapdisk-snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
 +VIR_FREE(backingFileArg);
 +
 +/* remove old disk image */
 +if (reuse  virFileExists(snapdisk-file) 
 +unlink(snapdisk-file)  0) {

Hmm, I wonder if that's the right thing to do?  If the file already
exists, then it seems like we should just skip the qemu-img call
altogether, and use the file as-is (trusting that the user created it
correctly, the same as we would do for an active disk snapshot), rather
than unlink()ing and then recreating the file.  Also, unlink() is unsafe
if the existing file is a block device instead of a regular file.


 +
 +if (virAsprintf(backingFileArg, backing_file=%s, 
 defdisk-src)  0) {
 +virReportOOMError();
 +goto cleanup;

This is a reintroduction of a backing file probing CVE if we know the
file format of defdisk-src.  You need to pass -o
backing_file=%s,backing_fmt=%s with the backing format, if it is known,
otherwise, we have to probe a file type where we previously knew the
file type.

I didn't look closely at the rest of the patch, but want to make sure we
avoid a security hole.

-- 
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 15/20] conf: Fix private symbols exported by files in conf

2012-10-31 Thread Eric Blake
On 10/23/2012 09:12 AM, Peter Krempa wrote:
 Some of the functions were moved to other files but the private symbol
 file wasn't tweaked to reflect that.
 ---
  src/libvirt_private.syms | 47 ---
  1 file changed, 24 insertions(+), 23 deletions(-)

ACK.  This one can be pushed prior to 1.0.0, if you'd like.

-- 
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 v11] support offline migration

2012-10-31 Thread li guang
ping ...

在 2012-10-23二的 16:09 +0800,li guang写道:
 ping ...
 
 在 2012-10-18四的 08:42 +0800,liguang写道:
  original migration did not aware of offline case,
  so, try to support offline migration quietly
  (did not disturb original migration) by pass
  VIR_MIGRATE_OFFLINE flag to migration APIs if only
  the domain is really inactive, and
  migration process will not puzzled by domain
  offline and exit unexpectedly.
  these changes did not take care of disk images the
  domain required, for them could be transferred by
  other APIs as suggested, then VIR_MIGRATE_OFFLINE
  should not combined with VIR_MIGRATE_NON_SHARED_*.
  if you want a persistent migration,
  you should  do virsh migrate --persistent youself.
  
  Signed-off-by: liguang lig.f...@cn.fujitsu.com
  ---
   include/libvirt/libvirt.h.in |1 +
   src/qemu/qemu_driver.c   |   15 ++
   src/qemu/qemu_migration.c|   60 
  +++--
   src/qemu/qemu_migration.h|3 +-
   tools/virsh-domain.c |6 
   5 files changed, 75 insertions(+), 10 deletions(-)
  
  diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
  index 81f12a4..1cebc21 100644
  --- a/include/libvirt/libvirt.h.in
  +++ b/include/libvirt/libvirt.h.in
  @@ -995,6 +995,7 @@ typedef enum {
  * whole migration process; 
  this will be used automatically
  * when supported */
   VIR_MIGRATE_UNSAFE= (1  9), /* force migration even if 
  it is considered unsafe */
  +VIR_MIGRATE_OFFLINE   = (1  10), /* offline migrate */
   } virDomainMigrateFlags;
   
   /* Domain migration. */
  diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
  index 97ad23e..38bfcab 100644
  --- a/src/qemu/qemu_driver.c
  +++ b/src/qemu/qemu_driver.c
  @@ -9622,6 +9622,20 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
   }
   
   if (!virDomainObjIsActive(vm)) {
  +if (flags  VIR_MIGRATE_OFFLINE) {
  +if (flags  (VIR_MIGRATE_NON_SHARED_DISK|
  + VIR_MIGRATE_NON_SHARED_INC)) {
  +virReportError(VIR_ERR_OPERATION_INVALID,
  +   %s, _(migrating storage handled by 
  volume APIs));
  +goto endjob;
  +}
  +if (!(flags  VIR_MIGRATE_PERSIST_DEST)) {
  +virReportError(VIR_ERR_OPERATION_INVALID,
  +   %s, _(VIR_MIGRATE_OFFLINE should 
  combined with VIR_MIGRATE_PERSIST_DEST));
  +goto endjob;
  +}
  +goto offline;
  +}
   virReportError(VIR_ERR_OPERATION_INVALID,
  %s, _(domain is not running));
   goto endjob;
  @@ -9634,6 +9648,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
   if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob)  0)
   goto endjob;
   
  +offline:
   if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname,
  cookieout, cookieoutlen,
  flags)))
  diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
  index db69a0a..b2f921e 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_OFFLINE,
   
   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, offline);
   
   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_OFFLINE = (1  
  QEMU_MIGRATION_COOKIE_FLAG_OFFLINE),
   };
   
   typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
  @@ -439,6 +441,9 @@ qemuMigrationCookieXMLFormat(struct qemud_driver 
  *driver,
   virBufferAdjustIndent(buf, -2);
   }
   
  +if (mig-flags  QEMU_MIGRATION_COOKIE_OFFLINE)
  +virBufferAsprintf(buf,   offline/\n);
  +
   virBufferAddLit(buf, /qemu-migration\n);
   return 0;
   }
  @@ -662,6 +667,11 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
   VIR_FREE(nodes);
   }
   
  +if ((flags  QEMU_MIGRATION_COOKIE_OFFLINE)) {
  +if (virXPathBoolean(count(./offline)  0, ctxt))
  +mig-flags |= QEMU_MIGRATION_COOKIE_OFFLINE;
  +