Re: [PATCH] qemu: Set swap_hard_limit before hard_limit

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

 



On Thu, Jul 12, 2012 at 05:03:52PM +0800, Osier Yang wrote:
> Setting hard_limit larger than previous swap_hard_limit must fail,
> it's not that good if one wants to change the swap_hard_limit
> and hard_limit together. E.g.
> 
> % virsh memtune rhel6
> hard_limit     : 1000000
> soft_limit     : 1000000
> swap_hard_limit: 1000000
> 
> % virsh memtune rhel6 --hard-limit 1000020 --soft-limit 1000020 \
> --swap-hard-limit 1000020 --live
> 
> This patch reoder the limits setting to set the swap_hard_limit
> first.
> ---
>  src/qemu/qemu_driver.c |   26 +++++++++++++-------------
>  1 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index dc04d13..1abdd27 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6625,43 +6625,43 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
>      for (i = 0; i < nparams; i++) {
>          virTypedParameterPtr param = &params[i];

Does this patch make any difference if the order of elements of params[]
doesn't change?

>  
> -        if (STREQ(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) {
> +        if (STREQ(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT)) {
>              if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> -                rc = virCgroupSetMemoryHardLimit(group, params[i].value.ul);
> +                rc = virCgroupSetMemSwapHardLimit(group, params[i].value.ul);
>                  if (rc != 0) {
>                      virReportSystemError(-rc, "%s",
> -                                         _("unable to set memory hard_limit tunable"));
> +                                         _("unable to set swap_hard_limit tunable"));
>                      ret = -1;
>                  }
>              }
> -
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> -                persistentDef->mem.hard_limit = params[i].value.ul;
> +                persistentDef->mem.swap_hard_limit = params[i].value.ul;
>              }
> -        } else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) {
> +        } else if (STREQ(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT)) {
>              if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> -                rc = virCgroupSetMemorySoftLimit(group, params[i].value.ul);
> +                rc = virCgroupSetMemoryHardLimit(group, params[i].value.ul);
>                  if (rc != 0) {
>                      virReportSystemError(-rc, "%s",
> -                                         _("unable to set memory soft_limit tunable"));
> +                                         _("unable to set memory hard_limit tunable"));
>                      ret = -1;
>                  }
>              }
>  
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> -                persistentDef->mem.soft_limit = params[i].value.ul;
> +                persistentDef->mem.hard_limit = params[i].value.ul;
>              }
> -        } else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT)) {
> +        } else if (STREQ(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT)) {
>              if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> -                rc = virCgroupSetMemSwapHardLimit(group, params[i].value.ul);
> +                rc = virCgroupSetMemorySoftLimit(group, params[i].value.ul);
>                  if (rc != 0) {
>                      virReportSystemError(-rc, "%s",
> -                                         _("unable to set swap_hard_limit tunable"));
> +                                         _("unable to set memory soft_limit tunable"));
>                      ret = -1;
>                  }
>              }
> +
>              if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
> -                persistentDef->mem.swap_hard_limit = params[i].value.ul;
> +                persistentDef->mem.soft_limit = params[i].value.ul;
>              }
>          }
>      }
> -- 
> 1.7.7.3
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

-- 
Thanks,
Hu Tao

--
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]