feat(ha-config-bootstrap): implement --vcpus CLI, wire validation, remove vcpus from config (task 2.2)
- Add --vcpus N argp option in main.c; store in myconf.vcpus - Replace inline argp guard with validate_vcpus() call (returns -EINVAL for <=0) - Add validate_startup_config() in startup_validation.c: returns 0; writes deprecation warning into caller-supplied warn_buf when vcpus key present - Wire validate_startup_config() into myapp_run() after conffile resolved; emit WARN() if warn_buf non-empty (Req 4.4) - Remove vcpus field from cluster_config_t (clusterconfig.h) - Preserve capnp ordinal: vcpus @7 -> vcpusDeprecated @7: Void in controller.capnp - vtaskmgr_init uses only myconf->vcpus with hardcoded default 8 - Add stub C types in typemap.h for capnp schema extensions from task 1.1 - 96 tests pass
This commit is contained in:
parent
bfa41eb135
commit
3ab2e6e4bf
12 changed files with 225 additions and 8 deletions
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
extern int myapp_run(myconf_t*);
|
||||
|
||||
/* forward declaration — implemented in startup_validation.c */
|
||||
int validate_vcpus(int vcpus);
|
||||
|
||||
static char doc[] = "xce_controller";
|
||||
static char args_doc[] = "";
|
||||
const char* argp_program_version
|
||||
|
|
@ -21,6 +24,7 @@ const char* argp_program_bug_address = BUG_EMAIL;
|
|||
#define OPT_PEERS 256
|
||||
#define OPT_CONF_KEEP_N 257
|
||||
#define OPT_CONF_STALE_TIMEOUT 258
|
||||
#define OPT_VCPUS 259
|
||||
|
||||
struct arguments {
|
||||
char* myname;
|
||||
|
|
@ -30,6 +34,7 @@ struct arguments {
|
|||
char* peers_str;
|
||||
int conf_keep_n;
|
||||
long conf_stale_timeout;
|
||||
int vcpus;
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
|
|
@ -44,6 +49,8 @@ static struct argp_option options[] = {
|
|||
"Versioned config files to retain (default: 2)" },
|
||||
{ "conf-stale-timeout", OPT_CONF_STALE_TIMEOUT, "SECS", 0,
|
||||
"Seconds before saved config is flagged stale (0=disabled, default: 86400)" },
|
||||
{ "vcpus", OPT_VCPUS, "N", 0,
|
||||
"Number of virtual CPUs for the task manager (must be >= 1)" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
@ -78,6 +85,11 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
|||
if (arguments->conf_stale_timeout < 0)
|
||||
argp_error(state, "--conf-stale-timeout must be >= 0 (got: %s)", arg);
|
||||
break;
|
||||
case OPT_VCPUS:
|
||||
arguments->vcpus = atoi(arg);
|
||||
if (validate_vcpus(arguments->vcpus) != 0)
|
||||
argp_error(state, "--vcpus must be >= 1 (got: %s)", arg);
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
@ -102,6 +114,7 @@ int main(int argc, char* argv[])
|
|||
memset(&arguments, 0x0, sizeof(arguments));
|
||||
arguments.conf_keep_n = 2;
|
||||
arguments.conf_stale_timeout = 86400;
|
||||
arguments.vcpus = 0; /* 0 = not set; use cluster config default */
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
|
|
@ -142,6 +155,7 @@ int main(int argc, char* argv[])
|
|||
myconf.name = arguments.myname;
|
||||
myconf.conf_keep_n = arguments.conf_keep_n;
|
||||
myconf.conf_stale_timeout = (time_t)arguments.conf_stale_timeout;
|
||||
myconf.vcpus = arguments.vcpus;
|
||||
memset(&myconf.peers_cfg, 0, sizeof(myconf.peers_cfg));
|
||||
|
||||
if (arguments.peers_str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue