[libvirt] [PATCH 02/13] conf: Add helper to determine whether memory hotplug is enabled for a vm

Peter Krempa pkrempa at redhat.com
Tue Sep 22 13:04:06 UTC 2015


On Tue, Sep 22, 2015 at 14:29:26 +0200, Michal Privoznik wrote:
> On 21.09.2015 19:21, Peter Krempa wrote:
> > Add a simple helper so that the code doesn't have to rewrite the same
> > condition multiple times.
> > ---
> >  src/conf/domain_conf.c    | 9 ++++++++-
> >  src/conf/domain_conf.h    | 1 +
> >  src/libvirt_private.syms  | 1 +
> >  src/qemu/qemu_command.c   | 2 +-
> >  src/qemu/qemu_domain.c    | 2 +-
> >  src/qemu/qemu_migration.c | 5 ++---
> >  6 files changed, 14 insertions(+), 6 deletions(-)
> > 
> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> > index a3b3ccb..fa2e331 100644
> > --- a/src/conf/domain_conf.c
> > +++ b/src/conf/domain_conf.c
> > @@ -1154,7 +1154,7 @@ int
> >  virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def)
> >  {
> >      /* memory hotplug tunables are not supported by this driver */
> > -    if (def->mem.max_memory > 0 || def->mem.memory_slots > 0) {
> > +    if (virDomainDefHasMemoryHotplug(def)) {
> >          virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> >                         _("memory hotplug tunables <maxMemory> are not "
> >                           "supported by this hypervisor driver"));
> > @@ -7671,6 +7671,13 @@ virDomainParseMemoryLimit(const char *xpath,
> >  }
> > 
> > 
> > +bool
> > +virDomainDefHasMemoryHotplug(const virDomainDef *def)
> > +{
> > +    return def->mem.memory_slots > 0 || def->mem.max_memory > 0;
> > +}
> > +
> 
> There are some other occurrences of this pattern too, e.g.:
> 
> virDomainDefPostParseInternal

Well this place makes sure that both the slot count and maximum size
were specified so I think it makes sense to leave the condition to stay
explicit as it's now so that it's more clear what's happening there.

> virDomainDefFormatInternal

I'll change this one.

> 
> Probably worth 'fixing' those places too.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150922/356cf973/attachment-0001.sig>


More information about the libvir-list mailing list