NetBSD Problem Report #56368

From www@netbsd.org  Tue Aug 17 21:00:17 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 520B81A921F
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 17 Aug 2021 21:00:17 +0000 (UTC)
Message-Id: <20210817210016.2DD101A9239@mollari.NetBSD.org>
Date: Tue, 17 Aug 2021 21:00:16 +0000 (UTC)
From: dev@iotib.net
Reply-To: dev@iotib.net
To: gnats-bugs@NetBSD.org
Subject: Using if=virtio,cache=none causes device to fail to read until reboot
X-Send-Pr-Version: www-1.0

>Number:         56368
>Category:       misc
>Synopsis:       Using if=virtio,cache=none causes device to fail to read until reboot
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 17 21:05:00 +0000 2021
>Originator:     Charadon
>Release:        9.2
>Organization:
none
>Environment:
NetBSD localhost 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Passing a raw device into qemu using the following:
-drive file=/dev/rwd1,if=none,id=hd0,format=raw

However, if this works the same way as it does on linux, this leads to very bad disk performance. So if I use this:

-drive file=/dev/rwd1,if=virtio,id=hd0,format=raw,cache=none
======================
This leads to an error where the raw device will no longer be readable until reboot is done. Reading times out with this error:

wd1d: device timeout reading fsbn 0 of 0-7 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 0
wd1: soft error (corrected) xfer 38
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 0
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 1
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 2
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 3
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), xfer 38, retry 4
wd1d: device timeout reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0)
======================
And until you reboot, even if you revert the qemu launch options to the ones that work, it will not read.

Here's my full QEMU command:
qemu-system-x86_64 -accel nvmm \
-cpu max -smp cpus=4 -m 6G \
-object rng-random,filename=/dev/urandom,id=viornd0 \
-device virtio-rng-pci,rng=viornd0 \
-drive file=/dev/rwd1,if=virtio,id=hd0,format=raw,cache=none \
-device virtio-blk-pci,drive=hd0 \
-display curses \
#-vga vmware \
-usb -device usb-mouse,bus=usb-bus.0 \
-netdev tap,id=tap0,ifname=tap0,script=no -device virtio-net-pci,netdev=tap0

What i've tried and didn't work:
- Removing: -device virtio-blk-pci,drive=hd0
- Trying if=virtio from boot up (before trying the options that work)
- Use /dev/wd1 instead of /dev/rwd1 (qemu forces /dev/rwd1)

Sidenote: I didn't know what kind of issue this is, so I put it under misc.
>How-To-Repeat:
- Have a 2nd storage device
- Install QEMU
- Load NVMM Module
- Run QEMU with launch option: -drive file=/dev/rwd1,if=virtio,id=hd0,format=raw,cache=none
- Device will fail to run.
>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.