Re: [PATCH v2 01/16] rust/qobject: add basic bindings

Paolo Bonzini
2026-02-25T08:05:57Z

On 2/24/26 14:33, Markus Armbruster wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
>> On 2/24/26 11:03, Markus Armbruster wrote:
>>>> diff --git a/rust/util/wrapper.h b/rust/util/wrapper.h
>>>> index b9ed68a01d8..0907dd59142 100644
>>>> --- a/rust/util/wrapper.h
>>>> +++ b/rust/util/wrapper.h
>>>> @@ -30,3 +30,10 @@ typedef enum memory_order {
>>>> #include "qemu/log.h"
>>>> #include "qemu/module.h"
>>>> #include "qemu/timer.h"
>>>> +#include "qobject/qnull.h"
>>>> +#include "qobject/qbool.h"
>>>> +#include "qobject/qnum.h"
>>>> +#include "qobject/qstring.h"
>>>> +#include "qobject/qobject.h"
>>>> +#include "qobject/qlist.h"
>>>> +#include "qobject/qdict.h"
>>>
>>> Is this file just for bindgen, and never actually fed to the C compiler?
>>
>> Yes.
>
> Thanks!
>
>>>> +impl From<()> for QObject {
>>>> + fn from(_null: ()) -> Self {
>>>> + // Conversion of the C inline `qnull` function
>>>> + unsafe { QObject::cloned_from_base(addr_of!(bindings::qnull_.base)) }
>>>> + }
>>>> +}
>>>
>>> Could we call C qnull() instead of using qnull_.base?
>>
>> See v1 review - no, because qnull() is inline. I can make it not
>> inline, of course.
>
> I feel making it inline was a bit silly. Perhaps I had a non-silly
> reason back then, but I can't see it anymore.

Maybe it was, but qnull_ is also used by tests/unit/check-qnull.c; and
it would also be silly to make qnull() extern while keeping the global
qnull_. In doubt, I'd leave it as is.

Paolo