[libvirt] [PATCH] conf: escape string for disk driver name attribute
by Luyao Huang
Just like e92e5ba1, this attribute was missed.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_conf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a3b3ccb..85c2d0d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18867,8 +18867,7 @@ virDomainDiskDefFormat(virBufferPtr buf,
def->ioeventfd || def->event_idx || def->copy_on_read ||
def->discard || def->iothread) {
virBufferAddLit(buf, "<driver");
- if (def->src->driverName)
- virBufferAsprintf(buf, " name='%s'", def->src->driverName);
+ virBufferEscapeString(buf, " name='%s'", def->src->driverName);
if (def->src->format > 0)
virBufferAsprintf(buf, " type='%s'",
virStorageFileFormatTypeToString(def->src->format));
--
1.8.3.1
9 years, 3 months
[libvirt] [PATCH] Use VIR_DIV_UP macro where possible
by Martin Kletzander
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Will push as trivial in a second.
src/rpc/virnetclientstream.c | 2 +-
src/util/virbitmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 1cc9002b0ad7..64e9cd221be2 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -279,7 +279,7 @@ int virNetClientStreamQueuePacket(virNetClientStreamPtr st,
goto end;
}
- pieces = (length + size - 1) / size;
+ pieces = VIR_DIV_UP(length, size);
for (piece = 0; piece < pieces; piece++) {
if (size > length - offset)
size = length - offset;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 4d270a910c19..57135a09f71e 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -71,7 +71,7 @@ virBitmapNewQuiet(size_t size)
if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size == 0)
return NULL;
- sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) / VIR_BITMAP_BITS_PER_UNIT;
+ sz = VIR_DIV_UP(size, VIR_BITMAP_BITS_PER_UNIT);
if (VIR_ALLOC_QUIET(bitmap) < 0)
return NULL;
--
2.5.3
9 years, 3 months
[libvirt] [PATCH 0/5] Couple of 'virsh create' fixes
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (5):
qemuDomainCreateXML: Don't remove persistent domains on error
qemuDomainCreateXML: Make domain definition transient
qemu: Move vm->persistent check into qemuDomainRemoveInactive
lxcDomainCreateXMLWithFiles: Don't remove persistent domains on error
lxcDomainCreateXMLWithFiles: Make domain definition transient
src/lxc/lxc_driver.c | 7 +++++--
src/qemu/qemu_domain.c | 9 ++++++++-
src/qemu/qemu_driver.c | 37 +++++++++++++++----------------------
src/qemu/qemu_migration.c | 14 +++++---------
src/qemu/qemu_process.c | 12 ++++--------
5 files changed, 37 insertions(+), 42 deletions(-)
--
2.4.9
9 years, 3 months
[libvirt] [PATCH] qemuDomainDeviceDefPostParse: Drop useless check
by Michal Privoznik
Now that virQEMUDriverCreateXMLConf is never called with NULL
(after 086f37e97aab) we can safely drop useless check in
qemuDomainDeviceDefPostParse as we are guaranteed to be always
called with the driver initialized. Therefore checking if driver
is NULL makes no sense. Moreover, if we mix it with direct driver
dereference.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_domain.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7d92f3a..8e3a7d3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1233,12 +1233,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
{
virQEMUDriverPtr driver = opaque;
virQEMUCapsPtr qemuCaps = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
- if (driver)
- cfg = virQEMUDriverGetConfig(driver);
-
qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator);
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
--
2.4.9
9 years, 3 months
[libvirt] [libvirt-sandbox][PATCH 0/4] Couple of coverity fixes
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (4):
builder: Drop dead code in gvir_sandbox_builder_clean_post_stop
libvirt-sandbox-init-common: Avoid calling fclose(NULL)
libvirt-sandbox-config: Don't deref NULL
libvirt-sandbox-init-qemu: Check for fopen() return value
libvirt-sandbox/libvirt-sandbox-builder.c | 4 ----
libvirt-sandbox/libvirt-sandbox-config.c | 15 ++++++++-------
libvirt-sandbox/libvirt-sandbox-init-common.c | 3 ++-
libvirt-sandbox/libvirt-sandbox-init-qemu.c | 11 ++++++++++-
4 files changed, 20 insertions(+), 13 deletions(-)
--
2.4.9
9 years, 3 months
[libvirt] [PATCH] Makefile: fix build fail when make rpm
by Luyao Huang
Build fail and error like this:
CC qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_capabilities.c:46:27: fatal error: qemu_capspriv.h: No such file or directory
#include "qemu_capspriv.h"
Add qemu_capspriv.h to source.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 060abe8..07d5879 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -763,7 +763,8 @@ QEMU_DRIVER_SOURCES = \
qemu/qemu_monitor_json.c \
qemu/qemu_monitor_json.h \
qemu/qemu_driver.c qemu/qemu_driver.h \
- qemu/qemu_interface.c qemu/qemu_interface.h
+ qemu/qemu_interface.c qemu/qemu_interface.h \
+ qemu/qemu_capspriv.h
XENAPI_DRIVER_SOURCES = \
xenapi/xenapi_driver.c xenapi/xenapi_driver.h \
--
1.8.3.1
9 years, 3 months
[libvirt] New software based on libvirt
by Gustav Fransson Nyvell
Hello,
I'm introducing to you the decentralized cloud Cherrypop.
Combining libvirt and LizardFS (as of now) it becomes a cloud completely
without masters. Thus, any node is sufficient for the cloud to be up
and therefore no wasted resources and no single point of failure.
It's still pretty crude software but will work with some tinkering. Hope
you try it and like it!
For more information, source and binary:
https://github.com/gustavfranssonnyvell/cherrypop
//Gustav
9 years, 3 months
[libvirt] [PATCH] add compress stream support
by Vasiliy Tolstov
use libarchive for compressed stream support
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
configure.ac | 11 ++++++--
include/libvirt/libvirt-stream.h | 6 +++++
m4/virt-archive.m4 | 26 +++++++++++++++++++
src/fdstream.c | 47 +++++++++++++++++++++++++++++++++
src/libvirt-stream.c | 56 +++++++++++++++++++++++++++++++++++++++-
src/libvirt_public.syms | 7 +++++
6 files changed, 150 insertions(+), 3 deletions(-)
create mode 100644 m4/virt-archive.m4
diff --git a/configure.ac b/configure.ac
index 03463b0..4018b49 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
@@ -1603,8 +1604,6 @@ fi
AC_SUBST([LIBPCAP_CFLAGS])
AC_SUBST([LIBPCAP_LIBS])
-
-
dnl
dnl Checks for the UML driver
dnl
@@ -2097,6 +2096,13 @@ AM_CONDITIONAL([WITH_STORAGE_DISK], [test "$with_storage_disk" = "yes"])
AC_SUBST([LIBPARTED_CFLAGS])
AC_SUBST([LIBPARTED_LIBS])
+if test "$with_libarchive" = "yes" || test "$with_libarchive" = "check"; then
+ PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.1.2], [], [LIBARCHIVE_FOUND=no])
+fi
+AC_SUBST([LIBARCHIVE_CFLAGS])
+AC_SUBST([LIBARCHIVE_LIBS])
+
+
if test "$with_storage_mpath" = "yes" ||
test "$with_storage_disk" = "yes"; then
DEVMAPPER_CFLAGS=
@@ -2892,6 +2898,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/include/libvirt/libvirt-stream.h b/include/libvirt/libvirt-stream.h
index 831640d..ac48fba 100644
--- a/include/libvirt/libvirt-stream.h
+++ b/include/libvirt/libvirt-stream.h
@@ -35,6 +35,12 @@ typedef enum {
virStreamPtr virStreamNew(virConnectPtr conn,
unsigned int flags);
+virStreamPtr virStreamNewLz4(virConnectPtr conn,
+ unsigned int flags);
+virStreamPtr virStreamNewGzip(virConnectPtr conn,
+ unsigned int flags);
+virStreamPtr virStreamNewXz(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..b550c41
--- /dev/null
+++ b/m4/virt-archive.m4
@@ -0,0 +1,26 @@
+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_DEFUN([LIBVIRT_RESULT_LIBARCHIVE],[
+ LIBVIRT_RESULT_LIB([LIBARCHIVE])
+])
diff --git a/src/fdstream.c b/src/fdstream.c
index b8ea86e..82f0e8c 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"
@@ -75,6 +79,9 @@ struct virFDStreamData {
void *icbOpaque;
virMutex lock;
+#ifdef WITH_LIBARCHIVE
+ void *archive;
+#endif
};
@@ -319,6 +326,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 (fdst->archive != NULL) {
+ archive_write_free(fdst->archive);
+ archive_read_free(fdst->archive);
+ }
+#endif
st->privateData = NULL;
/* call the internal stream closing callback */
@@ -385,7 +398,16 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
}
retry:
+#ifdef WITH_LIBARCHIVE
+ if (fdst->archive != NULL) {
+ archive_write_open_fd(fdst->archive, fdst->fd);
+ ret = archive_write_data(fdst->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 +419,15 @@ static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nbytes)
_("cannot write to stream"));
}
} else if (fdst->length) {
+#ifdef WITH_LIBARCHIVE
+ if (fdst->archive != NULL) {
+ fdst->offset += nbytes;
+ } else {
+ fdst->offset += ret;
+ }
+#else
fdst->offset += ret;
+#endif
}
virMutexUnlock(&fdst->lock);
@@ -435,7 +465,16 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
}
retry:
+#ifdef WITH_LIBARCHIVE
+ if (fdst->archive != NULL) {
+ archive_read_open_fd(fdst->archive, fdst->fd, 4096);
+ ret = archive_read_data(fdst->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 +486,15 @@ static int virFDStreamRead(virStreamPtr st, char *bytes, size_t nbytes)
_("cannot read from stream"));
}
} else if (fdst->length) {
+#ifdef WITH_LIBARCHIVE
+ if (fdst->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..40702dc 100644
--- a/src/libvirt-stream.c
+++ b/src/libvirt-stream.c
@@ -23,12 +23,16 @@
#include "datatypes.h"
#include "viralloc.h"
#include "virlog.h"
+#include "fdstream.h"
+
+#include <archive.h>
+
+struct virFDStreamData;
VIR_LOG_INIT("libvirt.stream");
#define VIR_FROM_THIS VIR_FROM_STREAMS
-
/**
* virStreamNew:
* @conn: pointer to the connection
@@ -69,6 +73,56 @@ virStreamNew(virConnectPtr conn,
return st;
}
+virStreamPtr
+virStreamNewLz4(virConnectPtr conn,
+ unsigned int flags)
+{
+ virStreamPtr st;
+
+ st = virStreamNew(conn, flags);
+ if (st != NULL) {
+ struct virFDStreamData *fdst = st->privateData;
+ fdst->archive = archive_write_new();
+ archive_write_add_filter(fdst->archive, ARCHIVE_FILTER_LZ4);
+ }
+
+ return st;
+}
+
+virStreamPtr
+virStreamNewGzip(virConnectPtr conn,
+ unsigned int flags)
+{
+ virStreamPtr st;
+
+ st = virStreamNew(conn, flags);
+ if (st != NULL) {
+ struct virFDStreamData *fdst = st->privateData;
+ fdst->archive = archive_write_new();
+ archive_write_add_filter(fdst->archive, ARCHIVE_FILTER_GZIP);
+ }
+
+ return st;
+}
+
+
+virStreamPtr
+virStreamNewXz(virConnectPtr conn,
+ unsigned int flags)
+{
+ virStreamPtr st;
+
+ st = virStreamNew(conn, flags);
+ if (st != NULL) {
+ struct virFDStreamData *fdst = st->privateData;
+ fdst->archive = archive_write_new();
+ archive_write_add_filter(fdst->archive, ARCHIVE_FILTER_XZ);
+ }
+
+ return st;
+}
+
+
/**
* virStreamRef:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index dd94191..46519ce 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -725,4 +725,11 @@ LIBVIRT_1.2.19 {
virDomainRename;
} LIBVIRT_1.2.17;
+LIBVIRT_1.2.20 {
+ global:
+ virStreamNewLz4;
+ virStreamNewGzip;
+ virStreamNewXz;
+} LIBVIRT_1.2.19;
+
# .... define new API here using predicted next version number ....
--
2.5.0
9 years, 3 months
[libvirt] [PATCH] spec: Fix some warnings with latest rpmbuild
by Cole Robinson
$ rpmbuild -ba libvirt.spec
warning: Macro expanded in comment on line 5: # If neither fedora nor rhel was defined, try to guess them from %{dist}
warning: Macro %enable_autotools defined but not used within scope
warning: Macro %client_only defined but not used within scope
...
---
libvirt.spec.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 48461e8..853d2ec 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -2,7 +2,7 @@
# This spec file assumes you are building for Fedora 13 or newer,
# or for RHEL 5 or newer. It may need some tweaks for other distros.
-# If neither fedora nor rhel was defined, try to guess them from %{dist}
+# If neither fedora nor rhel was defined, try to guess them from dist
%if !0%{?rhel} && !0%{?fedora}
%{expand:%(echo "%{?dist}" | \
sed -ne 's/^\.el\([0-9]\+\).*/%%define rhel \1/p')}
@@ -13,13 +13,13 @@
# Default to skipping autoreconf. Distros can change just this one line
# (or provide a command-line override) if they backport any patches that
# touch configure.ac or Makefile.am.
-%{!?enable_autotools:%define enable_autotools 0}
+%{!?enable_autotools:%global enable_autotools 0}
# A client only build will create a libvirt.so only containing
# the generic RPC driver, and test driver and no libvirtd
# Default to a full server + client build, but with the possibility
# of a command-line or ~/.rpmmacros override for client-only.
-%{!?client_only:%define client_only 0}
+%{!?client_only:%global client_only 0}
# Now turn off server build in certain cases
--
2.5.0
9 years, 3 months