libxl/xl: fix multivcpu handling

Signed-off-by: Stefano Stabellini<stefano.stabellini@eu.citrix.com>
This commit is contained in:
Keir Fraser committed 2010-06-04 10:14:06 +01:00
1 parent 88d60e45ef
commit ca896d0ca6
6 files changed
+32 -16

No files matched your search

+8
View File
@@ -875,6 +875,14 @@ static char ** libxl_build_device_model_args(struct libxl_ctx *ctx,
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) {
char *smac = libxl_sprintf(ctx, "%02x:%02x:%02x:%02x:%02x:%02x",
+2
View File
@@ -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;
+4 -6
View File
@@ -100,7 +100,7 @@ int build_post(struct libxl_ctx *ctx, uint32_t domid,
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, uint32_t domid,
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, uint32_t domid,
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;
+2 -2
View File
@@ -166,8 +166,8 @@ int libxl_device_pci_flr(struct libxl_ctx *ctx, unsigned int domain, unsigned in
/* 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 */
+11 -7
View File
@@ -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 *handle, uint32_t domid,
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;
+5 -1
View File
@@ -205,6 +205,8 @@ static void init_dm_info(libxl_device_model_info *dm_info,
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 *configfile_filename_report,
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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.