libguestfs: virt-make-fs fails on RISC-V

Bug #1940453 reported by Heinrich Schuchardt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libguestfs (Ubuntu)
Fix Released
Low
Graham Inggs

Bug Description

On RISC-V we have no KVM support yet.

LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1 \
virt-make-fs --partition=gpt --size=+1M --type=vfat \
directory/ file.img

fails with

/usr/bin/qemu-system-riscv64 \
    -global virtio-blk-pci.scsi=off \
    -no-user-config \
    -enable-fips \
    -nodefaults \
    -display none \
    -machine accel=kvm:tcg \
    -m 1280 \
    -no-reboot \
    -rtc driftfix=slew \
    -kernel /var/tmp/.guestfs-1000/appliance.d/kernel \
    -initrd /var/tmp/.guestfs-1000/appliance.d/initrd \
    -object rng-random,filename=/dev/urandom,id=rng0 \
    -device virtio-rng-pci,rng=rng0 \
    -device virtio-scsi-pci,id=scsi \
    -drive file=file.img,cache=writeback,format=raw,id=hd0,if=none \
    -device scsi-hd,drive=hd0 \
    -drive file=/var/tmp/.guestfs-1000/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none,format=raw \
    -device scsi-hd,drive=appliance \
    -device virtio-serial-pci \
    -serial stdio \
    -chardev socket,path=/run/user/1000/libguestfsDDkZA7/guestfsd.sock,id=channel0 \
    -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
    -append "panic=1 console=ttyS0 edd=off udevtimeout=6000 udev.event-timeout=6000 no_timer_check lpj=4000 printk.time=1 cgroup_disable=memory usbcore.nousb cryptomgr.notests tsc=reliable 8250.nr_uarts=1 root=UUID=446eed97-23e2-4547-8f1a-288406261495 selinux=0 guestfs_verbose=1 TERM=xterm-256color"
qemu-system-riscv64: -enable-fips: warning: -enable-fips is deprecated, please build QEMU with the `libgcrypt` library as the cryptography provider to enable FIPS compliance
qemu-system-riscv64: invalid accelerator kvm
qemu-system-riscv64: falling back to tcg
qemu-system-riscv64: -device virtio-rng-pci,rng=rng0: No 'PCI' bus found for device 'virtio-rng-pci'
libguestfs: error: appliance closed the connection unexpectedly, see earlier error messages
libguestfs: child_cleanup: 0x2ae5d0ae80: child process died
libguestfs: sending SIGTERM to process 74693
libguestfs: error: /usr/bin/qemu-system-riscv64 exited with error status 1, see debug messages above

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

"-machine accel=kvm:tcg \"
should be replaced by
"-machine virt \"
on architecture RISC-V.

tags: added: fr-1630
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

A change like the following could possibly fix the problem.

--- a/lib/qemu.c
+++ b/lib/qemu.c
@@ -309,7 +309,12 @@
 #ifdef MACHINE_TYPE
                            MACHINE_TYPE ","
 #endif
- "accel=kvm:tcg");
+#ifdef __riscv
+ "virt"
+#else
+ "accel=kvm:tcg"
+#endif
+ );
   guestfs_int_cmd_add_arg (cmd, "-device");

A better solution would be do detect the presence of KVM at runtime.

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

According to the QEMU documenation:

"For QEMU’s RISC-V system emulation, you must specify which board model you want to use with the -M or --machine option; there is no default."

The option accel=accels1[:accels2[:...]] identifies multiple accelerator. The first working one is chosen. So it is ok to use

    -M virt accel=kvm:tcg

for RISC-V. As KVM is not available currently QEMU will fallback to TCG.

Revision history for this message
Heinrich Schuchardt (xypron) wrote :
Revision history for this message
Heinrich Schuchardt (xypron) wrote :

libguestfs (1:1.44.1-1ubuntu8) is available in ppa:xypron/gnu-efi looking for a sponsor.

Changed in libguestfs (Ubuntu):
status: New → In Progress
Mathew Hodson (mhodson)
Changed in libguestfs (Ubuntu):
importance: Undecided → Low
Graham Inggs (ginggs)
Changed in libguestfs (Ubuntu):
assignee: nobody → Graham Inggs (ginggs)
Revision history for this message
Graham Inggs (ginggs) wrote :

Uploaded as libguestfs_1.44.1-1ubuntu6.

I suggest when uploading to a PPA to add a suffix to the version, e.g. 1.44.1-1ubuntu6~ppa1, 1.44.1-1ubuntu6~ppa2, etc. That way, you don't burn the version number you plan on uploading to the archive.

Changed in libguestfs (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libguestfs - 1:1.44.1-1ubuntu6

---------------
libguestfs (1:1.44.1-1ubuntu6) impish; urgency=medium

  * Specify board model for RISC-V (LP: #1940453)
    d/p/0001-launch-board-model-for-RISC-V.patch
  * Add missing packages to guest file system
    d/p/0001-appliance-add-missing-packages-to-package-list.patch

 -- Heinrich Schuchardt <email address hidden> Wed, 18 Aug 2021 18:33:55 +0200

Changed in libguestfs (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.