[libvirt] [RFC PATCH 2/6] conf: Tweak HPT parsing and formatting

Peter Krempa pkrempa at redhat.com
Wed May 23 16:42:31 UTC 2018


On Wed, May 23, 2018 at 18:17:58 +0200, Andrea Bolognani wrote:
> This doesn't seem very useful at the moment, but it will make
> sense once we introduce another HPT-related setting.
> 
> The output XML is decoupled from the input XML in preparation
> of future changes as well; while doing so, we can shave a few
> lines off the latter.
> 
> This commit is best viewed with 'git show -w'.
> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  src/conf/domain_conf.c                        | 25 ++++++++++++---
>  src/qemu/qemu_command.c                       | 32 ++++++++++---------
>  tests/qemuxml2argvdata/pseries-features.xml   | 14 ++------
>  tests/qemuxml2xmloutdata/pseries-features.xml | 29 ++++++++++++++++-
>  4 files changed, 68 insertions(+), 32 deletions(-)
>  mode change 120000 => 100644 tests/qemuxml2xmloutdata/pseries-features.xml
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 355e497002..20b845f02a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -27207,14 +27207,31 @@ virDomainDefFormatInternal(virDomainDefPtr def,
>                                    virDomainIOAPICTypeToString(def->features[i]));
>                  break;
>  
> -            case VIR_DOMAIN_FEATURE_HPT:
> +            case VIR_DOMAIN_FEATURE_HPT: {
> +                bool hasResizing = def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE;
> +                char *resizing = NULL;
> +
>                  if (def->features[i] != VIR_TRISTATE_SWITCH_ON ||
> -                    def->hpt_resizing == VIR_DOMAIN_HPT_RESIZING_NONE)
> +                    !hasResizing) {
>                      break;
> +                }
> +
> +                if (hasResizing) {
> +                    if (virAsprintf(&resizing, " resizing='%s'",
> +                                    virDomainHPTResizingTypeToString(def->hpt_resizing)) < 0) {
> +                        goto error;
> +                    }
> +                } else {
> +                    if (VIR_STRDUP(resizing, "") < 0)
> +                        goto error;
> +                }
>  
> -                virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
> -                                  virDomainHPTResizingTypeToString(def->hpt_resizing));
> +                virBufferAsprintf(buf, "<hpt%s/>\n",

This formulation looks fishy.

> +                                  resizing);
> +
> +                VIR_FREE(resizing);
>                  break;
> +            }
>  
>              /* coverity[dead_error_begin] */
>              case VIR_DOMAIN_FEATURE_LAST:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180523/4491ea5a/attachment-0001.sig>


More information about the libvir-list mailing list