On 11/16/09 13:28, Ian Molton wrote:
I've done something similar (below)
My commandline looks like:
- -virtiorng dev=/dev/foo,rate=1234
I added some properties to my driver which are obviously then filled in
from the options code, and I do my init like this:
There is no need for a new -virtiorng switch. qdev allows to set any
property when creating devices via -device on the command line.
VirtIODevice *virtio_rng_init(DeviceState *dev, RNGConf *rngdev)
{
VirtIORng *s;
s = (VirtIORng *)virtio_common_init("virtio-rng",
VIRTIO_ID_RNG,
0, sizeof(VirtIORng));
if (!s)
return NULL;
s->vdev.get_features = virtio_rng_get_features;
s->vq = virtio_add_queue(&s->vdev, 128, virtio_rng_handle);
s->chr = qemu_chr_open("vrngdev", rngdev->device, NULL);
...
return&s->vdev;
}
Is this 'not the right way' ? I think the commandline looks much simpler
this way.
The point is to separate host and guest state. -chardev ist host state,
the device is guest state, and they are linked using the chardev name.
OTOH, I can see that this might help with my next problem, which is that
I want to write EGD support for virtio-rng, so I'm guessing my
commandline would (in your scheme) need to be something like:
-tcpsocketthing $addr.of.egd.server,id=some-name-here,
more-egd-client-options
-device virtio-rng,tcpsocketthing=some-name-here,rate=$limit
Maybe ...
-chardev socket,id=egd,host=egd.domain.tld,port=whatever
-device virtio-rng,chardev=egd
... ?
This doesnt, however, get around my problem that the -device option
doesnt know how to parse OPT_SIZE types, though. (I'd like to be able to
specify 'rate' in B/s or KB/s (or even kbits/sec, more appropriately))
Yes, there is no qdev property type (yet) which can parse those
postfixes. Which is no reason to not add one though ;)
cheers,
Gerd