[libvirt] [PATCH] fix device hotplug
by Guido Günther
Hi,
due to some restructuring we free the device structure so devices are
plugged correctly but "dumpxml" fails since the dev structure is already
freed.
Cheers,
-- Guido
15 years, 11 months
[libvirt] libvirt remote connection failing
by Shanmuga Rajan
hi
I was trying to migrate KVM based vM between two machine.
when i tried to make connection with destination machine but it is not
working for me. i got some error.
i tried the following uri
qemu://192.168.1.22/
qemu://hostname/
everything is failed.
Can any one help me with correct uri to connect with remote machine.
i am using python binding of libvirt.
KVM-79
libvirt 5.0
Thanks and Regards,
- Shan
15 years, 11 months
[libvirt] PATCH: 0/28: Thread safety for libvirtd daemon and drivers
by Daniel P. Berrange
The following huge series of patches adds thread safety for the libvirtd
daemon and drivers, and makes the daemon multi-threaded in processing
RPC calls. This enables multiple clients to be processed in parallel,
without blocking each other. It does not change the thread rules for the
virConnectPtr object though, so each individual client is still serialized.
There are two core places where we have to have synchronization in the
threading model this patch series introduces
- The libvirt daemon code
- A single global server lock (aka struct qemud_server)
- One lock per client connection (aka struct qemud_client)
- The driver implementations
- One lock per driver (aka QEMU, LXC, Test, UML, OpenVZ, Network,
Storage, Node Devices)
- One lock per primary object in a driver (virDomainObjPtr,
virNetworkObjPtr, virStoragePoolObjPtr, virNodeDeviceObjptr
instances)
For most cases, the big global server / driver locks are only held while
obtaining one of the finer grained locks. This gives a fairly good level
of concurrency for operations touching different objects. Once this core
infrastructure is merged, it will be possible to iterate on impl of
drivers to reduce the time locks are held - eg avoid holding a lock while
talking to the QEMU monitor interface.
To try and make it easier to spot thread locking problems this series
refactors alot of methods so that there is only a single return point
where the unlock call can be placed, rather than multiple return point
which increases the chances of missing an unlock call.
This touches a huge amount of code, so I'd like to get this all merged
ASAP as it'll be really hard to keep it synced with ongoing changes.
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 11 months
[libvirt] [PATCH 1/5] write pid file into stateDir
by Guido Günther
Let qemu write out a pid file so we can check in stateDir for running
vm later.
TODO: Fix up the rest of the qemuxml2argvdata testcases, simple search
and replace. I sikpped that for now since it makes rebasing harder.
---
src/libvirt_sym.version.in | 1 +
src/qemu_conf.c | 7 +++++++
src/qemu_conf.h | 1 +
src/qemu_driver.c | 15 +++++++++++++++
src/util.c | 20 ++++++++++++++++----
src/util.h | 2 ++
.../qemuxml2argv-hostdev-usb-address.args | 2 +-
tests/qemuxml2argvtest.c | 2 ++
8 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/src/libvirt_sym.version.in b/src/libvirt_sym.version.in
index de0bc4a..1eff790 100644
--- a/src/libvirt_sym.version.in
+++ b/src/libvirt_sym.version.in
@@ -592,6 +592,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
virFileMakePath;
virFileOpenTty;
virFileReadLimFD;
+ virFilePid;
virFileReadPid;
virFileLinkPointsTo;
virParseNumber;
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index e6c378f..218aefa 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -724,6 +724,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
const char *emulator;
char uuid[VIR_UUID_STRING_BUFLEN];
char domid[50];
+ char *pidfile;
uname(&ut);
@@ -816,6 +817,9 @@ int qemudBuildCommandLine(virConnectPtr conn,
snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024);
snprintf(vcpus, sizeof(vcpus), "%lu", vm->def->vcpus);
snprintf(domid, sizeof(domid), "%d", vm->def->id);
+ pidfile = virFilePid(driver->stateDir, vm->def->name);
+ if (!pidfile)
+ goto error;
ADD_ENV_LIT("LC_ALL=C");
@@ -870,6 +874,9 @@ int qemudBuildCommandLine(virConnectPtr conn,
ADD_ARG_LIT("-monitor");
ADD_ARG_LIT("pty");
+ ADD_ARG_LIT("-pidfile");
+ ADD_ARG(pidfile);
+
if (vm->def->localtime)
ADD_ARG_LIT("-localtime");
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index 36d09d1..ffbd0e7 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -62,6 +62,7 @@ struct qemud_driver {
char *configDir;
char *autostartDir;
char *logDir;
+ char *stateDir;
unsigned int vncTLS : 1;
unsigned int vncTLSx509verify : 1;
char *vncTLSx509certdir;
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index ca96223..a2e573e 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -220,6 +220,10 @@ qemudStartup(void) {
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
goto out_of_memory;
+
+ if (asprintf (&qemu_driver->stateDir,
+ "%s/run/libvirt/qemu/", LOCAL_STATE_DIR) == -1)
+ goto out_of_memory;
} else {
if (!(pw = getpwuid(uid))) {
qemudLog(QEMUD_ERR, _("Failed to find user record for uid '%d': %s\n"),
@@ -233,6 +237,16 @@ qemudStartup(void) {
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1)
goto out_of_memory;
+
+ if (asprintf (&qemu_driver->stateDir,
+ "%s/run/libvirt/qemu/", base) == -1)
+ goto out_of_memory;
+ }
+
+ if (virFileMakePath(qemu_driver->stateDir) < 0) {
+ qemudLog(QEMUD_ERR, _("Failed to create state dir '%s': %s\n"),
+ qemu_driver->stateDir, strerror(errno));
+ goto error;
}
/* Configuration paths are either ~/.libvirt/qemu/... (session) or
@@ -378,6 +392,7 @@ qemudShutdown(void) {
VIR_FREE(qemu_driver->logDir);
VIR_FREE(qemu_driver->configDir);
VIR_FREE(qemu_driver->autostartDir);
+ VIR_FREE(qemu_driver->stateDir);
VIR_FREE(qemu_driver->vncTLSx509certdir);
VIR_FREE(qemu_driver->vncListen);
diff --git a/src/util.c b/src/util.c
index da26009..481f136 100644
--- a/src/util.c
+++ b/src/util.c
@@ -918,6 +918,17 @@ int virFileOpenTty(int *ttymaster ATTRIBUTE_UNUSED,
#endif
+char* virFilePid(const char *dir, const char* name)
+{
+ char* pidfile;
+
+ if (asprintf(&pidfile, "%s/%s.pid", dir, name) < 0) {
+ pidfile = NULL;
+ }
+ return pidfile;
+}
+
+
int virFileWritePid(const char *dir,
const char *name,
pid_t pid)
@@ -930,7 +941,7 @@ int virFileWritePid(const char *dir,
if ((rc = virFileMakePath(dir)))
goto cleanup;
- if (asprintf(&pidfile, "%s/%s.pid", dir, name) < 0) {
+ if (!(pidfile = virFilePid(dir, name))) {
rc = ENOMEM;
goto cleanup;
}
@@ -973,7 +984,8 @@ int virFileReadPid(const char *dir,
FILE *file;
char *pidfile = NULL;
*pid = 0;
- if (asprintf(&pidfile, "%s/%s.pid", dir, name) < 0) {
+
+ if (!(pidfile = virFilePid(dir, name))) {
rc = ENOMEM;
goto cleanup;
}
@@ -1006,8 +1018,8 @@ int virFileDeletePid(const char *dir,
int rc = 0;
char *pidfile = NULL;
- if (asprintf(&pidfile, "%s/%s.pid", dir, name) < 0) {
- rc = errno;
+ if (!(pidfile = virFilePid(dir, name))) {
+ rc = ENOMEM;
goto cleanup;
}
diff --git a/src/util.h b/src/util.h
index 0748cbf..58488ae 100644
--- a/src/util.h
+++ b/src/util.h
@@ -79,6 +79,8 @@ int virFileOpenTty(int *ttymaster,
char **ttyName,
int rawmode);
+char* virFilePid(const char *dir,
+ const char *name);
int virFileWritePid(const char *dir,
const char *name,
pid_t pid);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
index 3d6c16d..e1c5638 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:014.006
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /tmp/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:014.006
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 6e5355a..585eb08 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -156,6 +156,8 @@ mymain(int argc, char **argv)
if ((driver.caps = testQemuCapsInit()) == NULL)
return EXIT_FAILURE;
+ if((driver.stateDir = strdup("/tmp")) == NULL)
+ return EXIT_FAILURE;
#define DO_TEST(name, extraFlags) \
do { \
--
1.6.0.2
15 years, 11 months
[libvirt] how to connect LXC via libvirt
by Ian jonhson
Hi Daniel,
I followed the instructions in:
https://lists.linux-foundation.org/pipermail/containers/2008-September/01...
to try to connect with LXC which is built in my VM (ubuntu7.10 +
kernel 2.6.27-rc8).
Unfortunately, I fail.
The container can work when I use its user-space interfaces, however I can not
execute the "virsh --connect lxc:/// define mycontainer.xml" after I have
installed the libvirt (downloaded from CVS). I checked the libvirt.c
and found there
are only the "xen:///" support, not any codes to support LXC.
Therefore, I am wondering whether LXC has been supported in libvirt mainstream
and what should I do to get the result as your statement in maillist.
Thanks,
Ian
15 years, 11 months
[libvirt] [PATCH] Fix compiler warnings in test code
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID 1b81ac255ad765ab782829e7fe0a55dc7bab72ab
# Parent ee6ccfc062f49f514d7ae8924d5a596b18441fee
Fix compiler warnings in test code
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/test.c b/src/test.c
--- a/src/test.c
+++ b/src/test.c
@@ -1299,7 +1299,7 @@ static unsigned long testGetMaxMemory(vi
static unsigned long testGetMaxMemory(virDomainPtr domain) {
testConnPtr privconn = domain->conn->privateData;
virDomainObjPtr privdom;
- unsigned long ret = -1;
+ unsigned long ret = (unsigned long)-1;
testDriverLock(privconn);
privdom = virDomainFindByName(&privconn->domains,
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -9,6 +9,16 @@
#include "internal.h"
#include "nodeinfo.h"
#include "util.h"
+
+#ifndef __linux__
+
+static int
+mymain(int argc, char **argv)
+{
+ exit (77); /* means 'test skipped' for automake */
+}
+
+#else
static char *progname;
static char *abs_srcdir;
@@ -78,9 +88,6 @@ mymain(int argc, char **argv)
"nodeinfo-6",
};
char cwd[PATH_MAX];
-#ifndef __linux__
- exit (77); /* means 'test skipped' for automake */
-#endif
abs_srcdir = getenv("abs_srcdir");
if (!abs_srcdir)
@@ -102,4 +109,7 @@ mymain(int argc, char **argv)
return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
+#endif /* __linux__ */
+
VIRT_TEST_MAIN(mymain)
+
15 years, 11 months
[libvirt] [PATCH] Fix GCC hard-coding in python/
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229399267 28800
# Node ID b105e5a7cd6190e0b952a1587d7e80f39d02e63c
# Parent 35512df785342cd15214790e17e0c1f4d2182b32
Fix GCC hard-coding in python/
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/acinclude.m4 b/acinclude.m4
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -75,6 +75,11 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
WARN_CFLAGS="$COMPILER_FLAGS $complCFLAGS"
AC_SUBST(WARN_CFLAGS)
+
+ COMPILER_FLAGS=
+ gl_COMPILER_FLAGS(-Wno-redundant-decls)
+ NO_RDECLS_CFLAGS=$COMPILER_FLAGS
+ AC_SUBST(NO_RDECLS_CFLAGS)
])
diff --git a/python/Makefile.am b/python/Makefile.am
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -35,7 +35,7 @@ python_LTLIBRARIES = libvirtmod.la
libvirtmod_la_SOURCES = libvir.c types.c libvirt-py.c libvirt-py.h
# Python header files contain a redundant decl, hence:
-libvirtmod_la_CFLAGS = -Wno-redundant-decls
+libvirtmod_la_CFLAGS = @NO_RDECLS_CFLAGS@
libvirtmod_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs \
@CYGWIN_EXTRA_LDFLAGS@
15 years, 11 months
Re: [libvirt] PATCH 0/5: connection cloning support (WIP)
by David Lively
Hi Daniel -
When I apply these patches, I'm seeing segfaults on event delivery
when just running the existing synchronous
examples/domain-events/events-c/event-test.c (using the remote driver).
I've added a little debug. Apparently event->name is being NULLed out
sometime after the event is put on the queue:
DEBUG: remote_internal.c: remoteDomainEventFired (Event fired 0 3 1 1)
DEBUG: remote_internal.c: processCallRecv (Do 4 0)
DEBUG: remote_internal.c: processCallRecvLen (Got length, now need 64 total (60 more))
DEBUG: remote_internal.c: processCallRecv (Do 64 4)
DEBUG: remote_internal.c: processCallAsyncEvent (Encountered an event while waiting for a response)
DEBUG: remote_internal.c: get_nonnull_domain (domain.name: dsl)
DEBUG: datatypes.c: virGetDomain (New hash entry 0x804c728)
DEBUG: domain_event.c: virDomainEventNew (event: 0x804c770 ->name: dsl)
DEBUG: libvirt.c: virDomainFree (domain=0x804c728)
DEBUG: datatypes.c: virUnrefDomain (unref domain 0x804c728 dsl 1)
DEBUG: datatypes.c: virReleaseDomain (release domain 0x804c728 dsl)
DEBUG: datatypes.c: virReleaseDomain (unref connection 0x804b040 4)
DEBUG: domain_event.c: virDomainEventQueuePush (event: 0x804c770 ->name: dsl)
DEBUG: remote_internal.c: processCallRecv (Do 0 0)
DEBUG: remote_internal.c: remoteDomainEventQueueFlush ()
DEBUG: domain_event.c: virDomainEventDispatchDefaultFunc (event: 0x804c770 ->name: (null))
virGetDomain: name is NULL
Segmentation fault
I'll continue looking into it. But please let me know if you're
familiar with the problem ...
Thanks,
Dave
On Tue, 2008-12-16 at 10:24 -0500, David Lively wrote:
> Hi Daniels -
> Sorry for the delay. Life's been crazy. But now I'm finally looking
> into using this series of patches with my Java event implementation
> (which I've now redone via the java.nio.Select mechanism; ready to
> submit pending resolution of the RPC concurrency issues). I should have
> some feedback for you later today ...
>
> Thanks,
> Dave
>
> On Tue, 2008-12-09 at 12:08 +0000, Daniel P. Berrange wrote:
> > This series is a work-in-progress set of patches implementing connection
> > cloning. The idea is that if you want to use a connection form multiple
> > threads, you could do
> >
> > virConnectPtr copy = virConnectClone(conn)
> >
> > and use 'copy' from the other thread. This avoids the problem of having
> > to make all the virError handling stuff thread-local whic is the blocker
> > for allowing real mutlti-thread access to a single virConnectPtr object.
> >
> > I believe this cloning support should be sufficient for the Java bindings
> > need to use a thread for its event loop. The idea being that if you wanted
> > to use an event loop in a background thread, you'd create a cloned object
> > for use event loop triggered callbacks like domain events notifications.
> >
> > I'd still like to do some experiments later making the single virConnectPtr
> > fully thread safe, but that'll take a little more time. I'm hoping this
> > cloning will address the Java needs right now...
> >
> > Daniel
15 years, 11 months