From: Lucas Amaral <lucaaamaral@gmail.com>
Add backup_port_min and backup_port_max configuration options to
qemu.conf, defaulting to 10809-10872 (10809 is the IANA-assigned
NBD port; range of 64 matches the migration port pattern).
Signed-off-by: Lucas Amaral <lucaaamaral@gmail.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
---
src/qemu/libvirtd_qemu.aug | 2 ++
src/qemu/qemu.conf.in | 9 +++++++++
src/qemu/qemu_conf.c | 25 +++++++++++++++++++++++++
src/qemu/qemu_conf.h | 3 +++
src/qemu/test_libvirtd_qemu.aug.in | 2 ++
5 files changed, 41 insertions(+)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 0286582169..eb790d48be 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -146,6 +146,8 @@ module Libvirtd_qemu =
| int_entry "migration_port_min"
| int_entry "migration_port_max"
| str_entry "migration_host"
+ | int_entry "backup_port_min"
+ | int_entry "backup_port_max"
let log_entry = bool_entry "log_timestamp"
diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in
index 2d1c67034d..5eacd70022 100644
--- a/src/qemu/qemu.conf.in
+++ b/src/qemu/qemu.conf.in
@@ -969,6 +969,15 @@
#migration_port_max = 49215
+# Port range used for automatic allocation of NBD backup server ports.
+# When a pull-mode backup is started without specifying a TCP port, a
+# port from this range will be assigned automatically. The NBD standard
+# port is 10809.
+#
+#backup_port_min = 10809
+#backup_port_max = 10872
+
+
# Timestamp QEMU's log messages (if QEMU supports it)
#
# Defaults to 1.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 3ea42da502..d43e0c2b97 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -74,6 +74,9 @@ VIR_LOG_INIT("qemu.qemu_conf");
#define QEMU_MIGRATION_PORT_MIN 49152
#define QEMU_MIGRATION_PORT_MAX 49215
+#define QEMU_BACKUP_PORT_MIN 10809
+#define QEMU_BACKUP_PORT_MAX 10872
+
VIR_ENUM_IMPL(virQEMUSchedCore,
QEMU_SCHED_CORE_LAST,
"none",
@@ -268,6 +271,9 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
cfg->migrationPortMin = QEMU_MIGRATION_PORT_MIN;
cfg->migrationPortMax = QEMU_MIGRATION_PORT_MAX;
+ cfg->backupPortMin = QEMU_BACKUP_PORT_MIN;
+ cfg->backupPortMax = QEMU_BACKUP_PORT_MAX;
+
/* For privileged driver, try and find hugetlbfs mounts automatically.
* Non-privileged driver requires admin to create a dir for the
* user, chown it, and then let user configure it manually. */
@@ -989,6 +995,25 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfig *cfg,
return -1;
}
+ if (virConfGetValueUInt(conf, "backup_port_min", &cfg->backupPortMin) < 0)
+ return -1;
+ if (cfg->backupPortMin <= 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%1$s: backup_port_min: port must be greater than 0"),
+ filename);
+ return -1;
+ }
+
+ if (virConfGetValueUInt(conf, "backup_port_max", &cfg->backupPortMax) < 0)
+ return -1;
+ if (cfg->backupPortMax > 65535 ||
+ cfg->backupPortMax < cfg->backupPortMin) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%1$s: backup_port_max: port must be between the minimal port %2$d and 65535"),
+ filename, cfg->backupPortMin);
+ return -1;
+ }
+
if (virConfGetValueString(conf, "migration_host", &cfg->migrateHost) < 0)
return -1;
virStringStripIPv6Brackets(cfg->migrateHost);
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index aa2bac6891..af1e7ee503 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -241,6 +241,9 @@ struct _virQEMUDriverConfig {
unsigned int migrationPortMin;
unsigned int migrationPortMax;
+ unsigned int backupPortMin;
+ unsigned int backupPortMax;
+
bool logTimestamp;
bool stdioLogD;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 82cfec3b4b..2582c6a09c 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -110,6 +110,8 @@ module Test_libvirtd_qemu =
{ "migration_host" = "host.example.com" }
{ "migration_port_min" = "49152" }
{ "migration_port_max" = "49215" }
+{ "backup_port_min" = "10809" }
+{ "backup_port_max" = "10872" }
{ "log_timestamp" = "0" }
{ "nvram"
{ "1" = "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" }
--
2.53.0
© 2016 - 2026 Red Hat, Inc.