Commit Graph

235 Commits

Author SHA1 Message Date
Cole Robinson
17f171cdb7 cli: add --network passt,portForward=8080:80 convenience syntax
Roughly mirroring `podman run -p` syntax. Examples:

--network passt,portForward=8080:80
--network passt,portForward0=7000-8000/udp,portForward1=127.0.0.1:2222:22

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-21 21:59:44 +01:00
Cole Robinson
2f8f0e8151 virt-xml: implement --edit --boot uefi=off
Disable all UEFI config bits for an existing VM

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-21 21:51:24 +01:00
Cole Robinson
cfcd63b74e virt-install: implement --boot uefi=off
Tells virt-install to not use UEFI, if it would normally default
to it.

This likely isn't too useful in practice, since all occasions we
default to UEFI require it. But it future proofs opt out in case
we ever start defaulting to UEFI in cases where BIOS still works.

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-21 21:51:24 +01:00
Cole Robinson
f3aa24bd5d virt-install: use default --cpu mode more often
Currently we will only apply the default `--cpu mode=host-passthrough`
config when _no_ `--cpu` config is passed. But this means if a user
configures ex. cpu `<topology>`, we don't set `host-passthrough` and
they get the libvirt/qemu default baseline CPU.

Instead, only skip the default config if the user manually
specified a `mode` or `model` value directly

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-19 21:21:25 +01:00
Cole Robinson
8fb78739e7 virt-clone: try harder to allow nonexisting images with --preserve
Input XML can have non-existent disk images as long as `--preserve`
is used, or those disks are skipped for any reason. We already
handle that correctly in some cases, but others we fail. This
covers another one.

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-19 21:19:25 +01:00
Cole Robinson
8eb87af411 cloner: Handle .qcow2 nvram extension
We were hardcoding .fd extension, but it can be different nowadays

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-19 21:19:25 +01:00
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
Pavel Hrdina
5126c007ec tests: update tests to reflect the latest panic device changes
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 19:15:04 +01: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
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
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
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
Andrea Bolognani
01a451e7d9 tests: Update ppc64le capabilities
The old capabilities are extremely outdated. The new ones were
captured on an IBM POWER8 machine running Fedora 40.

A few new features are advertised, and the details of the
machine are significantly different, but not much of this is
reflected in the output XML files.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:53:36 -04:00
Andrea Bolognani
38906948c6 tests: Update aarch64 capabilities
The old capabilities are extremely outdated. The new ones were
captured on an Ampere Mt. Jade machine running Fedora 40.

Notable differences that are reflected in the output XML files
include the availability of SPICE, as well as EFI firmware and
ACPI support being advertised.

The test script had to be updated too, since both virtiofs and
memfd are now available.

Closes: #714

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
Lin Ma
7a974a3a72 cli: Add --features kvm.pv-ipi.state=on|off
Set kvm pv-ipi feature by --features argument.

E.g. virt-install --features kvm.pv-ipi.state=off
It results in the following domain xml:

 <features>
   <kvm>
     <pv-ipi state='off'/>
   </kvm>
 </features>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Cole Robinson
e1798ef8ad Add missing test file
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-06 15:32:04 -04:00
Pavel Hrdina
67206a858a tests: add more test cases to cover all code paths
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
74fd503b9e virtinst: enable most Hyper-V features by default
We will not enable hyperv_reset feature as modern Hyper-V versions don't
export it.

We also don't enable hyperv_reenlightenment as it is mostly relevant
when migrating VMs that are running Hyper-V inside and requires other
bits to work correctly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
9e9dbf735c domain.features: use domcapabilities when setting default Hyper-V features
We will no longer enable hyperv features based on libvirt and QEMU
versions.

