[PATCH 0 of 6] Add scheduling parameter persistence

Since libvirt does not persist tuning parameters like those needed to control the scheduler, this set introduces an additional persistence layer. It also makes DefineSystem() and ModifyResources() save that information and makes ComputerSystem set the parameters on domain startup. Comments welcome.

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213647742 25200 # Node ID 74b34a49b99a5bef18be26c85e1f2c76c09822ca # Parent e3b5268c1b4e18a7b0bfe48d98d1f1017a4498c6 Add persistent data location to configure.ac Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r e3b5268c1b4e -r 74b34a49b99a acinclude.m4 --- a/acinclude.m4 Fri Jun 13 18:39:12 2008 -0700 +++ b/acinclude.m4 Mon Jun 16 13:22:22 2008 -0700 @@ -317,6 +317,17 @@ ] ) +# +# Define info store location. +# +AC_DEFUN([DEFINE_INFO_STORE], + [ + AC_DEFINE_UNQUOTED([INFO_STORE], "$1", [Info store location]) + INFO_STORE=$1 + AC_SUBST(INFO_STORE) + ] +) + AC_DEFUN([SET_CSET], [ if test -d .hg && test -x $(which hg); then diff -r e3b5268c1b4e -r 74b34a49b99a configure.ac --- a/configure.ac Fri Jun 13 18:39:12 2008 -0700 +++ b/configure.ac Mon Jun 16 13:22:22 2008 -0700 @@ -60,6 +60,13 @@ [DEFINE_DISK_CONFIG($with_diskconfig)], [DEFINE_DISK_CONFIG(/etc/libvirt/diskpool.conf)] ) + +AC_ARG_WITH([info_store], + [ --with-info-store=PATH Set information store location (default=/etc/libvirt/cim)], + [DEFINE_INFO_STORE($withval)], + [DEFINE_INFO_STORE(/etc/libvirt/cim)] +) + AC_ARG_WITH([maxmem], [ --with-maxmem=FOO Set max memory (KB) for a guest.], [DEFINE_MAXMEM($with_maxmem)],

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213804832 25200 # Node ID 491abbe7867c50c66ce0cd3af41f169bf32dc8fb # Parent 74b34a49b99a5bef18be26c85e1f2c76c09822ca Add domain information store utilities This sets up a very simple XML file in /etc/libvirt/cim that can store some key=value attributes for a domain. The included test is a very simple example and exercise of the code, and should probably be improved a bit before moving on. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 74b34a49b99a -r 491abbe7867c libxkutil/Makefile.am --- a/libxkutil/Makefile.am Mon Jun 16 13:22:22 2008 -0700 +++ b/libxkutil/Makefile.am Wed Jun 18 09:00:32 2008 -0700 @@ -4,14 +4,14 @@ CFLAGS += $(CFLAGS_STRICT) -noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h +noinst_HEADERS = cs_util.h misc_util.h device_parsing.h xmlgen.h infostore.h lib_LTLIBRARIES = libxkutil.la AM_LDFLAGS = -lvirt -luuid libxkutil_la_SOURCES = cs_util_instance.c misc_util.c device_parsing.c \ - xmlgen.c + xmlgen.c infostore.c noinst_PROGRAMS = xml_parse_test diff -r 74b34a49b99a -r 491abbe7867c libxkutil/infostore.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxkutil/infostore.c Wed Jun 18 09:00:32 2008 -0700 @@ -0,0 +1,372 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith <danms@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <inttypes.h> +#include <sys/file.h> + +#include <libvirt/libvirt.h> +#include <libxml/parser.h> +#include <libxml/tree.h> +#include <libxml/xpath.h> +#include <libxml/xmlsave.h> +#include <libxml/tree.h> + +#include <libcmpiutil/libcmpiutil.h> +#include <config.h> + +#include "infostore.h" + +struct infostore_ctx { + xmlDocPtr doc; + xmlNodePtr root; + xmlXPathContextPtr xpathctx; + int fd; +}; + +static void infostore_cleanup_ctx(struct infostore_ctx *ctx) +{ + xmlXPathFreeContext(ctx->xpathctx); + xmlFreeDoc(ctx->doc); + close(ctx->fd); + + free(ctx); +} + +static char *_make_filename(const char *type, const char *name) +{ + int ret; + char *path; + + ret = asprintf(&path, "%s/%s_%s", + INFO_STORE, + type, + name); + if (ret == -1) { + CU_DEBUG("Failed to asprintf() path to info store"); + path = NULL; + } + + return path; +} + +static char *make_filename(virDomainPtr dom) +{ + virConnectPtr conn; + char *path = NULL; + + conn = virDomainGetConnect(dom); + if (conn == NULL) { + CU_DEBUG("Domain has no libvirt connection"); + goto out; + } + + path = _make_filename(virConnectGetType(conn), + virDomainGetName(dom)); + + CU_DEBUG("Path is %s", path); + + out: + return path; +} + +static xmlDocPtr parse_xml(int fd) +{ + xmlParserCtxtPtr ctx = NULL; + xmlDocPtr doc = NULL; + + ctx = xmlNewParserCtxt(); + if (ctx == NULL) + goto err; + + doc = xmlCtxtReadFd(ctx, + fd, + "foo", + NULL, + XML_PARSE_NOWARNING | XML_PARSE_NONET); + if (doc == NULL) + goto err; + + return doc; + err: + xmlFreeDoc(doc); + xmlFreeParserCtxt(ctx); + + return NULL; +} + +static xmlDocPtr new_xml(void) +{ + xmlDocPtr doc = NULL; + xmlNodePtr root = NULL; + + doc = xmlNewDoc(BAD_CAST "1.0"); + if (doc == NULL) { + CU_DEBUG("Failed to create new XML document"); + goto err; + } + + root = xmlNewNode(NULL, BAD_CAST "dominfo"); + if (root == NULL) { + CU_DEBUG("Failed top create new root node"); + goto err; + } + + xmlDocSetRootElement(doc, root); + + return doc; + err: + xmlFreeDoc(doc); + + return NULL; +} + +static bool save_xml(struct infostore_ctx *ctx) +{ + xmlSaveCtxtPtr save = NULL; + long size = 0; + + lseek(ctx->fd, 0, SEEK_SET); + + save = xmlSaveToFd(ctx->fd, NULL, 0); + if (save == NULL) { + CU_DEBUG("Failed to allocate save context"); + goto out; + } + + size = xmlSaveDoc(save, ctx->doc); + + xmlSaveClose(save); + + out: + return size >= 0; +} + +struct infostore_ctx *infostore_open(virDomainPtr dom) +{ + struct infostore_ctx *isc; + struct stat s; + char *filename = NULL; + + isc = calloc(1, sizeof(*isc)); + if (isc == NULL) { + CU_DEBUG("Unable to allocate domain_details struct"); + return NULL; + } + + filename = make_filename(dom); + if (filename == NULL) + goto err; + + isc->fd = open(filename, O_RDWR|O_CREAT, 0600); + if (isc->fd < 0) { + CU_DEBUG("Unable to open `%s': %m", filename); + goto err; + } + + if (flock(isc->fd, LOCK_EX) != 0) { + CU_DEBUG("Failed to lock infostore"); + goto err; + } + + fstat(isc->fd, &s); + if (s.st_size == 0) + isc->doc = new_xml(); + else + isc->doc = parse_xml(isc->fd); + + if (isc->doc == NULL) { + CU_DEBUG("Failed to parse XML"); + goto err; + } + + isc->root = xmlDocGetRootElement(isc->doc); + if (isc->root == NULL) { + CU_DEBUG("Failed to parse XML"); + goto err; + } + + if (!xmlStrEqual(isc->root->name, BAD_CAST "dominfo")) { + CU_DEBUG("XML does not start with <dominfo>"); + goto err; + } + + isc->xpathctx = xmlXPathNewContext(isc->doc); + if (isc->xpathctx == NULL) { + CU_DEBUG("Failed to allocate XPath context"); + goto err; + } + + free(filename); + + return isc; + + err: + infostore_cleanup_ctx(isc); + free(filename); + + return NULL; +} + +void infostore_close(struct infostore_ctx *ctx) +{ + if (ctx == NULL) + return; + + save_xml(ctx); + infostore_cleanup_ctx(ctx); +} + +void infostore_delete(const char *type, const char *name) +{ + char *path = NULL; + + path = _make_filename(type, name); + if (path == NULL) + return; + + unlink(path); + + free(path); +} + +static xmlXPathObjectPtr xpath_query(struct infostore_ctx *ctx, const char *key) +{ + char *path = NULL; + xmlXPathObjectPtr result = NULL; + + if (asprintf(&path, "/dominfo/%s[1]", key) == -1) { + CU_DEBUG("Failed to alloc path string"); + goto out; + } + + result = xmlXPathEval(BAD_CAST path, ctx->xpathctx); + if ((result->type != XPATH_NODESET) || + (xmlXPathNodeSetGetLength(result->nodesetval) < 1)) { + xmlXPathFreeObject(result); + result = NULL; + } + out: + free(path); + + return result; +} + +static char *xpath_query_string(struct infostore_ctx *ctx, const char *key) +{ + xmlXPathObjectPtr result; + char *val = NULL; + + result = xpath_query(ctx, key); + if (result != NULL) + val = (char *)xmlXPathCastToString(result); + + xmlXPathFreeObject(result); + + return val; +} + +static bool xpath_set_string(struct infostore_ctx *ctx, + const char *key, + const char *val) +{ + xmlXPathObjectPtr result = NULL; + xmlNodePtr node = NULL; + + result = xpath_query(ctx, key); + if (result == NULL) { + CU_DEBUG("Creating new node %s=%s", key, val); + node = xmlNewDocNode(ctx->doc, NULL, BAD_CAST key, NULL); + xmlAddChild(ctx->root, node); + } else { + node = result->nodesetval->nodeTab[0]; + } + + if (node == NULL) { + CU_DEBUG("Failed to update node for `%s'", key); + goto out; + } + + xmlNodeSetContent(node, BAD_CAST val); + out: + xmlXPathFreeObject(result); + + return node != NULL; +} + +uint64_t infostore_get_u64(struct infostore_ctx *ctx, const char *key) +{ + char *sval = NULL; + uint64_t val = 0; + + sval = xpath_query_string(ctx, key); + if (sval == NULL) + goto out; + + if (sscanf((const char *)sval, "%" SCNu64, &val) != 1) { + CU_DEBUG("Failed to parse u64 for %s (%s)", key, sval); + goto out; + } + out: + free(sval); + + return val; +} + +bool infostore_set_u64(struct infostore_ctx *ctx, const char *key, uint64_t val) +{ + char *sval = NULL; + + if (asprintf(&sval, "%" PRIu64, val) == -1) { + CU_DEBUG("Failed to format u64 string"); + sval = NULL; + goto out; + } + + xpath_set_string(ctx, key, sval); + out: + free(sval); + + return false; +} + +char *infostore_get_str(struct infostore_ctx *ctx, const char *key) +{ + return xpath_query_string(ctx, key); +} + +bool infostore_set_str(struct infostore_ctx *ctx, + const char *key, const char * val) +{ + return xpath_set_string(ctx, key, val); +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 74b34a49b99a -r 491abbe7867c libxkutil/infostore.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxkutil/infostore.h Wed Jun 18 09:00:32 2008 -0700 @@ -0,0 +1,54 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith <danms@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __INFOSTORE_H +#define __INFOSTORE_H + +#include <stdint.h> +#include <stdbool.h> +#include <libvirt/libvirt.h> + +struct infostore_ctx; + +struct infostore_ctx *infostore_open(virDomainPtr dom); +void infostore_close(struct infostore_ctx *ctx); +void infostore_delete(const char *type, const char *name); + +uint64_t infostore_get_u64(struct infostore_ctx *ctx, const char *key); +bool infostore_set_u64(struct infostore_ctx *ctx, + const char *key, uint64_t val); + +char *infostore_get_str(struct infostore_ctx *ctx, const char *key); +bool infostore_set_str(struct infostore_ctx *ctx, + const char *key, const char * val); + + +#endif + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 74b34a49b99a -r 491abbe7867c libxkutil/tests/Makefile.am --- a/libxkutil/tests/Makefile.am Mon Jun 16 13:22:22 2008 -0700 +++ b/libxkutil/tests/Makefile.am Wed Jun 18 09:00:32 2008 -0700 @@ -1,10 +1,10 @@ # Copyright IBM Corp. 2007 -TESTS = xml_tag.test xml_devices.test xmlgen.test xml_dominfo.test +TESTS = xml_tag.test xml_devices.test xmlgen.test xml_dominfo.test infostore.test CFLAGS += -g %.test: %.c - $(CC) -o $@ $^ $(CFLAGS) -lvirt `xml2-config --libs` + $(CC) -o $@ $^ $(CFLAGS) -lvirt `xml2-config --libs` -L../.libs -lxkutil clean-local: rm -f *.test diff -r 74b34a49b99a -r 491abbe7867c libxkutil/tests/infostore.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libxkutil/tests/infostore.c Wed Jun 18 09:00:32 2008 -0700 @@ -0,0 +1,80 @@ +/* + * Copyright IBM Corp. 2008 + * + * Authors: + * Dan Smith <danms@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdio.h> +#include <inttypes.h> + +#include <libvirt/libvirt.h> + +#include "../infostore.h" + +int main(int argc, char **argv) +{ + struct infostore_ctx *ctx = NULL; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + if (argc != 2) { + printf("Usage: %s <domain>\n", argv[0]); + return 1; + } + + conn = virConnectOpen(NULL); + if (conn == NULL) { + printf("Unable to open connection\n"); + goto out; + } + + dom = virDomainLookupByName(conn, argv[1]); + if (dom == NULL) { + printf("Unable to lookup domain `%s'\n", argv[1]); + goto out; + } + + ctx = infostore_open(dom); + if (ctx == NULL) { + printf("Unable to open infostore for `%s'\n", argv[1]); + goto out; + } + + printf("Foo: %" PRIu64 "\n", infostore_get_u64(ctx, "foo")); + + infostore_set_u64(ctx, "foo", 321); + infostore_set_u64(ctx, "bar", 987); + printf("Should be (null): %s\n", infostore_get_str(ctx, "baz")); + + out: + infostore_close(ctx); + virDomainFree(dom); + virConnectClose(conn); + + return 0; +} + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */

