diff --git a/cgmajor.patch b/cgmajor.patch deleted file mode 100644 index d314f7a..0000000 --- a/cgmajor.patch +++ /dev/null @@ -1,55 +0,0 @@ -Index: libvirt-0.4.6/src/cgroup.c -=================================================================== ---- libvirt-0.4.6.orig/src/cgroup.c -+++ libvirt-0.4.6/src/cgroup.c -@@ -761,6 +761,36 @@ out: - return rc; - } - -+/** -+ * virCgroupAllowDeviceMajor: -+ * -+ * @group: The cgroup to allow an entire device major type for -+ * @type: The device type (i.e., 'c' or 'b') -+ * @major: The major number of the device type -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupAllowDeviceMajor(virCgroupPtr group, -+ char type, -+ int major) -+{ -+ int rc; -+ char *devstr = NULL; -+ -+ if (asprintf(&devstr, "%c %i:* rwm", type, major) == -1) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ rc = virCgroupSetValueStr(group, -+ "devices.allow", -+ devstr); -+ out: -+ VIR_FREE(devstr); -+ -+ return rc; -+} -+ - int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares) - { - return virCgroupSetValueU64(group, "cpu.shares", (uint64_t)shares); -Index: libvirt-0.4.6/src/cgroup.h -=================================================================== ---- libvirt-0.4.6.orig/src/cgroup.h -+++ libvirt-0.4.6/src/cgroup.h -@@ -35,6 +35,9 @@ int virCgroupAllowDevice(virCgroupPtr gr - char type, - int major, - int minor); -+int virCgroupAllowDeviceMajor(virCgroupPtr group, -+ char type, -+ int major); - - int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares); - int virCgroupGetCpuShares(virCgroupPtr group, unsigned long *shares); diff --git a/cgroup.patch b/cgroup.patch deleted file mode 100644 index a16cdfe..0000000 --- a/cgroup.patch +++ /dev/null @@ -1,822 +0,0 @@ -# HG changeset patch -# User danms -# Date 1223056682 0 -# Node ID 64f19f607bc6837fe2411cfdb2942b13ce8902c1 -# Parent a28490b116b0430aa0d4f579bba57d52793312ed -[r2008-10-03 17:58:02 by danms] Add forgotten cgroup.{c,h} and ChangeLog - -Index: libvirt-0.4.6/src/cgroup.c -=================================================================== ---- /dev/null -+++ libvirt-0.4.6/src/cgroup.c -@@ -0,0 +1,762 @@ -+/* -+ * cgroup.c: Tools for managing cgroups -+ * -+ * Copyright IBM Corp. 2008 -+ * -+ * See COPYING.LIB for the License of this software -+ * -+ * Authors: -+ * Dan Smith -+ */ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "internal.h" -+#include "util.h" -+#include "memory.h" -+#include "cgroup.h" -+ -+#define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) -+#define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) -+ -+#define CGROUP_MAX_VAL 512 -+ -+struct virCgroup { -+ char *path; -+}; -+ -+const char *supported_controllers[] = { -+ "memory", -+ "devices", -+ NULL -+}; -+ -+/** -+ * virCgroupFree: -+ * -+ * @group: The group structure to free -+ */ -+void virCgroupFree(virCgroupPtr *group) -+{ -+ if (*group != NULL) { -+ VIR_FREE((*group)->path); -+ VIR_FREE(*group); -+ *group = NULL; -+ } -+} -+ -+static virCgroupPtr virCgroupGetMount(const char *controller) -+{ -+ FILE *mounts; -+ struct mntent entry; -+ char buf[CGROUP_MAX_VAL]; -+ virCgroupPtr root = NULL; -+ -+ if (VIR_ALLOC(root) != 0) -+ return NULL; -+ -+ mounts = fopen("/proc/mounts", "r"); -+ if (mounts == NULL) { -+ DEBUG0("Unable to open /proc/mounts: %m"); -+ goto err; -+ } -+ -+ while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) { -+ if (STREQ(entry.mnt_type, "cgroup") && -+ (strstr(entry.mnt_opts, controller))) { -+ root->path = strdup(entry.mnt_dir); -+ break; -+ } -+ } -+ -+ DEBUG("Mount for %s is %s\n", controller, root->path); -+ -+ if (root->path == NULL) { -+ DEBUG0("Did not find cgroup mount"); -+ goto err; -+ } -+ -+ fclose(mounts); -+ -+ return root; -+err: -+ virCgroupFree(&root); -+ -+ return NULL; -+} -+ -+/** -+ * virCgroupHaveSupport: -+ * -+ * Returns 0 if support is present, negative if not -+ */ -+int virCgroupHaveSupport(void) -+{ -+ virCgroupPtr root; -+ int i; -+ -+ for (i = 0; supported_controllers[i] != NULL; i++) { -+ root = virCgroupGetMount(supported_controllers[i]); -+ if (root == NULL) -+ return -1; -+ virCgroupFree(&root); -+ } -+ -+ return 0; -+} -+ -+static int virCgroupPathOfGroup(const char *group, -+ const char *controller, -+ char **path) -+{ -+ virCgroupPtr root = NULL; -+ int rc = 0; -+ -+ root = virCgroupGetMount(controller); -+ if (root == NULL) { -+ rc = -ENOTDIR; -+ goto out; -+ } -+ -+ if (asprintf(path, "%s/%s", root->path, group) == -1) -+ rc = -ENOMEM; -+out: -+ virCgroupFree(&root); -+ -+ return rc; -+} -+ -+static int virCgroupPathOf(const char *grppath, -+ const char *key, -+ char **path) -+{ -+ virCgroupPtr root; -+ int rc = 0; -+ char *controller = NULL; -+ -+ if (strchr(key, '.') == NULL) -+ return -EINVAL; -+ -+ if (sscanf(key, "%a[^.]", &controller) != 1) -+ return -EINVAL; -+ -+ root = virCgroupGetMount(controller); -+ if (root == NULL) { -+ rc = -ENOTDIR; -+ goto out; -+ } -+ -+ if (asprintf(path, "%s/%s/%s", root->path, grppath, key) == -1) -+ rc = -ENOMEM; -+out: -+ virCgroupFree(&root); -+ VIR_FREE(controller); -+ -+ return rc; -+} -+ -+static int virCgroupSetValueStr(virCgroupPtr group, -+ const char *key, -+ const char *value) -+{ -+ int fd = -1; -+ int rc = 0; -+ char *keypath = NULL; -+ -+ rc = virCgroupPathOf(group->path, key, &keypath); -+ if (rc != 0) -+ return rc; -+ -+ fd = open(keypath, O_WRONLY); -+ if (fd < 0) { -+ DEBUG("Unable to open %s: %m", keypath); -+ rc = -ENOENT; -+ goto out; -+ } -+ -+ DEBUG("Writing '%s' to '%s'", value, keypath); -+ -+ rc = safewrite(fd, value, strlen(value)); -+ if (rc < 0) { -+ DEBUG("Failed to write value '%s': %m", value); -+ rc = -errno; -+ goto out; -+ } else if (rc != strlen(value)) { -+ DEBUG("Short write of value '%s'", value); -+ rc = -ENOSPC; -+ goto out; -+ } -+ -+ rc = 0; -+out: -+ VIR_FREE(keypath); -+ close(fd); -+ -+ return rc; -+} -+ -+static int virCgroupSetValueU64(virCgroupPtr group, -+ const char *key, -+ uint64_t value) -+{ -+ char *strval = NULL; -+ int rc; -+ -+ if (asprintf(&strval, "%" PRIu64, value) == -1) -+ return -ENOMEM; -+ -+ rc = virCgroupSetValueStr(group, key, strval); -+ -+ VIR_FREE(strval); -+ -+ return rc; -+} -+ -+#if 0 -+/* This is included for completeness, but not yet used */ -+ -+static int virCgroupSetValueI64(virCgroupPtr group, -+ const char *key, -+ int64_t value) -+{ -+ char *strval = NULL; -+ int rc; -+ -+ if (asprintf(&strval, "%" PRIi64, value) == -1) -+ return -ENOMEM; -+ -+ rc = virCgroupSetValueStr(group, key, strval); -+ -+ VIR_FREE(strval); -+ -+ return rc; -+} -+ -+static int virCgroupGetValueStr(virCgroupPtr group, -+ const char *key, -+ char **value) -+{ -+ int fd = -1; -+ int rc; -+ char *keypath = NULL; -+ char buf[CGROUP_MAX_VAL]; -+ -+ memset(buf, 0, sizeof(buf)); -+ -+ rc = virCgroupPathOf(group->path, key, &keypath); -+ if (rc != 0) { -+ DEBUG("No path of %s, %s", group->path, key); -+ return rc; -+ } -+ -+ fd = open(keypath, O_RDONLY); -+ if (fd < 0) { -+ DEBUG("Unable to open %s: %m", keypath); -+ rc = -ENOENT; -+ goto out; -+ } -+ -+ rc = saferead(fd, buf, sizeof(buf)); -+ if (rc < 0) { -+ DEBUG("Failed to read %s: %m\n", keypath); -+ rc = -errno; -+ goto out; -+ } else if (rc == 0) { -+ DEBUG("Short read of %s\n", keypath); -+ rc = -EIO; -+ goto out; -+ } -+ -+ *value = strdup(buf); -+ if (*value == NULL) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ rc = 0; -+out: -+ VIR_FREE(keypath); -+ close(fd); -+ -+ return rc; -+} -+ -+static int virCgroupGetValueU64(virCgroupPtr group, -+ const char *key, -+ uint64_t *value) -+{ -+ char *strval = NULL; -+ int rc = 0; -+ -+ rc = virCgroupGetValueStr(group, key, &strval); -+ if (rc != 0) -+ goto out; -+ -+ if (sscanf(strval, "%" SCNu64, value) != 1) -+ rc = -EINVAL; -+out: -+ VIR_FREE(strval); -+ -+ return rc; -+} -+ -+static int virCgroupGetValueI64(virCgroupPtr group, -+ const char *key, -+ int64_t *value) -+{ -+ char *strval = NULL; -+ int rc = 0; -+ -+ rc = virCgroupGetValueStr(group, key, &strval); -+ if (rc != 0) -+ goto out; -+ -+ if (sscanf(strval, "%" SCNi64, value) != 1) -+ rc = -EINVAL; -+out: -+ VIR_FREE(strval); -+ -+ return rc; -+} -+#endif -+ -+static int _virCgroupInherit(const char *path, -+ const char *key) -+{ -+ int rc = 0; -+ int fd = -1; -+ char buf[CGROUP_MAX_VAL]; -+ char *keypath = NULL; -+ char *pkeypath = NULL; -+ -+ memset(buf, 0, sizeof(buf)); -+ -+ if (asprintf(&keypath, "%s/%s", path, key) == -1) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ if (access(keypath, F_OK) != 0) { -+ DEBUG("Group %s has no key %s\n", path, key); -+ goto out; -+ } -+ -+ if (asprintf(&pkeypath, "%s/../%s", path, key) == -1) { -+ rc = -ENOMEM; -+ VIR_FREE(keypath); -+ goto out; -+ } -+ -+ fd = open(pkeypath, O_RDONLY); -+ if (fd < 0) { -+ rc = -errno; -+ goto out; -+ } -+ -+ if (saferead(fd, buf, sizeof(buf)) <= 0) { -+ rc = -errno; -+ goto out; -+ } -+ -+ close(fd); -+ -+ fd = open(keypath, O_WRONLY); -+ if (fd < 0) { -+ rc = -errno; -+ goto out; -+ } -+ -+ if (safewrite(fd, buf, strlen(buf)) != strlen(buf)) { -+ rc = -errno; -+ goto out; -+ } -+ -+out: -+ VIR_FREE(keypath); -+ VIR_FREE(pkeypath); -+ close(fd); -+ -+ return rc; -+} -+ -+static int virCgroupInherit(const char *grppath) -+{ -+ int i; -+ int rc = 0; -+ const char *inherit_values[] = { -+ "cpuset.cpus", -+ "cpuset.mems", -+ NULL -+ }; -+ -+ for (i = 0; inherit_values[i] != NULL; i++) { -+ const char *key = inherit_values[i]; -+ -+ rc = _virCgroupInherit(grppath, key); -+ if (rc != 0) { -+ DEBUG("inherit of %s failed\n", key); -+ break; -+ } -+ } -+ -+ return rc; -+} -+ -+static int virCgroupMakeGroup(const char *name) -+{ -+ int i; -+ int rc = 0; -+ -+ for (i = 0; supported_controllers[i] != NULL; i++) { -+ char *path = NULL; -+ virCgroupPtr root; -+ -+ root = virCgroupGetMount(supported_controllers[i]); -+ if (root == NULL) -+ continue; -+ -+ rc = virCgroupPathOfGroup(name, supported_controllers[i], &path); -+ if (rc != 0) { -+ virCgroupFree(&root); -+ break; -+ } -+ -+ virCgroupFree(&root); -+ -+ if (access(path, F_OK) != 0) { -+ if (mkdir(path, 0655) < 0) { -+ rc = -errno; -+ VIR_FREE(path); -+ break; -+ } -+ virCgroupInherit(path); -+ } -+ -+ VIR_FREE(path); -+ } -+ -+ return rc; -+} -+ -+static int virCgroupRoot(virCgroupPtr *root) -+{ -+ int rc = 0; -+ char *grppath = NULL; -+ -+ if (VIR_ALLOC((*root)) != 0) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ (*root)->path = strdup("libvirt"); -+ if ((*root)->path == NULL) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ rc = virCgroupMakeGroup((*root)->path); -+out: -+ if (rc != 0) -+ virCgroupFree(root); -+ VIR_FREE(grppath); -+ -+ return rc; -+} -+ -+static int virCgroupNew(virCgroupPtr *parent, -+ const char *group, -+ virCgroupPtr *newgroup) -+{ -+ int rc = 0; -+ char *typpath = NULL; -+ -+ *newgroup = NULL; -+ -+ if (*parent == NULL) { -+ rc = virCgroupRoot(parent); -+ if (rc != 0) -+ goto err; -+ } -+ -+ if (VIR_ALLOC((*newgroup)) != 0) { -+ rc = -ENOMEM; -+ goto err; -+ } -+ -+ rc = asprintf(&((*newgroup)->path), -+ "%s/%s", -+ (*parent)->path, -+ group); -+ if (rc == -1) { -+ rc = -ENOMEM; -+ goto err; -+ } -+ -+ rc = 0; -+ -+ return rc; -+err: -+ virCgroupFree(newgroup); -+ *newgroup = NULL; -+ -+ VIR_FREE(typpath); -+ -+ return rc; -+} -+ -+static int virCgroupOpen(virCgroupPtr parent, -+ const char *group, -+ virCgroupPtr *newgroup) -+{ -+ int rc = 0; -+ char *grppath = NULL; -+ bool free_parent = (parent == NULL); -+ -+ rc = virCgroupNew(&parent, group, newgroup); -+ if (rc != 0) -+ goto err; -+ -+ if (free_parent) -+ virCgroupFree(&parent); -+ -+ rc = virCgroupPathOfGroup((*newgroup)->path, -+ supported_controllers[0], -+ &grppath); -+ if (rc != 0) -+ goto err; -+ -+ if (access(grppath, F_OK) != 0) { -+ rc = -ENOENT; -+ goto err; -+ } -+ -+ return rc; -+err: -+ virCgroupFree(newgroup); -+ *newgroup = NULL; -+ -+ return rc; -+} -+ -+static int virCgroupCreate(virCgroupPtr parent, -+ const char *group, -+ virCgroupPtr *newgroup) -+{ -+ int rc = 0; -+ bool free_parent = (parent == NULL); -+ -+ rc = virCgroupNew(&parent, group, newgroup); -+ if (rc != 0) { -+ DEBUG0("Unable to allocate new virCgroup structure"); -+ goto err; -+ } -+ -+ rc = virCgroupMakeGroup((*newgroup)->path); -+ if (rc != 0) -+ goto err; -+ -+ if (free_parent) -+ virCgroupFree(&parent); -+ -+ return rc; -+err: -+ virCgroupFree(newgroup); -+ *newgroup = NULL; -+ -+ if (free_parent) -+ virCgroupFree(&parent); -+ -+ return rc; -+} -+ -+/** -+ * virCgroupRemove: -+ * -+ * @group: The group to be removed -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupRemove(virCgroupPtr group) -+{ -+ int rc = 0; -+ int i; -+ char *grppath = NULL; -+ -+ for (i = 0; supported_controllers[i] != NULL; i++) { -+ if (virCgroupPathOfGroup(group->path, -+ supported_controllers[i], -+ &grppath) != 0) -+ continue; -+ -+ if (rmdir(grppath) != 0) -+ rc = -errno; -+ -+ VIR_FREE(grppath); -+ } -+ -+ return rc; -+} -+ -+/** -+ * virCgroupAddTask: -+ * -+ * @group: The cgroup to add a task to -+ * @pid: The pid of the task to add -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupAddTask(virCgroupPtr group, pid_t pid) -+{ -+ int rc = 0; -+ int fd = -1; -+ int i; -+ char *grppath = NULL; -+ char *taskpath = NULL; -+ char *pidstr = NULL; -+ -+ for (i = 0; supported_controllers[i] != NULL; i++) { -+ rc = virCgroupPathOfGroup(group->path, -+ supported_controllers[i], -+ &grppath); -+ if (rc != 0) -+ goto done; -+ -+ if (asprintf(&taskpath, "%s/tasks", grppath) == -1) { -+ rc = -ENOMEM; -+ goto done; -+ } -+ -+ fd = open(taskpath, O_WRONLY); -+ if (fd < 0) { -+ rc = -errno; -+ goto done; -+ } -+ -+ if (asprintf(&pidstr, "%lu", (unsigned long)pid) == -1) { -+ rc = -ENOMEM; -+ goto done; -+ } -+ -+ if (write(fd, pidstr, strlen(pidstr)) <= 0) { -+ rc = -errno; -+ goto done; -+ } -+ -+ done: -+ VIR_FREE(grppath); -+ VIR_FREE(taskpath); -+ VIR_FREE(pidstr); -+ close(fd); -+ -+ if (rc != 0) -+ break; -+ } -+ -+ return rc; -+} -+ -+/** -+ * virCgroupForDomain: -+ * -+ * @def: Domain definition to create cgroup for -+ * @driverName: Classification of this domain type (e.g., xen, qemu, lxc) -+ * @group: Pointer to returned virCgroupPtr -+ * -+ * Returns 0 on success -+ */ -+int virCgroupForDomain(virDomainDefPtr def, -+ const char *driverName, -+ virCgroupPtr *group) -+{ -+ int rc; -+ virCgroupPtr typegrp = NULL; -+ -+ rc = virCgroupOpen(NULL, driverName, &typegrp); -+ if (rc == -ENOENT) { -+ rc = virCgroupCreate(NULL, driverName, &typegrp); -+ if (rc != 0) -+ goto out; -+ } else if (rc != 0) -+ goto out; -+ -+ rc = virCgroupOpen(typegrp, def->name, group); -+ if (rc == -ENOENT) -+ rc = virCgroupCreate(typegrp, def->name, group); -+out: -+ virCgroupFree(&typegrp); -+ -+ return rc; -+} -+ -+/** -+ * virCgroupSetMemory: -+ * -+ * @group: The cgroup to change memory for -+ * @kb: The memory amount in kilobytes -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupSetMemory(virCgroupPtr group, unsigned long kb) -+{ -+ return virCgroupSetValueU64(group, -+ "memory.limit_in_bytes", -+ kb << 10); -+} -+ -+/** -+ * virCgroupDenyAllDevices: -+ * -+ * @group: The cgroup to deny devices for -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupDenyAllDevices(virCgroupPtr group) -+{ -+ return virCgroupSetValueStr(group, -+ "devices.deny", -+ "a"); -+} -+ -+/** -+ * virCgroupAllowDevice: -+ * -+ * @group: The cgroup to allow a device for -+ * @type: The device type (i.e., 'c' or 'b') -+ * @major: The major number of the device -+ * @minor: The minor number of the device -+ * -+ * Returns: 0 on success -+ */ -+int virCgroupAllowDevice(virCgroupPtr group, -+ char type, -+ int major, -+ int minor) -+{ -+ int rc; -+ char *devstr = NULL; -+ -+ if (asprintf(&devstr, "%c %i:%i rwm", type, major, minor) == -1) { -+ rc = -ENOMEM; -+ goto out; -+ } -+ -+ rc = virCgroupSetValueStr(group, -+ "devices.allow", -+ devstr); -+out: -+ VIR_FREE(devstr); -+ -+ return rc; -+} -Index: libvirt-0.4.6/src/cgroup.h -=================================================================== ---- /dev/null -+++ libvirt-0.4.6/src/cgroup.h -@@ -0,0 +1,43 @@ -+/* -+ * cgroup.h: Interface to tools for managing cgroups -+ * -+ * Copyright IBM Corp. 2008 -+ * -+ * See COPYING.LIB for the License of this software -+ * -+ * Authors: -+ * Dan Smith -+ */ -+ -+#ifndef CGROUP_H -+#define CGROUP_H -+ -+#include -+ -+struct virCgroup; -+typedef struct virCgroup *virCgroupPtr; -+ -+#include "domain_conf.h" -+ -+int virCgroupHaveSupport(void); -+ -+int virCgroupForDomain(virDomainDefPtr def, -+ const char *driverName, -+ virCgroupPtr *group); -+ -+int virCgroupAddTask(virCgroupPtr group, pid_t pid); -+ -+int virCgroupSetMemory(virCgroupPtr group, unsigned long kb); -+ -+int virCgroupDenyAllDevices(virCgroupPtr group); -+ -+int virCgroupAllowDevice(virCgroupPtr group, -+ char type, -+ int major, -+ int minor); -+ -+int virCgroupRemove(virCgroupPtr group); -+ -+void virCgroupFree(virCgroupPtr *group); -+ -+#endif /* CGROUP_H */ diff --git a/cgshares.patch b/cgshares.patch deleted file mode 100644 index 59dd8cc..0000000 --- a/cgshares.patch +++ /dev/null @@ -1,118 +0,0 @@ -Add get/set of cpu.shares to cgroup implementation - -This brings get/set of U64 out of the #if 0, which looks messier than it is. - -diff -r d18631472325 src/cgroup.c ---- a/src/cgroup.c Tue Oct 07 08:19:56 2008 -0700 -+++ b/src/cgroup.c Tue Oct 07 08:20:56 2008 -0700 -@@ -224,26 +224,6 @@ - return rc; - } - --#if 0 --/* This is included for completeness, but not yet used */ -- --static int virCgroupSetValueI64(virCgroupPtr group, -- const char *key, -- int64_t value) --{ -- char *strval = NULL; -- int rc; -- -- if (asprintf(&strval, "%" PRIi64, value) == -1) -- return -ENOMEM; -- -- rc = virCgroupSetValueStr(group, key, strval); -- -- VIR_FREE(strval); -- -- return rc; --} -- - static int virCgroupGetValueStr(virCgroupPtr group, - const char *key, - char **value) -@@ -293,20 +273,21 @@ - return rc; - } - --static int virCgroupGetValueU64(virCgroupPtr group, -+#if 0 -+/* This is included for completeness, but not yet used */ -+ -+static int virCgroupSetValueI64(virCgroupPtr group, - const char *key, -- uint64_t *value) -+ int64_t value) - { - char *strval = NULL; -- int rc = 0; -+ int rc; - -- rc = virCgroupGetValueStr(group, key, &strval); -- if (rc != 0) -- goto out; -+ if (asprintf(&strval, "%" PRIi64, value) == -1) -+ return -ENOMEM; - -- if (sscanf(strval, "%" SCNu64, value) != 1) -- rc = -EINVAL; --out: -+ rc = virCgroupSetValueStr(group, key, strval); -+ - VIR_FREE(strval); - - return rc; -@@ -331,6 +312,25 @@ - return rc; - } - #endif -+ -+static int virCgroupGetValueU64(virCgroupPtr group, -+ const char *key, -+ uint64_t *value) -+{ -+ char *strval = NULL; -+ int rc = 0; -+ -+ rc = virCgroupGetValueStr(group, key, &strval); -+ if (rc != 0) -+ goto out; -+ -+ if (sscanf(strval, "%" SCNu64, value) != 1) -+ rc = -EINVAL; -+out: -+ VIR_FREE(strval); -+ -+ return rc; -+} - - static int _virCgroupInherit(const char *path, - const char *key) -@@ -760,3 +760,13 @@ - - return rc; - } -+ -+int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares) -+{ -+ return virCgroupSetValueU64(group, "cpu.shares", (uint64_t)shares); -+} -+ -+int virCgroupGetCpuShares(virCgroupPtr group, unsigned long *shares) -+{ -+ return virCgroupGetValueU64(group, "cpu.shares", (uint64_t *)shares); -+} -diff -r d18631472325 src/cgroup.h ---- a/src/cgroup.h Tue Oct 07 08:19:56 2008 -0700 -+++ b/src/cgroup.h Tue Oct 07 08:20:56 2008 -0700 -@@ -36,6 +36,9 @@ - int major, - int minor); - -+int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares); -+int virCgroupGetCpuShares(virCgroupPtr group, unsigned long *shares); -+ - int virCgroupRemove(virCgroupPtr group); - - void virCgroupFree(virCgroupPtr *group); diff --git a/clone.patch b/clone.patch index 3256a18..1111855 100644 --- a/clone.patch +++ b/clone.patch @@ -1,6 +1,8 @@ ---- src/lxc_container.c +Index: src/lxc_container.c +=================================================================== +--- src/lxc_container.c.orig +++ src/lxc_container.c -@@ -604,6 +604,9 @@ int lxcContainerStart(virDomainDefPtr de +@@ -603,6 +603,9 @@ int lxcContainerStart(virDomainDefPtr de lxc_child_argv_t args = { def, nveths, veths, control, ttyPath }; /* allocate a stack for the container */ @@ -10,7 +12,7 @@ if (VIR_ALLOC_N(stack, stacksize) < 0) { lxcError(NULL, NULL, VIR_ERR_NO_MEMORY, NULL); return -1; -@@ -615,7 +618,11 @@ int lxcContainerStart(virDomainDefPtr de +@@ -614,7 +617,11 @@ int lxcContainerStart(virDomainDefPtr de if (def->nets != NULL) flags |= CLONE_NEWNET; @@ -22,7 +24,7 @@ VIR_FREE(stack); DEBUG("clone() returned, %d", pid); -@@ -641,18 +648,26 @@ int lxcContainerAvailable(int features) +@@ -640,18 +647,26 @@ int lxcContainerAvailable(int features) char *childStack; char *stack; int childStatus; diff --git a/cve-2008-5086.patch b/cve-2008-5086.patch index 9cb7255..76db122 100644 --- a/cve-2008-5086.patch +++ b/cve-2008-5086.patch @@ -1,11 +1,13 @@ -Index: libvirt-0.4.6/src/libvirt.c -=================================================================== ---- libvirt-0.4.6.orig/src/libvirt.c -+++ libvirt-0.4.6/src/libvirt.c -@@ -2342,6 +2342,16 @@ virDomainMigrate (virDomainPtr domain, - return NULL; - } - +diff --git a/src/libvirt.c b/src/libvirt.c +--- a/src/libvirt.c ++++ b/src/libvirt.c +@@ -2296,6 +2296,16 @@ virDomainMigrate (virDomainPtr domain, + conn = domain->conn; /* Source connection. */ + if (!VIR_IS_CONNECT (dconn)) { + virLibConnError (conn, VIR_ERR_INVALID_CONN, __FUNCTION__); ++ return NULL; ++ } ++ + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + return NULL; @@ -13,13 +15,10 @@ Index: libvirt-0.4.6/src/libvirt.c + if (dconn->flags & VIR_CONNECT_RO) { + /* NB, delibrately report error against source object, not dest here */ + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); -+ return NULL; -+ } -+ - /* Check that migration is supported by both drivers. */ - if (!VIR_DRV_SUPPORTS_FEATURE (conn->driver, conn, - VIR_DRV_FEATURE_MIGRATION_V1) || -@@ -2419,6 +2429,11 @@ __virDomainMigratePrepare (virConnectPtr + return NULL; + } + +@@ -2426,6 +2436,11 @@ virDomainMigratePrepare (virConnectPtr d return -1; } @@ -31,7 +30,7 @@ Index: libvirt-0.4.6/src/libvirt.c if (dconn->driver->domainMigratePrepare) return dconn->driver->domainMigratePrepare (dconn, cookie, cookielen, uri_in, uri_out, -@@ -2449,6 +2464,11 @@ __virDomainMigratePerform (virDomainPtr +@@ -2457,6 +2472,11 @@ virDomainMigratePerform (virDomainPtr do } conn = domain->conn; @@ -43,7 +42,31 @@ Index: libvirt-0.4.6/src/libvirt.c if (conn->driver->domainMigratePerform) return conn->driver->domainMigratePerform (domain, cookie, cookielen, uri, -@@ -2476,6 +2496,11 @@ __virDomainMigrateFinish (virConnectPtr +@@ -2482,6 +2502,11 @@ virDomainMigrateFinish (virConnectPtr dc + + if (!VIR_IS_CONNECT (dconn)) { + virLibConnError (NULL, VIR_ERR_INVALID_CONN, __FUNCTION__); ++ return NULL; ++ } ++ ++ if (dconn->flags & VIR_CONNECT_RO) { ++ virLibConnError(dconn, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + return NULL; + } + +@@ -2517,6 +2542,11 @@ virDomainMigratePrepare2 (virConnectPtr + return -1; + } + ++ if (dconn->flags & VIR_CONNECT_RO) { ++ virLibConnError(dconn, VIR_ERR_OPERATION_DENIED, __FUNCTION__); ++ return -1; ++ } ++ + if (dconn->driver->domainMigratePrepare2) + return dconn->driver->domainMigratePrepare2 (dconn, cookie, cookielen, + uri_in, uri_out, +@@ -2547,6 +2577,11 @@ virDomainMigrateFinish2 (virConnectPtr d return NULL; } @@ -52,10 +75,10 @@ Index: libvirt-0.4.6/src/libvirt.c + return NULL; + } + - if (dconn->driver->domainMigrateFinish) - return dconn->driver->domainMigrateFinish (dconn, dname, - cookie, cookielen, -@@ -2833,6 +2858,11 @@ virDomainBlockPeek (virDomainPtr dom, + if (dconn->driver->domainMigrateFinish2) + return dconn->driver->domainMigrateFinish2 (dconn, dname, + cookie, cookielen, +@@ -2905,6 +2940,11 @@ virDomainBlockPeek (virDomainPtr dom, } conn = dom->conn; @@ -67,7 +90,7 @@ Index: libvirt-0.4.6/src/libvirt.c if (!path) { virLibDomainError (dom, VIR_ERR_INVALID_ARG, _("path is NULL")); -@@ -2908,6 +2938,11 @@ virDomainMemoryPeek (virDomainPtr dom, +@@ -2980,6 +3020,11 @@ virDomainMemoryPeek (virDomainPtr dom, } conn = dom->conn; @@ -79,19 +102,19 @@ Index: libvirt-0.4.6/src/libvirt.c /* Flags must be VIR_MEMORY_VIRTUAL at the moment. * * Note on access to physical memory: A VIR_MEMORY_PHYSICAL flag is -@@ -3175,6 +3210,11 @@ virDomainSetAutostart(virDomainPtr domai +@@ -3246,6 +3291,11 @@ virDomainSetAutostart(virDomainPtr domai + } conn = domain->conn; - ++ + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + return (-1); + } -+ + if (conn->driver->domainSetAutostart) return conn->driver->domainSetAutostart (domain, autostart); - -@@ -4125,6 +4165,11 @@ virNetworkSetAutostart(virNetworkPtr net +@@ -4197,6 +4247,11 @@ virNetworkSetAutostart(virNetworkPtr net return (-1); } @@ -103,7 +126,7 @@ Index: libvirt-0.4.6/src/libvirt.c conn = network->conn; if (conn->networkDriver && conn->networkDriver->networkSetAutostart) -@@ -4323,6 +4368,11 @@ virConnectFindStoragePoolSources(virConn +@@ -4395,6 +4450,11 @@ virConnectFindStoragePoolSources(virConn return NULL; } @@ -115,7 +138,7 @@ Index: libvirt-0.4.6/src/libvirt.c if (conn->storageDriver && conn->storageDriver->findPoolSources) return conn->storageDriver->findPoolSources(conn, type, srcSpec, flags); -@@ -4996,6 +5046,11 @@ virStoragePoolSetAutostart(virStoragePoo +@@ -5068,6 +5128,11 @@ virStoragePoolSetAutostart(virStoragePoo return (-1); } diff --git a/detach-disk.patch b/detach-disk.patch index f2383c5..caf1da5 100644 --- a/detach-disk.patch +++ b/detach-disk.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.6/src/xend_internal.c +Index: libvirt-0.5.1/src/xend_internal.c =================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -5615,11 +5615,16 @@ virDomainXMLDevID(virDomainPtr domain, +--- libvirt-0.5.1.orig/src/xend_internal.c ++++ libvirt-0.5.1/src/xend_internal.c +@@ -5465,11 +5465,16 @@ virDomainXMLDevID(virDomainPtr domain, char *xref; if (dev->type == VIR_DOMAIN_DEVICE_DISK) { @@ -21,11 +21,11 @@ Index: libvirt-0.4.6/src/xend_internal.c if (xref == NULL) return -1; -Index: libvirt-0.4.6/src/xs_internal.c +Index: libvirt-0.5.1/src/xs_internal.c =================================================================== ---- libvirt-0.4.6.orig/src/xs_internal.c -+++ libvirt-0.4.6/src/xs_internal.c -@@ -868,7 +868,8 @@ xenStoreDomainGetNetworkID(virConnectPtr +--- libvirt-0.5.1.orig/src/xs_internal.c ++++ libvirt-0.5.1/src/xs_internal.c +@@ -917,7 +917,8 @@ xenStoreDomainGetNetworkID(virConnectPtr * freed by the caller. */ char * @@ -35,7 +35,7 @@ Index: libvirt-0.4.6/src/xs_internal.c char dir[80], path[128], **list = NULL, *val = NULL; unsigned int devlen, len, i, num; char *ret = NULL; -@@ -886,7 +887,7 @@ xenStoreDomainGetDiskID(virConnectPtr co +@@ -935,7 +936,7 @@ xenStoreDomainGetDiskID(virConnectPtr co if (devlen <= 0) return (NULL); @@ -44,11 +44,11 @@ Index: libvirt-0.4.6/src/xs_internal.c list = xs_directory(priv->xshandle, 0, dir, &num); if (list != NULL) { for (i = 0; i < num; i++) { -Index: libvirt-0.4.6/src/xs_internal.h +Index: libvirt-0.5.1/src/xs_internal.h =================================================================== ---- libvirt-0.4.6.orig/src/xs_internal.h -+++ libvirt-0.4.6/src/xs_internal.h -@@ -49,7 +49,8 @@ char * xenStoreDomainGetNetworkID(virCo +--- libvirt-0.5.1.orig/src/xs_internal.h ++++ libvirt-0.5.1/src/xs_internal.h +@@ -48,7 +48,8 @@ char * xenStoreDomainGetNetworkID(virCo const char *mac); char * xenStoreDomainGetDiskID(virConnectPtr conn, int id, @@ -57,4 +57,4 @@ Index: libvirt-0.4.6/src/xs_internal.h + const char *class); char * xenStoreDomainGetName(virConnectPtr conn, int id); - + int xenStoreDomainGetUUID(virConnectPtr conn, diff --git a/fs-storage-driver.patch b/fs-storage-driver.patch index 9e6fef6..9d25782 100644 --- a/fs-storage-driver.patch +++ b/fs-storage-driver.patch @@ -1,19 +1,17 @@ -Index: libvirt-0.4.5/src/storage_backend_fs.c +Index: libvirt-0.5.1/src/storage_backend_fs.c =================================================================== ---- libvirt-0.4.5.orig/src/storage_backend_fs.c -+++ libvirt-0.4.5/src/storage_backend_fs.c -@@ -583,7 +583,9 @@ virStorageBackendFileSystemIsMounted(vir +--- libvirt-0.5.1.orig/src/storage_backend_fs.c ++++ libvirt-0.5.1/src/storage_backend_fs.c +@@ -381,6 +381,8 @@ virStorageBackendFileSystemIsMounted(vir virStoragePoolObjPtr pool) { FILE *mtab; struct mntent *ent; -- + char *mpoint; + size_t len; -+ + if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) { virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("cannot read %s: %s"), -@@ -591,14 +593,27 @@ virStorageBackendFileSystemIsMounted(vir +@@ -389,14 +391,26 @@ virStorageBackendFileSystemIsMounted(vir return -1; } @@ -22,11 +20,10 @@ Index: libvirt-0.4.5/src/storage_backend_fs.c + "%s", strerror(errno)); + return -1; + } -+ ++ + len = strlen(mpoint); + if (mpoint[len-1] == '/') + mpoint[len-1] = NULL; -+ + while ((ent = getmntent(mtab)) != NULL) { - if (STREQ(ent->mnt_dir, pool->def->target.path)) { @@ -42,7 +39,7 @@ Index: libvirt-0.4.5/src/storage_backend_fs.c return 0; } -@@ -951,12 +966,16 @@ virStorageBackendFileSystemDelete(virCon +@@ -735,12 +749,16 @@ virStorageBackendFileSystemDelete(virCon { /* XXX delete all vols first ? */ diff --git a/libvirt-0.4.6.tar.bz2 b/libvirt-0.4.6.tar.bz2 deleted file mode 100644 index c42f407..0000000 --- a/libvirt-0.4.6.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:135ab72ebfba0359972e0fa0b4e643c4b744a0ebc9d60b3fb5e5518b5e575355 -size 3136828 diff --git a/libvirt-0.5.1.tar.bz2 b/libvirt-0.5.1.tar.bz2 new file mode 100644 index 0000000..41e0a2a --- /dev/null +++ b/libvirt-0.5.1.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc6fc1909f40667bd32574a11f4052160ed94620b79f3d5db5541f25a12429ee +size 3778088 diff --git a/libvirt.changes b/libvirt.changes index efbeb8b..324ea54 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Wed Jan 28 15:45:25 MST 2009 - jfehlig@novell.com + +- Updated to version 0.5.1 + - CPU and scheduler support for LXC + - SDL display configuration + - domain lifecycle event support for QEmu and Xen with python + bindings + - KVM/QEmu migration support + - User Mode Linux driver + - API for node device enumeration using HAL and DeviceKit with + python bindings + - Many bug fixes and improvements + ------------------------------------------------------------------- Fri Jan 9 09:41:49 MST 2009 - jfehlig@novell.com diff --git a/libvirt.spec b/libvirt.spec index c33ab7b..df13fe2 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -1,5 +1,5 @@ # -# spec file for package libvirt (Version 0.4.6) +# spec file for package libvirt (Version 0.5.1) # # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -30,7 +30,7 @@ %endif Name: libvirt -BuildRequires: PolicyKit-devel bridge-utils cyrus-sasl-devel fdupes gettext gnutls-devel iptables-devel libxml2-devel lvm2 ncurses-devel parted-devel pkg-config python-devel readline-devel util-linux xhtml-dtd +BuildRequires: PolicyKit-devel bridge-utils cyrus-sasl-devel fdupes gettext gnutls-devel hal-devel iptables-devel libnuma-devel libxml2-devel lvm2 ncurses-devel parted-devel pkg-config python-devel readline-devel util-linux xhtml-dtd %if %{with_xen} BuildRequires: xen-devel %endif @@ -48,8 +48,8 @@ Url: http://libvirt.org/ License: LGPL v2.1 or later Group: Development/Libraries/C and C++ AutoReqProv: yes -Version: 0.4.6 -Release: 14 +Version: 0.5.1 +Release: 1 Summary: A C toolkit to interract with the virtualization capabilities of Linux Requires: readline Requires: ncurses @@ -64,29 +64,20 @@ Requires: dnsmasq Requires: PolicyKit >= 0.6 Requires: socat Requires: open-iscsi +Requires: nfs-client +Requires: hal Source0: %{name}-%{version}.tar.bz2 Source1: libvirtd.init Patch0: socat.patch Patch1: libvirtd-defaults.patch Patch2: fs-storage-driver.patch -Patch3: snapshots.patch -Patch4: vif-parsing.patch -Patch5: xen-maxmem.patch -Patch6: cgroup.patch -Patch7: lxc_res_mem.patch -Patch8: cgshares.patch -Patch9: lxcsched.patch -Patch10: lxcvirsh.patch -Patch11: cgmajor.patch -Patch12: lxcpty.patch -Patch13: clone.patch -Patch14: vnc-port.patch -Patch15: suse-network.patch -Patch16: xen-pv-cdrom.patch -Patch17: detach-disk.patch -Patch18: migrate-params.patch -Patch19: cve-2008-5086.patch -Patch20: devhelp.patch +Patch3: clone.patch +Patch4: vnc-port.patch +Patch5: xen-pv-cdrom.patch +Patch6: detach-disk.patch +Patch7: migrate-params.patch +Patch8: cve-2008-5086.patch +Patch9: devhelp.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -112,6 +103,7 @@ Group: Development/Libraries/C and C++ Requires: %{name} = %{version} libxml2-devel %if %{with_xen} Requires: xen-devel +Requires: pkg-config %endif %description devel @@ -180,25 +172,13 @@ Authors: %patch0 -p1 %patch1 -p1 %patch2 -p1 -%patch3 -p1 +%patch3 %patch4 -p1 %patch5 -p1 %patch6 -p1 %patch7 -p1 %patch8 -p1 %patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -%patch14 -p1 -%patch15 -p1 -%patch16 -p1 -%patch17 -p1 -%patch18 -p1 -%patch19 -p1 -%patch20 -p1 -rm po/no.* %build %if ! %{with_xen} @@ -221,7 +201,8 @@ export CFLAGS="$RPM_OPT_FLAGS" --with-xen-proxy=no \ ac_cv_path_DNSMASQ=/usr/sbin/dnsmasq \ ac_cv_path_QEMU_IMG=/usr/bin/qemu-img-xen \ - ac_cv_path_ISCSIADM=/sbin/iscsiadm + ac_cv_path_ISCSIADM=/sbin/iscsiadm \ + ac_cv_path_SHOWMOUNT=/usr/sbin/showmount make DOCS_DIR=%{_docdir}/%{name}-python EXAMPLE_DIR=%{_docdir}/%{name}-python/examples HTML_DIR=%{_docdir}/%{name} %install @@ -331,6 +312,17 @@ rm -rf $RPM_BUILD_ROOT %{py_sitedir}/libvirtmod* %changelog +* Wed Jan 28 2009 jfehlig@novell.com +- Updated to version 0.5.1 + - CPU and scheduler support for LXC + - SDL display configuration + - domain lifecycle event support for QEmu and Xen with python + bindings + - KVM/QEmu migration support + - User Mode Linux driver + - API for node device enumeration using HAL and DeviceKit with + python bindings + - Many bug fixes and improvements * Fri Jan 09 2009 jfehlig@novell.com - Added missing html and png files to libvirt-doc package devhelp.patch diff --git a/libvirtd-defaults.patch b/libvirtd-defaults.patch index b2a6e67..4c3d5bd 100644 --- a/libvirtd-defaults.patch +++ b/libvirtd-defaults.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.4/qemud/libvirtd.conf +Index: libvirt-0.5.1/qemud/libvirtd.conf =================================================================== ---- libvirt-0.4.4.orig/qemud/libvirtd.conf -+++ libvirt-0.4.4/qemud/libvirtd.conf -@@ -15,8 +15,8 @@ +--- libvirt-0.5.1.orig/qemud/libvirtd.conf ++++ libvirt-0.5.1/qemud/libvirtd.conf +@@ -18,8 +18,8 @@ # It is necessary to setup a CA and issue server certificates before # using this capability. # @@ -13,7 +13,7 @@ Index: libvirt-0.4.4/qemud/libvirtd.conf # Listen for unencrypted TCP connections on the public TCP/IP port. # NB, must pass the --listen flag to the libvirtd process for this to -@@ -50,11 +50,9 @@ +@@ -53,11 +53,9 @@ # Flag toggling mDNS advertizement of the libvirt service. # @@ -28,11 +28,11 @@ Index: libvirt-0.4.4/qemud/libvirtd.conf # Override the default mDNS advertizement name. This must be # unique on the immediate broadcast network. -Index: libvirt-0.4.4/qemud/qemud.c +Index: libvirt-0.5.1/qemud/qemud.c =================================================================== ---- libvirt-0.4.4.orig/qemud/qemud.c -+++ libvirt-0.4.4/qemud/qemud.c -@@ -68,7 +68,7 @@ static int sigwrite = -1; /* Signa +--- libvirt-0.5.1.orig/qemud/qemud.c ++++ libvirt-0.5.1/qemud/qemud.c +@@ -92,7 +92,7 @@ static int sigwrite = -1; /* Signa static int ipsock = 0; /* -l Listen for TCP/IP */ /* Defaults for configuration file elements */ @@ -41,7 +41,7 @@ Index: libvirt-0.4.4/qemud/qemud.c static int listen_tcp = 0; static char *listen_addr = (char *) LIBVIRTD_LISTEN_ADDR; static char *tls_port = (char *) LIBVIRTD_TLS_PORT; -@@ -92,7 +92,7 @@ static int auth_tcp = REMOTE_AUTH_NONE; +@@ -116,7 +116,7 @@ static int auth_tcp = REMOTE_AUTH_NONE; #endif static int auth_tls = REMOTE_AUTH_NONE; diff --git a/lxc_res_mem.patch b/lxc_res_mem.patch deleted file mode 100644 index 1bd457c..0000000 --- a/lxc_res_mem.patch +++ /dev/null @@ -1,198 +0,0 @@ -# HG changeset patch -# User danms -# Date 1223052361 0 -# Node ID a28490b116b0430aa0d4f579bba57d52793312ed -# Parent 47378698026980b5734c81f9480b50c783dde68a -[r2008-10-03 16:46:01 by danms] Add cgroup manipulation and LXC driver - -diff -r 473786980269 -r a28490b116b0 src/Makefile.am ---- a/src/Makefile.am Thu Oct 02 15:04:11 2008 +0000 -+++ b/src/Makefile.am Fri Oct 03 16:46:01 2008 +0000 -@@ -90,13 +90,15 @@ - lxc_conf.c lxc_conf.h \ - lxc_container.c lxc_container.h \ - lxc_driver.c lxc_driver.h \ -- veth.c veth.h -+ veth.c veth.h \ -+ cgroup.c cgroup.h - - LXC_CONTROLLER_SOURCES = \ - lxc_conf.c lxc_conf.h \ - lxc_container.c lxc_container.h \ - lxc_controller.c \ -- veth.c veth.h -+ veth.c veth.h \ -+ cgroup.c cgroup.h - - OPENVZ_DRIVER_SOURCES = \ - openvz_conf.c openvz_conf.h \ -diff -r 473786980269 -r a28490b116b0 src/lxc_container.c ---- a/src/lxc_container.c Thu Oct 02 15:04:11 2008 +0000 -+++ b/src/lxc_container.c Fri Oct 03 16:46:01 2008 +0000 -@@ -320,12 +320,12 @@ - mode_t mode; - const char *path; - } devs[] = { -- { 1, 3, 0666, "/dev/null" }, -- { 1, 5, 0666, "/dev/zero" }, -- { 1, 7, 0666, "/dev/full" }, -- { 5, 1, 0600, "/dev/console" }, -- { 1, 8, 0666, "/dev/random" }, -- { 1, 9, 0666, "/dev/urandom" }, -+ { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL, 0666, "/dev/null" }, -+ { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO, 0666, "/dev/zero" }, -+ { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL, 0666, "/dev/full" }, -+ { LXC_DEV_MAJ_TTY, LXC_DEV_MIN_CONSOLE, 0600, "/dev/console" }, -+ { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" }, -+ { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" }, - }; - - if (virFileMakePath("/dev") < 0 || -diff -r 473786980269 -r a28490b116b0 src/lxc_container.h ---- a/src/lxc_container.h Thu Oct 02 15:04:11 2008 +0000 -+++ b/src/lxc_container.h Fri Oct 03 16:46:01 2008 +0000 -@@ -30,6 +30,16 @@ - LXC_CONTAINER_FEATURE_NET = (1 << 0), - }; - -+#define LXC_DEV_MAJ_MEMORY 1 -+#define LXC_DEV_MIN_NULL 3 -+#define LXC_DEV_MIN_ZERO 5 -+#define LXC_DEV_MIN_FULL 7 -+#define LXC_DEV_MIN_RANDOM 8 -+#define LXC_DEV_MIN_URANDOM 9 -+ -+#define LXC_DEV_MAJ_TTY 5 -+#define LXC_DEV_MIN_CONSOLE 1 -+ - int lxcContainerSendContinue(int control); - - int lxcContainerStart(virDomainDefPtr def, -diff -r 473786980269 -r a28490b116b0 src/lxc_controller.c ---- a/src/lxc_controller.c Thu Oct 02 15:04:11 2008 +0000 -+++ b/src/lxc_controller.c Fri Oct 03 16:46:01 2008 +0000 -@@ -42,12 +42,82 @@ - #include "veth.h" - #include "memory.h" - #include "util.h" -- -+#include "cgroup.h" - - #define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__) - #define DEBUG0(msg) VIR_DEBUG(__FILE__, "%s", msg) - - int debugFlag = 0; -+ -+struct cgroup_device_policy { -+ char type; -+ int major; -+ int minor; -+}; -+ -+/** -+ * lxcSetContainerResources -+ * @def: pointer to virtual machine structure -+ * -+ * Creates a cgroup for the container, moves the task inside, -+ * and sets resource limits -+ * -+ * Returns 0 on success or -1 in case of error -+ */ -+static int lxcSetContainerResources(virDomainDefPtr def) -+{ -+ virCgroupPtr cgroup; -+ int rc = -1; -+ int i; -+ struct cgroup_device_policy devices[] = { -+ {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, -+ {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, -+ {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL}, -+ {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, -+ {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, -+ {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_CONSOLE}, -+ {0, 0, 0}}; -+ -+ if (virCgroupHaveSupport() != 0) -+ return 0; /* Not supported, so claim success */ -+ -+ rc = virCgroupForDomain(def, "lxc", &cgroup); -+ if (rc != 0) { -+ lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, -+ _("Unable to create cgroup for %s\n"), def->name); -+ return rc; -+ } -+ -+ rc = virCgroupSetMemory(cgroup, def->maxmem); -+ if (rc != 0) -+ goto out; -+ -+ rc = virCgroupDenyAllDevices(cgroup); -+ if (rc != 0) -+ goto out; -+ -+ for (i = 0; devices[i].type != 0; i++) { -+ struct cgroup_device_policy *dev = &devices[i]; -+ rc = virCgroupAllowDevice(cgroup, -+ dev->type, -+ dev->major, -+ dev->minor); -+ if (rc != 0) -+ goto out; -+ } -+ -+ rc = virCgroupAddTask(cgroup, getpid()); -+out: -+ if (rc != 0) { -+ lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, -+ _("Failed to set lxc resources: %s\n"), strerror(-rc)); -+ virCgroupRemove(cgroup); -+ } -+ -+ virCgroupFree(&cgroup); -+ -+ return rc; -+} - - static char*lxcMonitorPath(virDomainDefPtr def) - { -@@ -394,6 +464,9 @@ - if (lxcControllerMoveInterfaces(nveths, veths, container) < 0) - goto cleanup; - -+ if (lxcSetContainerResources(def) < 0) -+ goto cleanup; -+ - if (lxcContainerSendContinue(control[0]) < 0) - goto cleanup; - -diff -r 473786980269 -r a28490b116b0 src/lxc_driver.c ---- a/src/lxc_driver.c Thu Oct 02 15:04:11 2008 +0000 -+++ b/src/lxc_driver.c Fri Oct 03 16:46:01 2008 +0000 -@@ -43,6 +43,7 @@ - #include "bridge.h" - #include "veth.h" - #include "event.h" -+#include "cgroup.h" - - - /* debug macros */ -@@ -376,6 +377,7 @@ - int waitRc; - int childStatus = -1; - virDomainNetDefPtr net; -+ virCgroupPtr cgroup; - - while (((waitRc = waitpid(vm->pid, &childStatus, 0)) == -1) && - errno == EINTR) -@@ -408,6 +410,11 @@ - for (net = vm->def->nets; net; net = net->next) { - vethInterfaceUpOrDown(net->ifname, 0); - vethDelete(net->ifname); -+ } -+ -+ if (virCgroupForDomain(vm->def, "lxc", &cgroup) == 0) { -+ virCgroupRemove(cgroup); -+ virCgroupFree(&cgroup); - } - - return rc; diff --git a/lxcpty.patch b/lxcpty.patch deleted file mode 100644 index 1147ffc..0000000 --- a/lxcpty.patch +++ /dev/null @@ -1,48 +0,0 @@ -Index: libvirt-0.4.6/src/lxc_container.h -=================================================================== ---- libvirt-0.4.6.orig/src/lxc_container.h -+++ libvirt-0.4.6/src/lxc_container.h -@@ -40,6 +40,8 @@ enum { - #define LXC_DEV_MAJ_TTY 5 - #define LXC_DEV_MIN_CONSOLE 1 - -+#define LXC_DEV_MAJ_PTY 136 -+ - int lxcContainerSendContinue(int control); - - int lxcContainerStart(virDomainDefPtr def, -Index: libvirt-0.4.6/src/lxc_controller.c -=================================================================== ---- libvirt-0.4.6.orig/src/lxc_controller.c -+++ libvirt-0.4.6/src/lxc_controller.c -@@ -106,6 +106,10 @@ static int lxcSetContainerResources(virD - goto out; - } - -+ rc = virCgroupAllowDeviceMajor(cgroup, 'c', LXC_DEV_MAJ_PTY); -+ if (rc != 0) -+ goto out; -+ - rc = virCgroupAddTask(cgroup, getpid()); - out: - if (rc != 0) { -@@ -452,6 +456,9 @@ lxcControllerRun(virDomainDefPtr def, - goto cleanup; - } - -+ if (lxcSetContainerResources(def) < 0) -+ goto cleanup; -+ - if ((container = lxcContainerStart(def, - nveths, - veths, -@@ -464,9 +471,6 @@ lxcControllerRun(virDomainDefPtr def, - if (lxcControllerMoveInterfaces(nveths, veths, container) < 0) - goto cleanup; - -- if (lxcSetContainerResources(def) < 0) -- goto cleanup; -- - if (lxcContainerSendContinue(control[0]) < 0) - goto cleanup; - diff --git a/lxcsched.patch b/lxcsched.patch deleted file mode 100644 index 150428b..0000000 --- a/lxcsched.patch +++ /dev/null @@ -1,130 +0,0 @@ -Add scheduling parameter support for LXC domains - -Index: libvirt-0.4.6/src/lxc_driver.c -=================================================================== ---- libvirt-0.4.6.orig/src/lxc_driver.c -+++ libvirt-0.4.6/src/lxc_driver.c -@@ -35,6 +35,7 @@ - #include - #include - -+#include "internal.h" - #include "lxc_conf.h" - #include "lxc_container.h" - #include "lxc_driver.h" -@@ -1149,6 +1150,94 @@ static int lxcVersion(virConnectPtr conn - return 0; - } - -+static char *lxcGetSchedulerType(virDomainPtr domain, int *nparams) -+{ -+ if (nparams) -+ *nparams = 1; -+ -+ return strdup("posix"); -+} -+ -+static int lxcSetSchedulerParameters(virDomainPtr _domain, -+ virSchedParameterPtr params, -+ int nparams) -+{ -+ int i; -+ int rc; -+ virCgroupPtr group; -+ virDomainObjPtr domain; -+ -+ if (virCgroupHaveSupport() != 0) -+ return 0; -+ -+ domain = virDomainFindByUUID(lxc_driver->domains, _domain->uuid); -+ if (domain == NULL) { -+ lxcError(NULL, _domain, VIR_ERR_INTERNAL_ERROR, -+ _("No such domain %s"), _domain->uuid); -+ return -EINVAL; -+ } -+ -+ rc = virCgroupForDomain(domain->def, "lxc", &group); -+ if (rc != 0) -+ return rc; -+ -+ for (i = 0; i < nparams; i++) { -+ virSchedParameterPtr param = ¶ms[i]; -+ -+ if (STREQ(param->field, "cpu_shares")) { -+ rc = virCgroupSetCpuShares(group, params[i].value.ui); -+ } else { -+ lxcError(NULL, _domain, VIR_ERR_INVALID_ARG, -+ _("Invalid parameter `%s'"), param->field); -+ rc = -ENOENT; -+ goto out; -+ } -+ } -+ -+ rc = 0; -+out: -+ virCgroupFree(&group); -+ -+ return rc; -+} -+ -+static int lxcGetSchedulerParameters(virDomainPtr _domain, -+ virSchedParameterPtr params, -+ int *nparams) -+{ -+ int rc = 0; -+ virCgroupPtr group; -+ virDomainObjPtr domain; -+ -+ if (virCgroupHaveSupport() != 0) -+ return 0; -+ -+ if ((*nparams) != 1) { -+ lxcError(NULL, _domain, VIR_ERR_INVALID_ARG, -+ _("Invalid parameter count")); -+ return -1; -+ } -+ -+ domain = virDomainFindByUUID(lxc_driver->domains, _domain->uuid); -+ if (domain == NULL) { -+ lxcError(NULL, _domain, VIR_ERR_INTERNAL_ERROR, -+ _("No such domain %s"), _domain->uuid); -+ return -ENOENT; -+ } -+ -+ rc = virCgroupForDomain(domain->def, "lxc", &group); -+ if (rc != 0) -+ return rc; -+ -+ rc = virCgroupGetCpuShares(group, (unsigned long *)¶ms[0].value.ul); -+ strncpy(params[0].field, "cpu_shares", sizeof(params[0].field)); -+ params[0].type = VIR_DOMAIN_SCHED_FIELD_ULLONG; -+ -+ virCgroupFree(&group); -+ -+ return rc; -+} -+ - /* Function Tables */ - static virDriver lxcDriver = { - VIR_DRV_LXC, /* the number virDrvNo */ -@@ -1198,9 +1287,9 @@ static virDriver lxcDriver = { - NULL, /* domainDetachDevice */ - NULL, /* domainGetAutostart */ - NULL, /* domainSetAutostart */ -- NULL, /* domainGetSchedulerType */ -- NULL, /* domainGetSchedulerParameters */ -- NULL, /* domainSetSchedulerParameters */ -+ lxcGetSchedulerType, /* domainGetSchedulerType */ -+ lxcGetSchedulerParameters, /* domainGetSchedulerParameters */ -+ lxcSetSchedulerParameters, /* domainSetSchedulerParameters */ - NULL, /* domainMigratePrepare */ - NULL, /* domainMigratePerform */ - NULL, /* domainMigrateFinish */ -@@ -1217,7 +1306,6 @@ static virDriver lxcDriver = { - NULL, /* domainListSnapshots */ - }; - -- - static virStateDriver lxcStateDriver = { - lxcStartup, - lxcShutdown, diff --git a/lxcvirsh.patch b/lxcvirsh.patch deleted file mode 100644 index df0ceb2..0000000 --- a/lxcvirsh.patch +++ /dev/null @@ -1,123 +0,0 @@ -Add generic parameter=value support for virsh's schedinfo command - -This patch maintains the two Xen-specific --weight and --cap options, -but adds support for setting arbitrary parameters by specifying them in -param=value syntax. - -Changes to the virsh manual are included. - -Changes: - - Replace use of 'a' conversion modifier with pre-alloc - -Index: libvirt-0.4.6/docs/virsh.pod -=================================================================== ---- libvirt-0.4.6.orig/docs/virsh.pod -+++ libvirt-0.4.6/docs/virsh.pod -@@ -322,12 +322,14 @@ This is roughly equivalent to doing a hi - with all the same limitations. Open network connections may be - severed upon restore, as TCP timeouts may have expired. - -+=item B optional I<--set> B I -+ - =item B optional I<--weight> B optional I<--cap> B I - --Allows to show (and set) the domain scheduler parameters. This is currently --only defined for XEN_CREDIT scheduler, and the optional weight and cap --arguments allows to set the associated parameters in that scheduler if --provided. -+Allows to show (and set) the domain scheduler parameters. -+ -+B: The weight and cap parameters are defined only for the -+XEN_CREDIT scheduler and are now I. - - =item B I B - -Index: libvirt-0.4.6/src/virsh.c -=================================================================== ---- libvirt-0.4.6.orig/src/virsh.c -+++ libvirt-0.4.6/src/virsh.c -@@ -1295,6 +1295,7 @@ static const vshCmdInfo info_schedinfo[] - - static const vshCmdOptDef opts_schedinfo[] = { - {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")}, -+ {"set", VSH_OT_STRING, VSH_OFLAG_NONE, gettext_noop("parameter=value")}, - {"weight", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("weight for XEN_CREDIT")}, - {"cap", VSH_OT_INT, VSH_OFLAG_NONE, gettext_noop("cap for XEN_CREDIT")}, - {NULL, 0, 0, NULL} -@@ -1304,6 +1305,9 @@ static int - cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) - { - char *schedulertype; -+ char *set; -+ char *param_name = NULL; -+ long long int param_value = 0; - virDomainPtr dom; - virSchedParameterPtr params = NULL; - int i, ret; -@@ -1311,6 +1315,7 @@ cmdSchedinfo(vshControl *ctl, const vshC - int nr_inputparams = 0; - int inputparams = 0; - int weightfound = 0; -+ int setfound = 0; - int weight = 0; - int capfound = 0; - int cap = 0; -@@ -1324,7 +1329,7 @@ cmdSchedinfo(vshControl *ctl, const vshC - if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", NULL))) - return FALSE; - -- /* Currently supports Xen Credit only */ -+ /* Deprecated Xen-only options */ - if(vshCommandOptBool(cmd, "weight")) { - weight = vshCommandOptInt(cmd, "weight", &weightfound); - if (!weightfound) { -@@ -1345,6 +1350,25 @@ cmdSchedinfo(vshControl *ctl, const vshC - } - } - -+ if(vshCommandOptBool(cmd, "set")) { -+ set = vshCommandOptString(cmd, "set", &setfound); -+ if (!setfound) { -+ vshError(ctl, FALSE, "%s", _("Error getting param")); -+ goto cleanup; -+ } -+ -+ param_name = vshMalloc(ctl, strlen(set) + 1); -+ if (param_name == NULL) -+ goto cleanup; -+ -+ if (sscanf(set, "%[^=]=%i", param_name, ¶m_value) != 2) { -+ vshError(ctl, FALSE, "%s", _("Invalid value of param")); -+ goto cleanup; -+ } -+ -+ nr_inputparams++; -+ } -+ - params = vshMalloc(ctl, sizeof (virSchedParameter) * nr_inputparams); - if (params == NULL) { - goto cleanup; -@@ -1363,7 +1387,14 @@ cmdSchedinfo(vshControl *ctl, const vshC - params[inputparams].value.ui = cap; - inputparams++; - } -- /* End Currently supports Xen Credit only */ -+ /* End Deprecated Xen-only options */ -+ -+ if (setfound) { -+ strncpy(params[inputparams].field,param_name,sizeof(params[0].field)); -+ params[inputparams].type = VIR_DOMAIN_SCHED_FIELD_LLONG; -+ params[inputparams].value.l = param_value; -+ inputparams++; -+ } - - assert (inputparams == nr_inputparams); - -@@ -1430,6 +1461,7 @@ cmdSchedinfo(vshControl *ctl, const vshC - } - cleanup: - free(params); -+ free(param_name); - virDomainFree(dom); - return ret_val; - } diff --git a/migrate-params.patch b/migrate-params.patch index 5aa76d9..cc6ce7d 100644 --- a/migrate-params.patch +++ b/migrate-params.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.6/src/xend_internal.c +Index: libvirt-0.5.1/src/xend_internal.c =================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -4355,6 +4355,8 @@ xenDaemonDomainMigratePerform (virDomain +--- libvirt-0.5.1.orig/src/xend_internal.c ++++ libvirt-0.5.1/src/xend_internal.c +@@ -4226,6 +4226,8 @@ xenDaemonDomainMigratePerform (virDomain "live", live, "port", port, "resource", "0", /* required, xend ignores it */ diff --git a/snapshots.patch b/snapshots.patch deleted file mode 100644 index 291e80e..0000000 --- a/snapshots.patch +++ /dev/null @@ -1,1215 +0,0 @@ -Index: libvirt-0.4.6/include/libvirt/libvirt.h.in -=================================================================== ---- libvirt-0.4.6.orig/include/libvirt/libvirt.h.in -+++ libvirt-0.4.6/include/libvirt/libvirt.h.in -@@ -470,6 +470,21 @@ int virDomainRestore - const char *from); - - /* -+ * Snapshots -+ */ -+int virDomainSnapshotCreate (virDomainPtr domain, -+ const char* name); -+int virDomainSnapshotApply (virDomainPtr domain, -+ const char* name); -+int virDomainSnapshotDelete (virDomainPtr domain, -+ const char* name); -+int virDomainNumOfSnapshots (virDomainPtr domain); -+int virDomainListSnapshots (virDomainPtr domain, -+ char **const names, -+ int maxnames); -+ -+ -+/* - * Domain core dump - */ - int virDomainCoreDump (virDomainPtr domain, -Index: libvirt-0.4.6/src/libvirt.c -=================================================================== ---- libvirt-0.4.6.orig/src/libvirt.c -+++ libvirt-0.4.6/src/libvirt.c -@@ -1659,6 +1659,168 @@ virDomainRestore(virConnectPtr conn, con - return -1; - } - -+ -+/** -+ * virDomainSnapshotCreate: -+ * @domain: a domain object -+ * @name: name for the new snapshot -+ * -+ * Creates a snapshot from a running domain -+ * -+ * Returns 0 in case of success and -1 in case of failure. -+ */ -+int -+virDomainSnapshotCreate(virDomainPtr domain, const char* name) -+{ -+ virConnectPtr conn; -+ -+ DEBUG("domain=%p", domain); -+ -+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) { -+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); -+ return (-1); -+ } -+ -+ conn = domain->conn; -+ if (conn->flags & VIR_CONNECT_RO) { -+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); -+ return (-1); -+ } -+ -+ if (conn->driver->domainSnapshotCreate) -+ return conn->driver->domainSnapshotCreate(domain, name); -+ -+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); -+ return -1; -+} -+ -+/** -+ * virDomainSnapshotApply: -+ * @domain: a domain object -+ * @name: name of the snapshot to apply -+ * -+ * Starts a domain using a given snapshot. The domain needs to be shut down -+ * before calling thsi function. -+ * -+ * Returns 0 in case of success and -1 in case of failure. -+ */ -+int -+virDomainSnapshotApply(virDomainPtr domain, const char* name) -+{ -+ virConnectPtr conn; -+ -+ DEBUG("domain=%p", domain); -+ -+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) { -+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); -+ return (-1); -+ } -+ -+ conn = domain->conn; -+ if (conn->flags & VIR_CONNECT_RO) { -+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); -+ return (-1); -+ } -+ -+ if (conn->driver->domainSnapshotApply) -+ return conn->driver->domainSnapshotApply(domain, name); -+ -+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); -+ return -1; -+} -+ -+/** -+ * virDomainSnapshotDelete: -+ * @domain: a domain object -+ * @name: name of the snapshot to delete -+ * -+ * Deletes a snapshot from the given domain -+ * -+ * Returns 0 in case of success and -1 in case of failure. -+ */ -+int -+virDomainSnapshotDelete(virDomainPtr domain, const char* name) -+{ -+ virConnectPtr conn; -+ -+ DEBUG("domain=%p", domain); -+ -+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) { -+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); -+ return (-1); -+ } -+ -+ conn = domain->conn; -+ if (conn->flags & VIR_CONNECT_RO) { -+ virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); -+ return (-1); -+ } -+ -+ if (conn->driver->domainSnapshotDelete) -+ return conn->driver->domainSnapshotDelete(domain, name); -+ -+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); -+ return -1; -+} -+ -+/** -+ * virDomainNumOfSnapshots: -+ * @domain: a domain object -+ * -+ * Returns the number of snapshots of the given domain or -1 in case of failure -+ */ -+int -+virDomainNumOfSnapshots(virDomainPtr domain) -+{ -+ virConnectPtr conn; -+ -+ DEBUG("domain=%p", domain); -+ -+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) { -+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); -+ return (-1); -+ } -+ -+ conn = domain->conn; -+ if (conn->driver->domainNumOfSnapshots) -+ return conn->driver->domainNumOfSnapshots(domain); -+ -+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); -+ return -1; -+} -+ -+/** -+ * virDomainListSnapshots: -+ * @domain: a domain object -+ * @names: pointer to an array to store the snapshot names -+ * @maxnames: size of the array -+ * -+ * List the names of all snapshots of the given domain. The names are -+ * stored in the @names array. Unused array entries are set to NULL. -+ * -+ * Returns 0 in case of success and -1 in case of failure. -+ */ -+int -+virDomainListSnapshots(virDomainPtr domain, char **const names, int maxnames) -+{ -+ virConnectPtr conn; -+ -+ DEBUG("domain=%p", domain); -+ -+ if (!VIR_IS_CONNECTED_DOMAIN(domain)) { -+ virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); -+ return (-1); -+ } -+ -+ conn = domain->conn; -+ if (conn->driver->domainListSnapshots) -+ return conn->driver->domainListSnapshots(domain, names, maxnames); -+ -+ virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); -+ return -1; -+} -+ -+ - /** - * virDomainCoreDump: - * @domain: a domain object -Index: libvirt-0.4.6/src/driver.h -=================================================================== ---- libvirt-0.4.6.orig/src/driver.h -+++ libvirt-0.4.6/src/driver.h -@@ -146,6 +146,21 @@ typedef int - (*virDrvDomainRestore) (virConnectPtr conn, - const char *from); - typedef int -+ (*virDrvDomainSnapshotCreate) (virDomainPtr domain, -+ const char* name); -+typedef int -+ (*virDrvDomainSnapshotApply) (virDomainPtr domain, -+ const char* name); -+typedef int -+ (*virDrvDomainSnapshotDelete) (virDomainPtr domain, -+ const char* name); -+typedef int -+ (*virDrvDomainNumOfSnapshots) (virDomainPtr domain); -+typedef int -+ (*virDrvDomainListSnapshots) (virDomainPtr domain, -+ char **const names, -+ int maxnames); -+typedef int - (*virDrvDomainCoreDump) (virDomainPtr domain, - const char *to, - int flags); -@@ -352,6 +367,12 @@ struct _virDriver { - virDrvDomainMemoryPeek domainMemoryPeek; - virDrvNodeGetCellsFreeMemory nodeGetCellsFreeMemory; - virDrvNodeGetFreeMemory getFreeMemory; -+ -+ virDrvDomainSnapshotCreate domainSnapshotCreate; -+ virDrvDomainSnapshotApply domainSnapshotApply; -+ virDrvDomainSnapshotDelete domainSnapshotDelete; -+ virDrvDomainNumOfSnapshots domainNumOfSnapshots; -+ virDrvDomainListSnapshots domainListSnapshots; - }; - - typedef int -Index: libvirt-0.4.6/src/xen_unified.c -=================================================================== ---- libvirt-0.4.6.orig/src/xen_unified.c -+++ libvirt-0.4.6/src/xen_unified.c -@@ -869,6 +869,81 @@ xenUnifiedDomainRestore (virConnectPtr c - } - - static int -+xenUnifiedDomainSnapshotCreate(virDomainPtr domain, const char* name) -+{ -+ GET_PRIVATE(domain->conn); -+ int i; -+ -+ for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -+ if (priv->opened[i] && -+ drivers[i]->domainSnapshotCreate && -+ drivers[i]->domainSnapshotCreate(domain, name) == 0) -+ return 0; -+ -+ return -1; -+} -+ -+static int -+xenUnifiedDomainSnapshotApply(virDomainPtr domain, const char* name) -+{ -+ GET_PRIVATE(domain->conn); -+ int i; -+ -+ for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -+ if (priv->opened[i] && -+ drivers[i]->domainSnapshotApply && -+ drivers[i]->domainSnapshotApply(domain, name) == 0) -+ return 0; -+ -+ return -1; -+} -+ -+static int -+xenUnifiedDomainSnapshotDelete(virDomainPtr domain, const char* name) -+{ -+ GET_PRIVATE(domain->conn); -+ int i; -+ -+ for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -+ if (priv->opened[i] && -+ drivers[i]->domainSnapshotDelete && -+ drivers[i]->domainSnapshotDelete(domain, name) == 0) -+ return 0; -+ -+ return -1; -+} -+ -+static int -+xenUnifiedDomainNumOfSnapshots(virDomainPtr domain) -+{ -+ GET_PRIVATE(domain->conn); -+ int i; -+ -+ for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -+ if (priv->opened[i] && -+ drivers[i]->domainNumOfSnapshots) -+ return drivers[i]->domainNumOfSnapshots(domain); -+ -+ return -1; -+} -+ -+static int -+xenUnifiedDomainListSnapshots(virDomainPtr domain, char **const names, -+ int maxnames) -+{ -+ GET_PRIVATE(domain->conn); -+ int i; -+ -+ for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -+ if (priv->opened[i] && -+ drivers[i]->domainListSnapshots && -+ drivers[i]->domainListSnapshots(domain, names, maxnames) == 0) -+ return 0; -+ -+ return -1; -+} -+ -+static int - xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, int flags) - { - GET_PRIVATE(dom->conn); -@@ -1336,6 +1411,11 @@ static virDriver xenUnifiedDriver = { - .domainGetInfo = xenUnifiedDomainGetInfo, - .domainSave = xenUnifiedDomainSave, - .domainRestore = xenUnifiedDomainRestore, -+ .domainSnapshotCreate = xenUnifiedDomainSnapshotCreate, -+ .domainSnapshotApply = xenUnifiedDomainSnapshotApply, -+ .domainSnapshotDelete = xenUnifiedDomainSnapshotDelete, -+ .domainNumOfSnapshots = xenUnifiedDomainNumOfSnapshots, -+ .domainListSnapshots = xenUnifiedDomainListSnapshots, - .domainCoreDump = xenUnifiedDomainCoreDump, - .domainSetVcpus = xenUnifiedDomainSetVcpus, - .domainPinVcpu = xenUnifiedDomainPinVcpu, -Index: libvirt-0.4.6/src/xen_unified.h -=================================================================== ---- libvirt-0.4.6.orig/src/xen_unified.h -+++ libvirt-0.4.6/src/xen_unified.h -@@ -63,6 +63,11 @@ struct xenUnifiedDriver { - virDrvDomainGetInfo domainGetInfo; - virDrvDomainSave domainSave; - virDrvDomainRestore domainRestore; -+ virDrvDomainSnapshotCreate domainSnapshotCreate; -+ virDrvDomainSnapshotApply domainSnapshotApply; -+ virDrvDomainSnapshotDelete domainSnapshotDelete; -+ virDrvDomainNumOfSnapshots domainNumOfSnapshots; -+ virDrvDomainListSnapshots domainListSnapshots; - virDrvDomainCoreDump domainCoreDump; - virDrvDomainSetVcpus domainSetVcpus; - virDrvDomainPinVcpu domainPinVcpu; -Index: libvirt-0.4.6/src/xend_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -51,6 +51,12 @@ - - #ifndef PROXY - -+static int xenDaemonDomainSnapshotCreate(virDomainPtr domain, const char* name); -+static int xenDaemonDomainSnapshotApply(virDomainPtr domain, const char* name); -+static int xenDaemonDomainSnapshotDelete(virDomainPtr domain, const char* name); -+static int xenDaemonDomainNumOfSnapshots(virDomainPtr domain); -+static int xenDaemonDomainListSnapshots(virDomainPtr domain, char **const names, int maxnames); -+ - /* - * The number of Xen scheduler parameters - */ -@@ -3070,6 +3076,87 @@ xenDaemonDomainRestore(virConnectPtr con - } - return xend_op(conn, "", "op", "restore", "file", filename, NULL); - } -+ -+static int -+xenDaemonDomainSnapshotCreate(virDomainPtr domain, const char* name) -+{ -+ if ((domain == NULL) || (name == NULL)) { -+ virXendError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); -+ return (-1); -+ } -+ return xend_op(domain->conn, domain->name, "op", -+ "snapshot_create", "name", name, NULL); -+} -+ -+static int -+xenDaemonDomainSnapshotApply(virDomainPtr domain, const char* name) -+{ -+ if ((domain == NULL) || (name == NULL)) { -+ virXendError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); -+ return (-1); -+ } -+ return xend_op(domain->conn, domain->name, "op", -+ "snapshot_apply", "name", name, NULL); -+} -+ -+static int -+xenDaemonDomainSnapshotDelete(virDomainPtr domain, const char* name) -+{ -+ if ((domain == NULL) || (name == NULL)) { -+ virXendError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); -+ return (-1); -+ } -+ return xend_op(domain->conn, domain->name, "op", -+ "snapshot_delete", "name", name, NULL); -+} -+ -+static int -+xenDaemonDomainNumOfSnapshots(virDomainPtr domain) -+{ -+ struct sexpr *root, *node, *value; -+ int i; -+ -+ root = sexpr_get(domain->conn, -+ "/xend/domain/%s?op=snapshot_list", domain->name); -+ if (root == NULL) -+ return -1; -+ -+ for (node = root, i = 0; node->kind == SEXPR_CONS; node = node->u.s.cdr) { -+ value = node->u.s.car; -+ -+ if (value->kind == SEXPR_VALUE) -+ i++; -+ } -+ -+ return i; -+} -+ -+static int -+xenDaemonDomainListSnapshots(virDomainPtr domain, char **const names, -+ int maxnames) -+{ -+ struct sexpr *root, *node, *value; -+ int i; -+ root = sexpr_get(domain->conn, -+ "/xend/domain/%s?op=snapshot_list", domain->name); -+ if (root == NULL) -+ return -1; -+ -+ for (node = root, i = 0; node->kind == SEXPR_CONS; node = node->u.s.cdr) { -+ value = node->u.s.car; -+ -+ if (value->kind == SEXPR_VALUE) { -+ names[i] = strdup(value->u.value); -+ if (++i > maxnames) -+ return 0; -+ } -+ } -+ -+ for (; i < maxnames; i++) -+ names[i] = NULL; -+ -+ return 0; -+} - #endif /* !PROXY */ - - /** -@@ -4824,6 +4911,11 @@ struct xenUnifiedDriver xenDaemonDriver - xenDaemonDomainGetInfo, /* domainGetInfo */ - xenDaemonDomainSave, /* domainSave */ - xenDaemonDomainRestore, /* domainRestore */ -+ xenDaemonDomainSnapshotCreate, /* domainSnapshotCreate */ -+ xenDaemonDomainSnapshotApply, /* domainSnapshotApply */ -+ xenDaemonDomainSnapshotDelete, /* domainSnapshotDelete */ -+ xenDaemonDomainNumOfSnapshots, /* domainNumOfSnapshots */ -+ xenDaemonDomainListSnapshots, /* domainListSnapshots */ - xenDaemonDomainCoreDump, /* domainCoreDump */ - xenDaemonDomainSetVcpus, /* domainSetVcpus */ - xenDaemonDomainPinVcpu, /* domainPinVcpu */ -Index: libvirt-0.4.6/src/proxy_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/proxy_internal.c -+++ libvirt-0.4.6/src/proxy_internal.c -@@ -66,6 +66,11 @@ struct xenUnifiedDriver xenProxyDriver = - xenProxyDomainGetInfo, /* domainGetInfo */ - NULL, /* domainSave */ - NULL, /* domainRestore */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - NULL, /* domainCoreDump */ - NULL, /* domainSetVcpus */ - NULL, /* domainPinVcpu */ -Index: libvirt-0.4.6/src/xen_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/xen_internal.c -+++ libvirt-0.4.6/src/xen_internal.c -@@ -700,6 +700,11 @@ struct xenUnifiedDriver xenHypervisorDri - xenHypervisorGetDomainInfo, /* domainGetInfo */ - NULL, /* domainSave */ - NULL, /* domainRestore */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - NULL, /* domainCoreDump */ - xenHypervisorSetVcpus, /* domainSetVcpus */ - xenHypervisorPinVcpu, /* domainPinVcpu */ -Index: libvirt-0.4.6/src/xm_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/xm_internal.c -+++ libvirt-0.4.6/src/xm_internal.c -@@ -105,6 +105,11 @@ struct xenUnifiedDriver xenXMDriver = { - xenXMDomainGetInfo, /* domainGetInfo */ - NULL, /* domainSave */ - NULL, /* domainRestore */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - NULL, /* domainCoreDump */ - xenXMDomainSetVcpus, /* domainSetVcpus */ - xenXMDomainPinVcpu, /* domainPinVcpu */ -Index: libvirt-0.4.6/src/xs_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/xs_internal.c -+++ libvirt-0.4.6/src/xs_internal.c -@@ -66,6 +66,11 @@ struct xenUnifiedDriver xenStoreDriver = - xenStoreGetDomainInfo, /* domainGetInfo */ - NULL, /* domainSave */ - NULL, /* domainRestore */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - NULL, /* domainCoreDump */ - NULL, /* domainSetVcpus */ - NULL, /* domainPinVcpu */ -Index: libvirt-0.4.6/src/virsh.c -=================================================================== ---- libvirt-0.4.6.orig/src/virsh.c -+++ libvirt-0.4.6/src/virsh.c -@@ -1100,6 +1100,189 @@ cmdSave(vshControl *ctl, const vshCmd *c - return ret; - } - -+ -+/* -+ * "snapshot-create" command -+ */ -+static vshCmdInfo info_snapshot_create[] = { -+ {"syntax", "snapshot-create "}, -+ {"help", gettext_noop("Create a snapshot of the domain")}, -+ {"desc", gettext_noop("Create a snapshot of the domain")}, -+ {NULL, NULL} -+}; -+ -+static vshCmdOptDef opts_snapshot_create[] = { -+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Domain name, id or uuid")}, -+ {"name", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Name of the snapshot")}, -+ {NULL, 0, 0, NULL} -+}; -+ -+static int -+cmdSnapshotCreate(vshControl * ctl, vshCmd * cmd) -+{ -+ virDomainPtr dom; -+ char *name; -+ char *domain; -+ int ret = TRUE; -+ -+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) -+ return FALSE; -+ -+ if (!(name = vshCommandOptString(cmd, "name", NULL))) -+ return FALSE; -+ -+ if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", &domain))) -+ return FALSE; -+ -+ if (virDomainSnapshotCreate(dom, name) == 0) { -+ vshPrint(ctl, _("Snapshot %s created for domain %s\n"), name, domain); -+ } else { -+ vshError(ctl, FALSE, _("Failed to create snapshot %s for domain %s"), -+ name, domain); -+ ret = FALSE; -+ } -+ -+ virDomainFree(dom); -+ return ret; -+} -+ -+/* -+ * "snapshot-apply" command -+ */ -+static vshCmdInfo info_snapshot_apply[] = { -+ {"syntax", "snapshot-apply "}, -+ {"help", gettext_noop("Start the domain using a snapshot")}, -+ {"desc", gettext_noop("Start the domain using a snapshot")}, -+ {NULL, NULL} -+}; -+ -+static vshCmdOptDef opts_snapshot_apply[] = { -+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Domain name, id or uuid")}, -+ {"name", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Name of the snapshot")}, -+ {NULL, 0, 0, NULL} -+}; -+ -+static int -+cmdSnapshotApply(vshControl * ctl, vshCmd * cmd) -+{ -+ virDomainPtr dom; -+ char *name; -+ char *domain; -+ int ret = TRUE; -+ -+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) -+ return FALSE; -+ -+ if (!(name = vshCommandOptString(cmd, "name", NULL))) -+ return FALSE; -+ -+ if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", &domain))) -+ return FALSE; -+ -+ if (virDomainSnapshotApply(dom, name) == 0) { -+ vshPrint(ctl, _("Domain %s started using snapshot %s\n"), -+ domain, name); -+ } else { -+ vshError(ctl, FALSE, _("Failed to start domain %s using snapshot %s"), -+ domain, name); -+ ret = FALSE; -+ } -+ -+ virDomainFree(dom); -+ return ret; -+} -+ -+/* -+ * "snapshot-delete" command -+ */ -+static vshCmdInfo info_snapshot_delete[] = { -+ {"syntax", "snapshot-delete "}, -+ {"help", gettext_noop("Delete a snapshot from a domain")}, -+ {"desc", gettext_noop("Delete a snapshot from a domain")}, -+ {NULL, NULL} -+}; -+ -+static vshCmdOptDef opts_snapshot_delete[] = { -+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Domain name, id or uuid")}, -+ {"name", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Name of the snapshot")}, -+ {NULL, 0, 0, NULL} -+}; -+ -+static int -+cmdSnapshotDelete(vshControl * ctl, vshCmd * cmd) -+{ -+ virDomainPtr dom; -+ char *name; -+ char *domain; -+ int ret = TRUE; -+ -+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) -+ return FALSE; -+ -+ if (!(name = vshCommandOptString(cmd, "name", NULL))) -+ return FALSE; -+ -+ if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", &domain))) -+ return FALSE; -+ -+ if (virDomainSnapshotDelete(dom, name) == 0) { -+ vshPrint(ctl, _("Snapshot %s deleted from domain %s\n"), name, domain); -+ } else { -+ vshError(ctl, FALSE, _("Failed to delete snapshot %s from domain %s"), -+ name, domain); -+ ret = FALSE; -+ } -+ -+ virDomainFree(dom); -+ return ret; -+} -+ -+/* -+ * "snapshot-list" command -+ */ -+static vshCmdInfo info_snapshot_list[] = { -+ {"syntax", "snapshot-list "}, -+ {"help", gettext_noop("List all snapshots of a domain")}, -+ {"desc", gettext_noop("List all snapshots of a domain")}, -+ {NULL, NULL} -+}; -+ -+static vshCmdOptDef opts_snapshot_list[] = { -+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("Domain name, id or uuid")}, -+ {NULL, 0, 0, NULL} -+}; -+ -+static int -+cmdSnapshotList(vshControl * ctl, vshCmd * cmd) -+{ -+ virDomainPtr dom; -+ char *domain; -+ char** names; -+ int num; -+ int i; -+ int ret = TRUE; -+ -+ if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) -+ return FALSE; -+ -+ if (!(dom = vshCommandOptDomain(ctl, cmd, "domain", &domain))) -+ return FALSE; -+ -+ // TODO Display snapshot details -+ num = virDomainNumOfSnapshots(dom); -+ names = malloc(num * sizeof(*names)); -+ virDomainListSnapshots(dom, names, num); -+ -+ for (i = 0; i < num; i++) { -+ printf("%s\n", names[i]); -+ free(names[i]); -+ } -+ -+ free(names); -+ virDomainFree(dom); -+ return ret; -+} -+ - /* - * "schedinfo" command - */ -@@ -5568,6 +5751,12 @@ static const vshCmdDef commands[] = { - {"undefine", cmdUndefine, opts_undefine, info_undefine}, - {"uri", cmdURI, NULL, info_uri}, - -+ {"snapshot-create", cmdSnapshotCreate, opts_snapshot_create, info_snapshot_create}, -+ {"snapshot-apply", cmdSnapshotApply, opts_snapshot_apply, info_snapshot_apply}, -+ {"snapshot-delete", cmdSnapshotDelete, opts_snapshot_delete, info_snapshot_delete}, -+ {"snapshot-list", cmdSnapshotList, opts_snapshot_list, info_snapshot_list}, -+ -+ - {"vol-create", cmdVolCreate, opts_vol_create, info_vol_create}, - {"vol-create-as", cmdVolCreateAs, opts_vol_create_as, info_vol_create_as}, - {"vol-delete", cmdVolDelete, opts_vol_delete, info_vol_delete}, -Index: libvirt-0.4.6/src/lxc_driver.c -=================================================================== ---- libvirt-0.4.6.orig/src/lxc_driver.c -+++ libvirt-0.4.6/src/lxc_driver.c -@@ -1203,6 +1203,11 @@ static virDriver lxcDriver = { - NULL, /* domainMemoryPeek */ - NULL, /* nodeGetCellsFreeMemory */ - NULL, /* getFreeMemory */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - }; - - -Index: libvirt-0.4.6/src/openvz_driver.c -=================================================================== ---- libvirt-0.4.6.orig/src/openvz_driver.c -+++ libvirt-0.4.6/src/openvz_driver.c -@@ -1014,6 +1014,11 @@ static virDriver openvzDriver = { - NULL, /* domainMemoryPeek */ - NULL, /* nodeGetCellsFreeMemory */ - NULL, /* nodeGetFreeMemory */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - }; - - int openvzRegister(void) { -Index: libvirt-0.4.6/src/qemu_driver.c -=================================================================== ---- libvirt-0.4.6.orig/src/qemu_driver.c -+++ libvirt-0.4.6/src/qemu_driver.c -@@ -4079,6 +4079,11 @@ static virDriver qemuDriver = { - NULL, /* nodeGetCellsFreeMemory */ - NULL, /* getFreeMemory */ - #endif -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - }; - - static virNetworkDriver qemuNetworkDriver = { -Index: libvirt-0.4.6/src/remote_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/remote_internal.c -+++ libvirt-0.4.6/src/remote_internal.c -@@ -4888,6 +4888,11 @@ static virDriver driver = { - .domainMemoryPeek = remoteDomainMemoryPeek, - .nodeGetCellsFreeMemory = remoteNodeGetCellsFreeMemory, - .getFreeMemory = remoteNodeGetFreeMemory, -+ .domainSnapshotCreate = NULL, -+ .domainSnapshotApply = NULL, -+ .domainSnapshotDelete = NULL, -+ .domainNumOfSnapshots = NULL, -+ .domainListSnapshots = NULL, - }; - - static virNetworkDriver network_driver = { -Index: libvirt-0.4.6/src/test.c -=================================================================== ---- libvirt-0.4.6.orig/src/test.c -+++ libvirt-0.4.6/src/test.c -@@ -1595,6 +1595,11 @@ static virDriver testDriver = { - NULL, /* domainMemoryPeek */ - testNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */ - NULL, /* getFreeMemory */ -+ NULL, /* domainSnapshotCreate */ -+ NULL, /* domainSnapshotApply */ -+ NULL, /* domainSnapshotDelete */ -+ NULL, /* domainNumOfSnapshots */ -+ NULL, /* domainListSnapshots */ - }; - - static virNetworkDriver testNetworkDriver = { -Index: libvirt-0.4.6/src/libvirt_sym.version -=================================================================== ---- libvirt-0.4.6.orig/src/libvirt_sym.version -+++ libvirt-0.4.6/src/libvirt_sym.version -@@ -35,6 +35,11 @@ - virDomainRestore; - virDomainResume; - virDomainSave; -+ virDomainSnapshotCreate; -+ virDomainSnapshotApply; -+ virDomainSnapshotDelete; -+ virDomainNumOfSnapshots; -+ virDomainListSnapshots; - virDomainCoreDump; - virDomainSetMemory; - virDomainSetMaxMemory; -Index: libvirt-0.4.6/docs/libvirt-api.xml -=================================================================== ---- libvirt-0.4.6.orig/docs/libvirt-api.xml -+++ libvirt-0.4.6/docs/libvirt-api.xml -@@ -143,6 +143,11 @@ - - - -+ -+ -+ -+ -+ - - - -@@ -1096,6 +1101,36 @@ see note above'/> - - - -+ -+ Start a shut off domain based on a previously taken snapshot -+ -+ -+ -+ -+ -+ Create a snapshot from a running domain -+ -+ -+ -+ -+ -+ Delete a snapshot from a domain -+ -+ -+ -+ -+ -+ Returns the number of snapshot a given domain has -+ -+ -+ -+ -+ Returns the names of the snapshots of a domain -+ -+ -+ -+ -+ - - Undefine a domain but does not stop it if it is running - -Index: libvirt-0.4.6/python/libvirt-py.c -=================================================================== ---- libvirt-0.4.6.orig/python/libvirt-py.c -+++ libvirt-0.4.6/python/libvirt-py.c -@@ -25,6 +25,25 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * -+libvirt_virDomainSnapshotDelete(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ int c_retval; -+ virDomainPtr domain; -+ PyObject *pyobj_domain; -+ char * name; -+ -+ if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainSnapshotDelete", &pyobj_domain, &name)) -+ return(NULL); -+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ -+ c_retval = virDomainSnapshotDelete(domain, name); -+LIBVIRT_END_ALLOW_THREADS; -+ py_retval = libvirt_intWrap((int) c_retval); -+ return(py_retval); -+} -+ -+PyObject * - libvirt_virStorageVolGetKey(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - const char * c_retval; -@@ -520,24 +539,6 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * --libvirt_virNetworkGetName(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -- PyObject *py_retval; -- const char * c_retval; -- virNetworkPtr network; -- PyObject *pyobj_network; -- -- if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetName", &pyobj_network)) -- return(NULL); -- network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network); --LIBVIRT_BEGIN_ALLOW_THREADS; -- -- c_retval = virNetworkGetName(network); --LIBVIRT_END_ALLOW_THREADS; -- py_retval = libvirt_charPtrConstWrap((const char *) c_retval); -- return(py_retval); --} -- --PyObject * - libvirt_virNetworkDestroy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - int c_retval; -@@ -771,6 +772,25 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * -+libvirt_virDomainSnapshotCreate(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ int c_retval; -+ virDomainPtr domain; -+ PyObject *pyobj_domain; -+ char * name; -+ -+ if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainSnapshotCreate", &pyobj_domain, &name)) -+ return(NULL); -+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ -+ c_retval = virDomainSnapshotCreate(domain, name); -+LIBVIRT_END_ALLOW_THREADS; -+ py_retval = libvirt_intWrap((int) c_retval); -+ return(py_retval); -+} -+ -+PyObject * - libvirt_virNetworkDefineXML(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - virNetworkPtr c_retval; -@@ -806,6 +826,24 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * -+libvirt_virDomainNumOfSnapshots(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ int c_retval; -+ virDomainPtr domain; -+ PyObject *pyobj_domain; -+ -+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainNumOfSnapshots", &pyobj_domain)) -+ return(NULL); -+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ -+ c_retval = virDomainNumOfSnapshots(domain); -+LIBVIRT_END_ALLOW_THREADS; -+ py_retval = libvirt_intWrap((int) c_retval); -+ return(py_retval); -+} -+ -+PyObject * - libvirt_virDomainResume(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - int c_retval; -@@ -824,6 +862,25 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * -+libvirt_virDomainSnapshotApply(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ int c_retval; -+ virDomainPtr domain; -+ PyObject *pyobj_domain; -+ char * name; -+ -+ if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainSnapshotApply", &pyobj_domain, &name)) -+ return(NULL); -+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ -+ c_retval = virDomainSnapshotApply(domain, name); -+LIBVIRT_END_ALLOW_THREADS; -+ py_retval = libvirt_intWrap((int) c_retval); -+ return(py_retval); -+} -+ -+PyObject * - libvirt_virConnectGetHostname(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - char * c_retval; -@@ -897,6 +954,24 @@ LIBVIRT_END_ALLOW_THREADS; - } - - PyObject * -+libvirt_virNetworkGetName(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ const char * c_retval; -+ virNetworkPtr network; -+ PyObject *pyobj_network; -+ -+ if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetName", &pyobj_network)) -+ return(NULL); -+ network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network); -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ -+ c_retval = virNetworkGetName(network); -+LIBVIRT_END_ALLOW_THREADS; -+ py_retval = libvirt_charPtrConstWrap((const char *) c_retval); -+ return(py_retval); -+} -+ -+PyObject * - libvirt_virConnectGetCapabilities(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { - PyObject *py_retval; - char * c_retval; -Index: libvirt-0.4.6/python/libvirt-py.h -=================================================================== ---- libvirt-0.4.6.orig/python/libvirt-py.h -+++ libvirt-0.4.6/python/libvirt-py.h -@@ -1,6 +1,7 @@ - /* Generated */ - - PyObject * libvirt_virStoragePoolGetXMLDesc(PyObject *self, PyObject *args); -+PyObject * libvirt_virDomainSnapshotDelete(PyObject *self, PyObject *args); - PyObject * libvirt_virStorageVolGetKey(PyObject *self, PyObject *args); - PyObject * libvirt_virConnectClose(PyObject *self, PyObject *args); - PyObject * libvirt_virDomainDefineXML(PyObject *self, PyObject *args); -@@ -28,7 +29,6 @@ PyObject * libvirt_virConnectNumOfNetwor - PyObject * libvirt_virStorageVolGetName(PyObject *self, PyObject *args); - PyObject * libvirt_virStoragePoolLookupByUUIDString(PyObject *self, PyObject *args); - PyObject * libvirt_virDomainGetXMLDesc(PyObject *self, PyObject *args); --PyObject * libvirt_virNetworkGetName(PyObject *self, PyObject *args); - PyObject * libvirt_virNetworkDestroy(PyObject *self, PyObject *args); - PyObject * libvirt_virStoragePoolLookupByName(PyObject *self, PyObject *args); - PyObject * libvirt_virNetworkGetBridgeName(PyObject *self, PyObject *args); -@@ -42,13 +42,17 @@ PyObject * libvirt_virNetworkSetAutostar - PyObject * libvirt_virDomainGetMaxMemory(PyObject *self, PyObject *args); - PyObject * libvirt_virResetLastError(PyObject *self, PyObject *args); - PyObject * libvirt_virStoragePoolFree(PyObject *self, PyObject *args); -+PyObject * libvirt_virDomainSnapshotCreate(PyObject *self, PyObject *args); - PyObject * libvirt_virNetworkDefineXML(PyObject *self, PyObject *args); - PyObject * libvirt_virConnResetLastError(PyObject *self, PyObject *args); -+PyObject * libvirt_virDomainNumOfSnapshots(PyObject *self, PyObject *args); - PyObject * libvirt_virDomainResume(PyObject *self, PyObject *args); -+PyObject * libvirt_virDomainSnapshotApply(PyObject *self, PyObject *args); - PyObject * libvirt_virConnectGetHostname(PyObject *self, PyObject *args); - PyObject * libvirt_virDomainGetName(PyObject *self, PyObject *args); - PyObject * libvirt_virNetworkGetXMLDesc(PyObject *self, PyObject *args); - PyObject * libvirt_virConnectNumOfStoragePools(PyObject *self, PyObject *args); -+PyObject * libvirt_virNetworkGetName(PyObject *self, PyObject *args); - PyObject * libvirt_virConnectGetCapabilities(PyObject *self, PyObject *args); - PyObject * libvirt_virDomainLookupByName(PyObject *self, PyObject *args); - PyObject * libvirt_virConnectFindStoragePoolSources(PyObject *self, PyObject *args); -Index: libvirt-0.4.6/python/libvirt.py -=================================================================== ---- libvirt-0.4.6.orig/python/libvirt.py -+++ libvirt-0.4.6/python/libvirt.py -@@ -359,6 +359,12 @@ class virDomain: - ret = libvirtmod.virDomainGetName(self._o) - return ret - -+ def numOfSnapshots(self): -+ """Returns the number of snapshot a given domain has """ -+ ret = libvirtmod.virDomainNumOfSnapshots(self._o) -+ if ret == -1: raise libvirtError ('virDomainNumOfSnapshots() failed', dom=self) -+ return ret -+ - def reboot(self, flags): - """Reboot a domain, the domain object is still usable there - after but the domain OS is being stopped for a restart. -@@ -433,6 +439,24 @@ class virDomain: - if ret == -1: raise libvirtError ('virDomainShutdown() failed', dom=self) - return ret - -+ def snapshotApply(self, name): -+ """Start a shut off domain based on a previously taken snapshot """ -+ ret = libvirtmod.virDomainSnapshotApply(self._o, name) -+ if ret == -1: raise libvirtError ('virDomainSnapshotApply() failed', dom=self) -+ return ret -+ -+ def snapshotCreate(self, name): -+ """Create a snapshot from a running domain """ -+ ret = libvirtmod.virDomainSnapshotCreate(self._o, name) -+ if ret == -1: raise libvirtError ('virDomainSnapshotCreate() failed', dom=self) -+ return ret -+ -+ def snapshotDelete(self, name): -+ """Delete a snapshot from a domain """ -+ ret = libvirtmod.virDomainSnapshotDelete(self._o, name) -+ if ret == -1: raise libvirtError ('virDomainSnapshotDelete() failed', dom=self) -+ return ret -+ - def suspend(self): - """Suspends an active domain, the process is frozen without - further access to CPU resources and I/O but the memory used -@@ -489,6 +513,12 @@ class virDomain: - ret = libvirtmod.virDomainInterfaceStats(self._o, path) - return ret - -+ def listSnapshots(self): -+ """Returns the names of the snapshots of a domain """ -+ ret = libvirtmod.virDomainListSnapshots(self._o) -+ if ret is None: raise libvirtError ('virDomainListSnapshots() failed', dom=self) -+ return ret -+ - def pinVcpu(self, vcpu, cpumap): - """Dynamically change the real CPUs which can be allocated to - a virtual CPU. This function requires privileged access to -Index: libvirt-0.4.6/python/libvir.c -=================================================================== ---- libvirt-0.4.6.orig/python/libvir.c -+++ libvirt-0.4.6/python/libvir.c -@@ -1466,6 +1466,35 @@ libvirt_virStoragePoolLookupByUUID(PyObj - return(py_retval); - } - -+static PyObject * -+libvirt_virDomainListSnapshots(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+ PyObject *py_retval; -+ int i, num; -+ char** names; -+ virDomainPtr domain; -+ PyObject *pyobj_domain; -+ -+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainListSnapshots", -+ &pyobj_domain)) -+ return(NULL); -+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); -+ -+LIBVIRT_BEGIN_ALLOW_THREADS; -+ num = virDomainNumOfSnapshots(domain); -+ names = malloc(num * sizeof(*names)); -+ virDomainListSnapshots(domain, names, num); -+LIBVIRT_END_ALLOW_THREADS; -+ -+ py_retval = PyList_New(num); -+ for (i = 0; i < num; i++) { -+ PyList_SetItem(py_retval, i, Py_BuildValue("s", names[i])); -+ free(names[i]); -+ } -+ free(names); -+ -+ return(py_retval); -+} -+ - - - /************************************************************************ -@@ -1502,6 +1531,7 @@ static PyMethodDef libvirtMethods[] = { - {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters, METH_VARARGS, NULL}, - {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus, METH_VARARGS, NULL}, - {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu, METH_VARARGS, NULL}, -+ {(char *) "virDomainListSnapshots", libvirt_virDomainListSnapshots, METH_VARARGS, NULL}, - {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL}, - {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL}, - {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL}, -Index: libvirt-0.4.6/python/libvirt-python-api.xml -=================================================================== ---- libvirt-0.4.6.orig/python/libvirt-python-api.xml -+++ libvirt-0.4.6/python/libvirt-python-api.xml -@@ -135,6 +135,11 @@ - - - -+ -+ Returns the names of the snapshots of a domain -+ -+ -+ - - list the storage pools, stores the pointers to the names in @names - -Index: libvirt-0.4.6/python/generator.py -=================================================================== ---- libvirt-0.4.6.orig/python/generator.py -+++ libvirt-0.4.6/python/generator.py -@@ -306,6 +306,7 @@ skip_impl = ( - 'virDomainSetSchedulerParameters', - 'virDomainGetVcpus', - 'virDomainPinVcpu', -+ 'virDomainListSnapshots', - 'virStoragePoolGetUUID', - 'virStoragePoolGetUUIDString', - 'virStoragePoolLookupByUUID', diff --git a/socat.patch b/socat.patch index 0d19d61..9a7a288 100644 --- a/socat.patch +++ b/socat.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.5/src/remote_internal.c +Index: libvirt-0.5.1/src/remote_internal.c =================================================================== ---- libvirt-0.4.5.orig/src/remote_internal.c -+++ libvirt-0.4.5/src/remote_internal.c -@@ -623,9 +623,22 @@ doRemoteOpen (virConnectPtr conn, +--- libvirt-0.5.1.orig/src/remote_internal.c ++++ libvirt-0.5.1/src/remote_internal.c +@@ -674,9 +674,22 @@ doRemoteOpen (virConnectPtr conn, cmd_argv[j++] = strdup ("none"); } cmd_argv[j++] = strdup (priv->hostname); @@ -16,7 +16,7 @@ Index: libvirt-0.4.5/src/remote_internal.c + } else { + cmd_argv[j++] = strdup ("socat"); + cmd_argv[j++] = strdup ("-"); -+ ++ + char *socat_addr = 0; + if ((asprintf (&socat_addr, "GOPEN:%s", + sockname ? sockname : LIBVIRTD_PRIV_UNIX_SOCKET)) < 0) { diff --git a/suse-network.patch b/suse-network.patch deleted file mode 100644 index 69bde60..0000000 --- a/suse-network.patch +++ /dev/null @@ -1,186 +0,0 @@ -Index: libvirt-0.4.6/src/network_conf.c -=================================================================== ---- libvirt-0.4.6.orig/src/network_conf.c -+++ libvirt-0.4.6/src/network_conf.c -@@ -752,6 +752,131 @@ error: - return NULL; - } - -+static int virNetworkIsBridge(const char *name) -+{ -+ char *path = NULL; -+ int ret = 0; -+ struct stat s; -+ -+ if (asprintf(&path, "/sys/class/net/%s/bridge", name) < 0) -+ goto out; -+ -+ if (stat(path, &s) != 0) -+ goto out; -+ -+ if (S_ISDIR(s.st_mode)) -+ ret = 1; -+ -+ out: -+ free(path); -+ return ret; -+} -+ -+static unsigned long virNetworkDefSuseGetValue(char *netName, char *valName) -+{ -+ unsigned long ret = 0; -+ char *path = NULL; -+ FILE *f; -+ -+ if (asprintf(&path, "/sys/class/net/%s/bridge/%s", netName, valName) < 0) -+ return ret; -+ -+ if ((f = fopen(path, "r")) == NULL) -+ goto out; -+ -+ if (fscanf(f, "%lu", &ret) != 1) { -+ ret = 0; -+ goto out; -+ } -+ -+ -+ out: -+ if (f != NULL) -+ fclose(f); -+ free(path); -+ return ret; -+} -+ -+static virNetworkObjPtr virNetworkLoadSuseNet(virConnectPtr conn, -+ virNetworkObjPtr *nets, -+ char *name) -+{ -+ virNetworkDefPtr def; -+ virNetworkObjPtr network; -+ int err; -+ -+ if ((network = virNetworkFindByName(*nets, name))) { -+ return network; -+ } -+ -+ if (VIR_ALLOC(network) < 0) { -+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); -+ return NULL; -+ } -+ -+ network->autostart = 1; -+ network->active = 1; -+ network->readonly = 1; -+ network->next = *nets; -+ -+ if (VIR_ALLOC(def) < 0) { -+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); -+ goto error; -+ } -+ -+ network->def = def; -+ -+ /* name */ -+ def->name = strdup(name); -+ if (def->name == NULL) { -+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); -+ goto error; -+ } -+ -+ /* uuid */ -+ if ((err = virUUIDGenerate(def->uuid))) { -+ virNetworkReportError(conn, VIR_ERR_INTERNAL_ERROR, -+ _("Failed to generate UUID: %s"), strerror(err)); -+ goto error; -+ } -+ -+ /* bridge information */ -+ def->bridge = strdup(name); -+ if (def->bridge == NULL) { -+ virNetworkReportError(conn, VIR_ERR_NO_MEMORY, NULL); -+ goto error; -+ } -+ def->stp = (int)virNetworkDefSuseGetValue(name, "stp_state"); -+ def->delay = virNetworkDefSuseGetValue(name, "forward_delay"); -+ -+ /* Add network to the list */ -+ *nets = network; -+ return network; -+ -+ error: -+ virNetworkObjFree(network); -+ return NULL; -+} -+ -+static void virNetworkLoadSuseNetworks(virConnectPtr conn, -+ virNetworkObjPtr *nets) -+{ -+ DIR *dir = NULL; -+ struct dirent *de; -+ int count = 0; -+ -+ dir = opendir("/sys/class/net"); -+ if (dir == NULL) -+ return; -+ -+ while ((de = readdir(dir))) { -+ if (virNetworkIsBridge(de->d_name)) { -+ virNetworkLoadSuseNet(conn, nets, de->d_name); -+ } -+ } -+ closedir(dir); -+} -+ - int virNetworkLoadAllConfigs(virConnectPtr conn, - virNetworkObjPtr *nets, - const char *configDir, -@@ -787,6 +912,7 @@ int virNetworkLoadAllConfigs(virConnectP - - closedir(dir); - -+ virNetworkLoadSuseNetworks(conn, nets); - return 0; - } - -Index: libvirt-0.4.6/src/network_conf.h -=================================================================== ---- libvirt-0.4.6.orig/src/network_conf.h -+++ libvirt-0.4.6/src/network_conf.h -@@ -82,6 +82,7 @@ struct _virNetworkObj { - unsigned int active : 1; - unsigned int autostart : 1; - unsigned int persistent : 1; -+ unsigned int readonly : 1; - - char *configFile; /* Persistent config file path */ - char *autostartLink; /* Symlink path for autostart */ -Index: libvirt-0.4.6/src/qemu_driver.c -=================================================================== ---- libvirt-0.4.6.orig/src/qemu_driver.c -+++ libvirt-0.4.6/src/qemu_driver.c -@@ -1601,6 +1601,12 @@ static int qemudShutdownNetworkDaemon(vi - if (!virNetworkIsActive(network)) - return 0; - -+ if (network->readonly) { -+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, -+ ": Network '%s' is readonly", network->def->name); -+ return -1; -+ } -+ - if (network->dnsmasqPid > 0) - kill(network->dnsmasqPid, SIGTERM); - -@@ -3974,6 +3980,12 @@ static int qemudNetworkSetAutostart(virN - return -1; - } - -+ if (network->readonly) { -+ qemudReportError(net->conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, -+ ": Network '%s' is readonly", network->def->name); -+ return -1; -+ } -+ - autostart = (autostart != 0); - - if (network->autostart == autostart) diff --git a/vif-parsing.patch b/vif-parsing.patch deleted file mode 100644 index a392340..0000000 --- a/vif-parsing.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: libvirt-0.4.6/src/xend_internal.c -=================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -1890,6 +1890,8 @@ xenDaemonParseSxprNets(virConnectPtr con - prev->next = net; - else - def->nets = net; -+ -+ prev = net; - vif_index++; - } - } diff --git a/vnc-port.patch b/vnc-port.patch index b36350e..c5a5cea 100644 --- a/vnc-port.patch +++ b/vnc-port.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.6/src/xend_internal.c +Index: libvirt-0.5.1/src/xend_internal.c =================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -2138,10 +2138,8 @@ xenDaemonParseSxprGraphicsNew(virConnect +--- libvirt-0.5.1.orig/src/xend_internal.c ++++ libvirt-0.5.1/src/xend_internal.c +@@ -2079,10 +2079,8 @@ xenDaemonParseSxprGraphicsNew(virConnect const char *keymap = sexpr_node(node, "device/vfb/keymap"); const char *unused = sexpr_node(node, "device/vfb/vncunused"); diff --git a/xen-maxmem.patch b/xen-maxmem.patch deleted file mode 100644 index b5ab00a..0000000 --- a/xen-maxmem.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: libvirt-0.4.6/src/xen_unified.c -=================================================================== ---- libvirt-0.4.6.orig/src/xen_unified.c -+++ libvirt-0.4.6/src/xen_unified.c -@@ -799,8 +799,15 @@ xenUnifiedDomainSetMaxMemory (virDomainP - GET_PRIVATE(dom->conn); - int i; - -+ /* Prefer xend for setting max memory */ -+ if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) { -+ if (xenDaemonDomainSetMaxMemory (dom, memory) == 0) -+ return 0; -+ } -+ - for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) -- if (priv->opened[i] && -+ if (i != XEN_UNIFIED_XEND_OFFSET && -+ priv->opened[i] && - drivers[i]->domainSetMaxMemory && - drivers[i]->domainSetMaxMemory (dom, memory) == 0) - return 0; diff --git a/xen-pv-cdrom.patch b/xen-pv-cdrom.patch index 6263eb1..fa155e6 100644 --- a/xen-pv-cdrom.patch +++ b/xen-pv-cdrom.patch @@ -1,8 +1,8 @@ -Index: libvirt-0.4.6/src/xend_internal.c +Index: libvirt-0.5.1/src/xend_internal.c =================================================================== ---- libvirt-0.4.6.orig/src/xend_internal.c -+++ libvirt-0.4.6/src/xend_internal.c -@@ -5158,7 +5158,10 @@ xenDaemonFormatSxprDisk(virConnectPtr co +--- libvirt-0.5.1.orig/src/xend_internal.c ++++ libvirt-0.5.1/src/xend_internal.c +@@ -5021,7 +5021,10 @@ xenDaemonFormatSxprDisk(virConnectPtr co def->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? "cdrom" : "disk"); } else {