qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: or1k -M virt -hda and net.


From: BALATON Zoltan
Subject: Re: or1k -M virt -hda and net.
Date: Thu, 9 Jan 2025 03:05:30 +0100 (CET)

On Wed, 8 Jan 2025, Rob Landley wrote:
On 1/8/25 07:01, BALATON Zoltan wrote:
On Tue, 7 Jan 2025, Rob Landley wrote:
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

You need '-drive if=none,id=hd0,format=raw,file=README' as a single option not split into two.

I'm not always specifying an -hda. Sometimes it does, and sometimes it runs without it. I would like to have everything EXCEPT the media specified, so it can be inserted into a ready drive or run without it.

That's what -hda traditionally does.

I think you can't do that with -drive. You either do

-drive if=none,id=d,format=raw,file=raw.img -device whatever,drive=d

or try to have -drive create the device by specifying the type in if and hope it works such as

-drive if=virtio,format=raw,file=raw.img

and then you don't need corresponding device but this may not work for every machine. The -hda option should expand to such -drive option but it cannot if the machine does not define a default interface for block devices. So maybe just setting block_default_type in the MachineClass to IF_VIRTIO might be enough, otherwise you may need to implement handling for it in the machine. In the sam460ex I had to implement it because it uses SATA with only two ports which only takes one device per IDE bus while the default in QEMU expects PATA IDE that can have two devices per bus and two buses but for virtio maybe it works without additional handling of drives and only the default is missing which -hda would use.

With if=none -drive won't auto-create a  device

$ root/or1k/run-qemu.sh -netdev user,id=net0 -device virtio-net-device,netdev=net0 -drive if=none,id=hd0,format=raw qemu-system-or1k: -drive if=none,id=hd0,format=raw: A block device must be specified for "file"

so you then also need a corresponding -device option for the drive that you seem to have already above.

$ root/or1k/run-qemu.sh -netdev user,id=net0 -device virtio-net-device,netdev=net0 -device virtio-blk-device
qemu-system-or1k: -device virtio-blk-device: drive property not set
$ root/or1k/run-qemu.sh -netdev user,id=net0 -device virtio-net-device,netdev=net0 -device virtio-blk-device,drive=hd0 qemu-system-or1k: -device virtio-blk-device,drive=hd0: Property 'virtio-blk-device.drive' can't find value 'hd0' $ root/or1k/run-qemu.sh -netdev user,id=net0 -device virtio-net-device,netdev=net0 -device virtio-blk-device,drive=hd0 -drive id=hd0,if=none qemu-system-or1k: -device virtio-blk-device,drive=hd0: Device needs media, but drive is empty

That's as close as I can get. As far as I can tell, it's complaining that I got it into the state I wanted, and it doesn't want to be in that state. The "if=none" does not appear to help.

I think you can only have empty cdrom devices which can be created without a drive option but not devices that don't have removable media. You also can't define a drive without a file or some other backing store.

I also don't know what drive=/id= pair "-hda" would be trying to populate, so dunno what name to use there.

Maybe you can try 'info block' in QEMU monitor to see what drives are defined and 'info qtree' to see what devices are attached to them. But if -hda option does not work this won't help, you can only check on other machines what -hda defines.

Regards,
BALATON Zoltan

Also, it requires -drive and its argument to be seperate:

 qemu-system-or1k: -device=virtio-blk-device,drive=hda: invalid option

Refusing to let them to be glued together with = (like most --longopt parsers do, including the https://github.com/landley/toybox/blob/master/lib/args.c I wrote) means I can't use bash's brace expansion to set up multiple at once (to preload support for -hda, -hdb, -hdc, and -hdd), ala:

 -drive=id=hd{0,1,2,3},if=none

Not that the current script has a bash dependency... :P

If you want -hda to work you may need something like commit d36b2f4e78 (hw/ppc/sam460ex: Support short options for adding drives) for the machine you use. In particular the MachineClass block_default_type field says what's the default interface that -drive and other short options should use (at least I think so, I'm no expert on this either but searching for it should at least point to where it's handled).

Thanks for the pointer, I'll take a look.

Rob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]