[libvirt] question about qemudDomainMigratePrepare2 of qemu_driver.c from libvirt-0.6.1

Hello I am just curious if the checking of the connection string in qemu_driver.c from libvirt-0.6.1 in qemudDomainMigratePrepare2 is faulty. The source is: [...] } else { /* Check the URI starts with "tcp:". We will escape the * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ if (!STREQLEN (uri_in, "tcp:", 6)) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup; } [...] The second compare-string "tcp:" is only 4 characters long, therefore a check via strncmp must fail i presumed, i isolated this comparison: #include <stdio.h> #include <string.h> #define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) int main () { char str[][200] = { "tcp://192.168.1.14:4444" , "tcp:192.168.1.14:4444" , "ssh ://192.168.1.14:4444" , "ssh:192.168.1.14:4444" }; int n; for (n=0 ; n<4 ; n++) { printf("testing %s against \"tcp:\" with result: ", str[n]); if (!STREQLEN(str[n],"tcp:",6)) { printf ("ERROR\n"); } else { printf ("OK\n"); } } return 0; } and as i pressumed this gives me on the commandline: testing tcp://192.168.1.14:4444 against "tcp:" with result: ERROR testing tcp:192.168.1.14:4444 against "tcp:" with result: ERROR testing ssh://192.168.1.14:4444 against "tcp:" with result: ERROR testing ssh:192.168.1.14:4444 against "tcp:" with result: ERROR if i change the 6 to 4 it gives testing tcp://192.168.1.14:4444 against "tcp:" with result: OK testing tcp:192.168.1.14:4444 against "tcp:" with result: OK testing ssh://192.168.1.14:4444 against "tcp:" with result: ERROR testing ssh:192.168.1.14:4444 against "tcp:" with result: ERROR but now tcp:// also is marked as correct. Am i missing something here and the checking in qemu_driver.c is correct? I always get the "only tcp URIs are supported for KVM migrations" if i try to migrate KVM-domains in virt-manager 0.7.0 and therefore searched for the root-cause of this problem. Kind regards, Gerrit Slomma Mit freundlichen Grüßen, Gerrit Slomma Team eBetrieb Deutsche Rentenversicherung Bund Abt. 11 - Organisation und IT-Services Fachbereich 1170 - IT-Services und Betrieb Bereich 1174 - Anwendungsbetrieb Team 1174-46 - Trustcenter, eBetrieb

On Tue, Mar 31, 2009 at 10:07:31AM +0200, Gerrit.Slomma@drv-bund.de wrote:
Hello
I am just curious if the checking of the connection string in qemu_driver.c from libvirt-0.6.1 in qemudDomainMigratePrepare2 is faulty. The source is:
[...] } else { /* Check the URI starts with "tcp:". We will escape the * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ if (!STREQLEN (uri_in, "tcp:", 6)) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup; } [...]
The second compare-string "tcp:" is only 4 characters long, therefore a check via strncmp must fail i presumed, i isolated this comparison:
Can you try with this patch applied diff -r b5ad7b1c453b src/qemu_driver.c --- a/src/qemu_driver.c Tue Mar 31 14:55:23 2009 +0100 +++ b/src/qemu_driver.c Tue Mar 31 15:02:30 2009 +0100 @@ -4629,7 +4629,7 @@ qemudDomainMigratePrepare2 (virConnectPt * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ - if (!STREQLEN (uri_in, "tcp:", 6)) { + if (!STRPREFIX (uri_in, "tcp:")) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup; Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Tue, Mar 31, 2009 at 10:07:31AM +0200, Gerrit.Slomma@drv-bund.de wrote:
Hello
I am just curious if the checking of the connection string in qemu_driver.c from libvirt-0.6.1 in qemudDomainMigratePrepare2 is faulty. The source is:
[...] } else { /* Check the URI starts with "tcp:". We will escape the * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ if (!STREQLEN (uri_in, "tcp:", 6)) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup; } [...]
The second compare-string "tcp:" is only 4 characters long, therefore a check via strncmp must fail i presumed, i isolated this comparison:
Can you try with this patch applied
diff -r b5ad7b1c453b src/qemu_driver.c --- a/src/qemu_driver.c Tue Mar 31 14:55:23 2009 +0100 +++ b/src/qemu_driver.c Tue Mar 31 15:02:30 2009 +0100 @@ -4629,7 +4629,7 @@ qemudDomainMigratePrepare2 (virConnectPt * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ - if (!STREQLEN (uri_in, "tcp:", 6)) { + if (!STRPREFIX (uri_in, "tcp:")) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup;
Yeah, that's the way to fix this. The STREQLEN(uri_in, "tcp:", 6) is a leftover from the KVM migration to QEMU migration implementation; in the KVM migration, you would use "tcp://", which would be the correct 6 characters, but in the QEMU migration implementation, you just use "tcp:". I guess I just forgot to fix this up. -- Chris Lalancette

On Tue, Mar 31, 2009 at 05:29:09PM +0200, Chris Lalancette wrote:
Daniel P. Berrange wrote:
On Tue, Mar 31, 2009 at 10:07:31AM +0200, Gerrit.Slomma@drv-bund.de wrote:
Hello
I am just curious if the checking of the connection string in qemu_driver.c from libvirt-0.6.1 in qemudDomainMigratePrepare2 is faulty. The source is:
[...] } else { /* Check the URI starts with "tcp:". We will escape the * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ if (!STREQLEN (uri_in, "tcp:", 6)) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup; } [...]
The second compare-string "tcp:" is only 4 characters long, therefore a check via strncmp must fail i presumed, i isolated this comparison:
Can you try with this patch applied
diff -r b5ad7b1c453b src/qemu_driver.c --- a/src/qemu_driver.c Tue Mar 31 14:55:23 2009 +0100 +++ b/src/qemu_driver.c Tue Mar 31 15:02:30 2009 +0100 @@ -4629,7 +4629,7 @@ qemudDomainMigratePrepare2 (virConnectPt * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ - if (!STREQLEN (uri_in, "tcp:", 6)) { + if (!STRPREFIX (uri_in, "tcp:")) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup;
Yeah, that's the way to fix this. The STREQLEN(uri_in, "tcp:", 6) is a leftover from the KVM migration to QEMU migration implementation; in the KVM migration, you would use "tcp://", which would be the correct 6 characters, but in the QEMU migration implementation, you just use "tcp:". I guess I just forgot to fix this up.
ACK, Dan can you apply this too ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Tue, Mar 31, 2009 at 11:36:51PM +0200, Daniel Veillard wrote:
On Tue, Mar 31, 2009 at 05:29:09PM +0200, Chris Lalancette wrote:
Can you try with this patch applied
diff -r b5ad7b1c453b src/qemu_driver.c --- a/src/qemu_driver.c Tue Mar 31 14:55:23 2009 +0100 +++ b/src/qemu_driver.c Tue Mar 31 15:02:30 2009 +0100 @@ -4629,7 +4629,7 @@ qemudDomainMigratePrepare2 (virConnectPt * URI when passing it to the qemu monitor, so bad * characters in hostname part don't matter. */ - if (!STREQLEN (uri_in, "tcp:", 6)) { + if (!STRPREFIX (uri_in, "tcp:")) { qemudReportError (dconn, NULL, NULL, VIR_ERR_INVALID_ARG, "%s", _("only tcp URIs are supported for KVM migrations")); goto cleanup;
Yeah, that's the way to fix this. The STREQLEN(uri_in, "tcp:", 6) is a leftover from the KVM migration to QEMU migration implementation; in the KVM migration, you would use "tcp://", which would be the correct 6 characters, but in the QEMU migration implementation, you just use "tcp:". I guess I just forgot to fix this up.
ACK, Dan can you apply this too ?
Yep, committed this now Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (4)
-
Chris Lalancette
-
Daniel P. Berrange
-
Daniel Veillard
-
Gerrit.Slomma@drv-bund.de