From 9fc356af430f71c6c8d76055f4860e819c26673d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 4 Apr 2013 12:04:07 -0400 Subject: [PATCH] virt-install: Better error when user accidentally passes -vcpus Notice the missing - in -vcpus. It maps to --hvm --cdrom pus If the user also specifies --paravirt, they get an error that hvm and paravirt conflict, which is very confusing. There isn't a nice way to catch this issue which isn't back compatible, so scrape the raw argv and try to figure it out. --- virt-install | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/virt-install b/virt-install index de0632991..35f16a78b 100755 --- a/virt-install +++ b/virt-install @@ -93,6 +93,18 @@ def supports_pxe(guest): return False +def check_vcpu_option_error(options): + # Catch a strangely common error of users passing -vcpus=2 instead of + # --vcpus=2. The single dash happens to map to enough shortened options + # that things can fail weirdly if --paravirt is also specified. + if not options.cdrom: + return + + for vcpu in [o for o in sys.argv if o.startswith("-vcpu")]: + if options.cdrom == vcpu[3:]: + fail("You specified -vcpus, you want --vcpus") + + ############################## # Device validation wrappers # ############################## @@ -980,6 +992,7 @@ def main(conn=None): if cliargs: fail(_("Unknown argument '%s'") % cliargs[0]) + check_vcpu_option_error(options) if options.distro_variant == "list": logging.debug("OS list requested")