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

[Crash-utility] [PATCH] Account for the changed type of the domain.vcpu field in Xen4



The 'vcpu' field changed from a fixed array to a pointer to an array. Change 
xen_hyper_store_domain_context to account for this change.

Signed-off-by: Petr Tesarik <ptesarik suse cz>
---
 xen_hyper.c      |   40 +++++++++++++++++++++++++++++++++++++---
 xen_hyper_defs.h |    1 +
 2 files changed, 38 insertions(+), 3 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_OFFSET_INIT(domain_max_vcpus, "domain", "max_vcpus");
 	XEN_HYPER_MEMBER_OFFSET_INIT(domain_arch, "domain", "arch");
 
 	XEN_HYPER_STRUCT_SIZE_INIT(arch_shared_info, "arch_shared_info");
@@ -1207,6 +1208,8 @@ struct xen_hyper_domain_context *
 xen_hyper_store_domain_context(struct xen_hyper_domain_context *dc,
 	       ulong domain, char *dp)
 {
+	unsigned int max_vcpus;
+	char *vcpup;
 	int i;
 
 	dc->domain = domain;
@@ -1244,9 +1247,40 @@ xen_hyper_store_domain_context(struct xe
 		dc->domain_flags = XEN_HYPER_DOMF_ERROR;
 	}
 	dc->evtchn = ULONG(dp + XEN_HYPER_OFFSET(domain_evtchn));
-	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)++;
+
+	if (XEN_HYPER_VALID_MEMBER(domain_max_vcpus)) {
+		max_vcpus = UINT(dp + XEN_HYPER_OFFSET(domain_max_vcpus));
+	} else {
+		max_vcpus = XEN_HYPER_MAX_VIRT_CPUS;
+	}
+	if (MEMBER_TYPE("domain", "vcpu") == TYPE_CODE_ARRAY)
+		vcpup = dp + XEN_HYPER_OFFSET(domain_vcpu);
+	else {
+		ulong vcpu_array = ULONG(dp + XEN_HYPER_OFFSET(domain_vcpu));
+		if (vcpu_array && max_vcpus) {
+			if (!(vcpup =
+				malloc(max_vcpus * sizeof(void *)))) {
+				error(FATAL, "cannot malloc VCPU array for domain %lx.",
+					domain);
+			}
+			if (!readmem(vcpu_array, KVADDR,
+				vcpup, max_vcpus * sizeof(void*),
+				"VCPU array", RETURN_ON_ERROR)) {
+				error(FATAL, "cannot read VCPU array for domain %lx.",
+					domain);
+			}
+		} else {
+			vcpup = NULL;
+		}
+	}
+	if (vcpup) {
+		for (i = 0; i < max_vcpus; i++) {
+			dc->vcpu[i] = ULONG(vcpup + i*sizeof(void *));
+			if (dc->vcpu[i])	XEN_HYPER_NR_VCPUS_IN_DOM(dc)++;
+		}
+		if (vcpup != dp + XEN_HYPER_OFFSET(domain_vcpu)) {
+			free(vcpup);
+		}
 	}
 
 	return dc;
--- a/xen_hyper_defs.h
+++ b/xen_hyper_defs.h
@@ -674,6 +674,7 @@ struct xen_hyper_offset_table {
 	long domain_is_shutting_down;
 	long domain_is_shut_down;
 	long domain_vcpu;
+	long domain_max_vcpus;
 	long domain_arch;
 #ifdef IA64
 	/* mm_struct */


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