Re: [PATCH 11/23] qemu_conf: split out virQEMUDriverConfigLoadNetworkEntry

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

 




On 1/15/19 8:23 AM, Ján Tomko wrote:
> Split out parts of the config parsing code to make
> the parent function easier to read.
> 
> Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
> ---
>  src/qemu/qemu_conf.c | 99 +++++++++++++++++++++++++-------------------
>  1 file changed, 56 insertions(+), 43 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index b7d258f17a..8aa5157cd1 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -423,6 +423,60 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
>  }
>  
>  
> +static int
> +virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfigPtr cfg,
> +                                    virConfPtr conf,
> +                                    const char *filename)
> +{
> +    if (virConfGetValueUInt(conf, "migration_port_min", &cfg->migrationPortMin) < 0)
> +        return -1;
> +    if (cfg->migrationPortMin <= 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("%s: migration_port_min: port must be greater than 0"),
> +                        filename);
> +        return -1;
> +    }
> +
> +    if (virConfGetValueUInt(conf, "migration_port_max", &cfg->migrationPortMax) < 0)
> +        return -1;
> +    if (cfg->migrationPortMax > 65535 ||
> +        cfg->migrationPortMax < cfg->migrationPortMin) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                        _("%s: migration_port_max: port must be between "
> +                          "the minimal port %d and 65535"),
> +                       filename, cfg->migrationPortMin);
> +        return -1;
> +    }
> +
> +    if (virConfGetValueString(conf, "migration_host", &cfg->migrateHost) < 0)
> +        return -1;
> +    virStringStripIPv6Brackets(cfg->migrateHost);
> +    if (cfg->migrateHost &&
> +        (STRPREFIX(cfg->migrateHost, "localhost") ||
> +         virSocketAddrIsNumericLocalhost(cfg->migrateHost))) {
> +        virReportError(VIR_ERR_CONF_SYNTAX,
> +                       _("migration_host must not be the address of"
> +                         " the local machine: %s"),
> +                       cfg->migrateHost);
> +        return -1;
> +    }
> +
> +    if (virConfGetValueString(conf, "migration_address", &cfg->migrationAddress) < 0)
> +        return -1;
> +    virStringStripIPv6Brackets(cfg->migrationAddress);
> +    if (cfg->migrationAddress &&
> +        (STRPREFIX(cfg->migrationAddress, "localhost") ||
> +         virSocketAddrIsNumericLocalhost(cfg->migrationAddress))) {
> +        virReportError(VIR_ERR_CONF_SYNTAX,
> +                       _("migration_address must not be the address of"
> +                         " the local machine: %s"),
> +                       cfg->migrationAddress);
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +

blank line

Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>

John
[...]

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

  Powered by Linux