From nobody Mon Apr 08 13:14:34 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 4VCqLf595Dz5H1Rk; Mon, 8 Apr 2024 13:14:34 +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 4VCqLf39qmz4qVr; Mon, 8 Apr 2024 13:14:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712582074; 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=MRHQdNmJHbF/SXoSQAouiTIi8QensVOO5RABN2eK9Yc=; b=rxz30KoRnaEC4k3DX2i8K6Onr8ZL51QhBuv9aF89WcfNca4Jp+Sw2rSQmUEe5xhdMFlGIF c6WW4u2eH2WMxqA2a2I0F/XDqEzS2DoTOocH7YojIqrlrRzKF/C2eIX3RAzTW61W5J2Ozw x0YhxQbD6PDXOD/rXEwyou57NglJ6HdHTdWIEK0jgUgHkT/J9pYZgtWw2pBZS5exJocmCH igxW72XZpmFjNWh00Oxg0Mz0ikoGnFvGGlObxhetEsUNCf8ZzH87bIF+Q9CLhlvHGFiEJt YQG5xcpD3xO2WR9eoN504JV3wQU/v2fRMNsj1yxWiwhpVUyh1QRs4GxfSMqjHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712582074; a=rsa-sha256; cv=none; b=VuwrkTMIe2Rp7yA3diO5TLWhzBuCz8RPO5+bL1sF1c1P8W9yVmCl8h3B2kxgED2Mb0Zeag JTyuxB5CDPRQkvYrD3MPvkGcpVQAHDojTILTLOsE/hzmbPo2cGH1zvC33OnHANDwI8Ro1n BmIUxsSgDx4GMq0g/9cr7/TKtXZj29Pc2kcpwtxkh51CeNoY7tQ0RpoQSPIWP9EaHCqz5X 1AFrpf4fwi2NrC93cX+bTJs5BmeoQQmzG8wHpTeZFUBKxK/V7tbiZVjIed2bP9JIb332jp GNTd/FojwhPPm/xqlJb9DJdFWRYyBhXLdfJyIzRC7ys+HDYUQopMZy67vlPbNw== 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=1712582074; 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=MRHQdNmJHbF/SXoSQAouiTIi8QensVOO5RABN2eK9Yc=; b=Hqahb4NHRSHniChQ+boi0/RAagxpRA5FzQckIaPH8LJvjd3gGsGoVlHh+hP/MPweuXqktU UtjLrWZQm8pvBYa0scday+gdqsbhuJUOrE0hqwHraOKUB32l0GxxlepMwdY0zsvK7iHAIZ H7biiNqjAybFr+JaoB633Iw27AYJmhERS09jdSjWlNbtCBCrWz6+mblOKlICCyQ6h83gl6 TFLNjLWQk7IiG13XgsRSAZ6mv0LAs9tzuxXPlG2zute4DrV3Cks+4Jf+k8jlOvOYsT9xwq 7n1ieMLaNnWcAWO29JB9sRbdZTLRnlSc6yIIT7f9n0nvuup8Ts6qidgc5eJhNA== 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 4VCqLf1X69z1Bkm; Mon, 8 Apr 2024 13:14:34 +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 438DEYoS000993; Mon, 8 Apr 2024 13:14:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 438DEYpR000990; Mon, 8 Apr 2024 13:14:34 GMT (envelope-from git) Date: Mon, 8 Apr 2024 13:14:34 GMT Message-Id: <202404081314.438DEYpR000990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: b9fa1500cb22 - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: b9fa1500cb2265b95927e19b9d2119ca26d65be3 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=b9fa1500cb2265b95927e19b9d2119ca26d65be3 commit b9fa1500cb2265b95927e19b9d2119ca26d65be3 Author: Rob Norris AuthorDate: 2024-04-08 13:07:32 +0000 Commit: Mark Johnston CommitDate: 2024-04-08 13:08:54 +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 --- 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 a055be46d8d4..90c9d51c2138 100644 --- a/usr.sbin/bhyvectl/bhyvectl.c +++ b/usr.sbin/bhyvectl/bhyvectl.c @@ -71,184 +71,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; @@ -1566,6 +1388,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) { @@ -1915,7 +1796,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); @@ -1924,21 +1805,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;