Commit Graph

2552 Commits

Author SHA1 Message Date
Cole Robinson
2835c250c7 virt-install: support --input none
Disables adding any default input devices

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-19 19:41:19 +01:00
Cole Robinson
c78ec96933 virt-install: let libvirt handle --input bus=default
Our logic here is poorly duplicating libvirt's postparse logic.
Notably it will try to add bus=ps2 on non-x86, and misses obscure
cases like parallels.

https://issues.redhat.com/browse/RHEL-66768

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-19 19:41:19 +01:00
Lin Ma
301423b83a virt-install: Fix the active_pcr_banks issue for TPM emulator
The commit 6baa327d added active_pcr_banks support, but put it under the child
element <tpm>, which is wrong, It should be under sub child element <backend>.

Before:
  --tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,\
      active_pcr_banks.sha1=on,\
	  active_pcr_banks.sha256=yes,\
	  active_pcr_banks.sha384=yes,\
	  active_pcr_banks.sha512=yes

  It results in the following domain xml:
    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0'/>
      <alias name='tpm0'/>
    </tpm>

After:
  --tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,\
      backend.active_pcr_banks.sha1=on,\
	  backend.active_pcr_banks.sha256=yes,\
	  backend.active_pcr_banks.sha384=yes,\
	  backend.active_pcr_banks.sha512=yes

  It results in the following domain xml:
    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0'>
        <active_pcr_banks>
          <sha1/>
          <sha256/>
          <sha384/>
          <sha512/>
        </active_pcr_banks>
      </backend>
      <alias name='tpm0'/>
    </tpm>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
fd48e0be57 virt-install: Add --tpm backend.source support
E.g.
    virt-install \
    ... \
    --tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,\
          backend.source.type=dir,backend.source.path=/some/dir

  It results in the following domain xml:
  <backend type="emulator" version="2.0">
    <source type="dir" path="/some/dir"/>
  </backend>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
7e4f7ae3d8 virt-install: Add support for 'debug' parameter on TPM emulator
E.g.
    virt-install \
    ... \
    --tpm model=tpm-tis,backend.type=emulator,backend.version=2.0,backend.debug=3

  It results in the following domain xml:
  <tpm model="tpm-tis">
    <backend type="emulator" version="2.0" debug="3"/>
  </tpm>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
1219030319 virt-install: Add support for streams attribute for 'virtio' sound card
E.g.
    virt-install \
    ... \
    --sound model=virtio,streams=4

  It results in the following domain xml:
  <sound model="virtio" streams="4"/>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
e883e7d525 virt-install: Add support for multi-channel mode for 'usb' sound card
E.g.
    virt-install \
    ... \
    --sound model=usb,multichannel=yes

  It results in the following domain xml:
  <sound model="usb" multichannel="yes"/>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
1c0f7f62e8 virt-install: Add support for blockio.discard_granularity
E.g.
    virt-install \
    ... \
    --disk /tmp/disk0.qcow2,size=16,driver.type=qcow2,blockio.discard_granularity=4096

  It results in the following domain xml:
  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2' discard='unmap'/>
    <source file='/tmp/disk0.qcow2'/>
    <target dev='vda' bus='virtio'/>
    <blockio discard_granularity="4096"/>
  </disk>

Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Lin Ma
0054b71dd7 virt-install: Fix a typo
Signed-off-by: Lin Ma <lma@suse.de>
2024-11-13 11:29:09 +01:00
Pavel Hrdina
f41deedd52 meson: add build config and its options
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 23:18:32 +01:00
Pavel Hrdina
03e35a7c29 meson: add virtinst files
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 23:18:32 +01:00
Pino Toscano
d46674b822 fix: improve translatable message
- use a single translatable message, instead of splitting the text in
  two; it helps translators to have the full context/text
- improve the language a bit

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2024-11-12 22:36:00 +01:00
Pavel Hrdina
2ce04b7cf6 virtinst.cli: replace DevicePanic.MODEL_ISA with "isa"
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 19:14:51 +01:00
Cole Robinson
c5a4664676 addhardware: panic: default to asking libvirt for default model
Drop our hardcoded model lists, and just ask libvirt to fill in
a model for us. Add an entry to the combo box so users can type
in a non-default value if they want one.

