mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 15:14:42 +00:00
Fixed QEMU uri parsing/detection
This commit is contained in:
parent
0caf0d767c
commit
01422bd794
@ -1,3 +1,7 @@
|
|||||||
|
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>
|
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
|
* src/bridge.c, src/qemu_driver.c, configure.in: Try to detect
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <libxml/uri.h>
|
||||||
|
|
||||||
#include <libvirt/virterror.h>
|
#include <libvirt/virterror.h>
|
||||||
|
|
||||||
@ -1362,25 +1363,39 @@ static int qemudMonitorCommand(struct qemud_driver *driver ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
|
|
||||||
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
|
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
|
||||||
const char *name,
|
const char *name,
|
||||||
int flags ATTRIBUTE_UNUSED) {
|
int flags ATTRIBUTE_UNUSED) {
|
||||||
|
xmlURIPtr uri = NULL;
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
|
|
||||||
if (qemu_driver == NULL)
|
if (qemu_driver == NULL)
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
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 (uid != 0) {
|
||||||
if (STRNEQ (name, "qemu:///session"))
|
if (STRNEQ (uri->path, "/session"))
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
goto decline;
|
||||||
} else { /* root */
|
} else { /* root */
|
||||||
if (STRNEQ (name, "qemu:///system") &&
|
if (STRNEQ (uri->path, "/system") &&
|
||||||
STRNEQ (name, "qemu:///session"))
|
STRNEQ (uri->path, "/session"))
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
goto decline;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->privateData = qemu_driver;
|
conn->privateData = qemu_driver;
|
||||||
|
|
||||||
|
xmlFreeURI(uri);
|
||||||
return VIR_DRV_OPEN_SUCCESS;
|
return VIR_DRV_OPEN_SUCCESS;
|
||||||
|
|
||||||
|
decline:
|
||||||
|
if (uri != NULL)
|
||||||
|
xmlFreeURI(uri);
|
||||||
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemudClose(virConnectPtr conn) {
|
static int qemudClose(virConnectPtr conn) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user