virt-install: Add --features option

And hide docs about old --noacpi/--noacpi options. I don't think
anyone really uses them anyways, but if anyone complains we should
just implement --features for the other CLI commands.
This commit is contained in:
Cole Robinson 2013-09-28 09:36:11 -04:00
parent 16a190a0dc
commit eca87838fb
14 changed files with 118 additions and 118 deletions

View File

@ -95,16 +95,6 @@ options is HIGHLY RECOMMENDED, as it can greatly increase performance
by specifying virtio among other guest tweaks.
See L<virt-install(1)> for valid values.
=item --noapic
Override the OS type / variant to disables the APIC setting for fully
virtualized guest.
=item --noacpi
Override the OS type / variant to disables the ACPI setting for fully
virtualized guest.
=back
=head2 Miscellaneous Options

View File

@ -94,24 +94,6 @@ See L<virt-install(1)> for valid values.
=head2 Full Virtualization specific options
Parameters specific only to fully virtualized guest installs.
=over 2
=item --noapic
Force disable APIC for the guest.
=item --noacpi
Force disable ACPI for the guest.
=back
=head2 Networking Configuration

View File

@ -187,6 +187,23 @@ To have libvirt automatically apply your static label, you must specify
relabel=yes. Otherwise disk images must be manually labeled by the admin,
including images that virt-install is asked to create.
=item --features FEAT=on|off,...
Set elements in the guests <features> XML on or off. Examples include acpi,
apic, eoi, privnet, and hyperv features. Some examples:
=over 2
=item B<--features eoi=on>
Enable APIC PV EOI
=item B<--features hyperv_vapic=on,hyperv_spinlocks=off>
Enable hypver VAPIC, but disable spinlocks
=back
=back
@ -826,14 +843,6 @@ Prefer KVM or KQEMU (in that order) if installing a QEMU guest. This behavior
is now the default, and this option is deprecated. To install a plain QEMU
guest, use '--virt-type qemu'
=item --noapic
Force disable APIC for the guest.
=item --noacpi
Force disable ACPI for the guest.
=back

View File

@ -5,10 +5,6 @@
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -14,9 +14,12 @@
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<apic eoi="on"/>
<pae/>
<privnet/>
<hyperv>
<spinlocks state="on" retries="1234"/>
</hyperv>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
@ -107,9 +110,12 @@
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<apic eoi="on"/>
<pae/>
<privnet/>
<hyperv>
<spinlocks state="on" retries="1234"/>
</hyperv>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>

View File

@ -5,10 +5,6 @@
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -5,10 +5,6 @@
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -10,10 +10,6 @@
<initrd>./virtinst-initrd.img.</initrd>
<cmdline>method=tests/cli-test-xml/faketree</cmdline>
</os>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
@ -39,10 +35,6 @@
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -10,10 +10,6 @@
<initrd>./virtinst-initrd.img.</initrd>
<cmdline>method=tests/cli-test-xml/faketree</cmdline>
</os>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
@ -40,10 +36,6 @@
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<bootloader>/usr/bin/pygrub</bootloader>
<features>
<acpi/>
<apic/>
</features>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -479,7 +479,27 @@ c = vinst.add_category("misc", "--nographics --noautoconsole")
c.add_compare("", "noargs-fail") # No arguments
c.add_compare("--hvm --nodisks --pxe --print-step all", "simple-pxe") # Diskless PXE install
c.add_compare("--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --vcpus cores=4", "w2k3-cdrom") # HVM windows install with disk
c.add_compare("""--hvm --pxe --controller usb,model=ich9-ehci1,address=0:0:4.7,index=0 --controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 --controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 --controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 --disk %(MANAGEDEXISTUPPER)s,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149 --disk %(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace --disk device=cdrom,bus=sata --serial tcp,host=:2222,mode=bind,protocol=telnet --filesystem /source,/target,mode=squash --network user,mac=12:34:56:78:11:22 --network bridge=foobar,model=virtio --channel spicevmc --smartcard passthrough,type=spicevmc --tpm passthrough,model=tpm-tis,path=/dev/tpm0 --security type=static,label='system_u:object_r:svirt_image_t:s0:c100,c200',relabel=yes --numatune \\"1-3,5\\",mode=preferred --boot loader=/foo/bar --host-device net_00_1c_25_10_b1_e4""", "many-devices") # Lots of devices
c.add_compare("""--hvm --pxe \
--controller usb,model=ich9-ehci1,address=0:0:4.7,index=0 \
--controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \
--controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 \
--controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 \
--disk %(MANAGEDEXISTUPPER)s,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149 \
--disk %(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace \
--disk device=cdrom,bus=sata \
--serial tcp,host=:2222,mode=bind,protocol=telnet \
--filesystem /source,/target,mode=squash \
--network user,mac=12:34:56:78:11:22 \
--network bridge=foobar,model=virtio \
--channel spicevmc \
--smartcard passthrough,type=spicevmc \
--tpm passthrough,model=tpm-tis,path=/dev/tpm0 \
--security type=static,label='system_u:object_r:svirt_image_t:s0:c100,c200',relabel=yes \
--numatune \\"1-3,5\\",mode=preferred \
--boot loader=/foo/bar \
--host-device net_00_1c_25_10_b1_e4 \
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234 \
""", "many-devices") # Lots of devices
c.add_valid("--hvm --disk path=virt-install,device=cdrom") # Specifying cdrom media via --disk
c.add_valid("--hvm --import --disk path=virt-install") # FV Import install
c.add_valid("--hvm --import --disk path=virt-install --prompt --force") # Working scenario w/ prompt shouldn't ask anything

