From nobody Mon Apr 15 14:05:35 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VJ88J0gR2z5Gfjx; Mon, 15 Apr 2024 14:05:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJ88H5Xw4z4WRT; Mon, 15 Apr 2024 14:05:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713189935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yNtm4apWSn4DwdDGmJdMjwCIFP7dHIPvUZFmxzzMu6k=; b=xUUoHH275wbLcdL2XHIfjaxiQ5+rLXCtaRJeRTLMXj6vIzpFHZWM5p6Ht8IemANYcS/QUz uzm/I5xP0s6tyVc7iGxLEAZJ0smzuCT7qH1gp+YUGH5rvHfL9mjyQoADTYd/bIWfRKIPIz mnSP+VsCNGn36BWkLdOn/PqEvKGWxVXRm90PkKZvVqA0ytMyVrMNI0Qb3JcRLV49mwsjhl Dz8xbX0uxS8V4yLK12jEloIzPZB7nCHPL6dNe1I+4dJst19VqjCwww+dZNvf41k7yoMix7 ueoeEiRB+Taq5/rNQc6qS8MzsJItD5b/lWpL01a9G/QtbCeucmfDsIkltSrG7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713189935; a=rsa-sha256; cv=none; b=O4shBYzEQVA2++tzijkCBQ+ppkisTG/5felHyMfZ6OmFv1jCw3MgfuwXysDp6WJV7aBuM6 jLJO/ui1fN2pRUBVQDMrT9srjOzSlZTU0bZa6oiIo9HdGMDuUrOP5kz0LlmxrnXCEWoiTQ SAwSxnjwuyy41XAaB34zSsWAgs/B6zjVxq2U4FPzG989t4v0GEzakUwjfUuM4y3l2EvFQd BrCkGdtGqK62BoL5szy6pG3QoY0OPBCBT2hcOOn/ty7NAVLsGL2rUfjgiZcBPK5smrudkh nmdxJOPfhzdIIfvx+7UemHGXhWedxoehGcHf8fA6upCow+QVE42nIocnhxGKCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713189935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yNtm4apWSn4DwdDGmJdMjwCIFP7dHIPvUZFmxzzMu6k=; b=mIRCnrc9t7a85WuDMql+vxCknGjs6nmRlQQCy3bpPS0amFIczMGQ6E02tOU+2/OABh2qzp SzxRBzBq3yfV/rmTFMHxuFvNfSsmFiPk+HElfi49hPSNmVn2kNWSipZ+pStuGDk+wY4L5E Y+AhJ+03MeUP3yoabrs9ciKYRcA4O92M3q3wxQj7z70lZ/psV8+RQQhxkQRoMSvkOhaTak 4uA4Acr9uI+YAJ76feUQTauYFnwszkkNhb1P41No+kglcN+T4zPZgGPIN5lvlbkoemOZGc eUvc5XRRxjFahAJBjk8lD8ja0waVpvvGA35moFUQdDAuOJVsT7rRNZc5GKAzGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VJ88H55fxz12sW; Mon, 15 Apr 2024 14:05:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43FE5ZxP070205; Mon, 15 Apr 2024 14:05:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43FE5Z6u070202; Mon, 15 Apr 2024 14:05:35 GMT (envelope-from git) Date: Mon, 15 Apr 2024 14:05:35 GMT Message-Id: <202404151405.43FE5Z6u070202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: a65d02d1d772 - stable/14 - bhyvectl: generate usage from options table List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a65d02d1d77275c2c91db07a7f031986251118ae Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a65d02d1d77275c2c91db07a7f031986251118ae commit a65d02d1d77275c2c91db07a7f031986251118ae Author: Rob Norris AuthorDate: 2024-04-08 13:07:32 +0000 Commit: Mark Johnston CommitDate: 2024-04-15 14:05:13 +0000 bhyvectl: generate usage from options table The usage text had fallen out of sync with the actually available options. Rather than keep them in sync by hand, just generate usage from the available options. Signed-off-by: Rob Norris Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44641 (cherry picked from commit b9fa1500cb2265b95927e19b9d2119ca26d65be3) --- usr.sbin/bhyvectl/bhyvectl.c | 245 +++++++++++-------------------------------- 1 file changed, 63 insertions(+), 182 deletions(-) diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c index 843e7a7b9dd5..050d72f013df 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -72,184 +72,6 @@ static const char *progname; -static void -usage(bool cpu_intel) -{ - - (void)fprintf(stderr, - "Usage: %s --vm=\n" - " [--cpu=]\n" - " [--create]\n" - " [--destroy]\n" -#ifdef BHYVE_SNAPSHOT - " [--checkpoint= | --suspend=]\n" -#endif - " [--get-all]\n" - " [--get-stats]\n" - " [--set-desc-ds]\n" - " [--get-desc-ds]\n" - " [--set-desc-es]\n" - " [--get-desc-es]\n" - " [--set-desc-gs]\n" - " [--get-desc-gs]\n" - " [--set-desc-fs]\n" - " [--get-desc-fs]\n" - " [--set-desc-cs]\n" - " [--get-desc-cs]\n" - " [--set-desc-ss]\n" - " [--get-desc-ss]\n" - " [--set-desc-tr]\n" - " [--get-desc-tr]\n" - " [--set-desc-ldtr]\n" - " [--get-desc-ldtr]\n" - " [--set-desc-gdtr]\n" - " [--get-desc-gdtr]\n" - " [--set-desc-idtr]\n" - " [--get-desc-idtr]\n" - " [--run]\n" - " [--capname=]\n" - " [--getcap]\n" - " [--setcap=<0|1>]\n" - " [--desc-base=]\n" - " [--desc-limit=]\n" - " [--desc-access=]\n" - " [--set-cr0=]\n" - " [--get-cr0]\n" - " [--set-cr2=]\n" - " [--get-cr2]\n" - " [--set-cr3=]\n" - " [--get-cr3]\n" - " [--set-cr4=]\n" - " [--get-cr4]\n" - " [--set-dr0=]\n" - " [--get-dr0]\n" - " [--set-dr1=]\n" - " [--get-dr1]\n" - " [--set-dr2=]\n" - " [--get-dr2]\n" - " [--set-dr3=]\n" - " [--get-dr3]\n" - " [--set-dr6=]\n" - " [--get-dr6]\n" - " [--set-dr7=]\n" - " [--get-dr7]\n" - " [--set-rsp=]\n" - " [--get-rsp]\n" - " [--set-rip=]\n" - " [--get-rip]\n" - " [--get-rax]\n" - " [--set-rax=]\n" - " [--get-rbx]\n" - " [--get-rcx]\n" - " [--get-rdx]\n" - " [--get-rsi]\n" - " [--get-rdi]\n" - " [--get-rbp]\n" - " [--get-r8]\n" - " [--get-r9]\n" - " [--get-r10]\n" - " [--get-r11]\n" - " [--get-r12]\n" - " [--get-r13]\n" - " [--get-r14]\n" - " [--get-r15]\n" - " [--set-rflags=]\n" - " [--get-rflags]\n" - " [--set-cs]\n" - " [--get-cs]\n" - " [--set-ds]\n" - " [--get-ds]\n" - " [--set-es]\n" - " [--get-es]\n" - " [--set-fs]\n" - " [--get-fs]\n" - " [--set-gs]\n" - " [--get-gs]\n" - " [--set-ss]\n" - " [--get-ss]\n" - " [--get-tr]\n" - " [--get-ldtr]\n" - " [--set-x2apic-state=]\n" - " [--get-x2apic-state]\n" - " [--unassign-pptdev=]\n" - " [--set-mem=]\n" - " [--get-lowmem]\n" - " [--get-highmem]\n" - " [--get-gpa-pmap]\n" - " [--assert-lapic-lvt=]\n" - " [--inject-nmi]\n" - " [--force-reset]\n" - " [--force-poweroff]\n" - " [--get-rtc-time]\n" - " [--set-rtc-time=]\n" - " [--get-rtc-nvram]\n" - " [--set-rtc-nvram=]\n" - " [--rtc-nvram-offset=]\n" - " [--get-active-cpus]\n" - " [--get-debug-cpus]\n" - " [--get-suspended-cpus]\n" - " [--get-intinfo]\n" - " [--get-eptp]\n" - " [--set-exception-bitmap]\n" - " [--get-exception-bitmap]\n" - " [--get-tsc-offset]\n" - " [--get-guest-pat]\n" - " [--get-io-bitmap-address]\n" - " [--get-msr-bitmap]\n" - " [--get-msr-bitmap-address]\n" - " [--get-guest-sysenter]\n" - " [--get-exit-reason]\n" - " [--get-cpu-topology]\n", - progname); - - if (cpu_intel) { - (void)fprintf(stderr, - " [--get-vmcs-pinbased-ctls]\n" - " [--get-vmcs-procbased-ctls]\n" - " [--get-vmcs-procbased-ctls2]\n" - " [--get-vmcs-entry-interruption-info]\n" - " [--set-vmcs-entry-interruption-info=]\n" - " [--get-vmcs-guest-physical-address\n" - " [--get-vmcs-guest-linear-address\n" - " [--get-vmcs-host-pat]\n" - " [--get-vmcs-host-cr0]\n" - " [--get-vmcs-host-cr3]\n" - " [--get-vmcs-host-cr4]\n" - " [--get-vmcs-host-rip]\n" - " [--get-vmcs-host-rsp]\n" - " [--get-vmcs-cr0-mask]\n" - " [--get-vmcs-cr0-shadow]\n" - " [--get-vmcs-cr4-mask]\n" - " [--get-vmcs-cr4-shadow]\n" - " [--get-vmcs-cr3-targets]\n" - " [--get-vmcs-apic-access-address]\n" - " [--get-vmcs-virtual-apic-address]\n" - " [--get-vmcs-tpr-threshold]\n" - " [--get-vmcs-vpid]\n" - " [--get-vmcs-instruction-error]\n" - " [--get-vmcs-exit-ctls]\n" - " [--get-vmcs-entry-ctls]\n" - " [--get-vmcs-link]\n" - " [--get-vmcs-exit-qualification]\n" - " [--get-vmcs-exit-interruption-info]\n" - " [--get-vmcs-exit-interruption-error]\n" - " [--get-vmcs-interruptibility]\n" - ); - } else { - (void)fprintf(stderr, - " [--get-vmcb-intercepts]\n" - " [--get-vmcb-asid]\n" - " [--get-vmcb-exit-details]\n" - " [--get-vmcb-tlb-ctrl]\n" - " [--get-vmcb-virq]\n" - " [--get-avic-apic-bar]\n" - " [--get-avic-backing-page]\n" - " [--get-avic-table]\n" - ); - } - exit(1); -} - static int get_rtc_time, set_rtc_time; static int get_rtc_nvram, set_rtc_nvram; static int rtc_nvram_offset; @@ -1567,6 +1389,65 @@ setup_options(bool cpu_intel) return (all_opts); } +static void +usage(const struct option *opts) +{ + static const char *set_desc[] = { + [VCPU] = "vcpu_number", + [SET_MEM] = "memory in units of MB", + [SET_EFER] = "EFER", + [SET_CR0] = "CR0", + [SET_CR2] = "CR2", + [SET_CR3] = "CR3", + [SET_CR4] = "CR4", + [SET_DR0] = "DR0", + [SET_DR1] = "DR1", + [SET_DR2] = "DR2", + [SET_DR3] = "DR3", + [SET_DR6] = "DR6", + [SET_DR7] = "DR7", + [SET_RSP] = "RSP", + [SET_RIP] = "RIP", + [SET_RAX] = "RAX", + [SET_RFLAGS] = "RFLAGS", + [DESC_BASE] = "BASE", + [DESC_LIMIT] = "LIMIT", + [DESC_ACCESS] = "ACCESS", + [SET_CS] = "CS", + [SET_DS] = "DS", + [SET_ES] = "ES", + [SET_FS] = "FS", + [SET_GS] = "GS", + [SET_SS] = "SS", + [SET_TR] = "TR", + [SET_LDTR] = "LDTR", + [SET_X2APIC_STATE] = "state", + [SET_CAP] = "0|1", + [CAPNAME] = "capname", + [UNASSIGN_PPTDEV] = "bus/slot.func", + [GET_GPA_PMAP] = "gpa", + [ASSERT_LAPIC_LVT] = "pin", + [SET_RTC_TIME] = "secs", + [SET_RTC_NVRAM] = "val", + [RTC_NVRAM_OFFSET] = "offset", +#ifdef BHYVE_SNAPSHOT + [SET_CHECKPOINT_FILE] = "filename", + [SET_SUSPEND_FILE] = "filename", +#endif + }; + (void)fprintf(stderr, "Usage: %s --vm=\n", progname); + for (const struct option *o = opts; o->name; o++) { + if (strcmp(o->name, "vm") == 0) + continue; + if (o->has_arg == REQ_ARG) + (void)fprintf(stderr, " [--%s=<%s>]\n", + o->name, set_desc[o->val]); + else + (void)fprintf(stderr, " [--%s]\n", o->name); + } + exit(1); +} + static const char * wday_str(int idx) { @@ -1916,7 +1797,7 @@ main(int argc, char *argv[]) case UNASSIGN_PPTDEV: unassign_pptdev = 1; if (sscanf(optarg, "%d/%d/%d", &bus, &slot, &func) != 3) - usage(cpu_intel); + usage(opts); break; case ASSERT_LAPIC_LVT: assert_lapic_lvt = atoi(optarg); @@ -1925,21 +1806,21 @@ main(int argc, char *argv[]) case SET_CHECKPOINT_FILE: case SET_SUSPEND_FILE: if (checkpoint_file != NULL) - usage(cpu_intel); + usage(opts); checkpoint_file = optarg; vm_suspend_opt = (ch == SET_SUSPEND_FILE); break; #endif default: - usage(cpu_intel); + usage(opts); } } argc -= optind; argv += optind; if (vmname == NULL) - usage(cpu_intel); + usage(opts); error = 0;