+static char *make_filename(virDomainPtr dom) +{ + virConnectPtr conn; + char *path = NULL; + + conn = virDomainGetConnect(dom); + if (conn == NULL) { + CU_DEBUG("Domain has no libvirt connection"); + goto out; + } + + path = _make_filename(virConnectGetType(conn), + virDomainGetName(dom)); + + CU_DEBUG("Path is %s", path); + + out:
Need to close the connection here.
+ return path; +} + +static xmlDocPtr parse_xml(int fd) +{ + xmlParserCtxtPtr ctx = NULL; + xmlDocPtr doc = NULL; + + ctx = xmlNewParserCtxt(); + if (ctx == NULL) + goto err; + + doc = xmlCtxtReadFd(ctx, + fd, + "foo", + NULL, + XML_PARSE_NOWARNING | XML_PARSE_NONET); + if (doc == NULL) + goto err;
Before returning, the xmlParserCtxtPtr should be freed.
+ + return doc; + err: + xmlFreeDoc(doc); + xmlFreeParserCtxt(ctx); + + return NULL; +} +
+bool infostore_set_u64(struct infostore_ctx *ctx, const char *key, uint64_t val) +{ + char *sval = NULL; + + if (asprintf(&sval, "%" PRIu64, val) == -1) { + CU_DEBUG("Failed to format u64 string"); + sval = NULL; + goto out; + } + + xpath_set_string(ctx, key, sval); + out: + free(sval); + + return false;
Not sure why you only return false here. In every place you've called it, you're not capturing the return, so the value doesn't really matter. However, just curious why it's false. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> Need to close the connection here. No, because I didn't open it, I just grabbed it from the virDomainPtr. KR> Before returning, the xmlParserCtxtPtr should be freed. Yep, thanks. KR> Not sure why you only return false here. In every place you've KR> called it, you're not capturing the return, so the value doesn't KR> really matter. However, just curious why it's false. Because I didn't change it once I implemented that function :P -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213804869 25200 # Node ID 05ee6d4b3049b86ab74d1b8121716e2440769316 # Parent 491abbe7867c50c66ce0cd3af41f169bf32dc8fb Make ProcRASD expose stored scheduler parameters When we're constructing a ProcRASD, open the infostore for the domain and read out the weight and limit attributes so they can be set in the RASD appropriately. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 491abbe7867c -r 05ee6d4b3049 src/Virt_RASD.c --- a/src/Virt_RASD.c Wed Jun 18 09:00:32 2008 -0700 +++ b/src/Virt_RASD.c Wed Jun 18 09:01:09 2008 -0700 @@ -33,6 +33,7 @@ #include "misc_util.h" #include "cs_util.h" +#include "infostore.h" #include "Virt_RASD.h" #include "svpc_types.h" @@ -91,6 +92,54 @@ { /* FIXME: Remove this */ return NULL; +} + +static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, + const CMPIObjectPath *ref, + const char *domain, + CMPIInstance *inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + struct infostore_ctx *info; + uint32_t weight; + uint64_t limit; + + conn = connect_by_classname(broker, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + + dom = virDomainLookupByName(conn, domain); + if (dom == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "Domain `%s' not found while getting info", domain); + goto out; + } + + info = infostore_open(dom); + if (info == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to open domain information store"); + goto out; + } + + weight = (uint32_t)infostore_get_u64(info, "weight"); + limit = infostore_get_u64(info, "limit"); + + CMSetProperty(inst, "Weight", + (CMPIValue *)&weight, CMPI_uint32); + CMSetProperty(inst, "Limit", + (CMPIValue *)&limit, CMPI_uint64); + + out: + virDomainFree(dom); + virConnectClose(conn); + infostore_close(info); + + return s; } static CMPIInstance *rasd_from_vdev(const CMPIBroker *broker, @@ -174,6 +223,7 @@ } else if (dev->type == CIM_RES_TYPE_PROC) { CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&dev->dev.vcpu.quantity, CMPI_uint64); + set_proc_rasd_params(broker, ref, host, inst); } /* FIXME: Put the HostResource in place */

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213805059 25200 # Node ID 5a98830e047c3b61be88c763325ecb9c9bc70370 # Parent 05ee6d4b3049b86ab74d1b8121716e2440769316 Add scheduling information to device_parsing structures Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 05ee6d4b3049 -r 5a98830e047c libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Wed Jun 18 09:01:09 2008 -0700 +++ b/libxkutil/device_parsing.h Wed Jun 18 09:04:19 2008 -0700 @@ -51,6 +51,8 @@ struct vcpu_device { uint64_t quantity; + uint32_t weight; + uint64_t limit; }; struct emu_device {

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213805105 25200 # Node ID cbbf8d96967525ab4dcb5bb67b2458a02c27e772 # Parent 5a98830e047c3b61be88c763325ecb9c9bc70370 Make VSMS record scheduler parameters when changed This includes a new function to synchronize information to the infostore for use during a ModifyResource() or DefineSystem() call. Also, delete the infostore for a domain on DestroySystem() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 5a98830e047c -r cbbf8d969675 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Jun 18 09:04:19 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Wed Jun 18 09:05:05 2008 -0700 @@ -42,6 +42,7 @@ #include <libcmpiutil/std_instance.h> #include "misc_util.h" +#include "infostore.h" #include "Virt_VirtualSystemManagementService.h" #include "Virt_ComputerSystem.h" @@ -471,6 +472,8 @@ struct virt_device *dev) { cu_get_u64_prop(inst, "VirtualQuantity", &dev->dev.vcpu.quantity); + cu_get_u64_prop(inst, "Limit", &dev->dev.vcpu.limit); + cu_get_u32_prop(inst, "Weight", &dev->dev.vcpu.weight); return NULL; } @@ -650,6 +653,54 @@ return inst; } +static CMPIStatus update_dominfo(const struct domain *dominfo, + const char *refcn) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + struct infostore_ctx *ctx = NULL; + struct virt_device *dev = dominfo->dev_vcpu; + virConnectPtr conn = NULL; + virDomainPtr dom = NULL; + + if (dominfo->dev_vcpu_ct != 1) { + /* Right now, we only have extra info for processors */ + CU_DEBUG("Domain has no vcpu devices!"); + return s; + } + + conn = connect_by_classname(_BROKER, refcn, &s); + if (conn == NULL) { + CU_DEBUG("Failed to connnect by %s", refcn); + return s; + } + + dom = virDomainLookupByName(conn, dominfo->name); + if (dom == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "Unable to lookup domain `%s'", dominfo->name); + goto out; + } + + ctx = infostore_open(dom); + if (ctx == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to open infostore"); + goto out; + } + + infostore_set_u64(ctx, "weight", dev->dev.vcpu.weight); + infostore_set_u64(ctx, "limit", dev->dev.vcpu.limit); + out: + infostore_close(ctx); + + virDomainFree(dom); + virConnectClose(conn); + + return s; +} + static CMPIInstance *create_system(CMPIInstance *vssd, CMPIArray *resources, const CMPIObjectPath *ref, @@ -690,6 +741,8 @@ CU_DEBUG("System XML:\n%s", xml); inst = connect_and_create(xml, ref, s); + if (inst != NULL) + update_dominfo(domain, CLASSNAME(ref)); out: cleanup_dominfo(&domain); @@ -780,6 +833,8 @@ rc = IM_RC_SYS_NOT_FOUND; goto error; } + + infostore_delete(virConnectGetType(conn), dom_name); virDomainDestroy(dom); /* Okay for this to fail */ if (virDomainUndefine(dom) == 0) { @@ -961,6 +1016,8 @@ "Virtual System `%s' not found", dominfo->name); goto out; } + + update_dominfo(dominfo, refcn); if (!domain_online(dom)) { CU_DEBUG("VS `%s' not online; skipping dynamic update",

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1213805122 25200 # Node ID 4535290b296e28a832bea92b46b774af79e08ba4 # Parent cbbf8d96967525ab4dcb5bb67b2458a02c27e772 Make ComputerSystem::RequestStateChange() set scheduling parameters at start Currently, only do this for Xen domains. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r cbbf8d969675 -r 4535290b296e src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Jun 18 09:05:05 2008 -0700 +++ b/src/Virt_ComputerSystem.c Wed Jun 18 09:05:22 2008 -0700 @@ -35,6 +35,7 @@ #include "cs_util.h" #include <libcmpiutil/libcmpiutil.h> #include "misc_util.h" +#include "infostore.h" #include "device_parsing.h" #include <libcmpiutil/std_invokemethod.h> #include <libcmpiutil/std_instance.h> @@ -620,6 +621,40 @@ DEFAULT_EQ(); DEFAULT_INST_CLEANUP(); +static void set_scheduler_params(virDomainPtr dom) +{ + struct infostore_ctx *ctx; + virConnectPtr conn = NULL; + virSchedParameter params[] = + {{ "weight", VIR_DOMAIN_SCHED_FIELD_UINT }, + { "cap", VIR_DOMAIN_SCHED_FIELD_UINT }, + }; + + conn = virDomainGetConnect(dom); + if (conn == NULL) { + CU_DEBUG("Unable to get connection from domain"); + return; + } + + if (!STREQC(virConnectGetType(conn), "xen")) { + CU_DEBUG("Not setting sched params for this domain type"); + return; + } + + ctx = infostore_open(dom); + if (ctx == NULL) { + CU_DEBUG("Unable to open infostore for domain"); + return; + } + + params[0].value.ui = infostore_get_u64(ctx, "weight"); + params[1].value.ui = infostore_get_u64(ctx, "limit"); + + virDomainSetSchedulerParameters(dom, params, 2); + + infostore_close(ctx); +} + /* This composite operation may be supported as a flag to reboot */ static int domain_reset(virDomainPtr dom) { @@ -643,6 +678,7 @@ case VIR_DOMAIN_SHUTOFF: CU_DEBUG("Start domain"); ret = virDomainCreate(dom); + set_scheduler_params(dom); break; case VIR_DOMAIN_PAUSED: CU_DEBUG("Unpause domain");
participants (2)
-
Dan Smith
-
Kaitlin Rupert