[libvirt] [PATCH v2] build: fix build with libselinux 2.3
by Cédric Bosdonnat
Several function signatures changed in libselinux 2.3, now taking
a 'const char *' instead of 'security_context_t'. The latter is
defined in selinux/selinux.h as
typedef char *security_context_t;
---
m4/virt-selinux.m4 | 18 ++++++++++++++++++
tests/securityselinuxhelper.c | 16 ++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/m4/virt-selinux.m4 b/m4/virt-selinux.m4
index 003c2a8..c299793 100644
--- a/m4/virt-selinux.m4
+++ b/m4/virt-selinux.m4
@@ -28,6 +28,24 @@ AC_DEFUN([LIBVIRT_CHECK_SELINUX],[
[with_selinux_mount=check])
if test "$with_selinux" = "yes"; then
+ AC_CACHE_CHECK([for selinux setcon parameter type], [gt_cv_setcon_param],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+#include <selinux/selinux.h>
+
+int setcon(const security_context_t context) {
+ return 0;
+}
+ ]],
+ [[]])],
+ [gt_cv_setcon_param='security_context'],
+ [gt_cv_setcon_param='const char*'])])
+ if test "$gt_cv_setcon_param" = 'const char*'; then
+ AC_DEFINE_UNQUOTED([SELINUX_CTX_CHAR_PTR], 1,
+ [SELinux uses char * for security context])
+ fi
+
AC_MSG_CHECKING([SELinux mount point])
if test "$with_selinux_mount" = "check" || test -z "$with_selinux_mount"; then
if test -d /sys/fs/selinux ; then
diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c
index dbc4c29..af4fae4 100644
--- a/tests/securityselinuxhelper.c
+++ b/tests/securityselinuxhelper.c
@@ -156,7 +156,11 @@ int getpidcon(pid_t pid, security_context_t *context)
return getpidcon_raw(pid, context);
}
+#ifdef SELINUX_CTX_CHAR_PTR
+int setcon_raw(const char *context)
+#else
int setcon_raw(security_context_t context)
+#endif
{
if (!is_selinux_enabled()) {
errno = EINVAL;
@@ -165,13 +169,21 @@ int setcon_raw(security_context_t context)
return setenv("FAKE_SELINUX_CONTEXT", context, 1);
}
+#ifdef SELINUX_CTX_CHAR_PTR
+int setcon(const char *context)
+#else
int setcon(security_context_t context)
+#endif
{
return setcon_raw(context);
}
+#ifdef SELINUX_CTX_CHAR_PTR
+int setfilecon_raw(const char *path, const char *con)
+#else
int setfilecon_raw(const char *path, security_context_t con)
+#endif
{
const char *constr = con;
if (STRPREFIX(path, abs_builddir "/securityselinuxlabeldata/nfs/")) {
@@ -182,7 +194,11 @@ int setfilecon_raw(const char *path, security_context_t con)
constr, strlen(constr), 0);
}
+#ifdef SELINUX_CTX_CHAR_PTR
+int setfilecon(const char *path, const char *con)
+#else
int setfilecon(const char *path, security_context_t con)
+#endif
{
return setfilecon_raw(path, con);
}
--
1.8.4.5
10 years, 6 months
[libvirt] [PATCH] Managed-Save: False warning on successful managed save restoration
by Jason J. Herne
From: "Jason J. Herne" <jjherne(a)us.ibm.com>
qemuDomainObjStart is checking the return code from qemuDomainObjRestore for
errors even after determining that the return code is 0. This causes the
following error message to appear even when the restore was successful.
Unable to restore from managed state [path]. Maybe the file is corrupted?
A simple conditional to handle the error case takes care of the problem.
Signed-off-by: Jason J. Herne <jjherne(a)us.ibm.com>
---
src/qemu/qemu_driver.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2b852eb..cec2b6c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6081,14 +6081,15 @@ qemuDomainObjStart(virConnectPtr conn,
else
vm->hasManagedSave = false;
}
-
- if (ret > 0) {
- VIR_WARN("Ignoring incomplete managed state %s", managed_save);
- } else {
- VIR_WARN("Unable to restore from managed state %s. "
- "Maybe the file is corrupted?", managed_save);
- goto cleanup;
+ else {
+ if (ret > 0) {
+ VIR_WARN("Ignoring incomplete managed state %s", managed_save);
+ } else {
+ VIR_WARN("Unable to restore from managed state %s. "
+ "Maybe the file is corrupted?", managed_save);
+ }
}
+ goto cleanup;
}
}
--
1.8.3.2
10 years, 6 months
[libvirt] [PATCH] qemu: managedsave: Don't spam logs with warnings about corrupted image
by Peter Krempa
Even successful start of a VM from a managed save image would spam the
logs with the following message:
Unable to restore from managed state [path]. Maybe the file is
corrupted?
Re-arrange the logic to output the warning only when the image is
corrupted.
The flaw was introduced in commit cfc28c66.
---
src/qemu/qemu_driver.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2b852eb..7a29b82 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6080,14 +6080,14 @@ qemuDomainObjStart(virConnectPtr conn,
VIR_WARN("Failed to remove the managed state %s", managed_save);
else
vm->hasManagedSave = false;
- }
- if (ret > 0) {
- VIR_WARN("Ignoring incomplete managed state %s", managed_save);
- } else {
+ goto cleanup;
+ } else if (ret < 0) {
VIR_WARN("Unable to restore from managed state %s. "
"Maybe the file is corrupted?", managed_save);
goto cleanup;
+ } else {
+ VIR_WARN("Ignoring incomplete managed state %s", managed_save);
}
}
}
--
1.9.3
10 years, 6 months
[libvirt] [PATCH 0/3] Fix startup of gluster pools
by Peter Krempa
Currently a gluster pool fails to start due to an attempt to canonicalize a
path residing on gluster storage. This series rearranges things to avoid that.
Peter Krempa (3):
storage: Return backing format from virStorageFileGetMetadataFromFD
storage: fs: Drop-in replace use of virStorageFileGetMetadataFromBuf
utils: storage: Canonicalize paths only for local filesystems
src/qemu/qemu_driver.c | 2 +-
src/storage/storage_backend_fs.c | 20 +++++++-------------
src/util/virstoragefile.c | 27 +++++++++++++++------------
src/util/virstoragefile.h | 3 ++-
4 files changed, 25 insertions(+), 27 deletions(-)
--
1.9.3
10 years, 6 months
[libvirt] [PATCH] qemu: reject rather than hang on blockcommit of active layer
by Eric Blake
qemu 2.0 added the ability to commit the active layer, but slightly
differently than what libvirt had been anticipating in its
implementation of the virDomainBlockCommit call. As a result, if
you attempt to do a 'virsh blockcommit $dom vda', qemu gets into a
state where it is waiting on libvirt to end the job, while libvirt
is waiting on qemu to end the job, and the guest is effectively
hung with regards to further commands for that block device.
I have patches coming down the pipeline that will add full support
for blockcommit of the active layer when coupled with qemu 2.0 or
later; but they depend on Peter's improvements to block job handling
and form enough of a new feature that they are not ready for
inclusion in the 1.2.5 release. So for now, just reject the
attempt, rather than letting the user get stuck. This is no worse
than the behavior of qemu 1.7 rejecting the job.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Reject active
commit.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
This patch should be committed before the 1.2.5 release, while
I continue to polish my full series for active commit support
for inclusion after the release.
src/qemu/qemu_driver.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2b852eb..f008763 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15461,6 +15461,15 @@ qemuDomainBlockCommit(virDomainPtr dom,
&top_parent)))
goto endjob;
+ /* FIXME: qemu 2.0 supports active commit, but as a two-stage
+ * process; qemu 2.1 is further improving active commit. We need
+ * to start support it in libvirt. */
+ if (topSource == &disk->src) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("committing the active layer not supported yet"));
+ goto endjob;
+ }
+
if (!topSource->backingStore) {
virReportError(VIR_ERR_INVALID_ARG,
_("top '%s' in chain for '%s' has no backing file"),
--
1.9.3
10 years, 6 months
[libvirt] xl and libvirt.
by Alvin Starr
I have been trying do some simulations of an openstack environment on my
workstation that is running xen and libvirt.
I managed to create nested HVM environments under lx but found a number
of shortfalls in libxl code.
I have added a nestedhvm as a domain feature and was looking at
inspecting the domain configuration when I realized that the persistant
data is keept in config files in /var/lib/xen/userdata.....
Libvirt and lx have incompatible file names and are using different
config formats.
Libvirt keeps the data as XML and xl keeps them as xm config files.
This means that libvirt domains cannot be manged with xl or xl domains
managed by libvirt.
Part of me thinks that sticking with the XL file format would be nice
from the point of view of being able to use xenlight tools once the
domain is configured.
At the very least it may make sense to keep an XL copy of the config
file in a format that xenlight can use.
To achieve my original goal of managing a nested HVM environment from
libvirt I need to get the CPUID flags working but I do believe that it
would be nice to have the various xen and libvirt tools being able to
talk to each other.
Any pearls of wisdom would be greatly appreciated.
--
Alvin Starr || voice: (905)513-7688
Netvel Inc. || Cell: (416)806-0133
alvin(a)netvel.net ||
10 years, 6 months
[libvirt] [PATCH 0/5] [RFC] Add support for per-guest-node binding
by Martin Kletzander
Currently we are only able to bind the whole domain to some host nodes
using the /domain/numatune/memory element. Numerous requests were
made to support host<->guest numa node bindings, so this series tries
to pinch an idea on how to do that using /domain/numatune/memnode
elements.
So here are few ideas I'd like to know others opinions on:
For some reason, qemu wants to know what host nodes it can use to for
allocation of the memory. While adding support for that, qemu added
various memory objects (-object memory*) with different backends.
There's 'memory-file' which is used for hugepages and 'memory-ram'
which is used for standard allocation. Latest version of the qemu
proposal is here:
http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg02706.html
Caveats:
- I'm not sure how cpu hotplug is done with guest numa nodes, but if
there is a possibility to increase the number of numa nodes (which
does not make sense to me from (a) user point of view and (b) our
XMLs and APIs), we need to be able to hotplug the ram as well,
- virDomainGetNumaParameters() now reflects only the
/domain/numatune/memory settings, not 'memnode' ones,
- virDomainSetNumaParameters() is not allowed when there is some
/domain/numatune/memnode parameter as we can query memdev info, but
not change it (if I understood the QEMU side correctly),
- when domain is started, cpuset.mems cgroup is not modified per for
each vcpu, this will be fixed, but the question is how to handle it
for non-strict settings [*],
- automatic numad placement can be now used together with memnode
settings which IMHO doesn't make any sense, but I was hesitant to
disable that in case somebody has a constructive criticism in this
area.
- This series alone is broken when used with
/domain/memoryBacking/hugepages, because it will still use the
memory-ram object, but that will be fixed with Michal's patches on
top of this series.
One idea how to solve some of the problems is to say that
/domain/numatune/memory is set for the whole domain regardless of what
anyone puts in /domain/numatune/memnode. virDomainGetNumaParameters()
could be extended to tell the info for all guest numa nodes, although
it seems new API would suit better for this kind of information. But
is it really neede when we are not able to modify it live and the
information is available in the domain XML?
*) does (or should) this:
...
<numatune>
<memory mode='strict' placement='static' nodeset='0-7'/>
<memnode nodeid='0' mode='preferred' nodeset='7'/>
</numatune>
...
mean what it looks like it means, that is "in guest node 0, prefer
allocating from host node 7 but feel free to allocate from 0-6 as well
in case you can't use 7, but never try allocating from host nodes
8-15"?
Martin Kletzander (5):
conf, schema: add 'id' field for cells
conf, schema: add support for numatune memnode element
qemu: purely a code movement
qemu: numa capability probing
qemu: pass numa node binding preferences to qemu
docs/formatdomain.html.in | 29 +++-
docs/schemas/domaincommon.rng | 22 +++
src/conf/cpu_conf.c | 39 ++++-
src/conf/domain_conf.c | 181 +++++++++++++++++----
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_cgroup.c | 2 +
src/qemu/qemu_command.c | 160 ++++++++++++++++--
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_domain.c | 23 ++-
src/qemu/qemu_driver.c | 14 +-
src/qemu/qemu_process.c | 3 +-
src/util/virnuma.h | 14 +-
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa1.xml | 6 +-
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa2.xml | 6 +-
tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml | 25 +++
.../qemuxml2argv-numatune-auto-prefer.args | 6 +
.../qemuxml2argv-numatune-auto-prefer.xml | 29 ++++
.../qemuxml2argv-numatune-auto.args | 6 +
.../qemuxml2argv-numatune-auto.xml | 26 +++
.../qemuxml2argv-numatune-memnode-nocpu.xml | 25 +++
.../qemuxml2argv-numatune-memnodes-problematic.xml | 31 ++++
.../qemuxml2argv-numatune-memnodes.args | 8 +
.../qemuxml2argv-numatune-memnodes.xml | 31 ++++
.../qemuxml2argv-numatune-prefer.args | 6 +
.../qemuxml2argv-numatune-prefer.xml | 29 ++++
tests/qemuxml2argvtest.c | 51 ++++--
.../qemuxml2xmlout-cpu-numa1.xml | 28 ++++
.../qemuxml2xmlout-cpu-numa2.xml | 28 ++++
tests/qemuxml2xmltest.c | 4 +
tests/qemuxmlnstest.c | 2 +-
31 files changed, 747 insertions(+), 93 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-numa3.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-auto-prefer.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-auto.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-auto.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-memnode-nocpu.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes-problematic.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-memnodes.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-prefer.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-numatune-prefer.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa1.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-numa2.xml
--
1.9.3
10 years, 6 months
[libvirt] [PATCH] doc: fix documentation of virDomainSet(Get)Metadata
by Dan Kenigsberg
The documentation of the functions should match the argument name in the actual
function signature.
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
src/libvirt.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 72a9f6d..f01b6dd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10109,14 +10109,14 @@ virDomainGetSecurityLabelList(virDomainPtr domain,
/**
* virDomainSetMetadata:
* @domain: a domain object
- * @type: type of description, from virDomainMetadataType
+ * @type: type of metadata, from virDomainMetadataType
* @metadata: new metadata text
* @key: XML namespace key, or NULL
* @uri: XML namespace URI, or NULL
* @flags: bitwise-OR of virDomainModificationImpact
*
* Sets the appropriate domain element given by @type to the
- * value of @description. A @type of VIR_DOMAIN_METADATA_DESCRIPTION
+ * value of @metadata. A @type of VIR_DOMAIN_METADATA_DESCRIPTION
* is free-form text; VIR_DOMAIN_METADATA_TITLE is free-form, but no
* newlines are permitted, and should be short (although the length is
* not enforced). For these two options @key and @uri are irrelevant and
@@ -10202,7 +10202,7 @@ virDomainSetMetadata(virDomainPtr domain,
/**
* virDomainGetMetadata:
* @domain: a domain object
- * @type: type of description, from virDomainMetadataType
+ * @type: type of metadata, from virDomainMetadataType
* @uri: XML namespace identifier
* @flags: bitwise-OR of virDomainModificationImpact
*
--
1.9.3
10 years, 6 months
[libvirt] [PATCH] virsh: forbid negative vcpu argument to vcpupin.
by Jincheng Miao
vcpupin will allow argument --vcpu as a signed number,
and pass it to virDomainPinVcpu directlly without
checking if this value is positive(valid).
> virsh vcpupin r7 -1 0
error: numerical overflow: input too large: 4294967295
This message is inaccurate, and the negative vcpu is
non-valuable. So forbid vcpu argument as a negative.
Signed-off-by: Jincheng Miao <jmiao(a)redhat.com>
---
tools/virsh-domain.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 84a6706..d9804cc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5797,7 +5797,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
{
virDomainInfo info;
virDomainPtr dom;
- int vcpu = -1;
+ unsigned int vcpu;
const char *cpulist = NULL;
bool ret = false;
unsigned char *cpumap = NULL;
@@ -5830,29 +5830,25 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
query = !cpulist;
- /* In query mode, "vcpu" is optional */
- if (vshCommandOptInt(cmd, "vcpu", &vcpu) < !query) {
+ /* In query mode, "vcpu" is optional*/
+ if (vshCommandOptUInt(cmd, "vcpu", &vcpu) < !query) {
vshError(ctl, "%s",
_("vcpupin: Invalid or missing vCPU number."));
- virDomainFree(dom);
- return false;
- }
-
- if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) {
- virDomainFree(dom);
- return false;
+ goto cleanup;
}
if (virDomainGetInfo(dom, &info) != 0) {
vshError(ctl, "%s", _("vcpupin: failed to get domain information."));
- virDomainFree(dom);
- return false;
+ goto cleanup;
}
if (vcpu >= info.nrVirtCpu) {
vshError(ctl, "%s", _("vcpupin: Invalid vCPU number."));
- virDomainFree(dom);
- return false;
+ goto cleanup;
+ }
+
+ if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) {
+ goto cleanup;
}
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
--
1.7.1
10 years, 6 months