Commit Graph

2454 Commits

Author SHA1 Message Date
Cole Robinson
ec434948a8 installer: drop default TPM for --cloud-init install phase
When shim in the guest sees unpopulated EFI NVRAM, like when
we create a new UEFI VM, it invokes fallback.efi to populate
initial NVRAM boot entries. When the guest also has a TPM device,
shim will do a one time VM reset. This reset throws off the
reboot detection that is central to virt-install's install
process.

The main install case that this will usually be relevant is
the combo of UEFI and --cloud-init. The latter usually implies
use of a distro cloud image, which will be using shim, and the
--cloud-init process requires a multi stage install compared
to just a plain import install.

For that case, we disable the default TPM device for the first
boot.

https://bugzilla.redhat.com/show_bug.cgi?id=2133525

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2023-09-12 12:04:49 -04:00
Cole Robinson
0f706cf874 Fix some pylint
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2023-09-12 11:54:04 -04:00
Martin Kletzander
9f8da1f666 virt-clone: Copy disk permissions as well
When cloning using libvirt APIs the function virStorageVolCreateXMLFrom
is used.  However name and permissions are taken from the new XML [1].
By copying the permissions (only the mode is used) we can avoid some
unexpected issues.

[1] https://libvirt.org/html/libvirt-libvirt-storage.html#virStorageVolCreateXMLFrom

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2115153
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2023-09-10 11:19:31 -04:00
Laszlo Ersek
2ebbdb2797 fix indentation of multiline log.exception() invocations
Commit f107e39989 ("Switch to more traditional logging structure",
2019-06-17) replaced "logging.exception" with "log.exception", effectively
shifting the argument lists 4 characters to the left. The second and
further lines of multiline invocations were not accordingly unindented,
however, which ended up setting a suboptimal precedent as well. Unindent
those lines now.

Reported-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-08-30 10:48:54 +02:00
Laszlo Ersek
7dbe973b3f virtinst: suppress "lookup_capsinfo" exception in machine type alias check
Just to be sure, this patch implements the second approach (described in
the previous patch) as well.

