qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"David Hildenbrand" <david@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	qemu-s390x@nongnu.org
Subject: Re: [RFC PATCH 1/4] confidential guest support: Add kvm_init() and kvm_reset() in class
Date: Tue, 6 Feb 2024 14:14:14 +0000	[thread overview]
Message-ID: <ZcI-tqhgJA06g4UQ@redhat.com> (raw)
In-Reply-To: <20240206082852.3333299-2-xiaoyao.li@intel.com>

On Tue, Feb 06, 2024 at 03:28:49AM -0500, Xiaoyao Li wrote:
> Different confidential VMs in different architectures all have the same
> needs to do their specific initialization (and maybe resetting) stuffs
> with KVM. Currently each of them exposes individual *_kvm_init()
> functions and let machine code or kvm code to call it.
> 
> To make it more object oriented, add two virtual functions, kvm_init()
> and kvm_reset() in ConfidentialGuestSupportClass, and expose two helpers
> functions for invodking them.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>  include/exec/confidential-guest-support.h | 42 ++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/include/exec/confidential-guest-support.h b/include/exec/confidential-guest-support.h
> index ba2dd4b5dfc4..ff0bfb26ad7a 100644
> --- a/include/exec/confidential-guest-support.h
> +++ b/include/exec/confidential-guest-support.h
> @@ -23,7 +23,10 @@
>  #include "qom/object.h"
>  
>  #define TYPE_CONFIDENTIAL_GUEST_SUPPORT "confidential-guest-support"
> -OBJECT_DECLARE_SIMPLE_TYPE(ConfidentialGuestSupport, CONFIDENTIAL_GUEST_SUPPORT)
> +OBJECT_DECLARE_TYPE(ConfidentialGuestSupport,
> +                    ConfidentialGuestSupportClass,
> +                    CONFIDENTIAL_GUEST_SUPPORT)
> +
>  
>  struct ConfidentialGuestSupport {
>      Object parent;
> @@ -55,8 +58,45 @@ struct ConfidentialGuestSupport {
>  
>  typedef struct ConfidentialGuestSupportClass {
>      ObjectClass parent;
> +
> +    int (*kvm_init)(ConfidentialGuestSupport *cgs, Error **errp);
> +    int (*kvm_reset)(ConfidentialGuestSupport *cgs, Error **errp);
>  } ConfidentialGuestSupportClass;
>  
> +static inline int confidential_guest_kvm_init(ConfidentialGuestSupport *cgs,
> +                                              Error **errp)
> +{
> +    ConfidentialGuestSupportClass *klass;
> +
> +    if (!cgs) {
> +        return 0;
> +    }

Typically I would expect any class/object methods to mandate a non-NULL
class/instance pointer.

IOW, the caller would generally be expected to check NULL and not
call this method in that case.

> +
> +    klass = CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs);
> +    if (klass->kvm_init) {
> +        return klass->kvm_init(cgs, errp);
> +    }
> +
> +    return 0;
> +}
> +
> +static inline int confidential_guest_kvm_reset(ConfidentialGuestSupport *cgs,
> +                                               Error **errp)
> +{
> +    ConfidentialGuestSupportClass *klass;
> +
> +    if (!cgs) {
> +        return 0;
> +    }
> +
> +    klass = CONFIDENTIAL_GUEST_SUPPORT_GET_CLASS(cgs);
> +    if (klass->kvm_reset) {
> +        return klass->kvm_reset(cgs, errp);
> +    }
> +
> +    return 0;
> +}
> +
>  #endif /* !CONFIG_USER_ONLY */
>  
>  #endif /* QEMU_CONFIDENTIAL_GUEST_SUPPORT_H */
> -- 
> 2.34.1
> 

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 :|



  reply	other threads:[~2024-02-06 14:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06  8:28 [RFC PATCH 0/4] Confidential Guest Support: Introduce kvm_init() and kvm_reset() virtual functions Xiaoyao Li
2024-02-06  8:28 ` [RFC PATCH 1/4] confidential guest support: Add kvm_init() and kvm_reset() in class Xiaoyao Li
2024-02-06 14:14   ` Daniel P. Berrangé [this message]
2024-02-06  8:28 ` [RFC PATCH 2/4] i386/sev: Switch to use confidential_guest_kvm_init() Xiaoyao Li
2024-02-06 14:16   ` Daniel P. Berrangé
2024-02-07  7:10     ` Xiaoyao Li
2024-02-06  8:28 ` [RFC PATCH 3/4] ppc/pef: switch to use confidential_guest_kvm_init/reset() Xiaoyao Li
2024-02-06  8:28 ` [RFC PATCH 4/4] s390: Switch to use confidential_guest_kvm_init() Xiaoyao Li
2024-02-06 14:19 ` [RFC PATCH 0/4] Confidential Guest Support: Introduce kvm_init() and kvm_reset() virtual functions Daniel P. Berrangé
2024-02-07  7:29   ` Xiaoyao Li

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=ZcI-tqhgJA06g4UQ@redhat.com \
    --to=berrange@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=xiaoyao.li@intel.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).