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

[libvirt] [PATCH v2 4/4] conf: Check migration_address whether is localhost



When enabling the migration_address option, by default it is
set to "127.0.0.1", but it's not a valid address for migration.
so we should add verification and set the default migration_address
to "0.0.0.0".

Signed-off-by: Chen Fan <chen fan fnst cn fujitsu com>
---
 src/qemu/qemu.conf                 | 2 +-
 src/qemu/qemu_conf.c               | 7 +++++++
 src/qemu/test_libvirtd_qemu.aug.in | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 79bba36..666c303 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -459,7 +459,7 @@
 
 # Override the listen address for all incoming migrations. Defaults to
 # 0.0.0.0, or :: if both host and qemu are capable of IPv6.
-#migration_address = "127.0.0.1"
+#migration_address = "0.0.0.0"
 
 
 # The default hostname or IP address which will be used by a migration
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 30169cf..65f98d7 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -716,6 +716,13 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
     }
 
     GET_VALUE_STR("migration_address", cfg->migrationAddress);
+    if (cfg->migrationAddress &&
+        virSocketAddrIsLocalhost(cfg->migrationAddress)) {
+        virReportError(VIR_ERR_CONF_SYNTAX,
+                       _("migration_address must not be 'localhost' address: %s"),
+                       cfg->migrationAddress);
+        goto cleanup;
+    }
 
     GET_VALUE_BOOL("log_timestamp", cfg->logTimestamp);
 
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index d2bc2c0..30fd27e 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -69,7 +69,7 @@ module Test_libvirtd_qemu =
 { "keepalive_interval" = "5" }
 { "keepalive_count" = "5" }
 { "seccomp_sandbox" = "1" }
-{ "migration_address" = "127.0.0.1" }
+{ "migration_address" = "0.0.0.0" }
 { "migration_host" = "host.example.com" }
 { "migration_port_min" = "49152" }
 { "migration_port_max" = "49215" }
-- 
1.9.3


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