Re: [libvirt] [PATCH v1 2/3] conf: Check migration_host is localhost or not during restart
On 09/12/2014 06:33 AM, Chen Fan wrote: Signed-off-by: Chen Fan chen.fan.f...@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); signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v1 2/3] conf: Check migration_host is localhost or not during restart
On Mon, 2014-09-22 at 15:34 +0200, Ján Tomko wrote: On 09/12/2014 06:33 AM, Chen Fan wrote: Signed-off-by: Chen Fan chen.fan.f...@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)) It's a good point. +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. I will update the output. Thanks, Chen Jan +goto cleanup; +} +} + GET_VALUE_STR(migration_address, cfg-migrationAddress); GET_VALUE_BOOL(log_timestamp, cfg-logTimestamp); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v1 2/3] conf: Check migration_host is localhost or not during restart
Signed-off-by: Chen Fan chen.fan.f...@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])) { +virReportError(VIR_ERR_CONF_SYNTAX, %s, + _(migration_host must be a valid address or hostname)); +goto cleanup; +} +} + GET_VALUE_STR(migration_address, cfg-migrationAddress); GET_VALUE_BOOL(log_timestamp, cfg-logTimestamp); -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list