View File

@ -70,14 +70,7 @@ def parse_args():
default=get_default_arch(),
help=_("Machine Architecture Type (i686/x86_64/ppc)"))
cli.add_distro_options(cfgg)
cfgg.add_option("", "--noapic", action="store_true", dest="noapic",
default=False,
help=_("Disables APIC for fully virtualized guest "
"(overrides value in os-variant db)"))
cfgg.add_option("", "--noacpi", action="store_true", dest="noacpi",
default=False,
help=_("Disables ACPI for fully virtualized guest "
"(overrides value in os-variant db)"))
cli.add_old_feature_options(cfgg)
opts.add_option_group(cfgg)
misc = OptionGroup(opts, "Miscellaneous Options")

View File

@ -48,18 +48,9 @@ def parse_args():
help=_("UUID for the guest."))
cli.vcpu_cli_options(geng)
cli.add_distro_options(geng)
cli.add_old_feature_options(geng)
parser.add_option_group(geng)
fulg = optparse.OptionGroup(parser,
_("Full Virtualization specific options"))
fulg.add_option("", "--noapic", action="store_true", dest="noapic",
default=False,
help=_("Disables APIC for fully virtualized guest"))
fulg.add_option("", "--noacpi", action="store_true", dest="noacpi",
default=False,
help=_("Disables ACPI for fully virtualized guest"))
parser.add_option_group(fulg)
netg = cli.network_option_group(parser)
parser.add_option_group(netg)
@ -133,6 +124,7 @@ def main(conn=None):
cli.convert_old_networks(guest, options, image.domain.interface)
cli.convert_old_graphics(guest, options,
default_override=bool(image.domain.graphics))
cli.convert_old_features(options)
guest.replace = options.replace
cli.get_name(guest, options.name or image.name)
@ -146,12 +138,7 @@ def main(conn=None):
cli.get_networks(guest, options.network)
cli.get_graphics(guest, options.graphics)
cli.set_os_variant(guest, options.distro_type, options.distro_variant)
if guest.os.is_hvm():
if options.noacpi:
guest.features.acpi = False
if options.noapic:
guest.features.apic = False
cli.parse_features(guest, getattr(options, "features", None))
if not guest.get_devices("input"):
guest.add_default_input_device()

View File

@ -495,6 +495,7 @@ def build_guest_instance(conn, options):
cli.convert_old_networks(guest, options, not options.nonetworks and 1 or 0)
cli.convert_old_graphics(guest, options)
convert_old_disks(options)
cli.convert_old_features(options)
# Guest configuration
cli.get_uuid(guest, options.uuid)
@ -503,10 +504,10 @@ def build_guest_instance(conn, options):
cli.parse_cpu(guest, options.cpu)
cli.parse_security(guest, options.security)
cli.parse_boot(guest, options.bootopts)
cli.parse_features(guest, options.features)
guest.autostart = options.autostart
guest.description = options.description
guest.features.acpi = not options.noacpi
guest.features.apic = not options.noapic
# Non-default devices
cli.get_controllers(guest, options.controller)
@ -902,6 +903,10 @@ def parse_args():
help=_("Set domain security driver configuration."))
geng.add_option("", "--numatune", dest="numatune",
help=_("Tune NUMA policy for the domain process."))
geng.add_option("", "--features", dest="features",
help=_("Set domain <features> XML. Ex:\n"
"--features acpi=off\n"
"--features apic=on,eoi=on"))
parser.add_option_group(geng)
insg = optparse.OptionGroup(parser, _("Installation Method Options"))
@ -993,16 +998,9 @@ def parse_args():
help=_("The CPU architecture to simulate"))
virg.add_option("", "--machine", dest="machine",
help=_("The machine type to emulate"))
virg.add_option("", "--noapic", action="store_true", dest="noapic",
default=False,
help=_("Disables APIC for fully virtualized guest "
"(overrides value in os-variant db)"))
virg.add_option("", "--noacpi", action="store_true", dest="noacpi",
default=False,
help=_("Disables ACPI for fully virtualized guest "
"(overrides value in os-variant db)"))
virg.add_option("-u", "--uuid", dest="uuid",
help=_("UUID for the guest."))
cli.add_old_feature_options(virg)
parser.add_option_group(virg)
misc = optparse.OptionGroup(parser, _("Miscellaneous Options"))

