mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Xen used to have single, system-wide limits for the number of grant
frames and maptrack frames a guest was allowed to create. Increasing
or decreasing this single limit on the Xen command-line would change
the limit for all guests on the system.
Later, per-domain limits for these values was created. The system-wide
limits became strict limits: domains could not be created with higher
limits, but could be created with lower limits. However, that change
also introduced a range of different "default" values into various
places in the toolstack:
- The python libxc bindings hard-coded these values to 32 and 1024,
respectively
- The libxl default values are 32 and 1024 respectively.
- xl will use the libxl default for maptrack, but does its own default
calculation for grant frames: either 32 or 64, based on the max
possible mfn.
These defaults interact poorly with the hypervisor command-line limit:
- The hypervisor command-line limit cannot be used to raise the limit
for all guests anymore, as the default in the toolstack will
effectively override this.
- If you use the hypervisor command-line limit to *reduce* the limit,
then the "default" values generated by the toolstack are too high,
and all guest creations will fail.
In other words, the toolstack defaults require any change to be
effected by having the admin explicitly specify a new value in every
guest.
In order to address this, have grant_table_init treat negative values
for max_grant_frames and max_maptrack_frames as instructions to use the
system-wide default, and have all the above toolstacks default to passing
-1 unless a different value is explicitly configured.
This restores the old behavior in that changing the hypervisor command-line
option can change the behavior for all guests, while retaining the ability
to set per-guest values. It also removes the bug that reducing the
system-wide max will cause all domains without explicit limits to fail.
NOTE: - The Ocaml bindings require the caller to always specify a value,
and the code to start a xenstored stubdomain hard-codes these to 4
and 128 respectively; this behavour will not be modified.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
137 lines
4.7 KiB
C
137 lines
4.7 KiB
C
/*
|
|
* Copyright (C) 2010 Citrix Ltd.
|
|
* Author Ian Jackson <ian.jackson@eu.citrix.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published
|
|
* by the Free Software Foundation; version 2.1 only. with the special
|
|
* exception on linking described in file LICENSE.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*/
|
|
|
|
#ifndef LIBXLUTIL_H
|
|
#define LIBXLUTIL_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "libxl.h"
|
|
|
|
enum XLU_ConfigValueType {
|
|
XLU_STRING,
|
|
XLU_LIST,
|
|
};
|
|
|
|
enum XLU_Operation {
|
|
XLU_OP_ASSIGNMENT = 0,
|
|
XLU_OP_ADDITION,
|
|
};
|
|
|
|
/* Unless otherwise stated, all functions return an errno value. */
|
|
typedef struct XLU_Config XLU_Config;
|
|
typedef struct XLU_ConfigList XLU_ConfigList;
|
|
typedef struct XLU_ConfigValue XLU_ConfigValue;
|
|
|
|
XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
|
|
/* 0 means we got ENOMEM. */
|
|
/* report_filename is copied; report is saved and must remain valid
|
|
* until the Config is destroyed. */
|
|
|
|
int xlu_cfg_readfile(XLU_Config*, const char *real_filename);
|
|
int xlu_cfg_readdata(XLU_Config*, const char *data, int length);
|
|
/* If these fail, then it is undefined behaviour to call xlu_cfg_get_...
|
|
* functions. You have to just xlu_cfg_destroy. */
|
|
|
|
void xlu_cfg_destroy(XLU_Config*);
|
|
|
|
|
|
/* All of the following print warnings to "report" if there is a problem.
|
|
* Return values are:
|
|
* 0 OK
|
|
* ESRCH not defined
|
|
* EINVAL value found but wrong format for request (prints warning unless dont_warn=true)
|
|
* ERANGE value out of range (from strtol)
|
|
*/
|
|
|
|
int xlu_cfg_get_string(const XLU_Config*, const char *n, const char **value_r,
|
|
int dont_warn);
|
|
/* free/strdup version */
|
|
int xlu_cfg_replace_string(const XLU_Config *cfg, const char *n,
|
|
char **value_r, int dont_warn);
|
|
int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r,
|
|
int dont_warn);
|
|
int xlu_cfg_get_bounded_long(const XLU_Config*, const char *n, long min,
|
|
long max, long *value_r, int dont_warn);
|
|
int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b,
|
|
int dont_warn);
|
|
|
|
int xlu_cfg_get_list(const XLU_Config*, const char *n,
|
|
XLU_ConfigList **list_r /* may be 0 */,
|
|
int *entries_r /* may be 0 */,
|
|
int dont_warn);
|
|
/* there is no need to free *list_r; lifetime is that of the XLU_Config */
|
|
int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n,
|
|
libxl_string_list *sl, int dont_warn);
|
|
const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry);
|
|
/* xlu_cfg_get_listitem cannot fail, except that if entry is
|
|
* out of range it returns 0 (not setting errno) */
|
|
|
|
enum XLU_ConfigValueType xlu_cfg_value_type(const XLU_ConfigValue *value);
|
|
int xlu_cfg_value_get_string(const XLU_Config *cfg, XLU_ConfigValue *value,
|
|
char **value_r, int dont_warn);
|
|
int xlu_cfg_value_get_list(const XLU_Config *cfg, XLU_ConfigValue *value,
|
|
XLU_ConfigList **value_r, int dont_warn);
|
|
XLU_ConfigValue *xlu_cfg_get_listitem2(const XLU_ConfigList *list,
|
|
int entry);
|
|
|
|
/*
|
|
* Disk specification parsing.
|
|
*/
|
|
|
|
int xlu_disk_parse(XLU_Config *cfg, int nspecs, const char *const *specs,
|
|
libxl_device_disk *disk);
|
|
/* disk must have been initialised.
|
|
*
|
|
* On error, returns errno value. Bad strings cause EINVAL and
|
|
* print a message to cfg's report (that's all cfg is used for).
|
|
*
|
|
* Normally one would pass nspecs==1 and only specs[0]. But it is
|
|
* permitted to pass more strings in which case each is parsed as a
|
|
* string containing a collection of parameters (but they all refer
|
|
* to of the configuration for a single disk).
|
|
*
|
|
* nspecs==0 is permitted but since it does not specify some mandatory
|
|
* properties, it produces a run-time configuration error if the
|
|
* resulting disk struct is used with libxl.
|
|
*/
|
|
|
|
/*
|
|
* PCI specification parsing
|
|
*/
|
|
int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci *pcidev, const char *str);
|
|
|
|
/*
|
|
* RDM parsing
|
|
*/
|
|
int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str);
|
|
|
|
/*
|
|
* Vif rate parsing.
|
|
*/
|
|
|
|
int xlu_vif_parse_rate(XLU_Config *cfg, const char *rate,
|
|
libxl_device_nic *nic);
|
|
|
|
#endif /* LIBXLUTIL_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* mode: C
|
|
* c-basic-offset: 4
|
|
* indent-tabs-mode: nil
|
|
* End:
|
|
*/
|