]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Make migration port range configurable
authorJiri Denemark <jdenemar@redhat.com>
Tue, 15 Oct 2013 13:26:52 +0000 (15:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 18 Oct 2013 14:35:38 +0000 (16:35 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1019053

src/qemu/qemu.conf
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_driver.c
src/qemu/test_libvirtd_qemu.aug.in

index e5ff33d5220638cd25e4ee02f98dce8f0c732787..6cfb9ea8ca5a6fd6ba05906a7721f6a341ee67cd 100644 (file)
 # Override the listen address for all incoming migrations. Defaults to
 # 0.0.0.0 or :: in case if both host and qemu are capable of IPv6.
 #migration_address = "127.0.0.1"
+
+
+# Override the port range used for incoming migrations.
+#
+# Minimum must be greater than 0, however when QEMU is not running as root,
+# setting the minimum to be lower than 1024 will not work.
+#
+# Maximum must not be greater than 65535.
+#
+#migration_port_min = 49152
+#migration_port_max = 49215
index 8d7bee8296e99fe4c1a02a66f3332bdc5ac56ba9..4ef9c758884519a5cc7ea16dcf8809a5015f4f47 100644 (file)
@@ -225,6 +225,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
     cfg->webSocketPortMin = QEMU_WEBSOCKET_PORT_MIN;
     cfg->webSocketPortMax = QEMU_WEBSOCKET_PORT_MAX;
 
+    cfg->migrationPortMin = QEMU_MIGRATION_PORT_MIN;
+    cfg->migrationPortMax = QEMU_MIGRATION_PORT_MAX;
+
 #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
     /* For privileged driver, try and find hugepage mount automatically.
      * Non-privileged driver requires admin to create a dir for the
@@ -462,6 +465,24 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
         goto cleanup;
     }
 
+    GET_VALUE_LONG("migration_port_min", cfg->migrationPortMin);
+    if (cfg->migrationPortMin <= 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("%s: migration_port_min: port must be greater than 0"),
+                        filename);
+        goto cleanup;
+    }
+
+    GET_VALUE_LONG("migration_port_max", cfg->migrationPortMax);
+    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);
+        goto cleanup;
+    }
+
     p = virConfGetValue(conf, "user");
     CHECK_TYPE("user", VIR_CONF_STRING);
     if (p && p->str &&
index c6fbaa56edf841e8f9105ae96ef8fa2efa7dfba3..f9ff7afa09bf902eabf1249150aac0ea327ddf8d 100644 (file)
@@ -161,6 +161,8 @@ struct _virQEMUDriverConfig {
 
     /* The default for -incoming */
     char *migrationAddress;
+    int migrationPortMin;
+    int migrationPortMax;
 };
 
 /* Main driver state */
index 895681b60bc8eaf006fbf509b737ab11e1936e56..4977b12d1aa1ca6c8eec72499fa9c3b452019489 100644 (file)
@@ -688,8 +688,8 @@ qemuStateInitialize(bool privileged,
         goto error;
 
     if ((qemu_driver->migrationPorts =
-         virPortAllocatorNew(QEMU_MIGRATION_PORT_MIN,
-                             QEMU_MIGRATION_PORT_MAX)) == NULL)
+         virPortAllocatorNew(cfg->migrationPortMin,
+                             cfg->migrationPortMax)) == NULL)
         goto error;
 
     if (qemuSecurityInit(qemu_driver) < 0)
index 7417d124e3d8e32c24cfe6ecf07e88811a7296c5..8f4b3a9d2c14813962caf8a0e7340338a53289b1 100644 (file)
@@ -70,3 +70,5 @@ module Test_libvirtd_qemu =
 { "keepalive_count" = "5" }
 { "seccomp_sandbox" = "1" }
 { "migration_address" = "127.0.0.1" }
+{ "migration_port_min" = "1234" }
+{ "migration_port_max" = "12345" }