[libvirt] [PATCH] Give correct error message when configure a wrong URI aliase.

From: Eli Qiao <taget@linux.vnet.ibm.com> Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com> When configure the URI aliase like this in 'libvirt.conf': uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ���we expect this message below��� Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -' Give this patch to fix this error. --- src/libvirt.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri) *uri = NULL; - /* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ - if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) - return 0; - if (!(config = virConnectConfigFile())) goto cleanup; -- 1.7.4.4

On Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao <taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j
No, we don't want # to appear in aliases as this will lead to confusion
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error. --- src/libvirt.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri)
*uri = NULL;
- /* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ - if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) - return 0; - if (!(config = virConnectConfigFile())) goto cleanup;
I disagree, I don't see any need to have complex aliases values. The principle is precisely to keep them simple. Use "jj" instead of "jj#j" for example. NACK 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 2011年11月22日 16:07, Daniel Veillard wrote:
On Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao<taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao<taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j No, we don't want # to appear in aliases as this will lead to confusion
I think Eli's purpose is to see the more sensiable message by removing the early checking. But I don't see the more sensiable message with applying the patch.
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error. --- src/libvirt.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri)
*uri = NULL;
- /* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ - if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) - return 0; - if (!(config = virConnectConfigFile())) goto cleanup; I disagree, I don't see any need to have complex aliases values. The principle is precisely to keep them simple. Use "jj" instead of "jj#j" for example.
Disagree too. The simple early checking ensure it doesn't flow into the loop, which is just waste. Osier

On Tue, Nov 22, 2011 at 04:07:21PM +0800, Daniel Veillard wrote:
On Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao <taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j
No, we don't want # to appear in aliases as this will lead to confusion
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error. --- src/libvirt.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri)
*uri = NULL;
- /* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ - if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) - return 0; - if (!(config = virConnectConfigFile())) goto cleanup;
I disagree, I don't see any need to have complex aliases values. The principle is precisely to keep them simple. Use "jj" instead of "jj#j" for example.
NACK
Actually, the patch doesn't change what is allowed - it still forbids 'jj#j' later on in the code. This only changes error reporting to be more clear, so I ACK this. 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 Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao <taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error. --- src/libvirt.c | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri)
*uri = NULL;
- /* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ - if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) - return 0; - if (!(config = virConnectConfigFile())) goto cleanup;
ACK, this is OK, since we still validate the URI_ALIAS_CHARS later on 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 11/22/2011 02:36 AM, Daniel P. Berrange wrote:
On Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao <taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error.
'git am' did not like this message, for some reason. I think I got it to apply correctly, though.
ACK, this is OK, since we still validate the URI_ALIAS_CHARS later on
Now pushed. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

于 2011年11月23日 06:28, Eric Blake 写道:
On 11/22/2011 02:36 AM, Daniel P. Berrange wrote:
On Tue, Nov 22, 2011 at 11:27:04AM +0800, taget@linux.vnet.ibm.com wrote:
From: Eli Qiao <taget@linux.vnet.ibm.com>
Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configure the URI aliase like this in 'libvirt.conf':
uri_aliases = [ "jj#j=qemu+ssh://root@127.0.0.1/system", "sleet=qemu+ssh://root@sleet.cloud.example.com/system", ] virsh -c jj#j
It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ,we expect this message below: Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -'
Give this patch to fix this error. 'git am' did not like this message, for some reason. I think I got it to apply correctly, though.
ACK, this is OK, since we still validate the URI_ALIAS_CHARS later on Now pushed.
thanks Eric. -- best regards eli
participants (6)
-
Daniel P. Berrange
-
Daniel Veillard
-
Eli Qiao
-
Eric Blake
-
Osier Yang
-
taget@linux.vnet.ibm.com