Long term libvirt should be providing all this info to us via
domcapabilities

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 09:55:20 -05:00
Cole Robinson
ebeb80073e devices: panic: let libvirt fill in model default
Currently `--panic default` for aarch64 doesn't even request
a `<panic/>` device due to quirky xmlbuilder behavior. Fix that,
but more generally just leave model empty and let libvirt fill it
in for us.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 09:44:37 -05:00
Cole Robinson
afa8231525 virt-install: add --network hostdev=HOSTDEV
This is a special convenience option for filling in `type=hostdev`
config using the same format of lookup string that can be
passed to `--hostdev`

Fixes: https://github.com/virt-manager/virt-manager/issues/500

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-11 15:30:25 -05:00
Cole Robinson
300f934cae virt-install: add --network type=hostdev,source.address.X= pci options
This just covers the common PCI case with these new options

source.address.type=
source.address.domain=
source.address.bus=
source.address.slot=
source.address.function=

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-11 14:26:47 -05:00
Cole Robinson
315b340fc4 virt-install: add --features msrs.unknown=ignore
Fixes: https://github.com/virt-manager/virt-manager/issues/570

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-11 14:13:59 -05:00
Jose
5875019b2d Update installertreemedia.py
Removing duplicated verb "be"
2024-11-11 14:27:22 +01:00
Grzegorz Szymaszek
c99b64725c man: update libvirt.org links
Fix no longer valid URL fragments, wrap at 80th column, remove dots that
follow only a few links.

Signed-off-by: Grzegorz Szymaszek <gszymaszek@short.pl>
2024-10-29 07:57:56 +01:00
Cole Robinson
8f75ac4e6e virt-install: implement --osinfo require=no as fallback name=generic
This is essentially what it has always behaved as, but making it
explicit in the code will now trigger the extra warnings when
detect=on is also used.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
e02607766c virt-install: Warn if --osinfo detect=on,name=OSNAME detection fails
Using `detect=on,name=OSNAME` is good for CI safety, incase
a new distro tree has a regression with detection, or if testing
against a new distro that osinfo-db doesn't know about.

But virt-install should still try to inform the user that detection
failed, and suggest filing a bug if the user expected it to work.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
e3da4337f6 cli: --osinfo detect=on shouldn't default to require=off
The require= behavior should be AUTO for this case, but the
way we were previously initializing variables made this OFF.
I don't think this was intentional. We should have changed
this when we started defaulting to `detect=on`

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
1487dbd200 cli: --osinfo: clean up require= handling
It's kinda hard to follow the logic here. cli require= can only be
on|off or unset, but we use an internal 'auto' value which seems
like it can come from the cli.

Try to clean it up with enum like values.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Pavel Hrdina
d4194c134b misc: codespell fixes
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-10-13 15:26:08 +02:00
Cole Robinson
a9a78f45cf installer: rename has_install_phase to requires_postboot_xml_changes
has_install_phase is an ambiguous name for its intended purpose.
Really this is so API users have a way of knowing if the VM `install`
process requires 2 XML phases or not. Make that naming explicit

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-11 14:40:03 +02:00
Cole Robinson
1c8e6f8428 virt-install: Make --cloud-init reboot by default (again)
This basically reverts this commit from virt-manager 4.0.0

```
commit 825ec644b8
Author: Cole Robinson <crobinso@redhat.com>
Date:   Tue Mar 1 10:32:01 2022 -0500

    installer: Do not force reboot with --cloud-init

    Resolves: https://github.com/virt-manager/virt-manager/issues/189
```

After that commit, using `--cloud-init` or `--unattended` would
basically imply `--noreboot`

For some usage of `--cloud-init`, like in the initial report, this
makes sense to do. virt-install will drop you into the cloud image,
you mess without, run `poweroff`, and are surprised when virt-install
reboots the VM. I agreed, and made the change

But changing this was a bad idea.

