Re: [libvirt] [PATCH v3 1/3] migration: add migration_host support for Ipv6 address without brackets

2014-10-07 Thread Ján Tomko
On 10/07/2014 06:07 AM, Chen Fan wrote:
 if specifying migration_host to an Ipv6 address without brackets,
 it was resolved to an incorrect address, such as:
 tcp:2001:0DB8::1428:,
 but the correct address should be:
 tcp:[2001:0DB8::1428]:
 so we should add brackets when parsing it.
 
 Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
 ---
  src/libvirt_private.syms  |  2 +-
  src/qemu/qemu_migration.c | 49 
 +++
  src/util/virsocketaddr.c  | 19 +-
  src/util/virsocketaddr.h  |  2 +-
  tests/sockettest.c|  2 +-
  5 files changed, 36 insertions(+), 38 deletions(-)

ACK

Jan



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v3 1/3] migration: add migration_host support for Ipv6 address without brackets

2014-10-07 Thread Chen, Fan
On Tue, 2014-10-07 at 11:08 +0200, Ján Tomko wrote: 
 On 10/07/2014 06:07 AM, Chen Fan wrote:
  if specifying migration_host to an Ipv6 address without brackets,
  it was resolved to an incorrect address, such as:
  tcp:2001:0DB8::1428:,
  but the correct address should be:
  tcp:[2001:0DB8::1428]:
  so we should add brackets when parsing it.
  
  Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
  ---
   src/libvirt_private.syms  |  2 +-
   src/qemu/qemu_migration.c | 49 
  +++
   src/util/virsocketaddr.c  | 19 +-
   src/util/virsocketaddr.h  |  2 +-
   tests/sockettest.c|  2 +-
   5 files changed, 36 insertions(+), 38 deletions(-)
 
 ACK

Thanks.

 
 Jan
 


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v3 1/3] migration: add migration_host support for Ipv6 address without brackets

2014-10-06 Thread Chen Fan
if specifying migration_host to an Ipv6 address without brackets,
it was resolved to an incorrect address, such as:
tcp:2001:0DB8::1428:,
but the correct address should be:
tcp:[2001:0DB8::1428]:
so we should add brackets when parsing it.

Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
---
 src/libvirt_private.syms  |  2 +-
 src/qemu/qemu_migration.c | 49 +++
 src/util/virsocketaddr.c  | 19 +-
 src/util/virsocketaddr.h  |  2 +-
 tests/sockettest.c|  2 +-
 5 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7cbc35b..8ab1394 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1911,11 +1911,11 @@ virSocketAddrGetIpPrefix;
 virSocketAddrGetPort;
 virSocketAddrGetRange;
 virSocketAddrIsNetmask;
-virSocketAddrIsNumeric;
 virSocketAddrIsPrivate;
 virSocketAddrIsWildcard;
 virSocketAddrMask;
 virSocketAddrMaskByPrefix;
+virSocketAddrNumericFamily;
 virSocketAddrParse;
 virSocketAddrParseIPv4;
 virSocketAddrParseIPv6;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 284cd5a..e135249 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2605,7 +2605,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
 if (VIR_STRDUP(migrateFrom, stdio)  0)
 goto cleanup;
 } else {
-virSocketAddr listenAddressSocket;
 bool encloseAddress = false;
 bool hostIPv6Capable = false;
 bool qemuIPv6Capable = false;
@@ -2627,28 +2626,21 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
 virObjectUnref(qemuCaps);
 
 if (listenAddress) {
-if (virSocketAddrIsNumeric(listenAddress)) {
-/* listenAddress is numeric IPv4 or IPv6 */
-if (virSocketAddrParse(listenAddressSocket, listenAddress, 
AF_UNSPEC)  0)
+if (virSocketAddrNumericFamily(listenAddress) == AF_INET6) {
+if (!qemuIPv6Capable) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
+   _(qemu isn't capable of IPv6));
 goto cleanup;
-
-/* address parsed successfully */
-if (VIR_SOCKET_ADDR_IS_FAMILY(listenAddressSocket, AF_INET6)) 
{
-if (!qemuIPv6Capable) {
-virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
-   _(qemu isn't capable of IPv6));
-goto cleanup;
-}
-if (!hostIPv6Capable) {
-virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
-   _(host isn't capable of IPv6));
-goto cleanup;
-}
-/* IPv6 address must be escaped in brackets on the cmd 
line */
-encloseAddress = true;
 }
+if (!hostIPv6Capable) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
+   _(host isn't capable of IPv6));
+goto cleanup;
+}
+/* IPv6 address must be escaped in brackets on the cmd line */
+encloseAddress = true;
 } else {
-/* listenAddress is a hostname */
+/* listenAddress is a hostname or IPv4 */
 }
 } else if (qemuIPv6Capable  hostIPv6Capable) {
 /* Listen on :: instead of 0.0.0.0 if QEMU understands it
@@ -2950,15 +2942,17 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
  * to be a correct hostname which refers to the target machine).
  */
 if (uri_in == NULL) {
+bool encloseAddress = false;
+const char *incFormat;
+
 if (virPortAllocatorAcquire(driver-migrationPorts, port)  0)
 goto cleanup;
 
 if (migrateHost != NULL) {
-if (virSocketAddrIsNumeric(migrateHost) 
-virSocketAddrParse(NULL, migrateHost, AF_UNSPEC)  0)
-goto cleanup;
+if (virSocketAddrNumericFamily(migrateHost) == AF_INET6)
+encloseAddress = true;
 
-   if (VIR_STRDUP(hostname, migrateHost)  0)
+if (VIR_STRDUP(hostname, migrateHost)  0)
 goto cleanup;
 } else {
 if ((hostname = virGetHostname()) == NULL)
@@ -2977,7 +2971,12 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
  * compatibility with old targets. We at least make the
  * new targets accept both syntaxes though.
  */
-if (virAsprintf(uri_out, tcp:%s:%d, hostname, port)  0)
+if (encloseAddress)
+incFormat = %s:[%s]:%d;
+else
+incFormat = %s:%s:%d;
+
+if (virAsprintf(uri_out, incFormat, tcp, hostname, port)  0)
 goto cleanup;