[libvirt] [PATCH 0/7] Series short description
by Amy Griffis
The following patches fix logging for the lxc controller. The lxc
controller makes use of the libvirt logging module, but because it
doesn't re-initialize the logging configuration the messages are
currently going nowhere.
There are a couple of options in fixing this. The lxc controller could
use libvirtd's logging configuration exactly, or it adopt a more
independent mode of logging to the container log file. After talking
with Daniel Veillard a while back, it seemed clear that both behaviors
are desirable. I resolved this by adding a lxc.conf file for the lxc
driver, with a boolean variable to toggle between modes.
I hope this looks good to both libvirt and container folks.
libvirt.spec.in | 16 ++++++
src/Makefile.am | 25 +++++++--
src/libvirt_private.syms | 3 +
src/lxc/libvirtd_lxc.aug | 30 +++++++++++
src/lxc/lxc.conf | 13 +++++
src/lxc/lxc_conf.c | 24 +++++++++
src/lxc/lxc_conf.h | 1
src/lxc/lxc_controller.c | 3 +
src/lxc/lxc_driver.c | 86 ++++++++++++++++++++++++++++----
src/lxc/test_libvirtd_lxc.aug | 31 ++++++++++++
src/util/logging.c | 109 ++++++++++++++++++++++++++++++++++++++---
src/util/logging.h | 14 +++++
src/util/util.c | 49 ++++++++++++++++++
src/util/util.h | 3 +
14 files changed, 379 insertions(+), 28 deletions(-)
create mode 100644 src/lxc/libvirtd_lxc.aug
create mode 100644 src/lxc/lxc.conf
create mode 100644 src/lxc/test_libvirtd_lxc.aug
Regards,
Amy
15 years, 1 month
[libvirt] Resubmission #2: [PATCH 0/3] sVirt AppArmor security driver
by Jamie Strandboge
Resubmitting again based on feedback from this list. Notably, the driver
has been reworked to use:
xml = virDomainDefFormat(conn, vm->def, ...
Then the helper program uses:
ctl->def = virDomainDefParseString(... xmlStr ...);
This simplifies adding new files. Part of this process involved adding
support for kernel, initrd, loader, serial, and console. I have commented
out code for hostdev (and pci would be easy enough), but it requires a
patch to to move the _usbDevice struct fully into hostusb.h. I figure
once the AppArmor driver is in, I can submit a patch for that.
This iteration also properly works with attach/detach. While I use
virDomainDefFormat() primarily, this does not work with attach because
the definition is not updated with the information yet (neither def nor
newDef), so I pass the disk file on the command line. For now this is ok
since SetSecurityImageLabel currently only deals with a single file, but
this will need to be adjusted depending on how the storage backend patch
works out. I thought about creating a new def and inserting the disk into
it and sending it off to virt-aa-helper, but I couldn't find an easy
way to get an accurate virCapsPtr in security_apparmor.c. I had a
similar problem with virt-aa-helper, but there I just created a fake
virCapsPtr (which defaults to 'hvm', which was a compromise I was
willing to make at this time since sVirt only supports qemu right now).
The issues with virCapsPtr aside, the code is overall cleaner and much
more easily extendable, so thanks for the excellent feedback. :)
The patches are against up to date trunk, compiles with no warnings,
'make check' passes for the tests I added, and the code passes
syntax-check. With the exception of the three calls to strncpy I had to
convert to virStr*, this is the code that is currently in Ubuntu 9.10
(0.7.0-1ubuntu8). Among other things, that means 9.10 now has your
preferred licensing.
[PATCH 1]
patch_1_reenable-nonfile-labels.patch (Updated based on prior feedback):
When James Morris originally submitted his sVirt patches (as seen in
libvirt 0.6.1), he did not require on disk labelling for
virSecurityDomainRestoreImageLabel. A later commit[2] changed this
behavior to assume on disk labelling, which halts implementations for
path-based MAC systems such as AppArmor and TOMOYO where
vm->def->seclabel is required to obtain the label. This patch simply
adds the 'virDomainObjPtr vm' argument back to *RestoreImageLabel.
[PATCH 2]
patch_2_apparmor_driver.patch (updated and merged into one patch based
on prior feedback):
- Updates src/security.c for AppArmor
- Adds security_apparmor.c, security_apparmor.h, virt-aa-helper.c and
updates po/POTFILES.in. virt-aa-helper.c is a new binary which is used
exclusively by the AppArmor security driver to manipulate AppArmor.
- Adds tests for virt-aa-helper and the security driver. secaatest.c is
identical to seclabeltest.c except it initializes the 'apparmor' driver
instead of 'selinux'. These tests are integrated into 'make check' and
pass.
- Updates configure.in, Makefile.am, src/Makefile.am, tests/Makefile.am,
and tools/Makefile.am for AppArmor. It is based on and should operate
the same as the SELinux configuration.
[PATCH 3]
patch_3_docs.patch (Updated based on prior feedback):
Updates docs/drvqemu.html.in for AppArmor and adds profile examples to
examples/apparmor. Updated based on prior feedback.
Jamie
On Fri, 04 Sep 2009, Jamie Strandboge wrote:
> This patch series implements the AppArmor security driver for sVirt.
> This implementation was developed for the Ubuntu AppArmorLibvirtProfile
> specification[1], but is general enough for any AppArmor deployment
> (such as Ubuntu, *SUSE and Mandriva).
>
> This patch has seen quite a bit of real world testing in Ubuntu 9.10
> (our development release) in our 0.7.0-1ubuntu3 package. I did make a
> few small changes after going through HACKING, but mostly I got the
> tests going and added documentation.
>
> DESIGN
> ------
> When a virtual machine is started, determine if a profile is currently
> defined for the machine, and use it if available. If not, generate a new
> profile for the machine based on a template, which is by default a very
> restrictive profile allowing access to disk files, and anything else
> needed to run, such as the pid, monitor and log files.
>
> Virtual machines should have a unique profile specific to that machine.
> To ensure uniqueness, the profile name will be derived from the UUID of
> the virtual machine. These profiles should be configurable, either by
> adjusting the profile template for new machines, creating/modifying the
> VM profile directly or through the use of AppArmor abstractions. This
> will allow for administrators to fine-tune confinement for individual
> machines if desired.
>
> If enabled at compile time, the sVirt security model will be activated
> if AppArmor is available on the host OS and a profile for the libvirtd
> daemon is loaded when libvirtd is started.
>
> libvirtd should not be allowed to create arbitrary profiles or modify
> profiles directly, so as to not allow libvirtd to potentially (ie via a
> security bug in libvirtd itself) bootstrap out of AppArmor confinement.
>
> Because root privileges are needed to manipulate AppArmor profiles,
> qemu:///session will not be supported at this time, but the
> implementation must allow for a confined libvirtd with qemu:///session
> guests running unconfined. This can be revisited when AppArmor supports
> per-user profiles.
>
> Please see the specification[1] for more details.
--
Jamie Strandboge | http://www.canonical.com
15 years, 1 month
[libvirt] [PATCH] cgroup -Werror fix
by Cole Robinson
Building with -Werror, I'm getting this error:
make[3]: *** [libvirt_lxc-cgroup.o] Error 1
make[3]: *** Waiting for unfinished jobs....
cc1: warnings being treated as errors
util/cgroup.c: In function 'virCgroupGetMemoryUsage':
util/cgroup.c:743: error: passing argument 4 of 'virCgroupGetValueU64'
from incompatible pointer type
util/cgroup.c:381: note: expected 'long long unsigned int *' but
argument is of type 'uint64_t *'
Patch below fixes it, though I'm not familiar with the code.
- Cole
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 77f19a5..f728a2f 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -736,7 +736,7 @@
*/
int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
{
- uint64_t usage_in_bytes;
+ long long unsigned int usage_in_bytes;
int ret;
ret = virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_MEMORY,
15 years, 1 month
[libvirt] [PATCH] in vbox driver, interface type bridge should really be type ethernet
by Florian Vichot
If I understand correctly, the "bridge" type for an interface means
libvirt is in charge of creating a tun device and adding it to the
specified bridge in the <source bridge=".."> attribute. This is not what
the (badly named IHMO) "Bridged Networking" mode in vbox does: all it
does is read and write its packets on the specified interface. Which is
what a type "ethernet" interface does in my opinion. I joined a quick
patch for that, Pritesh could you check it ?
Also, I was about to patch to add support for the proper "bridge" mode
in the vbox driver (because it's what I need in the end), but I see no
way of storing the fact that it's not just an "ethernet" interface using
the vbox API, so that the config would persist over libvirtd restarts.
There is always the possibility of naming the interface a special way
like "br1_myTap", and assume any type "ethernet" interface with a device
containing a "br1_" prefix would actually be a type "bridge" interface
with an associated "vbox_br1" bridge. Would that be acceptable, or is it
too hackish ?
BTW, just to make sure, I can use pretty much anything as a <target> ie.
ethN, panN etc in a type "ethernet" interface, right ? If <target> is
specified, it's not going to create a tun and use that ?
Thanks,
Florian
15 years, 1 month
[libvirt] [PATCH 0/6] correctly migrate paused VMs (and a bunch of bugfixes)
by Paolo Bonzini
Currently, the QEMU driver tries to migrate paused VMs, but the
effect is that the migrated virtual machine will always run on the
destination.
Furthermore, the state is erroneously stored as paused, so that the
driver is left confused and it is not possible to re-pause the VM
without doing a (useless except to make the libvirtd state consistent)
"virsh resume" first.
While pausing is not very used, this feature is still nice-to-have
in case for example you're migrating all VMs in emergency, or (when
QEMU will have asynchronous notifications) if you want to run QEMU
with the werror=stop option (*).
This set of patches is structured as follows:
1) patches 1 and 2 fix two bugs that were introduced by the recent
reorganization.
2) patch 3 fixes a bug that happens to be in the paths touched later on;
3) patch 4 adds the possibility to migrate a VM and leave it suspended
on the destination VM. I added the feature for debugging and thought I
might as well submit it for inclusion. Especially if the last two
patches turn out to be a no-go (at least in their current form), this
patch at least provides the infrastructure and a way to test it.
4) patches 5 and 6 actually fix the bug. Unfortunately, this requires
a change to the RPC protocol. I'm not sure whether it is required the
libvirtd's on both sides of the migration to have the same version,
or rather if this is a deal breaker.
The change to the protocol is in patch 5; the bug fix is in patch 6.
Please review and ack (or, for the last two, nack).
Paolo
(*) While the state of the migrated VM is currently fetched at the
beginning of migration, the communication happens at the end of it
(from Perform to Finish), so this is ready for being improved in
the future once QEMU provides asynchronous notifications.
15 years, 1 month
[libvirt] [PATCH] Misc win32 build fixes
by Daniel P. Berrange
* daemon/Makefile.am: Fix missing sasl rule
* src/datatypes.c: Add unistd.h to avoid gnulib bug
* src/util/cgroup.c: Disable mntent if not available
---
daemon/Makefile.am | 3 ++
src/datatypes.c | 1 +
src/util/cgroup.c | 66 ++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 26347d6..84aab04 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -243,6 +243,9 @@ install-data-sasl:
uninstall-data-sasl:
rm -f $(DESTDIR)$(sysconfdir)/sasl2/libvirt.conf
rmdir $(DESTDIR)$(sysconfdir)/sasl2/
+else
+install-data-sasl:
+uninstall-data-sasl:
endif
diff --git a/src/datatypes.c b/src/datatypes.c
index 6741b9e..89ad309 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -20,6 +20,7 @@
*/
#include <config.h>
+#include <unistd.h>
#include "datatypes.h"
#include "virterror_internal.h"
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 2e646fd..66297b9 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -13,7 +13,9 @@
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
+#ifdef HAVE_MNTENT_H
#include <mntent.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <errno.h>
@@ -68,7 +70,7 @@ void virCgroupFree(virCgroupPtr *group)
VIR_FREE(*group);
}
-
+#ifdef HAVE_MNTENT_H
/*
* Process /proc/mounts figuring out what controllers are
* mounted and where
@@ -233,6 +235,7 @@ static int virCgroupDetect(virCgroupPtr group)
return rc;
}
+#endif
static int virCgroupPathOfController(virCgroupPtr group,
@@ -317,12 +320,12 @@ static int virCgroupGetValueStr(virCgroupPtr group,
static int virCgroupSetValueU64(virCgroupPtr group,
int controller,
const char *key,
- uint64_t value)
+ unsigned long long int value)
{
char *strval = NULL;
int rc;
- if (virAsprintf(&strval, "%" PRIu64, value) == -1)
+ if (virAsprintf(&strval, "%llu", value) == -1)
return -ENOMEM;
rc = virCgroupSetValueStr(group, controller, key, strval);
@@ -339,12 +342,12 @@ static int virCgroupSetValueU64(virCgroupPtr group,
static int virCgroupSetValueI64(virCgroupPtr group,
int controller,
const char *key,
- int64_t value)
+ long long int value)
{
char *strval = NULL;
int rc;
- if (virAsprintf(&strval, "%" PRIi64, value) == -1)
+ if (virAsprintf(&strval, "%lld", value) == -1)
return -ENOMEM;
rc = virCgroupSetValueStr(group, controller, key, strval);
@@ -357,7 +360,7 @@ static int virCgroupSetValueI64(virCgroupPtr group,
static int virCgroupGetValueI64(virCgroupPtr group,
int controller,
const char *key,
- int64_t *value)
+ long long int *value)
{
char *strval = NULL;
int rc = 0;
@@ -378,7 +381,7 @@ out:
static int virCgroupGetValueU64(virCgroupPtr group,
int controller,
const char *key,
- uint64_t *value)
+ unsigned long long int *value)
{
char *strval = NULL;
int rc = 0;
@@ -387,7 +390,7 @@ static int virCgroupGetValueU64(virCgroupPtr group,
if (rc != 0)
goto out;
- if (sscanf(strval, "%" SCNu64, value) != 1)
+ if (virStrToLong_ull(strval, NULL, 10, value) < 0)
rc = -EINVAL;
out:
VIR_FREE(strval);
@@ -396,6 +399,7 @@ out:
}
+#ifdef HAVE_MNTENT_H
static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
{
int i;
@@ -546,7 +550,7 @@ cleanup:
virCgroupFree(&rootgrp);
return rc;
}
-
+#endif
/**
* virCgroupRemove:
@@ -617,6 +621,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
*
* Returns 0 on success
*/
+#ifdef HAVE_MNTENT_H
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
int privileged,
@@ -650,6 +655,16 @@ out:
return rc;
}
+#else
+int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED,
+ int privileged ATTRIBUTE_UNUSED,
+ int create ATTRIBUTE_UNUSED)
+{
+ /* Claim no support */
+ return -ENXIO;
+}
+#endif
/**
@@ -661,6 +676,7 @@ out:
*
* Returns 0 on success
*/
+#ifdef HAVE_MNTENT_H
int virCgroupForDomain(virCgroupPtr driver,
const char *name,
virCgroupPtr *group,
@@ -684,6 +700,15 @@ int virCgroupForDomain(virCgroupPtr driver,
return rc;
}
+#else
+int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED,
+ int create ATTRIBUTE_UNUSED)
+{
+ return -ENXIO;
+}
+#endif
/**
* virCgroupSetMemory:
@@ -786,6 +811,7 @@ int virCgroupAllowDeviceMajor(virCgroupPtr group, char type, int major)
*
* Returns: 0 on success
*/
+#if defined(major) && defined(minor)
int virCgroupAllowDevicePath(virCgroupPtr group, const char *path)
{
struct stat sb;
@@ -801,6 +827,14 @@ int virCgroupAllowDevicePath(virCgroupPtr group, const char *path)
major(sb.st_rdev),
minor(sb.st_rdev));
}
+#else
+int virCgroupAllowDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *path ATTRIBUTE_UNUSED)
+{
+ return -ENOSYS;
+}
+#endif
+
/**
* virCgroupDenyDevice:
@@ -861,6 +895,7 @@ int virCgroupDenyDeviceMajor(virCgroupPtr group, char type, int major)
return rc;
}
+#if defined(major) && defined(minor)
int virCgroupDenyDevicePath(virCgroupPtr group, const char *path)
{
struct stat sb;
@@ -876,26 +911,33 @@ int virCgroupDenyDevicePath(virCgroupPtr group, const char *path)
major(sb.st_rdev),
minor(sb.st_rdev));
}
+#else
+int virCgroupDenyDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *path ATTRIBUTE_UNUSED)
+{
+ return -ENOSYS;
+}
+#endif
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
{
return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
- "cpu.shares", (uint64_t)shares);
+ "cpu.shares", shares);
}
int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU,
- "cpu.shares", (uint64_t *)shares);
+ "cpu.shares", shares);
}
int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
{
return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPUACCT,
- "cpuacct.usage", (uint64_t *)usage);
+ "cpuacct.usage", usage);
}
int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
--
1.6.2.5
15 years, 1 month
[libvirt] [PATCH] Fix handling the return value of qemuMonitorSetBalloon
by Ryota Ozaki
Hi,
The current code doesn't correctly handle the positive return value
of qemuMonitorSetBalloon, i.e., the success case. The return value is
directly passed to the return of qemudDomainSetMemory which treats
a positive value as a failure.
This patch fixes the defect.
Thanks,
ozaki-r
>From f94b4c920ea30ae4a7f55fda343b4fff3bba040f Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Mon, 5 Oct 2009 03:14:58 +0900
Subject: [PATCH] Fix handling the return value of qemuMonitorSetBalloon
* src/qemu/qemu_driver.c: The positive return value of
qemuMonitorSetBalloon should be handled as a success
---
src/qemu/qemu_driver.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 95e672b..8cf9002 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3020,17 +3020,20 @@ static int qemudDomainSetMemory(virDomainPtr
dom, unsigned long newmem) {
}
if (virDomainIsActive(vm)) {
- ret = qemuMonitorSetBalloon(vm, newmem);
- /* Turn lack of balloon support into a fatal error */
- if (ret == 0) {
+ int r = qemuMonitorSetBalloon(vm, newmem);
+ if (r < 0)
+ goto cleanup;
+
+ /* Lack of balloon support is a fatal error */
+ if (r == 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
"%s", _("cannot set memory of an active domain"));
- ret = -1;
+ goto cleanup;
}
} else {
vm->def->memory = newmem;
- ret = 0;
}
+ ret = 0;
cleanup:
if (vm)
--
1.6.5.rc2
15 years, 1 month
[libvirt] [PATCH] lxc: implement missing APIs to control the amount of memory
by Ryota Ozaki
Hi,
The patch implements the missing memory control APIs for lxc, i.e.,
domainGetMaxMemory, domainSetMaxMemory, domainSetMemory, and improves
domainGetInfo to return proper amount of used memory via cgroup.
And also it includes trivial two fixes; add missing virCgroupSetMemory in
libvirt_private.syms and fix invalid lxcError argument in lxcDomainGetInfo.
Thanks,
ozaki-r
>From 530e56db9367fcb325aeaa7fb0d52a008db2f19f Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Mon, 5 Oct 2009 02:07:04 +0900
Subject: [PATCH] lxc: implement missing APIs to control the amount of memory
* src/libvirt_private.syms: Export virCgroupGetMemoryUsage
and add missing virCgroupSetMemory
* src/lxc/lxc_driver.c: Implement missing memory functions
* src/util/cgroup.c, src/util/cgroup.h: Add the function
to get used memory
---
src/libvirt_private.syms | 2 +
src/lxc/lxc_driver.c | 122 ++++++++++++++++++++++++++++++++++++++++++++--
src/util/cgroup.c | 20 ++++++++
src/util/cgroup.h | 1 +
4 files changed, 140 insertions(+), 5 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 49bbf96..3be3724 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -53,6 +53,8 @@ virCgroupForDriver;
virCgroupRemove;
virCgroupFree;
virCgroupAddTask;
+virCgroupSetMemory;
+virCgroupGetMemoryUsage;
virCgroupSetCpuShares;
virCgroupGetCpuShares;
virCgroupDenyDevicePath;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 5fb4105..8ec4ae4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -450,6 +450,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
if (!virDomainIsActive(vm) || driver->cgroup == NULL) {
info->cpuTime = 0;
+ info->memory = vm->def->memory;
} else {
if (virCgroupForDomain(driver->cgroup, vm->def->name,
&cgroup, 0) != 0) {
lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
@@ -458,13 +459,18 @@ static int lxcDomainGetInfo(virDomainPtr dom,
}
if (virCgroupGetCpuacctUsage(cgroup, &(info->cpuTime)) < 0) {
- lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
("cannot read cputime for domain"));
+ lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
+ "%s", _("cannot read cputime for domain"));
+ goto cleanup;
+ }
+ if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) {
+ lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
+ "%s", _("cannot read memory usage for domain"));
goto cleanup;
}
}
info->maxMem = vm->def->maxmem;
- info->memory = vm->def->memory;
info->nrVirtCpu = 1;
ret = 0;
@@ -501,6 +507,112 @@ cleanup:
return ret;
}
+/* Returns max memory in kb, 0 if error */
+static unsigned long lxcDomainGetMaxMemory(virDomainPtr dom) {
+ lxc_driver_t *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ unsigned long ret = 0;
+
+ lxcDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ lxcDriverUnlock(driver);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ ret = vm->def->maxmem;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ return ret;
+}
+
+static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
+ lxc_driver_t *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ lxcDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ lxcDriverUnlock(driver);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ if (newmax < vm->def->memory) {
+ lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
+ "%s", _("cannot set max memory lower than
current memory"));
+ goto cleanup;
+ }
+
+ vm->def->maxmem = newmax;
+ ret = 0;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ return ret;
+}
+
+static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
+ lxc_driver_t *driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ virCgroupPtr cgroup = NULL;
+ int ret = -1;
+
+ lxcDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+ lxcDriverUnlock(driver);
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ lxcError(dom->conn, dom, VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ if (newmem > vm->def->maxmem) {
+ lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
+ "%s", _("cannot set memory higher than max memory"));
+ goto cleanup;
+ }
+
+ if (virDomainIsActive(vm)) {
+ if (virCgroupForDomain(driver->cgroup, vm->def->name,
&cgroup, 0) != 0) {
+ lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to get cgroup for %s¥n"), vm->def->name);
+ goto cleanup;
+ }
+
+ if (virCgroupSetMemory(cgroup, newmem) < 0) {
+ lxcError(dom->conn, dom, VIR_ERR_OPERATION_FAILED,
+ "%s", _("cannot set memory for domain"));
+ goto cleanup;
+ }
+ } else {
+ vm->def->memory = newmem;
+ }
+ ret = 0;
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ if (cgroup)
+ virCgroupFree(&cgroup);
+ return ret;
+}
+
static char *lxcDomainDumpXML(virDomainPtr dom,
int flags)
{
@@ -2103,9 +2215,9 @@ static virDriver lxcDriver = {
NULL, /* domainReboot */
lxcDomainDestroy, /* domainDestroy */
lxcGetOSType, /* domainGetOSType */
- NULL, /* domainGetMaxMemory */
- NULL, /* domainSetMaxMemory */
- NULL, /* domainSetMemory */
+ lxcDomainGetMaxMemory, /* domainGetMaxMemory */
+ lxcDomainSetMaxMemory, /* domainSetMaxMemory */
+ lxcDomainSetMemory, /* domainSetMemory */
lxcDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL, /* domainRestore */
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 2e646fd..e56d293 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -702,6 +702,26 @@ int virCgroupSetMemory(virCgroupPtr group,
unsigned long kb)
}
/**
+ * virCgroupGetMemoryUsage:
+ *
+ * @group: The cgroup to change memory for
+ * @kb: Pointer to returned used memory in kilobytes
+ *
+ * Returns: 0 on success
+ */
+int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb)
+{
+ uint64_t usage_in_bytes;
+ int ret;
+ ret = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ "memory.usage_in_bytes", &usage_in_bytes);
+ if (ret == 0)
+ *kb = (unsigned long) usage_in_bytes >> 10;
+ return ret;
+}
+
+/**
* virCgroupDenyAllDevices:
*
* @group: The cgroup to deny devices for
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index aba56c6..aa36632 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -41,6 +41,7 @@ int virCgroupForDomain(virCgroupPtr driver,
int virCgroupAddTask(virCgroupPtr group, pid_t pid);
int virCgroupSetMemory(virCgroupPtr group, unsigned long kb);
+int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
int virCgroupDenyAllDevices(virCgroupPtr group);
--
1.6.5.rc2
15 years, 1 month
[libvirt] [PATCH] Make dnsmasq run from libvirtd reading /etc/ethers
by Satoru SATOH
The following small patch makes dnsmasq run from libvirtd reading
/etc/ethers and enables static ip address assignment with it.
Libvirtd already supports static ip address assignment by
//ip/dhcp/host element in network xml definition file, however the
number of the assignments looks limited by ARG_MAX or similar parameters
when dnsmasq is exec-ed.
This patch implements a workaround for this issue and the number of
static ip assignments becomes only limited by dnsmasq (I'm not sure the
exact number but it should large enough for most cases, I guess).
Signed-off-by: Satoru SATOH <satoru.satoh(a)gmail.com>
---
src/network/bridge_driver.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 95bc810..725d340 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -391,6 +391,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
1 + /* dnsmasq */
1 + /* --strict-order */
1 + /* --bind-interfaces */
+ 1 + /* --read-ethers */
(network->def->domain?2:0) + /* --domain name */
2 + /* --pid-file /var/run/libvirt/network/$NAME.pid */
2 + /* --conf-file "" */
@@ -427,6 +428,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
*/
APPEND_ARG(*argv, i++, "--strict-order");
APPEND_ARG(*argv, i++, "--bind-interfaces");
+ APPEND_ARG(*argv, i++, "--read-ethers");
if (network->def->domain) {
APPEND_ARG(*argv, i++, "--domain");
--
1.6.2.5
15 years, 1 month
[libvirt] [PATCH] Fix up "make check"
by Chris Lalancette
While running make check, I noticed that it was actually using
the virsh binary from my system, in /usr/bin/virsh, and not the
one that was just compiled. This is actually caused by a bug
in Makefile.am, where we didn't update the PATH to include tools.
While here, I also updated all of the scripts to properly define
the srcdir, abs_top_srcdir, and abs_top_builddir environment
variables. This is required if you want to be able to run the
tests standalone (i.e. ./test instead of from make check). I've
tested this on both RHEL-5 and Fedora-10 machines, and make check
works on both, as does running the individual tests by hand.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
tests/Makefile.am | 2 +-
tests/cpuset | 12 ++++++++----
tests/daemon-conf | 18 +++++++++++-------
tests/define-dev-segfault | 10 ++++++----
tests/int-overflow | 20 ++++++++++----------
tests/libvirtd-fail | 10 ++++++----
tests/libvirtd-pool | 10 ++++++----
tests/read-bufsiz | 15 ++++++++-------
tests/read-non-seekable | 12 ++++++++----
tests/start | 10 ++++++----
tests/test_conf.sh | 14 ++++++++------
tests/undefine | 14 +++++++++-----
tests/vcpupin | 12 ++++++++----
tests/virsh-all | 12 +++++++-----
tests/virsh-synopsis | 11 +++++++----
15 files changed, 109 insertions(+), 73 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index abda4ad..4caca8f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -150,7 +150,7 @@ TESTS += nodedevxml2xmltest
TESTS += interfacexml2xmltest
-path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/daemon
+path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/daemon$(PATH_SEPARATOR)$$abs_top_builddir/tools
# NB, automake < 1.10 does not provide the real
# abs_top_{src/build}dir variables, so don't rely
diff --git a/tests/cpuset b/tests/cpuset
index eeb0ee2..9f43269 100755
--- a/tests/cpuset
+++ b/tests/cpuset
@@ -16,17 +16,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
fail=0
# generate input
-virsh --connect test:///default dumpxml 1 > xml || fail=1
+$abs_top_builddir/tools/virsh --connect test:///default dumpxml 1 > xml || fail=1
# require the presence of the string we'll transform
grep '<vcpu>' xml > /dev/null || fail=1
@@ -34,7 +38,7 @@ grep '<vcpu>' xml > /dev/null || fail=1
sed "s/vcpu>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1
# Require failure and a diagnostic.
-virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
+$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
cat <<\EOF > exp || fail=1
error: Failed to define domain from xml-invalid
error: failed Xen syscall topology cpuset syntax error
diff --git a/tests/daemon-conf b/tests/daemon-conf
index 071497e..722fe4e 100755
--- a/tests/daemon-conf
+++ b/tests/daemon-conf
@@ -1,16 +1,20 @@
#!/bin/sh
# Get coverage of libvirtd's config-parsing code.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- libvirtd --version
+ $abs_top_builddir/daemon/libvirtd --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
+
+test -z "$CONFIG_HEADER" && CONFIG_HEADER="$abs_top_builddir/config.h"
-grep '^#define WITH_QEMU 1' $CONFIG_HEADER > /dev/null ||
+grep '^#define WITH_QEMU 1' "$CONFIG_HEADER" > /dev/null ||
skip_test_ "configured without QEMU support"
conf="$abs_top_srcdir/daemon/libvirtd.conf"
@@ -40,7 +44,7 @@ while :; do
esac
# Run libvirtd, expecting it to fail.
- libvirtd --config=$f 2> err && fail=1
+ $abs_top_builddir/daemon/libvirtd --config=$f 2> err && fail=1
case $rhs in
# '"'*) msg='should be a string';;
@@ -73,7 +77,7 @@ sed 's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",' tmp.conf > k \
mv k tmp.conf || fail=1
printf "running libvirtd with a valid config file ($sleep_secs seconds)\n" 1>&2
-libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$!
+$abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$!
sleep $sleep_secs
kill $pid
diff --git a/tests/define-dev-segfault b/tests/define-dev-segfault
index 4ae286f..e0b953a 100755
--- a/tests/define-dev-segfault
+++ b/tests/define-dev-segfault
@@ -2,13 +2,15 @@
# Exercise a bug whereby defining a valid domain could kill libvirtd.
# The bug can also be exercised with a simple define/dumpxml pair to virsh.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
@@ -62,7 +64,7 @@ cat <<\EOF > D.xml || fail=1
EOF
url=test:///default
-virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1
+$abs_top_builddir/tools/virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1
cat > exp <<EOF || fail=1
Domain D defined from D.xml
diff --git a/tests/int-overflow b/tests/int-overflow
index ac3119b..c9f5de9 100755
--- a/tests/int-overflow
+++ b/tests/int-overflow
@@ -2,16 +2,16 @@
# Ensure that an invalid domain ID isn't interpreted as a valid one.
# Before, an ID of 2^32+2 would be treated just like an ID of 2.
-# Boilerplate code to set up a test directory, cd into it,
-# and to ensure we remove it upon completion.
-this_test_() { echo "./$0" | sed 's,.*/,,'; }
-t_=$(this_test_)-$$
-init_cwd_=$(pwd)
-trap 'st=$?; d='"$t_"';
- cd '"$init_cwd_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0
-trap '(exit $?); exit $?' 1 2 13 15
-mkdir "$t_" || fail=1
-cd "$t_" || fail=1
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+. "$srcdir/test-lib.sh"
echo "error: failed to get domain '4294967298'" > exp || fail=1
echo domname 4294967298 | $abs_top_builddir/tools/virsh --quiet \
diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail
index eeb1ee6..c6b6876 100755
--- a/tests/libvirtd-fail
+++ b/tests/libvirtd-fail
@@ -1,18 +1,20 @@
#!/bin/sh
# Ensure that libvirt fails when given nonexistent --config=FILE
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- libvirtd --version
+ $abs_top_builddir/daemon/libvirtd --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
-libvirtd --config=no-such-conf --timeout=5 2> log
+$abs_top_builddir/daemon/libvirtd --config=no-such-conf --timeout=5 2> log
RET=$?
test "$RET" != "0" && exit 0 || exit 1
diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool
index 59da5a6..ca1db94 100755
--- a/tests/libvirtd-pool
+++ b/tests/libvirtd-pool
@@ -1,20 +1,22 @@
#!/bin/sh
# Get coverage of virsh pool-define-as XML formatting
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
pwd=$(pwd) || fail=1
-virsh --connect test:///default \
+$abs_top_builddir/tools/virsh --connect test:///default \
pool-define-as --print-xml \
P dir src-host /src/path /src/dev S /target-path \
1>out 2>&1
diff --git a/tests/read-bufsiz b/tests/read-bufsiz
index 7d53735..5baa7c5 100755
--- a/tests/read-bufsiz
+++ b/tests/read-bufsiz
@@ -16,20 +16,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=`pwd`
-test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
-
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
fail=0
# Output a valid definition, to be used as input.
-virsh -c test:///default dumpxml 1 > xml || fail=1
+$abs_top_builddir/tools/virsh -c test:///default dumpxml 1 > xml || fail=1
for i in before after; do
# The largest BUFSIZ I've seen is 128K. This is slightly larger.
@@ -38,7 +39,7 @@ for i in before after; do
# Append or prepend enough spaces to push the size over the limit:
( test $i = before && cat sp xml || cat xml sp ) > $in || fail=1
- virsh --connect test:///default define $in > out || fail=1
+ $abs_top_builddir/tools/virsh --connect test:///default define $in > out || fail=1
printf "Domain test defined from $in\n\n" > exp || fail=1
compare exp out || fail=1
done
diff --git a/tests/read-non-seekable b/tests/read-non-seekable
index 8a7bdcd..59c2389 100755
--- a/tests/read-non-seekable
+++ b/tests/read-non-seekable
@@ -16,12 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
fail=0
@@ -40,11 +44,11 @@ cat <<\EOF > dom
</domain>
EOF
-virsh -c test:///default define dom > /dev/null || fail=1
+$abs_top_builddir/tools/virsh -c test:///default define dom > /dev/null || fail=1
mkfifo_or_skip_ fifo
cat dom > fifo &
-virsh -c test:///default define fifo > /dev/null || fail=1
+$abs_top_builddir/tools/virsh -c test:///default define fifo > /dev/null || fail=1
(exit $fail); exit $fail
diff --git a/tests/start b/tests/start
index f457d59..930a6d9 100755
--- a/tests/start
+++ b/tests/start
@@ -16,13 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
@@ -30,7 +32,7 @@ fail=0
test_url=test:///default
# expect this to fail
-virsh -c $test_url start test > out 2> err && fail=1
+$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail=1
# stdout gets a newline
echo > exp || fail=1
diff --git a/tests/test_conf.sh b/tests/test_conf.sh
index 62c2324..682f1f5 100755
--- a/tests/test_conf.sh
+++ b/tests/test_conf.sh
@@ -1,17 +1,19 @@
#!/bin/sh
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+test -z "$abs_srcdir" && abs_srcdir=$(pwd)
+test -z "$abs_builddir" && abs_builddir=$(pwd)
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
set -e
-if test "x$abs_srcdir" = x; then
- abs_srcdir=`pwd`
- abs_builddir=`pwd`
-fi
fail=0
i=1
diff --git a/tests/undefine b/tests/undefine
index fafdae7..48b0ad9 100755
--- a/tests/undefine
+++ b/tests/undefine
@@ -16,17 +16,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
fail=0
# Attempt to undefine a running domain, by domain name.
-virsh -q -c test:///default undefine test > out 2>&1
+$abs_top_builddir/tools/virsh -q -c test:///default undefine test > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: Failed to undefine domain test
@@ -35,7 +39,7 @@ EOF
compare exp out || fail=1
# A different diagnostic when specifying a domain ID
-virsh -q -c test:///default undefine 1 > out 2>&1
+$abs_top_builddir/tools/virsh -q -c test:///default undefine 1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: a running domain like 1 cannot be undefined;
@@ -44,7 +48,7 @@ EOF
compare exp out || fail=1
# Succeed, now: first shut down, then undefine, both via name.
-virsh -q -c test:///default 'shutdown test; undefine test' > out 2>&1
+$abs_top_builddir/tools/virsh -q -c test:///default 'shutdown test; undefine test' > out 2>&1
test $? = 0 || fail=1
cat <<\EOF > exp || fail=1
Domain test is being shutdown
diff --git a/tests/vcpupin b/tests/vcpupin
index 79b02dc..a72ad4c 100755
--- a/tests/vcpupin
+++ b/tests/vcpupin
@@ -16,17 +16,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-. $srcdir/test-lib.sh
+. "$srcdir/test-lib.sh"
fail=0
# Invalid syntax.
-virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpupin: Invalid or missing vCPU number.
@@ -35,7 +39,7 @@ EOF
compare exp out || fail=1
# An out-of-range vCPU number deserves a diagnostic, too.
-virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
+$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpupin: Invalid vCPU number.
diff --git a/tests/virsh-all b/tests/virsh-all
index 03ea466..81b3e57 100755
--- a/tests/virsh-all
+++ b/tests/virsh-all
@@ -16,27 +16,29 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
-test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. "$srcdir/test-lib.sh"
fail=0
test_url=test:///default
-virsh -c $test_url help > cmds || framework_failure
+$abs_top_builddir/tools/virsh -c $test_url help > cmds || framework_failure
cmds=$(sed -n 's/^ \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure
test -n "$cmds" || framework_failure
for i in $cmds; do
echo testing $i... 1>&2
# For now, just run the command and ignore output and exit status.
- virsh -c $test_url $i < /dev/null > /dev/null 2>&1
+ $abs_top_builddir/tools/virsh -c $test_url $i < /dev/null > /dev/null 2>&1
done
(exit $fail); exit $fail
diff --git a/tests/virsh-synopsis b/tests/virsh-synopsis
index 24038dd..d72e887 100755
--- a/tests/virsh-synopsis
+++ b/tests/virsh-synopsis
@@ -16,24 +16,27 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+test -z "$srcdir" && srcdir=$(pwd)
+test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
+test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
+
if test "$VERBOSE" = yes; then
set -x
- virsh --version
+ $abs_top_builddir/tools/virsh --version
fi
-test -z "$srcdir" && srcdir=$(pwd)
. "$srcdir/test-lib.sh"
fail=0
test_url=test:///default
-virsh -c $test_url help > cmds || framework_failure
+$abs_top_builddir/tools/virsh -c $test_url help > cmds || framework_failure
cmds=$(sed -n 's/^ \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure
test -n "$cmds" || framework_failure
for i in $cmds; do
- virsh -c $test_url help $i > help || fail=1
+ $abs_top_builddir/tools/virsh -c $test_url help $i > help || fail=1
grep -A1 '^ SYNOPSIS$' help > synopsis \
|| { echo 1>&2 missing or invalid help SYNOPSIS for $i; fail=1; }
sed -n 2p synopsis > s2 || framework_failure
--
1.6.0.6
15 years, 1 month