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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]