|
|
43fe83 |
From 3b3b9b240e186546abf11b2683bf917be5fc854f Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <3b3b9b240e186546abf11b2683bf917be5fc854f.1382534061.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
Date: Tue, 22 Oct 2013 16:24:47 +0100
|
|
|
43fe83 |
Subject: [PATCH] qemu: Make migration port range configurable
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1019237
|
|
|
43fe83 |
|
|
|
43fe83 |
(cherry picked from commit e3ef20d7f7fee595ac4fc6094e04b7d65ee0583a)
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/qemu/qemu.conf | 11 +++++++++++
|
|
|
43fe83 |
src/qemu/qemu_conf.c | 21 +++++++++++++++++++++
|
|
|
43fe83 |
src/qemu/qemu_conf.h | 2 ++
|
|
|
43fe83 |
src/qemu/qemu_driver.c | 4 ++--
|
|
|
43fe83 |
src/qemu/test_libvirtd_qemu.aug.in | 2 ++
|
|
|
43fe83 |
5 files changed, 38 insertions(+), 2 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
|
|
|
43fe83 |
index 541db64..4b59320 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu.conf
|
|
|
43fe83 |
+++ b/src/qemu/qemu.conf
|
|
|
43fe83 |
@@ -427,3 +427,14 @@
|
|
|
43fe83 |
# Override the listen address for all incoming migrations. Defaults to
|
|
|
43fe83 |
# 0.0.0.0 or :: in case if both host and qemu are capable of IPv6.
|
|
|
43fe83 |
#migration_address = "127.0.0.1"
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+# Override the port range used for incoming migrations.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# Minimum must be greater than 0, however when QEMU is not running as root,
|
|
|
43fe83 |
+# setting the minimum to be lower than 1024 will not work.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+# Maximum must not be greater than 65535.
|
|
|
43fe83 |
+#
|
|
|
43fe83 |
+#migration_port_min = 49152
|
|
|
43fe83 |
+#migration_port_max = 49215
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
|
43fe83 |
index cea139d..e45180a 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_conf.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_conf.c
|
|
|
43fe83 |
@@ -207,6 +207,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
|
|
|
43fe83 |
cfg->webSocketPortMin = QEMU_WEBSOCKET_PORT_MIN;
|
|
|
43fe83 |
cfg->webSocketPortMax = QEMU_WEBSOCKET_PORT_MAX;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ cfg->migrationPortMin = QEMU_MIGRATION_PORT_MIN;
|
|
|
43fe83 |
+ cfg->migrationPortMax = QEMU_MIGRATION_PORT_MAX;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
|
|
|
43fe83 |
/* For privileged driver, try and find hugepage mount automatically.
|
|
|
43fe83 |
* Non-privileged driver requires admin to create a dir for the
|
|
|
43fe83 |
@@ -440,6 +443,24 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
+ GET_VALUE_LONG("migration_port_min", cfg->migrationPortMin);
|
|
|
43fe83 |
+ if (cfg->migrationPortMin <= 0) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
43fe83 |
+ _("%s: migration_port_min: port must be greater than 0"),
|
|
|
43fe83 |
+ filename);
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ GET_VALUE_LONG("migration_port_max", cfg->migrationPortMax);
|
|
|
43fe83 |
+ if (cfg->migrationPortMax > 65535 ||
|
|
|
43fe83 |
+ cfg->migrationPortMax < cfg->migrationPortMin) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
43fe83 |
+ _("%s: migration_port_max: port must be between "
|
|
|
43fe83 |
+ "the minimal port %d and 65535"),
|
|
|
43fe83 |
+ filename, cfg->migrationPortMin);
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
p = virConfGetValue(conf, "user");
|
|
|
43fe83 |
CHECK_TYPE("user", VIR_CONF_STRING);
|
|
|
43fe83 |
if (p && p->str &&
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
|
|
|
43fe83 |
index 4acc67b..576a2e2 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_conf.h
|
|
|
43fe83 |
+++ b/src/qemu/qemu_conf.h
|
|
|
43fe83 |
@@ -158,6 +158,8 @@ struct _virQEMUDriverConfig {
|
|
|
43fe83 |
|
|
|
43fe83 |
/* The default for -incoming */
|
|
|
43fe83 |
char *migrationAddress;
|
|
|
43fe83 |
+ int migrationPortMin;
|
|
|
43fe83 |
+ int migrationPortMax;
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
/* Main driver state */
|
|
|
43fe83 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
43fe83 |
index 4a4880c..226e32d 100644
|
|
|
43fe83 |
--- a/src/qemu/qemu_driver.c
|
|
|
43fe83 |
+++ b/src/qemu/qemu_driver.c
|
|
|
43fe83 |
@@ -688,8 +688,8 @@ qemuStateInitialize(bool privileged,
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
|
|
|
43fe83 |
if ((qemu_driver->migrationPorts =
|
|
|
43fe83 |
- virPortAllocatorNew(QEMU_MIGRATION_PORT_MIN,
|
|
|
43fe83 |
- QEMU_MIGRATION_PORT_MAX)) == NULL)
|
|
|
43fe83 |
+ virPortAllocatorNew(cfg->migrationPortMin,
|
|
|
43fe83 |
+ cfg->migrationPortMax)) == NULL)
|
|
|
43fe83 |
goto error;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (qemuSecurityInit(qemu_driver) < 0)
|
|
|
43fe83 |
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
|
|
|
43fe83 |
index be4518c..d6d55b8 100644
|
|
|
43fe83 |
--- a/src/qemu/test_libvirtd_qemu.aug.in
|
|
|
43fe83 |
+++ b/src/qemu/test_libvirtd_qemu.aug.in
|
|
|
43fe83 |
@@ -67,3 +67,5 @@ module Test_libvirtd_qemu =
|
|
|
43fe83 |
{ "keepalive_count" = "5" }
|
|
|
43fe83 |
{ "seccomp_sandbox" = "1" }
|
|
|
43fe83 |
{ "migration_address" = "127.0.0.1" }
|
|
|
43fe83 |
+{ "migration_port_min" = "1234" }
|
|
|
43fe83 |
+{ "migration_port_max" = "12345" }
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.4
|
|
|
43fe83 |
|