[libvirt] [PATCH v4 1/1] migration: add support for migrateURI configuration

For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime. Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> --- v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params() src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1 - +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1" # 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..43361dc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -574,6 +574,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox); + GET_VALUE_STR("migrate_uri", cfg->migrateUri); GET_VALUE_STR("migration_address", cfg->migrationAddress); ret = 0; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a36ea63..f99c56e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -163,6 +163,7 @@ struct _virQEMUDriverConfig { int seccompSandbox; + char *migrateUri; /* The default for -incoming */ char *migrationAddress; int migrationPortMin; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fca1a91..56c24b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10888,7 +10888,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; - const char *uri_in = NULL; + const char *uri_in = cfg->migrateUri; const char *listenAddress = cfg->migrationAddress; char *origname = NULL; int ret = -1; -- 1.8.1.4

Hi all, this series patch has been no response for several days, at opening discussion at https://www.redhat.com/archives/libvir-list/2014-April/msg00682.html, Jiri agreed with my point of view. but does anyone else have an opinion about this? any suggestion is welcome. Thanks, Chen On Wed, 2014-05-14 at 15:18 +0800, Chen Fan wrote:
For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> ---
v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1
- +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1"
# 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..43361dc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -574,6 +574,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
+ GET_VALUE_STR("migrate_uri", cfg->migrateUri); GET_VALUE_STR("migration_address", cfg->migrationAddress);
ret = 0; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a36ea63..f99c56e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -163,6 +163,7 @@ struct _virQEMUDriverConfig {
int seccompSandbox;
+ char *migrateUri; /* The default for -incoming */ char *migrationAddress; int migrationPortMin; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fca1a91..56c24b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10888,7 +10888,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; - const char *uri_in = NULL; + const char *uri_in = cfg->migrateUri; const char *listenAddress = cfg->migrationAddress; char *origname = NULL; int ret = -1;

On Wed, May 14, 2014 at 15:18:09 +0800, Chen Fan wrote:
For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> ---
v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1
- +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1"
# Override the listen address for all incoming migrations. Defaults to # 0.0.0.0, or :: if both host and qemu are capable of IPv6.
The more I think about this the more I incline to a slightly different approach. Rather than providing a way to override migration URI, we could just provide an option in libvirtd.conf to override what virGetHostname returns. That is, the option (naturally called hostname) would tell libvirt to use the configured hostname (which might even be just an IP address) instead of trying to detect it.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 198ee2f..43361dc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -574,6 +574,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
+ GET_VALUE_STR("migrate_uri", cfg->migrateUri); GET_VALUE_STR("migration_address", cfg->migrationAddress);
ret = 0; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a36ea63..f99c56e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -163,6 +163,7 @@ struct _virQEMUDriverConfig {
int seccompSandbox;
+ char *migrateUri; /* The default for -incoming */ char *migrationAddress; int migrationPortMin; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fca1a91..56c24b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10888,7 +10888,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; - const char *uri_in = NULL; + const char *uri_in = cfg->migrateUri; const char *listenAddress = cfg->migrationAddress; char *origname = NULL; int ret = -1;
And in any case, the change you made between v3 and v4 is wrong, since now you are only change one entry point to the Prepare phase while changing qemuMigrationPrepareDirect makes this work for all APIs and migration protocol versions. Jirka

On Wed, May 14, 2014 at 15:18:09 +0800, Chen Fan wrote:
For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> ---
v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1
- +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1"
# Override the listen address for all incoming migrations. Defaults to # 0.0.0.0, or :: if both host and qemu are capable of IPv6.
The more I think about this the more I incline to a slightly different approach. Rather than providing a way to override migration URI, we could just provide an option in libvirtd.conf to override what virGetHostname returns. That is, the option (naturally called hostname) would tell libvirt to use the configured hostname (which might even be just an IP address) instead of trying to detect it. If I understand correctly. you prefer using a hostname(or IP address)
Hi, Firstly thanks for your attention. On Thu, 2014-05-15 at 11:50 +0200, Jiri Denemark wrote: option in libvirtd.conf to configuring a default migration URI in qemu.conf, right? do you want to affect the all virGetHostname() returns? I'm afraid I can't see any benefit to the goal, could you tell me that? Thanks, Chen
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 198ee2f..43361dc 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -574,6 +574,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
+ GET_VALUE_STR("migrate_uri", cfg->migrateUri); GET_VALUE_STR("migration_address", cfg->migrationAddress);
ret = 0; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a36ea63..f99c56e 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -163,6 +163,7 @@ struct _virQEMUDriverConfig {
int seccompSandbox;
+ char *migrateUri; /* The default for -incoming */ char *migrationAddress; int migrationPortMin; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fca1a91..56c24b5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10888,7 +10888,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; - const char *uri_in = NULL; + const char *uri_in = cfg->migrateUri; const char *listenAddress = cfg->migrationAddress; char *origname = NULL; int ret = -1;
And in any case, the change you made between v3 and v4 is wrong, since now you are only change one entry point to the Prepare phase while changing qemuMigrationPrepareDirect makes this work for all APIs and migration protocol versions.
Oh, you are right. thanks. Chen
Jirka

On Thu, May 15, 2014 at 11:50:54AM +0200, Jiri Denemark wrote:
On Wed, May 14, 2014 at 15:18:09 +0800, Chen Fan wrote:
For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> ---
v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1
- +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1"
# Override the listen address for all incoming migrations. Defaults to # 0.0.0.0, or :: if both host and qemu are capable of IPv6.
The more I think about this the more I incline to a slightly different approach. Rather than providing a way to override migration URI, we could just provide an option in libvirtd.conf to override what virGetHostname returns. That is, the option (naturally called hostname) would tell libvirt to use the configured hostname (which might even be just an IP address) instead of trying to detect it.
I'm not sure this is a good idea. The hostname is used in a number of places in libvirt, and we don't neccessarily want them all to use the same interface as the migration data. eg if you have a NIC that is dedicated just for migration traffic, you won't want to force other parts of libvirt to use that. So having the migration hostname specified separately is a good idea IMHO. Perhaps we could simplify though by having 'migrate_host' rather than 'migrate_uri' ? And perhaps we do want a hostname override globally anyway, for other reasons. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Fri, 2014-05-16 at 09:51 -0400, Daniel P. Berrange wrote:
On Thu, May 15, 2014 at 11:50:54AM +0200, Jiri Denemark wrote:
On Wed, May 14, 2014 at 15:18:09 +0800, Chen Fan wrote:
For now, we set the migration URI via 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 patches add a configuration file option on dest host to save the default migrate uri which explicitly specify which of this host's addresses is used for transferring data, thus user doesn't boring to specify it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> ---
v3-v4: move up the default uri_in setting to qemuDomainMigratePrepare3Params()
src/qemu/qemu.conf | 6 +++++- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_driver.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index f0e802f..6b443d0 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -449,7 +449,11 @@ # #seccomp_sandbox = 1
- +# Override the migration URI for specifying one of host's IP addresses +# to transfer the migration data stream. +# Defaults to hostname, both IPv4 and IPv6 addresses are accepted. +# +#migrate_uri = "tcp://192.168.0.1"
# Override the listen address for all incoming migrations. Defaults to # 0.0.0.0, or :: if both host and qemu are capable of IPv6.
The more I think about this the more I incline to a slightly different approach. Rather than providing a way to override migration URI, we could just provide an option in libvirtd.conf to override what virGetHostname returns. That is, the option (naturally called hostname) would tell libvirt to use the configured hostname (which might even be just an IP address) instead of trying to detect it.
I'm not sure this is a good idea. The hostname is used in a number of places in libvirt, and we don't neccessarily want them all to use the same interface as the migration data. eg if you have a NIC that is dedicated just for migration traffic, you won't want to force other parts of libvirt to use that. So having the migration hostname specified separately is a good idea IMHO. Perhaps we could simplify though by having 'migrate_host' rather than 'migrate_uri' ? I think that is a good idea. I would like to implement them.
Thanks, Chen
And perhaps we do want a hostname override globally anyway, for other reasons.
Regards, Daniel
participants (4)
-
Chen Fan
-
chen.fan.fnst@cn.fujitsu.com
-
Daniel P. Berrange
-
Jiri Denemark