Note that there is precedent for suppressing "guest_lookup" exceptions:
refer to the "Error determining machine list" branch from commit
ae7ebc220b ("details: Properly limit machine type list by guests
arch/type", 2013-09-01).

(

In fact, that branch gets activated when opening the details window for a
domain that uses a non-default emulator; the "virt-manager --debug" log
contains:

> ERROR (details:613) Error determining machine list
> Traceback (most recent call last):
>   File "virtManager/details/details.py", line 605, in _init_details
>     capsinfo = caps.guest_lookup(
>   File "virtinst/capabilities.py", line 319, in guest_lookup
>     raise ValueError(msg)
> ValueError: Host does not support domain type kvm with machine
> 'pc-q35-8.1' for virtualization type 'hvm' with architecture 'x86_64'

)

Fixes: #539
Fixes: 05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-08-29 13:24:52 +02:00
Laszlo Ersek
4ead4acb44 virtinst: delay "lookup_capsinfo" until we really need it
When I try to open the details window for a domain that does not use the
system default emulator, I get the following exception:

> Traceback (most recent call last):
>   File "virtManager/vmwindow.py", line 40, in get_instance
>     cls._instances[key] = vmmVMWindow(vm)
>   File "virtManager/vmwindow.py", line 83, in __init__
>     self._details = vmmDetails(self.vm, self.builder, self.topwin,
>   File "virtManager/details/details.py", line 389, in __init__
>     self._init_details()
>   File "virtManager/details/details.py", line 807, in _init_details
>     vmmAddHardware.build_video_combo(self.vm, video_dev)
>   File "virtManager/addhardware.py", line 816, in build_video_combo
>     default = DeviceVideo.default_model(vm.xmlobj)
>   File "virtinst/devices/video.py", line 47, in default_model
>     if (guest.lookup_domcaps().supports_video_virtio() and
>   File "virtinst/guest.py", line 656, in lookup_domcaps
>     if not self._domcaps or not _compare(self._domcaps):
>   File "virtinst/guest.py", line 646, in _compare
>     if self.os.machine and not _compare_machine(domcaps):
>   File "virtinst/guest.py", line 633, in _compare_machine
>     capsinfo = self.lookup_capsinfo()
>   File "virtinst/guest.py", line 674, in lookup_capsinfo
>     self._capsinfo = self.conn.caps.guest_lookup(
>   File "virtinst/capabilities.py", line 319, in guest_lookup
>     raise ValueError(msg)
> ValueError: Host does not support domain type kvm with machine
> 'pc-q35-8.1' for virtualization type 'hvm' with architecture 'x86_64'

This is a regression; according to git-bisect, it was introduced in commit
05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27).

"lookup_capsinfo" (and "guest_lookup" called by it) are unsuitable for
machine type alias checking (or for anything else) if the domain uses an
emulator that differs from the system default emulator. The information
returned by virConnectGetCapabilities() pertains to the system default
emulator. Thus, when using a non-default emulator, we should either not
call "lookup_capsinfo" for machine type alias checking, *or* we should
suppress the exception, and pretend that the alias check was a mismatch.

It turns out that we can avoid the "lookup_capsinfo" call (and thereby the
exception) in practice if we just delay the call until after the direct
(non-alias) comparison.

Fixes: #539
Fixes: 05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-08-29 13:24:52 +02:00
Oleg Vasilev
b2f6e95383 cloner: clone serial files
Before this, on clone the serial file would remain the same for the cloned
domain. This doesn't make much sense as the output would be an intermix of two
unrelated output sequences.

Here we apply the the same filename changing algorithm, as with disk files.

Signed-off-by: Oleg Vasilev <oleg.vasilev@virtuozzo.com>
2023-03-22 17:44:06 -04:00
Cole Robinson
5c49151df9 tests: test win11 XML generation
And drop the futureproofing workaround now that it's no longer
required

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2023-01-19 11:54:03 -05:00
Toshiki Sonoda
6ec00474a6 virtinstall: Hide total_size in the progress bar if it doesn't need
virt-install prints the total_size value to the progress bar even if it
is meaningless.
This value can be confusing to user, so for execute prosess that doesn't
copy files (total_size = 0B), we hide the total_size value.
For example, 'Creating domain...' doesn't need to print the total_size
value.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Signed-off-by: Haruka Ohata <ohata.haruka@fujitsu.com>
2022-12-14 13:18:36 -05:00
Toshiki Sonoda
39c7a44314 virtinstall: Fix the allocating disk size printed by the progress bar
When a sparse file is created during a disk allocation,
virt-install prints not the created disk size but a sparse file size.

Therefore, we fix to print the created disk size during disk allocation
instead of the size of the sparse file by updating the meter with the
self.capacity.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Signed-off-by: Haruka Ohata <ohata.haruka@fujitsu.com>
2022-12-14 13:07:26 -05:00
Cole Robinson
4114fa1aa8 progress: Fix showing correct final total
Reproducer:
Reproducer:
./virt-install --connect test:///default \
               --location tests/data/fakemedia/fake-f26-netinst.iso

Before:
Starting install...
Retrieving 'vmlinuz'                            |    0 B  00:00:00 ...
Retrieving 'initrd.img'                         |    0 B  00:00:00 ...

After:
Starting install...
Retrieving 'vmlinuz'                            |    9 B  00:00:00 ...
Retrieving 'initrd.img'                         |    9 B  00:00:00 ...

progress.end() currently only reports the total amount of bytes
that were last written to the UI. It should report the total amount
that's been passed to update().

Reported-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-14 13:01:48 -05:00
Cole Robinson
b5d6dfaa0d tests: Update to latest kvm domcaps
And add some test coverage exclusions, needed for previous patches

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-14 12:45:05 -05:00
Lin Ma
180154d752 guest: Query availability of spicevmc channels in domcaps
Signed-off-by: Lin Ma <lma@suse.com>
2022-12-14 12:44:54 -05:00
Lin Ma
8cc6ee8da3 guest: Query availability of usb redirdevs in domcaps
Signed-off-by: Lin Ma <lma@suse.com>
2022-12-14 12:44:54 -05:00
Weijia Wang
75a25e3766 tests: cpio: set owner to 0:0 2022-12-13 13:45:16 -05:00
Cole Robinson
bb1afaba29 Fix pylint/pycodestyle warnings with latest versions
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-13 11:23:45 -05:00
Lin Ma
4a2df06483 diskbackend: Drop support for sheepdog
The sheepdog project is no longer actively developed, Libvirt removed
the support for sheepdog storage backend since v8.8.0, Let's drop it.

Signed-off-by: Lin Ma <lma@suse.com>
2022-11-07 10:10:00 -05:00
Cole Robinson
15ddeae6cb cli: support --boot loader.stateless=
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-10-17 11:54:37 -04:00
Cole Robinson
1d64a678d3 virt-install: Reuse cli.fail_conflicting
For the --unattended + --cloud-init conflict

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-22 10:16:19 -04:00
Cole Robinson
999ccb85e3 virt-install: --unattended and --cloud-init conflict
Make it an explicit error, otherwise unattended is preferred and
cloud-init is ignored

https://bugzilla.redhat.com/show_bug.cgi?id=2117157

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-21 16:47:26 -04:00
Cole Robinson
b0d0516736 cloner: Sync <uuid> and <sysinfo> system uuid
Otherwise libvirt errors like:

ERROR    UUID mismatch between <uuid> and <sysinfo>

https://bugzilla.redhat.com/show_bug.cgi?id=2038040

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-21 16:21:10 -04:00
Cole Robinson
a254ece0f0 virt-install: --help required options are wrong
Nowadays it could be as simple as `virt-install --install fedora36`.

Trying to represent the interdepencies here is not worth it, but
let's keep a simple string around to avoid the default parser
usage string, which is huge

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-21 16:10:55 -04:00
Lin Ma
fbdf051626 cli: --cpu: Add maxphysaddr.{mode,bits} options
This commit added support for cpu physical address bits control, It's
useful for VMs with huge amount of ram.

E.g.
--cpu Cascadelake-Server,maxphysaddr.mode=emulate,maxphysaddr.bits=46

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-20 10:03:11 -04:00
Cole Robinson
e94786c066 virtinstall: fix regression with --boot and no install method
Anything passed to --boot should imply --install no_install=yes
in the absence of other --install options. This is historically
what we've done but we regressed in 4.1.0

Resolves: https://github.com/virt-manager/virt-manager/issues/426

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-20 09:54:01 -04:00
Cole Robinson
1cb0be4002 virtinstall: split no_install conditional apart to track code coverage
Each bit here is part of the CLI API, we need to be sure we are
covering each one. Extend the test suite to hit one case we are missing

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-20 09:47:49 -04:00
Cole Robinson
4b15073572 cli: Drop unnecessary --disk prop aliases
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-17 10:27:36 -04:00
Lin Ma
11a887ece5 cli: --disk: Add driver.metadata_cache options
Properly setting the metadata cache size can provide better performance
in case of using big qcow2 images.

This patch introduces two driver options:
* driver.metadata_cache.max_size
* driver.metadata_cache.max_size.unit

E.g. --disk ...,driver.type=qcow2,\
     driver.metadata_cache.max_size=2,\
     driver.metadata_cache.max_size.unit=MiB

BTW, Metadata cache size control is currently supported only for qcow2.
Regarding how to properly caluclate the cache size of qcow2, Please refer
to qemu's documentation.

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-17 09:57:29 -04:00
Cole Robinson
8ca7c91697 Prep for release 4.1.0
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-04 15:53:33 -04:00
Cole Robinson
5e48307e9d virtinstall: Set VM name earlier so disks are named correctly
We need to change the flow from

  * parse all the strings
  * set capabilities defaults
  * build installer
  * fill in all guest defaults

To

  * parse boot and metadata strings
  * set capabilities defaults
  * build installer
  * set --name default
  * parse all the remaining strings
  * fill in all guest defaults

Because --disk parsing depends on --name for some path generation.
So this fixes --disk names when --name is implicitly specified by
--install or --osinfo

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Cole Robinson
02e6abad48 cli: Break up parse_option_strings
Into run_parser and run_all_parsers. Opencode some of the special
case handling in virtxml

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Cole Robinson
e2dfbf9bd9 virt-xml: Simplify --build-xml parse_option_strings usage
parse_option_strings will do the right thing for us already

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Cole Robinson
bfa37d0065 xmlutil: Take unindent_device_xml from details.py
We will use this in virt-xml soon

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Cole Robinson
d2b346370a virtxml: Remove redundant listify calls
parse_option_strings always returns a list

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Charles Arnold
424283ad1d launch_security: Use SEV-ES policy=0x07 if host supports it 2022-08-03 08:47:35 -04:00
Lin Ma
2984c13cff cli: Add --iothreads defaultiothread.thread_pool_{min,max}
It allows to set the thread pool size to optimize spawning worker threads
for the default event loop in real time environment. For example:

--iothreads defaultiothread.thread_pool_min=8,\
defaultiothread.thread_pool_max=16

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-02 14:56:09 -04:00
Lin Ma
0d84bcfbfa cli: Add iothreadids attributes thread_pool_min and thread_pool_max
These two optional attributes allow setting lower and upper boundary for
number of worker threads for given IOThread. For example:

--iothreads iothreads=2,\
iothreadids.iothread0.id=1,\
iothreadids.iothread1.id=2,\
iothreadids.iothread1.thread_pool_min=8,\
iothreadids.iothread1.thread_pool_max=16

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-01 11:32:23 -04:00
Lin Ma
b8a77805b0 domain: cpu: Clear 'migratable' when changing to custom cpu
Otherwise going host-passthrough -> custom can cause libvirt validation
error due to libvirt fills the default value(migratable='on') for the
host-passthrough in domain XML.

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-01 10:11:43 -04:00
Cole Robinson
35871fe96b capabilities: Remove noisy alias debugging
our debugging output is not this fine grained, so this crowds out
more interesting messages

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-01 06:04:48 -04:00
Cole Robinson
8079c421bd connection: De-duplicate ui and cli version logging
Remove the open coded version logging in cli.py and virt-manager
connection.py, and move it into virtinst connection open

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-01 06:04:48 -04:00
Cole Robinson
aeffa4f711 guest: Check coverage for more of domcaps caching
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-07-27 18:07:05 -04:00
Daniel P. Berrangé
92ba8e5d35 virtinst: log libvirt version numbers after connecting
The various version numbers reported by libvirt are all relevant pieces
of information when debugging problem reports.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Daniel P. Berrangé
01ff867f56 virtinst: include the version number in first log message
Knowledge of the version number is not always available from the user
bug report. They may merely have a log file from an automated system.
Including the version number in the log message is key information.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Daniel P. Berrangé
b5e8e58d74 virtinst: include host capbilities in debug log
This is critical information when debugging many user problems.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Daniel P. Berrangé
fec5fd84a7 virtinst: include domain capbilities in debug log
This is critical information when debugging many user problems.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Daniel P. Berrangé
05fcc7410e virtinst: fix caching of domain capabilities
The domain capabilities XML always contains the canonical machine name.
When the selected machine type for a guest is an alias, the check
comparing it to the domain capabilities machine will always fail. This
prevents the domain capabilities result from being cached.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Cole Robinson
7ae10b5566 cli: Add --serial source.tls=on|off
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-20 18:06:40 -04:00
Cole Robinson
137cfdc347 cli: Add --serial source.channel
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-20 18:03:55 -04:00
Cole Robinson
d0e6213643 cli: Add --memorybacking allocation.threads
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-20 17:54:50 -04:00
Cole Robinson
9da917b8ac connection: Add get_libvirt_data_root_dir()
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-20 09:10:59 -04:00
Cole Robinson
48f66f27fd domcaps: armv7l doesn't support tpm-tis
Libvirt domcaps can advertise armv7l support for tpm-tis, even though
it will explicitly reject that config:

https://gitlab.com/libvirt/libvirt/-/issues/329

Work around that in domcaps. Without this, UEFI arm32 VMs generate
default configs that libvirt will reject

https://bugzilla.redhat.com/show_bug.cgi?id=2078995

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-17 13:09:39 -04:00