dataplane: replace iothread object_add() with embedded instance
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 20 Mar 2014 14:06:32 +0000 (15:06 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 4 Apr 2014 18:48:13 +0000 (20:48 +0200)
commit54bee5c2b487250dcb8631ddff4307f329ec0541
tree611313e4e7b49a4a04a94b297df92f0382db3921
parent8c2664d86917c987944f1ca9770d1f7bbbf8eca8
dataplane: replace iothread object_add() with embedded instance

Before IOThread was its own object, each virtio-blk device would create
its own internal thread.  We need to preserve this behavior for
backwards compatibility when users do not specify -device
virtio-blk-pci,iothread=<id>.

This patch changes how the internal IOThread object is created.
Previously we used the monitor object_add() function, which is really a
layering violation.  The problem is that this needs to assign a name but
we don't have a name for this internal object.

Generating names for internal objects is a pain but even worse is that
they may collide with user-defined names.

Paolo Bonzini <pbonzini@redhat.com> suggested that the internal IOThread
object should not be named.  This way the conflict cannot happen and we
no longer need object_add().

One gotcha is that internal IOThread objects will not be listed by the
query-iothreads command since they are not named.  This is okay though
because query-iothreads is new and the internal IOThread is just for
backwards compatibility.  New users should explicitly define IOThread
objects.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/dataplane/virtio-blk.c