[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Crash-utility] [PATCH 5/7] Use the size of the Xen domain VCPU array if available



If the size of the vcpu array in struct domain is known, use it
to size the dynamically allocated vcpu array in crash. This enables
crash to initialize domains with a different number of VCPUs than
specified by the XEN_HYPER_MAX_VIRT_CPUS macro.

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

---
 xen_hyper.c      |   15 +++++++++++----
 xen_hyper_defs.h |    1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

--- a/xen_hyper.c
+++ b/xen_hyper.c
@@ -219,6 +219,7 @@ xen_hyper_domain_init(void)
 	XEN_HYPER_MEMBER_OFFSET_INIT(domain_is_shutting_down, "domain", 
"is_shutting_down");
 	XEN_HYPER_MEMBER_OFFSET_INIT(domain_is_shut_down, "domain", 
"is_shut_down");
 	XEN_HYPER_MEMBER_OFFSET_INIT(domain_vcpu, "domain", "vcpu");
+	XEN_HYPER_MEMBER_SIZE_INIT(domain_vcpu, "domain", "vcpu");
 	XEN_HYPER_MEMBER_OFFSET_INIT(domain_arch, "domain", "arch");
 
 	XEN_HYPER_STRUCT_SIZE_INIT(arch_shared_info, "arch_shared_info");
@@ -1207,7 +1208,8 @@ struct xen_hyper_domain_context *
 xen_hyper_store_domain_context(struct xen_hyper_domain_context *dc,
 	       ulong domain, char *dp)
 {
-	int i;
+	unsigned int max_vcpus;
+	unsigned int i;
 
 	dc->domain = domain;
 	BCOPY((char *)(dp + XEN_HYPER_OFFSET(domain_domain_id)),
@@ -1244,11 +1246,16 @@ 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))) {
+	if (XEN_HYPER_VALID_SIZE(domain_vcpu)) {
+		max_vcpus = XEN_HYPER_SIZE(domain_vcpu) / sizeof(void *);
+	} else {
+		max_vcpus = XEN_HYPER_MAX_VIRT_CPUS;
+	}
+	if (!(dc->vcpu = malloc(sizeof(ulong) * max_vcpus))) {
 		error(FATAL, "cannot malloc vcpu array (%d VCPUs).",
-		      XEN_HYPER_MAX_VIRT_CPUS);
+		      max_vcpus);
 	}
-	for (i = 0; i < XEN_HYPER_MAX_VIRT_CPUS; i++) {
+	for (i = 0; i < max_vcpus; 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)++;
 	}
--- a/xen_hyper_defs.h
+++ b/xen_hyper_defs.h
@@ -583,6 +583,7 @@ struct xen_hyper_size_table {
 	long crash_xen_core_t;			/* elf note v3,v4 */
 	long crash_xen_info_t;			/* elf note v3,v4 */
 	long domain;
+	long domain_vcpu;
 #ifdef IA64
 	long mm_struct;
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]