# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275642846 -3600
# Node ID f1faeaf76ddbed68d6cec256e89a1db208323b12
# Parent 51560365c4a4330d218d5b0ad355d08b07196d20
libxl/xl: fix multivcpu handling
Signed-off-by: Stefano Stabellini<stefano.stabellini@xxxxxxxxxxxxx>
---
tools/libxl/libxl.c | 8 ++++++++
tools/libxl/libxl.h | 2 ++
tools/libxl/libxl_dom.c | 10 ++++------
tools/libxl/libxl_internal.h | 4 ++--
tools/libxl/xenguest.c | 18 +++++++++++-------
tools/libxl/xl_cmdimpl.c | 6 +++++-
6 files changed, 32 insertions(+), 16 deletions(-)
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/libxl.c Fri Jun 04 10:14:06 2010 +0100
@@ -874,6 +874,14 @@ static char ** libxl_build_device_model_
}
if (info->apic) {
flexarray_set(dm_args, num++, "-acpi");
+ }
+ if (info->vcpus > 1) {
+ flexarray_set(dm_args, num++, "-vcpus");
+ flexarray_set(dm_args, num++, libxl_sprintf(ctx, "%d",
info->vcpus));
+ }
+ if (info->vcpu_avail) {
+ flexarray_set(dm_args, num++, "-vcpu_avail");
+ flexarray_set(dm_args, num++, libxl_sprintf(ctx, "0x%x",
info->vcpu_avail));
}
for (i = 0; i < num_vifs; i++) {
if (vifs[i].nictype == NICTYPE_IOEMU) {
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/libxl.h Fri Jun 04 10:14:06 2010 +0100
@@ -162,6 +162,8 @@ typedef struct {
bool usb; /* usb support enabled or disabled */
char *usbdevice; /* enable usb mouse: tablet for absolute mouse, mouse for
PS/2 protocol relative mouse */
bool apic; /* apic enabled or disabled */
+ int vcpus; /* max number of vcpus */
+ int vcpu_avail; /* vcpus actually available */
char **extra; /* extra parameters pass directly to qemu, NULL terminated */
/* Network is missing */
} libxl_device_model_info;
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/libxl_dom.c Fri Jun 04 10:14:06 2010 +0100
@@ -100,7 +100,7 @@ int build_post(struct libxl_ctx *ctx, ui
xc_cpuid_apply_policy(ctx->xch, domid);
#endif
- ents = libxl_calloc(ctx, (12 + info->max_vcpus) * 2, sizeof(char *));
+ ents = libxl_calloc(ctx, 12 + (info->max_vcpus * 2) + 2, sizeof(char *));
ents[0] = "memory/static-max";
ents[1] = libxl_sprintf(ctx, "%d", info->max_memkb);
ents[2] = "memory/target";
@@ -115,7 +115,7 @@ int build_post(struct libxl_ctx *ctx, ui
ents[11] = libxl_sprintf(ctx, "%lu", state->store_mfn);
for (i = 0; i < info->max_vcpus; i++) {
ents[12+(i*2)] = libxl_sprintf(ctx, "cpu/%d/availability", i);
- ents[12+(i*2)+1] = (i && info->cur_vcpus && (i >= info->cur_vcpus))
+ ents[12+(i*2)+1] = (i && info->cur_vcpus && !(info->cur_vcpus & (1 <<
i)))
? "offline" : "online";
}
@@ -182,10 +182,8 @@ int build_hvm(struct libxl_ctx *ctx, uin
XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm building failed");
return ERROR_FAIL;
}
- ret = hvm_build_set_params(ctx->xch, domid, info->u.hvm.apic,
info->u.hvm.acpi,
- info->u.hvm.pae, info->u.hvm.nx,
info->u.hvm.viridian,
- info->max_vcpus,
- state->store_port, &state->store_mfn);
+ ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
+ &state->store_mfn);
if (ret) {
XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params failed");
return ERROR_FAIL;
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/libxl_internal.h Fri Jun 04 10:14:06 2010 +0100
@@ -166,8 +166,8 @@ int libxl_device_pci_flr(struct libxl_ct
/* from xenguest (helper */
int hvm_build_set_params(xc_interface *handle, uint32_t domid,
- int apic, int acpi, int pae, int nx, int viridian,
- int vcpus, int store_evtchn, unsigned long
*store_mfn);
+ libxl_domain_build_info *info,
+ int store_evtchn, unsigned long *store_mfn);
/* xl_exec */
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/xenguest.c
--- a/tools/libxl/xenguest.c Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/xenguest.c Fri Jun 04 10:14:06 2010 +0100
@@ -17,10 +17,13 @@
#include <xenguest.h>
#include <sys/mman.h>
#include <xen/hvm/hvm_info_table.h>
+#include <string.h>
+
+#include "libxl.h"
int hvm_build_set_params(xc_interface *handle, uint32_t domid,
- int apic, int acpi, int pae, int nx, int viridian,
- int vcpus, int store_evtchn, unsigned long *store_mfn)
+ libxl_domain_build_info *info,
+ int store_evtchn, unsigned long *store_mfn)
{
struct hvm_info_table *va_hvm;
uint8_t *va_map, sum;
@@ -33,18 +36,19 @@ int hvm_build_set_params(xc_interface *h
return -1;
va_hvm = (struct hvm_info_table *)(va_map + HVM_INFO_OFFSET);
- va_hvm->acpi_enabled = acpi;
- va_hvm->apic_mode = apic;
- va_hvm->nr_vcpus = vcpus;
+ va_hvm->acpi_enabled = info->u.hvm.acpi;
+ va_hvm->apic_mode = info->u.hvm.apic;
+ va_hvm->nr_vcpus = info->max_vcpus;
+ memcpy(va_hvm->vcpu_online, &info->cur_vcpus, sizeof(info->cur_vcpus));
for (i = 0, sum = 0; i < va_hvm->length; i++)
sum += ((uint8_t *) va_hvm)[i];
va_hvm->checksum -= sum;
munmap(va_map, XC_PAGE_SIZE);
xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
- xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, pae);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
#if defined(__i386__) || defined(__x86_64__)
- xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, viridian);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
#endif
xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
return 0;
diff -r 51560365c4a4 -r f1faeaf76ddb tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri Jun 04 10:13:02 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Fri Jun 04 10:14:06 2010 +0100
@@ -205,6 +205,8 @@ static void init_dm_info(libxl_device_mo
dm_info->device_model = "qemu-dm";
dm_info->videoram = b_info->video_memkb / 1024;
dm_info->apic = b_info->u.hvm.apic;
+ dm_info->vcpus = b_info->max_vcpus;
+ dm_info->vcpu_avail = b_info->cur_vcpus;
dm_info->stdvga = 0;
dm_info->vnc = 1;
@@ -469,8 +471,10 @@ static void parse_config_data(const char
init_build_info(b_info, c_info);
/* the following is the actual config parsing with overriding values in
the structures */
- if (!xlu_cfg_get_long (config, "vcpus", &l))
+ if (!xlu_cfg_get_long (config, "vcpus", &l)) {
b_info->max_vcpus = l;
+ b_info->cur_vcpus = (1 << l) - 1;
+ }
if (!xlu_cfg_get_long (config, "memory", &l)) {
b_info->max_memkb = l * 1024;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|