[libvirt] [PATCH 0/2] libxl: suspend-related fixes
by Jim Fehlig
Commit d00c77ae introduced a regression in save and migration operations
of persisent domains. E.g. after a successful migration the source host
showes the migrated domain in state "pmsuspended" instead of "shut off".
Fix it by reverting the commit and setting the state after a successful
call to the underlying libxl API.
Jim Fehlig (2):
Revert "libxl: send lifecycle event on suspend"
libxl: send lifecycle event on PMSuspend
src/libxl/libxl_domain.c | 19 ++++++++-----------
src/libxl/libxl_driver.c | 6 ++++++
2 files changed, 14 insertions(+), 11 deletions(-)
--
2.22.0
5 years, 4 months
[libvirt] [PATCH] conf: resctrl object is not properly handled
by Wang Huaqiang
resctrl object stored in def->resctrls is shared by cachetune and
memorytune. The domain xml configuration is parsed firstly for
cachetune then memorytune, and the resctrl object will not be created
in parsing settings for memorytune once it found sharing exists.
But resctrl is improperly freed when sharing happens.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/conf/domain_conf.c | 12 +++++-------
tests/genericxml2xmlindata/memorytune.xml | 4 ++++
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 617ccac..604e006 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19590,7 +19590,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
ssize_t i = 0;
int n;
- int ret = -1;
ctxt->node = node;
@@ -19632,14 +19631,13 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
return -1;
- if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)
- goto cleanup;
+ if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) {
+ virDomainResctrlDefFree(resctrl);
+ return -1;
+ }
}
- ret = 0;
- cleanup:
- virDomainResctrlDefFree(resctrl);
- return ret;
+ return 0;
}
diff --git a/tests/genericxml2xmlindata/memorytune.xml b/tests/genericxml2xmlindata/memorytune.xml
index ea03e22..7486b54 100644
--- a/tests/genericxml2xmlindata/memorytune.xml
+++ b/tests/genericxml2xmlindata/memorytune.xml
@@ -5,6 +5,10 @@
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>4</vcpu>
<cputune>
+ <cachetune vcpus='0-1'>
+ <cache id='0' level='3' type='both' size='768' unit='KiB'/>
+ <cache id='1' level='3' type='both' size='768' unit='KiB'/>
+ </cachetune>
<memorytune vcpus='0-1'>
<node id='0' bandwidth='20'/>
<node id='1' bandwidth='30'/>
--
2.7.4
5 years, 4 months
[libvirt] [PATCH v2] tools: console: Relax stream EOF handling
by Roman Bolshakov
Regular VM shutdown triggers the error for existing session of virsh
console and it returns with non-zero exit code:
error: internal error: console stream EOF
The message and status code are misleading because there's no real
error. virStreamRecv returns 0 when the end of the stream is reached.
In that case, virStreamFinish should be used to get confirmation of
stream completion. virSteramAbort is used otherwise to terminate the
stream early before an EOF.
Fixes: 29f2b5248c6 ("tools: console: pass stream/fd errors to user")
Signed-off-by: Roman Bolshakov <r.bolshakov(a)yadro.com>
---
Changes since v1:
- Added needAbort parameter to virConsoleShutdown to specify if finish
or abort is needed
- Use it (needAbort = false) to finish stream after EOF from
virStreamRecv
- Print internal error if virStreamFinish or virStreamAbort do not
succeed
tools/virsh-console.c | 44 ++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index e16f841e57..ad514a99a7 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -97,7 +97,7 @@ virConsoleHandleSignal(int sig ATTRIBUTE_UNUSED)
static void
-virConsoleShutdown(virConsolePtr con)
+virConsoleShutdown(virConsolePtr con, bool needAbort)
{
virErrorPtr err = virGetLastError();
@@ -105,8 +105,15 @@ virConsoleShutdown(virConsolePtr con)
virCopyLastError(&con->error);
if (con->st) {
+ int termError;
virStreamEventRemoveCallback(con->st);
- virStreamAbort(con->st);
+ if (needAbort)
+ termError = virStreamAbort(con->st);
+ else
+ termError = virStreamFinish(con->st);
+ if (termError < 0)
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("cannot terminate console stream"));
virStreamFree(con->st);
con->st = NULL;
}
@@ -158,7 +165,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (avail < 1024) {
if (VIR_REALLOC_N(con->streamToTerminal.data,
con->streamToTerminal.length + 1024) < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
con->streamToTerminal.length += 1024;
@@ -172,11 +179,10 @@ virConsoleEventOnStream(virStreamPtr st,
if (got == -2)
goto cleanup; /* blocking */
if (got <= 0) {
+ bool needAbort = true;
if (got == 0)
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("console stream EOF"));
-
- virConsoleShutdown(con);
+ needAbort = false;
+ virConsoleShutdown(con, needAbort);
goto cleanup;
}
con->streamToTerminal.offset += got;
@@ -195,7 +201,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (done == -2)
goto cleanup; /* blocking */
if (done < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
memmove(con->terminalToStream.data,
@@ -216,7 +222,7 @@ virConsoleEventOnStream(virStreamPtr st,
if (events & VIR_STREAM_EVENT_ERROR ||
events & VIR_STREAM_EVENT_HANGUP) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
}
cleanup:
@@ -246,7 +252,7 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (avail < 1024) {
if (VIR_REALLOC_N(con->terminalToStream.data,
con->terminalToStream.length + 1024) < 0) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
con->terminalToStream.length += 1024;
@@ -260,17 +266,17 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (got < 0) {
if (errno != EAGAIN) {
virReportSystemError(errno, "%s", _("cannot read from stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
}
goto cleanup;
}
if (got == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
if (con->terminalToStream.data[con->terminalToStream.offset] == con->escapeChar) {
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
@@ -283,13 +289,13 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
if (events & VIR_EVENT_HANDLE_ERROR) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IO error on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
if (events & VIR_EVENT_HANDLE_HANGUP) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdin"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
@@ -322,7 +328,7 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
if (done < 0) {
if (errno != EAGAIN) {
virReportSystemError(errno, "%s", _("cannot write to stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
}
goto cleanup;
}
@@ -344,13 +350,13 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
if (events & VIR_EVENT_HANDLE_ERROR) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IO error stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
if (events & VIR_EVENT_HANDLE_HANGUP) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF on stdout"));
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
goto cleanup;
}
@@ -489,7 +495,7 @@ virshRunConsole(vshControl *ctl,
ret = 0;
cleanup:
- virConsoleShutdown(con);
+ virConsoleShutdown(con, true);
if (ret < 0) {
vshResetLibvirtError();
--
2.22.0
5 years, 4 months
[libvirt] [PATCH] ci: Adapt to container name changes
by Andrea Bolognani
Since libvirt-dockerfile's commit 7130ffe0a0e9, the containers
used for CI builds have been renamed from buildenv-* to
buildenv-libvirt-* in order to make it possible for projects
other than libvirt to be supported, so we need to update our
Makefile.ci scaffolding accordingly.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
This is connected to
https://www.redhat.com/archives/libvir-list/2019-August/msg00399.html
https://www.redhat.com/archives/libvir-list/2019-August/msg00416.html
and should only be merged once the above have been merged *and*
deployed, as in, images with the new names have been generated.
Makefile.ci | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.ci b/Makefile.ci
index 8857c953b2..dddd438a98 100644
--- a/Makefile.ci
+++ b/Makefile.ci
@@ -49,7 +49,7 @@ CI_SUBMODULES = $(shell git submodule | awk '{ print $$2 }')
# Location of the container images we're going to pull
# Can be useful to overridde to use a locally built
# image instead
-CI_IMAGE_PREFIX = quay.io/libvirt/buildenv-
+CI_IMAGE_PREFIX = quay.io/libvirt/buildenv-libvirt-
# The default tag is ':latest' but if the container
# repo above uses different conventions this can override it
--
2.21.0
5 years, 4 months
[libvirt] [PATCH] tests: fix #ifdef indentation from previous commit
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed under the brown paper bag rule :-(
tests/virpcimock.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index e9a3791aea..c0dcd377d5 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -32,9 +32,9 @@
static int (*real_access)(const char *path, int mode);
static int (*real_open)(const char *path, int flags, ...);
-#ifdef __GLIBC__
+# ifdef __GLIBC__
static int (*real___open_2)(const char *path, int flags);
-#endif /* ! __GLIBC__ */
+# endif /* ! __GLIBC__ */
static int (*real_close)(int fd);
static DIR * (*real_opendir)(const char *name);
static char *(*real_virFileCanonicalizePath)(const char *path);
@@ -957,9 +957,9 @@ init_syms(void)
VIR_MOCK_REAL_INIT(access);
VIR_MOCK_REAL_INIT(open);
-#ifdef __GLIBC__
+# ifdef __GLIBC__
VIR_MOCK_REAL_INIT(__open_2);
-#endif /* ! __GLIBC__ */
+# endif /* ! __GLIBC__ */
VIR_MOCK_REAL_INIT(close);
VIR_MOCK_REAL_INIT(opendir);
VIR_MOCK_REAL_INIT(virFileCanonicalizePath);
@@ -1088,7 +1088,7 @@ open(const char *path, int flags, ...)
}
-#ifdef __GLIBC__
+# ifdef __GLIBC__
/* in some cases this function may not be present in headers, so we need
* a declaration to silence the complier */
int
@@ -1118,7 +1118,7 @@ __open_2(const char *path, int flags)
return ret;
}
-#endif /* ! __GLIBC__ */
+# endif /* ! __GLIBC__ */
DIR *
opendir(const char *path)
--
2.21.0
5 years, 4 months
[libvirt] [PATCH] tests: don't try to mock __open_2 on non-GLibc builds
by Daniel P. Berrangé
Mocking of the __open_2 function was added in
commit 459f071cacf30af9df93b7d090b1bda71b0ef20f
Author: Michal Privoznik <mprivozn(a)redhat.com>
Date: Thu Aug 15 16:37:17 2019 +0200
virpcimock: Mock __open_2()
This function only exists in glibc, however, and the mocking code runs
on systems not using glibc, such as FreeBSD. Even Linux hosts might be
using a different libc impl, though we don't actively try to support
that.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a CI build fix for FreeBSD
tests/virpcimock.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index ca6cc060fd..e9a3791aea 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -32,7 +32,9 @@
static int (*real_access)(const char *path, int mode);
static int (*real_open)(const char *path, int flags, ...);
+#ifdef __GLIBC__
static int (*real___open_2)(const char *path, int flags);
+#endif /* ! __GLIBC__ */
static int (*real_close)(int fd);
static DIR * (*real_opendir)(const char *name);
static char *(*real_virFileCanonicalizePath)(const char *path);
@@ -955,7 +957,9 @@ init_syms(void)
VIR_MOCK_REAL_INIT(access);
VIR_MOCK_REAL_INIT(open);
+#ifdef __GLIBC__
VIR_MOCK_REAL_INIT(__open_2);
+#endif /* ! __GLIBC__ */
VIR_MOCK_REAL_INIT(close);
VIR_MOCK_REAL_INIT(opendir);
VIR_MOCK_REAL_INIT(virFileCanonicalizePath);
@@ -1084,6 +1088,7 @@ open(const char *path, int flags, ...)
}
+#ifdef __GLIBC__
/* in some cases this function may not be present in headers, so we need
* a declaration to silence the complier */
int
@@ -1113,7 +1118,7 @@ __open_2(const char *path, int flags)
return ret;
}
-
+#endif /* ! __GLIBC__ */
DIR *
opendir(const char *path)
--
2.21.0
5 years, 4 months
[libvirt] [PATCHv2 00/11] util/resctrl cleanups and refactors
by Wang Huaqiang
Patches submitted for purpose of refactoring existing 'resctrl' related
source code, including some code cleanups as well as some fixes. This is
also a preparation for memory bandwidth monitor codes.
Plan to support Resctrl Control Monitors, which is a feature introduced
by kernel 'resctrl' sub-model. Submit some cleanup and refactoring patches
for upcoming memory bandwidth resource monitoring (MBM) monitors.
Related MBM RFC is
https://www.redhat.com/archives/libvir-list/2019-April/msg01409.html.
This RFC is not actively discussed since libvirt already implemented similar
resctrl cache monitoring (CMT), and lots details have been discussed
and implemented during the work of CMT.
The cleanups and refactoring includes:
v2 changes:
1. Addressed comments of v1.
2. Introduce a new algorithm for verifying new monitor vcpus and existing
monitors and allocations.
3. Fixes for creating default-allocation-monitor in 'resctrl' file
system.(patch 0001).
v1 changes:
1. Removing some reluctant lines and white spaces that is existing
in current code and not meet the libvirt coding style.
2. Replace 'virResctrlAllocIsEmpty' with @n==0 for indicating no
resctrl allocation in configuration file.
3. Private API changes, removed 'virResctrlMonitorGetCacheOccupancy'
and exported a new API named 'virResctrlMonitorGetStats' with similar
functionality, but with capability to be used for retrieving MBM
statistical information.
4. Refactoring 'virResctrlMonitorFreeStats' for more reusing in code.
5. Extend data structure 'virResctrlMonitorStats' with the capability
to carry multiple statistical information from monitor.
Wang Huaqiang (11):
util,conf: Handle default monitor group of an allocation properly
conf: code cleanup, remove empty line and one space
conf: code cleanup for return error code directly
conf: some code cleanup
conf: refactor 'virDomainResctrlVcpuMatch' and some code cleanup
conf: Append 'resctrl' object according to number of monitor group
directly
util: Refactor and rename 'virResctrlMonitorFreeStats'
util: Refactor 'virResctrlMonitorStats'
util: Extend virresctl API to retrieve multiple monitor statistics
util: Remove unused virResctrlMonitorGetCacheOccupancy
conf: Refactor and rename the function to validate a new resctrl
monitor
src/conf/domain_conf.c | 145 ++++++++++++++++++++++++-----------------------
src/libvirt_private.syms | 5 +-
src/qemu/qemu_driver.c | 41 ++++++++++----
src/qemu/qemu_process.c | 3 +-
src/util/virresctrl.c | 75 ++++++++++--------------
src/util/virresctrl.h | 23 +++++---
6 files changed, 156 insertions(+), 136 deletions(-)
--
2.7.4
5 years, 4 months
[libvirt] [jenkins-ci PATCH] guests: remove obsolete install of intltool
by Daniel P. Berrangé
libvirt-glib, libvirt-sandbox and virt-viewer have all ditched usage
of intltool, so this no longer needs to be installed.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
guests/vars/projects/libvirt-glib.yml | 1 -
guests/vars/projects/libvirt-sandbox.yml | 1 -
guests/vars/projects/virt-viewer.yml | 1 -
3 files changed, 3 deletions(-)
diff --git a/guests/vars/projects/libvirt-glib.yml b/guests/vars/projects/libvirt-glib.yml
index 13a5128..baa5b6a 100644
--- a/guests/vars/projects/libvirt-glib.yml
+++ b/guests/vars/projects/libvirt-glib.yml
@@ -3,6 +3,5 @@ packages:
- glib2
- gobject-introspection
- gtk-doc
- - intltool
- libxml2
- vala
diff --git a/guests/vars/projects/libvirt-sandbox.yml b/guests/vars/projects/libvirt-sandbox.yml
index 46b903f..f444333 100644
--- a/guests/vars/projects/libvirt-sandbox.yml
+++ b/guests/vars/projects/libvirt-sandbox.yml
@@ -4,7 +4,6 @@ packages:
- glibc-static
- gobject-introspection
- gtk-doc
- - intltool
- libcap-ng
- libselinux
- libxml2
diff --git a/guests/vars/projects/virt-viewer.yml b/guests/vars/projects/virt-viewer.yml
index cd32176..c03d50b 100644
--- a/guests/vars/projects/virt-viewer.yml
+++ b/guests/vars/projects/virt-viewer.yml
@@ -3,7 +3,6 @@ packages:
- glib2
- gtk-vnc2
- gtk3
- - intltool
- libgovirt
- libxml2
- spice-gtk3
--
2.21.0
5 years, 4 months
[libvirt] [PATCH] ci: Comment tweaks in Makefile.ci
by Eric Blake
Fix some typos and grammar (calling something safer and error-prone is
odd, and 'ther eneeds' is an obvious typo), and reflow some long
lines.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Makefile.ci | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/Makefile.ci b/Makefile.ci
index 8857c953b2..df2195ea72 100644
--- a/Makefile.ci
+++ b/Makefile.ci
@@ -86,7 +86,7 @@ endif
# is liable to mess with SELinux labelling which will
# then prevent the host accessing them. And podman cannot
# relabel the files due to it running rootless. So
-# copying them first is safer and error-prone.
+# copying them first is safer and less error-prone.
CI_PWDB_MOUNTS = \
--volume $(CI_SCRATCHDIR)/group:/etc/group:ro,z \
--volume $(CI_SCRATCHDIR)/passwd:/etc/passwd:ro,z \
@@ -98,22 +98,26 @@ CI_PWDB_MOUNTS = \
CI_ULIMIT_FILES = 1024
ifeq ($(CI_ENGINE),podman)
- # Podman cannot reuse host namespace when running non-root containers. Until
- # support for --keep-uid is added we can just create another mapping that will
- # do that for us. Beware, that in {uid,git}map=container_id:host_id:range,
- # the host_id does actually refer to the uid in the first mapping where 0
- # (root) is mapped to the current user and rest is offset.
-
- # In order to set up this mapping, we need to keep all the user IDs to prevent
- # possible errors as some images might expect UIDs up to 90000 (looking at you
- # fedora), so we don't want the overflowuid to be used for them. For mapping
- # all the other users properly ther eneeds to be some math done. Don't worry,
- # it's just addition and subtraction.
-
- # 65536 ought to be enough (tm), but for really rare cases the maximums might
- # need to be higher, but that only happens when your /etc/sub{u,g}id allow
- # users to have more IDs. Unless --keep-uid is supported, let's do this in a
- # way that should work for everyone.
+ # Podman cannot reuse host namespace when running non-root
+ # containers. Until support for --keep-uid is added we can
+ # just create another mapping that will do that for us.
+ # Beware, that in {uid,git}map=container_id:host_id:range, the
+ # host_id does actually refer to the uid in the first mapping
+ # where 0 (root) is mapped to the current user and rest is
+ # offset.
+ #
+ # In order to set up this mapping, we need to keep all the
+ # user IDs to prevent possible errors as some images might
+ # expect UIDs up to 90000 (looking at you fedora), so we don't
+ # want the overflowuid to be used for them. For mapping all
+ # the other users properly, some math needs to be done.
+ # Don't worry, it's just addition and subtraction.
+ #
+ # 65536 ought to be enough (tm), but for really rare cases the
+ # maximums might need to be higher, but that only happens when
+ # your /etc/sub{u,g}id allow users to have more IDs. Unless
+ # --keep-uid is supported, let's do this in a way that should
+ # work for everyone.
CI_MAX_UID = $(shell sed -n "s/^$USER:[^:]\+://p" /etc/subuid)
CI_MAX_GID = $(shell sed -n "s/^$USER:[^:]\+://p" /etc/subgid)
ifeq ($(CI_MAX_UID),)
--
2.20.1
5 years, 4 months