]> 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)
committerJán Tomko <jtomko@redhat.com>
Thu, 9 Jan 2014 13:25:35 +0000 (14:25 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1019053
(cherry picked from commit e3ef20d7f7fee595ac4fc6094e04b7d65ee0583a)

Conflicts:
  missing support for changing the migration listen address

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

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 0f0a24c20ef4eaee1a6eead466370edc0b6b892d..e7c300bf8f5b1e127709407fe7f2d2d95ab07c73 100644 (file)
 # Defaults to -1.
 #
 #seccomp_sandbox = 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 7c3f317cf0d2e94f5770fd24a64f2c8c35a43719..1c8351f294b5e15605f7b467277dad3af1549be5 100644 (file)
@@ -228,6 +228,9 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
     cfg->remotePortMin = QEMU_REMOTE_PORT_MIN;
     cfg->remotePortMax = QEMU_REMOTE_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
@@ -433,6 +436,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 47fbef8f42192c440ce5c39189935ef29ac57b5c..a91d2a5873b42fcbf8ed5a0770aec376a9ccd2cd 100644 (file)
@@ -148,6 +148,9 @@ struct _virQEMUDriverConfig {
     unsigned int keepAliveCount;
 
     int seccompSandbox;
+
+    int migrationPortMin;
+    int migrationPortMax;
 };
 
 /* Main driver state */
index 777c6be3b9b0faba3e6d480339243ef8885dcfb2..21fed47ab735fcdb96c88e3be11654ce17a2a17f 100644 (file)
@@ -663,8 +663,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 26ca0688d81ad9ff2b1149637b82b75b727f398d..d57b3b48c48424e3793e36d83cc3c0d68ea9b678 100644 (file)
@@ -63,3 +63,5 @@ module Test_libvirtd_qemu =
 { "keepalive_interval" = "5" }
 { "keepalive_count" = "5" }
 { "seccomp_sandbox" = "1" }
+{ "migration_port_min" = "1234" }
+{ "migration_port_max" = "12345" }