[libvirt] [PATCH] add compress stream support
by Vasiliy Tolstov
Some libvirt functions use streams, this patch add
compress stream support.
So VolumeDownload/VolumeUpload can greatly speedup by using
compressed streams to save network bandtwidth and don't transfer
zero bytes (in case of raw disk format)
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
configure.ac | 2 ++
daemon/Makefile.am | 3 +++
include/libvirt/libvirt-stream.h | 3 +++
m4/virt-archive.m4 | 29 ++++++++++++++++++++++++++
src/Makefile.am | 17 +++++++++++-----
src/datatypes.h | 7 +++++++
src/fdstream.c | 44 ++++++++++++++++++++++++++++++++++++++++
src/libvirt-stream.c | 15 ++++++++++++++
tools/Makefile.am | 17 ++++++++++++++--
9 files changed, 130 insertions(+), 7 deletions(-)
create mode 100644 m4/virt-archive.m4
diff --git a/configure.ac b/configure.ac
index 03463b0..58a15bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -250,6 +250,7 @@ LIBVIRT_CHECK_SANLOCK
LIBVIRT_CHECK_SASL
LIBVIRT_CHECK_SELINUX
LIBVIRT_CHECK_SSH2
+LIBVIRT_CHECK_LIBARCHIVE
LIBVIRT_CHECK_SYSTEMD_DAEMON
LIBVIRT_CHECK_UDEV
LIBVIRT_CHECK_WIRESHARK
@@ -2892,6 +2893,7 @@ LIBVIRT_RESULT_SANLOCK
LIBVIRT_RESULT_SASL
LIBVIRT_RESULT_SELINUX
LIBVIRT_RESULT_SSH2
+LIBVIRT_RESULT_LIBARCHIVE
LIBVIRT_RESULT_SYSTEMD_DAEMON
LIBVIRT_RESULT_UDEV
LIBVIRT_RESULT_WIRESHARK
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index be1b5a9..a4d63eb 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -177,17 +177,20 @@ libvirtd_CFLAGS = \
$(XDR_CFLAGS) $(DBUS_CFLAGS) $(LIBNL_CFLAGS) \
$(WARN_CFLAGS) $(PIE_CFLAGS) \
$(COVERAGE_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\""
libvirtd_LDFLAGS = \
$(RELRO_LDFLAGS) \
$(PIE_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NO_INDIRECT_LDFLAGS) \
$(NULL)
libvirtd_LDADD = \
$(LIBXML_LIBS) \
+ $(LIBARCHIVE_LIBS) \
$(GNUTLS_LIBS) \
$(SASL_LIBS) \
$(DBUS_LIBS) \
diff --git a/include/libvirt/libvirt-stream.h b/include/libvirt/libvirt-stream.h
index 831640d..c75f03e 100644
--- a/include/libvirt/libvirt-stream.h
+++ b/include/libvirt/libvirt-stream.h
@@ -31,10 +31,13 @@
typedef enum {
VIR_STREAM_NONBLOCK = (1 << 0),
+ VIR_STREAM_COMPRESS_GZIP = (1 << 1),
+ VIR_STREAM_COMPRESS_XZ = (1 << 2),
} virStreamFlags;
virStreamPtr virStreamNew(virConnectPtr conn,
unsigned int flags);
+
int virStreamRef(virStreamPtr st);
int virStreamSend(virStreamPtr st,
diff --git a/m4/virt-archive.m4 b/m4/virt-archive.m4
new file mode 100644
index 0000000..9770732
--- /dev/null
+++ b/m4/virt-archive.m4
@@ -0,0 +1,29 @@
+dnl The libarchive.so library
+dnl
+dnl Copyright (C) 2012-2013 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_CHECK_LIBARCHIVE],[
+ LIBVIRT_CHECK_PKG([LIBARCHIVE], [libarchive], [3.1.2])
+ AC_SUBST(LIBARCHIVE_CFLAGS)
+ AC_SUBST(LIBARCHIVE_LIBS)
+ AC_SUBST(LIBARCHIVE_LDFLAGS)
+])
+
+AC_DEFUN([LIBVIRT_RESULT_LIBARCHIVE],[
+ LIBVIRT_RESULT_LIB([LIBARCHIVE])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 060abe8..429c2c7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,11 +25,11 @@ abs_topsrcdir = $(shell cd $(top_srcdir) && pwd)
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
# that actually use them. Also keep GETTEXT_CPPFLAGS at the end.
-INCLUDES = -I../gnulib/lib \
+INCLUDES = -I../gnulib/lib \
-I$(top_srcdir)/gnulib/lib \
- -I$(top_srcdir) \
+ -I$(top_srcdir) \
-I../include \
- -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include \
-I$(srcdir)/util \
-DIN_LIBVIRT \
-Dabs_topbuilddir="\"$(abs_topbuilddir)\"" \
@@ -37,14 +37,16 @@ INCLUDES = -I../gnulib/lib \
$(GETTEXT_CPPFLAGS)
AM_CFLAGS = $(LIBXML_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
$(WARN_CFLAGS) \
- $(LOCK_CHECKING_CFLAGS) \
+ $(LOCK_CHECKING_CFLAGS) \
$(WIN32_EXTRA_CFLAGS) \
$(COVERAGE_CFLAGS)
AM_LDFLAGS = $(DRIVER_MODULE_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
$(RELRO_LDFLAGS) \
$(NO_INDIRECT_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
EXTRA_DIST = $(conf_DATA) util/keymaps.csv
@@ -1051,11 +1053,13 @@ libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
$(DBUS_CFLAGS) $(LDEXP_LIBM) $(NUMACTL_CFLAGS) \
$(SYSTEMD_DAEMON_CFLAGS) $(POLKIT_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
-I$(srcdir)/conf
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS) \
$(SECDRIVER_LIBS) $(NUMACTL_LIBS) $(SYSTEMD_DAEMON_LIBS) \
+ $(LIBARCHIVE_LIBS) \
$(POLKIT_LIBS)
@@ -2214,6 +2218,7 @@ libvirt_lxc_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) \
$(MINGW_EXTRA_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
libvirt_lxc_la_CFLAGS = $(AM_CFLAGS)
libvirt_lxc_la_LIBADD = libvirt.la $(CYGWIN_EXTRA_LIBADD)
@@ -2292,13 +2297,15 @@ libvirt_setuid_rpc_client_la_SOURCES = \
libvirt_setuid_rpc_client_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBXML_LIBS) \
+ $(LIBARCHIVE_LIBS) \
$(SECDRIVER_LIBS) \
$(NULL)
libvirt_setuid_rpc_client_la_CFLAGS = \
-DLIBVIRT_SETUID_RPC_CLIENT \
-I$(srcdir)/conf \
- -I$(srcdir)/rpc \
+ -I$(srcdir)/rpc \
$(AM_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
$(SECDRIVER_CFLAGS) \
$(XDR_CFLAGS) \
$(NULL)
diff --git a/src/datatypes.h b/src/datatypes.h
index be108fe..4c0c10d 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -29,6 +29,10 @@
# include "virobject.h"
# include "viruuid.h"
+#ifdef WITH_LIBARCHIVE
+# include <archive.h>
+#endif
+
extern virClassPtr virConnectClass;
extern virClassPtr virDomainClass;
extern virClassPtr virDomainSnapshotClass;
@@ -520,6 +524,9 @@ struct _virStream {
virStreamDriverPtr driver;
void *privateData;
+#ifdef WITH_LIBARCHIVE
+ struct archive *archive;
+#endif
};
/**
diff --git a/src/fdstream.c b/src/fdstream.c
index b8ea86e..9a71a9f 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -33,6 +33,10 @@
#include <netinet/in.h>
#include <termios.h>
+#ifdef WITH_LIBARCHIVE
+# include <archive.h>
+#endif
+
#include "fdstream.h"
#include "virerror.h"
#include "datatypes.h"
@@ -319,6 +323,12 @@ virFDStreamCloseInt(virStreamPtr st, bool streamAbort)
if (VIR_CLOSE(fdst->errfd) < 0)
VIR_DEBUG("ignoring failed close on fd %d", fdst->errfd);
+#ifdef WITH_LIBARCHIVE
+ if (st->archive != NULL) {
+ archive_write_free(st->archive);
+ archive_read_free(st->archive);
+ }
+#endif
st->privateData = NULL;
/* call the internal stream closing callback */
@@ -385,7 +395,16 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
}
retry:
+#ifdef WITH_LIBARCHIVE
+ if (st->archive != NULL) {
+ archive_write_open_fd(st->archive, fdst->fd);
+ ret = archive_write_data(st->archive, bytes, nbytes);
+ } else {
+ ret = write(fdst->fd, bytes, nbytes);
+ }
+#else
ret = write(fdst->fd, bytes, nbytes);
+#endif
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
ret = -2;
@@ -397,7 +416,15 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
_("cannot write to stream"));
}
} else if (fdst->length) {
+#ifdef WITH_LIBARCHIVE
+ if (st->archive != NULL) {
+ fdst->offset += nbytes;
+ } else {
+ fdst->offset += ret;
+ }
+#else
fdst->offset += ret;
+#endif
}
virMutexUnlock(&fdst->lock);
@@ -435,7 +462,16 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
}
retry:
+#ifdef WITH_LIBARCHIVE
+ if (st->archive != NULL) {
+ archive_read_open_fd(st->archive, fdst->fd, 4096);
+ ret = archive_read_data(st->archive, bytes, nbytes);
+ } else {
+ ret = read(fdst->fd, bytes, nbytes);
+ }
+#else
ret = read(fdst->fd, bytes, nbytes);
+#endif
if (ret < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
ret = -2;
@@ -447,7 +483,15 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
_("cannot read from stream"));
}
} else if (fdst->length) {
+#ifdef WITH_LIBARCHIVE
+ if (st->archive != NULL) {
+ fdst->offset += nbytes;
+ } else {
+ fdst->offset += ret;
+ }
+#else
fdst->offset += ret;
+#endif
}
virMutexUnlock(&fdst->lock);
diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
index c16f586..0f09d9d 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -24,6 +24,10 @@
#include "viralloc.h"
#include "virlog.h"
+#ifdef WITH_LIBARCHIVE
+# include <archive.h>
+#endif
+
VIR_LOG_INIT("libvirt.stream");
#define VIR_FROM_THIS VIR_FROM_STREAMS
@@ -45,6 +49,7 @@ VIR_LOG_INIT("libvirt.stream");
*
* If a non-blocking data stream is required passed
* VIR_STREAM_NONBLOCK for flags, otherwise pass 0.
+ * VIR_STREAM_COMPRESS_GZIP or VIR_STREAM_COMPRESS_XZ
*
* Returns the new stream, or NULL upon error
*/
@@ -66,6 +71,16 @@ virStreamNew(virConnectPtr conn,
else
virDispatchError(conn);
+ if ((flags & VIR_STREAM_COMPRESS_GZIP) || (flags & VIR_STREAM_COMPRESS_XZ)) {
+ st->archive = archive_write_new();
+
+ if (flags & VIR_STREAM_COMPRESS_GZIP)
+ archive_write_add_filter(st->archive, ARCHIVE_FILTER_GZIP);
+
+ if (flags & VIR_STREAM_COMPRESS_XZ)
+ archive_write_add_filter(st->archive, ARCHIVE_FILTER_XZ);
+ }
+
return st;
}
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 03e9339..fa19a20 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -25,8 +25,12 @@ INCLUDES = \
AM_LDFLAGS = \
$(RELRO_LDFLAGS) \
$(NO_INDIRECT_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
+AM_CFLAGS = \
+ $(LIBARCHIVE_CFLAGS)
+
POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)"
ICON_FILES = \
@@ -140,15 +144,18 @@ virt_host_validate_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
virt_host_validate_LDADD = \
../src/libvirt.la \
- ../gnulib/lib/libgnu.la \
+ ../gnulib/lib/libgnu.la \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
virt_host_validate_CFLAGS = \
$(LIBXML_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
$(WARN_CFLAGS) \
$(PIE_CFLAGS) \
$(COVERAGE_CFLAGS) \
@@ -165,15 +172,18 @@ virt_login_shell_SOURCES = \
virt_login_shell_LDFLAGS = \
$(AM_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
+ $(LIBARHCIVE_LDFLAGS) \
$(NULL)
virt_login_shell_LDADD = \
$(STATIC_BINARIES) \
$(PIE_LDFLAGS) \
../src/libvirt-setuid-rpc-client.la \
+ $(LIBARCHIVE_LDFLAGS) \
../gnulib/lib/libgnu.la
virt_login_shell_CFLAGS = \
-DLIBVIRT_SETUID_RPC_CLIENT \
+ $(LIBARCHIVE_CFLAGS) \
$(LIBXML_CFLAGS) \
$(WARN_CFLAGS) \
$(PIE_CFLAGS) \
@@ -202,6 +212,7 @@ virsh_SOURCES = \
virsh_LDFLAGS = \
$(AM_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
+ $(LIBARCHIVE_LDFLAGS) \
$(NULL)
virsh_LDADD = \
$(STATIC_BINARIES) \
@@ -209,14 +220,16 @@ virsh_LDADD = \
../src/libvirt.la \
../src/libvirt-lxc.la \
../src/libvirt-qemu.la \
- ../gnulib/lib/libgnu.la \
+ ../gnulib/lib/libgnu.la \
$(LIBXML_LIBS) \
+ $(LIBARCHIVE_LIBS) \
$(VIRSH_LIBS)
virsh_CFLAGS = \
$(WARN_CFLAGS) \
$(PIE_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(LIBXML_CFLAGS) \
+ $(LIBARCHIVE_CFLAGS) \
$(READLINE_CFLAGS)
BUILT_SOURCES =
--
2.5.0
9 years, 2 months
[libvirt] [PATCH] maint: Remove control characters from LGPL license file
by Andrea Bolognani
---
COPYING.LESSER | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/COPYING.LESSER b/COPYING.LESSER
index 4362b49..e5ab03e 100644
--- a/COPYING.LESSER
+++ b/COPYING.LESSER
@@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
-
+
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
-
+
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
-
+
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
-
+
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
-
+
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
-
+
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
-
+
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
-
+
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
-
+
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
--
2.4.2
9 years, 2 months
[libvirt] [PATCH] domain: Fix migratable XML with graphics/@listen
by Jiri Denemark
As of commit 6992994, we set graphics/@listen attribute according to the
first listen child element even if that element is of type='network'.
This was done for backward compatibility with applications which only
support the original listen attribute. However, by doing so we broke
migration to older libvirt which tried to check that the listen
attribute matches one of the listen child elements but which did not
take type='network' elements into account.
We are not concerned about compatibility with old applications when
formatting domain XML for migration for two reasons. The XML is consumed
only by libvirtd and the IP address associated with type='network'
listen address on the source host is just useless on the destination
host. Thus, we can safely avoid propagating the type='network' IP
address to graphics/@listen attribute when creating migratable XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1265111
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/domain_conf.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c890977..033ae46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21020,19 +21020,17 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
* <graphics>. This is done to improve backward compatibility.
*/
for (i = 0; i < def->nListens; i++) {
- virDomainGraphicsListenType listenType;
-
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
def->listens[i].fromConfig)
continue;
- listenType = virDomainGraphicsListenGetType(def, i);
- if (listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
- (listenType == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
- !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) {
- if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
- break;
- }
+ if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
+ flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE |
+ VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))
+ continue;
+
+ if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
+ break;
}
virBufferAsprintf(buf, "<graphics type='%s'", type);
--
2.5.3
9 years, 2 months
[libvirt] [PATCH] vsh: create a noinstall libvirt_shell library
by Erik Skultety
Instead of referencing vsh sources in all relevant client targets,
create a library that the client can link against.
---
tools/Makefile.am | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 03e9339..08aebec 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -129,6 +129,24 @@ virt-sanlock-cleanup.8: virt-sanlock-cleanup.in $(top_srcdir)/configure.ac
&& if grep 'POD ERROR' $(srcdir)/$@ ; then \
rm $(srcdir)/$@; exit 1; fi
+noinst_LTLIBRARIES = libvirt_shell.la
+libvirt_shell_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(PIE_CFLAGS) \
+ $(READLINE_CFLAGS) \
+ $(LIBXML_CFLAGS) \
+ $(NULL)
+libvirt_shell_la_LDFLAGS = \
+ $(AM_LDFLAGS) \
+ $(PIE_LDFLAGS) \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+libvirt_shell_la_LIBADD = \
+ $(LIBXML_LIBS) \
+ ../gnulib/lib/libgnu.la \
+ $(NULL)
+libvirt_shell_la_SOURCES = vsh.c vsh.h
+
virt_host_validate_SOURCES = \
virt-host-validate.c \
virt-host-validate-common.c virt-host-validate-common.h \
@@ -179,11 +197,7 @@ virt_login_shell_CFLAGS = \
$(PIE_CFLAGS) \
$(COVERAGE_CFLAGS)
-virt_shell_SOURCES = \
- vsh.c vsh.h
-
virsh_SOURCES = \
- $(virt_shell_SOURCES) \
virsh.c virsh.h \
virsh-console.c virsh-console.h \
virsh-domain.c virsh-domain.h \
@@ -210,14 +224,13 @@ virsh_LDADD = \
../src/libvirt-lxc.la \
../src/libvirt-qemu.la \
../gnulib/lib/libgnu.la \
- $(LIBXML_LIBS) \
+ libvirt_shell.la \
$(VIRSH_LIBS)
virsh_CFLAGS = \
$(WARN_CFLAGS) \
$(PIE_CFLAGS) \
$(COVERAGE_CFLAGS) \
- $(LIBXML_CFLAGS) \
- $(READLINE_CFLAGS)
+ $(LIBXML_CFLAGS)
BUILT_SOURCES =
if WITH_WIN_ICON
--
2.4.3
9 years, 2 months
[libvirt] [libvirt-test-api][PATCHv2] Add new test case for allocPages API
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
cases/test_connection.conf | 10 ++++
repos/virconn/connection_allocPages.py | 84 ++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
create mode 100644 repos/virconn/connection_allocPages.py
diff --git a/cases/test_connection.conf b/cases/test_connection.conf
index 336b1ad..a4406bf 100644
--- a/cases/test_connection.conf
+++ b/cases/test_connection.conf
@@ -77,3 +77,13 @@ virconn:connection_getMemoryParameters
virconn:connection_getMemoryStats
conn
qemu:///system
+
+virconn:connection_allocPages
+ conn
+ qemu:///system
+
+virconn:connection_allocPages
+ conn
+ qemu:///system
+ flags
+ pageset
diff --git a/repos/virconn/connection_allocPages.py b/repos/virconn/connection_allocPages.py
new file mode 100644
index 0000000..de3c071
--- /dev/null
+++ b/repos/virconn/connection_allocPages.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+
+required_params = ()
+optional_params = {'conn': '', 'flags': ''}
+
+HOST_HUGEPAGE = '/sys/devices/system/node/node%d/hugepages/hugepages-%dkB/nr_hugepages'
+
+def get_host_pagesize(conn):
+ ret = []
+ tree = lxml.etree.fromstring(conn.getCapabilities())
+
+ set = tree.xpath("/capabilities/host/cpu/pages")
+ for n in set:
+ ret.append(int(n.attrib['size']))
+
+ return ret
+
+def get_host_pagecount(pagesize):
+ try:
+ return int(open(HOST_HUGEPAGE % (0, pagesize)).read())
+ except IOError:
+ return -1
+
+def connection_allocPages(params):
+ """
+ test API for allocPages in class virConnect
+ """
+ logger = params['logger']
+ fail=0
+
+ if 'flags' in params:
+ if params['flags'] == 'pageset':
+ flags = libvirt.VIR_NODE_ALLOC_PAGES_SET
+ else:
+ logger.error("Unknown flags name: %s" % params['flags'])
+ return 1
+ else:
+ flags = 0
+
+ try:
+ if 'conn' in params:
+ conn=libvirt.open(params['conn'])
+ else:
+ conn=libvirt.open(optional_params['conn'])
+ logger.info("get connection to libvirtd")
+ list1 = get_host_pagesize(conn)
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ for i in list1:
+ logger.info("test hugepage size %d" % i)
+
+ if get_host_pagecount(i) == -1:
+ logger.info("Skip system page size %d" % i)
+ continue
+
+ try:
+ cur_count = get_host_pagecount(i)
+ if flags == libvirt.VIR_NODE_ALLOC_PAGES_SET:
+ conn.allocPages({i : cur_count + 1}, 0, 1, flags)
+ else:
+ conn.allocPages({i : 1}, 0, 1, flags)
+ if get_host_pagecount(i) != cur_count + 1:
+ logger.error("libvirt set a wrong page count to %dKiB hugepage" % i)
+ fail = 1
+ except libvirtError, e:
+ if "Allocated only" in e.message:
+ tmp_count = int(e.message.split()[-1])
+
+ if tmp_count != get_host_pagecount(i):
+ logger.error("libvirt output %dKiB hugepage count is not right" % i)
+ fail = 1
+ else:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return fail
--
1.8.3.1
9 years, 2 months
[libvirt] [libvirt-test-api][PATCH] Add a new test case for setUserPassword
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
cases/linux_domain.conf | 22 ++++++++
repos/domain/set_user_passwd.py | 111 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 133 insertions(+)
create mode 100644 repos/domain/set_user_passwd.py
diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 19daded..9a65cf3 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -299,6 +299,28 @@ domain:info_iothread
conn
qemu:///system
+domain:set_user_passwd
+ guestname
+ $defaultname
+ username
+ $username
+ userpassword
+ $password
+ conn
+ qemu:///system
+
+domain:set_user_passwd
+ guestname
+ $defaultname
+ username
+ $username
+ userpassword
+ $password
+ conn
+ qemu:///system
+ flags
+ encrypted
+
domain:destroy
guestname
$defaultname
diff --git a/repos/domain/set_user_passwd.py b/repos/domain/set_user_passwd.py
new file mode 100644
index 0000000..bf9bd06
--- /dev/null
+++ b/repos/domain/set_user_passwd.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+import crypt
+from utils import utils
+
+required_params = ('guestname', 'username', 'userpassword',)
+optional_params = {'conn': 'qemu:///system', 'flags': '',}
+
+def get_guest_mac(vm):
+ tree = lxml.etree.fromstring(vm.XMLDesc(0))
+ set = tree.xpath("/domain/devices/interface/mac")
+
+ for n in set:
+ return n.attrib['address']
+
+ return False
+
+
+def check_agent_status(vm):
+ """ make sure agent is okay to use """
+
+ tree = lxml.etree.fromstring(vm.XMLDesc(0))
+
+ set = tree.xpath("//channel[@type='unix']/target[@name='org.qemu.guest_agent.0']")
+ for n in set:
+ if n.attrib['state'] == 'connected':
+ return True
+
+ return False
+
+def create_new_user(ipaddr, newusername, username, userpasswd, logger):
+ cmd = "useradd %s" % newusername
+ ret, retinfo = utils.remote_exec_pexpect(ipaddr, username, userpasswd, cmd)
+ if ret == 0 or "already exists" in retinfo:
+ return 0
+ else:
+ logger.error("Fail: cannot create a new user: %s" % retinfo)
+ return 1
+
+def verify_cur_user(ipaddr, username, userpasswd):
+ cmd = "whoami"
+ ret, retinfo = utils.remote_exec_pexpect(ipaddr, username, userpasswd, cmd)
+
+ return ret
+
+def set_user_passwd(params):
+ """
+ test API for setUserPassword in class virDomain
+ """
+
+ logger = params['logger']
+ guest = params['guestname']
+ username = params['username']
+ userpasswd = params['userpassword']
+
+ if 'flags' in params:
+ if params['flags'] == 'encrypted':
+ flags = libvirt.VIR_DOMAIN_PASSWORD_ENCRYPTED
+ else:
+ flags = 0
+ else:
+ flags = 0
+
+ try:
+ if 'conn' in params:
+ conn = libvirt.open(params['conn'])
+ else:
+ conn = libvirt.open(optional_params['conn'])
+
+ logger.info("get connection to libvirtd")
+ vm = conn.lookupByName(guest)
+ logger.info("test guest name: %s" % guest)
+
+ if not check_agent_status(vm):
+ logger.error("guest agent is not connected")
+ return 1
+
+ mac = get_guest_mac(vm)
+ if not mac:
+ logger.error("cannot get guest interface mac")
+ return 1
+
+ ipaddr = utils.mac_to_ip(mac, 180)
+ if not ipaddr:
+ logger.error("cannot get guest IP")
+ return 1
+
+ if flags > 0:
+ passwd = crypt.crypt("123456", crypt.mksalt(crypt.METHOD_SHA512))
+ else:
+ passwd = "123456"
+
+
+ if create_new_user(ipaddr, "usertestapi", username, userpasswd, logger) != 0:
+ return 1
+
+ vm.setUserPassword("usertestapi", passwd, flags)
+
+ if verify_cur_user(ipaddr, "usertestapi", "123456") != 0:
+ logger.error("cannot login guest via new user")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
--
1.8.3.1
9 years, 2 months
[libvirt] [libvirt-test-api][PATCH 1/2] introduce a new helper to parse mountinfo
by Luyao Huang
And will return list like this :
[{'devminor': '25', 'mountdir': '/sys/fs/cgroup/cpuset', 'devmajor': '0', 'mounttype': 'cgroup'},...]
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
utils/utils.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/utils/utils.py b/utils/utils.py
index a6e6965..6909fed 100644
--- a/utils/utils.py
+++ b/utils/utils.py
@@ -925,3 +925,40 @@ def param_to_tuple_nolength(paramlist):
lengh = max(d)
return param_to_tuple(paramlist, int(lengh) + 1)
+
+def parse_mountinfo(string):
+ """a helper to parse mountinfo in /proc/self/mountinfo
+ and return a list contains multiple dict
+ """
+
+ ret = []
+ mount_list = string.split("\n")
+ for n in mount_list:
+ mount_dict = {}
+ if n.find("/") > 0:
+ tmp = n[:n.find("/")]
+ if len(tmp.split()) != 3:
+ continue
+
+ if tmp.split()[2].find(":") < 0:
+ continue
+
+ mount_dict['devmajor'] = tmp.split()[2].split(":")[0]
+ mount_dict['devminor'] = tmp.split()[2].split(":")[1]
+
+ tmp = n[n.find("/") + 1:]
+
+ mount_dict['mountdir'] = tmp.split()[0]
+
+ if tmp.find(" - ") < 0:
+ continue
+
+ tmp = tmp.split(" - ")[1]
+
+ mount_dict['mounttype'] = tmp.split()[0]
+ if tmp.split()[1].find("/") > 0:
+ mount_dict['sourcedir'] = tmp.split()[1]
+
+ ret.append(mount_dict)
+
+ return ret
--
1.8.3.1
9 years, 2 months
[libvirt] [libvirt-sandbox][PATCH] configure: Get static libs for static linking
by Michal Privoznik
So you wanna build libvirt-sandbox, right? And you think you have
everything you need. Dang, you don't! Because we check for libz
and liblzma for dynamic linking. However,
libvirt-sandbox-init-qemu is linked statically. Therefore, we
need to ask pkg-config to fetch us the list of libs for static
linking.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Okay, I admit that this may be not as serious as I made it in the commit message. The only difference after this patch is -pthread added to LZMA libs:
configure: Configuration summary
configure: =====================
configure:
configure:
configure: Libraries:
configure:
configure: LZMA: -llzma -pthread
configure: ZLIB: -lz
configure: GOBJECT: -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lgobject-2.0 -lglib-2.0
configure: LIBVIRT_GOBJECT: -pthread -I/usr/include/libvirt-gobject-1.0 -I/usr/include/libvirt-gconfig-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -lvirt-gobject-1.0 -lgio-2.0 -lvirt-gconfig-1.0 -lgobject-2.0 -lglib-2.0 -lxml2 -lvir
configure.ac | 3 +++
1 file changed, 3 insertions(+)
diff --git a/configure.ac b/configure.ac
index 92d65f4..00c2d7e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,6 +86,8 @@ AC_ARG_WITH([zlib],
[add ZLIB support @<:@default=yes@:>@])])
m4_divert_text([DEFAULTS], [with_zlib=yes])
+orig_pkg_config="$PKG_CONFIG"
+PKG_CONFIG="$PKG_CONFIG --static"
if test "$with_zlib" = "yes" ; then
PKG_CHECK_MODULES(ZLIB, zlib >= $ZLIB_REQUIRED)
AC_DEFINE([WITH_ZLIB], [1], [Whether ZLIB support was enabled])
@@ -100,6 +102,7 @@ if test "$with_lzma" = "yes" ; then
PKG_CHECK_MODULES(LZMA, liblzma >= $LZMA_REQUIRED)
AC_DEFINE([WITH_LZMA], [1], [Whether LZMA support was enabled])
fi
+PKG_CONFIG="$orig_pkg_config"
LIBVIRT_SANDBOX_CAPNG
LIBVIRT_SANDBOX_GETTEXT
--
2.4.9
9 years, 2 months
[libvirt] [PATCH v2 0/4] Couple of 'virsh create' fixes
by Michal Privoznik
And this time 'virsh restore' too.
The diff to v1 is that more drivers is fixed.
Michal Privoznik (4):
virDomainCreateXML: Don't remove persistent domains on error
virDomainCreateXML: Make domain definition transient
qemu: Move vm->persistent check into qemuDomainRemoveInactive
virDomainRestore: Don't keep transient domains around
src/bhyve/bhyve_driver.c | 1 +
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 7 +++++--
src/openvz/openvz_driver.c | 1 +
src/qemu/qemu_domain.c | 9 ++++++++-
src/qemu/qemu_driver.c | 39 ++++++++++++++++-----------------------
src/qemu/qemu_migration.c | 14 +++++---------
src/qemu/qemu_process.c | 12 ++++--------
src/test/test_driver.c | 15 +++++++++++++--
src/uml/uml_driver.c | 8 +++++---
src/vmware/vmware_driver.c | 7 +++++--
11 files changed, 64 insertions(+), 50 deletions(-)
--
2.4.9
9 years, 2 months
[libvirt] [PATCH] Remove redundand assignment
by Martin Kletzander
I initially added this in order to keep the code more error-prone to
following additions, but it seems it's still frowned upon.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Pushed as really, really trivial.
src/qemu/qemu_domain.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b57b9954b33f..12cc447180b5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -831,7 +831,6 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
goto error;
}
virObjectUnref(caps);
- caps = NULL;
VIR_FREE(tmp);
return 0;
--
2.5.3
9 years, 2 months