For now, we set the migration URI from command line '--migrate_uri' or construct the URI by looking up the dest host's hostname which could be solved by DNS automatically. But in cases the dest host have two or more NICs to reach, we may need to send the migration data over a specific NIC which is different from the automatically resloved one for some reason like performance, security, etc. thus we must explicitly specify the migrateuri in command line everytime, but it is too troublesome if there are many such hosts(and don't forget virt-manager). This patch adds a configuration file option on dest host to save the default migrate uri which explicitly configure which of this host's addresses should be used to transfer, thus user doesn't boring to specify it in command line everytime. Signed-off-by: Chen Fan <chen.fan.fnst@xxxxxxxxxxxxxx> --- src/qemu/qemu.conf | 5 ++++- src/qemu/qemu_conf.c | 2 ++ src/qemu/qemu_conf.h | 2 ++ src/qemu/qemu_migration.c | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..2973631 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,10 @@ # #seccomp_sandbox = 1 - +# Override the URI used for any specific migration URI to be sent. +# Defaults to NULL, will be set to as "tcp://hostIP[:port]". +# +#migrate_uri = "tcp://hostIP:port" # Override the listen address for all incoming migrations. Defaults to # 0.0.0.0, or :: if both host and qemu are capable of IPv6. diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 198ee2f..0bd943d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -576,6 +576,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_STR("migration_address", cfg->migrationAddress); + GET_VALUE_STR("migrate_uri", cfg->migrateUri); + ret = 0; cleanup: diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a36ea63..2e45421 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -167,6 +167,8 @@ struct _virQEMUDriverConfig { char *migrationAddress; int migrationPortMin; int migrationPortMax; + + char *migrateUri; }; /* Main driver state */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 593d2d3..ab64c58 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2639,6 +2639,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, int ret = -1; virURIPtr uri = NULL; bool well_formed_uri = true; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, " "cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, " @@ -2649,6 +2650,10 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, *uri_out = NULL; + if (uri_in == NULL && cfg->migrateUri) { + uri_in = cfg->migrateUri; + } + /* The URI passed in may be NULL or a string "tcp://somehostname:port". * * If the URI passed in is NULL then we allocate a port number -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list