[libvirt] [PATCH] fix non-srcdir build failure
by Jim Meyering
"make distcheck" was failing.
This fixes it and adds some quotes.
>From 8b6f9ff168dd0ce7318f1947a7766a4b223acdd4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 8 Jan 2009 20:53:30 +0100
Subject: [PATCH] fix non-srcdir build failure
* qemud/Makefile.am (check-local): Prefix use of test_libvirtd.aug
with $(srcdir)/. Add quotes around $(AUGPARSE), in case it expands
to something unusual.
---
qemud/Makefile.am | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
index 8983416..ad4ccf1 100644
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -239,7 +239,8 @@ libvirtd.init: libvirtd.init.in
mv $@-t $@
check-local:
- if [ -x $(AUGPARSE) ]; then $(AUGPARSE) -I $(srcdir) test_libvirtd.aug ; fi
+ test -x '$(AUGPARSE)' \
+ && '$(AUGPARSE)' -I $(srcdir) $(srcdir)/test_libvirtd.aug || :
else
--
1.6.1.141.gfe98e
15 years, 10 months
[libvirt] [PATCH 5/5] read saved vm status on libvirtd startup
by Guido Günther
The earlier patches didn't change libvirtd behaviour (except for
kvm/qemu not being teared down on an unexpected daemon crash), all vms
were still being shutoff at daemon shutdown. This patch now adds the
code to read back the vm status after on daemon startup and reconnects
all running vms found in stateDir which are left over from a daemon
restart or crash and also disables shutting down of VMs when libvirt
quits.
---
src/qemu_driver.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 158 insertions(+), 7 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index d8b87e4..57a396c 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -183,6 +183,46 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
}
+static int
+qemudGetProcFD(pid_t pid, int fdnum)
+{
+ int fd;
+
+#ifdef __linux__
+ char *path = NULL;
+
+ if (!asprintf(&path, "/proc/%d/fd/%d", pid, fdnum)) {
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, NULL);
+ return -1;
+ }
+
+ if((fd = open(path, O_RDONLY)) < 0) {
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to open %s"), path);
+ return -1;
+ }
+ if (qemudSetCloseExec(fd) < 0) {
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to set close-on-exec flag on %s"), path);
+ goto error;
+ }
+
+ if (qemudSetNonBlock(fd) < 0) {
+ qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Unable to put %s into non-blocking mode"), path);
+ goto error;
+ }
+
+ VIR_FREE(path);
+ return fd;
+error:
+ VIR_FREE(path);
+ close(fd);
+#endif
+ return -1;
+}
+
+
/**
* qemudRemoveDomainStatus
*
@@ -220,6 +260,104 @@ cleanup:
}
+static int qemudOpenMonitor(virConnectPtr conn,
+ virDomainObjPtr vm,
+ const char *monitor,
+ int reconnect);
+
+/**
+ * qemudReconnectVMs
+ *
+ * Reconnect running vms to the daemon process
+ */
+static int
+qemudReconnectVMs(struct qemud_driver *driver)
+{
+ int i;
+
+ for (i = 0 ; i < qemu_driver->domains.count ; i++) {
+ virDomainObjPtr vm = qemu_driver->domains.objs[i];
+ qemudDomainStatusPtr status = NULL;
+ char *config = NULL;
+ int rc;
+
+ virDomainObjLock(vm);
+ /* Read pid */
+ if ((rc = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) == 0)
+ DEBUG("Found pid %d for '%s'", vm->pid, vm->def->name);
+ else
+ goto next;
+
+ if ((config = virDomainConfigFile(NULL,
+ driver->stateDir,
+ vm->def->name)) == NULL) {
+ qemudLog(QEMUD_ERR, _("Failed to read domain status for %s\n"),
+ vm->def->name);
+ goto next_error;
+ }
+
+ status = qemudDomainStatusParseFile(NULL, driver->caps, config, 0);
+ if (status) {
+ vm->newDef = vm->def;
+ vm->def = status->def;
+ } else {
+ qemudLog(QEMUD_ERR, _("Failed to parse domain status for %s\n"),
+ vm->def->name);
+ goto next_error;
+ }
+
+ if ((rc = qemudOpenMonitor(NULL, vm, status->monitorpath, 1)) != 0) {
+ qemudLog(QEMUD_ERR, _("Failed to reconnect monitor for %s: %d\n"),
+ vm->def->name, rc);
+ goto next_error;
+ } else
+ vm->monitorpath = status->monitorpath;
+
+ vm->stdin_fd = qemudGetProcFD(vm->pid, 0);
+ vm->stdout_fd = qemudGetProcFD(vm->pid, 1);
+ vm->stderr_fd = qemudGetProcFD(vm->pid, 2);
+ if (vm->stdin_fd == -1 || vm->stdout_fd == -1 || vm->stderr_fd == -1)
+ goto next_error;
+
+ if (((vm->stdout_watch = virEventAddHandle(vm->stdout_fd,
+ VIR_EVENT_HANDLE_READABLE |
+ VIR_EVENT_HANDLE_ERROR |
+ VIR_EVENT_HANDLE_HANGUP,
+ qemudDispatchVMEvent,
+ driver, NULL)) < 0) ||
+ ((vm->stderr_watch = virEventAddHandle(vm->stderr_fd,
+ VIR_EVENT_HANDLE_READABLE |
+ VIR_EVENT_HANDLE_ERROR |
+ VIR_EVENT_HANDLE_HANGUP,
+ qemudDispatchVMEvent,
+ driver, NULL)) < 0)) {
+
+ qemudLog(QEMUD_ERR, _("Failed to reconnect to stdout/stderr\n"));
+ goto next_error;
+ }
+
+ if (vm->def->id >= driver->nextvmid)
+ driver->nextvmid = vm->def->id + 1;
+
+ vm->state = status->state;
+ goto next;
+
+next_error:
+ /* we failed to reconnect the vm so remove it's traces */
+ vm->def->id = -1;
+ qemudRemoveDomainStatus(NULL, driver, vm);
+ virDomainDefFree(vm->def);
+ vm->def = vm->newDef;
+ vm->newDef = NULL;
+next:
+ virDomainObjUnlock(vm);
+ VIR_FREE(status);
+ VIR_FREE(config);
+ }
+ return 0;
+}
+
+
/**
* qemudStartup:
*
@@ -316,6 +454,7 @@ qemudStartup(void) {
qemu_driver->autostartDir,
NULL, NULL) < 0)
goto error;
+ qemudReconnectVMs(qemu_driver);
qemudAutostartConfigs(qemu_driver);
qemuDriverUnlock(qemu_driver);
@@ -418,11 +557,14 @@ qemudShutdown(void) {
/* shutdown active VMs */
for (i = 0 ; i < qemu_driver->domains.count ; i++) {
+ /* FIXME: don't shutdown VMs on daemon shutdown for now */
+#if 0
virDomainObjPtr dom = qemu_driver->domains.objs[i];
virDomainObjLock(dom);
if (virDomainIsActive(dom))
qemudShutdownVMDaemon(NULL, qemu_driver, dom);
virDomainObjUnlock(dom);
+#endif
}
virDomainObjListFree(&qemu_driver->domains);
@@ -543,7 +685,8 @@ qemudCheckMonitorPrompt(virConnectPtr conn ATTRIBUTE_UNUSED,
static int qemudOpenMonitor(virConnectPtr conn,
virDomainObjPtr vm,
- const char *monitor) {
+ const char *monitor,
+ int reconnect) {
int monfd;
char buf[1024];
int ret = -1;
@@ -564,11 +707,19 @@ static int qemudOpenMonitor(virConnectPtr conn,
goto error;
}
- ret = qemudReadMonitorOutput(conn,
- vm, monfd,
- buf, sizeof(buf),
- qemudCheckMonitorPrompt,
- "monitor", 10000);
+ if (!reconnect) {
+ ret = qemudReadMonitorOutput(conn,
+ vm, monfd,
+ buf, sizeof(buf),
+ qemudCheckMonitorPrompt,
+ "monitor", 10000);
+ } else {
+ vm->monitor = monfd;
+ ret = 0;
+ }
+
+ if (ret != 0)
+ goto error;
if (!(vm->monitorpath = strdup(monitor))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
@@ -669,7 +820,7 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
}
/* Got them all, so now open the monitor console */
- ret = qemudOpenMonitor(conn, vm, monitor);
+ ret = qemudOpenMonitor(conn, vm, monitor, 0);
cleanup:
VIR_FREE(monitor);
--
1.6.0.2
15 years, 10 months
[libvirt] [PATCH] PCI passthrough docs, tests and minor change
by Daniel Veillard
The following add the documentation for the PCI passthrough,
extends the RNG and add an extra test for the QEmu parsing to
args and serialization back to XML.
I also noticed that we parse (and save) and extra PCI domain
argument, but it's not actually used when calling qemu, so I
assume it's a missing feature for QEmu and just decided to patch
the code to not save the extra value when not defined (i.e. 0).
Whether it should just be removed at this point is IMHO a separate
decision, which is why I took the way with minimal changes. Note
that the domain attribute is not documented nor part or the RNG
either at this point.
Daniel
--
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/
15 years, 10 months
[libvirt] text console install
by Michael Kress
Hi, I'm not able to get a text console install of any distribution
(CentOS-5.2 for example).
I'm using the following command:
virt-install -n myname -f myimage.img -s 10 -c
/iso/CentOS-5.2-x86_64-bin-DVD.iso --accelerate -r 1024 --hvm --nographics
The vnc version of this command works flawlessly, but I'd like this host
to be a headless one.
The installation seems to start as I can see the instance with state
"running" with the following command:
virsh -c qemu:///system list
But all I see is the following messages:
========================
Starting install...
Creating domain...
Connecting to uri: qemu:///system
========================
After a while there's one strange character showing up in the console.
Pressing Ctrl-Alt Gr-] I can exit the screen and there's a message:
========================
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
========================
BTW, I got the following line in /etc/libvirt/qemu.conf
vnc_listen="192.168.2.3"
But also tried without that line.
How can I get the text console to show up?
Thanks
Michael
--
Michael Kress, kress(a)hal.saar.de
http://www.michael-kress.de / http://kress.net
P E N G U I N S A R E C O O L
15 years, 10 months
[libvirt] Question, new libvirt driver - OpenNebula.
by "Abel Míguez Rodríguez"
Hello all,
We have updated the libvirt implementation
for OpenNebula to libvirt- 0.5.1 release, made use of the internal XML
handling API and the existing infrastructure for error, data
structures, etc...
Now we are facing the problem of needing
several libraries to compile the driver, the OpenNebula API
(liboneapi) and the xmlrpc library that the API makes use of.
The problem is that the xmlrpc library itself depends on: libxmlrpc_client++ libxmlrpc_client libxmlrpc++ libxmlrpc libxmlrpc_util libxmlrpc_xmlparse libxmlrpc_xmltok
We would like to link just against less libraries to make the driver compilation clear and simple, any idea?
Cheers
Abel
15 years, 10 months
[libvirt] interface.script not launched (KVM/qemu)
by Daniel Schwager
Hi,
I use kvm and libvirt for running windows on a fedora-core9.
Problem: I defined a interface script which should run, if the KVM/qemu
starts, but libvirt does not tell kvm to use the script:
Part of my domain.xml:
<interface type="bridge">
<source bridge="br-guest"/>
<script path='bridge-kvm.sh'/>
<model type='e1000'/>
</interface>
Part of the logfile of qemu in /var/log/libvirt/qemu
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /
/usr/bin/qemu-kvm \
-S -M pc -m 250 -smp 1 -name winxp100 -monitor pty -boot
c \
-drive file=/tmp/winxp100,if=ide,index=0,boot=on \
-net nic,macaddr=52:54:00:79:d5:c9,vlan=0,model=e1000 \
-net tap,fd=14,script=,vlan=0,ifname=vnet0 \
-serial pty -parallel none -usb -usbdevice tablet -vnc
0.0.0.0:0
There, you can see the empty script directive "...,script=,...."
root@kvm ~]$ rpm -qa | grep libvirt
libvirt-0.5.1-2.fc9.x86_64
How can I fix this problem ?
regards
Danny
15 years, 10 months
[libvirt] [PATCH] split out logfile opening
by Guido Günther
Hi,
attached patch splits out the qemu logfile opening into a separate
function which makes the code a bit more readable and I'll need this for
the libvirtd restart code.
Cheers,
-- Guido
15 years, 10 months
[libvirt] Libvirt - Xen Enterprise - Koan
by Gerhardus.Geldenhuis@gta-travel.com
Hi
I hope me "replying" this way does not break anyone's mail sorting, I
only now subscribed to the list.
> Thanks for this - this sounds like the most likely issue. The problem
is
> that Citrix seems to move things around somewhat as that config file
> does not exist. There is a xensource directory that contains the
> following but other than that i am a bit stuck.
They might have overriden the config file to point somewhere else.
Try and find the file "XendOptions.py" and see where it loads the
config from. Or see if anything sets $XEND_CONFIG env variable at
startup. In regular upstream xen code, it XendOptions.py has:
class XendOptionsFile(XendOptions):
"""Default path to the config file."""
config_default = "/etc/xen/xend-config.sxp"
I did a find . -name *.py > temp.gg
and then
141 cat temp.gg | xargs grep -i xendoptions
142 cat temp.gg | xargs grep -i xend
144 cat temp.gg | xargs grep -i XEND_CONFIG
148 cat temp.gg | xargs grep -i config_default
All of these searches gave me absolutely no results.
I am sure that the config files are in :
/etc/xensource/
xapi.conf
xapi-ssl.conf
the contents of xapi.conf is:
schema_filename = /etc/xensource/db_schema.sql
license_filename = /etc/xensource/license
http-port = 80
use-ssl = true
ssl-cert = /etc/ssl/certs/xensource-rio.pem
ssl-port = 443
# dom0-mem = 128
and of xapi-ssl.conf is:
pid = /var/run/xapi.ssl.pid
socket = r:TCP_NODELAY=1
socket = a:TCP_NODELAY=1
socket = l:TCP_NODELAY=1
[xapi]
accept = 443
connect = 80
cert = /etc/xensource/xapi-ssl.pem
I am thinking that maybe only ssl connections are allowed ... which is
why virsh can't connect?
we are running "XenServer release 4.1.0-7843p (xenenterprise)" and I am
trying to get spacewalk to get the necessary domain details when
registering a xen host.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
15 years, 10 months
[libvirt] [PATCH] Fix non-debug compile
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1230005985 28800
# Node ID 60090fd4e447795742265241b39f2759d9530514
# Parent d7c3bd669a72371127852aefb3ba2cc0443da8da
Fix non-debug compile
Remove duplicate defines, and stub out virLogMessage() for non-debug
builds.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/logging.h b/src/logging.h
--- a/src/logging.h
+++ b/src/logging.h
@@ -47,12 +47,6 @@
do { } while (0)
#define VIR_ERROR(category, f, l, fmt,...) \
do { } while (0)
-#define VIR_INFO(category, fmt,...) \
- do { } while (0)
-#define VIR_WARN(category, fmt,...) \
- do { } while (0)
-#define VIR_ERROR(category, fmt,...) \
- do { } while (0)
#endif /* !ENABLE_DEBUG */
#define DEBUG(fmt,...) \
@@ -82,6 +76,8 @@ typedef enum {
VIR_LOG_WARN,
VIR_LOG_ERROR,
} virLogPriority;
+
+#ifdef ENABLE_DEBUG
/**
* virLogOutputFunc:
@@ -114,10 +110,6 @@ extern int virLogDefineOutput(virLogOutp
extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c,
void *data, int priority, int flags);
-#if 0
-extern char *virLogGetDump(int flags);
-#endif
-
/*
* Internal logging API
*/
@@ -127,8 +119,23 @@ extern void virLogShutdown(void);
extern void virLogShutdown(void);
extern int virLogParseFilters(const char *filters);
extern int virLogParseOutputs(const char *output);
+
extern void virLogMessage(const char *category, int priority,
const char *funcname, long long linenr, int flags,
const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 6, 7);
+#else /* ENABLE_DEBUG */
+
+#define virLogSetDefaultPriority(p)
+#define virLogDefineFilter(m, p, f)
+#define virLogDefineOutput(func, c, d, p, f)
+#define virLogStartup()
+#define virLogReset()
+#define virLogShutdown()
+#define virLogParseFilters(f)
+#define virLogParseOutputs(o)
+#define virLogMessage(c, p, func, l, f, fmt, __VA_ARGS__)
+
+#endif /* ENABLE_DEBUG */
+
#endif
15 years, 10 months
[libvirt] [PATCH] Fix Solaris compile after gnulib refresh
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1231444798 28800
# Node ID bf47245a1fecebe59ef30371a4465d713d37af06
# Parent b0dbefc87cb8b0194ad2bd518c2e8261b6bb0a6c
Fix Solaris compile after gnulib refresh
As documented in NEWS, we now need to explicitly specify usage of
libsocket.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -79,9 +79,9 @@ AC_CHECK_HEADERS([pwd.h paths.h regex.h
dnl Where are the XDR functions?
dnl If portablexdr is installed, prefer that.
-dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW) or none (most Unix)
+dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), nsl (Solaris) or none (most Unix)
AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
- AC_SEARCH_LIBS([xdrmem_create],[rpc xdr])
+ AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
])
AC_CHECK_LIB([intl],[gettext],[])
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -248,7 +248,7 @@ endif # DBUS_INIT_SCRIPTS_RED_HAT
# This must be added last, since functions it provides/replaces
# are used by nearly every other library.
-libvirtd_LDADD += ../gnulib/lib/libgnu.la
+libvirtd_LDADD += ../gnulib/lib/libgnu.la $(LIBSOCKET)
endif # WITH_LIBVIRTD
diff --git a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -33,6 +33,7 @@ LDADDS = \
$(WARN_CFLAGS) \
../src/libvirt_test.la \
../gnulib/lib/libgnu.la \
+ $(LIBSOCKET) \
$(COVERAGE_LDFLAGS)
EXTRA_DIST = \
15 years, 10 months