cloud-init and unattended VMs have 2 XML phases. First XML is booting
off temporary media (the generated cloudinit iso), second XML is the
permanent boot config (booting off disk). We need to force the VM
to fully poweroff, so that the second XML config takes effect. We
make that happen with `<on_reboot>destroy</on_reboot>`, which tells
libvirt/qemu to poweroff the VM when it receives a guest reboot
notification. virt-install then defaults to restarting the VM when
it detects shutdown, to manually replicate the VM requested reboot,
but still get the second XML config to take effect.

The perennial problem with this is that, from outside the VM, we
don't know if the user inside the VM requested `poweroff` or `reboot`.
virt-install emulates the reboot behavior, and provides `--noreboot`
to override it. It's still confusing if a user puts a `poweroff`
command at the end of an anaconda kickstart file, and sees the VM
reboot, but it's been that way forever.

Except with that commit above, we flipped it for --cloud-init and
--unattended. Now, users who do `poweroff` are getting expected
behavior, but users who request `reboot` are not.

We could go further and add a `--yesreboot` option or similar. But
for consistency sake I think we should just revert that behavior,
and tell users to use --noreboot like usual.

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-11 14:40:03 +02:00
Cole Robinson
51c3f1c687 virt-xml: Add --edit --convert-to-vnc
This wires up the guest.convert_to_vnc function to command line,
and documents it.

There's one suboption `qemu-vdagent=on|off`, defaulting to `off`

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
f7988a94e6 guest: convert_to_vnc: optionally add qemu-vdagent
Disabled by default, but maybe we turn it on in the future
when qemu-vdagent supports migration.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
d58299ee6b guest: convert_to_vnc: convert video device
This is mostly about stripping out spice references. All qxl devices
are converted to app defaults

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
f0078a179d guest: remove spiceport devices when spice is removed
serial/console type='spiceport' is another spice specific device,
so remove that too

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
229b905053 guest: add convert_to_vnc()
This is the beginnings of support for a `virt-xml --convert-to-vnc`
option. Take an existing VM, strip out most of the previous graphics
config, and add VNC graphics.

We try to convert over some of the shared graphic bits, like listen
and port settings, if they were previously specified.

If spice GL was enabled, we convert to egl-headless config

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
c498c519ed virt-install: Exit gracefully when VM is undefined behind our back
We still error, but don't throw a traceback.

Resolves: #455

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-08 13:40:30 -04:00
Cole Robinson
dd354e8b72 virt-xml: add --edit --convert-to-q35
Wire up guest.convert_to_q35 to the CLI. We add one suboptions,
`num_pcie_root_ports=X`, matching the pre-existing
`--controller num_pcie_root_ports=X` option

Nothing fancy here. See man page docs for details

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-03 14:20:12 -04:00
Cole Robinson
454aad78a4 guest: add convert_to_q35
This function converts a PC/i400FX XML config to Q35. Mostly
this is deleting any plain PCI addresses and controllers, adding
pcie-root-ports, convert IDE -> SATA, and let libvirt fill in
the rest.

This the implementation piece. CLI additions come later

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-03 14:20:12 -04:00
Cole Robinson
2ee2dda124 virt-xml: Fix cli_arg_name vs cli_flag_name() usage
Most of the time these strings are the same, but not when
a command line argument has a dash in it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
f66cca92a9 cli: Make --xml option parsing less special
We can make `--xml` fit the common xml cli option paradigm, which
less us drop a whole bunch of special handling in virt-xml

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
76f4599460 virtxml: Don't require options at XML action time
Adjust cli.py `run_parser` and similar functions to take the
parservalue directly, rather than passing in the whole `options`
structure.

This makes it easier to reason about what the virt-xml action
functions are actually working with.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
455b38f724 virtxml: Add Action class to track action + option pairs
This adds an Action class which is a container for (most) of the
data we need to perform a virt-xml operation. Basically an instance
of the class represents a pairing like

    --edit 1 --disk path=/foo    or
    --add-device --network wibble,model=virtio
    etc

This is a functional no-op, but it moves the code closer to
an architecture that will allow us to perform multiple actions
with a single virt-xml command.

