The QOM type of S390PVGuest is declared by OBJECT_DECLARE_SIMPLE_TYPE,
which means it doesn't need the class!
Therefore, use OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES to implement
the type, then there's no need for class definition.
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: qemu-s390x@nongnu.org
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
target/s390x/kvm/pv.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/target/s390x/kvm/pv.c b/target/s390x/kvm/pv.c
index 2bc916a5455f..a4dbbcef7e08 100644
--- a/target/s390x/kvm/pv.c
+++ b/target/s390x/kvm/pv.c
@@ -313,12 +313,6 @@ struct S390PVGuest {
ConfidentialGuestSupport parent_obj;
};
-typedef struct S390PVGuestClass S390PVGuestClass;
-
-struct S390PVGuestClass {
- ConfidentialGuestSupportClass parent_class;
-};
-
/*
* If protected virtualization is enabled, the amount of data that the
* Read SCP Info Service Call can use is limited to one page. The
@@ -380,12 +374,12 @@ static int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
return 0;
}
-OBJECT_DEFINE_TYPE_WITH_INTERFACES(S390PVGuest,
- s390_pv_guest,
- S390_PV_GUEST,
- CONFIDENTIAL_GUEST_SUPPORT,
- { TYPE_USER_CREATABLE },
- { NULL })
+OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
+ s390_pv_guest,
+ S390_PV_GUEST,
+ CONFIDENTIAL_GUEST_SUPPORT,
+ { TYPE_USER_CREATABLE },
+ { NULL })
static void s390_pv_guest_class_init(ObjectClass *oc, const void *data)
{
--
2.34.1
On 14.05.25 10:49, Zhao Liu wrote:
> The QOM type of S390PVGuest is declared by OBJECT_DECLARE_SIMPLE_TYPE,
> which means it doesn't need the class!
>
> Therefore, use OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES to implement
> the type, then there's no need for class definition.
>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Ilya Leoshkevich <iii@linux.ibm.com>
> Cc: qemu-s390x@nongnu.org
> Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> target/s390x/kvm/pv.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/target/s390x/kvm/pv.c b/target/s390x/kvm/pv.c
> index 2bc916a5455f..a4dbbcef7e08 100644
> --- a/target/s390x/kvm/pv.c
> +++ b/target/s390x/kvm/pv.c
> @@ -313,12 +313,6 @@ struct S390PVGuest {
> ConfidentialGuestSupport parent_obj;
> };
>
> -typedef struct S390PVGuestClass S390PVGuestClass;
> -
> -struct S390PVGuestClass {
> - ConfidentialGuestSupportClass parent_class;
> -};
> -
> /*
> * If protected virtualization is enabled, the amount of data that the
> * Read SCP Info Service Call can use is limited to one page. The
> @@ -380,12 +374,12 @@ static int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp)
> return 0;
> }
>
> -OBJECT_DEFINE_TYPE_WITH_INTERFACES(S390PVGuest,
> - s390_pv_guest,
> - S390_PV_GUEST,
> - CONFIDENTIAL_GUEST_SUPPORT,
> - { TYPE_USER_CREATABLE },
> - { NULL })
> +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
> + s390_pv_guest,
> + S390_PV_GUEST,
> + CONFIDENTIAL_GUEST_SUPPORT,
> + { TYPE_USER_CREATABLE },
> + { NULL })
I'll note that existing callers of
OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES happily ignore the line limit
and put it into a single line.
(which ends up looking better IMHO)
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
> > +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
> > + s390_pv_guest,
> > + S390_PV_GUEST,
> > + CONFIDENTIAL_GUEST_SUPPORT,
> > + { TYPE_USER_CREATABLE },
> > + { NULL })
>
> I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> happily ignore the line limit and put it into a single line.
>
> (which ends up looking better IMHO)
Ok, I'll onor the existing conventions (which I'll apply to other
patches as well).
> Reviewed-by: David Hildenbrand <david@redhat.com>
Thanks!
Regards,
Zhao
On Wed, 14 May 2025, Zhao Liu wrote:
>>> +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
>>> + s390_pv_guest,
>>> + S390_PV_GUEST,
>>> + CONFIDENTIAL_GUEST_SUPPORT,
>>> + { TYPE_USER_CREATABLE },
>>> + { NULL })
>>
>> I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>> happily ignore the line limit and put it into a single line.
>>
>> (which ends up looking better IMHO)
>
> Ok, I'll onor the existing conventions (which I'll apply to other
> patches as well).
There are two line limits. If something is clearer on one line you could
exceed the normal 80 chars and put up to 90 chars on one line for which
checkpatch will issue a warning that can be ignored for these cases. Over
90 lines checkpatch will give an error and I think you should not ignore
that. Maybe try to put as much on one line as possible instead of new line
after each argument but without exceeding the 80 chars or if the whole
line fits in 90 chars then use that. Or maybe do not indent second line
under ( but with 4 spaces then you can fit it in two lines but lines over
90 chars are undesirable.
Regards,
BALATON Zoltan
>> Reviewed-by: David Hildenbrand <david@redhat.com>
>
> Thanks!
>
> Regards,
> Zhao
>
>
>
On Wed, May 14, 2025 at 06:24:03PM +0200, BALATON Zoltan wrote:
> Date: Wed, 14 May 2025 18:24:03 +0200
> From: BALATON Zoltan <balaton@eik.bme.hu>
> Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>
> On Wed, 14 May 2025, Zhao Liu wrote:
> > > > +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
> > > > + s390_pv_guest,
> > > > + S390_PV_GUEST,
> > > > + CONFIDENTIAL_GUEST_SUPPORT,
> > > > + { TYPE_USER_CREATABLE },
> > > > + { NULL })
> > >
> > > I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> > > happily ignore the line limit and put it into a single line.
> > >
> > > (which ends up looking better IMHO)
> >
> > Ok, I'll onor the existing conventions (which I'll apply to other
> > patches as well).
>
> There are two line limits. If something is clearer on one line you could
> exceed the normal 80 chars and put up to 90 chars on one line for which
> checkpatch will issue a warning that can be ignored for these cases. Over 90
> lines checkpatch will give an error and I think you should not ignore that.
Thank you. This makes sense!
> Maybe try to put as much on one line as possible instead of new line after
> each argument but without exceeding the 80 chars or if the whole line fits
> in 90 chars then use that. Or maybe do not indent second line under ( but
> with 4 spaces then you can fit it in two lines but lines over 90 chars are
> undesirable.
HMM, I understand you mean:
OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest, s390_pv_guest,
S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT, { TYPE_USER_CREATABLE }, { NULL })
The second line is 82 chars and now I think this version is better.
Thanks,
Zhao
On Thu, 15 May 2025, Zhao Liu wrote:
> On Wed, May 14, 2025 at 06:24:03PM +0200, BALATON Zoltan wrote:
>> Date: Wed, 14 May 2025 18:24:03 +0200
>> From: BALATON Zoltan <balaton@eik.bme.hu>
>> Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
>> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>>
>> On Wed, 14 May 2025, Zhao Liu wrote:
>>>>> +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
>>>>> + s390_pv_guest,
>>>>> + S390_PV_GUEST,
>>>>> + CONFIDENTIAL_GUEST_SUPPORT,
>>>>> + { TYPE_USER_CREATABLE },
>>>>> + { NULL })
>>>>
>>>> I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>>>> happily ignore the line limit and put it into a single line.
>>>>
>>>> (which ends up looking better IMHO)
>>>
>>> Ok, I'll onor the existing conventions (which I'll apply to other
>>> patches as well).
>>
>> There are two line limits. If something is clearer on one line you could
>> exceed the normal 80 chars and put up to 90 chars on one line for which
>> checkpatch will issue a warning that can be ignored for these cases. Over 90
>> lines checkpatch will give an error and I think you should not ignore that.
>
> Thank you. This makes sense!
>
>> Maybe try to put as much on one line as possible instead of new line after
>> each argument but without exceeding the 80 chars or if the whole line fits
>> in 90 chars then use that. Or maybe do not indent second line under ( but
>> with 4 spaces then you can fit it in two lines but lines over 90 chars are
>> undesirable.
>
> HMM, I understand you mean:
>
> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest, s390_pv_guest,
> S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT, { TYPE_USER_CREATABLE }, { NULL })
>
> The second line is 82 chars and now I think this version is better.
Yes and maybe can even fit in 80 chars if using { } instead of { NULL }.
Regards,
BALATON Zoltan
On Thu, May 15, 2025 at 05:41:40PM +0200, BALATON Zoltan wrote:
> On Thu, 15 May 2025, Zhao Liu wrote:
> > On Wed, May 14, 2025 at 06:24:03PM +0200, BALATON Zoltan wrote:
> > > Date: Wed, 14 May 2025 18:24:03 +0200
> > > From: BALATON Zoltan <balaton@eik.bme.hu>
> > > Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
> > > OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> > >
> > > On Wed, 14 May 2025, Zhao Liu wrote:
> > > > > > +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
> > > > > > + s390_pv_guest,
> > > > > > + S390_PV_GUEST,
> > > > > > + CONFIDENTIAL_GUEST_SUPPORT,
> > > > > > + { TYPE_USER_CREATABLE },
> > > > > > + { NULL })
> > > > >
> > > > > I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> > > > > happily ignore the line limit and put it into a single line.
> > > > >
> > > > > (which ends up looking better IMHO)
> > > >
> > > > Ok, I'll onor the existing conventions (which I'll apply to other
> > > > patches as well).
> > >
> > > There are two line limits. If something is clearer on one line you could
> > > exceed the normal 80 chars and put up to 90 chars on one line for which
> > > checkpatch will issue a warning that can be ignored for these cases. Over 90
> > > lines checkpatch will give an error and I think you should not ignore that.
> >
> > Thank you. This makes sense!
> >
> > > Maybe try to put as much on one line as possible instead of new line after
> > > each argument but without exceeding the 80 chars or if the whole line fits
> > > in 90 chars then use that. Or maybe do not indent second line under ( but
> > > with 4 spaces then you can fit it in two lines but lines over 90 chars are
> > > undesirable.
> >
> > HMM, I understand you mean:
> >
> > OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest, s390_pv_guest,
> > S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT, { TYPE_USER_CREATABLE }, { NULL })
> >
> > The second line is 82 chars and now I think this version is better.
>
> Yes and maybe can even fit in 80 chars if using { } instead of { NULL }.
Personally, once you have to break the line, I would be inclined
to have *nothing* after the '(' on the first line, and then break
at the list of interfaces. ie
OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(
S390PVGuest, s390_pv_guest, S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT,
{ TYPE_USER_CREATABLE }, { NULL })
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On Thu, May 15, 2025 at 05:11:56PM +0100, Daniel P. Berrangé wrote:
> Date: Thu, 15 May 2025 17:11:56 +0100
> From: "Daniel P. Berrangé" <berrange@redhat.com>
> Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>
> On Thu, May 15, 2025 at 05:41:40PM +0200, BALATON Zoltan wrote:
> > On Thu, 15 May 2025, Zhao Liu wrote:
> > > On Wed, May 14, 2025 at 06:24:03PM +0200, BALATON Zoltan wrote:
> > > > Date: Wed, 14 May 2025 18:24:03 +0200
> > > > From: BALATON Zoltan <balaton@eik.bme.hu>
> > > > Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
> > > > OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> > > >
> > > > On Wed, 14 May 2025, Zhao Liu wrote:
> > > > > > > +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
> > > > > > > + s390_pv_guest,
> > > > > > > + S390_PV_GUEST,
> > > > > > > + CONFIDENTIAL_GUEST_SUPPORT,
> > > > > > > + { TYPE_USER_CREATABLE },
> > > > > > > + { NULL })
> > > > > >
> > > > > > I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
> > > > > > happily ignore the line limit and put it into a single line.
> > > > > >
> > > > > > (which ends up looking better IMHO)
> > > > >
> > > > > Ok, I'll onor the existing conventions (which I'll apply to other
> > > > > patches as well).
> > > >
> > > > There are two line limits. If something is clearer on one line you could
> > > > exceed the normal 80 chars and put up to 90 chars on one line for which
> > > > checkpatch will issue a warning that can be ignored for these cases. Over 90
> > > > lines checkpatch will give an error and I think you should not ignore that.
> > >
> > > Thank you. This makes sense!
> > >
> > > > Maybe try to put as much on one line as possible instead of new line after
> > > > each argument but without exceeding the 80 chars or if the whole line fits
> > > > in 90 chars then use that. Or maybe do not indent second line under ( but
> > > > with 4 spaces then you can fit it in two lines but lines over 90 chars are
> > > > undesirable.
> > >
> > > HMM, I understand you mean:
> > >
> > > OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest, s390_pv_guest,
> > > S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT, { TYPE_USER_CREATABLE }, { NULL })
> > >
> > > The second line is 82 chars and now I think this version is better.
> >
> > Yes and maybe can even fit in 80 chars if using { } instead of { NULL }.
>
> Personally, once you have to break the line, I would be inclined
> to have *nothing* after the '(' on the first line, and then break
> at the list of interfaces. ie
>
> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(
> S390PVGuest, s390_pv_guest, S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT,
> { TYPE_USER_CREATABLE }, { NULL })
>
This version looks better! Thank you all for your patience.
(How to elegantly break lines is indeed a matter of taste, and I've
improved in this area now with your help :-).)
Regards,
Zhao
On 16.05.25 05:23, Zhao Liu wrote:
> On Thu, May 15, 2025 at 05:11:56PM +0100, Daniel P. Berrangé wrote:
>> Date: Thu, 15 May 2025 17:11:56 +0100
>> From: "Daniel P. Berrangé" <berrange@redhat.com>
>> Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
>> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>>
>> On Thu, May 15, 2025 at 05:41:40PM +0200, BALATON Zoltan wrote:
>>> On Thu, 15 May 2025, Zhao Liu wrote:
>>>> On Wed, May 14, 2025 at 06:24:03PM +0200, BALATON Zoltan wrote:
>>>>> Date: Wed, 14 May 2025 18:24:03 +0200
>>>>> From: BALATON Zoltan <balaton@eik.bme.hu>
>>>>> Subject: Re: [PATCH 8/9] target/s390x/kvm/pv: Consolidate
>>>>> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>>>>>
>>>>> On Wed, 14 May 2025, Zhao Liu wrote:
>>>>>>>> +OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest,
>>>>>>>> + s390_pv_guest,
>>>>>>>> + S390_PV_GUEST,
>>>>>>>> + CONFIDENTIAL_GUEST_SUPPORT,
>>>>>>>> + { TYPE_USER_CREATABLE },
>>>>>>>> + { NULL })
>>>>>>>
>>>>>>> I'll note that existing callers of OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES
>>>>>>> happily ignore the line limit and put it into a single line.
>>>>>>>
>>>>>>> (which ends up looking better IMHO)
>>>>>>
>>>>>> Ok, I'll onor the existing conventions (which I'll apply to other
>>>>>> patches as well).
>>>>>
>>>>> There are two line limits. If something is clearer on one line you could
>>>>> exceed the normal 80 chars and put up to 90 chars on one line for which
>>>>> checkpatch will issue a warning that can be ignored for these cases. Over 90
>>>>> lines checkpatch will give an error and I think you should not ignore that.
>>>>
>>>> Thank you. This makes sense!
>>>>
>>>>> Maybe try to put as much on one line as possible instead of new line after
>>>>> each argument but without exceeding the 80 chars or if the whole line fits
>>>>> in 90 chars then use that. Or maybe do not indent second line under ( but
>>>>> with 4 spaces then you can fit it in two lines but lines over 90 chars are
>>>>> undesirable.
>>>>
>>>> HMM, I understand you mean:
>>>>
>>>> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(S390PVGuest, s390_pv_guest,
>>>> S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT, { TYPE_USER_CREATABLE }, { NULL })
>>>>
>>>> The second line is 82 chars and now I think this version is better.
>>>
>>> Yes and maybe can even fit in 80 chars if using { } instead of { NULL }.
>>
>> Personally, once you have to break the line, I would be inclined
>> to have *nothing* after the '(' on the first line, and then break
>> at the list of interfaces. ie
>>
>> OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES(
>> S390PVGuest, s390_pv_guest, S390_PV_GUEST, CONFIDENTIAL_GUEST_SUPPORT,
>> { TYPE_USER_CREATABLE }, { NULL })
>>
>
> This version looks better! Thank you all for your patience.
>
> (How to elegantly break lines is indeed a matter of taste, and I've
> improved in this area now with your help :-).)
Sorry for starting this :) And thanks for your patience.
Back when I added a OBJECT_DEFINE_SIMPLE_TYPE_WITH_INTERFACES, I did it
just like everybody else:
Cram it all into a single line because it's all unbelievable unreadable
already, no need to fake that breaking lines would improve that in any
way ...
--
Cheers,
David / dhildenb
© 2016 - 2025 Red Hat, Inc.