View File

@ -755,6 +755,20 @@ def convert_old_graphics(guest, options, default_override=None):
options.graphics = [optstr]
def convert_old_features(options):
if getattr(options, "features", None):
return
opts = ""
if options.noacpi:
opts += "acpi=off"
if options.noapic:
if opts:
opts += ","
opts += "apic=off"
options.features = opts or None
def set_os_variant(obj, distro_type, distro_variant):
# This is used for both Guest and virtconv VM, so be careful
if (not distro_type and
@ -913,6 +927,13 @@ def add_distro_options(g):
"e.g. 'fedora18', 'rhel6', 'winxp', etc."))
def add_old_feature_options(optg):
optg.add_option("", "--noapic", action="store_true", dest="noapic",
default=False, help=optparse.SUPPRESS_HELP)
optg.add_option("", "--noacpi", action="store_true", dest="noacpi",
default=False, help=optparse.SUPPRESS_HELP)
#############################################
# CLI complex parsing helpers #
# (for options like --disk, --network, etc. #
@ -1101,7 +1122,7 @@ def parse_cpu(guest, optstr):
"optional": [],
"disable": [],
"forbid": [],
}
}
opts = parse_optstr(optstr,
basedict=default_dict,
remove_first="model")
@ -1197,16 +1218,12 @@ def parse_boot(guest, optstr):
# --security parsing #
######################
def parse_security(guest, security):
seclist = util.listify(security)
secopts = seclist and seclist[0] or None
if not secopts:
def parse_security(guest, optstr):
if not optstr:
return
# Parse security opts
opts = parse_optstr(secopts)
arglist = secopts.split(",")
secmodel = guest.seclabel
opts = parse_optstr(optstr)
arglist = optstr.split(",")
# Beware, adding boolean options here could upset label comma handling
mode = get_opt_param(opts, "type")
@ -1232,21 +1249,47 @@ def parse_security(guest, security):
break
if label:
secmodel.label = label
guest.seclabel.label = label
if not mode:
mode = secmodel.TYPE_STATIC
mode = guest.seclabel.TYPE_STATIC
if mode:
secmodel.type = mode
guest.seclabel.type = mode
if relabel:
secmodel.relabel = relabel
guest.seclabel.relabel = relabel
_check_leftover_opts(opts)
# Run for validation purposes
secmodel.get_xml_config()
guest.seclabel.get_xml_config()
######################
# --features parsing #
######################
def parse_features(guest, optstr):
if not optstr:
return
opts = parse_optstr(optstr)
set_param = _build_set_param(guest.features, opts)
set_param("acpi", "acpi", convert_cb=yes_or_no_convert)
set_param("apic", "apic", convert_cb=yes_or_no_convert)
set_param("pae", "pae", convert_cb=yes_or_no_convert)
set_param("privnet", "privnet", convert_cb=yes_or_no_convert)
set_param("hap", "hap", convert_cb=yes_or_no_convert)
set_param("viridian", "viridian", convert_cb=yes_or_no_convert)
set_param("eoi", "eoi", convert_cb=yes_or_no_convert)
set_param("hyperv_vapic", "hyperv_vapic", convert_cb=yes_or_no_convert)
set_param("hyperv_relaxed", "hyperv_relaxed", convert_cb=yes_or_no_convert)
set_param("hyperv_spinlocks", "hyperv_spinlocks",
convert_cb=yes_or_no_convert)
set_param("hyperv_spinlocks_retries", "hyperv_spinlocks_retries")
_check_leftover_opts(opts)
##########################
# Guest <device> parsing #