From 7b40fcd11f3af58c2343f170c0b8a4c89318aeb9 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 26 Dec 2007 05:41:05 +0000 Subject: [PATCH] * src/openvz.c: patch from Mikhail Pokidko to fix the OpenVZ compilation error #426385 Daniel --- ChangeLog | 5 ++++ src/openvz_driver.c | 57 ++++++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5c7afd902..7130ca4b82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 26 06:38:53 CET 2007 Daniel Veillard + + * src/openvz.c: patch from Mikhail Pokidko to fix the OpenVZ + compilation error #426385 + Tue Dec 18 00:18:33 CET 2007 Daniel Veillard * configure.in docs/libvir.html docs/news.html po/*: diff --git a/src/openvz_driver.c b/src/openvz_driver.c index 7f6d0cd3d0..5f5c94b44b 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -72,9 +72,10 @@ static int openvzDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info); static int openvzDomainShutdown(virDomainPtr dom); static int openvzDomainReboot(virDomainPtr dom, unsigned int flags); static int openvzDomainCreate(virDomainPtr dom); -static virDrvOpenStatus openvzOpen(virConnectPtr conn, const char *name, - int flags ATTRIBUTE_UNUSED); - +static virDrvOpenStatus openvzOpen(virConnectPtr conn, + xmlURIPtr uri, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED); static int openvzClose(virConnectPtr conn); static const char *openvzGetType(virConnectPtr conn ATTRIBUTE_UNUSED); static int openvzListDomains(virConnectPtr conn, int *ids, int nids); @@ -554,35 +555,37 @@ bail_out5: } static virDrvOpenStatus openvzOpen(virConnectPtr conn, - const char *name, - int *credtype ATTRIBUTE_UNUSED, - int ncredtype ATTRIBUTE_UNUSED, - virConnectAuthCallbackPtr cb ATTRIBUTE_UNUSED, - void *cbdata ATTRIBUTE_UNUSED, - int flags ATTRIBUTE_UNUSED) { - struct openvz_vm *vms; + xmlURIPtr uri, + virConnectAuthPtr auth ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED) +{ + struct openvz_vm *vms; - /* Just check if the guy is root. Nothing really to open for OpenVZ */ - if (getuid()) { // OpenVZ tools can only be used by r00t - return VIR_DRV_OPEN_DECLINED; - } else { - if (strcmp(name, "openvz:///system")) - return VIR_DRV_OPEN_DECLINED; - } + /*Just check if the user is root. Nothing really to open for OpenVZ */ + if (getuid()) { // OpenVZ tools can only be used by r00t + return VIR_DRV_OPEN_DECLINED; + } else { + if (uri == NULL || uri->scheme == NULL || uri->path == NULL) + return VIR_DRV_OPEN_DECLINED; + if (STRNEQ (uri->scheme, "openvz")) + return VIR_DRV_OPEN_DECLINED; + if (STRNEQ (uri->path, "/system")) + return VIR_DRV_OPEN_DECLINED; + } /* See if we are running an OpenVZ enabled kernel */ - if(access("/proc/vz/veinfo", F_OK) == -1 || - access("/proc/user_beancounters", F_OK) == -1) { - return VIR_DRV_OPEN_DECLINED; - } + if(access("/proc/vz/veinfo", F_OK) == -1 || + access("/proc/user_beancounters", F_OK) == -1) { + return VIR_DRV_OPEN_DECLINED; + } - conn->privateData = &ovz_driver; + conn->privateData = &ovz_driver; - virStateInitialize(); - vms = openvzGetVPSInfo(conn); - ovz_driver.vms = vms; + virStateInitialize(); + vms = openvzGetVPSInfo(conn); + ovz_driver.vms = vms; - return VIR_DRV_OPEN_SUCCESS; -} + return VIR_DRV_OPEN_SUCCESS; +}; static int openvzClose(virConnectPtr conn) {