/* join_worker_args.c -- xce-test-cli-ux task 2.6 remediation (bug-1557 fix) * * See join_worker_args.h for the full extraction rationale. Verbatim * extraction of test.c's cmd_join_worker() parsing/defaulting block -- no * behavior change from the pre-extraction version. */ #include "join_worker_args.h" #include #include #include #include /* getopt, optarg, optind */ int join_worker_parse_attrs(int argc, char* argv[], hostattrs_t* attrs) { int opt; if (attrs == NULL) { return -EINVAL; } /* bug-1557: maxmem is bytes-canonical (see resources.yaml, hardware_ * monitor.c's total_memory) -- this default used to read plain "64" * back when maxmem was MB-scale (64 MB); an earlier session converted * the codebase's canonical unit to bytes but missed this test-tool * default, leaving it at a nonsensical 64 BYTES. Expressed here as * 64 * 1024 * 1024 (64MB in bytes) to preserve the original intent, * matching this file's own byte-constant convention (see test.c's * main() `logsize = 64 * 1024 * 1024`). */ attrs->cpufactor = 1.0; attrs->maxcpus = 4; attrs->maxmem = 64 * 1024 * 1024; attrs->maxswap = 1024; attrs->maxtmp = 2048; attrs->ndisks = 1; attrs->hostmodel = "Intel64"; attrs->hosttype = "LINUX64"; optind = 1; while ((opt = getopt(argc, argv, "f:c:m:s:t:d:")) != -1) { switch (opt) { case 'f': attrs->cpufactor = atof(optarg); break; case 'c': attrs->maxcpus = atoi(optarg); break; case 'm': attrs->maxmem = atoi(optarg); break; case 's': attrs->maxswap = atoi(optarg); break; case 't': attrs->maxtmp = atoi(optarg); break; case 'd': attrs->ndisks = atoi(optarg); break; default: printf(" join [-f cpufactor] [-c maxcpus] [-m maxmem] [-s maxswap] " "[-t maxtmp] [-d ndisks]\n"); return -EINVAL; } } return 0; }