Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Crash Utility (http://www.linux-archive.org/crash-utility/)
-   -   Allocate the Xen domain vcpu array dynamically (http://www.linux-archive.org/crash-utility/477551-allocate-xen-domain-vcpu-array-dynamically.html)

Petr Tesarik 01-17-2011 10:40 AM

Allocate the Xen domain vcpu array dynamically
 
Each domain can have a different number of max VCPUs in Xen4. Prepare
for this by converting the static array into a dynamic one.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
xen_hyper.c | 11 +++++++++++
xen_hyper_defs.h | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)

--- a/xen_hyper.c
+++ b/xen_hyper.c
@@ -1244,6 +1244,10 @@ xen_hyper_store_domain_context(struct xe
dc->domain_flags = XEN_HYPER_DOMF_ERROR;
}
dc->evtchn = ULONG(dp + XEN_HYPER_OFFSET(domain_evtchn));
+ if (!(dc->vcpu = malloc(sizeof(ulong) * XEN_HYPER_MAX_VIRT_CPUS))) {
+ error(FATAL, "cannot malloc vcpu array (%d VCPUs).",
+ XEN_HYPER_MAX_VIRT_CPUS);
+ }
for (i = 0; i < XEN_HYPER_MAX_VIRT_CPUS; i++) {
dc->vcpu[i] = ULONG(dp + XEN_HYPER_OFFSET(domain_vcpu) +
i*sizeof(void *));
if (dc->vcpu[i]) XEN_HYPER_NR_VCPUS_IN_DOM(dc)++;
@@ -1308,6 +1312,13 @@ xen_hyper_alloc_domain_context_space(int
}
xhdt->context_array_cnt = domains;
} else if (domains > xhdt->context_array_cnt) {
+ struct xen_hyper_domain_context *dc;
+ int i;
+ for (dc = xhdt->context_array, i = 0;
+ i < xhdt->context_array_cnt; ++dc, ++i) {
+ if (dc->vcpu)
+ free(dc->vcpu);
+ }
if (!(xhdt->context_array =
realloc(xhdt->context_array,
domains * sizeof(struct xen_hyper_domain_context)))) {
--- a/xen_hyper_defs.h
+++ b/xen_hyper_defs.h
@@ -463,7 +463,7 @@ struct xen_hyper_domain_context {
ulong domain_flags;
ulong evtchn;
int vcpu_cnt;
- ulong vcpu[XEN_HYPER_MAX_VIRT_CPUS];
+ ulong *vcpu;
struct xen_hyper_vcpu_context_array *vcpu_context_array;
};


--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility


All times are GMT. The time now is 06:51 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.