[PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs

Michal Privoznik posted 15 patches 3 years, 4 months ago
There is a newer version of this series
[PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs
Posted by Michal Privoznik 3 years, 4 months ago
From: Haibin Huang <haibin.huang@intel.com>

Signed-off-by: Haibin Huang <haibin.huang@intel.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_capabilities.c | 11 +++++++++++
 src/conf/domain_capabilities.h | 22 ++++++++++++++++++++++
 src/libvirt_private.syms       |  1 +
 3 files changed, 34 insertions(+)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 653123f293..1d3bba3019 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -76,6 +76,17 @@ virSEVCapabilitiesFree(virSEVCapability *cap)
 }
 
 
+void
+virSGXCapabilitiesFree(virSGXCapability *cap)
+{
+    if (!cap)
+        return;
+
+    g_free(cap->sections);
+    g_free(cap);
+}
+
+
 static void
 virDomainCapsDispose(void *obj)
 {
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index a526969cda..e4654a65cd 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -193,6 +193,22 @@ struct _virSEVCapability {
     unsigned int max_es_guests;
 };
 
+typedef struct _virSection virSection;
+struct _virSection {
+    unsigned long long size;
+    int node;
+};
+
+typedef struct _virSGXCapability virSGXCapability;
+struct _virSGXCapability {
+    bool flc;
+    bool sgx1;
+    bool sgx2;
+    unsigned long long section_size;
+    size_t nsections;
+    virSection *sections;
+};
+
 typedef enum {
     VIR_DOMAIN_CAPS_FEATURE_IOTHREADS = 0,
     VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO,
@@ -229,6 +245,7 @@ struct _virDomainCaps {
 
     virDomainCapsFeatureGIC gic;
     virSEVCapability *sev;
+    virSGXCapability *sgx;
     /* add new domain features here */
 
     virTristateBool features[VIR_DOMAIN_CAPS_FEATURE_LAST];
@@ -277,3 +294,8 @@ void
 virSEVCapabilitiesFree(virSEVCapability *capabilities);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSEVCapability, virSEVCapabilitiesFree);
+
+void
+virSGXCapabilitiesFree(virSGXCapability *capabilities);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSGXCapability, virSGXCapabilitiesFree);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6a5c5600df..08ed484900 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -216,6 +216,7 @@ virDomainCapsEnumSet;
 virDomainCapsFormat;
 virDomainCapsNew;
 virSEVCapabilitiesFree;
+virSGXCapabilitiesFree;
 
 
 # conf/domain_conf.h
-- 
2.35.1
Re: [PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs
Posted by Peter Krempa 3 years, 4 months ago
On Wed, Jul 27, 2022 at 12:34:53 +0200, Michal Privoznik wrote:
> From: Haibin Huang <haibin.huang@intel.com>
> 
> Signed-off-by: Haibin Huang <haibin.huang@intel.com>
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/conf/domain_capabilities.c | 11 +++++++++++
>  src/conf/domain_capabilities.h | 22 ++++++++++++++++++++++
>  src/libvirt_private.syms       |  1 +
>  3 files changed, 34 insertions(+)

[...]

> diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
> index a526969cda..e4654a65cd 100644
> --- a/src/conf/domain_capabilities.h
> +++ b/src/conf/domain_capabilities.h
> @@ -193,6 +193,22 @@ struct _virSEVCapability {
>      unsigned int max_es_guests;
>  };
>  
> +typedef struct _virSection virSection;

This name feels a bit too generic and not much reusable. On the other
hand changing it feels pointless.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Re: [PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs
Posted by Daniel P. Berrangé 3 years, 4 months ago
On Thu, Jul 28, 2022 at 10:04:23AM +0200, Peter Krempa wrote:
> On Wed, Jul 27, 2022 at 12:34:53 +0200, Michal Privoznik wrote:
> > From: Haibin Huang <haibin.huang@intel.com>
> > 
> > Signed-off-by: Haibin Huang <haibin.huang@intel.com>
> > Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> > ---
> >  src/conf/domain_capabilities.c | 11 +++++++++++
> >  src/conf/domain_capabilities.h | 22 ++++++++++++++++++++++
> >  src/libvirt_private.syms       |  1 +
> >  3 files changed, 34 insertions(+)
> 
> [...]
> 
> > diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
> > index a526969cda..e4654a65cd 100644
> > --- a/src/conf/domain_capabilities.h
> > +++ b/src/conf/domain_capabilities.h
> > @@ -193,6 +193,22 @@ struct _virSEVCapability {
> >      unsigned int max_es_guests;
> >  };
> >  
> > +typedef struct _virSection virSection;
> 
> This name feels a bit too generic and not much reusable. On the other
> hand changing it feels pointless.

Clearly it should be   virSGXSection 

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 :|
Re: [PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs
Posted by Michal Prívozník 3 years, 4 months ago
On 7/28/22 10:35, Daniel P. Berrangé wrote:
> On Thu, Jul 28, 2022 at 10:04:23AM +0200, Peter Krempa wrote:
>> On Wed, Jul 27, 2022 at 12:34:53 +0200, Michal Privoznik wrote:
>>> From: Haibin Huang <haibin.huang@intel.com>
>>>
>>> Signed-off-by: Haibin Huang <haibin.huang@intel.com>
>>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>>> ---
>>>  src/conf/domain_capabilities.c | 11 +++++++++++
>>>  src/conf/domain_capabilities.h | 22 ++++++++++++++++++++++
>>>  src/libvirt_private.syms       |  1 +
>>>  3 files changed, 34 insertions(+)
>>
>> [...]
>>
>>> diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
>>> index a526969cda..e4654a65cd 100644
>>> --- a/src/conf/domain_capabilities.h
>>> +++ b/src/conf/domain_capabilities.h
>>> @@ -193,6 +193,22 @@ struct _virSEVCapability {
>>>      unsigned int max_es_guests;
>>>  };
>>>  
>>> +typedef struct _virSection virSection;
>>
>> This name feels a bit too generic and not much reusable. On the other
>> hand changing it feels pointless.

Ooops yes, of course. Been looking too much into these patches lately.

> 
> Clearly it should be   virSGXSection 

Indeed, fixed.

Michal

RE: [PATCH v14 07/15] domain_capabilities: Define SGX capabilities structs
Posted by Huang, Haibin 3 years, 4 months ago

> -----Original Message-----
> From: Daniel P. Berrangé <berrange@redhat.com>
> Sent: Thursday, July 28, 2022 4:36 PM
> To: Peter Krempa <pkrempa@redhat.com>
> Cc: Michal Privoznik <mprivozn@redhat.com>; libvir-list@redhat.com; Yang,
> Lin A <lin.a.yang@intel.com>; Ding, Jian-feng <jian-feng.ding@intel.com>;
> Huang, Haibin <haibin.huang@intel.com>
> Subject: Re: [PATCH v14 07/15] domain_capabilities: Define SGX capabilities
> structs
> 
> On Thu, Jul 28, 2022 at 10:04:23AM +0200, Peter Krempa wrote:
> > On Wed, Jul 27, 2022 at 12:34:53 +0200, Michal Privoznik wrote:
> > > From: Haibin Huang <haibin.huang@intel.com>
> > >
> > > Signed-off-by: Haibin Huang <haibin.huang@intel.com>
> > > Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> > > ---
> > >  src/conf/domain_capabilities.c | 11 +++++++++++
> > > src/conf/domain_capabilities.h | 22 ++++++++++++++++++++++
> > >  src/libvirt_private.syms       |  1 +
> > >  3 files changed, 34 insertions(+)
> >
> > [...]
> >
> > > diff --git a/src/conf/domain_capabilities.h
> > > b/src/conf/domain_capabilities.h index a526969cda..e4654a65cd 100644
> > > --- a/src/conf/domain_capabilities.h
> > > +++ b/src/conf/domain_capabilities.h
> > > @@ -193,6 +193,22 @@ struct _virSEVCapability {
> > >      unsigned int max_es_guests;
> > >  };
> > >
> > > +typedef struct _virSection virSection;
> >
> > This name feels a bit too generic and not much reusable. On the other
> > hand changing it feels pointless.
> 
> Clearly it should be   virSGXSection
[Haibin] good idea, I will modify it.
> 
> 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 :|