Here's where I ran out of time for the day. I'm much less familiar
with xen than with qemu, so I have no idea how to tell if xen's
documented domain/vcpu_avail (which is what we want for current vcpus)
is usable in contrast to domain/vcpus (the maximum amount). For that
matter, I'm not even sure if modifying the Sxpr parsing/generating
code is enough to make xen use the new attribute, or what else might
be involved. Hints on what I need to do from here are greatly
appreciated.
---
src/xen/xend_internal.c | 6 ++++++
src/xen/xm_internal.c | 6 ++++++
src/xenapi/xenapi_utils.c | 2 +-
3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 16140d1..9f1c741 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2189,6 +2189,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
}
def->maxvcpus = sexpr_int(root, "domain/vcpus");
+// def->vcpus = sexpr_int(root, "domain/vcpu_avail");
def->vcpus = def->maxvcpus;
tmp = sexpr_node(root, "domain/on_poweroff");
@@ -2462,6 +2463,7 @@ sexpr_to_xend_domain_info(virDomainPtr domain, const struct sexpr
*root,
info->state = VIR_DOMAIN_NOSTATE;
}
info->cpuTime = sexpr_float(root, "domain/cpu_time") * 1000000000;
+// info->nrVirtCpu = sexpr_int(root, "domain/vcpu_avail");
info->nrVirtCpu = sexpr_int(root, "domain/vcpus");
return (0);
}
@@ -5662,6 +5664,8 @@ xenDaemonFormatSxpr(virConnectPtr conn,
virBufferVSprintf(&buf, "(name '%s')", def->name);
virBufferVSprintf(&buf, "(memory %lu)(maxmem %lu)",
def->memory/1024, def->maxmem/1024);
+// virBufferVSprintf(&buf, "(vcpus %u)(vcpu_avail %u)",
def->maxvcpus,
+// def->vcpus);
virBufferVSprintf(&buf, "(vcpus %u)", def->maxvcpus);
if (def->cpumask) {
@@ -5757,6 +5761,8 @@ xenDaemonFormatSxpr(virConnectPtr conn,
else
virBufferVSprintf(&buf, "(kernel '%s')",
def->os.loader);
+// virBufferVSprintf(&buf, "(vcpus %u)(vcpu_avail %u)",
+// def->maxvcpus, def->vcpus);
virBufferVSprintf(&buf, "(vcpus %u)", def->maxvcpus);
for (i = 0 ; i < def->os.nBootDevs ; i++) {
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index e658c19..dd768e1 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -773,6 +773,10 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
(unsigned short) count != count)
goto cleanup;
def->maxvcpus = count;
+// if (xenXMConfigGetULong(conf, "vcpu_avail", &count, 1) < 0 ||
+// (unsigned short) count != count)
+// goto cleanup;
+// def->vcpus = count;
def->vcpus = def->maxvcpus;
if (xenXMConfigGetString(conf, "cpus", &str, NULL) < 0)
@@ -2244,6 +2248,8 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
if (xenXMConfigSetInt(conf, "vcpus", def->maxvcpus) < 0)
goto no_memory;
+// if (xenXMConfigSetInt(conf, "vcpu_avail", def->vcpus) < 0)
+// goto no_memory;
if ((def->cpumask != NULL) &&
((cpus = virDomainCpuSetFormat(def->cpumask,
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 423f83a..5bf9138 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -512,7 +512,7 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
if (def->maxvcpus) {
(*record)->vcpus_max = (int64_t) def->maxvcpus;
- (*record)->vcpus_at_startup = (int64_t) def->vcpus;
+ (*record)->vcpus_at_startup = (int64_t) def->maxvcpus; // FIXME
}
if (def->onPoweroff)
(*record)->actions_after_shutdown =
actionShutdownLibvirt2XenapiEnum(def->onPoweroff);
--
1.7.2.3