From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v3 5/6] iothread: add "iothread" qdev property type
Date: Fri, 21 Feb 2014 14:01:03 +0100 [thread overview]
Message-ID: <53074E0F.1040006@redhat.com> (raw)
In-Reply-To: <CAJSP0QWCRBba2WT57mNgBuotb72j=A5tesuLSRKoQAxgK2J8Cg@mail.gmail.com>
Il 21/02/2014 13:45, Stefan Hajnoczi ha scritto:
>> This is okay; object_property_add_link reference count takes ownership of
>> the original value of the pointer.
>
> Here's an example:
>
> static void pxa2xx_pcmcia_initfn(Object *obj)
> int pxa2xx_pcmcia_attach(void *opaque, PCMCIACardState *card)
>
> On one hand "card" is a link. On the other hand we manually assign to
> s->card without using object_property_set_link() and without
> object_ref(card).
>
> This is broken.
Actually, what you showed is fine---ugly, but fine.
It means is that pxa2xx_pcmcia_attach has taken ownership of a reference
from its caller. It is ugly because it violates abstraction. And
pxa2xx_pcmcia_detach leaks the object because it doesn't object_unref()
the card. But it is fine, and no one calls pxa2xx_pcmcia_detach anyway. ;)
> We're abusing the link property because the
> pxa2xx_pcmcia_attach() function is semantically different from
> object_property_set_link(). What's worse is that you can still call
> object_property_set_link() and it will not perform the extra steps
> that pxa2xx_pcmcia_attach() is taking to raise an IRQ and prevent
> attaching to an already attached slot.
*This* is broken, and is exactly why we need link setters. Adding a
link setter and using it in pxa2xx_pcmcia_attach/detach would fix all
the problems here.
Of course, the question is how one would go testing this thing.
>> The real disaster is that links cannot be "locked" at realize time. For
>> this to happen, links need to have a setter like object_property_add_str
>> (not sure if they need a getter).
>
> Yes, this would allow the weird pxa2xx example to behavior itself
> better because _attach() would become the set() callback function.
Exactly.
>>> The rng device examples don't seem to help because there is no way to
>>> specify the rng backend via a qdev property (we always create a default
>>> backend). I need to be able to specify the object via a qdev property
>>> to the virtio-blk-pci device.
>>
>>
>> You can do that, see virtio-rng-pci. It creates a link and forwards that to
>> virtio-rng.
>
> No, virtio-rng-pci has no rng qdev property. The user cannot set it
> on the command-line:
Sure, it has no *qdev* property, but lo and behold:
qemu-system-x86_64 \
-object rng-random,filename=/dev/random,id=rng0 \
-device virtio-rng-pci,rng=rng0
This is why I believe we want static properties in QOM by the way, not
just in qdev. So that this rng property can be documented and not just
magic.
/me searches for an appropriate Star Wars quote
If once you start down the dark path, forever will it dominate your
destiny; consume you, it will! As it did Obi-Wan's apprentice.
Paolo
ps: You're fulfilling your destiny, Anakin. Become my apprentice. Learn
to use the Dark Side of the Force.
>>> Do I need to define a link<> qdev property:
>>> DEFINE_PROP_LINK("iothread", _state, _field.iothread, TYPE_IOTHREAD,
>>> IOThread *)
>>
>>
>> Perhaps, but to do that we need to first fix object_property_add_link.
>
> Okay, I'll start working on that and use "x-iothread" in the meantime
> for this series.
>
> Stefan
>
next prev parent reply other threads:[~2014-02-21 13:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 12:50 [Qemu-devel] [PATCH v3 0/6] dataplane: switch to N:M devices-per-thread model Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 1/6] rfifolock: add recursive FIFO lock Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 2/6] aio: add aio_context_acquire() and aio_context_release() Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 3/6] iothread: add I/O thread object Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 4/6] qdev: add get_pointer_and_free() for temporary strings Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 5/6] iothread: add "iothread" qdev property type Stefan Hajnoczi
2014-02-20 12:58 ` Paolo Bonzini
2014-02-21 11:03 ` Stefan Hajnoczi
2014-02-21 11:33 ` Paolo Bonzini
2014-02-21 12:45 ` Stefan Hajnoczi
2014-02-21 13:01 ` Paolo Bonzini [this message]
2014-02-21 13:25 ` Stefan Hajnoczi
2014-02-21 13:29 ` Paolo Bonzini
2014-02-21 14:15 ` Stefan Hajnoczi
2014-02-20 12:50 ` [Qemu-devel] [PATCH v3 6/6] dataplane: replace internal thread with IOThread Stefan Hajnoczi
2014-02-20 12:57 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53074E0F.1040006@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).