93 Commits

Author SHA1 Message Date
Richard W.M. Jones
2b00025238 -o kubevirt: Create a VirtualMachine instead of a VirtualMachineInstance
VMs converted by virt-v2v are pets not cattle so we want to create
permanent non-running machines.  (They may later or even soon
afterwards be started up by some other tool, at which point they also
become Instances.)  Therefore use a different kind and slightly
restructure the yaml around this.

Thanks: Lee Yarwood
2024-07-11 12:14:21 +01:00
Richard W.M. Jones
e0d79e9a2e -o kubevirt: Add metadata labels
Add various information which we have but cannot add to the Kubevirt
yaml in any other place.

Example output:

...
metadata:
  name: fedora-39
  labels:
    libguestfs.org/virt-v2v-version: "2.5.4"
    libguestfs.org/osinfo: fedora39
...

Thanks: Bella Khizgiyaev, Liran Rotenberg
Fixes: https://issues.redhat.com/browse/RHEL-45992
2024-07-11 12:14:21 +01:00
Richard W.M. Jones
a659b334f5 tests/test-v2v-o-kubevirt-windows.sh: Set fake virtio-win
When converting this phony Windows guest we didn't set the VIRTIO_WIN
environment variable.  As a result the test output could change (and
break) depending on if the virtio-win package was installed or not.

Point VIRTIO_WIN to the fake virtio-win directory (as we do with other
Windows tests).  We also need to modify the test output since the fake
virtio-win does contain enough for virt-v2v to think that virtio
driver installation was successful.

Fixes: commit af1f7b571fb21fdbfa2974ee54a22b4fdcbc886a
2024-03-15 11:38:39 +00:00
Richard W.M. Jones
ce67e6e66f tests: Don't rebuild real_guests_scripts after clean
Move this rule to 'make distclean' so we don't rebuild these scripts
all the time.  It's not necessary as they hardly ever change.
2024-03-12 09:56:55 +00:00
Richard W.M. Jones
7845d21c65 tests: Fix EXTRA_DIST
Fixes: commit af1f7b571fb21fdbfa2974ee54a22b4fdcbc886a
2024-03-12 09:51:33 +00:00
Richard W.M. Jones
53c9177a78 -o kubevirt: Use virtio-transitional for ancient guests 2024-03-11 16:04:29 +00:00
Richard W.M. Jones
eee069f8da -o kubevirt: Add network interfaces to output 2024-03-11 15:49:12 +00:00
Richard W.M. Jones
81e0c33c84 -o kubevirt: Add CPU model & topology when available
See: https://kubevirt.io/user-guide/virtual_machines/templates/
See: https://kubevirt.io/api-reference/v1.2.0/definitions.html#_v1_cpu
2024-03-11 15:49:09 +00:00
Richard W.M. Jones
af1f7b571f tests: -o kubevirt: Split up test into Fedora and Windows variants
The existing test used a phony Windows image, but this has some
shortcomings including not testing any virtio paths.  Add a second
test of a phony Fedora image to get a little more coverage.
2024-03-11 15:47:09 +00:00
Richard W.M. Jones
4f16fec063 -o kubevirt: Add os firmware field in output
Fixes: https://github.com/libguestfs/virt-v2v/issues/45
Fixes: https://issues.redhat.com/browse/RHEL-28197
2024-03-11 11:32:11 +00:00
Richard W.M. Jones
9711492dc2 tests: Add test for -o kubevirt mode 2024-03-11 11:18:11 +00:00
Richard W.M. Jones
01a6f36862 tests: Test new --key all:SELECTOR option 2023-12-07 16:48:17 +00:00
Richard W.M. Jones
41c4fed5c7 tests: Fix network tests for newer libvirt
The old tests' network bridge had a bogus <mac address="00:00:00:00:00:00">.

