[libvirt] [PATCH] Fix URI alias prefix matching

Wen Ruo Lv (none) lvroyce at lvroyce-ThinkPad-T420
Mon Oct 31 12:00:18 UTC 2011


From: lvroyce <lvroyce at lvroyce-ThinkPad-T420.(none)>

URI alias always do prefix matching,because we count length of entry according to config file entry, which should be the given alias' length. 
e.g.:
/etc/libvirt/libvirt.conf
uri_aliases = [
  "hail=qemu:///system",
  "sleet=qemu+ssh://root@9.115.122.57/system",
  "sam=qemu+unix:///system?socket=/var/run/libvirt/libvirt-sock",
]

when issue "virsh -c hailly" it will match "hail=qemu:///system"

Signed-off-by: Wen Ruo Lv <lvroyce at lvroyce-ThinkPad-T420.(none)>
---
 src/libvirt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index e9d1a29..54e283f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1022,7 +1022,7 @@ virConnectOpenFindURIAliasMatch(virConfValuePtr value, const char *alias, char *
             return -1;
         }
 
-        if (STREQLEN(entry->str, alias, offset-entry->str)) {
+        if (STREQLEN(entry->str, alias, strlen(alias))) {
             VIR_DEBUG("Resolved alias '%s' to '%s'",
                       alias, offset+1);
             if (!(*uri = strdup(offset+1))) {
-- 
1.7.4.1




More information about the libvir-list mailing list