[libvirt] [sandbox][PATCH v2] Fix delete of running container
by Wayne Sun
Delete running container is not supprted and will report an error.
Related to bug:
https://bugzilla.redhat.com/show_bug.cgi?id=994495
Signed-off-by: Wayne Sun <gsun(a)redhat.com>
---
bin/virt-sandbox-service | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 550d46c..c07c33b 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -254,11 +254,16 @@ class Container:
def delete(self):
self.connect()
- # Stop service if it is running
- try:
- self.stop()
- except:
- pass
+ # Check container is running or not
+ cmd = "/usr/bin/virsh -c %s list | sed '1d;2d;$d' | awk -F' '\
+ '{ print $2}'" % self.uri
+ p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
+ out, err = p.communicate()
+ if p.returncode and p.returncode != 0:
+ raise OSError(_("Failed to list running domain"))
+
+ if self.name in out.splitlines():
+ raise ValueError([_("Delete running container is not supported")])
# Not sure we should remove content
if os.path.exists(self.dest):
--
1.7.1
11 years, 4 months
[libvirt] [PATCH] cgroup: refactor macros usage
by Roman Bogorodskiy
util/vircgroup.c uses a lot of macros to detect if cgroup is supported
by the system or not. These macros are pretty smart and allow to keep
code compact, however the downside of that is that it's getting harder
to navigate through the cgroup code.
So re-organise macros in a more simple fashion, i.e. just explicitly
provide functional and stub implementation for every public function.
---
src/util/vircgroup.c | 984 +++++++++++++++++++++++++++++++++------------------
1 file changed, 648 insertions(+), 336 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index cfb4b3f..45db658 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -61,6 +61,13 @@ VIR_ENUM_IMPL(virCgroupController, VIR_CGROUP_CONTROLLER_LAST,
"freezer", "blkio", "net_cls", "perf_event",
"name=systemd");
+#if defined(__linux__) && defined(HAVE_MNTENT_H) && defined(HAVE_GETMNTENT_R) \
+ && defined(_DIRENT_HAVE_D_TYPE) && defined(major) && defined(minor)
+# define VIR_CGROUP_SUPPORTED
+#endif
+
+#if defined(VIR_CGROUP_SUPPORTED)
+
typedef enum {
VIR_CGROUP_NONE = 0, /* create subdir under each cgroup if possible. */
VIR_CGROUP_MEM_HIERACHY = 1 << 0, /* call virCgroupSetMemoryUseHierarchy
@@ -72,7 +79,6 @@ typedef enum {
bool virCgroupAvailable(void)
{
bool ret = false;
-#ifdef HAVE_GETMNTENT_R
FILE *mounts = NULL;
struct mntent entry;
char buf[CGROUP_MAX_VAL];
@@ -91,11 +97,9 @@ bool virCgroupAvailable(void)
}
VIR_FORCE_FCLOSE(mounts);
-#endif
return ret;
}
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
static int virCgroupPartitionEscape(char **path);
@@ -169,16 +173,6 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
VIR_FREE(scopename);
return valid;
}
-#else
-static bool
-virCgroupValidateMachineGroup(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
- const char *drivername ATTRIBUTE_UNUSED,
- bool stripEmulatorSuffix ATTRIBUTE_UNUSED)
-{
- return true;
-}
-#endif
/**
* virCgroupFree:
@@ -220,7 +214,6 @@ bool virCgroupHasController(virCgroupPtr cgroup, int controller)
return cgroup->controllers[controller].mountPoint != NULL;
}
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
static int virCgroupCopyMounts(virCgroupPtr group,
virCgroupPtr parent)
{
@@ -339,7 +332,6 @@ error:
return -1;
}
-
static int virCgroupCopyPlacement(virCgroupPtr group,
const char *path,
virCgroupPtr parent)
@@ -374,7 +366,6 @@ static int virCgroupCopyPlacement(virCgroupPtr group,
return 0;
}
-
/*
* virCgroupDetectPlacement:
* @group: the group to process
@@ -599,8 +590,6 @@ static int virCgroupDetect(virCgroupPtr group,
return 0;
}
-#endif
-
int virCgroupPathOfController(virCgroupPtr group,
int controller,
@@ -651,7 +640,6 @@ int virCgroupPathOfController(virCgroupPtr group,
return 0;
}
-
static int virCgroupSetValueStr(virCgroupPtr group,
int controller,
const char *key,
@@ -727,8 +715,6 @@ static int virCgroupSetValueU64(virCgroupPtr group,
return ret;
}
-
-
static int virCgroupSetValueI64(virCgroupPtr group,
int controller,
const char *key,
@@ -797,8 +783,6 @@ cleanup:
return ret;
}
-
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
{
size_t i;
@@ -993,9 +977,7 @@ error:
return -1;
}
-#endif
-#if defined _DIRENT_HAVE_D_TYPE
int virCgroupRemoveRecursively(char *grppath)
{
DIR *grpdir;
@@ -1044,14 +1026,6 @@ int virCgroupRemoveRecursively(char *grppath)
return rc;
}
-#else
-int virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
/**
* virCgroupRemove:
@@ -1101,7 +1075,6 @@ int virCgroupRemove(virCgroupPtr group)
return rc;
}
-
/**
* virCgroupAddTask:
*
@@ -1252,8 +1225,6 @@ cleanup:
return ret;
}
-
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
static int virCgroupPartitionNeedsEscaping(const char *path)
{
FILE *fp = NULL;
@@ -1445,18 +1416,6 @@ cleanup:
VIR_FREE(newpath);
return ret;
}
-#else
-int virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED,
- int controllers ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
-
/**
* virCgroupNewSelf:
@@ -1484,7 +1443,6 @@ int virCgroupNewSelf(virCgroupPtr *group)
*
* Returns 0 on success, or -1 on error
*/
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupNewDomainPartition(virCgroupPtr partition,
const char *driver,
const char *name,
@@ -1526,18 +1484,6 @@ cleanup:
VIR_FREE(grpname);
return ret;
}
-#else
-int virCgroupNewDomainPartition(virCgroupPtr partition ATTRIBUTE_UNUSED,
- const char *driver ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
/**
* virCgroupNewVcpu:
@@ -1549,7 +1495,6 @@ int virCgroupNewDomainPartition(virCgroupPtr partition ATTRIBUTE_UNUSED,
*
* Returns 0 on success, or -1 on error
*/
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupNewVcpu(virCgroupPtr domain,
int vcpuid,
bool create,
@@ -1580,17 +1525,6 @@ cleanup:
VIR_FREE(name);
return ret;
}
-#else
-int virCgroupNewVcpu(virCgroupPtr domain ATTRIBUTE_UNUSED,
- int vcpuid ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
/**
* virCgroupNewEmulator:
@@ -1601,7 +1535,6 @@ int virCgroupNewVcpu(virCgroupPtr domain ATTRIBUTE_UNUSED,
*
* Returns: 0 on success or -1 on error
*/
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupNewEmulator(virCgroupPtr domain,
bool create,
virCgroupPtr *group)
@@ -1626,36 +1559,13 @@ int virCgroupNewEmulator(virCgroupPtr domain,
cleanup:
return ret;
}
-#else
-int virCgroupNewEmulator(virCgroupPtr domain ATTRIBUTE_UNUSED,
- bool create ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
-
-
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupNewDetect(pid_t pid,
int controllers,
virCgroupPtr *group)
{
return virCgroupNew(pid, "", NULL, controllers, group);
}
-#else
-int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
- int controllers ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
/*
* Returns 0 on success (but @group may be NULL), -1 on fatal error
@@ -1941,7 +1851,6 @@ int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight)
*
* Returns: 0 on success, -1 on error
*/
-#if defined(major) && defined(minor)
int virCgroupSetBlkioDeviceWeight(virCgroupPtr group,
const char *path,
unsigned int weight)
@@ -1982,17 +1891,6 @@ int virCgroupSetBlkioDeviceWeight(virCgroupPtr group,
VIR_FREE(str);
return ret;
}
-#else
-int
-virCgroupSetBlkioDeviceWeight(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *path ATTRIBUTE_UNUSED,
- unsigned int weight ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
/**
* virCgroupSetMemory:
@@ -2364,7 +2262,6 @@ cleanup:
* Returns: 0 on success, 1 if path exists but is not a device, or
* -1 on error
*/
-#if defined(major) && defined(minor)
int virCgroupAllowDevicePath(virCgroupPtr group, const char *path, int perms)
{
struct stat sb;
@@ -2385,17 +2282,6 @@ int virCgroupAllowDevicePath(virCgroupPtr group, const char *path, int perms)
minor(sb.st_rdev),
perms);
}
-#else
-int virCgroupAllowDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *path ATTRIBUTE_UNUSED,
- int perms ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
-
/**
* virCgroupDenyDevice:
@@ -2468,7 +2354,6 @@ cleanup:
return ret;
}
-#if defined(major) && defined(minor)
int virCgroupDenyDevicePath(virCgroupPtr group, const char *path, int perms)
{
struct stat sb;
@@ -2489,16 +2374,6 @@ int virCgroupDenyDevicePath(virCgroupPtr group, const char *path, int perms)
minor(sb.st_rdev),
perms);
}
-#else
-int virCgroupDenyDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *path ATTRIBUTE_UNUSED,
- int perms ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
{
@@ -2609,63 +2484,6 @@ int virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char **usage)
"cpuacct.usage_percpu", usage);
}
-#ifdef _SC_CLK_TCK
-int virCgroupGetCpuacctStat(virCgroupPtr group, unsigned long long *user,
- unsigned long long *sys)
-{
- char *str;
- char *p;
- int ret = -1;
- static double scale = -1.0;
-
- if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
- "cpuacct.stat", &str) < 0)
- return -1;
-
- if (!(p = STRSKIP(str, "user ")) ||
- virStrToLong_ull(p, &p, 10, user) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Cannot parse user stat '%s'"),
- p);
- goto cleanup;
- }
- if (!(p = STRSKIP(p, "\nsystem ")) ||
- virStrToLong_ull(p, NULL, 10, sys) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Cannot parse sys stat '%s'"),
- p);
- goto cleanup;
- }
- /* times reported are in system ticks (generally 100 Hz), but that
- * rate can theoretically vary between machines. Scale things
- * into approximate nanoseconds. */
- if (scale < 0) {
- long ticks_per_sec = sysconf(_SC_CLK_TCK);
- if (ticks_per_sec == -1) {
- virReportSystemError(errno, "%s",
- _("Cannot determine system clock HZ"));
- goto cleanup;
- }
- scale = 1000000000.0 / ticks_per_sec;
- }
- *user *= scale;
- *sys *= scale;
-
- ret = 0;
-cleanup:
- VIR_FREE(str);
- return ret;
-}
-#else
-int virCgroupGetCpuacctStat(virCgroupPtr group ATTRIBUTE_UNUSED,
- unsigned long long *user ATTRIBUTE_UNUSED,
- unsigned long long *sys ATTRIBUTE_UNUSED)
-{
- virReportSystemError(ENOSYS, "%s",
- _("Control groups not supported on this platform"));
- return -1;
-}
-#endif
int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
{
@@ -2681,53 +2499,614 @@ int virCgroupGetFreezerState(virCgroupPtr group, char **state)
"freezer.state", state);
}
+static char *virCgroupIdentifyRoot(virCgroupPtr group)
+{
+ char *ret = NULL;
+ size_t i;
-#if defined HAVE_KILL && defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
-/*
- * Returns 1 if some PIDs are killed, 0 if none are killed, or -1 on error
- */
-static int virCgroupKillInternal(virCgroupPtr group, int signum, virHashTablePtr pids)
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ char *tmp;
+ if (!group->controllers[i].mountPoint)
+ continue;
+ if (!(tmp = strrchr(group->controllers[i].mountPoint, '/'))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not find directory separator in %s"),
+ group->controllers[i].mountPoint);
+ return NULL;
+ }
+
+ if (VIR_STRNDUP(ret, group->controllers[i].mountPoint,
+ tmp - group->controllers[i].mountPoint) < 0)
+ return NULL;
+ return ret;
+ }
+
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not find any mounted controllers"));
+ return NULL;
+}
+
+
+int virCgroupIsolateMount(virCgroupPtr group, const char *oldroot,
+ const char *mountopts)
{
int ret = -1;
- bool killedAny = false;
- char *keypath = NULL;
- bool done = false;
- FILE *fp = NULL;
- VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
- group, group->path, signum, pids);
+ size_t i;
+ char *opts = NULL;
+ char *root = NULL;
- if (virCgroupPathOfController(group, -1, "tasks", &keypath) < 0)
+ if (!(root = virCgroupIdentifyRoot(group)))
return -1;
- /* PIDs may be forking as we kill them, so loop
- * until there are no new PIDs found
- */
- while (!done) {
- done = true;
- if (!(fp = fopen(keypath, "r"))) {
- if (errno == ENOENT) {
- VIR_DEBUG("No file %s, assuming done", keypath);
- killedAny = false;
- goto done;
- }
-
- virReportSystemError(errno,
- _("Failed to read %s"),
- keypath);
- goto cleanup;
- } else {
- while (!feof(fp)) {
- unsigned long pid_value;
- if (fscanf(fp, "%lu", &pid_value) != 1) {
- if (feof(fp))
- break;
- virReportSystemError(errno,
- _("Failed to read %s"),
- keypath);
- goto cleanup;
- }
- if (virHashLookup(pids, (void*)pid_value))
- continue;
+ VIR_DEBUG("Mounting cgroups at '%s'", root);
+
+ if (virFileMakePath(root) < 0) {
+ virReportSystemError(errno,
+ _("Unable to create directory %s"),
+ root);
+ goto cleanup;
+ }
+
+ if (virAsprintf(&opts,
+ "mode=755,size=65536%s", mountopts) < 0)
+ goto cleanup;
+
+ if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
+ virReportSystemError(errno,
+ _("Failed to mount %s on %s type %s"),
+ "tmpfs", root, "tmpfs");
+ goto cleanup;
+ }
+
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ if (!group->controllers[i].mountPoint)
+ continue;
+
+ if (!virFileExists(group->controllers[i].mountPoint)) {
+ char *src;
+ if (virAsprintf(&src, "%s%s%s",
+ oldroot,
+ group->controllers[i].mountPoint,
+ group->controllers[i].placement) < 0)
+ goto cleanup;
+
+ VIR_DEBUG("Create mount point '%s'", group->controllers[i].mountPoint);
+ if (virFileMakePath(group->controllers[i].mountPoint) < 0) {
+ virReportSystemError(errno,
+ _("Unable to create directory %s"),
+ group->controllers[i].mountPoint);
+ VIR_FREE(src);
+ goto cleanup;
+ }
+
+ if (mount(src, group->controllers[i].mountPoint, NULL, MS_BIND, NULL) < 0) {
+ virReportSystemError(errno,
+ _("Failed to bind cgroup '%s' on '%s'"),
+ src, group->controllers[i].mountPoint);
+ VIR_FREE(src);
+ goto cleanup;
+ }
+
+ VIR_FREE(src);
+ }
+
+ if (group->controllers[i].linkPoint) {
+ VIR_DEBUG("Link mount point '%s' to '%s'",
+ group->controllers[i].mountPoint,
+ group->controllers[i].linkPoint);
+ if (symlink(group->controllers[i].mountPoint,
+ group->controllers[i].linkPoint) < 0) {
+ virReportSystemError(errno,
+ _("Unable to symlink directory %s to %s"),
+ group->controllers[i].mountPoint,
+ group->controllers[i].linkPoint);
+ return -1;
+ }
+ }
+ }
+ ret = 0;
+
+cleanup:
+ VIR_FREE(root);
+ VIR_FREE(opts);
+ return ret;
+}
+
+#else /* !(VIR_CGROUP_SUPPORTED) */
+bool virCgroupAvailable(void)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return false;
+}
+
+void virCgroupFree(virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+}
+
+int virCgroupNewSelf(virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewDetectMachine(const char *name ATTRIBUTE_UNUSED,
+ const char *drivername ATTRIBUTE_UNUSED,
+ pid_t pid ATTRIBUTE_UNUSED,
+ const char *partition ATTRIBUTE_UNUSED,
+ int controllers ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetMemoryHardLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetMemoryHardLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetMemorySoftLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetMemorySoftLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetMemSwapHardLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetMemSwapHardLimit(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetMemSwapUsage(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetMemoryUsage(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long *kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetMemory(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long kb ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetCpusetMems(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *mems ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpusetMems(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char **mems ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetCpusetCpus(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *cpus ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpusetCpus(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char **cpus ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupDenyAllDevices(virCgroupPtr group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupDenyDeviceMajor(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char type ATTRIBUTE_UNUSED,
+ int major ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupDenyDevice(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char type ATTRIBUTE_UNUSED,
+ int major ATTRIBUTE_UNUSED,
+ int minor ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetCpuCfsPeriod(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long cfs_period ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpuCfsPeriod(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *cfs_period ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetCpuCfsQuota(virCgroupPtr group ATTRIBUTE_UNUSED,
+ long long cfs_quota ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpuCfsQuota(virCgroupPtr group ATTRIBUTE_UNUSED,
+ long long *cfs_quota ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetCpuShares(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long shares ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpuShares(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *shares ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpuacctPercpuUsage(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char **usage ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetCpuacctUsage(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *usage ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupSetBlkioWeight(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned int weight ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupAllowDevice(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char type ATTRIBUTE_UNUSED,
+ int major ATTRIBUTE_UNUSED,
+ int minor ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupAllowDeviceMajor(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char type ATTRIBUTE_UNUSED,
+ int major ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupAddTask(virCgroupPtr group ATTRIBUTE_UNUSED,
+ pid_t pid ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupMoveTask(virCgroupPtr src_group ATTRIBUTE_UNUSED,
+ virCgroupPtr dest_group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupAddTaskController(virCgroupPtr group ATTRIBUTE_UNUSED,
+ pid_t pid ATTRIBUTE_UNUSED,
+ int controller ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetBlkioWeight(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned int *weight ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewMachine(const char *name ATTRIBUTE_UNUSED,
+ const char *drivername ATTRIBUTE_UNUSED,
+ bool privileged ATTRIBUTE_UNUSED,
+ const unsigned char *uuid ATTRIBUTE_UNUSED,
+ const char *rootdir ATTRIBUTE_UNUSED,
+ pid_t pidleader ATTRIBUTE_UNUSED,
+ bool isContainer ATTRIBUTE_UNUSED,
+ const char *partition ATTRIBUTE_UNUSED,
+ int controllers ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+bool virCgroupNewIgnoreError(void)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return false;
+}
+
+int virCgroupRemove(virCgroupPtr group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewPartition(const char *path ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED,
+ int controllers ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewDomainPartition(virCgroupPtr partition ATTRIBUTE_UNUSED,
+ const char *driver ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewVcpu(virCgroupPtr domain ATTRIBUTE_UNUSED,
+ int vcpuid ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewEmulator(virCgroupPtr domain ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupNewDetect(pid_t pid ATTRIBUTE_UNUSED,
+ int controllers ATTRIBUTE_UNUSED,
+ virCgroupPtr *group ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int
+virCgroupSetBlkioDeviceWeight(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *path ATTRIBUTE_UNUSED,
+ unsigned int weight ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupAllowDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *path ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+int virCgroupDenyDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *path ATTRIBUTE_UNUSED,
+ int perms ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupPathOfController(virCgroupPtr group ATTRIBUTE_UNUSED,
+ int controller ATTRIBUTE_UNUSED,
+ const char *key ATTRIBUTE_UNUSED,
+ char **path ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+bool virCgroupHasController(virCgroupPtr cgroup ATTRIBUTE_UNUSED,
+ int controller ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+
+}
+
+int virCgroupSetFreezerState(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *state ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupGetFreezerState(virCgroupPtr group ATTRIBUTE_UNUSED,
+ char **state ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+int virCgroupIsolateMount(virCgroupPtr group ATTRIBUTE_UNUSED,
+ const char *oldroot ATTRIBUTE_UNUSED,
+ const char *mountopts ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+#endif /* VIR_CGROUP_SUPPORTED */
+
+#if defined(VIR_CGROUP_SUPPORTED) && defined(HAVE_KILL)
+/*
+ * Returns 1 if some PIDs are killed, 0 if none are killed, or -1 on error
+ */
+static int virCgroupKillInternal(virCgroupPtr group, int signum, virHashTablePtr pids)
+{
+ int ret = -1;
+ bool killedAny = false;
+ char *keypath = NULL;
+ bool done = false;
+ FILE *fp = NULL;
+ VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
+ group, group->path, signum, pids);
+
+ if (virCgroupPathOfController(group, -1, "tasks", &keypath) < 0)
+ return -1;
+
+ /* PIDs may be forking as we kill them, so loop
+ * until there are no new PIDs found
+ */
+ while (!done) {
+ done = true;
+ if (!(fp = fopen(keypath, "r"))) {
+ if (errno == ENOENT) {
+ VIR_DEBUG("No file %s, assuming done", keypath);
+ killedAny = false;
+ goto done;
+ }
+
+ virReportSystemError(errno,
+ _("Failed to read %s"),
+ keypath);
+ goto cleanup;
+ } else {
+ while (!feof(fp)) {
+ unsigned long pid_value;
+ if (fscanf(fp, "%lu", &pid_value) != 1) {
+ if (feof(fp))
+ break;
+ virReportSystemError(errno,
+ _("Failed to read %s"),
+ keypath);
+ goto cleanup;
+ }
+ if (virHashLookup(pids, (void*)pid_value))
+ continue;
VIR_DEBUG("pid=%lu", pid_value);
/* Cgroups is a Linux concept, so this cast is safe. */
@@ -2800,7 +3179,6 @@ int virCgroupKill(virCgroupPtr group, int signum)
return ret;
}
-
static int virCgroupKillRecursiveInternal(virCgroupPtr group, int signum, virHashTablePtr pids, bool dormdir)
{
int ret = -1;
@@ -2911,7 +3289,7 @@ int virCgroupKillPainfully(virCgroupPtr group)
return ret;
}
-#else /* !(HAVE_KILL, HAVE_MNTENT_H, HAVE_GETMNTENT_R) */
+#else /* !(VIR_CGROUP_SUPPORTED, HAVE_KILL) */
int virCgroupKill(virCgroupPtr group ATTRIBUTE_UNUSED,
int signum ATTRIBUTE_UNUSED)
{
@@ -2933,128 +3311,62 @@ int virCgroupKillPainfully(virCgroupPtr group ATTRIBUTE_UNUSED)
_("Control groups not supported on this platform"));
return -1;
}
-#endif /* HAVE_KILL, HAVE_MNTENT_H, HAVE_GETMNTENT_R */
-
-#ifdef __linux__
-static char *virCgroupIdentifyRoot(virCgroupPtr group)
-{
- char *ret = NULL;
- size_t i;
-
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- char *tmp;
- if (!group->controllers[i].mountPoint)
- continue;
- if (!(tmp = strrchr(group->controllers[i].mountPoint, '/'))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not find directory separator in %s"),
- group->controllers[i].mountPoint);
- return NULL;
- }
-
- if (VIR_STRNDUP(ret, group->controllers[i].mountPoint,
- tmp - group->controllers[i].mountPoint) < 0)
- return NULL;
- return ret;
- }
-
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Could not find any mounted controllers"));
- return NULL;
-}
-
+#endif /* VIR_CGROUP_SUPPORTED, HAVE_KILL */
-int virCgroupIsolateMount(virCgroupPtr group, const char *oldroot,
- const char *mountopts)
+#if defined(VIR_CGROUP_SUPPORTED) && defined(_SC_CLK_TCK)
+int virCgroupGetCpuacctStat(virCgroupPtr group, unsigned long long *user,
+ unsigned long long *sys)
{
+ char *str;
+ char *p;
int ret = -1;
- size_t i;
- char *opts = NULL;
- char *root = NULL;
+ static double scale = -1.0;
- if (!(root = virCgroupIdentifyRoot(group)))
+ if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
+ "cpuacct.stat", &str) < 0)
return -1;
- VIR_DEBUG("Mounting cgroups at '%s'", root);
-
- if (virFileMakePath(root) < 0) {
- virReportSystemError(errno,
- _("Unable to create directory %s"),
- root);
+ if (!(p = STRSKIP(str, "user ")) ||
+ virStrToLong_ull(p, &p, 10, user) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cannot parse user stat '%s'"),
+ p);
goto cleanup;
}
-
- if (virAsprintf(&opts,
- "mode=755,size=65536%s", mountopts) < 0)
- goto cleanup;
-
- if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
- virReportSystemError(errno,
- _("Failed to mount %s on %s type %s"),
- "tmpfs", root, "tmpfs");
+ if (!(p = STRSKIP(p, "\nsystem ")) ||
+ virStrToLong_ull(p, NULL, 10, sys) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cannot parse sys stat '%s'"),
+ p);
goto cleanup;
}
-
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- if (!group->controllers[i].mountPoint)
- continue;
-
- if (!virFileExists(group->controllers[i].mountPoint)) {
- char *src;
- if (virAsprintf(&src, "%s%s%s",
- oldroot,
- group->controllers[i].mountPoint,
- group->controllers[i].placement) < 0)
- goto cleanup;
-
- VIR_DEBUG("Create mount point '%s'", group->controllers[i].mountPoint);
- if (virFileMakePath(group->controllers[i].mountPoint) < 0) {
- virReportSystemError(errno,
- _("Unable to create directory %s"),
- group->controllers[i].mountPoint);
- VIR_FREE(src);
- goto cleanup;
- }
-
- if (mount(src, group->controllers[i].mountPoint, NULL, MS_BIND, NULL) < 0) {
- virReportSystemError(errno,
- _("Failed to bind cgroup '%s' on '%s'"),
- src, group->controllers[i].mountPoint);
- VIR_FREE(src);
- goto cleanup;
- }
-
- VIR_FREE(src);
- }
-
- if (group->controllers[i].linkPoint) {
- VIR_DEBUG("Link mount point '%s' to '%s'",
- group->controllers[i].mountPoint,
- group->controllers[i].linkPoint);
- if (symlink(group->controllers[i].mountPoint,
- group->controllers[i].linkPoint) < 0) {
- virReportSystemError(errno,
- _("Unable to symlink directory %s to %s"),
- group->controllers[i].mountPoint,
- group->controllers[i].linkPoint);
- return -1;
- }
+ /* times reported are in system ticks (generally 100 Hz), but that
+ * rate can theoretically vary between machines. Scale things
+ * into approximate nanoseconds. */
+ if (scale < 0) {
+ long ticks_per_sec = sysconf(_SC_CLK_TCK);
+ if (ticks_per_sec == -1) {
+ virReportSystemError(errno, "%s",
+ _("Cannot determine system clock HZ"));
+ goto cleanup;
}
+ scale = 1000000000.0 / ticks_per_sec;
}
- ret = 0;
+ *user *= scale;
+ *sys *= scale;
+ ret = 0;
cleanup:
- VIR_FREE(root);
- VIR_FREE(opts);
+ VIR_FREE(str);
return ret;
}
-#else /* __linux__ */
-int virCgroupIsolateMount(virCgroupPtr group ATTRIBUTE_UNUSED,
- const char *oldroot ATTRIBUTE_UNUSED,
- const char *mountopts ATTRIBUTE_UNUSED)
+#else
+int virCgroupGetCpuacctStat(virCgroupPtr group ATTRIBUTE_UNUSED,
+ unsigned long long *user ATTRIBUTE_UNUSED,
+ unsigned long long *sys ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Control groups not supported on this platform"));
return -1;
}
-#endif /* __linux__ */
+#endif
--
1.8.1.4
11 years, 4 months
[libvirt] [libvirt-sandbox][PATCH v2] Update man page about virt-sandbox-service
by Zhe Peng
Add upgrade and remove start,stop,list
---
bin/virt-sandbox-service.pod | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/bin/virt-sandbox-service.pod b/bin/virt-sandbox-service.pod
index 32caad9..7752145 100644
--- a/bin/virt-sandbox-service.pod
+++ b/bin/virt-sandbox-service.pod
@@ -4,7 +4,7 @@ virt-sandbox-service - Secure container tool
=head1 SYNOPSIS
- {create,clone,connect,delete,execute,list,reload,start,stop}
+ {create,clone,connect,delete,execute,reload,upgrade}
commands:
@@ -20,6 +20,8 @@ virt-sandbox-service - Secure container tool
reload Reload a running sandbox container
+ upgrade Upgrade an existing sandbox container
+
=head1 DESCRIPTION
virt-sandbox-service is used to provision secure sandboxed system services.
@@ -52,7 +54,7 @@ supported currently).
=head1 SEE ALSO
-C<libvirt(8)>, C<selinux(8)>, C<systemd(8)>, C<virt-sandbox(1)>, C<virt-sandbox-service-create(1)>, C<virt-sandbox-service-clone(1)>, C<virt-sandbox-service-connect(1)>, C<virt-sandbox-service-delete(1)>, C<virt-sandbox-service-execute(1)>, C<virt-sandbox-service-reload(1)>
+C<libvirt(8)>, C<selinux(8)>, C<systemd(8)>, C<virt-sandbox(1)>, C<virt-sandbox-service-create(1)>, C<virt-sandbox-service-clone(1)>, C<virt-sandbox-service-connect(1)>, C<virt-sandbox-service-delete(1)>, C<virt-sandbox-service-execute(1)>, C<virt-sandbox-service-reload(1)>, C<virt-sandbox-service-upgrade(1)>
=head1 FILES
--
1.7.7.6
11 years, 4 months
[libvirt] [libvirt-sandbox][PATCH] Update man page about virt-sandbox-service
by Zhe Peng
Add upgrade and remove start,stop,list
---
bin/virt-sandbox-service.pod | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/bin/virt-sandbox-service.pod b/bin/virt-sandbox-service.pod
index 32caad9..e8ab55e 100644
--- a/bin/virt-sandbox-service.pod
+++ b/bin/virt-sandbox-service.pod
@@ -4,7 +4,7 @@ virt-sandbox-service - Secure container tool
=head1 SYNOPSIS
- {create,clone,connect,delete,execute,list,reload,start,stop}
+ {create,clone,connect,delete,execute,reload,upgrade}
commands:
@@ -20,6 +20,8 @@ virt-sandbox-service - Secure container tool
reload Reload a running sandbox container
+ upgrade Upgrade an existing Secure container
+
=head1 DESCRIPTION
virt-sandbox-service is used to provision secure sandboxed system services.
@@ -52,7 +54,7 @@ supported currently).
=head1 SEE ALSO
-C<libvirt(8)>, C<selinux(8)>, C<systemd(8)>, C<virt-sandbox(1)>, C<virt-sandbox-service-create(1)>, C<virt-sandbox-service-clone(1)>, C<virt-sandbox-service-connect(1)>, C<virt-sandbox-service-delete(1)>, C<virt-sandbox-service-execute(1)>, C<virt-sandbox-service-reload(1)>
+C<libvirt(8)>, C<selinux(8)>, C<systemd(8)>, C<virt-sandbox(1)>, C<virt-sandbox-service-create(1)>, C<virt-sandbox-service-clone(1)>, C<virt-sandbox-service-connect(1)>, C<virt-sandbox-service-delete(1)>, C<virt-sandbox-service-execute(1)>, C<virt-sandbox-service-reload(1)>, C<virt-sandbox-service-upgrade(1)>
=head1 FILES
--
1.7.7.6
11 years, 4 months
[libvirt] rhel 5 'make check' failure
by Eric Blake
I ran out of time to investigate today, in case someone wants to beat me
to a fix:
> virsystemdmock.c: In function 'dbus_connection_send_with_reply_and_block':
> virsystemdmod.c:68: warning: implicit declaration of function 'dbus_message_set_serial'
this failure occurred on RHEL 5; dbus-devel-1.1.2-20.el5.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
11 years, 4 months
[libvirt] [PATCHv2] build: fix configure detection of if_bridge.h on RHEL 6, try 2
by Eric Blake
This is a second attempt at fixing the problem first attempted
in commit 2df8d99; basically undoing the fact that it was
reverted in commit 43cee32f, plus fixing one more issue: the
code in configure.ac has to EXACTLY match virnetdevbridge.c
with regards to declaring in6 types before using if_bridge.h.
The rest of this commit message borrows from the original:
A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support
Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:
configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2 conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1
I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.
* configure.ac (if_bridge.h): Avoid conflicting type definitions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Although this fixes a build-breaker, this time I'm awaiting review
since my first attempt caused grief on Fedora.
configure.ac | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index a155790..e5dd67b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -997,7 +997,15 @@ if test "$with_linux" = "yes"; then
if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then
AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],,
[AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])],
- [[#include <netinet/in.h>
+ [[/* The kernel folks broke their headers when used with particular
+ * glibc versions; although the structs are ABI compatible, the
+ * C type system doesn't like struct redefinitions. We work around
+ * the problem here in the same manner as in virnetdevbridge.c. */
+ #include <netinet/in.h>
+ #define in6_addr in6_addr_
+ #define sockaddr_in6 sockaddr_in6_
+ #define ipv6_mreq ipv6_mreq_
+ #include <linux/in6.h>
]])
fi
fi
--
1.8.3.1
11 years, 4 months
[libvirt] Patch for BUG ID 994657
by Schmaus, John M. (John)
Hi All,
Here is the change I made to address the SIGSEGV we were seeing in libvirtd when attempting to create a new VM via virt-install:
- We call virDomainDefFree after xenDaemonCreateXML returns to xenUnifiedDomainCreateXML.
- xenUnifiedDomainCreateXML passes def to virGetDomain after XenDaemonCreateXML returns and before it calls virGetDomain.
- xenUnifiedDomainCreateXML calls virDomainDefFree(def) when it's done with def, so no need to free inside xenUnifiedDomainCreateXML.
------------------------ patch -------------------------
--- /tmp/xend_internal.c 2013-08-07 12:03:03.000000000 -0600
+++ src/xen/xend_internal.c 2013-08-07 08:51:49.000000000 -0600
@@ -2171,7 +2171,9 @@
if (xenDaemonDomainResume(conn, def) < 0)
goto error;
- virDomainDefFree(def);
+ // We call this a little later and still want to use def, so
+ // don't free it just yet.
+ //virDomainDefFree(def);
return 0;
11 years, 4 months
[libvirt] [PATCH] build: fix configure detection of if_bridge.h on RHEL 6
by Eric Blake
A fresh checkout on a RHEL 6 machine with these packages:
kernel-headers-2.6.32-405.el6.x86_64
glibc-2.12-1.128.el6.x86_64
failed to configure with this message:
checking for linux/if_bridge.h... no
configure: error: You must install kernel-headers in order to compile libvirt with QEMU or LXC support
Digging in config.log, we see that the problem is identical to
what we fixed earlier in commit d12c2811:
configure:98831: checking for linux/if_bridge.h
configure:98853: gcc -std=gnu99 -c -g -O2 conftest.c >&5
In file included from /usr/include/linux/if_bridge.h:17,
from conftest.c:559:
/usr/include/linux/in6.h:31: error: redefinition of 'struct in6_addr'
/usr/include/linux/in6.h:48: error: redefinition of 'struct sockaddr_in6'
/usr/include/linux/in6.h:56: error: redefinition of 'struct ipv6_mreq'
configure:98860: $? = 1
I had not hit it earlier because I was using incremental builds,
where config.cache had shielded me from the kernel-headers breakage.
* configure.ac (if_bridge.h): Avoid conflicting type definitions.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule, and backporting to v1.1.1-maint
configure.ac | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 944a870..02f3e4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -999,7 +999,14 @@ if test "$with_linux" = "yes"; then
if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then
AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],,
[AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support])],
- [[#include <netinet/in.h>
+ [[/* The kernel folks broke their headers when used with particular
+ * glibc versions; although the structs are ABI compatible, the
+ * C type system doesn't like struct redefinitions. We work around
+ * the problem here in the same manner as in virnetdevbridge.c. */
+ #include <netinet/in.h>
+ #define in6_addr in6_addr_
+ #define sockaddr_in6 sockaddr_in6_
+ #define ipv6_mreq ipv6_mreq_
]])
fi
fi
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCH] virthread: include config.h in the header file
by Paul Moore
The virthread.h header file includes platform specific header files
that help define the thread implementation, see code snippet below.
# ifdef WIN32
# include "virthreadwin32.h"
# elif defined HAVE_PTHREAD_MUTEXATTR_INIT
# include "virthreadpthread.h"
# else
# error "Either pthreads or Win32 threads are required"
# endif
Unfortunately, virthread.h does not include config.h so every source
file which includes virthread.h must also include config.h, regardless
of if the source file directly needs definitions in config.h. This
patch adds config.h to virthread.h in an effort to help simplify
things.
Signed-off-by: Paul Moore <pmoore(a)redhat.com>
---
src/util/virthread.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 84d3bdc..091cdd0 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -22,6 +22,8 @@
#ifndef __THREADS_H_
# define __THREADS_H_
+#include <config.h>
+
# include "internal.h"
# include "virerror.h"
11 years, 4 months
[libvirt] [PATCH v2 0/3] Add tests for network update XML parsing
by Ján Tomko
v1: https://www.redhat.com/archives/libvir-list/2013-July/msg01971.html
v2: remove the spaces from other elements instead of adding one
Ján Tomko (3):
Remove the space before the slash in network XML
Reverse logic allowing partial DHCP host XML
Test network XML update
src/conf/network_conf.h | 9 +
src/conf/network_conf.c | 47 +--
src/libvirt_private.syms | 1 +
src/network/default.xml | 4 +-
src/test/test_driver.c | 4 +-
tests/Makefile.am | 9 +-
tests/networkxml2xmltest.c | 3 +
tests/networkxml2xmlupdatetest.c | 372 +++++++++++++++++++++
tests/networkxml2confdata/dhcp6-nat-network.xml | 20 +-
tests/networkxml2confdata/dhcp6-network.xml | 14 +-
.../dhcp6host-routed-network.xml | 16 +-
tests/networkxml2confdata/isolated-network.xml | 4 +-
.../networkxml2confdata/nat-network-dns-hosts.xml | 2 +-
.../nat-network-dns-srv-record-minimal.xml | 10 +-
.../nat-network-dns-srv-record.xml | 10 +-
.../nat-network-dns-txt-record.xml | 10 +-
tests/networkxml2confdata/nat-network.xml | 8 +-
tests/networkxml2confdata/netboot-network.xml | 8 +-
.../networkxml2confdata/netboot-proxy-network.xml | 6 +-
tests/networkxml2confdata/routed-network.xml | 2 +-
tests/networkxml2xmlin/bandwidth-network.xml | 4 +-
.../networkxml2xmlin/dhcp6host-routed-network.xml | 16 +-
tests/networkxml2xmlin/empty-allow-ipv6.xml | 2 +-
tests/networkxml2xmlin/isolated-network.xml | 4 +-
tests/networkxml2xmlin/nat-network-dns-hosts.xml | 2 +-
.../nat-network-dns-srv-record-minimal.xml | 10 +-
.../nat-network-dns-srv-record.xml | 10 +-
.../nat-network-dns-srv-records.xml | 27 ++
.../nat-network-dns-txt-record.xml | 10 +-
tests/networkxml2xmlin/nat-network.xml | 8 +-
tests/networkxml2xmlin/netboot-network.xml | 6 +-
tests/networkxml2xmlin/netboot-proxy-network.xml | 4 +-
tests/networkxml2xmlin/routed-network.xml | 2 +-
tests/networkxml2xmlout/bandwidth-network.xml | 4 +-
.../networkxml2xmlout/dhcp6host-routed-network.xml | 16 +-
tests/networkxml2xmlout/empty-allow-ipv6.xml | 2 +-
tests/networkxml2xmlout/host-bridge-net.xml | 2 +-
tests/networkxml2xmlout/isolated-network.xml | 4 +-
tests/networkxml2xmlout/nat-network-dns-hosts.xml | 2 +-
.../nat-network-dns-srv-record-minimal.xml | 10 +-
.../nat-network-dns-srv-record.xml | 10 +-
.../nat-network-dns-srv-records.xml | 27 ++
.../nat-network-dns-txt-record.xml | 10 +-
tests/networkxml2xmlout/nat-network.xml | 8 +-
tests/networkxml2xmlout/netboot-network.xml | 8 +-
tests/networkxml2xmlout/netboot-proxy-network.xml | 6 +-
tests/networkxml2xmlout/routed-network.xml | 2 +-
.../networkxml2xmlupdatein/dhcp-range-existing.xml | 1 +
tests/networkxml2xmlupdatein/dhcp-range.xml | 1 +
.../dns-host-gateway-incomplete.xml | 3 +
tests/networkxml2xmlupdatein/dns-host-pudding.xml | 3 +
.../dns-txt-record-example.xml | 1 +
.../dns-txt-record-snowman.xml | 1 +
tests/networkxml2xmlupdatein/host-existing.xml | 1 +
tests/networkxml2xmlupdatein/host-incomplete.xml | 1 +
.../networkxml2xmlupdatein/host-new-incomplete.xml | 1 +
tests/networkxml2xmlupdatein/host-new.xml | 1 +
tests/networkxml2xmlupdatein/host-updated.xml | 1 +
tests/networkxml2xmlupdatein/interface-eth1.xml | 1 +
tests/networkxml2xmlupdatein/interface-eth47.xml | 1 +
.../networkxml2xmlupdatein/portgroup-alice-new.xml | 10 +
tests/networkxml2xmlupdatein/portgroup-alison.xml | 11 +
tests/networkxml2xmlupdatein/srv-record-donkey.xml | 1 +
.../networkxml2xmlupdatein/srv-record-invalid.xml | 1 +
.../networkxml2xmlupdatein/srv-record-protocol.xml | 1 +
.../networkxml2xmlupdatein/srv-record-service.xml | 1 +
tests/networkxml2xmlupdatein/srv-record.xml | 1 +
.../networkxml2xmlupdatein/unparsable-dns-host.xml | 1 +
.../dhcp6host-routed-network-another-range.xml | 27 ++
.../dhcp6host-routed-network-range.xml | 27 ++
.../nat-network-dns-more-hosts.xml | 19 ++
.../nat-network-dns-srv-record.xml | 26 ++
.../nat-network-dns-srv-records.xml | 27 ++
.../nat-network-dns-txt-none.xml | 23 ++
.../nat-network-dns-txt-records.xml | 27 ++
.../nat-network-forward-ifaces.xml | 27 ++
.../nat-network-host-updated.xml | 23 ++
.../networkxml2xmlupdateout/nat-network-hosts.xml | 24 ++
.../nat-network-no-forward-ifaces.xml | 24 ++
.../nat-network-no-hosts.xml | 10 +
.../nat-network-no-range.xml | 22 ++
.../nat-network-one-host.xml | 22 ++
tests/networkxml2xmlupdateout/nat-network.xml | 23 ++
.../openvswitch-net-modified.xml | 33 ++
.../openvswitch-net-more-portgroups.xml | 44 +++
.../openvswitch-net-without-alice.xml | 23 ++
86 files changed, 1100 insertions(+), 170 deletions(-)
create mode 100644 tests/networkxml2xmlupdatetest.c
create mode 100644 tests/networkxml2xmlin/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlout/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlupdatein/dhcp-range-existing.xml
create mode 100644 tests/networkxml2xmlupdatein/dhcp-range.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-host-gateway-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-host-pudding.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-txt-record-example.xml
create mode 100644 tests/networkxml2xmlupdatein/dns-txt-record-snowman.xml
create mode 100644 tests/networkxml2xmlupdatein/host-existing.xml
create mode 100644 tests/networkxml2xmlupdatein/host-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/host-new-incomplete.xml
create mode 100644 tests/networkxml2xmlupdatein/host-new.xml
create mode 100644 tests/networkxml2xmlupdatein/host-updated.xml
create mode 100644 tests/networkxml2xmlupdatein/interface-eth1.xml
create mode 100644 tests/networkxml2xmlupdatein/interface-eth47.xml
create mode 100644 tests/networkxml2xmlupdatein/portgroup-alice-new.xml
create mode 100644 tests/networkxml2xmlupdatein/portgroup-alison.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-donkey.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-invalid.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-protocol.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record-service.xml
create mode 100644 tests/networkxml2xmlupdatein/srv-record.xml
create mode 100644 tests/networkxml2xmlupdatein/unparsable-dns-host.xml
create mode 100644 tests/networkxml2xmlupdateout/dhcp6host-routed-network-another-range.xml
create mode 100644 tests/networkxml2xmlupdateout/dhcp6host-routed-network-range.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-more-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-srv-record.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-srv-records.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-txt-none.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-dns-txt-records.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-forward-ifaces.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-host-updated.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-forward-ifaces.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-hosts.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-no-range.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network-one-host.xml
create mode 100644 tests/networkxml2xmlupdateout/nat-network.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-modified.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml
create mode 100644 tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml
--
1.8.1.5
11 years, 4 months