[libvirt] [PATCH] Make the use of XDG folders variable
by Martin Kletzander
While ago, commit 32a9aac2e04c991340b66c855a1095e4e6445e54 introduced
a change of the folders used to keep information in user home
directories. As this can still cause problems, mainly with older
SELinux policies, make this change variable with new configuration
option '--disable-xdg'.
---
Sorry for not splitting this patch, but either having the option and
not making it work or the other way around is pretty bad (and having
it in repo as a commit even worse).
configure.ac | 14 +++++++
daemon/Makefile.am | 2 +
daemon/libvirtd-config.c | 11 ++++++
daemon/libvirtd.c | 84 +++++++++++++++++++++++++++++++++++++-----
daemon/libvirtd.pod.in | 6 +--
libvirt.spec.in | 11 ++++++
src/libvirt.c | 19 ++++++++--
src/network/bridge_driver.c | 22 ++++++++++-
src/nwfilter/nwfilter_driver.c | 15 +++++++-
src/qemu/qemu_driver.c | 55 ++++++++++++++++++---------
src/remote/remote_driver.c | 15 +++++++-
src/secret/secret_driver.c | 13 +++++++
src/uml/uml_driver.c | 14 +++++++
src/util/virauth.c | 8 ++++
tools/virsh.c | 13 +++++++
15 files changed, 263 insertions(+), 39 deletions(-)
diff --git a/configure.ac b/configure.ac
index ee51bb6..cacdefe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2545,6 +2545,20 @@ if test "$enable_locking" = "yes"; then
fi
AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"])
+dnl --enable-xdg=(yes|no)
+AC_ARG_ENABLE([xdg],
+ [AC_HELP_STRING([--disable-xdg],
+ [disable using XDG folders])],
+ [], [enable_xdg=yes])
+if test x"$enable_xdg" = x"yes"; then
+ AC_DEFINE([ENABLE_XDG], [], [whether to use XDG folders])
+ AC_SUBST([userconfdir], [[XDG_CONFIG_DIR/libvirt]])
+ AC_SUBST([userrundir], [[XDG_RUNTIME_DIR/libvirt]])
+else
+ AC_SUBST([userconfdir], [[HOME/.libvirt]])
+ AC_SUBST([userrundir], [HOME/.libvirt])
+fi
+
dnl Enable building libvirtd?
AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 3405c67..1b9ad7c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -87,6 +87,8 @@ libvirtd.8: $(srcdir)/libvirtd.8.in
sed \
-e 's!SYSCONFDIR!$(sysconfdir)!g' \
-e 's!LOCALSTATEDIR!$(localstatedir)!g' \
+ -e 's!USERCONFDIR!$(userconfdir)!g' \
+ -e 's!USERRUNDIR!$(userrundir)!g' \
< $< > $@-t
mv $@-t $@
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index d9dfea1..227147d 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -203,6 +203,7 @@ daemonConfigFilePath(bool privileged, char **configfile)
} else {
char *configdir = NULL;
+#ifdef ENABLE_XDG
if (!(configdir = virGetUserConfigDirectory()))
goto error;
@@ -210,6 +211,16 @@ daemonConfigFilePath(bool privileged, char **configfile)
VIR_FREE(configdir);
goto no_memory;
}
+#else
+ if (!(configdir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(configfile, "%s/.libvirt/libvirtd.conf", configdir) < 0) {
+ VIR_FREE(configdir);
+ goto no_memory;
+ }
+#endif
+
VIR_FREE(configdir);
}
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b49acc5..c87039e 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -245,6 +245,8 @@ daemonPidFilePath(bool privileged,
goto no_memory;
} else {
char *rundir = NULL;
+
+#ifdef ENABLE_XDG
mode_t old_umask;
if (!(rundir = virGetUserRuntimeDirectory()))
@@ -261,6 +263,15 @@ daemonPidFilePath(bool privileged,
VIR_FREE(rundir);
goto no_memory;
}
+#else
+ if (!(rundir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(pidfile, "%s/.libvirt/libvirtd.pid", rundir) < 0) {
+ VIR_FREE(rundir);
+ goto no_memory;
+ }
+#endif
VIR_FREE(rundir);
}
@@ -293,8 +304,9 @@ daemonUnixSocketPaths(struct daemonConfig *config,
goto no_memory;
} else {
char *rundir = NULL;
- mode_t old_umask;
+#ifdef ENABLE_XDG
+ mode_t old_umask;
if (!(rundir = virGetUserRuntimeDirectory()))
goto error;
@@ -309,6 +321,15 @@ daemonUnixSocketPaths(struct daemonConfig *config,
VIR_FREE(rundir);
goto no_memory;
}
+#else
+ if (!(rundir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(sockfile, "@%s/.libvirt/libvirt-sock", rundir) < 0) {
+ VIR_FREE(rundir);
+ goto no_memory;
+ }
+#endif
VIR_FREE(rundir);
}
@@ -663,10 +684,12 @@ daemonSetupLogging(struct daemonConfig *config,
LOCALSTATEDIR) == -1)
goto no_memory;
} else {
- char *logdir = virGetUserCacheDirectory();
+ char *logdir = NULL;
+
+#ifdef ENABLE_XDG
mode_t old_umask;
- if (!logdir)
+ if (!(logdir = virGetUserCacheDirectory()))
goto error;
old_umask = umask(077);
@@ -681,6 +704,17 @@ daemonSetupLogging(struct daemonConfig *config,
VIR_FREE(logdir);
goto no_memory;
}
+#else
+ if (!(logdir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(&tmp, "%d:file:%s/.libvirt/libvirtd.log",
+ virLogGetDefaultPriority(), logdir) == -1) {
+ VIR_FREE(logdir);
+ goto no_memory;
+ }
+#endif
+
VIR_FREE(logdir);
}
} else {
@@ -801,6 +835,7 @@ static int daemonStateInit(virNetServerPtr srv)
return 0;
}
+#ifdef ENABLE_XDG
static int migrateProfile(void)
{
char *old_base = NULL;
@@ -876,6 +911,7 @@ static int migrateProfile(void)
return ret;
}
+#endif
/* Print command-line usage. */
static void
@@ -926,14 +962,14 @@ libvirt management daemon:\n"), argv0);
LOCALSTATEDIR);
} else {
fprintf(stderr,
- "%s", _("\n\
+ _("\n\
Default paths:\n\
\n\
Configuration file (unless overridden by -f):\n\
- $XDG_CONFIG_HOME/libvirt/libvirtd.conf\n\
+ %s/libvirtd.conf\n\
\n\
Sockets:\n\
- $XDG_RUNTIME_DIR/libvirt/libvirt-sock (in UNIX abstract namespace)\n\
+ %s/libvirt-sock (in UNIX abstract namespace)\n \
\n\
TLS:\n\
CA certificate: $HOME/.pki/libvirt/cacert.pem\n\
@@ -941,8 +977,18 @@ libvirt management daemon:\n"), argv0);
Server private key: $HOME/.pki/libvirt/serverkey.pem\n\
\n\
PID file:\n\
- $XDG_RUNTIME_DIR/libvirt/libvirtd.pid\n\
-\n"));
+ %s/libvirtd.pid\n \
+\n"),
+#ifdef ENABLE_XDG
+ "$XDG_CONFIG_HOME/libvirt",
+ "$XDG_RUNTIME_DIR/libvirt",
+ "$XDG_RUNTIME_DIR/libvirt"
+#else
+ "$HOME/.libvirt",
+ "$HOME/.libvirt",
+ "$HOME/.libvirt"
+#endif
+ );
}
}
@@ -1115,11 +1161,13 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+#ifdef ENABLE_XDG
if (!privileged &&
migrateProfile() < 0) {
VIR_ERROR(_("Exiting due to failure to migrate profile"));
exit(EXIT_FAILURE);
}
+#endif
if (config->host_uuid &&
virSetHostUUIDStr(config->host_uuid) < 0) {
@@ -1170,22 +1218,38 @@ int main(int argc, char **argv) {
if (privileged) {
run_dir = strdup(LOCALSTATEDIR "/run/libvirt");
} else {
+#ifdef ENABLE_XDG
run_dir = virGetUserRuntimeDirectory();
if (!run_dir) {
VIR_ERROR(_("Can't determine user directory"));
goto cleanup;
}
+#else
+ char *user_dir = virGetUserDirectory();
+
+ if (!user_dir) {
+ VIR_ERROR(_("Can't determine user directory"));
+ goto cleanup;
+ }
+ ignore_value(virAsprintf(&run_dir, "%s/.libvirt/", user_dir));
+ VIR_FREE(user_dir);
+#endif
}
if (!run_dir) {
virReportOOMError();
goto cleanup;
}
- if (privileged)
+ if (privileged) {
old_umask = umask(022);
- else
+ } else {
+#ifdef ENABLE_XDG
old_umask = umask(077);
+#else
+ old_umask = umask(022);
+#endif
+ }
VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
if (virFileMakePath(run_dir) < 0) {
char ebuf[1024];
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 930b752..82cb14f 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -112,12 +112,12 @@ The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
=over
-=item F<$XDG_CONFIG_HOME/libvirtd.conf>
+=item F<$USERCONFDIR/libvirtd.conf>
The default configuration file used by libvirtd, unless overridden on the
command line using the B<-f>|B<--config> option.
-=item F<$XDG_RUNTIME_DIR/libvirt/libvirt-sock>
+=item F<$USERRUNDIR/libvirt-sock>
The socket libvirtd will use.
@@ -133,7 +133,7 @@ The TLS B<Server> certificate libvirtd will use.
The TLS B<Server> private key libvirtd will use.
-=item F<$XDG_RUNTIME_DIR/libvirt/libvirtd.pid>
+=item F<$USERRUNDIR/libvirtd.pid>
The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 318fe92..0ec7e03 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -305,6 +305,12 @@
%endif
+# Don't change user directories in older RHELs
+%if 0%{?rhel} <= 6
+%define
+%endif
+
+
# The RHEL-5 Xen package has some feature backports. This
# flag is set to enable use of those special bits on RHEL-5
%if 0%{?rhel} == 5
@@ -1210,6 +1216,10 @@ of recent versions of Linux (and other OSes).
%define _with_firewalld --with-firewalld
%endif
+%if %{disable_xdg}
+%define _disable_xdg --enable-xdg=no
+%endif
+
%define when %(date +"%%F-%%T")
%define where %(hostname)
%define who %{?packager}%{!?packager:Unknown}
@@ -1278,6 +1288,7 @@ autoreconf -if
%{?_without_dtrace} \
%{?_without_driver_modules} \
%{?_with_firewalld} \
+ %{?_disable_xdg} \
%{with_packager} \
%{with_packager_version} \
--with-qemu-user=%{qemu_user} \
diff --git a/src/libvirt.c b/src/libvirt.c
index 76e4401..4a15808 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -922,15 +922,26 @@ virConnectGetConfigFilePath(void)
SYSCONFDIR) < 0)
goto no_memory;
} else {
- char *userdir = virGetUserConfigDirectory();
- if (!userdir)
+ char *userdir = NULL;
+
+#ifdef ENABLE_XDG
+ if (!(userdir = virGetUserConfigDirectory()))
goto error;
- if (virAsprintf(&path, "%s/libvirt.conf",
- userdir) < 0) {
+ if (virAsprintf(&path, "%s/libvirt.conf", userdir) < 0) {
VIR_FREE(userdir);
goto no_memory;
}
+#else
+ if (!(userdir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(&path, "%s/.libvirt/libvirt.conf", userdir) < 0) {
+ VIR_FREE(userdir);
+ goto no_memory;
+ }
+#endif
+
VIR_FREE(userdir);
}
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index e1846ee..874b3be 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -302,9 +302,10 @@ networkStartup(int privileged) {
if ((base = strdup (SYSCONFDIR "/libvirt")) == NULL)
goto out_of_memory;
} else {
- char *userdir = virGetUserCacheDirectory();
+ char *userdir = NULL;
- if (!userdir)
+#ifdef ENABLE_XDG
+ if (!(userdir = virGetUserCacheDirectory()))
goto error;
if (virAsprintf(&driverState->logDir,
@@ -320,6 +321,23 @@ networkStartup(int privileged) {
goto out_of_memory;
}
VIR_FREE(userdir);
+#else
+ if (!(userdir = virGetUserDirectory()))
+ goto error;
+
+ if (virAsprintf(&driverState->logDir,
+ "%s/.libvirt/qemu/log", userdir) == -1) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+
+ if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+#endif
+
}
/* Configuration paths are either ~/.libvirt/qemu/... (session) or
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index a80bb66..b0be1c6 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -2,7 +2,7 @@
* nwfilter_driver.c: core driver for network filter APIs
* (based on storage_driver.c)
*
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
* Copyright (C) 2010 IBM Corporation
* Copyright (C) 2010 Stefan Berger
@@ -219,9 +219,22 @@ nwfilterDriverStartup(int privileged)
if ((base = strdup (SYSCONFDIR "/libvirt")) == NULL)
goto out_of_memory;
} else {
+#ifdef ENABLE_XDG
base = virGetUserConfigDirectory();
if (!base)
goto error;
+#else
+ char *userdir = virGetUserDirectory();
+
+ if (!userdir)
+ goto error;
+
+ if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+#endif
}
if (virAsprintf(&driverState->configDir,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index decf0fb..cc8185d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -659,36 +659,57 @@ qemudStartup(int privileged) {
"%s/lib/libvirt/qemu/dump", LOCALSTATEDIR) == -1)
goto out_of_memory;
} else {
- char *rundir;
- char *cachedir;
+ char *tmpdir;
- cachedir = virGetUserCacheDirectory();
- if (!cachedir)
+#ifdef ENABLE_XDG
+ base = virGetUserConfigDirectory();
+ if (!base)
+ goto error;
+
+ tmpdir = virGetUserCacheDirectory();
+ if (!tmpdir)
goto error;
if (virAsprintf(&qemu_driver->logDir,
- "%s/qemu/log", cachedir) == -1) {
- VIR_FREE(cachedir);
+ "%s/qemu/log", tmpdir) == -1) {
+ VIR_FREE(tmpdir);
goto out_of_memory;
}
- if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", cachedir) == -1) {
- VIR_FREE(cachedir);
+ if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", tmpdir) == -1) {
+ VIR_FREE(tmpdir);
goto out_of_memory;
}
- VIR_FREE(cachedir);
+ VIR_FREE(tmpdir);
- rundir = virGetUserRuntimeDirectory();
- if (!rundir)
+ tmpdir = virGetUserRuntimeDirectory();
+ if (!tmpdir)
goto error;
- if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", rundir) == -1) {
- VIR_FREE(rundir);
+ if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", tmpdir) == -1) {
+ VIR_FREE(tmpdir);
goto out_of_memory;
}
- VIR_FREE(rundir);
-
- base = virGetUserConfigDirectory();
- if (!base)
+ VIR_FREE(tmpdir);
+#else
+ if (!(tmpdir = virGetUserDirectory()))
goto error;
+
+ if (virAsprintf(&qemu_driver->logDir,
+ "%s/.libvirt/qemu/log", tmpdir) == -1) {
+ VIR_FREE(tmpdir);
+ goto out_of_memory;
+ }
+
+ if (virAsprintf(&base, "%s/.libvirt", tmpdir) == -1) {
+ VIR_FREE(tmpdir);
+ goto out_of_memory;
+ }
+
+ if (virAsprintf(&qemu_driver->stateDir, "%s/qemu/run", base) == -1)
+ goto out_of_memory;
+ if (virAsprintf(&qemu_driver->cacheDir, "%s/qemu/cache", base) == -1)
+ goto out_of_memory;
+#endif
+
if (virAsprintf(&qemu_driver->libDir, "%s/qemu/lib", base) == -1)
goto out_of_memory;
if (virAsprintf(&qemu_driver->saveDir, "%s/qemu/save", base) == -1)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index fc4c696..1b6a360 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -640,15 +640,26 @@ doRemoteOpen(virConnectPtr conn,
case trans_unix:
if (!sockname) {
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
- char *userdir = virGetUserRuntimeDirectory();
+ char *userdir = NULL;
- if (!userdir)
+# ifdef ENABLE_XDG
+ if (!(userdir = virGetUserRuntimeDirectory()))
goto failed;
if (virAsprintf(&sockname, "%s/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
VIR_FREE(userdir);
goto no_memory;
}
+# else
+ if (!(userdir = virGetUserDirectory()))
+ goto failed;
+
+ if (virAsprintf(&sockname, "%s/.libvirt/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
+ VIR_FREE(userdir);
+ goto no_memory;
+ }
+# endif
+
VIR_FREE(userdir);
} else {
if (flags & VIR_DRV_OPEN_REMOTE_RO)
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 9ce1e33..846b5cc 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -1091,9 +1091,22 @@ secretDriverStartup(int privileged)
if (base == NULL)
goto out_of_memory;
} else {
+#ifdef ENABLE_XDG
base = virGetUserConfigDirectory();
if (!base)
goto error;
+#else
+ char *userdir = virGetUserDirectory();
+
+ if (!userdir)
+ goto error;
+
+ if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+#endif
}
if (virAsprintf(&driverState->directory, "%s/secrets", base) == -1)
goto out_of_memory;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c341fab..1cc5c20 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -462,9 +462,23 @@ umlStartup(int privileged)
"%s/run/libvirt/uml-guest", LOCALSTATEDIR) == -1)
goto out_of_memory;
} else {
+
+#ifdef ENABLE_XDG
base = virGetUserConfigDirectory();
if (!base)
goto error;
+#else
+ userdir = virGetUserDirectory();
+
+ if (!userdir)
+ goto error;
+
+ if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+#endif
if (virAsprintf(¨_driver->logDir,
"%s/uml/log", base) == -1)
diff --git a/src/util/virauth.c b/src/util/virauth.c
index 6d9935d..a5dbc1f 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -68,11 +68,19 @@ int virAuthGetConfigFilePath(virConnectPtr conn,
}
}
+#ifdef ENABLE_XDG
if (!(userdir = virGetUserConfigDirectory()))
goto cleanup;
if (virAsprintf(path, "%s/auth.conf", userdir) < 0)
goto no_memory;
+#else
+ if (!(userdir = virGetUserDirectory()))
+ goto cleanup;
+
+ if (virAsprintf(path, "%s/.libvirt/auth.conf", userdir) < 0)
+ goto no_memory;
+#endif
VIR_DEBUG("Checking for readability of '%s'", *path);
if (access(*path, R_OK) == 0)
diff --git a/tools/virsh.c b/tools/virsh.c
index f0ec625..2d0e62b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2465,18 +2465,31 @@ vshReadlineInit(vshControl *ctl)
stifle_history(500);
/* Prepare to read/write history from/to the $XDG_CACHE_HOME/virsh/history file */
+
+# ifdef ENABLE_XDG
userdir = virGetUserCacheDirectory();
+# else
+ userdir = virGetUserDirectory();
+# endif
if (userdir == NULL) {
vshError(ctl, "%s", _("Could not determine home directory"));
return -1;
}
+# ifdef ENABLE_XDG
if (virAsprintf(&ctl->historydir, "%s/virsh", userdir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
VIR_FREE(userdir);
return -1;
}
+# else
+ if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) {
+ vshError(ctl, "%s", _("Out of memory"));
+ VIR_FREE(userdir);
+ return -1;
+ }
+# endif
if (virAsprintf(&ctl->historyfile, "%s/history", ctl->historydir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
--
1.7.12.3
12 years, 1 month
[libvirt] [PATCH 0/7] External checkpoint support
by Peter Krempa
This series adds support for external system checkpoints.
This series is designed to be applied on top of:
http://www.redhat.com/archives/libvir-list/2012-September/msg00594.html
This first series adds support for taking the snapshots. I'll follow up
with adding support to revert snapshots or to add add snapshots with
different parents, but I'd like to start rounds of review on this until
the design settles.
Peter
Peter Krempa (7):
qemu: Fix misleading comment for qemuDomainObjBeginJobWithDriver()
qemu: Split out code to save domain memory to allow reuse
snapshot: Add flag to enable creating checkpoints in paused state
snapshot: qemu: Add async job type for snapshots
snapshot: qemu: Rename qemuDomainSnapshotCreateActive
snapshot: qemu: Add support for external checkpoints
snapshot: qemu: Remove restrictions preventing external snapshots
include/libvirt/libvirt.h.in | 4 +
src/qemu/qemu_domain.c | 6 +-
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 474 +++++++++++++++++++++++++------------------
src/qemu/qemu_process.c | 19 ++
tools/virsh-domain-monitor.c | 2 +
tools/virsh-snapshot.c | 6 +
tools/virsh.pod | 12 +-
8 files changed, 326 insertions(+), 198 deletions(-)
--
1.7.12
12 years, 1 month
[libvirt] [PATCH v2 0/6] Add support for lock failure action
by Jiri Denemark
When sanlock is used as a locking driver and sanlock deamon loses access to its
lockspace, it automatically kills off the domains that had their locks stored
there. Apparently some management apps would like to change this behavior by
configuring what should happen when locks are lost.
Patch 3/7 from v1 was dropped in v2. Other patches were updated according to
review comments. More details may be found in each patch.
Jiri Denemark (6):
conf: Rename life cycle actions to event actions
conf: Add on_lockfailure event configuration
locking: Add const char * parameter to avoid ugly typecasts
locking: Pass hypervisor driver name when acquiring locks
locking: Add support for lock failure action
locking: Implement lock failure action in sanlock driver
docs/formatdomain.html.in | 37 ++++++++--
docs/internals/locking.html.in | 8 +++
docs/locking.html.in | 24 +++++++
docs/schemas/domaincommon.rng | 30 +++++++--
libvirt.spec.in | 1 +
po/POTFILES.in | 1 +
src/Makefile.am | 13 +++-
src/conf/domain_conf.c | 85 ++++++++++++++---------
src/conf/domain_conf.h | 18 ++++-
src/libvirt_private.syms | 2 +
src/locking/domain_lock.c | 36 ++++++----
src/locking/domain_lock.h | 4 ++
src/locking/lock_driver.h | 8 ++-
src/locking/lock_driver_nop.c | 1 +
src/locking/lock_driver_sanlock.c | 114 +++++++++++++++++++++++++++----
src/locking/lock_manager.c | 10 ++-
src/locking/lock_manager.h | 1 +
src/locking/sanlock_helper.c | 138 ++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 9 +--
src/qemu/qemu_hotplug.c | 15 +++--
src/qemu/qemu_process.c | 4 +-
22 files changed, 479 insertions(+), 81 deletions(-)
create mode 100644 src/locking/sanlock_helper.c
--
1.7.12
12 years, 1 month
[libvirt] [PATCH 0/3] vcpupin improvements
by Osier Yang
These 3 patches are to improve vcpu pinning problems:
problem 1:
vcpu hotplug is supported for some time, but it doesn't set
pinning policy for the vcpus onlined, or doesn't remove
the pinning policy for offlined vcpus.
problem 2:
Also each vcpu doesn't inherit the pinning policy from
def->cpuset (<vcpu cpuset='0-3,^2'>4</vcpu>) if there is no
policy specified explicitly for its own. This is incorrect,
as it conflicts with the of def->cpuset.
PATCH 3/3 fix problem 1 (based an ACKed but not pushed patch
https://www.redhat.com/archives/libvir-list/2012-October/msg00372.html).
PATCH 2/3 fix problem 2.
Osier Yang (3):
conf: Do not allow vcpupin's cpuid exceed current vcpus number
conf: Initialize the pinning policy for vcpus
qemu: Initialize cpuset for hotplugged vcpu as def->cpuset
src/conf/domain_conf.c | 60 +++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 3 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 75 ++++++++++++++++++++++++++++++++++++++++-----
4 files changed, 128 insertions(+), 11 deletions(-)
Regards,
Osier
12 years, 1 month
[libvirt] [PATCH v9] support offline migration
by liguang
original migration did not aware of offline case,
so, try to support offline migration quietly
(did not disturb original migration) by pass
VIR_MIGRATE_OFFLINE flag to migration APIs if only
the domain is really inactive, and
migration process will not puzzled by domain
offline and exit unexpectedly.
these changes did not take care of disk images the
domain required, for them could be transferred by
other APIs as suggested, then VIR_MIGRATE_OFFLINE
should not combined with VIR_MIGRATE_NON_SHARED_*.
so, this migration result is just make domain
definition alive at target side.
Signed-off-by: liguang <lig.fnst(a)cn.fujitsu.com>
---
include/libvirt/libvirt.h.in | 1 +
src/qemu/qemu_driver.c | 15 ++++++++++++
src/qemu/qemu_migration.c | 53 ++++++++++++++++++++++++++++++++++++-----
src/qemu/qemu_migration.h | 3 +-
tools/virsh-domain.c | 6 ++++
5 files changed, 70 insertions(+), 8 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 79c7689..627e9d4 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -995,6 +995,7 @@ typedef enum {
* whole migration process; this will be used automatically
* when supported */
VIR_MIGRATE_UNSAFE = (1 << 9), /* force migration even if it is considered unsafe */
+ VIR_MIGRATE_OFFLINE = (1 << 10), /* offline migrate */
} virDomainMigrateFlags;
/* Domain migration. */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6848924..105febf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9631,6 +9631,15 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
}
if (!virDomainObjIsActive(vm)) {
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ if (flags & (VIR_MIGRATE_NON_SHARED_DISK|
+ VIR_MIGRATE_NON_SHARED_INC)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("migrating storage handled by volume APIs"));
+ goto endjob;
+ }
+ goto offline;
+ }
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
@@ -9643,6 +9652,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0)
goto endjob;
+offline:
if (!(xml = qemuMigrationBegin(driver, vm, xmlin, dname,
cookieout, cookieoutlen,
flags)))
@@ -9878,6 +9888,11 @@ qemuDomainMigrateConfirm3(virDomainPtr domain,
goto cleanup;
}
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_OUT))
goto cleanup;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8e85875..411a4c2 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -70,6 +70,7 @@ enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE,
QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT,
+ QEMU_MIGRATION_COOKIE_FLAG_OFFLINE,
QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -77,12 +78,13 @@ enum qemuMigrationCookieFlags {
VIR_ENUM_DECL(qemuMigrationCookieFlag);
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
QEMU_MIGRATION_COOKIE_FLAG_LAST,
- "graphics", "lockstate", "persistent");
+ "graphics", "lockstate", "persistent", "offline");
enum qemuMigrationCookieFeatures {
QEMU_MIGRATION_COOKIE_GRAPHICS = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
QEMU_MIGRATION_COOKIE_LOCKSTATE = (1 << QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE),
QEMU_MIGRATION_COOKIE_PERSISTENT = (1 << QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT),
+ QEMU_MIGRATION_COOKIE_OFFLINE = (1 << QEMU_MIGRATION_COOKIE_FLAG_OFFLINE),
};
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -439,6 +441,9 @@ qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
virBufferAdjustIndent(buf, -2);
}
+ if (mig->flags & QEMU_MIGRATION_COOKIE_OFFLINE)
+ virBufferAsprintf(buf, " <offline/>\n");
+
virBufferAddLit(buf, "</qemu-migration>\n");
return 0;
}
@@ -662,6 +667,11 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
VIR_FREE(nodes);
}
+ if ((flags & QEMU_MIGRATION_COOKIE_OFFLINE)) {
+ if (virXPathBoolean("count(./offline) > 0", ctxt))
+ mig->flags |= QEMU_MIGRATION_COOKIE_OFFLINE;
+ }
+
return 0;
error:
@@ -721,6 +731,10 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
qemuMigrationCookieAddPersistent(mig, dom) < 0)
return -1;
+ if (flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ mig->flags |= QEMU_MIGRATION_COOKIE_OFFLINE;
+ }
+
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;
@@ -1151,6 +1165,13 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
QEMU_MIGRATION_COOKIE_LOCKSTATE) < 0)
goto cleanup;
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ if (qemuMigrationBakeCookie(mig, driver, vm,
+ cookieout, cookieoutlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE) < 0)
+ goto cleanup;
+ }
+
if (xmlin) {
if (!(def = virDomainDefParseString(driver->caps, xmlin,
QEMU_EXPECTED_VIRT_TYPES,
@@ -1314,6 +1335,15 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
goto endjob;
}
+ if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
+ QEMU_MIGRATION_COOKIE_OFFLINE)))
+ return ret;
+
+ if (mig->flags & QEMU_MIGRATION_COOKIE_OFFLINE) {
+ ret = 0;
+ goto cleanup;
+ }
+
/* Start the QEMU daemon, with the same command-line arguments plus
* -incoming $migrateFrom
*/
@@ -1856,7 +1886,8 @@ qemuMigrationRun(struct qemud_driver *driver,
virLockManagerPluginGetName(driver->lockManager));
return -1;
}
-
+ if (flags & VIR_MIGRATE_OFFLINE)
+ return 0;
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen,
QEMU_MIGRATION_COOKIE_GRAPHICS)))
goto cleanup;
@@ -2372,6 +2403,8 @@ static int doPeer2PeerMigrate3(struct qemud_driver *driver,
qemuDomainObjExitRemoteWithDriver(driver, vm);
}
VIR_FREE(dom_xml);
+ if (flags & VIR_MIGRATE_OFFLINE)
+ goto cleanup;
if (ret == -1)
goto cleanup;
@@ -2477,7 +2510,7 @@ finish:
vm->def->name);
cleanup:
- if (ddomain) {
+ if (ddomain || (flags & VIR_MIGRATE_OFFLINE)) {
virObjectUnref(ddomain);
ret = 0;
} else {
@@ -2554,7 +2587,7 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
}
/* domain may have been stopped while we were talking to remote daemon */
- if (!virDomainObjIsActive(vm)) {
+ if (!virDomainObjIsActive(vm) && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest unexpectedly quit"));
goto cleanup;
@@ -2617,7 +2650,7 @@ qemuMigrationPerformJob(struct qemud_driver *driver,
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0)
goto cleanup;
- if (!virDomainObjIsActive(vm)) {
+ if (!virDomainObjIsActive(vm) && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
goto endjob;
@@ -2941,6 +2974,8 @@ qemuMigrationFinish(struct qemud_driver *driver,
*/
if (retcode == 0) {
if (!virDomainObjIsActive(vm)) {
+ if (flags & VIR_MIGRATE_OFFLINE)
+ goto offline;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest unexpectedly quit"));
goto endjob;
@@ -3038,7 +3073,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
goto endjob;
}
}
-
+ offline:
dom = virGetDomain (dconn, vm->def->name, vm->def->uuid);
event = virDomainEventNewFromObj(vm,
@@ -3074,6 +3109,7 @@ qemuMigrationFinish(struct qemud_driver *driver,
endjob:
if (qemuMigrationJobFinish(driver, vm) == 0) {
vm = NULL;
+ } else if (flags & VIR_MIGRATE_OFFLINE) {
} else if (!vm->persistent && !virDomainObjIsActive(vm)) {
qemuDomainRemoveInactive(driver, vm);
vm = NULL;
@@ -3120,7 +3156,10 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0)))
return -1;
-
+ if (flags & VIR_MIGRATE_OFFLINE) {
+ rv = 0;
+ goto cleanup;
+ }
/* Did the migration go as planned? If yes, kill off the
* domain object, but if no, resume CPUs
*/
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 7a2269a..b4f6a77 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -36,7 +36,8 @@
VIR_MIGRATE_NON_SHARED_DISK | \
VIR_MIGRATE_NON_SHARED_INC | \
VIR_MIGRATE_CHANGE_PROTECTION | \
- VIR_MIGRATE_UNSAFE)
+ VIR_MIGRATE_UNSAFE | \
+ VIR_MIGRATE_OFFLINE)
enum qemuMigrationJobPhase {
QEMU_MIGRATION_PHASE_NONE = 0,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 505169b..2218379 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6647,6 +6647,7 @@ static const vshCmdOptDef opts_migrate[] = {
{"dname", VSH_OT_DATA, 0, N_("rename to new name during migration (if supported)")},
{"timeout", VSH_OT_INT, 0, N_("force guest to suspend if live migration exceeds timeout (in seconds)")},
{"xml", VSH_OT_STRING, 0, N_("filename containing updated XML for the target")},
+ {"offline", VSH_OT_BOOL, 0, N_("for offline migration")},
{NULL, 0, 0, NULL}
};
@@ -6713,6 +6714,11 @@ doMigrate(void *opaque)
if (vshCommandOptBool(cmd, "unsafe"))
flags |= VIR_MIGRATE_UNSAFE;
+ if (vshCommandOptBool(cmd, "offline")) {
+ if (!virDomainIsActive(dom))
+ flags |= VIR_MIGRATE_OFFLINE;
+ }
+
if (xmlfile &&
virFileReadAll(xmlfile, 8192, &xml) < 0) {
vshError(ctl, _("file '%s' doesn't exist"), xmlfile);
--
1.7.2.5
12 years, 1 month
[libvirt] build libvirt error. lack of AppArmor .
by yue
error occur when attach a rbd-disk to domain.
1.configure: error: You must install the AppArmor development package in order to compile libvirt
2.
2012-10-10 17:36:16.305+0000: 3808: warning : qemuDomainObjTaint:1297 : Domain id=2 name='xpSP3' uuid=b45bd66a-6700-4905-c5f4-4c799413d7b7 is tainted: high-privileges
2012-10-10 17:36:16.712+0000: 3808: error : qemuMonitorOpenUnix:266 : failed to connect to monitor socket: No such process
2012-10-10 17:36:16.712+0000: 3808: error : qemuProcessWaitForMonitor:1510 : internal error process exited while connecting to monitor: char device redirected to /dev/pts/4
qemu-kvm: -drive file=rbd:cloud/testrbd:id=cloud:key=AQCGbGRQ+M+NGBAATtylZNiSxqCTQ4uaApd+9w==:auth_supported=cephx none:mon_host=192.168.10.4\:6789,if=none,id=drive-ide0-0-1,format=raw: could not open disk image rbd:cloud/testrbd:id=cloud:key=AQCGbGRQ+M+NGBAATtylZNiSxqCTQ4uaApd+9w==:auth_supported=cephx none:mon_host=192.168.10.4\:6789: No such file or directory
centos6.2 2.6.32-220.el6.x86_64
12 years, 1 month
[libvirt] Correct name of domain/pm/suspend-to-mem in docs
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
docs/formatdomain.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3cc6c51..f9fe6ca 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -983,7 +983,7 @@
...
<pm>
<suspend-to-disk enabled='no'/>
- <suspend-to-ram enabled='yes'/>
+ <suspend-to-mem enabled='yes'/>
</pm>
...</pre>
--
1.7.12.1
12 years, 1 month
[libvirt] [libvirt-glib] gconfig: Add API to set domain/pm tree
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
API for new domain power management configuration.
---
libvirt-gconfig/Makefile.am | 2 +
.../libvirt-gconfig-domain-power-management.c | 101 +++++++++++++++++++++
.../libvirt-gconfig-domain-power-management.h | 76 ++++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain.c | 16 ++++
libvirt-gconfig/libvirt-gconfig-domain.h | 3 +
libvirt-gconfig/libvirt-gconfig.h | 1 +
libvirt-gconfig/libvirt-gconfig.sym | 11 +++
7 files changed, 210 insertions(+)
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-power-management.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-power-management.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 5a80123..caa62f0 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -50,6 +50,7 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-domain-memballoon.h \
libvirt-gconfig-domain-os.h \
libvirt-gconfig-domain-parallel.h \
+ libvirt-gconfig-domain-power-management.h \
libvirt-gconfig-domain-redirdev.h \
libvirt-gconfig-domain-seclabel.h \
libvirt-gconfig-domain-serial.h \
@@ -121,6 +122,7 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-domain-memballoon.c \
libvirt-gconfig-domain-os.c \
libvirt-gconfig-domain-parallel.c \
+ libvirt-gconfig-domain-power-management.c \
libvirt-gconfig-domain-redirdev.c \
libvirt-gconfig-domain-seclabel.c \
libvirt-gconfig-domain-serial.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-power-management.c b/libvirt-gconfig/libvirt-gconfig-domain-power-management.c
new file mode 100644
index 0000000..c6b1962
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-power-management.c
@@ -0,0 +1,101 @@
+/*
+ * libvirt-gconfig-domain-power-management.c: libvirt domain power management configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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
+ *
+ * Authors:
+ *
+ * Zeeshan Ali (Khattak) <zeeshanak(a)gnome.org>
+ * Christophe Fergeau <cfergeau(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
+ GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT, \
+ GVirConfigDomainPowerManagementPrivate))
+
+struct _GVirConfigDomainPowerManagementPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainPowerManagement,
+ gvir_config_domain_power_management,
+ GVIR_CONFIG_TYPE_OBJECT);
+
+static void gvir_config_domain_power_management_class_init
+ (GVirConfigDomainPowerManagementClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigDomainPowerManagementPrivate));
+}
+
+
+static void
+gvir_config_domain_power_management_init(GVirConfigDomainPowerManagement *pm)
+{
+ g_debug("Init GVirConfigDomainPowerManagement=%p", pm);
+
+ pm->priv = GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT_GET_PRIVATE(pm);
+}
+
+
+GVirConfigDomainPowerManagement *gvir_config_domain_power_management_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT,
+ "pm", NULL);
+ return GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT(object);
+}
+
+GVirConfigDomainPowerManagement *
+gvir_config_domain_power_management_new_from_xml(const gchar *xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT,
+ "pm", NULL, xml, error);
+ return GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT(object);
+}
+
+void gvir_config_domain_power_management_set_ram_suspend_enabled
+ (GVirConfigDomainPowerManagement *pm, gboolean enabled)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_POWER_MANAGEMENT(pm));
+
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(pm),
+ "suspend-to-ram",
+ "enabled",
+ enabled? "yes" : "no");
+}
+
+void gvir_config_domain_power_management_set_disk_suspend_enabled
+ (GVirConfigDomainPowerManagement *pm, gboolean enabled)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_POWER_MANAGEMENT(pm));
+
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(pm),
+ "suspend-to-disk",
+ "enabled",
+ enabled? "yes" : "no");
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-power-management.h b/libvirt-gconfig/libvirt-gconfig-domain-power-management.h
new file mode 100644
index 0000000..1d9b3b7
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-power-management.h
@@ -0,0 +1,76 @@
+/*
+ * libvirt-gconfig-domain-power-management.h: libvirt domain power management configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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
+ *
+ * Zeeshan Ali (Khattak) <zeeshanak(a)gnome.org>
+ * Christophe Fergeau <cfergeau(a)redhat.com>
+ */
+
+#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
+#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GCONFIG_DOMAIN_POWER_MANAGEMENT_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_POWER_MANAGEMENT_H__
+
+#include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT (gvir_config_domain_power_management_get_type ())
+#define GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT, GVirConfigDomainPowerManagement))
+#define GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT, GVirConfigDomainPowerManagementClass))
+#define GVIR_CONFIG_IS_DOMAIN_POWER_MANAGEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT))
+#define GVIR_CONFIG_IS_DOMAIN_POWER_MANAGEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT))
+#define GVIR_CONFIG_DOMAIN_POWER_MANAGEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_POWER_MANAGEMENT, GVirConfigDomainPowerManagementClass))
+
+typedef struct _GVirConfigDomainPowerManagement GVirConfigDomainPowerManagement;
+typedef struct _GVirConfigDomainPowerManagementPrivate GVirConfigDomainPowerManagementPrivate;
+typedef struct _GVirConfigDomainPowerManagementClass GVirConfigDomainPowerManagementClass;
+
+struct _GVirConfigDomainPowerManagement
+{
+ GVirConfigObject parent;
+
+ GVirConfigDomainPowerManagementPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainPowerManagementClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_power_management_get_type(void);
+
+GVirConfigDomainPowerManagement *gvir_config_domain_power_management_new(void);
+GVirConfigDomainPowerManagement *
+gvir_config_domain_power_management_new_from_xml(const gchar *xml,
+ GError **error);
+void gvir_config_domain_power_management_set_ram_suspend_enabled
+ (GVirConfigDomainPowerManagement *pm, gboolean enabled);
+void gvir_config_domain_power_management_set_disk_suspend_enabled
+ (GVirConfigDomainPowerManagement *pm, gboolean enabled);
+
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_POWER_MANAGEMENT_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index e679e3a..e664351 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -804,3 +804,19 @@ void gvir_config_domain_set_cpu(GVirConfigDomain *domain,
"cpu",
GVIR_CONFIG_OBJECT(cpu));
}
+
+/**
+ * gvir_config_domain_set_power_management:
+ * @domain: a #GVirConfigDomain
+ * @pm: (allow-none): a #GVirPowerManagement instance
+ */
+void gvir_config_domain_set_power_management(GVirConfigDomain *domain,
+ GVirConfigDomainPowerManagement *pm)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
+ g_return_if_fail(pm != NULL || GVIR_CONFIG_IS_DOMAIN_POWER_MANAGEMENT(pm));
+
+ gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+ "pm",
+ GVIR_CONFIG_OBJECT(pm));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
index a7bd73b..3a7be12 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -32,6 +32,7 @@
#include <libvirt-gconfig/libvirt-gconfig-domain-device.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-seclabel.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-cpu.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-power-management.h>
G_BEGIN_DECLS
@@ -143,6 +144,8 @@ gchar *gvir_config_domain_get_custom_xml(GVirConfigDomain *domain,
GVirConfigDomainCpu *gvir_config_domain_get_cpu(GVirConfigDomain *domain);
void gvir_config_domain_set_cpu(GVirConfigDomain *domain,
GVirConfigDomainCpu *cpu);
+void gvir_config_domain_set_power_management(GVirConfigDomain *domain,
+ GVirConfigDomainPowerManagement *pm);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 4b5ccbd..0428259 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -67,6 +67,7 @@
#include <libvirt-gconfig/libvirt-gconfig-domain-memballoon.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-os.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-parallel.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-power-management.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-redirdev.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-seclabel.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-serial.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 2ec2e80..c19cd79 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -472,4 +472,15 @@ LIBVIRT_GCONFIG_0.1.3 {
gvir_config_domain_graphics_vnc_set_socket;
} LIBVIRT_GCONFIG_0.1.0;
+LIBVIRT_GCONFIG_0.1.4 {
+ global:
+ gvir_config_domain_power_management_get_type;
+ gvir_config_domain_power_management_new;
+ gvir_config_domain_power_management_new_from_xml;
+ gvir_config_domain_power_management_set_ram_suspend_enabled;
+ gvir_config_domain_power_management_set_disk_suspend_enabled;
+
+ gvir_config_domain_set_power_management;
+} LIBVIRT_GCONFIG_0.1.3;
+
# .... define new API here using predicted next version number ....
--
1.7.12.1
12 years, 1 month
[libvirt] feature?
by Gene Czarcinski
By accident I had virtual guests running where the ip6 network
definition was different than the one specified in the network xml file
... and it worked!
Of course I did get an "extra" network address on the interface (due I
assume to radvd) but it worked.
Now, this is really an isolated network and I like this as a feature.
For "regular" private or isolated virtual networks, the virtualization
host can still get to any guest and any network ... except the ones
where I had forgot to update the virtual network xml.
comments?
Gene
12 years, 1 month