While doing this, we centralize most of the cli validation that is
scattered around, since it's now easier to do it in one place.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
b7c72af73d virtxml: move some functions
Move the validation functions out from amongst the functional XML
editing code, and into their own section. We will be adding more
code alongside in future patches.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
de00ff7661 virt-xml: Fix --define with stdin XML
And rework the `refresh-machine-type` testcase to trigger it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-23 10:37:16 -04:00
Cole Robinson
b83a1b0d0f domain: Use KEEP_TPM flag for domain rename
If the VM has implicit TPM state, use the VIR_DOMAIN_UNDEFINE_KEEP_TPM
flag to preserve that state when renaming the VM (if libvirt is new
enough).

The state is stored based on VM UUID and nothing else, and the UUID
is preserved during rename, so we don't need to do any of the same
trickery that's required for nvram duplication.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-19 05:48:01 +02:00
Lin Ma
2d94e92d80 guest: Drop the '_' prefix for _add_q35_pcie_controllers
We will use it in domain.py as well.

Signed-off-by: Lin Ma <lma@suse.com>
2024-09-10 13:27:08 -04:00
Cole Robinson
9813dc3b4f capabilities: Exclude a line from code coverage
updated test suite capabilities XML doesn't hit this line anymore.
Just exclude it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-10 13:13:46 -04:00
Andrea Bolognani
2a52d77096 domcapabilities: Add firmware patterns for loongarch64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:56:38 -04:00
Andrea Bolognani
dc603792bf domcapabilities: Add firmware patterns for riscv64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:54:35 -04:00
Andrea Bolognani
5d5da5ff6e domcapabilities: Update comment
Fedora uses the same paths as Gerd's packages these days.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 10:54:53 +02:00
Lin Ma
4782dd1cce cli: Add --disk driver.discard_no_unref=on|off
E.g.
  virt-install \
  ... \
  --disk /tmp/disk0.qcow2,size=16,driver.type=qcow2,driver.discard=unmap,\
  driver.discard_no_unref=on

It results in the following domain xml:
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' discard='unmap' discard_no_unref='on'/>
      <source file='/tmp/disk0.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
6a65def684 cli: Add --video model.blob=on|off
Libvirt enables blob resources for the virtio video device since 9.2.0.
It accelerates the display path due to less or no copying of pixel data.

E.g.
  virt-install \
  ... \
  --video model.type=virtio,blob=on

It results in the following domain xml:

    <video>
      <model type="virtio" blob="on"/>
    </video>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
febddd4b01 cli: Add --memdev target.address_base for virtio-mem and virtio-pmem
Libvirt(since 9.4.0) allows to control this attribute for virtio-{mem,pmem}.
Now add it into virt-install.

Example:
virt-install \
--name test \
--os-variant opensusetumbleweed \
--cdrom /isos/openSUSE-Tumbleweed-DVD-x86_64-Current.iso \
--disk /vms/tw/disk0.qcow2 \
--vcpu 2 \
--cpu cell0.cpus=0,cell0.memory=4194304,\
cell1.cpus=1,cell1.memory=4194304 \
--memory maxMemory=65536,maxMemory.slots=8 \
--memdev model=virtio-mem,\
target.node=0,\
target.block=2048,\
target.size=8192,\
target.requested=2097152,\
target.address_base=0x280000000 \
--memdev model=virtio-pmem,\
source.path=/tmp/virtio_pmem,\
target.size=4096,\
target.address_base=0x480000000

It results in the following domain XML snippet:
    <memory model='virtio-mem'>
      <target>
        <size unit='KiB'>8388608</size>
        <node>0</node>
        <block unit='KiB'>2048</block>
        <requested unit='KiB'>2097152</requested>
        <current unit='KiB'>0</current>
        <address base='0x280000000'/>
      </target>
      <alias name='virtiomem0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </memory>
    <memory model='virtio-pmem' access='shared'>
      <source>
        <path>/tmp/virtio_pmem</path>
      </source>
      <target>
        <size unit='KiB'>2097152</size>
        <address base='0x480000000'/>
      </target>
      <alias name='virtiopmem0'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </memory>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00