Commit Graph

115 Commits

Author SHA1 Message Date
Cole Robinson e0c5d74e82 domain: launch_security: simplify defaults and validation
* libvirt fills in cbitpos and reducedPhysBits for us
* libvirt errors if type is missing
* libvirt errors if host/qemu doesn't support sev

So drop it all. This simplifies testing because we don't need
sev domcaps in place just to generate the XML

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-28 08:45:18 -05:00
Cole Robinson e3ecae0d2a domain: cpu: Clear 'migratable' and 'check' when changing mode
Otherwise going host-passthrough -> host-model -> host-passthrough
can cause libvirt validation errors or leave unintended bits in
the XML

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-20 11:04:37 -05:00
Cole Robinson 3fd71ea72f tests: cli: A bunch of cleanup
- Move most xml suboption testing to many-devices test
- Clarify every specific bit we are testing in the singleton tests
- Consolidate/drop/reduce a lot of tests

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-19 10:02:41 -05:00
Cole Robinson 2c477f3302 domain: cpu: Use host-passthrough by default on x86
When libvirt and qemu are new enough, use host-passthrough for the
CPU default. Nowadays this is recommended over host-model for most
end user usage where migration isn't a critical feature.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 14:03:44 -05:00
Cole Robinson 49f54a294b virtinst: cpu: drop host-copy support
host-copy was the old default, but it's fundamentally flawed. Since
we switched to host-model default a few years back, it's not advertised
in the docs or selectable via virt-manager any more.

Have it print a warning and invoke host-model-only

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 12:31:52 -05:00
Cole Robinson 01f52fed97 cli: Add --launchSecurity kernelHashes=yes|no
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-26 17:08:27 -05:00
Cole Robinson 9c45f4a2e9 details: Strip back 'Enable shared memory' to only cover memfd
Strip back the logic to:

* Only try to toggle source_type=memfd and access_mode=shared
* Disable the field if guest has any <numa> config
* Disable the field if domcaps does not report virtiofs and memfd

This is the simplest future proof case, though it will exclude some
legit guest configs and some libvirt+qemu back compat.

My feeling is the <numa> stuff in particular is pretty advanced, so if
users have it configured they can toggle shared memory via the XML
without too much trouble.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-25 12:43:32 -05:00
Lin Ma b19f973f78 domain: cpu: Add function all_shared_memAccess_cells()
It returns true in case all of numa nodes have the "shared" memAccess
attribute defined explicitly.

Signed-off-by: Lin Ma <lma@suse.com>
2022-01-25 12:26:14 -05:00
Lin Ma f223992934 domain: cpu: Add function has_private_memAccess_cells()
It returns true in case any of numa nodes has the "private" memAccess
attribute.

Signed-off-by: Lin Ma <lma@suse.com>
2022-01-25 12:26:14 -05:00
Lin Ma 0864a9b231 domain: memorybacking: Add function is_shared_access()
It returns true in case the memoryBacking element contains the "shared"
access mode.

Signed-off-by: Lin Ma <lma@suse.com>
2022-01-25 12:26:14 -05:00
Daniel P. Berrangé 883419c214 virtinst: allow to force create topology from scratch
When setting CPU defaults we want to force create the topology even if
the user has not specified anything. In particular this allows for
overriding the QEMU defaults, to expose vCPUs as cores instead of
sockets which is a much saner default for Windows.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:39 -05:00
Daniel P. Berrangé 9a578e1ac5 virtinst: prefer cores when exposing topology to the guest
In real world silicon though it is rare to have high socket/die counts,
but common to have huge core counts.

Some OS will even refuse to use sockets over a certain count.

Thus we prefer to expose cores to the guest rather than sockets as the
default for missing fields.

This matches a recent change made in QEMU for new machine types

  commit 4a0af2930a4e4f64ce551152fdb4b9e7be106408
  Author: Yanan Wang <wangyanan55@huawei.com>
  Date:   Wed Sep 29 10:58:09 2021 +0800

    machine: Prefer cores over sockets in smp parsing since 6.2

Closes: https://github.com/virt-manager/virt-manager/issues/155
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Daniel P. Berrangé e1c8866163 virtinst: validate that the CPU topology is sane
The product of sockets * dies * cores * threads must be equal to the
vCPU count. While libvirt and QEMU will report this error scenario,
it makes sense to catch it in virt-install, so we can test our local
logic for setting defaults for topology.

This exposes some inconsistent configurations in the test suite.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Daniel P. Berrangé 609007c9ca virtinst: make CPU topology defaulting take account of dies
Any missing values in the topology need to be calculated based on the
other values which are set.

We can take account of fact that 'total_vcpus' treats any unset values
as being 1 to simplify the way we set topology defaults.

