From: Rob Landley <rob@landley.net>
To: "Alex Bennée" <alex.bennee@linaro.org>,
"Stafford Horne" <shorne@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Linux OpenRISC <linux-openrisc@vger.kernel.org>
Subject: Re: or1k -M virt -hda and net.
Date: Tue, 7 Jan 2025 17:20:56 -0600 [thread overview]
Message-ID: <e2f1c14c-f5d2-48f3-bb6e-d1db0ce6d1fa@landley.net> (raw)
In-Reply-To: <87y0zmbita.fsf@draig.linaro.org>
On 1/7/25 12:05, Alex Bennée wrote:
> Stafford Horne <shorne@gmail.com> writes:
>> I have not used -hda before, do you have it working with other targets?
>>
>> According to the qemu docs in qemu-options.hx. I see:
>>
>> Use file as hard disk 0, 1, 2 or 3 image on the default bus of the
>> emulated machine (this is for example the IDE bus on most x86 machines,
>> but it can also be SCSI, virtio or something else on other target
>> architectures). See also the :ref:`disk images` chapter in the System
>> Emulation Users Guide.
>>
>> I think, since we don't have a "default" bus in openrisc this doesn't work so we
>> need to specify the -drive explictly.
>>
>> I checked the x86 machine code and confirm it seems to work like this. There is
>> code in the system setup to look for hd* drives and wire them into IDE. There
>> is no such code in openrisc.
>
> Yeah don't use -hdX as they are legacy options with a lot of default
> assumptions. As the docs say: https://qemu.readthedocs.io/en/master/system/invocation.html#hxtool-1
>
> The QEMU block device handling options have a long history and have
> gone through several iterations as the feature set and complexity of
> the block layer have grown. Many online guides to QEMU often reference
> older and deprecated options, which can lead to confusion.
I want "a block device from this file" in a generic way that works the
same across multiple architectures regardless of the board being
emulated, where I only have to specify the file not explicitly
micromanage bus plumbing details, and which is easy for a human to type
from when explained over a voice call.
What's the alternative to -hda you suggest for that?
Can I do "./run-qemu.sh -drive file=blah.img" without the rest? Perhaps
specify all the details in the script and then optionally add an extra
argument at the end? I couldn't get that to work:
$ root/or1k/run-qemu.sh -netdev user,id=net0 -device
virtio-net-device,netdev=net0 -drive format=raw,id=hd0 -device
virtio-blk-device,drive=hd0 -drive file=README
qemu-system-or1k: -drive format=raw,id=hd0: A block device must be
specified for "file"
Also, if you say -device and -drive but do NOT specify a file, qemu
refuses to start. So I can't set the defaults but only optionally use
them, the way -hda has defaults built into the image that don't cause a
problem if I DON'T add a -hda argument to the command line.
> Older options like -hda are essentially macros which expand into -drive
> options for various drive interfaces.
Where the knowledge of "what this board needs in order to do that" is
built into qemu rather than provided by the caller, yes.
> The original forms bake in a lot
> of assumptions from the days when QEMU was emulating a legacy PC, they
> are not recommended for modern configurations.
I'm building a kernel. It finds /dev/?da so I can mount it. That is my
desired outcome.
I am attempting to get generic behavior out of multiple architectures,
among other reasons so I can cross-test and package up "it fails on X,
here's a build and test" to point package maintainers at.
"It natively builds under the emulator" is the easiest way to make that
work, which is why https://landley.net/bin/toolchains/latest/ has a
native.sqf for each cross.tar.xz.
wget system-image-arch.txz
wget toolchain.sqf
wget test.img
./run-emulator.sh -hda test.img -hdb toolchain.sqf
If I have to explain "-drive virtio-potato-walrus,inkpot=striated
-device collect=striated,burbank-potato,ireland" at somebody whose
domain expertise is xfce or something, the barrier to getting them to
reproduce the issue I'm seeing is noticeably higher. If I have to MAKE a
bespoke wrapper shell script for them with every bug report, the
likelihood that it works differently for them than when I tried it is
noticeably nonzero, and the likelihood of the issue going on my todo
heap and never getting pursued upstream is also noticeably higher. Which
is why I try to make generic tools...
(Making a _test_ script to demonstrate the issue is normal. If it's
their project, usually they can tell if I typoed it and fix it up
themselves because they know what I MEANT. But if I typo the setup for
the virtual environment, or are missing a prerequisite package install,
or they hit qemu version skew, or I said /bin/sh and theirs points to
dash... Brick wall. It either works or it doesn't.)
(And when I have to set up the long version for a nightly cron job, and
then when the test fails 6 months later and I look at it and go "huh?
salad?" that's a bad 3am digression as well. And which is more likely to
break from version skew during qemu version upgrades: two lines of
micromanaging --longopts or -hda that gets adjusted by the maintainers?)
Rob
P.S. For some reason -hda grew an "I'm going to make the first block
read-only just like loopback devices do because you can't be trusted"
nag a few years back, but it's mostly yet more boot spam. I can tell the
kernel to be quiet during boot, but never figured out the equivalent for
qemu-system...
next prev parent reply other threads:[~2025-01-07 23:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 5:42 QEMU commit 0a923be2f642 broke my or1k image Rob Landley
2024-09-16 7:21 ` Stafford Horne
2024-11-21 22:32 ` Rob Landley
2024-11-22 16:35 ` Stafford Horne
2024-11-23 0:54 ` Rob Landley
2024-11-23 8:28 ` Stafford Horne
2024-11-24 5:18 ` Rob Landley
2024-11-24 6:50 ` Stafford Horne
2024-12-22 17:29 ` or1k -M virt -hda and net Rob Landley
[not found] ` <Z2lgL31ZeSkO59MZ@antec>
2025-01-01 1:19 ` Rob Landley
2025-01-07 11:56 ` Rob Landley
2025-01-07 17:31 ` Stafford Horne
2025-01-07 18:05 ` Alex Bennée
2025-01-07 23:20 ` Rob Landley [this message]
2025-01-08 13:01 ` BALATON Zoltan
2025-01-08 22:57 ` Rob Landley
2025-01-09 2:05 ` BALATON Zoltan
2025-01-08 14:59 ` Alex Bennée
2025-01-08 22:34 ` Rob Landley
2025-01-09 2:48 ` BALATON Zoltan
2025-01-07 22:44 ` Rob Landley
2025-01-08 8:24 ` Geert Uytterhoeven
2025-01-08 16:23 ` Rob Landley
2025-01-08 16:26 ` Geert Uytterhoeven
2025-01-08 22:40 ` Rob Landley
2025-01-09 8:49 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e2f1c14c-f5d2-48f3-bb6e-d1db0ce6d1fa@landley.net \
--to=rob@landley.net \
--cc=Jason@zx2c4.com \
--cc=alex.bennee@linaro.org \
--cc=linux-openrisc@vger.kernel.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shorne@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).