[PATCH v3 08/12] conf: Add a memballoon helper for future use

Luke Yue posted 12 patches 4 years, 3 months ago
There is a newer version of this series
[PATCH v3 08/12] conf: Add a memballoon helper for future use
Posted by Luke Yue 4 years, 3 months ago
Currently it will only be used in test driver.

Signed-off-by: Luke Yue <lukedyue@gmail.com>
---
 src/conf/domain_conf.c   | 24 ++++++++++++++++++++++++
 src/conf/domain_conf.h   |  4 ++++
 src/libvirt_private.syms |  1 +
 3 files changed, 29 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 512bfab9e9..92a8bd63f3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16998,6 +16998,30 @@ virDomainTPMDefRemove(virDomainDef *def,
 }
 
 
+bool
+virDomainMemballoonDefEquals(const virDomainMemballoonDef *a,
+                             const virDomainMemballoonDef *b)
+{
+    if (a->model != b->model)
+        return false;
+
+    if (a->period != b->period)
+        return false;
+
+    if (a->autodeflate != b->autodeflate)
+        return false;
+
+    if (a->free_page_reporting != b->free_page_reporting)
+        return false;
+
+    if (a->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+        !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info))
+        return false;
+
+    return true;
+}
+
+
 char *
 virDomainDefGetDefaultEmulator(virDomainDef *def,
                                virCaps *caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 715c8fbd16..f60ba37d19 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3863,6 +3863,10 @@ ssize_t virDomainTPMDefFind(const virDomainDef *def,
 virDomainTPMDef *virDomainTPMDefRemove(virDomainDef *def, size_t idx)
     ATTRIBUTE_NONNULL(1);
 
+bool virDomainMemballoonDefEquals(const virDomainMemballoonDef *a,
+                                  const virDomainMemballoonDef *b)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
+
 VIR_ENUM_DECL(virDomainTaint);
 VIR_ENUM_DECL(virDomainTaintMessage);
 VIR_ENUM_DECL(virDomainVirt);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cfda58320a..b143537bb4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -506,6 +506,7 @@ virDomainLoaderTypeFromString;
 virDomainLoaderTypeToString;
 virDomainLockFailureTypeFromString;
 virDomainLockFailureTypeToString;
+virDomainMemballoonDefEquals;
 virDomainMemballoonModelTypeFromString;
 virDomainMemballoonModelTypeToString;
 virDomainMemoryDefFree;
-- 
2.33.1

Re: [PATCH v3 08/12] conf: Add a memballoon helper for future use
Posted by Martin Kletzander 4 years, 2 months ago
On Wed, Nov 10, 2021 at 10:24:27PM +0800, Luke Yue wrote:
>Currently it will only be used in test driver.
>
>Signed-off-by: Luke Yue <lukedyue@gmail.com>
>---
> src/conf/domain_conf.c   | 24 ++++++++++++++++++++++++
> src/conf/domain_conf.h   |  4 ++++
> src/libvirt_private.syms |  1 +
> 3 files changed, 29 insertions(+)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 512bfab9e9..92a8bd63f3 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -16998,6 +16998,30 @@ virDomainTPMDefRemove(virDomainDef *def,
> }
>
>
>+bool
>+virDomainMemballoonDefEquals(const virDomainMemballoonDef *a,
>+                             const virDomainMemballoonDef *b)

It is really weird that you picked the membaloon as that particular one
does not really make sense to be present multiple times, it is similar
to the watchdog device.  It is not a problem in this case, but I feel
like this function is a bit useless.
Re: [PATCH v3 08/12] conf: Add a memballoon helper for future use
Posted by Luke Yue 4 years, 2 months ago
On Fri, 2021-11-26 at 16:44 +0100, Martin Kletzander wrote:
> On Wed, Nov 10, 2021 at 10:24:27PM +0800, Luke Yue wrote:
> > Currently it will only be used in test driver.
> > 
> > Signed-off-by: Luke Yue <lukedyue@gmail.com>
> > ---
> > src/conf/domain_conf.c   | 24 ++++++++++++++++++++++++
> > src/conf/domain_conf.h   |  4 ++++
> > src/libvirt_private.syms |  1 +
> > 3 files changed, 29 insertions(+)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index 512bfab9e9..92a8bd63f3 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -16998,6 +16998,30 @@ virDomainTPMDefRemove(virDomainDef *def,
> > }
> > 
> > 
> > +bool
> > +virDomainMemballoonDefEquals(const virDomainMemballoonDef *a,
> > +                             const virDomainMemballoonDef *b)
> 
> It is really weird that you picked the membaloon as that particular
> one
> does not really make sense to be present multiple times, it is
> similar
> to the watchdog device.  It is not a problem in this case, but I feel
> like this function is a bit useless.

Oh, sorry, I didn't realize that, I forgot that the device would just
present once, so that we can just remove the device without comparison,
I will remove the comparison function.

Thanks,
Luke