Older libvirt appeared to drop this completely.  Newer libvirt appears
to rewrite it as a valid MAC, eg. <mac address="52:54:00:xx:xx:xx">
(for some randomly chosen "xx"'s).  To make the tests stable, replace
the old bogus value with a valid value, and update the tests to check
for it.
2023-11-02 11:02:47 +00:00
Richard W.M. Jones
5f58def90a convert: Find out if Windows guest is expecting RTC set to UTC
Read HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation key
"RealTimeIsUniversal" to see if the Windows guest is expecting RTC
set to localtime (not present) or UTC (present and set to 1).

See: https://wiki.archlinux.org/title/System_time#UTC_in_Microsoft_Windows
See: https://listman.redhat.com/archives/libguestfs/2023-September/thread.html#32556
Reported-by: Lee Garrett
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-09-25 17:21:00 +01:00
Richard W.M. Jones
93b86b8634 -o libvirt: Add <clock offset="utc|localtime"/> to libvirt XML
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-09-25 17:21:00 +01:00
Laszlo Ersek
3060af01e8 LUKS-on-LVM conversion test: test /dev/mapper/VG-LV translation
In the LUKS-on-LVM conversion test, repeat the null conversion with such
"--key" options that exercise the recent "/dev/mapper/VG-LV" ->
"/dev/VG/LV" translation (unescaping) from libguestfs-common.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230515175529.290724-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-19 11:37:17 +02:00
Laszlo Ersek
0ecbe09c09 LUKS-on-LVM conversion test: rename VGs and LVs
In preparation for a subsequent patch, rename "VG" to "Volume-Group", and
"LV<n>" to "Logical-Volume-<n>", in the LUKS-on-LVM conversion test.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230515175529.290724-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-05-19 11:36:07 +02:00
Andrey Drobyshev
94b249b6e5 tests: add --block-driver option test
The test checks that the newly introduced --block-driver option doesn't
break conversion.  Basically its logic somewhat repeats test-v2v-i-disk.sh
and test-v2v-in-place.sh, but with the new option being set.

The checks it performs are:

 1. Run disk-sourced conversion (-i disk) based on the phony windows.img
    and check that it completes (i.e. produces converted disk and
    corresponding domain XML;
 2. Run libvirt-sourced in-place conversion based on an XML with virtio
    vda disk specified (virtio-blk case) and check that the resulting
    image has the phony viostor driver installed.
 3. Run libvirt-sourced in-place conversion based on an XML with scsi
    sda disk specified (virtio-scsi case) and check that the resulting
    image has the phony vioscsi driver installed.

Note that the latter 2 cases aren't really comprehensive as v2v actually
copies all the drivers present in $VIRTIO_WIN, regardless of the block
driver specified. The real difference comes from the PCI ID values written
into the registry. But since we can't test real Windows and evaluate
those values, we're doing the best we can here, i.e. testing that conversion
doesn't break and drivers are still present with --block-driver option
being set explicitly.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Message-Id: <20230310175433.781335-7-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-03-14 13:56:38 +01:00
Richard W.M. Jones
83a6400aea -o libvirt: Always use host-model unless overridden by source hypervisor
In the case where the source hypervisor doesn't specify a CPU model,
previously we chose qemu64 (qemu's most basic model), except for a few
guests that we know won't work on qemu64, eg. RHEL 9 requires
x86_64-v2 where we use <cpu mode='host-model'/>

However we recently encountered an obscure KVM bug related to this
(https://bugzilla.redhat.com/show_bug.cgi?id=2168082).  Windows 11
thinks the qemu64 CPU model when booted on real AMD Milan is an AMD
Phenom and tried to apply an ancient erratum to it.  Since KVM didn't
emulate the correct MSRs for this it caused the guest to fail to boot.

After discussion upstream we can't see any reason not to give all
guests host-model.  This should fix the bug above and also generally
improve performance by allowing the guest to exploit all host
features.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2168082#c19
Related: https://listman.redhat.com/archives/libguestfs/2023-February/030624.html
Thanks: Laszlo Ersek, Dr. David Alan Gilbert, Daniel Berrangé
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-02-20 11:10:12 +00:00
Laszlo Ersek
224243b8e2 test-v2v-i-ova: spell out ntfs feature group dependency
"windows.img" is created as an empty phony image if the libguestfs
appliance lacks the ntfs feature group.

"tests/Makefile.am" deals well with this, because for the "central"
"windows.vmdk" target, we restrict the VMDK conversion to a non-empty
"windows.img". Subsequently, dependent test cases check for "windows.vmdk"
specifically, and if that file is missing, the tests are skipped (they
exit with code 77).

"test-v2v-i-ova.sh" and "test-v2v-i-ova-directory.sh" are exceptions
however. They perform the same conversion manually (in their own separate
workspace directories). They assume that, if "windows.img" exists, it can
be converted to VMDK. When the image size is zero, the conversion breaks,
and both test cases fail. Skip both tests if "windows.img" is empty.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: replace further occurrences of windows.img with $f]
2023-01-13 10:45:35 +01:00
Laszlo Ersek
0198097947 test-v2v-fedora-btrfs-conversion: spell out btrfs feature group dependency
In case the libguestfs appliance lacks the btrfs feature group, we create
a zero-sized phony Fedora/BTRFS image variant, causing this test case to
fail. In that situation, the test should just be skipped.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2023-01-13 10:45:19 +01:00
Richard W.M. Jones
e2f35826a9 tests: Update guest versions for slow tests
Test Fedora 37 (up from 35) and RHEL 8.7 (up from 8.4).  In particular
the virt-builder RHEL 8.4 template's repository URLs no longer work so
it could not be tested.
2022-11-26 15:25:33 +00:00
Richard W.M. Jones
0805ea9379 New virt-v2v-inspector tool
This tool can be used to estimate the disk space needed before doing a
virt-v2v conversion.  It is a replacement for the old --print-estimate
option which was dropped in virt-v2v 2.0 (commit 5828c9c7d5 "v2v:
Remove --print-estimate option").

In Kubernetes and tools like Kubevirt, it's not possible to create
some disks and attach to them (in order to populate them with data) in
one step.  This makes virt-v2v conversions awkward because ideally we
would like the output mode (-o kubevirt) to both create the target
disks and populate them at the same time.

To work around this problem, we need a tool which can inspect the
virt-v2v source hypervisor before we do the conversion in order to
find out how many disks are needed and their sizes.  Then we can
create the target disks, and then we can run a second container with
virt-v2v attached to the disks to do the conversion and populate the
output.

This new tool essentially uses the same -i* options as virt-v2v (and
no -o* options) and outputs various useful metadata.  Example:

  $ virt-v2v-inspector --quiet -i disk fedora-32.img
  virt-v2v-inspector: The QEMU Guest Agent will be installed for this guest
at first boot.
  virt-v2v-inspector: warning: /files/boot/grub2/device.map/hd0 references
unknown device "vda".  You may have to fix this entry manually after
conversion.
  <?xml version='1.0' encoding='utf-8'?>
  <v2v-inspection>
    <!-- generated by virt-v2v-inspector 2.1.9local,libvirt -->
    <program>virt-v2v-inspector</program>
    <package>virt-v2v</package>
    <version>2.1.9</version>
    <disks>
      <disk index='0'>
        <virtual-size>6442450944</virtual-size>
        <allocated estimated='true'>1400897536</allocated>
      </disk>
    </disks>
    <operatingsystem>
      <name>linux</name>
      <distro>fedora</distro>
      <osinfo>fedora32</osinfo>
      <arch>x86_64</arch>
      <major_version>32</major_version>
      <minor_version>0</minor_version>
      <package_format>rpm</package_format>
      <package_management>dnf</package_management>
      <product_name>Fedora 32 (Thirty Two)</product_name>
    </operatingsystem>
  </v2v-inspection>

There should be sufficient information in the <disks> section to
allocate target disks, plus additional information is printed which
might be useful.

Note that we do a full conversion in order to generate this
information.  In particular it's not possible to generate the
<allocated/> estimate without this.  It's plausible we could have a
--no-convert option, but I'm not sure it's worthwhile: it would only
save a little time, but would make everything less accurate, plus
maybe it is a good idea to find out if conversion is going to work
before we create the target disks?

I chose XML instead of JSON for output.  XML allows us to annotate
elements with attributes like "estimated='true'".  It also lets us
represent 64 bit number accurately, where JSON cannot represent such
numbers.

The output can be written to stdout (the default, or you can use "-O -"),
but for use from another program it is usually better to write the
output to a file using "-O output.xml".

Acked-by: Laszlo Ersek <lersek at redhat.com>
2022-11-26 14:58:26 +00:00
Richard W.M. Jones
7505750972 tests: Add a simple test of -o local -of qcow2 -oo compressed
This only tests that it doesn't completely fail, which it did before
we fixed nbdcopy.  I checked the file sizes manually and with
compression the resulting file is about half the size.

This test is a clone of tests/test-v2v-of-option.sh.  In order to
compare the sizes across the two tests, and to keep the tests fairly
similar I added an ls -l command to the original test.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-07-05 10:50:18 +01:00
Laszlo Ersek
e4efe4b7d2 tests: add LUKS-on-LVM test
Port guestfs-tools commit 27da4b0c4991 ("inspector: add LUKS-on-LVM test",
2022-02-28) to virt-v2v. While at it, account for virt-v2v commit
fd7cd0c0fd22 ("test-data/phony-guests: Increase size of root filesystem",
2022-06-08).

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220614112709.12210-4-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-06-14 15:37:04 +02:00
Laszlo Ersek
a2ff864d93 tests: rename "luks" to "lvm-on-luks"
Clarify that our current usage of "luks" stands for "lvm-on-luks" (IOW,
that the decrypted LUKS devices are Physical Volumes for LVM).

(This is a port of libguestfs patch 'tests: rename "luks" to
"lvm-on-luks"' -- commit 39a5bb6fda4d. See also guestfs-tools commit
8f2bbc3d50d8 -- 'inspector: rename "luks" to "lvm-on-luks"', 2022-02-28.)

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220614112709.12210-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-06-14 15:36:58 +02:00
Laszlo Ersek
48c6ea27c5 output/create_libvirt_xml: wire up the QEMU guest agent
The intent (even before RHBZ#2028764) has been to install the QEMU guest
agent in the converted domain unconditionally. Therefore, in order for the
GA to be actually accessible from the host side, augment the libvirt
output module with a "guest agent connection" also unconditionally.

For starters, the domain needs a virtio-serial device. Then there must be
a port on the device that (in the guest) the GA identifies by name, and
that (on the host) is exposed as a listening socket (usually in the unix
address family). The adress of that port (usually a pathname, i.e., for a
unix domain socket) is then passed to whatever host-side application wants
to talk to the GA.

The minimal domain XML fragment for that ("minimal" for our purposes) is

  <controller type='virtio-serial' model='virtio'>
  <channel type='unix'>
    <target type='virtio' name='org.qemu.guest_agent.0'/>
  </channel>

The "controller" element is needed because "controller/@model" is where we
regulate "virtio" vs. "virtio-transitional".

Everything else is filled in by libvirt. Notably, libvirt (a) creates and
binds the unix domain socket itself (usually
"/var/lib/libvirt/qemu/channel/target/DOMAIN/org.qemu.guest_agent.0"), (b)
passes the file descriptor to QEMU, and (c) figures out the socket
pathname for commands such as

  virsh domfsinfo DOMAIN
  virsh domhostname DOMAIN --source agent
  virsh domifaddr DOMAIN --source agent
  virsh guestinfo DOMAIN

For QEMU, the corresponding options would be

  -chardev socket,id=agent,server=on,wait=off,path=/tmp/DOMAIN-agent \
  -device virtio-serial-pci,id=vioserial \
  -device virtserialport,bus=vioserial.0,nr=1,chardev=agent,name=org.qemu.guest_agent.0 \

Note the "path=/tmp/DOMAIN-agent" property of "-chardev"; virt-v2v would
have to generate that (in place of the "fd=nnnn" property that libvirt
passes to QEMU).

Omit extending the QEMU output module for now, as the QGA protocol is
based on JSON, and one needs "virsh" or "virt-manager" (or another
management application interface) anyway, for efficiently exchanging
messages with QGA. I don't know of end-user tools that directly connect to
"/tmp/DOMAIN-agent".

Don't modify the RHV and OpenStack outputs either; both of these
management products likely configure the virtio-serial device
automatically, for the agent access.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220613170135.12557-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
2022-06-14 08:34:34 +02:00
Richard W.M. Jones
3600f81ec5 tests: Add test cases for converting the phony Fedora images
As well as testing a full Fedora conversion which was not really
tested properly before, this also adds tests of conversions of Btrfs,
RAID and LUKS guests.
2022-06-09 09:16:19 +01:00
Laszlo Ersek
0c24fc6015 adopt inversion of SELinux relabeling in virt-customize
Remove "--selinux-relabel" options.

Do not add any "--no-selinux-relabel" options; rely on the internal check
for SELinux support instead ("is_selinux_guest" in
"common/mlcustomize/SELinux_relabel.ml").

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1554735
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2075718
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220510105307.15402-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: incorporate common submodule update]
2022-05-11 05:37:25 +02:00
Richard W.M. Jones
728009b307 tests: Add new test cases test-v2v-i-vmx-7.* to EXTRA_DIST
Fixes: commit e7539dc6f6d1debb1919f54ef44219142a747042
2022-04-26 10:34:09 +01:00
Laszlo Ersek
e7539dc6f6 input: -i vmx: Add support for SATA hard disks
See also:

- virt-v2v commit 75872bf282d7 ("input: -i vmx: Add support for NVMe
  devices", 2022-04-08),

- libvirt commit 2214fe90442c ("vmx: start parsing SATA disks",
  2020-10-14).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1883802
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220419152415.13356-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-04-21 16:06:43 +02:00
Tomáš Golembiovský
291edb363e -o rhv-upload: wait for VM creation task
oVirt API call for VM creation finishes before the VM is actually
created. Entities may be still locked after virt-v2v terminates and if
user tries to perform (scripted) actions after virt-v2v those operations
may fail. To prevent this it is useful to monitor the task and wait for
the completion. This will also help to prevent some corner case
scenarios (that would be difficult to debug) when the VM creation job
fails after virt-v2v already termintates with success.

Thanks: Nir Soffer
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1985827
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Arik Hadas <ahadas@redhat.com>
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
2022-04-20 17:36:56 +01:00
Richard W.M. Jones
2f6ce86474 tests: Add NVMe test cases to EXTRA_DIST
Found by running make dist && make maintainer-check-extra-dist

Fixes: commit 75872bf282d7f2322110caca70963717b43806b1
2022-04-12 11:50:40 +01:00
Richard W.M. Jones
4e6b389b4e output: Remove -o json mode
This removes the -o json mode completely.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-04-11 12:09:33 +01:00
Richard W.M. Jones
75872bf282 input: -i vmx: Add support for NVMe devices
We model NVMe devices in the source hypervisor.

We currently assume that no one is using the namespaces feature of
NVMe, ie. that each source device will appear in a Linux guest as
/dev/nvme0n1, /dev/nvme1n1, etc.  We could fix this if it is a
problem, but it requires adjusting the current assumption for
removable devices that slots are simple integers.

The devices are mapped to virtio-blk, so in the target the device name
has to change from /dev/nvme0 to /dev/vda (etc.)

Reported-by: Ming Xie
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2070530
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-04-08 16:24:38 +01:00
Richard W.M. Jones
2b27652013 Add in-place support back to virt-v2v
Add a new front end called virt-v2v-in-place which implements simple
in-place conversion support for local disks.

Commit 255722cbf3 ("v2v: Modular virt-v2v") temporarily dropped this
feature.  This commit adds it back.
2022-03-10 15:11:53 +00:00
Richard W.M. Jones
19cc458328 -o rhv-upload: Replace -oo rhv-direct with -oo rhv-proxy
This simply replaces the existing -oo rhv-direct option with a new -oo
rhv-proxy option.  Note that using this option "bare" (ie. just “-oo
rhv-proxy”) does nothing in the current commit because the default is
still to use the proxy.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2033096
Thanks: Nir Soffer
2022-02-15 17:55:20 +00:00
Laszlo Ersek
cacedec640 convert/convert_windows: consult "best driver"'s dev list for virtio-1.0
Life would be too simple if we could just call osinfo_os_get_all_devices()
for determining virtio-1.0 support for Windows guests. Now that we've
extracted the libosinfo logic that identifies the "best" virtio driver
(for copying its files into the guest), fetch the list of devices
supported by the same "best driver" as well. Use that list, in addition to
the one from osinfo_os_get_all_devices(), for determining (Q35 and)
virtio-1.0 support.

Thankfully this mess is not needed when converting Linux guests.

With this, we need to revert the data for three Windows-based test cases
to their pre-f0cea012d018 status (modulo intermediary commits 4f6b143c1cb3
("output: -o libvirt, qemu: Use correct device name for vsock",
2022-01-20) and 4c3d0b8b3b4b ("output: -o libvirt: Fix <graphics/> element
port/autoport", 2022-01-20)). The reason is that those tests all set the
VIRTIO_WIN environment variable, in which case we simply assume
"virtio_1_0 = true" on the fallback ("Not_found" exception) branch.

Fixes: f0cea012d0183edf6f7b769c28d5038593f3fe6a
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220201123219.9317-8-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-02-01 15:12:40 +01:00
Richard W.M. Jones
26361e0350 tests/test-v2v-trim.sh: Use -of qcow2 to preserve output format
Old virt-v2v used the same output format as input format when doing
disk to disk copies.  Modular virt-v2v doesn't do this, it requires
using -of to set the output format to the same as the input format if
that is desired.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:43:34 +00:00
Richard W.M. Jones
0ec1a0ef2e tests: Don't use virt-builder --update when testing Windows conversions
The error was:

virt-builder: error: cannot use ‘--update’ because no package manager
has been detected for this guest OS.

If this guest OS is a common one with ordinary package management then this
may have been caused by a failure of libguestfs inspection.

For OSes such as Windows that lack package management, this is not
possible.  Try using one of the ‘--firstboot*’ flags instead (described
in the manual).

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:43:34 +00:00
Richard W.M. Jones
c2702313af tests: Drop old and add newer RHEL versions to the tests
Let's try to test only the latest versions of RHEL that we have in the
internal (to Red Hat) virt-builder repository.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
[Laszlo reviewed an earlier version of this patch.  I updated it with
a more consistent rationale and list of RHEL versions]
2022-01-20 12:43:25 +00:00
Richard W.M. Jones
0b76aca004 tests: Drop ancient Ubuntu versions, add Ubuntu 20.04 LTS
Ubuntu 14.04 failed in the --update command.  These versions are out
of standard support (5 years) so drop them from testing.  Add Ubuntu 20.04.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:40:29 +00:00
Richard W.M. Jones
ea6a9a814e tests: Drop test of centos-6
The image cannot be updated, see error below.  In any case we are
testing a RHEL 6 image so it is not really necessary to continue to
test CentOS 6.

Loaded plugins: fastestmirror, security
Setting up Update Process
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
virt-builder: error: yum -y update: command exited with an error

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:40:26 +00:00
Richard W.M. Jones
5b82ed2598 tests: Drop some obsolete Fedora versions, start testing F35
For very old Fedora versions, it's no longer possible to download the
packages (required by virt-builder --update).  We get this error:

Error: Cannot retrieve metalink for repository: fedora/20/x86_64. Please verify its path and try again

I also dropped Fedora 23 and 29.  Although those can be updated, it's
not really worth testing long-obsolete versions of Fedora.  More
useful is testing the long-term stable equivalents (ie. CentOS and
RHEL).

I did however add the current version of Fedora (35) because it's
worth testing that current Fedora conversions work.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:40:22 +00:00
Richard W.M. Jones
4f6b143c1c output: -o libvirt, qemu: Use correct device name for vsock
According to https://libvirt.org/formatdomain.html#vsock it's <vsock/>
not <viosock/>.  There is also no model="none", we just omit it if not
present.

According to https://wiki.qemu.org/Features/VirtioVsock the qemu
parameter is -device vhost-vsock-pci.

Fixes: 05f780c16f0135c657615520c2245b42de1efc3e
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:40:18 +00:00
Richard W.M. Jones
4c3d0b8b3b output: -o libvirt: Fix <graphics/> element port/autoport
According to https://libvirt.org/formatdomain.html only vnc and sdl
graphics types support port/autoport.

In addition, autoport='yes' is the non-deprecated replacement for
port='-1'.  Since we don't need to support ancient libvirt, we don't
need to keep adding port='-1' in the autoport case.  virt-xml-validate
rejects our XML if it has both attributes.

Thanks: Martin Kletzander
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:40:15 +00:00
Richard W.M. Jones
924aa8b70a Restore message about setting up the input and output
Old virt-v2v would print a summary of the input and output options
before connecting to the input/output, looking something like this:

  [   0.2] Opening the source -i libvirt -ic [etc]

This gave reassurance that virt-v2v was doing something in the case
where the source was slow or unreachable.  In particular if you use
-i libvirt with a vCenter URL, and the URL is wrong, libvirt hangs for
a few minutes without printing anything.

Modular virt-v2v rearranged things so the connecting phase was silent,
which meant that in the case above virt-v2v appeared to hang for a few
minutes printing nothing at all.

This change adds to_string functions to all the input and output
methods and uses them to print a message like:

  [   0.0] Setting up the source: -i libvirt -ic [etc]

The hang still happens, but at least it's now clear where it's hanging.

Note the old "Opening the source" message now refers to libguestfs
connecting to the NBD source disk pipeline.

Typical full output looks like this:

  $ virt-v2v -i disk /var/tmp/fedora-35.img -o disk -os /var/tmp/out
  [   0.0] Setting up the source: -i disk /var/tmp/fedora-35.img
  [   1.1] Opening the source
  [   5.9] Inspecting the source
  [  11.5] Checking for sufficient free disk space in the guest
  [  11.5] Converting Fedora Linux 35 (Thirty Five) to run on KVM
  virt-v2v: warning: /files/boot/grub2/device.map/hd0 references unknown
  device "vda".  You may have to fix this entry manually after conversion.
  virt-v2v: This guest has virtio drivers installed.
  [  57.4] Mapping filesystem data to avoid copying unused and blank areas
  [  61.0] Closing the overlay
  [  61.7] Assigning disks to buses
  [  61.7] Checking if the guest needs BIOS or UEFI to boot
  [  61.7] Setting up the destination: -o disk -os /var/tmp/out
  [  62.8] Copying disk 1/1
  █ 100% [****************************************]
  [  81.7] Creating output metadata
  [  81.7] Finishing off

Reported-by: Xiaodai Wang
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2041886
Fixes: commit 255722cbf39afc0b012e2ac00d16fa6ba2f8c21f
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-19 15:26:28 +00:00
Laszlo Ersek
f0cea012d0 convert: determine machine type and virtio-1.0 from osinfo for x86 guests
Determine the machine type and virtio-1.0 support from osinfo, for x86
guests. This connects the previous two parts of this series.

Keep the original logic from commit ac39fa292c31 ("v2v: Set machine type
explicitly for outputs which support it (RHBZ#1581428).", 2020-12-04) for
non-x86 guests, and for the case when libosinfo does not recognize the
guest OS.

Update the "cdrom", "floppy", and "i-ova" test cases, which all use a
(phony) Windows 7 image -- Windows 7 does not support virtio-1.0-only
devices, according to libosinfo.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1942325
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220106140910.13695-10-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-01-07 12:29:21 +01:00
Laszlo Ersek
07b12fe99f output_rhv: restrict block status collection to the old RHV output
Nir reports that, despite the comment we removed in commit a2a4f7a09996,
we generally cannot access the output NBD servers in the finalization
stage. In particular, in the "rhv_upload_finalize" function
[output/output_rhv_upload.ml], the output disks are disconnected before
"create_ovf" is called.

Consequently, the "get_disk_allocated" call in the "create_ovf" ->
"add_disks" -> "get_disk_allocated" chain fails.

Rich suggests that we explicitly restrict the "get_disk_allocated" call
with a new optional boolean parameter to the one output plugin that really
needs it, namely the old RHV one.

Accordingly, revert the VDSM test case to its state at (a2a4f7a09996^).

Cc: Nir Soffer <nsoffer@redhat.com>
Fixes: a2a4f7a09996a5e66d027d0d9692e083eb0a8128
Reported-by: Nir Soffer <nsoffer@redhat.com>
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034240
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211220135640.12436-1-lersek@redhat.com>
Tested-by: Nir Soffer <nsoffer@redhat.com>
[lersek@redhat.com: drop parens around condition in "if"; thanks: Rich]
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-22 10:25:39 +01:00
Laszlo Ersek
eb7af78bea convert_linux: translate the first CD-ROM's references in boot conf files
If the only CD-ROM in "s_removables" is on an IDE controller, and the
guest kernel represents it with a /dev/hdX device node, then convert
references to this device node, in the boot config files, to /dev/cdrom.
On the destination (after conversion), /dev/cdrom will point to whataver
node we converted the CD-ROM to, masking a potential i440fx -> q35 (IDE ->
SATA) board change.

If the only CD-ROM is not on an IDE controller, or the guest is modern
enough to represent the IDE CD-ROM as /dev/sr0, then perform no
translation. Namely, /dev/sr0 survives a potential i440fx -> q35 (IDE ->
SATA) board change intact.

When multiple CD-ROMs exist, emit a warning, and attempt the conversion on
the first CD-ROM, as a guess. This may be inexact, but we can't do better,
because:

- SATA, SCSI, and (on modern guests) IDE CD-ROMs are lumped together in
  the /dev/sr* namespace, on the source side, and "s_removable_slot" is
  useless for telling them apart, as we don't know the exact controller
  topology (and OS enumeration order);

- after conversion: some OSes don't create /dev/cdrom* symlinks to all
  CD-ROMs, and even if multiple such symlinks are created, their order is
  basically random.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1637857
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211215153153.13468-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-17 13:25:10 +01:00