Some tests don't use the kvm-x86_64-domcaps-latest so the code will now
not enable Hyper-V features. There are still other test cases that cover
Hyper-V features so instead of mangling with URI for these tests update
test data.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
139b0e285b cli: add --features hyperv.avic.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
a06d53596b cli: add --features hyperv.evmcs.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
5afc6919c9 cli: add --features hyperv.ipi.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
e3ec248cff cli: add --features hyperv.tblflush.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
c421ec1b75 cli: add --features hyperv.reenlightenment.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
2786ea5df2 cli: add --features hyperv.frequencies.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
6289a1369b cli: add --features hyperv.stimer.direct.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
1f69795b0a cli: add --features hyperv.stimer.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
d7976a883a cli: add --features hyperv.runtime.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
d2a29245cd cli: add --features hyperv.vpindex.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
ac26945c56 domain.features: reorder Hyper-V features
Follow the table from libvirt documentation [1].

[1] <https://libvirt.org/formatdomain.html#hypervisor-features>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Cole Robinson
2da4884962 tests: Cover some weird virt-xml corner case behaviors
Examples:

`virt-xml MYVM --add-device --sound FOO1 --sound FOO2` is not rejected
and will add 2 devices.

`virt-xml MYVM --remove-device --sound opt1=FOO1 --sound opt2=FOO2`
is not rejected, only the final `--sound` option is used.

`virt-xml MYVM --edit --sound FOO1 --sound address.type=BAR` is not
rejected. The commandlines will effectively be squashed

`--sound` can be any XML option, but trying to mix and match
options like `--sound` and `--disk` is always rejected.

These bits are unexpected and undocument, but have been around since
the beginning of virt-xml.

I can see us breaking compat on these in the future (particularly the
--remove-device bit), but that would need to be an explicit decision,
and announced appropriately. In the mean time, we should be testing
this so it doesn't accidentally regress.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-08-28 21:09:31 +02:00
Cole Robinson
7e79e064ea Revert virt-xml multiple --edit support
This reverts b34ae0d0c8 and
1fef5d8661.

Playing with this some more I found some deeper problems. For example

```console
[:~/src/virt-manager] (main) $ ./virt-xml test-for-virtxml --connect test://`pwd`/tests/data/testdriver/testsuite.xml --print-diff --edit 1 --video model=FOO --edit 2 --sound model=BAR
--- Original XML
+++ Altered XML
@@ -180,14 +180,14 @@
     <graphics type="vnc" port="-1" autoport="yes">
       <listen type="address"/>
     </graphics>
-    <sound model="sb16"/>
+    <sound model="BAR"/>
     <sound model="es1370"/>
     <sound model="ich6"/>
     <video>
       <model type="vmvga" vram="16384" heads="1" primary="yes"/>
     </video>
     <video>
-      <model type="cirrus" vram="16384" heads="3"/>
+      <model type="FOO" vram="16384" heads="3"/>
     </video>
     <hostdev mode="subsystem" type="usb" managed="yes">
       <source>
```

There's other weirdness too, though it's mostly strange plays on previous weird behavior

* `--edit --video model=vga --edit --sound model=ich9 --video model=qxl` works
* `--add-device --sound model=foo --video model=bar` was previously rejected but now works
* `--remove-device --video model=vmvga --sound model=sb16` was previously rejected by now works

Fixing all this is not trivial. So I think we need to revert and go back to the drawing board.
2024-08-28 21:09:31 +02:00
Daniel P. Berrangé
97469abd8e tests: add tests for AMD SEV-SNP
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2024-08-28 14:38:40 +02:00
Pavel Hrdina
1fef5d8661 tests: add virt-xml test to demonstrate changing graphics and video at the same time
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-08-26 12:33:51 -04:00
Pavel Hrdina
b34ae0d0c8 virt-xml: allow multiple --edit options
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-08-26 12:33:51 -04:00
Pavel Hrdina
093d58fbc8 virtinst: add/remove spice devices when updating graphics type
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-08-26 12:33:51 -04:00
Pavel Hrdina
aaf8551914 virtinst: remove spice devices when removing last spice graphics
When Spice graphics is used QEMU creates a Spice server and communicates
with Spice client using multiple channels. These channels are used by
the spice devices as well. Without the Spice graphics defined there is
no use for the other devices. In addition libvirt will report error for
such configuration.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-08-26 12:33:51 -04:00