Paolo Bonzini <[email protected]> writes: > On 22/09/2016 11:19, Markus Armbruster wrote: >>> > I think -device is okay for something that isn't a "backend" but is >>> > directly guest-visible. >> Well, the contents of a block device is just as guest-visible. We split >> the device in a frontend and a backend, and the contents comes from the >> backend. >> >> We traditionally don't model memory as a split device. Perhaps we >> should. Regardless of whether we actually do, "contents of a memory >> device that you need to create by some other means (explicit or >> implicit)" feels much more like -object than like -device to me. > > The closest precedents here are "-bios" (not an object at all), PCI ROMs > (a property points to the file), and "-pflash" (split into backend and > frontend, the frontend being a device).
-pflash ARG is sugar for -drive if=pflash,file=ARG. Like all -drive other than drive if=none, it creates a block backend and asks the board to create a block frontend. Some boards create a modern QOMified device such as "cfi.pflash01", some create just a ROM memory region, which isn't a device (in the same way RAM normally isn't), and some ignore the request silently. The modern, fully general form for QOMified devices would be to define the backend with -drive if=none, and the frontend with -device. -bios ARG is sugar for -machine firmware=ARG. This asks the board to load firmware from file ARG. Again, boards could create a modern QOMified ROM device (theoretical, not sure there are any), a non-device ROM memory region, or ignore the request. The difference to pflash is that we don't wrap a full-blown block backend around the file, simply because that would complicate things for no gain. But that's detail; it's playing the role of a backend all the same. A (QOMified) PCI may have a PCI ROM. To configure its contents, you use a PCI device property naming a file. In all cases, QOMified devices get bits from the host via a backend. The backend can be an explicit object (e.g. a block backend) or, if the backend is trivial, folded into the frontend. > I think there is a device concept in here, the question is whether you > want to split the backend and frontend. For read-only data the > precedents favor not splitting it. Yes, we sometimes choose to fold trivial backends into the frontends instead of doing a split device. That's fine. However, in the case we're discussing, we're not doing that! There is no RAM device with a trivial backend folded in. There's only a weird pseudo-device that copies the contents of a file into memory, then sits around doing absolutely nothing. For me, that's an abuse of -device. It's certainly no worse than some other parts of the QEMU command line / QMP. Not exactly a good excuse, though :)
