[libvirt] [PATCH v2 03/25] qemu: Move <memballoon> validation out of qemu_command.c

Andrea Bolognani abologna at redhat.com
Thu Jan 24 15:46:32 UTC 2019


On Wed, 2019-01-23 at 16:32 -0500, Cole Robinson wrote:
[...]
> +static int
> +qemuDomainDeviceDefValidateMemballoon(const virDomainMemballoonDef *memballoon,

You could pass

  const virDomainDef *def

too here, as most other qemuDomainDeviceDefValidate*() functions
already do: that would allow you to...

> +                                      virQEMUCapsPtr qemuCaps)
> +{
> +    if (!memballoon ||
> +        memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_NONE) {
> +        return 0;
> +    }

... replace this with

  if (!virDomainDefHasMemballoon(def))
      return 0;

which is arguably slightly nicer. But this version works perfectly
fine, so it's entirely up to you whether to do that or not.

[...]
> @@ -2463,11 +2462,10 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
>      }
>  
>      if (persistentDef) {
> -        if (!persistentDef->memballoon ||
> -            persistentDef->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) {
> +        if (!virDomainDefHasMemballoon(def)) {

s/def/persistentDef/

With this fixed,

  Reviewed-by: Andrea Bolognani <abologna at redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list