Re: [libvirt] [PATCH v1 1/3] migration: add migration_host support for Ipv6 address without brackets
On Mon, 2014-09-22 at 15:34 +0200, Ján Tomko wrote: > On 09/12/2014 06:31 AM, Chen Fan wrote: > > when 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 > > --- > > src/qemu/qemu_migration.c | 19 +++ > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > > diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c > > index e4b664b..c7eb305 100644 > > --- a/src/qemu/qemu_migration.c > > +++ b/src/qemu/qemu_migration.c > > @@ -2850,11 +2850,22 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, > > goto cleanup; > > > > if (migrateHost != NULL) { > > -if (virSocketAddrIsNumeric(migrateHost) && > > -virSocketAddrParse(NULL, migrateHost, AF_UNSPEC) < 0) > > -goto cleanup; > > Hmm, I'm not sure what this check was doing - if the address was succesfully > parsed in AddrIsNumeric, it should be parsed by virSocketAddrParse as well. agreed. > > > +virSocketAddr migrateHostSocket; > > +bool migrateHostisIpv6Address = false; > > + > > +if (virSocketAddrIsNumeric(migrateHost)) { > > +if (virSocketAddrParse(&migrateHostSocket, migrateHost, > > AF_UNSPEC) < 0) > > +goto cleanup; > > + > > +if (VIR_SOCKET_ADDR_IS_FAMILY(&migrateHostSocket, > > AF_INET6)) { > > +migrateHostisIpv6Address = true; > > +} > > +} > > > > We also do this parsing to chceck for numeric IPv6 addresses in > qemuMigrationPrepareAny. It would be nicer to create a new > 'virSocketAddrIsNumericIPv6' function and use it in both of them. I will follow this. Thanks, Chen > > Jan > > > - if (VIR_STRDUP(hostname, migrateHost) < 0) > > +if ((migrateHostisIpv6Address && > > + virAsprintf(&hostname, "[%s]", migrateHost) < 0) || > > +(!migrateHostisIpv6Address && > > + virAsprintf(&hostname, "%s", migrateHost) < 0)) > > goto cleanup; > > } else { > > if ((hostname = virGetHostname()) == NULL) > > > > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v1 1/3] migration: add migration_host support for Ipv6 address without brackets
On 09/12/2014 06:31 AM, Chen Fan wrote: > when 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 > --- > src/qemu/qemu_migration.c | 19 +++ > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c > index e4b664b..c7eb305 100644 > --- a/src/qemu/qemu_migration.c > +++ b/src/qemu/qemu_migration.c > @@ -2850,11 +2850,22 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, > goto cleanup; > > if (migrateHost != NULL) { > -if (virSocketAddrIsNumeric(migrateHost) && > -virSocketAddrParse(NULL, migrateHost, AF_UNSPEC) < 0) > -goto cleanup; Hmm, I'm not sure what this check was doing - if the address was succesfully parsed in AddrIsNumeric, it should be parsed by virSocketAddrParse as well. > +virSocketAddr migrateHostSocket; > +bool migrateHostisIpv6Address = false; > + > +if (virSocketAddrIsNumeric(migrateHost)) { > +if (virSocketAddrParse(&migrateHostSocket, migrateHost, > AF_UNSPEC) < 0) > +goto cleanup; > + > +if (VIR_SOCKET_ADDR_IS_FAMILY(&migrateHostSocket, AF_INET6)) > { > +migrateHostisIpv6Address = true; > +} > +} > We also do this parsing to chceck for numeric IPv6 addresses in qemuMigrationPrepareAny. It would be nicer to create a new 'virSocketAddrIsNumericIPv6' function and use it in both of them. Jan > - if (VIR_STRDUP(hostname, migrateHost) < 0) > +if ((migrateHostisIpv6Address && > + virAsprintf(&hostname, "[%s]", migrateHost) < 0) || > +(!migrateHostisIpv6Address && > + virAsprintf(&hostname, "%s", migrateHost) < 0)) > goto cleanup; > } else { > if ((hostname = virGetHostname()) == NULL) > signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v1 1/3] migration: add migration_host support for Ipv6 address without brackets
when 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 --- src/qemu/qemu_migration.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e4b664b..c7eb305 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2850,11 +2850,22 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver, goto cleanup; if (migrateHost != NULL) { -if (virSocketAddrIsNumeric(migrateHost) && -virSocketAddrParse(NULL, migrateHost, AF_UNSPEC) < 0) -goto cleanup; +virSocketAddr migrateHostSocket; +bool migrateHostisIpv6Address = false; + +if (virSocketAddrIsNumeric(migrateHost)) { +if (virSocketAddrParse(&migrateHostSocket, migrateHost, AF_UNSPEC) < 0) +goto cleanup; + +if (VIR_SOCKET_ADDR_IS_FAMILY(&migrateHostSocket, AF_INET6)) { +migrateHostisIpv6Address = true; +} +} - if (VIR_STRDUP(hostname, migrateHost) < 0) +if ((migrateHostisIpv6Address && + virAsprintf(&hostname, "[%s]", migrateHost) < 0) || +(!migrateHostisIpv6Address && + virAsprintf(&hostname, "%s", migrateHost) < 0)) goto cleanup; } else { if ((hostname = virGetHostname()) == NULL) -- 1.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list