[PATCH 0 of 2] (#2) Make ProcRASD check running domains for VCPU count

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225207324 25200 # Node ID 819ae6c97a071eb28c56719a8bb29bf584664556 # Parent e043f46f299ec3dd3d1e48e51e57437fa90db136 Add a domain_vcpu_count() function to return the number of active VCPUs for a given domain. Changes: - Fix misplaced free() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r e043f46f299e -r 819ae6c97a07 libxkutil/misc_util.c --- a/libxkutil/misc_util.c Wed Oct 22 08:28:37 2008 -0700 +++ b/libxkutil/misc_util.c Tue Oct 28 08:22:04 2008 -0700 @@ -541,6 +541,45 @@ return result; } +int domain_vcpu_count(virDomainPtr dom) +{ + virVcpuInfoPtr info = NULL; + int max; + int count; + int actual = 0; + int i; + virConnectPtr conn = NULL; + + conn = virDomainGetConnect(dom); + if (conn == NULL) { + CU_DEBUG("Failed to get connection from domain"); + return -1; + } + + max = virConnectGetMaxVcpus(conn, virConnectGetType(conn)); + if (max <= 0) { + CU_DEBUG("Failed to get max vcpu count"); + return -1; + } + + info = calloc(max, sizeof(*info)); + if (info == NULL) { + CU_DEBUG("Failed to allocate %i vcpuinfo structures", max); + return -1; + } + + count = virDomainGetVcpus(dom, info, max, NULL, 0); + + for (i = 0; i < count; i++) { + if (info[i].cpu != -1) + actual++; + } + + free(info); + + return actual; +} + /* * Local Variables: * mode: C diff -r e043f46f299e -r 819ae6c97a07 libxkutil/misc_util.h --- a/libxkutil/misc_util.h Wed Oct 22 08:28:37 2008 -0700 +++ b/libxkutil/misc_util.h Tue Oct 28 08:22:04 2008 -0700 @@ -124,6 +124,8 @@ bool check_refs_pfx_match(const CMPIObjectPath *refa, const CMPIObjectPath *refb); +int domain_vcpu_count(virDomainPtr dom); + #define LIBVIRT_CIM_DEFAULT_MAKEREF() \ static CMPIInstance* make_ref(const CMPIObjectPath *source_ref, \ const CMPIInstance *target_inst, \

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1225207665 25200 # Node ID 2df4433a10600aee5a8ed0aae0c1ded96a3e4d0f # Parent 819ae6c97a071eb28c56719a8bb29bf584664556 Make ProcRASD properly reflect the number of VCPUs a domain currently has, instead of just the number that the libvirt XML definition claims. Since Xen doesn't always honor vcpu add/remove actions, this is required to make sure we're reflecting the state of the system when a domain is running. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 819ae6c97a07 -r 2df4433a1060 src/Virt_RASD.c --- a/src/Virt_RASD.c Tue Oct 28 08:22:04 2008 -0700 +++ b/src/Virt_RASD.c Tue Oct 28 08:27:45 2008 -0700 @@ -96,6 +96,7 @@ static CMPIStatus set_proc_rasd_params(const CMPIBroker *broker, const CMPIObjectPath *ref, + struct virt_device *dev, const char *domain, CMPIInstance *inst) { @@ -105,6 +106,7 @@ struct infostore_ctx *info; uint32_t weight; uint64_t limit; + uint64_t count; conn = connect_by_classname(broker, CLASSNAME(ref), &s); if (conn == NULL) @@ -117,6 +119,17 @@ "Domain `%s' not found while getting info", domain); goto out; } + + if (domain_online(dom)) + count = domain_vcpu_count(dom); + else + count = dev->dev.vcpu.quantity; + + if (count > 0) + CMSetProperty(inst, + "VirtualQuantity", + (CMPIValue *)&count, + CMPI_uint64); info = infostore_open(dom); if (info == NULL) { @@ -306,14 +319,7 @@ CMSetProperty(inst, "Limit", (CMPIValue *)&dev->dev.mem.maxsize, CMPI_uint64); } else if (dev->type == CIM_RES_TYPE_PROC) { - if (dev->dev.vcpu.quantity > 0) { - CMSetProperty(inst, - "VirtualQuantity", - (CMPIValue *)&dev->dev.vcpu.quantity, - CMPI_uint64); - } - - set_proc_rasd_params(broker, ref, host, inst); + set_proc_rasd_params(broker, ref, dev, host, inst); } /* FIXME: Put the HostResource in place */
participants (2)
-
Dan Smith
-
Kaitlin Rupert