[libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument
by Wei Liu
In the latest libxenlight code, libxl_domain_create_restore accepts a
new argument. Update libvirt's libxl driver for that. Use the macro
provided by libxenlight to detect which version should be used.
The new parameter (send_back_fd) is set to -1 because libvirt provides
no such fd.
Signed-off-by: Wei Liu <wei.liu2(a)citrix.com>
---
Build test with Xen 4.6.1 (old API) and Xen unstable (new API).
---
src/libxl/libxl_domain.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 04962a0..aed904b 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -1070,7 +1070,12 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
ret = libxl_domain_create_new(cfg->ctx, &d_config,
&domid, NULL, &aop_console_how);
} else {
-#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS
+#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD)
+ params.checkpointed_stream = 0;
+ ret = libxl_domain_create_restore(cfg->ctx, &d_config, &domid,
+ restore_fd, -1, ¶ms, NULL,
+ &aop_console_how);
+#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS)
params.checkpointed_stream = 0;
ret = libxl_domain_create_restore(cfg->ctx, &d_config, &domid,
restore_fd, ¶ms, NULL,
--
2.1.4
8 years, 7 months
[libvirt] 200ms delay waiting for qemu monitor
by Richard W.M. Jones
[Thanks to Dan Berrangé for doing the analysis of this one]
I was investigating a 200+ millisecond delay when libvirt starts a
qemu guest. You can see the traces here:
http://oirase.annexia.org/tmp/libvirt.log
http://oirase.annexia.org/tmp/libvirtd.log
The delay happens at around 16:52:57.327-6:52:57.528 in the libvirtd log.
As you can see the delay is almost precisely 200ms.
Dan found the cause which seems to be this code:
https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_monitor.c;h...
(There are other examples of the same anti-pattern in src/fdstream.c
and src/qemu/qemu_agent.c, but it's the particular code above which
seems to be causing the delay).
To give you some sense why I regard this as a problem, the TOTAL time
taken to launch and shutdown the libguestfs appliance (that includes
qemu, BIOS, guest kernel, probing and mouting disks, running the
guestfs daemon, and the shutdown process in reverse), without libvirt,
is now 900ms. Libvirt adds about 220ms on top of this.
What can we do about this? Obviously we could simply reduce the
delay, but even if it was set to 20ms, that would be too much (aim is
to reduce the whole process from 900ms down to 150ms), and it would
also mean that libvirt was essentially polling.
Can we use inotify to detect if the socket has been created? Seems to
create portability problems.
Dan suggested:
Can we create the socket in libvirtd and pass it to qemu?
Can we pass a file descriptor to qemu?
Other suggestions?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
8 years, 7 months
[libvirt] [PATCH v2 0/3] qemu: Explicitly check for gnutls_rnd()
by Andrea Bolognani
Patch 1 fixes a bug in configure.
Patch 2 performs a minor cleanup.
Patch 3 is the fix for the build issues currently experienced
on CentOS 6 (see [1]).
Changes from v1:
* update CFLAGS and LIBS before performing the check, so
that the compiler can actually find the function
Cheers.
[1] https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/syste...
Andrea Bolognani (3):
configure: Restore CFLAGS properly after GnuTLS checks
configure: Always use old_CFLAGS and old_LIBS
qemu: Explicitly check for gnutls_rnd()
configure.ac | 31 +++++++++++++++++++------------
src/qemu/qemu_domain.c | 6 +++---
2 files changed, 22 insertions(+), 15 deletions(-)
--
2.5.5
8 years, 7 months
[libvirt] [PATCH v2] host-validate: Improve CPU flags processing
by Andrea Bolognani
Instead of relying on substring search, tokenize the input
and process each CPU flag separately. This ensures CPU flag
detection will continue to work correctly even if we start
looking for CPU flags whose name might appear as part of
other CPU flags' names.
The result of processing is stored in a virBitmap, which
means we don't have to parse /proc/cpuinfo in its entirety
for each single CPU flag we want to check.
Moreover, use of the newly-introduced virHostValidateCPUFlag
enumeration ensures we don't go looking for random CPU flags
which might actually be simple typos.
---
Changes in v2:
* use virStringSplitCount() and STRPREFIX() instead of
strtok_r() and strcmp(), as suggested by Peter
tools/virt-host-validate-common.c | 67 ++++++++++++++++++++++++++++++++-------
tools/virt-host-validate-common.h | 13 +++++++-
tools/virt-host-validate-qemu.c | 12 +++++--
3 files changed, 77 insertions(+), 15 deletions(-)
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index 8ebf73e..3305a32 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -31,7 +31,6 @@
#endif /* HAVE_MNTENT_H */
#include <sys/stat.h>
-#include "virutil.h"
#include "viralloc.h"
#include "virfile.h"
#include "virt-host-validate-common.h"
@@ -39,6 +38,10 @@
#define VIR_FROM_THIS VIR_FROM_NONE
+VIR_ENUM_IMPL(virHostValidateCPUFlag, VIR_HOST_VALIDATE_CPU_FLAG_LAST,
+ "vmx",
+ "svm");
+
static bool quiet;
void virHostMsgSetQuiet(bool quietFlag)
@@ -188,29 +191,64 @@ int virHostValidateNamespace(const char *hvname,
}
-bool virHostValidateHasCPUFlag(const char *name)
+virBitmapPtr virHostValidateGetCPUFlags(void)
{
- FILE *fp = fopen("/proc/cpuinfo", "r");
- bool ret = false;
+ FILE *fp;
+ virBitmapPtr flags;
- if (!fp)
- return false;
+ if (!(fp = fopen("/proc/cpuinfo", "r")))
+ return NULL;
+
+ if (!(flags = virBitmapNewQuiet(VIR_HOST_VALIDATE_CPU_FLAG_LAST)))
+ return NULL;
do {
char line[1024];
+ char *start;
+ char **tokens;
+ size_t ntokens;
+ size_t i;
if (!fgets(line, sizeof(line), fp))
break;
- if (strstr(line, name)) {
- ret = true;
- break;
+ /* The line we're interested in is marked either as "flags" or
+ * as "Features" depending on the architecture, so check both
+ * prefixes */
+ if (!STRPREFIX(line, "flags") && !STRPREFIX(line, "Features"))
+ continue;
+
+ /* fgets() includes the trailing newline in the output buffer,
+ * so we need to clean that up ourselves. We can safely access
+ * line[strlen(line) - 1] because the checks above would cause
+ * us to skip empty strings */
+ line[strlen(line) - 1] = '\0';
+
+ /* Skip to the separator */
+ if (!(start = strstr(line, ":")))
+ continue;
+
+ /* Split the line using " " as a delimiter. The first token
+ * will always be ":", but that's okay */
+ if (!(tokens = virStringSplitCount(start, " ", 0, &ntokens)))
+ continue;
+
+ /* Go through all flags and check whether one of those we
+ * might want to check for later on is present; if that's
+ * the case, set the relevant bit in the bitmap */
+ for (i = 0; i < ntokens; i++) {
+ int value;
+
+ if ((value = virHostValidateCPUFlagTypeFromString(tokens[i])) >= 0)
+ ignore_value(virBitmapSetBit(flags, value));
}
+
+ virStringFreeListCount(tokens, ntokens);
} while (1);
VIR_FORCE_FCLOSE(fp);
- return ret;
+ return flags;
}
@@ -359,15 +397,20 @@ int virHostValidateCGroupController(const char *hvname,
int virHostValidateIOMMU(const char *hvname,
virHostValidateLevel level)
{
+ virBitmapPtr flags;
struct stat sb;
const char *bootarg = NULL;
bool isAMD = false, isIntel = false;
- if (virHostValidateHasCPUFlag("vmx"))
+ flags = virHostValidateGetCPUFlags();
+
+ if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))
isIntel = true;
- else if (virHostValidateHasCPUFlag("svm"))
+ else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM))
isAMD = true;
+ virBitmapFree(flags);
+
virHostMsgCheck(hvname, "%s", _("for device assignment IOMMU support"));
if (isIntel) {
diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-common.h
index d4c4759..26e006b 100644
--- a/tools/virt-host-validate-common.h
+++ b/tools/virt-host-validate-common.h
@@ -23,6 +23,8 @@
# define __VIRT_HOST_VALIDATE_COMMON_H__
# include "internal.h"
+# include "virutil.h"
+# include "virbitmap.h"
typedef enum {
VIR_HOST_VALIDATE_FAIL,
@@ -32,6 +34,15 @@ typedef enum {
VIR_HOST_VALIDATE_LAST,
} virHostValidateLevel;
+typedef enum {
+ VIR_HOST_VALIDATE_CPU_FLAG_VMX = 0,
+ VIR_HOST_VALIDATE_CPU_FLAG_SVM,
+
+ VIR_HOST_VALIDATE_CPU_FLAG_LAST,
+} virHostValidateCPUFlag;
+
+VIR_ENUM_DECL(virHostValidateCPUFlag);
+
extern void virHostMsgSetQuiet(bool quietFlag);
extern void virHostMsgCheck(const char *prefix,
@@ -53,7 +64,7 @@ extern int virHostValidateDeviceAccessible(const char *hvname,
virHostValidateLevel level,
const char *hint);
-extern bool virHostValidateHasCPUFlag(const char *name);
+extern virBitmapPtr virHostValidateGetCPUFlags(void);
extern int virHostValidateLinuxKernel(const char *hvname,
int version,
diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qemu.c
index a9f6c1e..b96b020 100644
--- a/tools/virt-host-validate-qemu.c
+++ b/tools/virt-host-validate-qemu.c
@@ -24,14 +24,20 @@
#include "virt-host-validate-qemu.h"
#include "virt-host-validate-common.h"
+#include "virbitmap.h"
int virHostValidateQEMU(void)
{
+ virBitmapPtr flags;
int ret = 0;
virHostMsgCheck("QEMU", "%s", ("for hardware virtualization"));
- if (virHostValidateHasCPUFlag("svm") ||
- virHostValidateHasCPUFlag("vmx")) {
+
+ flags = virHostValidateGetCPUFlags();
+
+ if (flags &&
+ (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) ||
+ virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))) {
virHostMsgPass();
if (virHostValidateDeviceExists("QEMU", "/dev/kvm",
VIR_HOST_VALIDATE_FAIL,
@@ -48,6 +54,8 @@ int virHostValidateQEMU(void)
_("Only emulated CPUs are available, performance will be significantly limited"));
}
+ virBitmapFree(flags);
+
if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net",
VIR_HOST_VALIDATE_WARN,
_("Load the 'vhost_net' module to improve performance "
--
2.5.5
8 years, 7 months
[libvirt] [PATCH] qemu: Check for gnutls_rnd() explicitly
by Andrea Bolognani
Our use of gnutls_rnd() is conditional to the availability of
the <gnutls/crypto.h> header file.
Such check, however, turns out not to be strict enough as there
are some versions of gnutls (eg. 2.8.5 as available in CentOS 6)
that provide the header file, but not the function itself, which
was introduced in 2.12.0.
Introduce an explicit check for the function itself.
---
Would qualify as a build breaker (see [1]) but I'd rather have
some feedback before pushing it.
[1] https://ci.centos.org/view/libvirt-project/job/libvirt-daemon-build/syste...
configure.ac | 4 ++++
src/qemu/qemu_domain.c | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 85fc6e1..360674f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1286,6 +1286,10 @@ if test "x$with_gnutls" != "xno"; then
#include <gnutls/gnutls.h>
]])
+ dnl gnutls_rnd() was introduced in 2.12, so just checking for the
+ dnl corresponding header is not enough: we have to check for it explicitly
+ AC_CHECK_FUNCS([gnutls_rnd])
+
with_gnutls=yes
fi
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fa7cfc9..55dcba8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -635,8 +635,8 @@ qemuDomainGenerateRandomKey(size_t nbytes)
if (VIR_ALLOC_N(key, nbytes) < 0)
return NULL;
-#if HAVE_GNUTLS_CRYPTO_H
- /* Generate a master key using gnutls if possible */
+#if HAVE_GNUTLS_RND
+ /* Generate a master key using gnutls_rnd() if possible */
if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to generate master key, ret=%d"), ret);
@@ -644,7 +644,7 @@ qemuDomainGenerateRandomKey(size_t nbytes)
return NULL;
}
#else
- /* If we don't have gnutls, we will generate a less cryptographically
+ /* If we don't have gnutls_rnd(), we will generate a less cryptographically
* strong master key from /dev/urandom.
*/
if ((ret = virRandomBytes(key, nbytes)) < 0) {
--
2.5.5
8 years, 7 months
[libvirt] [PATCH] qemu: perf: Fix crash/memory corruption on failed VM start
by Peter Krempa
The new perf code didn't bother to clear a pointer in 'priv' causing a
double free or other memory corruption goodness if a VM failed to start.
Clear the pointer after freeing the memory.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757
---
src/qemu/qemu_process.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2b600c1..6c870f5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3444,6 +3444,7 @@ qemuDomainPerfRestart(virDomainObjPtr vm)
cleanup:
virPerfFree(priv->perf);
+ priv->perf = NULL;
return -1;
}
@@ -5970,6 +5971,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
virCgroupFree(&priv->cgroup);
virPerfFree(priv->perf);
+ priv->perf = NULL;
qemuProcessRemoveDomainStatus(driver, vm);
--
2.8.0
8 years, 7 months
[libvirt] [PATCH 0/3] vz: add boot order support
by Nikolay Shirokovskiy
Let's add support for old school boot order via xml os section.
Nikolay Shirokovskiy (3):
vz: support boot order specification on define domain
vz: fix disk order on load domain
vz: support boot order in domain xml dump
src/vz/vz_sdk.c | 390 +++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 341 insertions(+), 49 deletions(-)
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH] util: move ENODATA redefine to virutil.h
by Roman Bogorodskiy
FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO. However,
now we have virrandom.c that's using ENODATA also, so move this
re-definition to a common place, virutil.h, so it could fix things for
both consumers.
---
src/util/virutil.h | 4 ++++
src/util/viruuid.c | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/util/virutil.h b/src/util/virutil.h
index b121de0..36ed186 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -36,6 +36,10 @@
# define MAX(a, b) ((a) > (b) ? (a) : (b))
# endif
+# ifndef ENODATA
+# define ENODATA EIO
+# endif
+
int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK;
int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK;
diff --git a/src/util/viruuid.c b/src/util/viruuid.c
index 1fcc954..16e57db 100644
--- a/src/util/viruuid.c
+++ b/src/util/viruuid.c
@@ -46,10 +46,6 @@
VIR_LOG_INIT("util.uuid");
-#ifndef ENODATA
-# define ENODATA EIO
-#endif
-
static unsigned char host_uuid[VIR_UUID_BUFLEN];
static int
--
2.7.4
8 years, 7 months
[libvirt] [PATCH 0/2] Fix alias asignment code for hotplugged RNGs/memory
by Peter Krempa
I messed up the original impl and then copied it to memory devices. Sigh.
Peter Krempa (2):
qemu: alias: Fix calculation of RNG device aliases
qemu: alias: Fix calculation of memory device aliases
src/qemu/qemu_alias.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_alias.h | 7 ++++++-
src/qemu/qemu_hotplug.c | 4 ++--
3 files changed, 53 insertions(+), 5 deletions(-)
--
2.8.0
8 years, 7 months
[libvirt] [PATCH] nss: Simplify move_and_align
by Michal Privoznik
What this function does can be written much shorter.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/nss/libvirt_nss.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index de34baf..587b171 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -263,12 +263,10 @@ move_and_align(void *buf, size_t len, size_t *idx)
char *buffer = buf;
size_t move = LIBVIRT_ALIGN(len);
- if (!idx)
- return buffer + move;
+ if (idx)
+ *idx += move;
- *idx += move;
-
- return buffer + *idx;
+ return buffer + move;
}
enum nss_status
--
2.7.3
8 years, 7 months