diff -r b281c5ec47da src/qemu_driver.c --- a/src/qemu_driver.c Thu Sep 20 16:28:56 2007 -0400 +++ b/src/qemu_driver.c Thu Sep 20 17:16:16 2007 -0400 @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -1362,25 +1363,37 @@ static int qemudMonitorCommand(struct qe static virDrvOpenStatus qemudOpen(virConnectPtr conn, - const char *name, - int flags ATTRIBUTE_UNUSED) { + const char *name, + int flags ATTRIBUTE_UNUSED) { + xmlURIPtr uri = NULL; uid_t uid = getuid(); if (qemu_driver == NULL) return VIR_DRV_OPEN_DECLINED; + uri = xmlParseURI(name); + if (uri == NULL || uri->scheme == NULL || uri->path == NULL) + return VIR_DRV_OPEN_DECLINED; + + if (STRNEQ (uri->scheme, "qemu")) + goto decline; + if (uid != 0) { - if (STRNEQ (name, "qemu:///session")) - return VIR_DRV_OPEN_DECLINED; + if (STRNEQ (uri->path, "/session")) + goto decline; } else { /* root */ - if (STRNEQ (name, "qemu:///system") && - STRNEQ (name, "qemu:///session")) - return VIR_DRV_OPEN_DECLINED; + if (STRNEQ (uri->path, "/system") && + STRNEQ (uri->path, "/session")) + goto decline; } conn->privateData = qemu_driver; return VIR_DRV_OPEN_SUCCESS; + + decline: + xmlFreeURI(uri); + return VIR_DRV_OPEN_DECLINED; } static int qemudClose(virConnectPtr conn) {