qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v2 1/3] virtio-bus : Introduce VirtioBus.


From: Cornelia Huck
Subject: Re: [Qemu-devel] [RFC PATCH v2 1/3] virtio-bus : Introduce VirtioBus.
Date: Fri, 23 Nov 2012 15:35:47 +0100

On Fri, 23 Nov 2012 15:12:45 +0100
Konrad Frederic <address@hidden> wrote:

> On 23/11/2012 13:08, Cornelia Huck wrote:
> > On Thu, 22 Nov 2012 15:50:50 +0100
> > address@hidden wrote:
> >
> >
> >> +/* Create a virtio bus.  */
> >> +VirtioBus *virtio_bus_new(DeviceState *host, const VirtioBusInfo *info)
> >> +{
> >> +    /*
> >> +     * This is needed, as we want to have different names for each 
> >> virtio-bus.
> >> +     * If we don't do that, we can't add more than one VirtIODevice.
> >> +     */
> >> +    static int next_virtio_bus;
> >> +    char *bus_name = g_strdup_printf("virtio-bus.%d", next_virtio_bus++);
> > This still has the overflow/id-reuse problem, hasn't it?
> What do you mean by overflow problem ?

If you do a lot of hotplugs (and hotunplugs), at some point
next_virtio_bus will overflow and the code will start to create
virtio-bus.<existing number>. It's a bit of a pathological case, but I
can see it happening on machines with lots of devices that change
rapidly (such as somebody running a test script doing
device_add/device_del).

Maybe use something like the ida stuff the virtio kernel code is using
(don't know whether something similar exists in qemu).

> 
> >
> >> +
> >> +    BusState *qbus = qbus_create(TYPE_VIRTIO_BUS, host, bus_name);
> >> +    VirtioBus *bus = VIRTIO_BUS(qbus);
> >> +    bus->info = info;
> >> +    qbus->allow_hotplug = 0;
> >> +    bus->bus_in_use = false;
> >> +    DPRINTF("%s bus created\n", bus_name);
> >> +    return bus;
> >> +}
> > Don't you need a way to destroy the bus again when the proxy device is
> > hotunplugged?
> >
> Yes, you're right I must add a way to destroy the bus, and the devices 
> when the proxy is hot unplugged!
> 
> Thanks,
> 
> Fred
> 




reply via email to

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