This ensures that topology defaulting takes account of dies.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Daniel P. Berrangé 9bb86f5186 virtinst: move method for calculating vCPU count from topology
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Daniel P. Berrangé c1491ae142 virtinst: set dies in topology to 1
It is always permitted to set dies==1 regardless of architecture or
machine type. The only constraint is around setting values > 1, for
archs/machines that don't support the dies concept.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Daniel P. Berrangé 7b68fe1a5e virtinst: take account of 'dies' when calc vcpu count from topology
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:38 -05:00
Jonathon Jongsma 9766beea04 cli: add 'ioapic.driver' to --features
Add the ability to set the ioapic driver using the --features argument:

    $ virt-install --features ioapic.driver=qemu ...

This results in the following xml:

  <features>
    ...
    <ioapic driver="qemu"/>
  </features>

This is required in order to install a guest with >255 cpus. Such a
configuration requires an iommu with extended interrupt mode enabled,
which in turn requires IOMMU interrupt remapping to be enabled, which in
turn requires a split I/O APIC.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-01-11 18:26:06 -05:00
Daniel P. Berrangé 019c621b62 virtinst: fix check for UEFI in SEV setup
The code was only checking the manual approach to enabling UEFI, not the
modern automatic approach.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-11 12:04:39 -05:00
Hugues Fafard cb97f6001b cli: --cpu: code cleanup & reordering
Shuffling bits of code around, adding comments and grouping CLI options
to make the code easier to read and understand at a glance.

Brings the ordering of XML options in line with libvirt's own output as
implemented in `src/conf/cpu_conf.c` and `src/conf/numa_conf.c`.
2021-10-04 15:10:10 -04:00
Hugues Fafard 6a2bc142eb cli: --cpu: add support for NUMA interconnects
This includes support for the following options:
* numa.interconnects.latency[0-9]*.initiator
* numa.interconnects.latency[0-9]*.target
* numa.interconnects.latency[0-9]*.cache
* numa.interconnects.latency[0-9]*.type
* numa.interconnects.latency[0-9]*.value
* numa.interconnects.latency[0-9]*.unit
* The same suboptions for `numa.interconnects.bandwith[0-9]*`

Note that the cache= attribute is only explicitly defined for <latency>
nodes in the documentation. However, since <latency> and <bandwidth>
nodes are otherwise identical, the docs also don't explicitly forbid it
for <bandwidth> nodes, and libvirt happily accepts XML that does specify
it for for <bandwidth> nodes, this implements the cache= attribute for
<bandwidth> elements as well.
2021-10-04 15:08:39 -04:00
Hugues Fafard fbcb7539c3 cli: --cpu: add support for NUMA caches
This includes support for the following options:
* numa.cell[0-9]*.cache[0-9]*.level
* numa.cell[0-9]*.cache[0-9]*.associativity
* numa.cell[0-9]*.cache[0-9]*.policy
* numa.cell[0-9]*.cache[0-9]*.size.value
* numa.cell[0-9]*.cache[0-9]*.size.unit
* numa.cell[0-9]*.cache[0-9]*.line.value
* numa.cell[0-9]*.cache[0-9]*.line.unit
2021-10-04 15:08:38 -04:00
Hugues Fafard 42bb522f0d cli: --cpu: make `numa.cell[0-9]*.discard` an on/off type option 2021-10-04 15:08:38 -04:00
Hugues Fafard bf3bd824c1 cli: --cpu: add support for unit of NUMA memory size
This adds support for the `numa.cell[0-9]*.unit` option.
2021-10-04 15:08:38 -04:00
Hugues Fafard 7d49d95a0f cli: --cpu: add support for specifying dies in topology
This adds support for the `topology.dies` option.
2021-10-04 15:08:38 -04:00
Hugues Fafard 1166bb3d8d cli: --cpu: add support for `check` & `migratable` options
Note that the `migratable` option is only allowed by libvirt for
`mode=passthrough` or `mode=maximum`.
2021-10-04 15:08:38 -04:00
Hugues Fafard bcd97dd01a cli: --cputune: add support for cachetune montiors
This adds support for the following options:
* `cachetune[0-9]*.monitor[0-9]*.level`
* `cachetune[0-9]*.monitor[0-9]*.vcpus`
2021-10-04 13:31:54 -04:00
Hugues Fafard 563a97f022 cli: --cputune: add scheduling options
This includes support for the following options:
* `emulatorsched.scheduler`
* `emulatorsched.priority`
* `iothreadsched.iothreads`
* `iothreadsched.scheduler`
* `iothreadsched.priority`
2021-10-04 13:31:54 -04:00
Hugues Fafard 95721ae8d7 cli: --cputune: cleanup 2021-10-04 13:31:54 -04:00
Hugues Fafard 5cfbbf5701 cli: --cputune: add support for host cpu usage quotas
This includes support for the following options:
* `shares`
* `period`
* `quota`
* `global_period`
* `global_quota`
* `emulator_period`
* `emulator_quota`
* `iothread_period`
* `iothread_quota`
2021-10-04 13:31:54 -04:00
Pavel Hrdina 0953e1aea1 cli: introduce --resource fibrechannel.appid option
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-14 17:08:35 +02:00
Hugues Fafard 6cc7987627 Finish reordering stuff and cleaning up
Finishes shuffling bits of code around to make the options better
grouped in the code so it's easier to read and understand what's what at
a glance.
2021-07-29 11:44:57 -04:00
Hugues Fafard edf6c3ff2e cli: --boot: Completed options for container boot
Adds support for `initenv[0-9]*.name` and `initenv[0-9]*` suboptions.
2021-07-29 11:44:57 -04:00
Hugues Fafard 7bc4ba81ff cli: --boot: Completed options for direct kernel boot
Adds support for `acpi.table` and `acpi.table.type` suboptions.
2021-07-29 11:44:57 -04:00
Hugues Fafard 0a856179a5 cli: --boot: Completed options for host-based bootloader
Adds support for `bootloader_args` suboption
2021-07-29 11:44:57 -04:00
Hugues Fafard a24cdd1964 cli: --boot: Completed options for guest-based bootloader
Adds support for `bootmenu.timeout` suboption.
2021-07-29 11:44:57 -04:00
Hugues Fafard b987613106 cli: --boot: add support of firmware features
libvirt 7.2.0 introduced support for a list of firmware features
that should or should not be present. Libvirt takes these into
account when auto-selecting a firmware. Currently supported features
are `enrolled-keys` and `secure-boot`.
2021-07-28 09:46:16 -04:00
Hugues Fafard c2f629fc03 cli: --cputune: add iothreadpin[0-9]* config
This adds the following suboptions to configure the
<domain><cputune><iothreadpin> list:

