[libvirt] [PATCH v1 2/3] conf: Check migration_host is localhost or not during restart

Ján Tomko jtomko at redhat.com
Mon Sep 22 13:34:27 UTC 2014


On 09/12/2014 06:33 AM, Chen Fan wrote:
> Signed-off-by: Chen Fan <chen.fan.fnst at cn.fujitsu.com>
> ---
>  src/qemu/qemu_conf.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index ac10b64..013f3de 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -707,6 +707,17 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
>      GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
>  
>      GET_VALUE_STR("migration_host", cfg->migrateHost);
> +    if (cfg->migrateHost) {
> +        if (STRPREFIX(cfg->migrateHost, "localhost") ||
> +            STREQ(cfg->migrateHost, "127.0.0.1") ||
> +            STREQ(cfg->migrateHost, "::1") ||
> +            STREQ(cfg->migrateHost, "[::1]")) {\

I think we need a 'virSocketAddrIsLocalhost' function similar to
virSocketAddrIsWildcard, which would check any numeric represnation of the
address:

if (STRPREFIX(cfg->migrateHost, "localhost") ||
    virSocketAddrIsLocalhost(cfg->migrateHost))

> +            virReportError(VIR_ERR_CONF_SYNTAX, "%s",
> +                           _("migration_host must be a valid address or hostname"));

Something more specific, like: "migration_host must not be localhost" is more
user-friendly.

Jan

> +            goto cleanup;
> +        }
> +    }
> +
>      GET_VALUE_STR("migration_address", cfg->migrationAddress);
>  
>      GET_VALUE_BOOL("log_timestamp", cfg->logTimestamp);
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140922/451cd429/attachment-0001.sig>


More information about the libvir-list mailing list