[libvirt] [PATCH] test_driver: avoid using nerrors unitialized in testDomainGetDiskErrors
by Ilias Stamatis
Right now nerrors can be used unitialized in the last for loop causing
a bug.
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ce4ff1a582..2371581f51 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3275,7 +3275,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
virDomainObjPtr vm = NULL;
int ret = -1;
size_t i;
- size_t nerrors;
+ size_t nerrors = 0;
virCheckFlags(0, -1);
--
2.22.0
5 years, 5 months
[libvirt] [PATCH] test: ensure nerrors variable is initialized
by Daniel P. Berrangé
There is an error path that jumps over the initialization of
nerrors, and the jump target reads the variable contents.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
Pushed as a build fix
src/test/test_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ce4ff1a582..2371581f51 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3275,7 +3275,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
virDomainObjPtr vm = NULL;
int ret = -1;
size_t i;
- size_t nerrors;
+ size_t nerrors = 0;
virCheckFlags(0, -1);
--
2.21.0
5 years, 5 months
[libvirt] [PATCH] test_driver: sanitize user-provided array in testDomainGetDiskErrors
by Ilias Stamatis
Zero out the user provided memory in order to avoid passing random
pointers to VIR_FREE later.
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7c58d2c8ce..8ee1f0cad6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3275,6 +3275,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
virDomainObjPtr vm = NULL;
int ret = -1;
size_t i;
+ size_t nerrors;
virCheckFlags(0, -1);
@@ -3284,8 +3285,13 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
+ nerrors = MIN(vm->def->ndisks, maxerrors);
+
if (errors) {
- for (i = 0; i < MIN(vm->def->ndisks, maxerrors); i++) {
+ /* sanitize input */
+ memset(errors, 0, sizeof(virDomainDiskError) * nerrors);
+
+ for (i = 0; i < nerrors; i++) {
if (VIR_STRDUP(errors[i].disk, vm->def->disks[i]->dst) < 0)
goto cleanup;
errors[i].error = (i % (VIR_DOMAIN_DISK_ERROR_LAST - 1)) + 1;
@@ -3297,7 +3303,7 @@ static int testDomainGetDiskErrors(virDomainPtr dom,
cleanup:
if (ret < 0) {
- for (i = 0; i < MIN(vm->def->ndisks, maxerrors); i++)
+ for (i = 0; i < nerrors; i++)
VIR_FREE(errors[i].disk);
}
virDomainObjEndAPI(&vm);
--
2.22.0
5 years, 5 months
[libvirt] [PATCH] test_driver: Implement virDomainSetPerfEvents
by Ilias Stamatis
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7c58d2c8ce..9974eba882 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3372,6 +3372,69 @@ testDomainGetFSInfo(virDomainPtr dom,
}
+static int
+testDomainSetPerfEvents(virDomainPtr dom,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags)
+{
+ virDomainObjPtr vm = NULL;
+ virDomainDefPtr def = NULL;
+ size_t i;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+ if (virTypedParamsValidate(params, nparams,
+ VIR_PERF_PARAM_CMT, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_MBMT, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_MBML, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CPU_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_INSTRUCTIONS, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CACHE_REFERENCES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CACHE_MISSES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_BRANCH_INSTRUCTIONS, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_BRANCH_MISSES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_BUS_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_STALLED_CYCLES_FRONTEND, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_STALLED_CYCLES_BACKEND, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_REF_CPU_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CPU_CLOCK, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_TASK_CLOCK, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_PAGE_FAULTS, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CONTEXT_SWITCHES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CPU_MIGRATIONS, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_PAGE_FAULTS_MIN, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_PAGE_FAULTS_MAJ, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_ALIGNMENT_FAULTS, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_EMULATION_FAULTS, VIR_TYPED_PARAM_BOOLEAN,
+ NULL) < 0)
+ return -1;
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ return -1;
+
+ if (!(def = virDomainObjGetOneDef(vm, flags)))
+ goto cleanup;
+
+ for (i = 0; i < nparams; i++) {
+ virTypedParameterPtr param = ¶ms[i];
+ virPerfEventType type = virPerfEventTypeFromString(param->field);
+
+ if (param->value.b)
+ def->perf.events[type] = VIR_TRISTATE_BOOL_YES;
+ else
+ def->perf.events[type] = VIR_TRISTATE_BOOL_NO;
+ }
+
+ ret = 0;
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
static int
testDomainGetPerfEvents(virDomainPtr dom,
virTypedParameterPtr *params,
@@ -7410,6 +7473,7 @@ static virHypervisorDriver testHypervisorDriver = {
.domainSetAutostart = testDomainSetAutostart, /* 0.3.2 */
.domainGetDiskErrors = testDomainGetDiskErrors, /* 5.4.0 */
.domainGetFSInfo = testDomainGetFSInfo, /* 5.6.0 */
+ .domainSetPerfEvents = testDomainSetPerfEvents, /* 5.6.0 */
.domainGetPerfEvents = testDomainGetPerfEvents, /* 5.6.0 */
.domainGetSchedulerType = testDomainGetSchedulerType, /* 0.3.2 */
.domainGetSchedulerParameters = testDomainGetSchedulerParameters, /* 0.3.2 */
--
2.22.0
5 years, 5 months
[libvirt] [PULL 0/4] Python queue, 2019-07-01
by Eduardo Habkost
The following changes since commit 7d0e02405fc02a181319b1ab8681d2f72246b7c6:
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-patches-pull-request' into staging (2019-07-01 17:40:32 +0100)
are available in the Git repository at:
git://github.com/ehabkost/qemu.git tags/python-next-pull-request
for you to fetch changes up to e5abf59eae5990296c243202f95f801495c52e76:
Deprecate Python 2 support (2019-07-01 19:02:10 -0300)
----------------------------------------------------------------
Python queue, 2019-07-01
* Deprecate Python 2 support (Eduardo Habkost)
* qemu/__init__.py refactor (John Snow)
* make qmp-shell work with python3 (Igor Mammedov)
----------------------------------------------------------------
Eduardo Habkost (1):
Deprecate Python 2 support
Igor Mammedov (1):
qmp: make qmp-shell work with python3
John Snow (2):
python/qemu: split QEMUMachine out from underneath __init__.py
machine.py: minor delinting
configure | 8 +
scripts/render_block_graph.py | 2 +-
python/qemu/__init__.py | 502 +-------------------
python/qemu/machine.py | 531 ++++++++++++++++++++++
python/qemu/qtest.py | 2 +-
qemu-deprecated.texi | 8 +
scripts/device-crash-test | 2 +-
scripts/qmp/qmp-shell | 5 +-
tests/acceptance/avocado_qemu/__init__.py | 2 +-
tests/acceptance/virtio_version.py | 2 +-
tests/migration/guestperf/engine.py | 24 +-
tests/qemu-iotests/235 | 2 +-
tests/vm/basevm.py | 3 +-
13 files changed, 572 insertions(+), 521 deletions(-)
create mode 100644 python/qemu/machine.py
--
2.18.0.rc1.1.g3f1ff2140
5 years, 5 months
[libvirt] [RFC] test_driver: Thoughts on the implementation of some FS-related APIs
by Ilias Stamatis
Hello,
I was thinking about how to implement the following APIs in the test driver:
-virDomainFSFreeze
-virDomainFSThaw
-virDomainFSTrim
The first two are conceptually paired. They both get a mountpoints
argument. The QEMU driver (which is the only driver implementing this
currently) ignores this completely.
However, I thought that we can allow it and pretend that the only
available mountpoints are "/" and "/boot" (like in a default Fedora
installation). The following questions arise though:
- Should we keep some kind of temporary or permanent state on the test
driver about this? Because it makes sense for virDomainFSThaw to
succeed only on mountpoints for which previously virDomainFSFreeze has
been called. If so, *where* exactly should we keep this state?
- In case a non-existing mountpoint is passed to either of the first 2
APIs. Should we fail? If so, a new error code should be introduced for
this. Also for the cases above where e.g. Thaw is called on a fs that
isn't frozen probably yet another different error code must be used.
Should we add all these new error codes?
Or maybe all the above is more complicated than necessary and it's
fine if we ignore mountpoints completely like the QEMU driver does and
make all 3 APIs above to always succeed no matter what in the test
driver?
Thanks,
Ilias
5 years, 5 months
[libvirt] [PATCH] remote: mention libssh in error message
by Pino Toscano
Mention libssh as possible transport in the error message of an
unrecognized transport.
https://bugzilla.redhat.com/show_bug.cgi?id=1727013
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
src/remote/remote_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index df58b23c8c..97d9d5fa88 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -825,7 +825,7 @@ doRemoteOpen(virConnectPtr conn,
} else {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("remote_open: transport in URL not recognised "
- "(should be tls|unix|ssh|ext|tcp|libssh2)"));
+ "(should be tls|unix|ssh|ext|tcp|libssh2|libssh)"));
return VIR_DRV_OPEN_ERROR;
}
}
--
2.21.0
5 years, 5 months
[libvirt] [PATCH] Revert "lxc: Try harder to stop/reboot containers"
by Daniel P. Berrangé
This reverts commit 14b6a1854fb4c02c5fb2f51679f8ff099f28f53c.
If virLXCDomainSetRunlevel returns -1 this indicates a serious
error / failure that must be propagated to the caller. We must
not carry on with other shutdown methods in this case.
If virLXCDomainSetRunlevel return 0, this indicates that no
initctl was found and it is thus reasonable to fallback to
sending SIGTERM.
The commit being reverted is broken because it would fallback
to SIGTERM when virLXCDomainSetRunlevel returns -1, and would
not fallback when virLXCDomainSetRunlevel returns 0. ie it
did the exact opposite of what was required.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/lxc/lxc_driver.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9db2a02dee..01af5f6db8 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3262,7 +3262,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
virLXCDomainObjPrivatePtr priv;
virDomainObjPtr vm;
int ret = -1;
- int rc = -1;
+ int rc;
virCheckFlags(VIR_DOMAIN_SHUTDOWN_INITCTL |
VIR_DOMAIN_SHUTDOWN_SIGNAL, -1);
@@ -3291,17 +3291,19 @@ lxcDomainShutdownFlags(virDomainPtr dom,
(flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
int command = VIR_INITCTL_RUNLEVEL_POWEROFF;
- if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0) {
- if (flags != 0 &&
- (flags & VIR_DOMAIN_SHUTDOWN_INITCTL)) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("Container does not provide an initctl pipe"));
- goto endjob;
- }
+ if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0)
+ goto endjob;
+ if (rc == 0 && flags != 0 &&
+ ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Container does not provide an initctl pipe"));
+ goto endjob;
}
+ } else {
+ rc = 0;
}
- if (rc < 0 &&
+ if (rc == 0 &&
(flags == 0 ||
(flags & VIR_DOMAIN_SHUTDOWN_SIGNAL))) {
if (kill(priv->initpid, SIGTERM) < 0 &&
@@ -3338,7 +3340,7 @@ lxcDomainReboot(virDomainPtr dom,
virLXCDomainObjPrivatePtr priv;
virDomainObjPtr vm;
int ret = -1;
- int rc = -1;
+ int rc;
virCheckFlags(VIR_DOMAIN_REBOOT_INITCTL |
VIR_DOMAIN_REBOOT_SIGNAL, -1);
@@ -3367,17 +3369,19 @@ lxcDomainReboot(virDomainPtr dom,
(flags & VIR_DOMAIN_REBOOT_INITCTL)) {
int command = VIR_INITCTL_RUNLEVEL_REBOOT;
- if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0) {
- if (flags != 0 &&
- (flags & VIR_DOMAIN_REBOOT_INITCTL)) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("Container does not provide an initctl pipe"));
- goto endjob;
- }
+ if ((rc = virLXCDomainSetRunlevel(vm, command)) < 0)
+ goto endjob;
+ if (rc == 0 && flags != 0 &&
+ ((flags & ~VIR_DOMAIN_SHUTDOWN_INITCTL) == 0)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Container does not provide an initctl pipe"));
+ goto endjob;
}
+ } else {
+ rc = 0;
}
- if (rc < 0 &&
+ if (rc == 0 &&
(flags == 0 ||
(flags & VIR_DOMAIN_REBOOT_SIGNAL))) {
if (kill(priv->initpid, SIGHUP) < 0 &&
--
2.21.0
5 years, 5 months
[libvirt] [PATCH] lxc: Fix reboot via initctl
by Lubomir Rintel
virInitctlSetRunLevel() returns 0 only if ended up doing nothing, 1 if it
actually succeeded. Let's check for the error condition.
Without this, a successful reboot would be treated as a failure and the
LXC driver will proceed sending a TERM signal instead, effectively
cancelling the shutdown.
Signed-off-by: Lubomir Rintel <lkundrak(a)v3.sk>
---
src/lxc/lxc_domain.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 51a9fd36eb..1dc2d0d4cf 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -457,7 +457,9 @@ lxcDomainInitctlCallback(pid_t pid ATTRIBUTE_UNUSED,
data->st[i].st_ino == cont_sb.st_ino)
continue;
- return virInitctlSetRunLevel(fifo, data->runlevel);
+ if (virInitctlSetRunLevel(fifo, data->runlevel) == -1)
+ return -1;
+ return 0;
}
/* If no usable fifo was found then declare success. Caller
--
2.21.0
5 years, 5 months
[libvirt] UDP broadcasts vs. nat Masquerading issue
by Nikolai Zhubr
Hi all,
I'm observing an issue that as soon as libvirt starts, UPD broadcasts
flowing through physical network (and intended for other services,
unrelated to any virtualization) get broken. Specifically, windows
neighbourhood browsing through samba's nmbd starts suffering badly
(Samba is running on this same box).
At the moment I'm running a quite outdated version 1.2.9 of libvirt, but
because other than this issue it does its job pretty well I'd first
consider some patching/backporting rather than totally replacing it with
a new one. Anyway, I first need to better understand what is going on
and what is wrong with it.
This could also be related somewhat to
https://www.redhat.com/archives/libvir-list/2013-September/msg01311.html
but I suppose it is not exactly that thing, and besides, my version does
already include a fix for the broadcasts issue mentioned in the msg01311.
I've already figured the source of trouble is anyway related to these
rules added:
-A POSTROUTING -o br0 -j MASQUERADE
-A POSTROUTING -o enp0s25 -j MASQUERADE
-A POSTROUTING -o virbr2_nic -j MASQUERADE
-A POSTROUTING -o vnet0 -j MASQUERADE
Here, virbr2_nic and vnet0 are used by libvirt for arranging NAT-mode
network configurations for VMs, unrelated to normal network stuff, so it
looks ok. However, br0 (with enp0s25 in it) is a main interface of this
host with primary ip address. And enp0s25 is a physical nic of this
host, and it is used for all sorts of regular (unrelated to
virtualization) communications as well. Also, br0 is used for attaching
some bridge-mode (as opposed to NAT-mode) VMs managed by libvirt, but
bridge mode is not supposed to employ address translation anyway.
So, clearly, libvirt somehow chooses to set up masquerading for
literally all existing network interfaces here (except lo), but I can't
see a reason for the first two rules in the list above. Furthermore,
they corrupt UDP broadcats coming from outside and reaching this host
(through enp0s25/br0) such that source address gets replaced by this
hosts primary address (as per masquerading). I've verified this by
arranging a hand-crafted UDP listener and printing the respective source
addresses as seen by normal userspace. Obviously Samba server can not
work correctly under such conditions.
Now I've discovered that I can "eliminate" the problem by e.g.:
1. Removing "-A POSTROUTING -o br0 -j MASQUERADE" (manual brute force)
2. Inserting "-A POSTROUTING -s 192.168.0.0/24 -d 192.168.0.255/32 -j
ACCEPT"
(Of course correcting rules by hand is not a solution, just a test)
So question is, how the correct rules should ideally look like? And, is
this issue known/fixed in most current libvirt?
Thank you,
Regards,
Nikolai
5 years, 5 months