Hi, I set the information of cpu_weight/cpu_cap to configuration file or sxp format, and execute "virsh start". But the information of weight/cap is lost. libvirt doesn't support cpu_weight and cpu_cap for XML format. see also Bz#337591 https://bugzilla.redhat.com/show_bug.cgi?id=337591 I make a patch to add weight/cap attributes as vcpus element (eg. <vcpus weight='512' cap='280'>4</vcpus>) c.f. the thread at: https://www.redhat.com/archives/libvir-list/2007-October/msg00044.html Signed-off-by: Tatsuro Enokura <fj7716hz@xxxxxxxxxxxxxxxxx> Thanks, Tatsuro Enokura
Index: libvirt/src/xend_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.c,v retrieving revision 1.151 diff -u -p -r1.151 xend_internal.c --- libvirt/src/xend_internal.c 22 Oct 2007 20:28:55 -0000 1.151 +++ libvirt/src/xend_internal.c 24 Oct 2007 06:02:27 -0000 @@ -1438,8 +1438,19 @@ xend_parse_sexp_desc(virConnectPtr conn, if ((cur_mem >= MIN_XEN_GUEST_SIZE) && (cur_mem != max_mem)) virBufferVSprintf(&buf, " <currentMemory>%d</currentMemory>\n", cur_mem); - virBufferVSprintf(&buf, " <vcpu>%d</vcpu>\n", + virBufferVSprintf(&buf, " <vcpu"); + if (sexpr_node(root, "domain/cpu_weight") != NULL) { + virBufferVSprintf(&buf, " weight='%d'", + sexpr_int(root, "domain/cpu_weight")); + } + if (sexpr_node(root, "domain/cpu_cap") != NULL) { + virBufferVSprintf(&buf, " cap='%d'", + sexpr_int(root, "domain/cpu_cap")); + } + virBufferVSprintf(&buf, ">%d</vcpu>\n", sexpr_int(root, "domain/vcpus")); + + tmp = sexpr_node(root, "domain/on_poweroff"); if (tmp != NULL) virBufferVSprintf(&buf, " <on_poweroff>%s</on_poweroff>\n", tmp); Index: libvirt/src/xm_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xm_internal.c,v retrieving revision 1.41 diff -u -p -r1.41 xm_internal.c --- libvirt/src/xm_internal.c 10 Oct 2007 17:55:38 -0000 1.41 +++ libvirt/src/xm_internal.c 24 Oct 2007 06:02:28 -0000 @@ -661,9 +661,14 @@ char *xenXMDomainFormatXML(virConnectPtr virBufferVSprintf(buf, " <memory>%ld</memory>\n", val * 1024); + virBufferVSprintf(buf, " <vcpu"); + if (xenXMConfigGetInt(conf, "cpu_weight", &val) == 0) + virBufferVSprintf(buf, " weight='%ld'", val); + if (xenXMConfigGetInt(conf, "cpu_cap", &val) == 0) + virBufferVSprintf(buf, " cap='%ld'", val); if (xenXMConfigGetInt(conf, "vcpus", &val) < 0) val = 1; - virBufferVSprintf(buf, " <vcpu>%ld</vcpu>\n", val); + virBufferVSprintf(buf, ">%ld</vcpu>\n", val); if (xenXMConfigGetString(conf, "on_poweroff", &str) < 0) @@ -1820,6 +1825,12 @@ virConfPtr xenXMParseXMLToConfig(virConn if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "vcpus", "string(/domain/vcpu)", 0, 1, "cannot set vcpus config parameter") < 0) goto error; + if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "cpu_weight", "string(/domain/vcpu/@weight)", 0, 1, + "cannot set cpu_weight config paramerter") < 0) + goto error; + if (xenXMConfigSetIntFromXPath(conn, conf, ctxt, "cpu_cap", "string(/domain/vcpu/@cap)", 0, 1, + "cannot set cpu_cap config paramerter") < 0) + goto error; obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt); if ((obj != NULL) && (obj->type == XPATH_STRING) && Index: libvirt/src/xml.c =================================================================== RCS file: /data/cvs/libvirt/src/xml.c,v retrieving revision 1.94 diff -u -p -r1.94 xml.c --- libvirt/src/xml.c 23 Oct 2007 15:31:33 -0000 1.94 +++ libvirt/src/xml.c 24 Oct 2007 06:02:28 -0000 @@ -1529,6 +1529,12 @@ virDomainParseXMLDesc(virConnectPtr conn vcpus = (unsigned int) f; } virBufferVSprintf(&buf, "(vcpus %u)", vcpus); + if (virXPathNumber("number(/domain/vcpu[1]/@weight)", ctxt, &f) == 0) { + virBufferVSprintf(&buf, "(cpu_weight %ld)", (long) f); + } + if (virXPathNumber("number(/domain/vcpu[1]/@cap)", ctxt, &f) == 0) { + virBufferVSprintf(&buf, "(cpu_cap %ld)", (long) f); + } str = virXPathString("string(/domain/vcpu/@cpuset)", ctxt); if (str != NULL) {
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list