提交 01422bd7 编写于 作者: D Daniel P. Berrange

Fixed QEMU uri parsing/detection

上级 0caf0d76
Fri Sep 21 15:06:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/qemu_driver.c: Use libxml for parsing & checking URIs
Thu Sep 20 19:37:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/bridge.c, src/qemu_driver.c, configure.in: Try to detect
......
......@@ -45,6 +45,7 @@
#include <pwd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <libxml/uri.h>
#include <libvirt/virterror.h>
......@@ -1362,25 +1363,39 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED,
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)
goto decline;
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;
xmlFreeURI(uri);
return VIR_DRV_OPEN_SUCCESS;
decline:
if (uri != NULL)
xmlFreeURI(uri);
return VIR_DRV_OPEN_DECLINED;
}
static int qemudClose(virConnectPtr conn) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册