cli: Deprecate explicit --cpuset option, make it a --vcpus sub option

This commit is contained in:
Cole Robinson 2014-01-21 15:24:46 -05:00
parent 54b73f4502
commit ec79c676b3
5 changed files with 36 additions and 43 deletions

View File

@ -68,11 +68,6 @@ Number of vcpus to configure for your guest. Defaults to
C</image/devices/vcpu> in the XML descriptor. This option can also be
used to set CPU topology, please see L<virt-install(1)> for more info.
=item --cpuset
Set which physical cpus the guest can use. Please see L<virt-install(1)> for
more info.
=item --cpu
Configure the CPU and CPU features exposed to the guest. Please see

View File

@ -109,7 +109,7 @@ specify UUID, you should use a 32-digit hexadecimal number. UUID are intended
to be unique across the entire data center, and indeed world. Bear this in
mind if manually specifying a UUID
=item --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#]
=item --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#][,cpuset=CPUSET]
Number of virtual cpus to configure for the guest. If 'maxvcpus' is specified,
the guest will be able to hotplug up to MAX vcpus while the guest is running,
@ -119,9 +119,7 @@ CPU topology can additionally be specified with sockets, cores, and threads.
If values are omitted, the rest will be autofilled preferring sockets over
cores over threads.
=item --cpuset=CPUSET
Set which physical cpus the guest can use. C<CPUSET> is a comma separated list of numbers, which can also be specified in ranges or cpus to exclude. Example:
'cpuset' sets which physical cpus the guest can use. C<CPUSET> is a comma separated list of numbers, which can also be specified in ranges or cpus to exclude. Example:
0,2,3,5 : Use processors 0,2,3 and 5
1-5,^3,8 : Use processors 1,2,4,5 and 8
@ -134,15 +132,13 @@ an optimal cpu pinning using NUMA data, if available.
Tune NUMA policy for the domain process. Example invocations
--numatune 1,2,3,4-7
--numatune \"1-3,5\",mode=preferred
--numatune 1-3,5,mode=preferred
Specifies the numa nodes to allocate memory from. This has the same syntax
as C<--cpuset> option. mode can be one of 'interleave', 'preferred', or
'strict' (the default). See 'man 8 numactl' for information about each
mode.
The nodeset string must use escaped-quotes if specifying any other option.
=item --cpu MODEL[,+feature][,-feature][,match=MATCH][,vendor=VENDOR]
Configure the CPU model and CPU features exposed to the guest. The only

View File

@ -101,24 +101,23 @@ def main(conn=None):
cli.convert_old_graphics(guest, options,
default_override=bool(image.domain.graphics))
cli.convert_old_features(options)
cli.convert_old_cpuset(options)
if not options.vcpus:
options.vcpus = image.domain.vcpu or ""
guest.replace = options.replace
cli.set_os_variant(guest, options.distro_type, options.distro_variant)
cli.get_name(guest, options.name or image.name)
cli.get_memory(guest, options.memory or (image.domain.memory and
int(image.domain.memory)))
if options.uuid:
guest.uuid = options.uuid
cli.set_os_variant(guest, options.distro_type, options.distro_variant)
parsermap = cli.build_parser_map(options,
only=["vcpus", "cpu", "network", "graphics", "features"])
cli.parse_option_strings(parsermap, options, guest, None)
cli.get_cpuset(guest, options.cpuset)
if not guest.get_devices("input"):
guest.add_default_input_device()
if not guest.get_devices("console") and not guest.get_devices("serial"):

View File

@ -495,6 +495,7 @@ def build_guest_instance(conn, options):
cli.convert_old_graphics(guest, options)
convert_old_disks(options)
cli.convert_old_features(options)
cli.convert_old_cpuset(options)
# non-xml install options
guest.installer.extraargs = options.extra_args or ""
@ -502,6 +503,10 @@ def build_guest_instance(conn, options):
cli.set_os_variant(guest, options.distro_type, options.distro_variant)
guest.autostart = options.autostart
cli.get_name(guest, options.name)
# Memory needs to come before the vcpu setting
cli.get_memory(guest, options.memory)
# Guest configuration
guest.os.init = options.init
if options.uuid:
@ -521,12 +526,6 @@ def build_guest_instance(conn, options):
# about those first.
need_storage, need_install = validate_required_options(options, guest)
# Actually set required options
cli.get_name(guest, options.name)
cli.get_memory(guest, options.memory)
# Needs to come after setting memory
cli.get_cpuset(guest, options.cpuset)
get_disks(guest, options.disk, options.nodisks, need_storage)
get_install_media(guest, options.location, options.cdrom, need_install)

View File

@ -564,24 +564,13 @@ def get_memory(guest, memory):
func=check_memory)
def get_cpuset(guest, cpuset):
memory = guest.memory
conn = guest.conn
if cpuset and cpuset != "auto":
guest.cpuset = cpuset
elif cpuset == "auto":
tmpset = None
try:
tmpset = virtinst.DomainNumatune.generate_cpuset(conn, memory)
except Exception, e:
logging.debug("Not setting cpuset: %s", str(e))
if tmpset:
logging.debug("Auto cpuset is: %s", tmpset)
guest.cpuset = tmpset
return
def convert_old_cpuset(options):
if not options.cpuset:
return
if not options.vcpus:
options.vcpus = ""
options.vcpus += ",cpuset=%s" % options.cpuset
logging.debug("Generated compat cpuset: --vcpus %s", options.vcpus)
def _default_network_opts(guest):
@ -771,16 +760,15 @@ def vcpu_cli_options(grp, backcompat=True):
grp.add_argument("--vcpus",
help=_("Number of vcpus to configure for your guest. Ex:\n"
"--vcpus 5\n"
"--vcpus 5,maxcpus=10\n"
"--vcpus sockets=2,cores=4,threads=2"))
grp.add_argument("--cpuset",
help=_("Set which physical CPUs domain can use."))
"--vcpus 5,maxcpus=10,cpuset=1-4,6,8\n"
"--vcpus sockets=2,cores=4,threads=2,"))
grp.add_argument("--cpu",
help=_("CPU model and features. Ex: --cpu coreduo,+x2apic"))
if backcompat:
grp.add_argument("--check-cpu", action="store_true",
help=argparse.SUPPRESS)
grp.add_argument("--cpuset", help=argparse.SUPPRESS)
def graphics_option_group(parser):
@ -1235,6 +1223,22 @@ class ParserVCPU(VirtCLIParser):
self.set_param(None, "vcpus", setter_cb=set_vcpus_cb)
self.set_param("vcpus", "maxvcpus")
def set_cpuset_cb(opts, inst, cliname, val):
if val == "auto":
try:
val = virtinst.DomainNumatune.generate_cpuset(
inst.conn, inst.memory)
logging.debug("Auto cpuset is: %s", val)
except Exception, e:
logging.error("Not setting cpuset: %s", str(e))
val = None
if val:
inst.cpuset = val
self.set_param(None, "cpuset", can_comma=True,
setter_cb=set_cpuset_cb)
def _parse(self, opts, inst):
set_from_top = ("maxvcpus" not in opts.opts and