[PATCH 4/7] Allocate the Xen domain vcpu array dynamically

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

 



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@xxxxxxx>

---
 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility


[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux