Re: [libvirt] Entering 0.9.0 freeze week, RC1 version to test
by Justin Clift
Hey all,
virsh in 0.9.0 RC1 doesn't work properly. There's a hang at
start up:
$ virsh
<waits forever>
Control-C breaks out ok, dropping back to bash prompt.
The pieces compiled in were:
$ virsh -V
Virsh command line tool of libvirt 0.9.0
See web site at http://libvirt.org/
Compiled with support for:
Hypervisors: OpenVZ VirtualBox ESX Test
Networking: Remote Daemon
Storage: Dir SCSI
Miscellaneous: Secrets Debug Readline
This is definitely something new. With 0.8.8, virsh starts ok:
$ virsh
Welcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh # ^D
$
Compiled with the same options:
$ virsh -V
Virsh command line tool of libvirt 0.8.8
See web site at http://libvirt.org/
Compiled with support for:
Hypervisors: OpenVZ VirtualBox ESX Test
Networking: Remote Daemon
Storage: Dir SCSI
Miscellaneous: Secrets Debug Readline
Haven't looked into this in more detail yet, but might
get time to today/tomorrow. Kind of wondering if it's
related to the win32 prob Matthias mentioned.
Regards and best wishes,
Justin Clift
13 years, 8 months
[libvirt] [PATCH] Add missing checks for QEMU domain state in tunables APIs
by Daniel P. Berrange
The methods qemuDomain{Get,Set}{Memory,Blkio,Scheduler}Parameters
all forgot to do a check on virDomainIsActive(), resulting in bogus
error messages from later parts of their impl
* src/qemu/qemu_driver.c: Add missing checks on virDomainIsActive()
---
src/qemu/qemu_driver.c | 38 +++++++++++++++++++++++++++++++++++++-
1 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e97c1d9..f54e41c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4245,6 +4245,12 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find cgroup for domain %s"), vm->def->name);
@@ -4321,6 +4327,12 @@ static int qemuDomainGetBlkioParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if ((*nparams) == 0) {
/* Current number of blkio parameters supported by cgroups */
*nparams = QEMU_NB_BLKIO_PARAM;
@@ -4405,6 +4417,12 @@ static int qemuDomainSetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find cgroup for domain %s"), vm->def->name);
@@ -4508,6 +4526,12 @@ static int qemuDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if ((*nparams) == 0) {
/* Current number of memory parameters supported by cgroups */
*nparams = QEMU_NB_MEM_PARAM;
@@ -4621,6 +4645,12 @@ static int qemuSetSchedulerParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find cgroup for domain %s"), vm->def->name);
@@ -4692,6 +4722,12 @@ static int qemuGetSchedulerParameters(virDomainPtr dom,
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find cgroup for domain %s"), vm->def->name);
@@ -4751,7 +4787,7 @@ qemudDomainBlockStats (virDomainPtr dom,
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
- if (!virDomainObjIsActive (vm)) {
+ if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
--
1.7.4
13 years, 8 months
[libvirt] [PATCH 0/8] pending patch queue
by Eric Blake
All of these have been posted before (sometimes buried as replies in
another thread), but I'm reposting to make it easier to get feedback
in one place. My upcoming fd: migration v5 series was tested with all
of these applied, and while I can probably rebase things to skip any
or all of these patches, it would be nicer to get them in to 0.9.0.
Eric Blake (8):
remote: fix memory leak
qemu: don't restore state label twice
docs: document recent hook additions
tests: don't alter state in $HOME
virsh: optimize creation of default connection
maint: use space, not tab, in remote_protocol-structs
logging: always NUL-terminate circular buffer
build: fix driver module build
docs/hooks.html.in | 23 +-
src/Makefile.am | 13 +-
src/libvirt_private.syms | 20 +
src/libvirt_xenxs.syms | 22 +
src/qemu/qemu_driver.c | 1 +
src/qemu/qemu_process.c | 4 +-
src/remote/remote_driver.c | 120 ++--
src/remote_protocol-structs | 1489 ++++++++++++++++++++++---------------------
src/util/logging.c | 8 +-
tests/Makefile.am | 30 +-
tests/int-overflow | 4 +-
tools/virsh.c | 423 +++++++-----
12 files changed, 1152 insertions(+), 1005 deletions(-)
create mode 100644 src/libvirt_xenxs.syms
--
1.7.4
13 years, 8 months
[libvirt] [PATCH] Update event loop example programs to demonstrate best practice
by Daniel P. Berrange
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
13 years, 8 months
[libvirt] Update on the goal page, patch and discussion
by Daniel Veillard
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/
13 years, 8 months
[libvirt] [Patch v7 1/4] libvirt/qemu - persistent modification of domain.
by KAMEZAWA Hiroyuki
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
13 years, 8 months
[libvirt] [PATCH] qemu: Only restore security label when saving is successfull.
by Osier Yang
"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
13 years, 8 months
[libvirt] [PATCHv5 00/13] outgoing fd: migration and virFileOpenAs
by Eric Blake
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
13 years, 8 months
[libvirt] [PATCH 0/8] Additional functionality for libxl driver
by Markus Groß
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
13 years, 8 months
[libvirt] [PATCH] build: fix compilation on mingw
by Eric Blake
* 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
13 years, 8 months