Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 38 participants
- 40204 discussions
[libvirt] [PATCH] Update event loop example programs to demonstrate best practice
by Daniel P. Berrange 29 Mar '11
by Daniel P. Berrange 29 Mar '11
29 Mar '11
The example C event loop code is a nasty hack and not compliant
with the require API semantics. Delete this, so that developers
don't mistakenly copy it. Instead call the new public event loop
APIs.
Update the python event loop example, so that it can optionally
use the public event APIs, as an alternative to the pure python
code. The pure python event code is a good working example, so
don't delete it.
* examples/domain-events/events-c/event-test.c: Replace event
loop code with use of public APIs
* examples/domain-events/events-python/event-test.py: Allow
optional use of new public event APIs
---
examples/domain-events/events-c/event-test.c | 163 +------------------
examples/domain-events/events-python/event-test.py | 29 ++++-
2 files changed, 36 insertions(+), 156 deletions(-)
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index 6e3a160..ee68bb1 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -5,10 +5,8 @@
#include <string.h>
#include <signal.h>
-#if HAVE_SYS_POLL_H
-# include <sys/types.h>
-# include <sys/poll.h>
# include <libvirt/libvirt.h>
+# include <libvirt/virterror.h>
# define VIR_DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
__func__, __LINE__)
@@ -20,22 +18,6 @@
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
# endif
-/* handle globals */
-int h_fd = 0;
-virEventHandleType h_event = 0;
-virEventHandleCallback h_cb = NULL;
-virFreeCallback h_ff = NULL;
-void *h_opaque = NULL;
-
-/* timeout globals */
-# define TIMEOUT_MS 1000
-int t_active = 0;
-int t_timeout = -1;
-virEventTimeoutCallback t_cb = NULL;
-virFreeCallback t_ff = NULL;
-void *t_opaque = NULL;
-
-
/* Prototypes */
const char *eventToString(int event);
int myEventAddHandleFunc (int fd, int event,
@@ -266,94 +248,6 @@ static void myFreeFunc(void *opaque)
}
-/* EventImpl Functions */
-int myEventHandleTypeToPollEvent(virEventHandleType events)
-{
- int ret = 0;
- if(events & VIR_EVENT_HANDLE_READABLE)
- ret |= POLLIN;
- if(events & VIR_EVENT_HANDLE_WRITABLE)
- ret |= POLLOUT;
- if(events & VIR_EVENT_HANDLE_ERROR)
- ret |= POLLERR;
- if(events & VIR_EVENT_HANDLE_HANGUP)
- ret |= POLLHUP;
- return ret;
-}
-
-virEventHandleType myPollEventToEventHandleType(int events)
-{
- virEventHandleType ret = 0;
- if(events & POLLIN)
- ret |= VIR_EVENT_HANDLE_READABLE;
- if(events & POLLOUT)
- ret |= VIR_EVENT_HANDLE_WRITABLE;
- if(events & POLLERR)
- ret |= VIR_EVENT_HANDLE_ERROR;
- if(events & POLLHUP)
- ret |= VIR_EVENT_HANDLE_HANGUP;
- return ret;
-}
-
-int myEventAddHandleFunc(int fd, int event,
- virEventHandleCallback cb,
- void *opaque,
- virFreeCallback ff)
-{
- VIR_DEBUG("Add handle %d %d %p %p", fd, event, cb, opaque);
- h_fd = fd;
- h_event = myEventHandleTypeToPollEvent(event);
- h_cb = cb;
- h_ff = ff;
- h_opaque = opaque;
- return 0;
-}
-
-void myEventUpdateHandleFunc(int fd, int event)
-{
- VIR_DEBUG("Updated Handle %d %d", fd, event);
- h_event = myEventHandleTypeToPollEvent(event);
- return;
-}
-
-int myEventRemoveHandleFunc(int fd)
-{
- VIR_DEBUG("Removed Handle %d", fd);
- h_fd = 0;
- if (h_ff)
- (h_ff)(h_opaque);
- return 0;
-}
-
-int myEventAddTimeoutFunc(int timeout,
- virEventTimeoutCallback cb,
- void *opaque,
- virFreeCallback ff)
-{
- VIR_DEBUG("Adding Timeout %d %p %p", timeout, cb, opaque);
- t_active = 1;
- t_timeout = timeout;
- t_cb = cb;
- t_ff = ff;
- t_opaque = opaque;
- return 0;
-}
-
-void myEventUpdateTimeoutFunc(int timer ATTRIBUTE_UNUSED, int timeout)
-{
- /*VIR_DEBUG("Timeout updated %d %d", timer, timeout);*/
- t_timeout = timeout;
-}
-
-int myEventRemoveTimeoutFunc(int timer)
-{
- VIR_DEBUG("Timeout removed %d", timer);
- t_active = 0;
- if (t_ff)
- (t_ff)(t_opaque);
- return 0;
-}
-
/* main test functions */
void usage(const char *pname)
@@ -372,7 +266,6 @@ static void stop(int sig)
int main(int argc, char **argv)
{
- int sts;
int callback1ret = -1;
int callback2ret = -1;
int callback3ret = -1;
@@ -386,17 +279,12 @@ int main(int argc, char **argv)
action_stop.sa_handler = stop;
- if(argc > 1 && STREQ(argv[1],"--help")) {
+ if (argc > 1 && STREQ(argv[1],"--help")) {
usage(argv[0]);
return -1;
}
- virEventRegisterImpl( myEventAddHandleFunc,
- myEventUpdateHandleFunc,
- myEventRemoveHandleFunc,
- myEventAddTimeoutFunc,
- myEventUpdateTimeoutFunc,
- myEventRemoveTimeoutFunc);
+ virEventRegisterDefaultImpl();
virConnectPtr dconn = NULL;
dconn = virConnectOpenReadOnly (argv[1] ? argv[1] : NULL);
@@ -451,38 +339,12 @@ int main(int argc, char **argv)
(callback5ret != -1) &&
(callback6ret != -1) &&
(callback7ret != -1)) {
- while(run) {
- struct pollfd pfd = { .fd = h_fd,
- .events = h_event,
- .revents = 0};
-
- sts = poll(&pfd, 1, TIMEOUT_MS);
-
- /* if t_timeout < 0 then t_cb must not be called */
- if (t_cb && t_active && t_timeout >= 0) {
- t_cb(t_timeout,t_opaque);
- }
-
- if (sts == 0) {
- /* VIR_DEBUG0("Poll timeout"); */
- continue;
- }
- if (sts < 0 ) {
- VIR_DEBUG0("Poll failed");
- continue;
- }
- if ( pfd.revents & POLLHUP ) {
- VIR_DEBUG0("Reset by peer");
- return -1;
+ while (run) {
+ if (virEventRunDefaultImpl() < 0) {
+ virErrorPtr err = virGetLastError();
+ fprintf(stderr, "Failed to run event loop: %s\n",
+ err && err->message ? err->message : "Unknown error");
}
-
- if(h_cb) {
- h_cb(0,
- h_fd,
- myPollEventToEventHandleType(pfd.revents & h_event),
- h_opaque);
- }
-
}
VIR_DEBUG0("Deregistering event handlers");
@@ -496,17 +358,10 @@ int main(int argc, char **argv)
}
VIR_DEBUG0("Closing connection");
- if( dconn && virConnectClose(dconn)<0 ) {
+ if (dconn && virConnectClose(dconn) < 0) {
printf("error closing\n");
}
printf("done\n");
return 0;
}
-
-#else
-int main(void) {
- printf("event-test program not available without sys/poll.h support\n");
- return 1;
-}
-#endif
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
index c149ed9..df75dce 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -15,6 +15,17 @@ import errno
import time
import threading
+# For the sake of demonstration, this example program includes
+# an implementation of a pure python event loop. Most applications
+# would be better off just using the default libvirt event loop
+# APIs, instead of implementing this in python. The exception is
+# where an application wants to integrate with an existing 3rd
+# party event loop impl
+#
+# Change this to 'False' to make the demo use the native
+# libvirt event loop impl
+use_pure_python_event_loop = True
+
do_debug = False
def debug(msg):
global do_debug
@@ -392,6 +403,10 @@ def virEventLoopPureRun():
global eventLoop
eventLoop.run_loop()
+def virEventLoopNativeRun():
+ while True:
+ libvirt.virEventRunDefaultImpl()
+
# Spawn a background thread to run the event loop
def virEventLoopPureStart():
global eventLoopThread
@@ -400,6 +415,13 @@ def virEventLoopPureStart():
eventLoopThread.setDaemon(True)
eventLoopThread.start()
+def virEventLoopNativeStart():
+ global eventLoopThread
+ libvirt.virEventRegisterDefaultImpl()
+ eventLoopThread = threading.Thread(target=virEventLoopNativeRun, name="libvirtEventLoop")
+ eventLoopThread.setDaemon(True)
+ eventLoopThread.start()
+
##########################################################################
# Everything that now follows is a simple demo of domain lifecycle events
@@ -474,9 +496,12 @@ def main():
print "Using uri:" + uri
# Run a background thread with the event loop
- virEventLoopPureStart()
+ if use_pure_python_event_loop:
+ virEventLoopPureStart()
+ else:
+ virEventLoopNativeStart()
- vc = libvirt.open(uri)
+ vc = libvirt.openReadOnly(uri)
# Close connection on exit (to test cleanup paths)
old_exitfunc = getattr(sys, 'exitfunc', None)
--
1.7.4
2
2
It is a patch but beyond the unevitable spelling errors it contains
I would appreciate some feedback on the content, which also defines the
limits of the project.
Some significant things to note in the diff below:
- we do extend libvirt scope beyond purely managing domains, there is
already a number of blocks which are here as helpr functions to
manage the resources on the host.
- we are expanding in the direction of libvirt being sufficient to do
most of the management on the Host (but within the limits of the need
for virtualization, e.g. managing users on the host is out of scope)
- we don't require anymore APIs to be supported by multiple
hypervisors to get in, it's already the case in practice, but we
should still make sure the semantic of those APIs are clear. We
added quite a bit for QEmu, but for example I saw on IRC that VBox
could emulate a network unplug/replug on a domain interface, and
that would be a good addition even if a priori no other hypervisor
supports it.
- Make clear that all libvirt APIs are available remotely, which is
key to use libvirt for building management tools.
- link the goal page from the project main page
As for libvirt project directions, I think it just reflects the natural
evolution in the last couple of years. We are less hypervisor agnostic
and extending in the Host management. Clearly there is interest in
making sure libvirt is complete in term of features for the hypervisors
supported, especially the ones like KVM or LXC which don't really have
integrated management library.
Maybe I should have added a bit more about the security aspect, as
integration of security context and making sure remote access are
secured are very important additions to the library.
Wording and content comments welcome, I guess we are all agreeing
but the goals of the project as written are certainly up for discussion :-)
Daniel
diff --git a/docs/goals.html.in b/docs/goals.html.in
index 8f0d075..6394709 100644
--- a/docs/goals.html.in
+++ b/docs/goals.html.in
@@ -16,20 +16,32 @@
<p class="image">
<img alt="Hypervisor and domains running on a node" src="node.gif"/>
</p>
- <p>Now we can define the goal of libvirt: to provide a common generic
- and stable layer to securely manage domains on a node. The node may be
- distant and libvirt should provide all APIs needed to provision, create,
- modify, monitor, control, migrate and stop the domains, within the limits
- of the support of the hypervisor for those operations. Multiple nodes may
- be accessed with libvirt simultaneously but the APIs are limited to
- single node operations.</p>
+ <p>Now we can define the goal of libvirt: <b> to provide a common and
+ stable layer sufficient to securely manage domains on a node, possibly
+ distant</b>.</p>
+ <p> As a result, libvirt should provide all APIs needed to do the
+ management like: provision, create, modify, monitor, control, migrate
+ and stop the domains - within the limits of the support of the hypervisor
+ for those operations. Some operations which may be hypervisor specific,
+ if needed for domain management should be provided too. Multiple nodes
+ may be accessed with libvirt simultaneously but the APIs are limited to
+ single node operations. Node ressource operations which are needed
+ for the management and provisioning of domains are also in the scope of
+ the libvirt API, like interface setup, firewall rules, storage management
+ and in general provisioning APIs. Libvirt will also provide the state
+ monitoring APIs needed to implement management policies, obviously
+ checking domain state but also expose local node resources consumption.
+ </p>
<p>This implies the following sub-goals:</p>
<ul>
- <li>the API should not be targeted to a single virtualization environment
- which also means that some very specific capabilities which are not generic
- enough may not be provided as libvirt APIs</li>
+ <li>All API can be carried remotely though secure APIs</li>
+ <li>While most API will be generic in term of hypervisor or Host OS,
+ some API may be targeted to a single virtualization environment
+ as long as the semantic for the operations from a domain management
+ perspective is clear</li>
<li>the API should allow to do efficiently and cleanly all the operations
- needed to manage domains on a node</li>
+ needed to manage domains on a node including resource provisioning and
+ setup</li>
<li>the API will not try to provide high level virtualization policies or
multi-nodes management features like load balancing, but the API should be
sufficient so they can be implemented on top of libvirt</li>
diff --git a/docs/index.html.in b/docs/index.html.in
index d40f652..64eb84d 100644
--- a/docs/index.html.in
+++ b/docs/index.html.in
@@ -8,7 +8,8 @@
<ul>
<li>
A toolkit to interact with the virtualization capabilities
- of recent versions of Linux (and other OSes).
+ of recent versions of Linux (and other OSes), see our
+ <a href="goals.html">project goals</a> for details.
</li>
<li>
Free software available under the
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
2
2
[libvirt] [Patch v7 1/4] libvirt/qemu - persistent modification of domain.
by KAMEZAWA Hiroyuki 29 Mar '11
by KAMEZAWA Hiroyuki 29 Mar '11
29 Mar '11
This is v7. Dropped patches for Nics and added 2 sanity checks and
show correct error messages.
=
>From 948597237bd9ecfc5c7343fd30efdca37733274e Mon Sep 17 00:00:00 2001
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
Date: Fri, 25 Mar 2011 16:59:55 +0900
Subject: [PATCHv7 1/4] libvirt/qemu - persistent modification of devices.
Now, qemudDomainAttachDeviceFlags() and qemudDomainDetachDeviceFlags()
doesn't support VIR_DOMAIN_DEVICE_MODIFY_CONFIG. By this, virsh's
at(de)tatch-device --persistent cannot modify qemu config.
(Xen allows it.)
This patch is a base patch for adding support of devices in
step by step manner. Following patches will add some device
support.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
---
src/qemu/qemu_driver.c | 138 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 125 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index af897ad..a4fb1cd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4144,16 +4144,125 @@ cleanup:
return ret;
}
-static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
+/*
+ * Attach a device given by XML, the change will be persistent
+ * and domain XML definition file is updated.
+ */
+static int qemuDomainAttachDevicePersistent(virDomainDefPtr vmdef,
+ virDomainDeviceDefPtr newdev)
+{
+
+ switch(newdev->type) {
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Sorry, the device is not supported for now"));
+ return -1;
+ }
+
+ return 0;
+}
+
+static int qemuDomainDetachDevicePersistent(virDomainDefPtr vmdef,
+ virDomainDeviceDefPtr device)
+{
+ switch(device->type) {
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Sorry, the device is not supported for now"));
return -1;
}
+ return 0;
+}
+
+static int qemuDomainModifyDevicePersistent(virDomainPtr dom,
+ const char *xml,
+ unsigned int attach,
+ unsigned int flags)
+{
+ struct qemud_driver *driver;
+ virDomainDeviceDefPtr device;
+ virDomainDefPtr vmdef;
+ virDomainObjPtr vm;
+ int ret = -1;
+
+ /*
+ * When both of MODIFY_CONFIG and MODIFY_LIVE is specified at the same,
+ * time return error for now. We should support this later.
+ */
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Now, cannot modify alive domain and its definition "
+ "at the same time."));
+ return -1;
+ }
+
+ driver = dom->conn->privateData;
+ qemuDriverLock(driver);
+ vm = virDomainFindByName(&driver->domains, dom->name);
+ if (!vm) {
+ qemuReportError(VIR_ERR_NO_DOMAIN, _("no domain with name : '%s'"),
+ dom->name);
+ goto unlock_out;
+ }
+
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
+ goto unlock_out;
+
+ if (virDomainObjIsActive(vm)) {
+ /*
+ * For now, just allow updating inactive domains. Further development
+ * will allow updating both active domain and its config file at
+ * the same time.
+ */
+ qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("unsupported to update active domain's definition."));
+ goto endjob;
+ }
+
+ vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
- return qemudDomainAttachDevice(dom, xml);
+ if (!vmdef)
+ goto endjob;
+
+ device = virDomainDeviceDefParse(driver->caps,
+ vmdef, xml, VIR_DOMAIN_XML_INACTIVE);
+ if (!device)
+ goto endjob;
+
+ if (attach)
+ ret = qemuDomainAttachDevicePersistent(vmdef, device);
+ else
+ ret = qemuDomainDetachDevicePersistent(vmdef, device);
+
+ if (!ret) /* save the result */
+ ret = virDomainSaveConfig(driver->configDir, vmdef);
+
+ virDomainDeviceDefFree(device);
+
+endjob:
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
+unlock_out:
+ if (vm)
+ virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
+ return ret;
+}
+
+static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
+ const char *xml,
+ unsigned int flags)
+{
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)
+ return qemuDomainModifyDevicePersistent(dom, xml, 1, flags);
+
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE)
+ return qemudDomainAttachDevice(dom, xml);
+
+ qemuReportError(VIR_ERR_INVALID_ARG,
+ _("bad flag: %x not supported"), flags);
+
+ return -1;
}
@@ -4368,13 +4477,16 @@ cleanup:
static int qemudDomainDetachDeviceFlags(virDomainPtr dom,
const char *xml,
unsigned int flags) {
- if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("cannot modify the persistent configuration of a domain"));
- return -1;
- }
- return qemudDomainDetachDevice(dom, xml);
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG)
+ return qemuDomainModifyDevicePersistent(dom, xml, 0, flags);
+
+ if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE)
+ return qemudDomainDetachDevice(dom, xml);
+
+ qemuReportError(VIR_ERR_INVALID_ARG,
+ _("bad flag: %x not supported now"), flags);
+ return -1;
}
static int qemudDomainGetAutostart(virDomainPtr dom,
--
1.7.4.1
3
16
[libvirt] [PATCH] qemu: Only restore security label when saving is successfull.
by Osier Yang 29 Mar '11
by Osier Yang 29 Mar '11
29 Mar '11
"qemudDomainSaveFlag" trys to restore security label even if
the saving fails, a useless warning will be thowed then, e.g.
if "doStopVcpus" fails.
* src/qemu/qemu_driver.c
---
src/qemu/qemu_driver.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index af897ad..1baee58 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1823,6 +1823,7 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
int is_reg = 0;
unsigned long long offset;
virCgroupPtr cgroup = NULL;
+ bool saved = false;
memset(&header, 0, sizeof(header));
memcpy(header.magic, QEMUD_SAVE_MAGIC, sizeof(header.magic));
@@ -2040,6 +2041,8 @@ static int qemudDomainSaveFlag(struct qemud_driver *driver, virDomainPtr dom,
if (rc < 0)
goto endjob;
+ saved = true;
+
if ((!bypassSecurityDriver) &&
virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
vm, path) < 0)
@@ -2087,7 +2090,7 @@ endjob:
path, vm->def->name, rc);
}
- if ((!bypassSecurityDriver) &&
+ if ((!bypassSecurityDriver) && saved &&
virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
vm, path) < 0)
VIR_WARN("failed to restore save state label on %s", path);
--
1.7.4
2
4
28 Mar '11
This addresses the comments raised during v4:
https://www.redhat.com/archives/libvir-list/2011-March/msg00421.html
More comments in individual patches.
It could still use a bit more testing with root-squash NFS, and I'm
also hitting a problem where if I run daemon/libvirtd myself, I
get a SELinux error:
error: unable to set security context 'system_u:object_r:svirt_image_t:s0:c80,c237' on fd 23: Permission denied
but if I run the system service libvirtd or SELinux permissive, things
work. Somehow, the attempt to set the fd SELinux label on a pipe is
not working when libvirt is started as an unconfined process (that is,
the fd has label
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023) but when
started as a daemon, SELinux is happy to allow the transition. I
suspect that this is a bug in SELinux, since my understanding is that
it should always be possible to go from unconfined to something more
restrictive, but we already proved that SELinux fd labelling is
relatively unused and untested back when we first added it in commit
34a19dda.
If possible, I'd like to get this in before the 0.9.0 freeze, and we
can fix any fallout from testing during the freeze week.
Eric Blake (13):
util: allow clearing cloexec bit
qemu: fix restoring a compressed save image
qemu: allow simple domain save to use fd: protocol
util: use SCM_RIGHTS in virFileOperation when needed
qemu: simplify domain save fd handling
storage: simplify fd handling
util: rename virFileOperation to virFileOpenAs
util: adjust indentation in previous patch
qemu, storage: improve type safety
qemu: use common API for reading difficult files
qemu: consolidate migration to file code
qemu: skip granting access during fd migration
qemu: support fd: migration with compression
src/libvirt_private.syms | 3 +-
src/qemu/qemu_command.c | 16 ++
src/qemu/qemu_driver.c | 500 +++++++++--------------------------------
src/qemu/qemu_migration.c | 139 ++++++++++++
src/qemu/qemu_migration.h | 8 +
src/storage/storage_backend.c | 78 ++++---
src/util/util.c | 176 ++++++++++-----
src/util/util.h | 16 +-
tests/qemuxml2argvtest.c | 2 +-
9 files changed, 448 insertions(+), 490 deletions(-)
--
1.7.4
2
16
28 Mar '11
This series of patches adds new functionality to the libxl driver.
Some code is derived from the qemu driver.
Therefore I added Daniel to the author list of libxl_driver.c too.
Markus Groß (8):
Add event callbacks to libxl driver
Get cpu time and current memory balloon from libxl
Add vcpu functions to libxl driver
Add memory functions to libxl driver
Add domainXMLFromNative/domainXMLToNative to libxl driver
Add domainGetSchedulerType to libxl driver
Add domainGetOSType to libxl driver
Add domainSuspend/Resume to libxl driver
configure.ac | 2 +
daemon/Makefile.am | 3 +
src/Makefile.am | 8 +-
src/libxl/libxl_conf.h | 8 +-
src/libxl/libxl_driver.c | 1108 +++++++++++++++++++++++++++++++++++++++++-----
5 files changed, 1021 insertions(+), 108 deletions(-)
--
1.7.4.1
4
28
* src/util/command.c (virCommandAbort) [WIN32]: Provide stub.
Reported by Daniel P. Berrange's autobuilder.
---
Pushing this under the build-breaker rule, as it was caught by
Daniel's autobuilder.
src/util/command.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c
index 905256e..2e475a0 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -1291,6 +1291,7 @@ virCommandWait(virCommandPtr cmd, int *exitstatus)
}
+#ifndef WIN32
/*
* Abort an async command if it is running, without issuing
* any errors or affecting errno. Designed for error paths
@@ -1349,6 +1350,15 @@ cleanup:
cmd->reap = false;
errno = saved_errno;
}
+#else /* WIN32 */
+void
+virCommandAbort(virCommandPtr cmd ATTRIBUTE_UNUSED)
+{
+ /* Mingw lacks WNOHANG and kill(). But since we haven't ported
+ * virExecWithHook to mingw yet, there's no process to be killed,
+ * making this implementation trivially correct for now :) */
+}
+#endif
/*
* Release all resources
--
1.7.4
1
0
libvirt provides vnc to access the VMs under its control.
However, I can not get applications with graphical interface to run when I
use vnc to access a VM.
The same applications will display properly if I ssh -X to the VM.
Is there anyway to overcome this problem?
Best Regards,
Kenneth Nagin
3
2
28 Mar '11
If a domain is initially created without a <vidoe> device but with other
devices (like <interface>), PCI device slots normally reserved for
hardcoded devices (host bridge, IDE controller, video) get assigned to
these. If than later on a <video> device is added without removing the
already assigned <addresse>s, the re-definition fails in
qemuAssignDevicePCISlots() with the error message "Primary video card
must have PCI address 0:0:2.0"
To simplify editing existing domains just reserve the first three slots
for internal usage by setting qemuDomainPCIAddressSet.nextslot = 3.
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
src/qemu/qemu_command.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c63de09..c359fd0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -733,6 +733,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def)
if (!(addrs = qemuDomainPCIAddressSetCreate(def)))
goto cleanup;
+ /* reserve first 3 slots for hardcoded devices */
+ addrs->nextslot = 3;
+
if (qemuAssignDevicePCISlots(def, addrs) < 0)
goto cleanup;
}
--
1.7.1
2
1
The Open Nebula driver has been unmaintained since it was first
introduced. The only commits have been for tree-wide cleanups.
It also has a major design flaw, in that it only knows about guests
that it has created itself, which makes it of very limited use.
Discussions wrt evolution of the VMWare ESX driver, concluded that
it should limit itself to single-node ESX operation and not try to
manage the multi-node architecture of VirtualCenter. Open Nebula
is a cluster like Virtual Center, not a single node system, so
reasoning applies.
The DeltaCloud project includes an Open Nebula driver and is a much
better fit architecturally, since it is explicitly targetting the
distributed multihost cluster scenario.
Thus this patch deletes the libvirt Open Nebula driver with the
recommendation that people use DeltaCloud for managing it instead.
* configure.ac: Remove probe for xmlrpc & --with-one arg
* daemon/Makefile.am, daemon/libvirtd.c, src/Makefile.am: Remove
ONE driver build
* src/opennebula/one_client.c, src/opennebula/one_client.h,
src/opennebula/one_conf.c, src/opennebula/one_conf.h,
src/opennebula/one_driver.c, src/opennebula/one_driver.c: Delete
files
* autobuild.sh, libvirt.spec.in, mingw32-libvirt.spec.in: Remove
build rules for Open Nebula
* docs/drivers.html.in, docs/sitemap.html.in: Remove reference
to OpenNebula
* docs/drvone.html.in: Delete file
---
autobuild.sh | 1 -
configure.ac | 41 --
daemon/Makefile.am | 4 -
daemon/libvirtd.c | 7 -
docs/drivers.html.in | 1 -
docs/drvone.html.in | 108 ------
docs/sitemap.html.in | 4 -
libvirt.spec.in | 12 +-
mingw32-libvirt.spec.in | 1 -
src/Makefile.am | 29 --
src/README | 5 +-
src/opennebula/one_client.c | 207 -----------
src/opennebula/one_client.h | 62 ----
src/opennebula/one_conf.c | 285 ---------------
src/opennebula/one_conf.h | 54 ---
src/opennebula/one_driver.c | 850 -------------------------------------------
src/opennebula/one_driver.h | 30 --
17 files changed, 3 insertions(+), 1698 deletions(-)
delete mode 100644 docs/drvone.html.in
delete mode 100644 src/opennebula/one_client.c
delete mode 100644 src/opennebula/one_client.h
delete mode 100644 src/opennebula/one_conf.c
delete mode 100644 src/opennebula/one_conf.h
delete mode 100644 src/opennebula/one_driver.c
delete mode 100644 src/opennebula/one_driver.h
diff --git a/autobuild.sh b/autobuild.sh
index 54fb273..491f1b8 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -81,7 +81,6 @@ if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
--without-uml \
--without-vbox \
--without-openvz \
- --without-one \
--without-phyp \
--without-netcf \
--without-audit \
diff --git a/configure.ac b/configure.ac
index 12bf0f6..dd15962 100644
--- a/configure.ac
+++ b/configure.ac
@@ -271,8 +271,6 @@ AC_ARG_WITH([vbox],
[with_vbox=yes])
AC_ARG_WITH([lxc],
AC_HELP_STRING([--with-lxc], [add Linux Container support @<:@default=check@:>@]),[],[with_lxc=check])
-AC_ARG_WITH([one],
- AC_HELP_STRING([--with-one], [add ONE support @<:@default=check@:>@]),[],[with_one=check])
AC_ARG_WITH([esx],
AC_HELP_STRING([--with-esx], [add ESX support @<:@default=check@:>@]),[],[with_esx=check])
AC_ARG_WITH([test],
@@ -440,11 +438,6 @@ if test "$with_qemu" = "yes" ; then
fi
AM_CONDITIONAL([WITH_QEMU], [test "$with_qemu" = "yes"])
-if test "$with_one" = "yes" ; then
- AC_DEFINE_UNQUOTED([WITH_ONE],1,[whether ONE driver is enabled])
-fi
-AM_CONDITIONAL([WITH_ONE],[test "$with_one" = "yes"])
-
if test "$with_test" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_TEST], 1, [whether Test driver is enabled])
fi
@@ -725,34 +718,6 @@ fi
dnl Need to test if pkg-config exists
PKG_PROG_PKG_CONFIG
-dnl OpenNebula driver Compilation setting
-dnl
-
-if test "$with_libvirtd" = "no" ; then
- with_one=no
-fi
-XMLRPC_CFLAGS=
-XMLRPC_LIBS=
-if test "x$with_one" = "xyes" || test "x$with_one" = "xcheck"; then
- PKG_CHECK_MODULES(XMLRPC, xmlrpc_client >= $XMLRPC_REQUIRED,
- [with_one=yes], [
- if test "x$with_one" = "xcheck" ; then
- with_one=no
- else
- AC_MSG_ERROR(
- [You must install XMLRPC-C >= $XMLRPC_REQUIRED to compile libvirt ONE driver])
- fi
- ])
- if test "x$with_one" = "xyes" ; then
- AC_DEFINE_UNQUOTED([HAVE_XMLRPC], 1,
- [whether One is used to broadcast server presence])
- fi
-fi
-AM_CONDITIONAL([HAVE_XMLRPC], [test "x$with_one" = "xyes"])
-AM_CONDITIONAL([WITH_ONE], [test "x$with_one" = "xyes"])
-AC_SUBST([XMLRPC_CFLAGS])
-AC_SUBST([XMLRPC_LIBS])
-
dnl ==========================================================================
dnl find libxml2 library, borrowed from xmlsec
@@ -2415,7 +2380,6 @@ AC_MSG_NOTICE([ XenAPI: $with_xenapi])
AC_MSG_NOTICE([xenlight: $with_libxl])
AC_MSG_NOTICE([ LXC: $with_lxc])
AC_MSG_NOTICE([ PHYP: $with_phyp])
-AC_MSG_NOTICE([ ONE: $with_one])
AC_MSG_NOTICE([ ESX: $with_esx])
AC_MSG_NOTICE([ Test: $with_test])
AC_MSG_NOTICE([ Remote: $with_remote])
@@ -2542,11 +2506,6 @@ AC_MSG_NOTICE([ netcf: $NETCF_CFLAGS $NETCF_LIBS])
else
AC_MSG_NOTICE([ netcf: no])
fi
-if test "$with_one" = "yes" ; then
-AC_MSG_NOTICE([ xmlrpc: $XMLRPC_CFLAGS $XMLRPC_LIBS])
-else
-AC_MSG_NOTICE([ xmlrpc: no])
-fi
if test "$with_qemu" = "yes" && test "$LIBPCAP_FOUND" != "no"; then
AC_MSG_NOTICE([ pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS])
else
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 9e3a557..0fde04c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -114,10 +114,6 @@ if WITH_UML
libvirtd_LDADD += ../src/libvirt_driver_uml.la
endif
-if WITH_ONE
- libvirtd_LDADD += ../src/libvirt_driver_one.la
-endif
-
if WITH_STORAGE_DIR
libvirtd_LDADD += ../src/libvirt_driver_storage.la
endif
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 7818316..024f56f 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -87,9 +87,6 @@
# ifdef WITH_UML
# include "uml/uml_driver.h"
# endif
-# ifdef WITH_ONE
-# include "opennebula/one_driver.h"
-# endif
# ifdef WITH_NETWORK
# include "network/bridge_driver.h"
# endif
@@ -925,7 +922,6 @@ static struct qemud_server *qemudInitialize(void) {
virDriverLoadModule("qemu");
virDriverLoadModule("lxc");
virDriverLoadModule("uml");
- virDriverLoadModule("one");
virDriverLoadModule("nwfilter");
#else
# ifdef WITH_NETWORK
@@ -958,9 +954,6 @@ static struct qemud_server *qemudInitialize(void) {
# ifdef WITH_UML
umlRegister();
# endif
-# ifdef WITH_ONE
- oneRegister();
-# endif
#endif
return server;
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index ecad03a..0428870 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -20,7 +20,6 @@
<ul>
<li><strong><a href="drvlxc.html">LXC</a></strong> - Linux Containers</li>
- <li><strong><a href="drvone.html">OpenNebula</a></strong></li>
<li><strong><a href="drvopenvz.html">OpenVZ</a></strong></li>
<li><strong><a href="drvqemu.html">QEMU</a></strong></li>
<li><strong><a href="drvtest.html">Test</a></strong> - Used for testing</li>
diff --git a/docs/drvone.html.in b/docs/drvone.html.in
deleted file mode 100644
index 036c0c7..0000000
--- a/docs/drvone.html.in
+++ /dev/null
@@ -1,108 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
-<title></title>
-<meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)">
-<meta name="CREATED" content="0;0">
-<meta name="CHANGED" content="20090701;13170700">
-</head>
-<body lang="en-US" dir="LTR">
-<h1>OpenNebula Virtual Infrastructure Manager driver</h1>
-<p><a name="toc"></a><a href="http://opennebula.org/">OpenNebula</a>
-is a Virtual Infrastructure Manager that controls Virtual Machines (VM) in a pool of distributed resources
-by orchestrating network, storage and virtualization technologies. The OpenNebula driver lets you manage your private or hybrid (<a href="http://aws.amazon.com/ec2/">Amazon EC2</a> or <a href="http://www.elastichosts.com/">Elastic Hosts</a> based) cloud using a standard libvirt interface, including the API as well as the related
-tools and VM description files.</p>
-<h2>
-<a name="prereq"></a>Deployment pre-requisites</h2>
-<ul>
-<li>
-<p style="margin-bottom: 0in">A working OpenNebula installation,
- version 1.2 or higher.
- </p>
- </li>
-</ul>
-<h2>
-<a name="uris"></a>Connections to OpenNebula driver</h2>
-<p>The Uri of the driver protocol is "one". Some example
-connection Uris for the driver are:
-</p>
-<pre>
-one:/// (local access)
-one+unix:/// (local access)
-one://example.com/ (remote access)
-one+tcp://example.com/ (remote access, SASl/Kerberos)
-one+ssh://user@example.com/ (remote access, SSH tunnelled)
-</pre>
-<h2>
-<a name="xmlconfig"></a>Example domain XML config</h2>
-<p>There are some limitations on the XML attributes that may be
-specified when interfacing OpenNebula. The following xml example
-details the attributes and options supported by the OpenNebula
-driver:</p>
-
-<h3>Paravirtualized guest direct kernel boot
-</h3>
-<pre>
-<domain type='one'>
- <name>vm01</name>
- <memory>32768</memory>
- <vcpu>1</vcpu>
-
- <os>
- <type>linux</type>
- <kernel>/boot/vmlinuz-2.6.24-17-xen</kernel>
- <initrd>/boot/initrd.img-2.6.24-17-xen</initrd>
- <cmdline></cmdline>
- <root>sda1</root>
- </os>
-
- <devices>
- <disk type='file' device='disk'>
- <source file='/images/sgehosts/01/disk.img'/>
- <target dev='sda1'/>
- </disk>
-
- <disk type='file' device='disk'>
- <source file='/images/sgehosts/01/swap.img'/>
- <target dev='sda2'/>
- </disk>
-
- <disk type='file' device='cdrom'>
- <source file='/images/iso/cdrom.iso'/>
- <target dev='hdc'/>
- <readonly/>
- </disk>
-
-
- <!--BRIDGE-->
- <interface type='bridge'>
- <source bridge='eth0'/>
- <mac address='00:16:3e:5d:c7:9e'/>
- </interface>
-
- <!--ONE Network-->
- <interface type='network'>
- <source network='onenetwork'/>
- </interface>
- </devices>
-</domain>
-</pre>
-<p>
-<b>Note:</b> The "<interface type='network'>" will
-attach the interface to a previously configured network (named
-<tt>onenetwork</tt>) within the <a href="http://opennebula.org/">OpenNebula</a> system, typically with the
-<tt>onevnet</tt> CLI command.</p>
-
-<p><b>Note</b>: OpenNebula supports the simultaneous use of different hypervisors, so you can specify any os type (linux or hvm) supported by your cluster.
-</p>
-
-<h2>Links</h2>
-<ul>
-<li><a href="http://www.opennebula.org/doku.php?id=documentation">OpenNebula Documentation</a>
-</li>
-<li><a href="http://www.opennebula.org/doku.php?id=documentation:rel1.2:ug">OpenNebula User Guide</a>
-</li>
-</ul>
-</body>
-</html>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index ac0af71..5650fee 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -191,10 +191,6 @@
<span>Driver for VirtualBox</span>
</li>
<li>
- <a href="drvone.html">OpenNebula</a>
- <span>Driver for OpenNebula</span>
- </li>
- <li>
<a href="drvesx.html">VMware ESX</a>
<span>Driver for VMware ESX</span>
</li>
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4a62c80..2a84c26 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -46,8 +46,6 @@
%define with_uml 0%{!?_without_uml:%{server_drivers}}
%define with_xenapi 0%{!?_without_xenapi:%{server_drivers}}
%define with_libxl 0%{!?_without_libxl:%{server_drivers}}
-# XXX this shouldn't be here, but it mistakenly links into libvirtd
-%define with_one 0%{!?_without_one:%{server_drivers}}
# Then the hypervisor drivers that talk a native remote protocol
%define with_phyp 0%{!?_without_phyp:1}
@@ -96,13 +94,12 @@
%define with_numactl 0
%endif
-# RHEL doesn't ship OpenVZ, VBox, UML, OpenNebula, PowerHypervisor,
+# RHEL doesn't ship OpenVZ, VBox, UML, PowerHypervisor,
# VMWare, libxenserver (xenapi), or libxenlight (Xen 4.1 and newer)
%if 0%{?rhel}
%define with_openvz 0
%define with_vbox 0
%define with_uml 0
-%define with_one 0
%define with_phyp 0
%define with_vmware 0
%define with_xenapi 0
@@ -306,9 +303,6 @@ Requires: libcgroup
%if %{with_xen}
BuildRequires: xen-devel
%endif
-%if %{with_one}
-BuildRequires: xmlrpc-c-devel >= 1.14.0
-%endif
BuildRequires: libxml2-devel
BuildRequires: xhtml1-dtds
BuildRequires: readline-devel
@@ -540,10 +534,6 @@ of recent versions of Linux (and other OSes).
%define _without_uml --without-uml
%endif
-%if ! %{with_one}
-%define _without_one --without-one
-%endif
-
%if %{with_rhel5}
%define _with_rhel5_api --with-rhel5-api
%endif
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index 0841dc0..27c75c1 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -54,7 +54,6 @@ MinGW Windows libvirt virtualization library.
--without-uml \
--without-vbox \
--without-openvz \
- --without-one \
--without-phyp \
--without-netcf \
--without-audit \
diff --git a/src/Makefile.am b/src/Makefile.am
index c3729a6..cacfc49 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -306,14 +306,6 @@ UML_DRIVER_SOURCES = \
uml/uml_conf.c uml/uml_conf.h \
uml/uml_driver.c uml/uml_driver.h
-ONE_DRIVER_SOURCES = \
- ./opennebula/one_conf.c \
- ./opennebula/one_conf.h \
- ./opennebula/one_driver.c \
- ./opennebula/one_driver.h \
- ./opennebula/one_client.c \
- ./opennebula/one_client.h
-
ESX_DRIVER_SOURCES = \
esx/esx_private.h \
esx/esx_driver.c esx/esx_driver.h \
@@ -794,26 +786,6 @@ endif
libvirt_driver_uml_la_SOURCES = $(UML_DRIVER_SOURCES)
endif
-if WITH_ONE
-if WITH_DRIVER_MODULES
-mod_LTLIBRARIES += libvirt_driver_one.la
-else
-noinst_LTLIBRARIES += libvirt_driver_one.la
-# Stateful, so linked to daemon instead
-#libvirt_la_BUILT_LIBADD += libvirt_driver_one.la
-endif
-libvirt_driver_one_la_CFLAGS = $(XMLRPC_CFLAGS) \
- -I@top_srcdir@/src/conf $(AM_CFLAGS)
-libvirt_driver_one_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_one_la_LIBADD = $(XMLRPC_LIBS)
-#libvirt_driver_one_la_CFLAGS = "-DWITH_ONE"
-if WITH_DRIVER_MODULES
-libvirt_driver_one_la_LIBADD += ../gnulib/lib/libgnu.la
-libvirt_driver_one_la_LDFLAGS += -module -avoid-version
-endif
-libvirt_driver_one_la_SOURCES = $(ONE_DRIVER_SOURCES)
-endif
-
BUILT_SOURCES += $(ESX_DRIVER_GENERATED)
@@ -1023,7 +995,6 @@ EXTRA_DIST += \
$(QEMU_DRIVER_SOURCES) \
$(LXC_DRIVER_SOURCES) \
$(UML_DRIVER_SOURCES) \
- $(ONE_DRIVER_SOURCES) \
$(OPENVZ_DRIVER_SOURCES) \
$(PHYP_DRIVER_SOURCES) \
$(VBOX_DRIVER_SOURCES) \
diff --git a/src/README b/src/README
index ad171a5..f95a8b7 100644
--- a/src/README
+++ b/src/README
@@ -27,7 +27,6 @@ Then there are the hypervisor implementations:
* esx/ - VMware ESX and GSX support using vSphere API over SOAP
* lxc/ - Linux Native Containers
- * opennebula/ - Open Nebula using XMLRPC
* openvz/ - OpenVZ containers using cli tools
* phyp/ - IBM Power Hypervisor using CLI tools over SSH
* qemu/ - QEMU / KVM using qemu CLI/monitor
@@ -42,8 +41,8 @@ Then there are the hypervisor implementations:
Finally some secondary drivers that are shared for several HVs.
Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers.
-The ESX, OpenNebula, Power Hypervisor, Remote, Test & VirtualBox
-drivers all implement the secondary drivers directly
+The ESX, Power Hypervisor, Remote, Test & VirtualBox drivers all
+implement the secondary drivers directly
* cpu/ - CPU feature management
* interface/ - Host network interface management
diff --git a/src/opennebula/one_client.c b/src/opennebula/one_client.c
deleted file mode 100644
index da806fc..0000000
--- a/src/opennebula/one_client.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <config.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "one_client.h"
-#include "datatypes.h"
-#include "util.h"
-#include "memory.h"
-
-oneClient one_client;
-
-void c_oneStart()
-{
- xmlrpc_env_init(&one_client.env);
- xmlrpc_client_init2(&one_client.env, XMLRPC_CLIENT_NO_FLAGS,
- "OpenNebula API Client", "1.2", NULL, 0);
-
- one_client.error = 0;
- one_client.url = "http://localhost:2633/RPC2";
- one_client.session = "one-session";
-};
-
-
-int c_oneReturnCode(xmlrpc_value *resultP);
-
-int c_oneReturnCode(xmlrpc_value *resultP)
-{
- int return_code;
- char *return_string;
-
- xmlrpc_decompose_value(&one_client.env, resultP, "(bs)",
- &return_code, &return_string);
-
- if( return_code )
- {
- xmlrpc_DECREF(resultP);
- VIR_FREE(return_string);
- return 0;
- }
- else
- {
- VIR_FREE(one_client.error);
-
- one_client.error=return_string;
- return -1;
- }
-}
-
-int c_oneDeploy(int vmid, int hid)
-{
- xmlrpc_value *resultP;
-
- resultP = xmlrpc_client_call(&one_client.env, one_client.url,
- "one.vmdeploy", "(sii)", one_client.session, (xmlrpc_int32)vmid,
- (xmlrpc_int32)hid);
-
- return c_oneReturnCode(resultP);
-}
-
-int c_oneMigrate(int vmid, int hid, int flag)
-{
- xmlrpc_value *resultP;
-
- resultP = xmlrpc_client_call(&one_client.env, one_client.url,
- "one.vmmigrate", "(siib)", one_client.session, (xmlrpc_int32)vmid,
- (xmlrpc_int32)hid,
- (xmlrpc_bool)flag);
-
- return c_oneReturnCode(resultP);
-}
-
-int c_oneAllocateTemplate(char* vm_template)
-{
- xmlrpc_value *resultP;
- xmlrpc_value *valueP;
- int return_code;
- char *return_string;
- int vmid;
-
-
- resultP = xmlrpc_client_call(&one_client.env, one_client.url,
- "one.vmallocate", "(ss)", one_client.session, vm_template);
-
- xmlrpc_array_read_item(&one_client.env, resultP, 0, &valueP);
- xmlrpc_read_bool(&one_client.env, valueP, &return_code);
-
- if( return_code )
- {
- xmlrpc_DECREF(valueP);
- xmlrpc_array_read_item(&one_client.env, resultP, 1, &valueP);
- xmlrpc_read_int(&one_client.env, valueP, &vmid);
-
- xmlrpc_DECREF(valueP);
- xmlrpc_DECREF(resultP);
-
- return vmid;
- }
- else
- {
- xmlrpc_DECREF(valueP);
- xmlrpc_array_read_item(&one_client.env, resultP, 1, &valueP);
- xmlrpc_read_string(&one_client.env, valueP,
- (const char **)&return_string);
-
- xmlrpc_DECREF(valueP);
- xmlrpc_DECREF(resultP);
-
- VIR_FREE(one_client.error);
-
- one_client.error=return_string;
- return -1;
- }
-}
-
-int c_oneAction(int vmid, char* action)
-{
- xmlrpc_value *resultP;
-
- resultP = xmlrpc_client_call(&one_client.env, one_client.url,
- "one.vmaction", "(ssi)", one_client.session, action,
- (xmlrpc_int32)vmid);
-
- return c_oneReturnCode(resultP);
-}
-
-int c_oneShutdown(int vmid)
-{
- return c_oneAction(vmid, (char *)"shutdown");
-}
-
-int c_oneSuspend(int vmid)
-{
- return c_oneAction(vmid, (char *)"suspend");
-}
-
-int c_oneStop(int vmid)
-{
- return c_oneAction(vmid, (char *)"stop");
-}
-
-int c_oneResume(int vmid)
-{
- return c_oneAction(vmid, (char *)"resume");
-}
-
-int c_oneCancel(int vmid)
-{
- return c_oneAction(vmid, (char *)"cancel");
-}
-
-int c_oneFinalize(int vmid)
-{
- return c_oneAction(vmid, (char *)"finalize");
-}
-
-int c_oneVmInfo(int vmid, char* ret_info, int length)
-{
- xmlrpc_value *resultP;
- int return_code;
- char *return_string;
- int retval = -1;
-
- resultP = xmlrpc_client_call(&one_client.env, one_client.url,
- "one.vmget_info", "(si)", one_client.session, vmid);
-
- xmlrpc_decompose_value(&one_client.env, resultP, "(bs)",
- &return_code, &return_string);
-
- if( return_code )
- {
- if (virStrncpy(ret_info, return_string, length-1, length) != NULL)
- /* Only set the return value to 0 if we succeeded */
- retval = 0;
- }
-
- xmlrpc_DECREF(resultP);
- VIR_FREE(return_string);
-
- return retval;
-}
-
-void c_oneFree()
-{
- xmlrpc_env_clean(&one_client.env);
- xmlrpc_client_cleanup();
-}
diff --git a/src/opennebula/one_client.h b/src/opennebula/one_client.h
deleted file mode 100644
index e94956d..0000000
--- a/src/opennebula/one_client.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef ONE_CLIENT_H_
-# define ONE_CLIENT_H_
-
-# include <xmlrpc-c/base.h>
-# include <xmlrpc-c/client.h>
-
-struct _oneClient {
- xmlrpc_env env;
- const char *url;
- const char *session;
- char *error;
-};
-
-typedef struct _oneClient oneClient;
-typedef oneClient *oneClientPtr;
-
-void c_oneStart(void);
-
-int c_oneDeploy(int vmid, int hid);
-
-int c_oneMigrate(int vmid, int hid, int flag);
-
-int c_oneAllocateTemplate(char* vm_template);
-
-int c_oneAction(int vmid,char* action);
-
-int c_oneShutdown(int vmid);
-
-int c_oneSuspend(int vmid);
-
-int c_oneStop(int vmid);
-
-int c_oneResume(int vmid);
-
-int c_oneCancel(int vmid);
-
-int c_oneFinalize(int vmid);
-
-int c_oneVmInfo(int vmid, char* ret_info,int leng);
-
-void c_oneFree(void);
-
-
-#endif /* ONE_CLIENT_H_ */
diff --git a/src/opennebula/one_conf.c b/src/opennebula/one_conf.c
deleted file mode 100644
index 9f0ed26..0000000
--- a/src/opennebula/one_conf.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*----------------------------------------------------------------------------------*/
-/*
- * Copyright (C) 2010 Red Hat, Inc.
- * Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*-----------------------------------------------------------------------------------*/
-
-#include <config.h>
-#include <sys/utsname.h>
-
-#include "virterror_internal.h"
-#include "one_conf.h"
-#include "buf.h"
-#include "memory.h"
-#include "util.h"
-
-#define VIR_FROM_THIS VIR_FROM_ONE
-/* --------------------------------------------------------------------------------- */
-
-/**
- * oneCapsInit initialize the driver capabilities
- * @return a pointer to the driver capabilities NULL in case of error
- */
-
-virCapsPtr oneCapsInit(void)
-{
- struct utsname utsname;
- virCapsPtr caps;
- virCapsGuestPtr guest;
-
- uname(&utsname);
-
- if ((caps = virCapabilitiesNew(utsname.machine,0,0)) == NULL)
- {
- goto no_memory;
- }
-
- virCapabilitiesSetMacPrefix(caps,(unsigned char[]){ 0x52, 0x54, 0x00 });
-
- if ((guest = virCapabilitiesAddGuest(caps,
- "hvm",
- "i686",
- 32,
- NULL,
- NULL,
- 0,
- NULL)) == NULL)
- {
- goto no_memory;
- }
-
- if (virCapabilitiesAddGuestDomain(guest,
- "one",
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- {
- goto no_memory;
- }
-
-
- if ((guest = virCapabilitiesAddGuest(caps,
- "hvm",
- "x86_64",
- 64,
- NULL,
- NULL,
- 0,
- NULL)) == NULL)
- {
- goto no_memory;
- }
-
- if (virCapabilitiesAddGuestDomain(guest,
- "one",
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- {
- goto no_memory;
- }
- if ((guest = virCapabilitiesAddGuest(caps,
- "xen",
- "i686",
- 32,
- NULL,
- NULL,
- 0,
- NULL)) == NULL)
- {
- goto no_memory;
- }
- if (virCapabilitiesAddGuestDomain(guest,
- "one",
- NULL,
- NULL,
- 0,
- NULL) == NULL)
- {
- goto no_memory;
- }
-
- return caps;
-
-no_memory:
-
- virCapabilitiesFree(caps);
- return NULL;
-}
-
-/* --------------------------------------------------------------------------------- */
-/* --------------------------------------------------------------------------------- */
-/* --------------------------------------------------------------------------------- */
-
-
-/**
- * oneSubmitVM generates an OpenNebula description file and submits the new VM
- * @param driver the OpenNebula driver
- * @param vm the virtual machine pointer
- * @return the OpenNebula ID for the new VM or -1 in case of error
- */
-
-int oneSubmitVM(one_driver_t* driver ATTRIBUTE_UNUSED,
- virDomainObjPtr vm)
-{
- char* templ;
- int oneid;
-
- if ((templ = xmlOneTemplate(vm->def)) == NULL)
- return -1;
-
- if ((oneid = c_oneAllocateTemplate(templ)) < 0) {
- oneError(VIR_ERR_OPERATION_FAILED, "%s",
- _("Error submitting virtual machine to OpenNebula"));
- VIR_FREE(templ);
- return -1;
- }
-
- VIR_FREE(templ);
- return oneid;
-}
-/* --------------------------------------------------------------------------------- */
-/* --------------------------------------------------------------------------------- */
-/* --------------------------------------------------------------------------------- */
-
-/**
- * xmlOneTemplate Generate an OpenNebula template to deploy a VM from libvirt
- * internal Domain definition.
- * @param def Internal libvirt Domain definition
- * @return OpenNebula VM template.
- */
-
-char* xmlOneTemplate(virDomainDefPtr def)
-{
- int i;
- virBuffer buf= VIR_BUFFER_INITIALIZER;
- virBufferVSprintf(&buf,"#OpenNebula Template automatically generated "
- "by libvirt\nNAME = %s\nCPU = %d\nMEMORY = %ld\n",
- def->name,
- def->maxvcpus,
- VIR_DIV_UP(def->mem.max_balloon, 1024));
-
- /*Optional Booting OpenNebula Information:*/
- if (def->os.kernel) {
- virBufferVSprintf(&buf,"OS=[ kernel = \"%s\"",def->os.kernel);
- if (def->os.initrd)
- virBufferVSprintf(&buf,",\n initrd = \"%s\"",def->os.initrd);
- if (def->os.cmdline)
- virBufferVSprintf(&buf,",\n kernel_cmd = \"%s\"",def->os.cmdline);
- if (def->os.root)
- virBufferVSprintf(&buf,",\n root = \"%s\"",def->os.root);
-
- virBufferAddLit(&buf," ]\n");
- }
- /* set Disks & NICS */
- for (i=0 ; i < def->ndisks ; i++) {
- /* missing source is only allowed at cdrom and floppy */
- if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- virBufferVSprintf(&buf, "DISK=[ type = disk,\n"
- "\tsource = \"%s\",\n",
- def->disks[i]->src);
- }
- else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
- virBufferAddLit(&buf, "DISK=[ type = cdrom,\n");
- if (def->disks[i]->src) virBufferVSprintf(&buf, "\tsource = \"%s\",\n",def->disks[i]->src);
- }
- else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
- virBufferAddLit(&buf, "DISK=[ type = floppy,\n");
- if (def->disks[i]->src) virBufferVSprintf(&buf, "\tsource = \"%s\",\n",def->disks[i]->src);
- }
-
- virBufferVSprintf(&buf, "\ttarget = \"%s\",\n"
- "\treadonly =",
- def->disks[i]->dst);
-
- if (def->disks[i]->readonly)
- virBufferAddLit(&buf,"\"yes\"]\n");
- else
- virBufferAddLit(&buf,"\"no\"]\n");
- }
-
- for (i=0 ; i< def->nnets ; i++)
- {
- if (!def->nets[i]) {
- continue;
- }
-
- switch(def->nets[i]->type)
- {
- case VIR_DOMAIN_NET_TYPE_BRIDGE:
- virBufferVSprintf(&buf,"NIC=[ bridge =\"%s\",\n",def->nets[i]->data.bridge.brname);
-
- if (def->nets[i]->ifname)
- virBufferVSprintf(&buf," target =\"%s\",\n",def->nets[i]->ifname);
-
- virBufferVSprintf(&buf," mac =\"%02x:%02x:%02x:%02x:%02x:%02x\" ]\n",
- def->nets[i]->mac[0],def->nets[i]->mac[1],
- def->nets[i]->mac[2],def->nets[i]->mac[3],
- def->nets[i]->mac[4],def->nets[i]->mac[5]);
- break;
-
- case VIR_DOMAIN_NET_TYPE_NETWORK:
- virBufferVSprintf(&buf,"NIC=[ network=\"%s\"",def->nets[i]->data.network.name);
- if (def->nets[i]->ifname)
- virBufferVSprintf(&buf,",\n target =\"%s\"",def->nets[i]->ifname);
- virBufferAddLit(&buf," ]\n");
- break;
-
- default: break;
- }
- }
-
- for(i=0;i<def->ngraphics;i++) {
- if (def->graphics[i] == NULL)
- continue;
-
- if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
- virBufferAddLit(&buf,"GRAPHICS = [\n type = \"vnc\"");
-
- if (def->graphics[i]->data.vnc.listenAddr != NULL)
- virBufferVSprintf(&buf,",\n listen = \"%s\"",
- def->graphics[i]->data.vnc.listenAddr);
-
- if (def->graphics[i]->data.vnc.autoport == 0)
- virBufferVSprintf(&buf,",\n port = \"%d\"",
- def->graphics[i]->data.vnc.port);
-
- if (def->graphics[i]->data.vnc.auth.passwd != NULL)
- virBufferVSprintf(&buf,",\n passwd = \"%s\"",
- def->graphics[i]->data.vnc.auth.passwd);
-
- virBufferAddLit(&buf," ]\n");
-
- }
- else /* graphics.type==VIR_DOMAIN_GRAPHICS_TYPE_SDL */
- virBufferAddLit(&buf,"GRAPHICS = [\n type = \"sdl\" ]\n");
-
- }
- if (virBufferError(&buf))
- goto no_memory;
-
- return virBufferContentAndReset(&buf);
-
-no_memory:
- virReportOOMError();
- virBufferFreeAndReset(&buf);
- return NULL;
-};
diff --git a/src/opennebula/one_conf.h b/src/opennebula/one_conf.h
deleted file mode 100644
index c53090c..0000000
--- a/src/opennebula/one_conf.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*----------------------------------------------------------------------------------*/
-/*
- * Copyright (C) 2010 Red Hat, Inc.
- * Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*-----------------------------------------------------------------------------------*/
-
-#ifndef ONE_CONF_H
-# define ONE_CONF_H
-
-# include <config.h>
-
-# include "internal.h"
-# include "domain_conf.h"
-# include "capabilities.h"
-# include "threads.h"
-# include "one_client.h"
-
-struct one_driver{
- virMutex lock;
-
- virCapsPtr caps;
- virDomainObjList domains;
- int nextid;
-};
-
-typedef struct one_driver one_driver_t;
-
-virCapsPtr oneCapsInit(void);
-
-int oneSubmitVM(one_driver_t* driver, virDomainObjPtr vm);
-
-char* xmlOneTemplate(virDomainDefPtr def);
-
-# define oneError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_ONE, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
-
-#endif /* ONE_CONF_H */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
deleted file mode 100644
index 3146589..0000000
--- a/src/opennebula/one_driver.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*---------------------------------------------------------------------------*/
-/*
- * Copyright (C) 2010-2011 Red Hat, Inc.
- * Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*---------------------------------------------------------------------------*/
-
-#include <config.h>
-
-#include <fcntl.h>
-#include <sched.h>
-#include <sys/utsname.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/poll.h>
-#include <unistd.h>
-#include <wait.h>
-#include <sys/time.h>
-
-#include "virterror_internal.h"
-#include "logging.h"
-#include "datatypes.h"
-#include "one_conf.h"
-#include "one_driver.h"
-#include "memory.h"
-#include "util.h"
-#include "bridge.h"
-
-#define VIR_FROM_THIS VIR_FROM_ONE
-
-static int oneStartup(int privileged);
-static int oneShutdown(void);
-static int oneActive(void);
-
-static void oneDriverLock(one_driver_t* driver)
-{
- virMutexLock(&driver->lock);
-}
-
-static void oneDriverUnlock(one_driver_t* driver)
-{
- virMutexUnlock(&driver->lock);
-}
-
-static one_driver_t *one_driver =NULL;
-
-
-static virDrvOpenStatus oneOpen(virConnectPtr conn,
- virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- int flags ATTRIBUTE_UNUSED)
-{
- /* Verify uri was specified */
- if (conn->uri == NULL) {
- conn->uri = xmlParseURI("one:///");
- if (!conn->uri) {
- virReportOOMError();
- return VIR_DRV_OPEN_ERROR;
- }
- } else if (conn->uri->scheme == NULL ||
- STRNEQ(conn->uri->scheme, "one")) {
- goto declineConnection;
- }
- conn->privateData = one_driver;
-
- return VIR_DRV_OPEN_SUCCESS;
-
-declineConnection:
- return VIR_DRV_OPEN_DECLINED;
-}
-
-static int oneClose(virConnectPtr conn)
-{
- conn->privateData = NULL;
- return 0;
-}
-
-
-static int oneIsEncrypted(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Not encrypted because it uses HTTP, not HTTPs */
- return 0;
-}
-
-
-static int oneIsSecure(virConnectPtr conn ATTRIBUTE_UNUSED)
-{
- /* Not secure because it uses HTTP, not HTTPs */
- return 0;
-}
-
-static int oneIsUpdated(virDomainPtr conn ATTRIBUTE_UNUSED)
-{
- return 0;
-}
-
-static virDomainPtr oneDomainLookupByID(virConnectPtr conn,
- int id)
-{
- one_driver_t *driver = conn->privateData;
- virDomainPtr dom = NULL;
- virDomainObjPtr vm = NULL;
-
- oneDriverLock(driver);
- vm = virDomainFindByID(&driver->domains, id);
- oneDriverUnlock(driver);
-
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, NULL);
- goto return_point;
- }
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
- if (dom) {
- dom->id = vm->def->id;
- }
-
-return_point:
- if(vm) {
- virDomainObjUnlock(vm);
- }
-
- return dom;
-}
-
-static virDomainPtr oneDomainLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid)
-{
- one_driver_t *driver = conn->privateData;
- virDomainPtr dom = NULL;
- virDomainObjPtr vm = NULL;
-
- oneDriverLock(driver);
- vm = virDomainFindByUUID(&driver->domains, uuid);
- oneDriverUnlock(driver);
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, NULL);
- goto return_point;
- }
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
- if (dom) {
- dom->id = vm->def->id;
- }
-
-return_point:
- if(vm) {
- virDomainObjUnlock(vm);
- }
-
- return dom;
-}
-
-static virDomainPtr oneDomainLookupByName(virConnectPtr conn,
- const char *name)
-{
- one_driver_t *driver = conn->privateData;
- virDomainObjPtr vm = NULL;
- virDomainPtr dom=NULL;
-
- oneDriverLock(driver);
- vm = virDomainFindByName(&driver->domains, name);
- oneDriverUnlock(driver);
-
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, NULL);
- goto return_point;
- }
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
- if (dom) {
- dom->id = vm->def->id;
- }
-return_point:
- if(vm) {
- virDomainObjUnlock(vm);
- }
-
- return dom;
-}
-
-static int oneListDomains(virConnectPtr conn, int *ids, int nids)
-{
- one_driver_t *driver = conn->privateData;
- int n;
-
- oneDriverLock(driver);
- n = virDomainObjListGetActiveIDs(&driver->domains, ids, nids);
- oneDriverUnlock(driver);
-
- return n;
-}
-
-static int oneNumDomains(virConnectPtr conn)
-{
- one_driver_t *driver = conn->privateData;
- int n;
-
- oneDriverLock(driver);
- n = virDomainObjListNumOfDomains(&driver->domains, 1);
- oneDriverUnlock(driver);
-
- return n;
-}
-
-static int oneListDefinedDomains(virConnectPtr conn,
- char **const names, int nnames) {
- one_driver_t *driver = conn->privateData;
- int n;
-
- oneDriverLock(driver);
- n = virDomainObjListGetInactiveNames(&driver->domains, names, nnames);
- oneDriverUnlock(driver);
-
- return n;
-}
-
-static int oneNumDefinedDomains(virConnectPtr conn)
-{
- one_driver_t *driver = conn->privateData;
- int n;
-
- oneDriverLock(driver);
- n = virDomainObjListNumOfDomains(&driver->domains, 0);
- oneDriverUnlock(driver);
-
- return n;
-}
-
-static virDomainPtr oneDomainDefine(virConnectPtr conn, const char *xml)
-{
- one_driver_t *driver = conn->privateData;
- virDomainDefPtr def;
- virDomainObjPtr vm;
- virDomainPtr dom=NULL;
-
- oneDriverLock(driver);
- if (!(def = virDomainDefParseString(driver->caps, xml,
- VIR_DOMAIN_XML_INACTIVE)))
- goto return_point;
-
- if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def, false))) {
- virDomainDefFree(def);
- goto return_point;
- }
-
- vm->def->id = -1;
- vm->persistent = 1;
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
- if (dom) {
- dom->id = vm->def->id;
- }
- virDomainObjUnlock(vm);
-
-return_point:
- oneDriverUnlock(driver);
- return dom;
-}
-
-
-static int oneDomainUndefine(virDomainPtr dom)
-{
- one_driver_t *driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
- int ret=-1;
-
- oneDriverLock(driver);
- vm =virDomainFindByUUID(&driver->domains, dom->uuid);
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto return_point;
- }
-
- if (!vm->persistent) {
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot undefine transient domain"));
- goto return_point;
- }
- virDomainRemoveInactive(&driver->domains, vm);
- ret=0;
-
-return_point:
- if (vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
- return ret;
-}
-
-static int oneDomainGetInfo(virDomainPtr dom,
- virDomainInfoPtr info)
-{
- one_driver_t *driver = dom->conn->privateData;
- struct timeval tv;
- virDomainObjPtr vm;
- oneDriverLock(driver);
- vm= virDomainFindByUUID(&driver->domains, dom->uuid);
- oneDriverUnlock(driver);
-
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- return -1;
- }
-
- if(gettimeofday(&tv,NULL)<0) {
- oneError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("getting time of day"));
- virDomainObjUnlock(vm);
- return -1;
- }
-
- if (!virDomainObjIsActive(vm)) {
- info->cpuTime = 0;
- } else {
- char vm_info[257];
- c_oneVmInfo(vm->pid,vm_info,256);
- /* State: */
- char* cptr = strstr(vm_info,"STATE");
- cptr = index(cptr, ':');
- cptr++;
- int one_state=atoi(cptr);
-
- switch(one_state) {
- case 3: /** running */
- if (vm->state!=VIR_DOMAIN_SHUTDOWN)
- vm->state=VIR_DOMAIN_RUNNING;
- break;
- case 5: /** pause */
- vm->state=VIR_DOMAIN_PAUSED;
- break;
- case 6: /** done */
- vm->state=VIR_DOMAIN_SHUTOFF;
- vm->def->id=-1;
- break;
- case 7: /** error */
- vm->state=VIR_DOMAIN_CRASHED;
- break;
- default:
- break;
- };
- /* Memory: */
- cptr=strstr(vm_info,"MEMORY");
- cptr=index(cptr,':');
- cptr++;
- vm->def->mem.cur_balloon = atoi(cptr);
-
- /* run time: */
- cptr=strstr(vm_info,"START TIME");
- cptr=index(cptr,':');
- cptr++;
- long starttime = atol(cptr);
- info->cpuTime = (tv.tv_sec - starttime) *1000ll *1000ll *1000ll;
-
- }
-
- info->state = vm->state;
- info->maxMem = vm->def->mem.max_balloon;
- info->memory = vm->def->mem.cur_balloon;
- info->nrVirtCpu = vm->def->vcpus;
-
- virDomainObjUnlock(vm);
- return 0;
-}
-
-static char *oneGetOSType(virDomainPtr dom)
-{
- one_driver_t *driver = dom->conn->privateData;
- virDomainObjPtr vm = NULL;
- char *ret = NULL;
-
- oneDriverLock(driver);
- vm =virDomainFindByUUID(&driver->domains, dom->uuid);
- oneDriverUnlock(driver);
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN, "%s",
- _("no domain with matching uuid"));
- goto cleanup;
- }
-
- ret = strdup(vm->def->os.type);
- if (!ret)
- virReportOOMError();
-
-cleanup:
- if (vm)
- virDomainObjUnlock(vm);
- return ret;
-}
-
-static int oneDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
-{
- virConnectPtr conn = dom->conn;
- one_driver_t *driver = conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
- int oneid;
-
- virCheckFlags(0, -1);
-
- oneDriverLock(driver);
- vm = virDomainFindByName(&driver->domains, dom->name);
-
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN,
- _("no domain named %s"), dom->name);
- goto return_point;
- }
- if((oneid = oneSubmitVM(driver, vm)) < 0) {
- goto return_point;
- }
- vm->pid=oneid;
- vm->def->id=driver->nextid++;
- vm->state=VIR_DOMAIN_BLOCKED;
- ret=0;
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
-
- return ret;
-}
-
-static int oneDomainStart(virDomainPtr dom)
-{
- return oneDomainStartWithFlags(dom, 0);
-}
-
-static virDomainPtr
-oneDomainCreateAndStart(virConnectPtr conn,
- const char *xml,
- unsigned int flags) {
- one_driver_t *driver = conn->privateData;
- virDomainObjPtr vm = NULL;
- virDomainDefPtr def;
- virDomainPtr dom = NULL;
- int oneid;
-
- virCheckFlags(0, NULL);
-
- oneDriverLock(driver);
- if (!(def = virDomainDefParseString(driver->caps, xml,
- VIR_DOMAIN_XML_INACTIVE)))
- goto return_point;
-
- vm = virDomainFindByName(&driver->domains, def->name);
- if (vm) {
- oneError(VIR_ERR_OPERATION_FAILED,
- _("Already an OpenNebula VM active with the name: '%s' id: %d "),
- def->name,def->id);
- goto return_point;
- }
-
- if (!(vm = virDomainAssignDef(driver->caps,
- &driver->domains, def, false))) {
- virDomainDefFree(def);
- goto return_point;
- }
- if ((oneid = oneSubmitVM(driver, vm)) < 0) {
- virDomainRemoveInactive(&driver->domains, vm);
- vm=NULL;
- goto return_point;
- }
-
- vm->def->id=driver->nextid++;
- vm->persistent=0;
- vm->pid=oneid;
- vm->state=VIR_DOMAIN_BLOCKED;
-
- dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
- if (dom) {
- dom->id = vm->def->id;
- }
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
-
- return dom;
-}
-
-static int oneDomainShutdown(virDomainPtr dom)
-{
- one_driver_t *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret=-1;
-
- oneDriverLock(driver);
- if (!(vm=virDomainFindByID(&driver->domains, dom->id))) {
- oneError(VIR_ERR_NO_DOMAIN,
- _("no domain with id %d"), dom->id);
- goto return_point;
- }
-
- if (c_oneShutdown(vm->pid)) {
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("Wrong state to perform action"));
- goto return_point;
- }
- vm->state=VIR_DOMAIN_SHUTDOWN;
- ret= 0;
-
- if (!vm->persistent) {
- virDomainRemoveInactive(&driver->domains, vm);
- vm = NULL;
- }
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
-
- return ret;
-}
-
-static int oneDomainDestroy(virDomainPtr dom)
-{
- one_driver_t *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret=-1;
-
- oneDriverLock(driver);
- vm= virDomainFindByID(&driver->domains, dom->id);
- if (!vm) {
- oneError(VIR_ERR_NO_DOMAIN,
- _("no domain with id %d"), dom->id);
- goto return_point;
- }
- if(c_oneCancel(vm->pid)) {
- /* VM not running, delete the instance at ONE DB */
- if(c_oneFinalize(vm->pid)){
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("Wrong state to perform action"));
- goto return_point;
- }
- }
- if(!vm->persistent) {
- virDomainRemoveInactive(&driver->domains,vm);
- vm=NULL;
- }
- ret=0;
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
-
- oneDriverUnlock(driver);
-
- return ret;
-}
-
-static int oneDomainSuspend(virDomainPtr dom)
-{
- one_driver_t* driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret=-1;
-
- oneDriverLock(driver);
- if ((vm=virDomainFindByID(&driver->domains,dom->id))){
-
- if (vm->state == VIR_DOMAIN_RUNNING) {
- if( !(c_oneSuspend(vm->pid)) ) {
- vm->state=VIR_DOMAIN_PAUSED;
- ret=0;
- goto return_point;
- }
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("Wrong state to perform action"));
- goto return_point;
- }
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain is not running"));
- } else {
- oneError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id %d"), dom->id);
- }
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
-
- return ret;
-};
-
-static int oneDomainResume(virDomainPtr dom)
-{
- one_driver_t* driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret=-1;
-
- oneDriverLock(driver);
- if ((vm=virDomainFindByID(&driver->domains,dom->id))) {
- if (vm->state == VIR_DOMAIN_PAUSED) {
- if( !(c_oneResume(vm->pid)) ) {
- vm->state=VIR_DOMAIN_RUNNING;
- ret=0;
- goto return_point;
- }
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("Wrong state to perform action"));
- goto return_point;
- }
- oneError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain is not paused"));
- } else {
- oneError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching id %d"), dom->id);
- }
-
-return_point:
- if(vm)
- virDomainObjUnlock(vm);
- oneDriverUnlock(driver);
-
- return ret;
-};
-
-static int oneStartup(int privileged ATTRIBUTE_UNUSED){
-
- if (VIR_ALLOC(one_driver) < 0) {
- return -1;
- }
-
- if(virMutexInit(&one_driver->lock)<0){
- VIR_FREE(one_driver);
- return -1;
- }
-
- c_oneStart();
- oneDriverLock(one_driver);
-
- if (virDomainObjListInit(&one_driver->domains) < 0) {
- goto error;
- }
-
- one_driver->nextid=1;
- if ((one_driver->caps = oneCapsInit()) == NULL) {
- virReportOOMError();
- goto error;
- }
- oneDriverUnlock(one_driver);
-
- return 0;
-
-error:
- oneDriverUnlock(one_driver);
- oneShutdown();
- return -1;
-}
-
-static int oneShutdown(void){
- if (one_driver == NULL)
- return(-1);
-
- oneDriverLock(one_driver);
- virDomainObjListDeinit(&one_driver->domains);
-
- virCapabilitiesFree(one_driver->caps);
- oneDriverUnlock(one_driver);
- virMutexDestroy(&one_driver->lock);
- VIR_FREE(one_driver);
- one_driver = NULL;
- c_oneFree();
- return 0;
-}
-
-static int oneActive(void){
- int active = 0;
-
- if (one_driver == NULL)
- return(0);
-
- oneDriverLock(one_driver);
- active = virDomainObjListNumOfDomains(&one_driver->domains, 1);
- oneDriverUnlock(one_driver);
-
- return active;
-
-}
-
-static int oneVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *hvVer)
-{
- *hvVer = 1;
- return 0;
-}
-
-
-static int oneGetAutostart(virDomainPtr domain ATTRIBUTE_UNUSED, int *autostart)
-{
- autostart=0;
- return 0;
-}
-
-static char* oneGetCapabilities(virConnectPtr conn){
- one_driver_t* privconn = conn->privateData;
- char *xml;
- oneDriverLock(privconn);
- if ((xml = virCapabilitiesFormatXML(privconn->caps)) == NULL)
- virReportOOMError();
- oneDriverUnlock(privconn);
- return xml;
-}
-/* Function Tables */
-static virDriver oneDriver = {
- VIR_DRV_ONE, /* the number virDrvNo */
- "one", /* the name of the driver */
- oneOpen, /* open */
- oneClose, /* close */
- NULL, /* supports_feature */
- NULL, /* type */
- oneVersion, /* version */
- NULL, /* libvirtVersion (impl. in libvirt.c) */
- NULL, /* getHostname */
- NULL, /* getSysinfo */
- NULL, /* getMaxVcpus */
- NULL, /* nodeGetInfo */
- oneGetCapabilities, /* getCapabilities */
- oneListDomains, /* listDomains */
- oneNumDomains, /* numOfDomains */
- oneDomainCreateAndStart, /* domainCreateXML */
- oneDomainLookupByID, /* domainLookupByID */
- oneDomainLookupByUUID, /* domainLookupByUUID */
- oneDomainLookupByName, /* domainLookupByName */
- oneDomainSuspend, /* domainSuspend */
- oneDomainResume, /* domainResume */
- oneDomainShutdown, /* domainShutdown */
- NULL, /* domainReboot */
- oneDomainDestroy, /* domainDestroy */
- oneGetOSType, /* domainGetOSType */
- NULL, /* domainGetMaxMemory */
- NULL, /* domainSetMaxMemory */
- NULL, /* domainSetMemory */
- NULL, /* domainSetMemoryFlags */
- NULL, /* domainSetMemoryParameters */
- NULL, /* domainGetMemoryParameters */
- NULL, /* domainSetBlkioParameters */
- NULL, /* domainGetBlkioParameters */
- oneDomainGetInfo, /* domainGetInfo */
- NULL, /* domainSave */
- NULL, /* domainRestore */
- NULL, /* domainCoreDump */
- NULL, /* domainSetVcpus */
- NULL, /* domainSetVcpusFlags */
- NULL, /* domainGetVcpusFlags */
- NULL, /* domainPinVcpu */
- NULL, /* domainGetVcpus */
- NULL, /* domainGetMaxVcpus */
- NULL, /* domainGetSecurityLabel */
- NULL, /* nodeGetSecurityModel */
- NULL, /* domainDumpXML */
- NULL, /* domainXMLFromNative */
- NULL, /* domainXMLToNative */
- oneListDefinedDomains, /* listDefinedDomains */
- oneNumDefinedDomains, /* numOfDefinedDomains */
- oneDomainStart, /* domainCreate */
- oneDomainStartWithFlags, /* domainCreateWithFlags */
- oneDomainDefine, /* domainDefineXML */
- oneDomainUndefine, /* domainUndefine */
- NULL, /* domainAttachDevice */
- NULL, /* domainAttachDeviceFlags */
- NULL, /* domainDetachDevice */
- NULL, /* domainDetachDeviceFlags */
- NULL, /* domainUpdateDeviceFlags */
- oneGetAutostart, /* domainGetAutostart */
- NULL, /* domainSetAutostart */
- NULL, /* domainGetSchedulerType */
- NULL, /* domainGetSchedulerParameters */
- NULL, /* domainSetSchedulerParameters */
- NULL, /* domainMigratePrepare */
- NULL, /* domainMigratePerform */
- NULL, /* domainMigrateFinish */
- NULL, /* domainBlockStats */
- NULL, /* domainInterfaceStats */
- NULL, /* domainMemoryStats */
- NULL, /* domainBlockPeek */
- NULL, /* domainMemoryPeek */
- NULL, /* domainGetBlockInfo */
- NULL, /* nodeGetCellsFreeMemory */
- NULL, /* getFreeMemory */
- NULL, /* domainEventRegister */
- NULL, /* domainEventDeregister */
- NULL, /* domainMigratePrepare2 */
- NULL, /* domainMigrateFinish2 */
- NULL, /* nodeDeviceDettach; */
- NULL, /* nodeDeviceReAttach; */
- NULL, /* nodeDeviceReset; */
- NULL, /* domainMigratePrepareTunnel */
- oneIsEncrypted, /* isEncrypted */
- oneIsSecure, /* isSecure */
- NULL, /* domainIsActive */
- NULL, /* domainIsPersistent */
- oneIsUpdated, /* domainIsUpdated */
- NULL, /* cpuCompare */
- NULL, /* cpuBaseline */
- NULL, /* domainGetJobInfo */
- NULL, /* domainAbortJob */
- NULL, /* domainMigrateSetMaxDowntime */
- NULL, /* domainMigrateSetMaxSpeed */
- NULL, /* domainEventRegisterAny */
- NULL, /* domainEventDeregisterAny */
- NULL, /* domainManagedSave */
- NULL, /* domainHasManagedSaveImage */
- NULL, /* domainManagedSaveRemove */
- NULL, /* domainSnapshotCreateXML */
- NULL, /* domainSnapshotDumpXML */
- NULL, /* domainSnapshotNum */
- NULL, /* domainSnapshotListNames */
- NULL, /* domainSnapshotLookupByName */
- NULL, /* domainHasCurrentSnapshot */
- NULL, /* domainSnapshotCurrent */
- NULL, /* domainRevertToSnapshot */
- NULL, /* domainSnapshotDelete */
- NULL, /* qemuDomainMonitorCommand */
- NULL, /* domainOpenConsole */
-};
-
-static virStateDriver oneStateDriver = {
- .name = "OpenNebula",
- .initialize = oneStartup,
- .cleanup = oneShutdown,
- .active = oneActive,
-};
-
-
-int oneRegister(void)
-{
- virRegisterDriver(&oneDriver);
- virRegisterStateDriver(&oneStateDriver);
- return 0;
-}
diff --git a/src/opennebula/one_driver.h b/src/opennebula/one_driver.h
deleted file mode 100644
index 6cc1f46..0000000
--- a/src/opennebula/one_driver.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*---------------------------------------------------------------------------*/
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
- * Complutense de Madrid (dsa-research.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*---------------------------------------------------------------------------*/
-
-
-#ifndef ONE_DRIVER_H
-# define ONE_DRIVER_H
-
-# include <config.h>
-# include "one_client.h"
-
-int oneRegister(void);
-
-#endif /* ONE_DRIVER_H */
--
1.7.4
5
8