* iothreadpin[0-9]*.iothread
* iothreadpin[0-9]*.cpuset
2021-07-27 08:28:10 -04:00
Hugues Fafard f0f7ae2d1c cli: --cputune: add emulatorpin.cpuset config
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2021-07-26 14:12:36 -04:00
Han Han 38dd57284f cli: --feature: Support kvm.poll-control.state
Implement kvm.poll-control.state to `virt-install --feature`. It requires
libvirt >= v6.10.0.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Han Han <hhan@redhat.com>
2021-05-28 15:43:38 -04:00
Jonathan Schwender f9a0c3ccb2 cli: --cputune: add vcpusched[0-9]* config
This adds the following suboptions to configure <cputune>:

- vcpusched.vcpus
- vcpusched.scheduler
- vcpusched.priority

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2021-02-16 16:37:15 -05:00
Cole Robinson 65f93e5d60 cli: support --sysinfo type=fwcfg,entry...
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-09-11 09:00:33 -04:00
Cole Robinson b3fb88e345 cli: Add --cpu numa.cell.memAccess and discard
https://bugzilla.redhat.com/show_bug.cgi?id=1824373

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-08-31 13:53:26 -04:00
Cole Robinson 34c6d1c7ea virtinst: cpu: Move topology elements to their own class
This is a no-op but will help with a future bug fix

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-08-27 19:41:28 -04:00
Cole Robinson aa89a48371 xmlutil: Centralize all 'programming error' exceptions
Raise them directly instead of adding the hard to read conditional
into the function

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-07-17 19:08:27 -04:00
Charles Arnold 837bbf2bd3 Fix check for q35 machine type
This fix could be included independent of the other patches.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
2020-07-12 14:10:24 -04:00
Cole Robinson dcab14e0b4 domain: cpu: Finish test coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Menno Lageman 0254558e6e cli: add --features kvm.hint-dedicated.state=
QEMU version 2.12.1 introduced a performance feature under commit
be7773268d98 ("target-i386: add KVM_HINTS_DEDICATED performance hint").
Support for this performance hint was added in libvirt 5.7.0 by commit
cb12c59dac04 ("qemu: support for kvm-hint-dedicated performance hint").

This patch extends virt-install's existing --features option to insert the
appropriate XML into the guest definition if this feature is specified
on the command line.

    E.g. --features='kvm.hint-dedicated.state=on' would result
    in the following XML:

      <features>
        ...
        <kvm>
          <hint-dedicated state='on'/>
        </kvm>
        ...
      </features>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
2019-09-03 14:04:18 -04:00
Athina Plaskasoviti 2e49041d85 cli: Add --clock timer[0-9]*.catchup options
Added:
-timer[0-9]*.catchup.threshold
-timer[0-9]*.catchup.slew
-timer[0-9]*.catchup.limit

Catchup attributes need timer with assigned tickpolicy=catchup.

XML Mapping:

<clock>
  ...
  <catchup threshold="X" slew="X" limit="X"/>
  ...
</clock>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-08-19 15:39:47 -04:00
Athina Plaskasoviti cc60d558c0 cli: Add --cputune memorytune options
--memorytune[0-9]*.vcpus
--memorytune[0-9]*.node[0-9]*.id
--memorytune[0-9]*.node[0-9]*.bandwidth

XML Mapping:

<cputune>
  ...
  <memorytune vcpus="X">
    <node id="X" bandwidth="X"/>
  </memorytune>
  ...
</cputune>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-08-19 15:39:47 -04:00