Rebased to version 1.1.3.5

Fix QXL PCI address conflict (bz #1016775)
Fix journald PRIORITY values (bz #1043550)
Fix crash with filterref and update-device (bz #1093301)
Fix 'cannot find session' error with iscsi (bz #1093791)
Fix bond XML issues (bz #1084702)
remotes/origin/f20
Cole Robinson 2014-05-03 17:37:27 -04:00
parent 9cd81dde07
commit 33bd789e17
9 changed files with 11 additions and 1425 deletions

View File

@ -1,54 +0,0 @@
From f599cc7aa26bc0218e8cd0311d7307931763345a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Wed, 8 Jan 2014 19:55:19 +0100
Subject: [PATCH] Add Documentation fields to systemd service files
We point to the manpages where available and redirect to libvirt's
homepage as a last resort.
(cherry picked from commit 1b9f5aa7fe67d9d4bb843db3580bdbc917c49a10)
---
daemon/libvirtd.service.in | 2 ++
src/locking/virtlockd.service.in | 2 ++
tools/libvirt-guests.service.in | 2 ++
3 files changed, 6 insertions(+)
diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in
index 25979ef..dc2433a 100644
--- a/daemon/libvirtd.service.in
+++ b/daemon/libvirtd.service.in
@@ -9,6 +9,8 @@ Before=libvirt-guests.service
After=network.target
After=dbus.service
After=iscsid.service
+Documentation=man:libvirtd(8)
+Documentation=http://libvirt.org
[Service]
EnvironmentFile=-/etc/sysconfig/libvirtd
diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in
index 0ef9923..059c14e 100644
--- a/src/locking/virtlockd.service.in
+++ b/src/locking/virtlockd.service.in
@@ -1,6 +1,8 @@
[Unit]
Description=Virtual machine lock manager
Requires=virtlockd.socket
+Documentation=man:virtlockd(8)
+Documentation=http://libvirt.org
[Service]
EnvironmentFile=-/etc/sysconfig/virtlockd
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index d48d4b8..d8d7adf 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -1,6 +1,8 @@
[Unit]
Description=Suspend Active Libvirt Guests
After=network.target libvirtd.service
+Documentation=man:libvirtd(8)
+Documentation=http://libvirt.org
[Service]
EnvironmentFile=-/etc/sysconfig/libvirt-guests

View File

@ -1,41 +0,0 @@
From 08abb8225b8104693e71d0f0e610edfdefb085f2 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 21 Feb 2014 10:16:36 +0100
Subject: [PATCH] virSystemdCreateMachine: Set dependencies for slices
https://bugzilla.redhat.com/show_bug.cgi?id=1031696
When creating a new domain, we let systemd know about it by calling
CreateMachine() function via dbus. Systemd then creates a scope and
places domain into it. However, later when the host is shutting
down, systemd computes the shutdown order to see what processes can
be shut down in parallel. And since we were not setting
dependencies at all, the slices (and thus domains) were most likely
killed before libvirt-guests.service. So user domains that had to
be saved, shut off, whatever were in fact killed. This problem can
be solved by letting systemd know that scopes we're creating must
not be killed before libvirt-guests.service.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ba79e3879e771417ee90e125d8b38743a867d7d1)
---
src/util/virsystemd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 1ba37cc..4e2721b 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -242,8 +242,10 @@ int virSystemdCreateMachine(const char *name,
iscontainer ? "container" : "vm",
(unsigned int)pidleader,
rootdir ? rootdir : "",
- 1, "Slice", "s",
- slicename) < 0)
+ 3,
+ "Slice", "s", slicename,
+ "After", "as", 1, "libvirtd.service",
+ "Before", "as", 1, "libvirt-guests.service") < 0)
goto cleanup;
ret = 0;

View File

@ -1,61 +0,0 @@
From 393ffe6c3f7c72bfe8c6d254adf37e6f42169024 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 21 Feb 2014 12:46:08 +0100
Subject: [PATCH] libvirt-guests: Wait for libvirtd to initialize
I've noticed that in some cases systemd was quick enough and even
if libvirt-guests.service is marked to be started after the
libvirtd.service my guests were not resumed as
libvirt-guests.sh failed to connect. This is because of a
simple fact: systemd correctly starts libvirt-guests after it
execs libvirtd. However, the daemon is not able to accept
connections right from the start. It's doing some
initialization which may take ages. This problem is not limited
to systemd only, indeed. Any init system that is able to startup
services in parallel (e.g. OpenRC) may run into this situation.
The fix is to try connecting not only once, but continuously a few
times with a small sleep in between tries.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 4e7fc8305a53676ba2362bfaa8ca05c4851b7e12)
---
tools/libvirt-guests.sh.in | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 38e93c5..4bbd4e4 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -37,6 +37,8 @@ SHUTDOWN_TIMEOUT=300
PARALLEL_SHUTDOWN=0
START_DELAY=0
BYPASS_CACHE=0
+CONNECT_RETRIES=10
+RETRIES_SLEEP=1
test -f "$sysconfdir"/sysconfig/libvirt-guests &&
. "$sysconfdir"/sysconfig/libvirt-guests
@@ -87,12 +89,17 @@ test_connect()
{
uri=$1
- run_virsh "$uri" connect 2>/dev/null
- if [ $? -ne 0 ]; then
- eval_gettext "Can't connect to \$uri. Skipping."
- echo
- return 1
- fi
+ for ((i = 0; i < ${CONNECT_RETRIES}; i++)); do
+ run_virsh "$uri" connect 2>/dev/null
+ if [ $? -eq 0 ]; then
+ return 0;
+ fi
+ sleep ${RETRIES_SLEEP}
+ eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i"
+ done
+ eval_gettext "Can't connect to \$uri. Skipping."
+ echo
+ return 1
}
# list_guests URI PERSISTENT

View File

@ -1,193 +0,0 @@
From 876861ca02d466c70ab0782bbdb4bf03d4e03148 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Fri, 21 Feb 2014 13:06:42 +0100
Subject: [PATCH] virNetServerRun: Notify systemd that we're accepting clients
Systemd does not forget about the cases, where client service needs to
wait for daemon service to initialize and start accepting new clients.
Setting a dependency in client is not enough as systemd doesn't know
when the daemon has initialized itself and started accepting new
clients. However, it offers a mechanism to solve this. The daemon needs
to call a special systemd function by which the daemon tells "I'm ready
to accept new clients". This is exactly what we need with
libvirtd-guests (client) and libvirtd (daemon). So now, with this
change, libvirt-guests.service is invoked not any sooner than
libvirtd.service calls the systemd notify function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 68954fb25c4a75c5c2c213f57927eb188cca2239)
---
configure.ac | 2 ++
daemon/libvirtd.service.in | 1 +
m4/virt-systemd-daemon.m4 | 34 ++++++++++++++++++++++++++++++++++
src/Makefile.am | 4 ++--
src/libvirt_private.syms | 1 +
src/rpc/virnetserver.c | 5 +++++
src/util/virsystemd.c | 12 ++++++++++++
src/util/virsystemd.h | 2 ++
8 files changed, 59 insertions(+), 2 deletions(-)
create mode 100644 m4/virt-systemd-daemon.m4
diff --git a/configure.ac b/configure.ac
index aea0bd3..0d5cf59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,7 @@ LIBVIRT_CHECK_SANLOCK
LIBVIRT_CHECK_SASL
LIBVIRT_CHECK_SELINUX
LIBVIRT_CHECK_SSH2
+LIBVIRT_CHECK_SYSTEMD_DAEMON
LIBVIRT_CHECK_UDEV
LIBVIRT_CHECK_YAJL
@@ -2731,6 +2732,7 @@ LIBVIRT_RESULT_SANLOCK
LIBVIRT_RESULT_SASL
LIBVIRT_RESULT_SELINUX
LIBVIRT_RESULT_SSH2
+LIBVIRT_RESULT_SYSTEMD_DAEMON
LIBVIRT_RESULT_UDEV
LIBVIRT_RESULT_YAJL
AC_MSG_NOTICE([ libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in
index dc2433a..e1f2a07 100644
--- a/daemon/libvirtd.service.in
+++ b/daemon/libvirtd.service.in
@@ -13,6 +13,7 @@ Documentation=man:libvirtd(8)
Documentation=http://libvirt.org
[Service]
+Type=notify
EnvironmentFile=-/etc/sysconfig/libvirtd
ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS
ExecReload=/bin/kill -HUP $MAINPID
diff --git a/m4/virt-systemd-daemon.m4 b/m4/virt-systemd-daemon.m4
new file mode 100644
index 0000000..8516e41
--- /dev/null
+++ b/m4/virt-systemd-daemon.m4
@@ -0,0 +1,34 @@
+dnl The libsystemd-daemon.so library
+dnl
+dnl Copyright (C) 2012-2013 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_CHECK_SYSTEMD_DAEMON],[
+ LIBVIRT_CHECK_PKG([SYSTEMD_DAEMON], [libsystemd-daemon], [0.27.1])
+
+ old_CFLAGS="$CFLAGS"
+ old_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $SYSTEMD_DAEMON_CFLAGS"
+ LIBS="$LIBS $SYSTEMD_DAEMON_LIBS"
+ AC_CHECK_FUNCS([sd_notify])
+ CFLAGS="$old_CFLAGS"
+ LIBS="$old_LIBS"
+])
+
+AC_DEFUN([LIBVIRT_RESULT_SYSTEMD_DAEMON],[
+ LIBVIRT_RESULT_LIB([SYSTEMD_DAEMON])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 1a2cf6b..f813b68 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -933,11 +933,11 @@ libvirt_util_la_SOURCES = \
libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
$(DBUS_CFLAGS) $(LDEXP_LIBM) $(NUMACTL_CFLAGS) \
- -I$(top_srcdir)/src/conf
+ $(SYSTEMD_DAEMON_CFLAGS) -I$(top_srcdir)/src/conf
libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
$(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
$(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) $(LIBXML_LIBS) \
- $(SECDRIVER_LIBS) $(NUMACTL_LIBS)
+ $(SECDRIVER_LIBS) $(NUMACTL_LIBS) $(SYSTEMD_DAEMON_LIBS)
noinst_LTLIBRARIES += libvirt_conf.la
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d7bed65..babca5f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1955,6 +1955,7 @@ virSystemdCreateMachine;
virSystemdMakeMachineName;
virSystemdMakeScopeName;
virSystemdMakeSliceName;
+virSystemdNotifyStartup;
virSystemdTerminateMachine;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 2306e10..df61036 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -38,6 +38,7 @@
#include "virnetservermdns.h"
#include "virdbus.h"
#include "virstring.h"
+#include "virsystemd.h"
#ifndef SA_SIGINFO
# define SA_SIGINFO 0
@@ -1085,6 +1086,10 @@ void virNetServerRun(virNetServerPtr srv)
goto cleanup;
}
+ /* We are accepting connections now. Notify systemd
+ * so it can start dependent services. */
+ virSystemdNotifyStartup();
+
VIR_DEBUG("srv=%p quit=%d", srv, srv->quit);
while (!srv->quit) {
/* A shutdown timeout is specified, so check
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 4e2721b..d9837ce 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -21,6 +21,10 @@
#include <config.h>
+#ifdef WITH_SYSTEMD_DAEMON
+# include <systemd/sd-daemon.h>
+#endif
+
#include "virsystemd.h"
#include "virdbus.h"
#include "virstring.h"
@@ -302,3 +306,11 @@ cleanup:
VIR_FREE(machinename);
return ret;
}
+
+void
+virSystemdNotifyStartup(void)
+{
+#ifdef WITH_SYSTEMD_DAEMON
+ sd_notify(0, "READY=1");
+#endif
+}
diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h
index d9845e1..7fed456 100644
--- a/src/util/virsystemd.h
+++ b/src/util/virsystemd.h
@@ -46,4 +46,6 @@ int virSystemdTerminateMachine(const char *name,
const char *drivername,
bool privileged);
+void virSystemdNotifyStartup(void);
+
#endif /* __VIR_SYSTEMD_H__ */

View File

@ -1,342 +0,0 @@
From d3e5327fed75feeb262f4571f280a68625561a82 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Tue, 19 Nov 2013 15:21:40 -0700
Subject: [PATCH] maint: fix comma style issues: conf
Most of our code base uses space after comma but not before;
fix the remaining uses before adding a syntax check.
* src/conf/capabilities.c: Consistently use commas.
* src/conf/domain_conf.c: Likewise.
* src/conf/network_conf.c: Likewise.
* src/conf/storage_conf.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 6f4901e13b55b0a6adac303d7880740ac1bb5300)
---
src/conf/capabilities.c | 2 +-
src/conf/domain_conf.c | 4 +-
src/conf/network_conf.c | 6 +--
src/conf/storage_conf.c | 97 +++++++++++++++++++++++++------------------------
4 files changed, 55 insertions(+), 54 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1acc936..ad6faa2 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -761,7 +761,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " <host>\n");
if (virUUIDIsValid(caps->host.host_uuid)) {
virUUIDFormat(caps->host.host_uuid, host_uuid);
- virBufferAsprintf(&xml," <uuid>%s</uuid>\n", host_uuid);
+ virBufferAsprintf(&xml, " <uuid>%s</uuid>\n", host_uuid);
}
virBufferAddLit(&xml, " <cpu>\n");
if (caps->host.arch)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c812e71..af1909b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14243,7 +14243,7 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
{
if (def->blockio.logical_block_size > 0 ||
def->blockio.physical_block_size > 0) {
- virBufferAddLit(buf," <blockio");
+ virBufferAddLit(buf, " <blockio");
if (def->blockio.logical_block_size > 0) {
virBufferAsprintf(buf,
" logical_block_size='%u'",
@@ -14270,7 +14270,7 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
def->startupPolicy) {
switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE:
- virBufferAddLit(buf," <source");
+ virBufferAddLit(buf, " <source");
if (def->src)
virBufferEscapeString(buf, " file='%s'", def->src);
if (def->startupPolicy)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c877a6d..fe29f82 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2393,7 +2393,7 @@ virNetworkIpDefFormat(virBufferPtr buf,
VIR_FREE(addr);
}
if (def->prefix > 0) {
- virBufferAsprintf(buf," prefix='%u'", def->prefix);
+ virBufferAsprintf(buf, " prefix='%u'", def->prefix);
}
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
@@ -2492,7 +2492,7 @@ virNetworkRouteDefFormat(virBufferPtr buf,
VIR_FREE(addr);
}
if (def->has_prefix) {
- virBufferAsprintf(buf," prefix='%u'", def->prefix);
+ virBufferAsprintf(buf, " prefix='%u'", def->prefix);
}
if (VIR_SOCKET_ADDR_VALID(&def->gateway)) {
char *addr = virSocketAddrFormat(&def->gateway);
@@ -2502,7 +2502,7 @@ virNetworkRouteDefFormat(virBufferPtr buf,
VIR_FREE(addr);
}
if (def->has_metric && def->metric > 0) {
- virBufferAsprintf(buf," metric='%u'", def->metric);
+ virBufferAsprintf(buf, " metric='%u'", def->metric);
}
virBufferAddLit(buf, "/>\n");
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 975e662..33e4caf 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1053,7 +1053,7 @@ virStoragePoolSourceFormat(virBufferPtr buf,
size_t i, j;
char uuid[VIR_UUID_STRING_BUFLEN];
- virBufferAddLit(buf," <source>\n");
+ virBufferAddLit(buf, " <source>\n");
if ((options->flags & VIR_STORAGE_POOL_SOURCE_HOST) && src->nhost) {
for (i = 0; i < src->nhost; i++) {
virBufferAsprintf(buf, " <host name='%s'", src->hosts[i].name);
@@ -1067,14 +1067,14 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src->ndevice) {
for (i = 0; i < src->ndevice; i++) {
if (src->devices[i].nfreeExtent) {
- virBufferAsprintf(buf," <device path='%s'>\n",
+ virBufferAsprintf(buf, " <device path='%s'>\n",
src->devices[i].path);
for (j = 0; j < src->devices[i].nfreeExtent; j++) {
virBufferAsprintf(buf, " <freeExtent start='%llu' end='%llu'/>\n",
src->devices[i].freeExtents[j].start,
src->devices[i].freeExtents[j].end);
}
- virBufferAddLit(buf," </device>\n");
+ virBufferAddLit(buf, " </device>\n");
} else {
virBufferAsprintf(buf, " <device path='%s'/>\n",
src->devices[i].path);
@@ -1084,7 +1084,7 @@ virStoragePoolSourceFormat(virBufferPtr buf,
if ((options->flags & VIR_STORAGE_POOL_SOURCE_DIR) &&
src->dir)
- virBufferAsprintf(buf," <dir path='%s'/>\n", src->dir);
+ virBufferAsprintf(buf, " <dir path='%s'/>\n", src->dir);
if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER)) {
if (src->adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST ||
@@ -1095,24 +1095,25 @@ virStoragePoolSourceFormat(virBufferPtr buf,
if (src->adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
virBufferEscapeString(buf, " parent='%s'",
src->adapter.data.fchost.parent);
- virBufferAsprintf(buf," wwnn='%s' wwpn='%s'/>\n",
+ virBufferAsprintf(buf, " wwnn='%s' wwpn='%s'/>\n",
src->adapter.data.fchost.wwnn,
src->adapter.data.fchost.wwpn);
} else if (src->adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
- virBufferAsprintf(buf," name='%s'/>\n", src->adapter.data.name);
+ virBufferAsprintf(buf, " name='%s'/>\n", src->adapter.data.name);
}
}
if ((options->flags & VIR_STORAGE_POOL_SOURCE_NAME) &&
src->name)
- virBufferAsprintf(buf," <name>%s</name>\n", src->name);
+ virBufferAsprintf(buf, " <name>%s</name>\n", src->name);
if ((options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) &&
src->initiator.iqn) {
- virBufferAddLit(buf," <initiator>\n");
- virBufferEscapeString(buf," <iqn name='%s'/>\n", src->initiator.iqn);
- virBufferAddLit(buf," </initiator>\n");
+ virBufferAddLit(buf, " <initiator>\n");
+ virBufferEscapeString(buf, " <iqn name='%s'/>\n",
+ src->initiator.iqn);
+ virBufferAddLit(buf, " </initiator>\n");
}
if (options->formatToString) {
@@ -1123,40 +1124,40 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src->format);
return -1;
}
- virBufferAsprintf(buf," <format type='%s'/>\n", format);
+ virBufferAsprintf(buf, " <format type='%s'/>\n", format);
}
if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP ||
src->authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
- virBufferAsprintf(buf," <auth type='%s' username='%s'>\n",
+ virBufferAsprintf(buf, " <auth type='%s' username='%s'>\n",
virStoragePoolAuthTypeTypeToString(src->authType),
(src->authType == VIR_STORAGE_POOL_AUTH_CHAP ?
src->auth.chap.username :
src->auth.cephx.username));
- virBufferAddLit(buf," <secret");
+ virBufferAddLit(buf, " <secret");
if (src->auth.cephx.secret.uuidUsable) {
virUUIDFormat(src->auth.cephx.secret.uuid, uuid);
- virBufferAsprintf(buf," uuid='%s'", uuid);
+ virBufferAsprintf(buf, " uuid='%s'", uuid);
}
if (src->auth.cephx.secret.usage != NULL) {
- virBufferAsprintf(buf," usage='%s'", src->auth.cephx.secret.usage);
+ virBufferAsprintf(buf, " usage='%s'", src->auth.cephx.secret.usage);
}
- virBufferAddLit(buf,"/>\n");
+ virBufferAddLit(buf, "/>\n");
- virBufferAddLit(buf," </auth>\n");
+ virBufferAddLit(buf, " </auth>\n");
}
if (src->vendor != NULL) {
- virBufferEscapeString(buf," <vendor name='%s'/>\n", src->vendor);
+ virBufferEscapeString(buf, " <vendor name='%s'/>\n", src->vendor);
}
if (src->product != NULL) {
- virBufferEscapeString(buf," <product name='%s'/>\n", src->product);
+ virBufferEscapeString(buf, " <product name='%s'/>\n", src->product);
}
- virBufferAddLit(buf," </source>\n");
+ virBufferAddLit(buf, " </source>\n");
return 0;
}
@@ -1181,16 +1182,16 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
goto cleanup;
}
virBufferAsprintf(&buf, "<pool type='%s'>\n", type);
- virBufferAsprintf(&buf," <name>%s</name>\n", def->name);
+ virBufferAsprintf(&buf, " <name>%s</name>\n", def->name);
virUUIDFormat(def->uuid, uuid);
- virBufferAsprintf(&buf," <uuid>%s</uuid>\n", uuid);
+ virBufferAsprintf(&buf, " <uuid>%s</uuid>\n", uuid);
- virBufferAsprintf(&buf," <capacity unit='bytes'>%llu</capacity>\n",
+ virBufferAsprintf(&buf, " <capacity unit='bytes'>%llu</capacity>\n",
def->capacity);
- virBufferAsprintf(&buf," <allocation unit='bytes'>%llu</allocation>\n",
+ virBufferAsprintf(&buf, " <allocation unit='bytes'>%llu</allocation>\n",
def->allocation);
- virBufferAsprintf(&buf," <available unit='bytes'>%llu</available>\n",
+ virBufferAsprintf(&buf, " <available unit='bytes'>%llu</available>\n",
def->available);
if (virStoragePoolSourceFormat(&buf, options, &def->source) < 0)
@@ -1200,27 +1201,27 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
* doesn't have a target */
if (def->type != VIR_STORAGE_POOL_RBD &&
def->type != VIR_STORAGE_POOL_SHEEPDOG) {
- virBufferAddLit(&buf," <target>\n");
+ virBufferAddLit(&buf, " <target>\n");
if (def->target.path)
- virBufferAsprintf(&buf," <path>%s</path>\n", def->target.path);
+ virBufferAsprintf(&buf, " <path>%s</path>\n", def->target.path);
- virBufferAddLit(&buf," <permissions>\n");
- virBufferAsprintf(&buf," <mode>0%o</mode>\n",
+ virBufferAddLit(&buf, " <permissions>\n");
+ virBufferAsprintf(&buf, " <mode>0%o</mode>\n",
def->target.perms.mode);
- virBufferAsprintf(&buf," <owner>%d</owner>\n",
+ virBufferAsprintf(&buf, " <owner>%d</owner>\n",
(int) def->target.perms.uid);
- virBufferAsprintf(&buf," <group>%d</group>\n",
+ virBufferAsprintf(&buf, " <group>%d</group>\n",
(int) def->target.perms.gid);
if (def->target.perms.label)
- virBufferAsprintf(&buf," <label>%s</label>\n",
+ virBufferAsprintf(&buf, " <label>%s</label>\n",
def->target.perms.label);
- virBufferAddLit(&buf," </permissions>\n");
- virBufferAddLit(&buf," </target>\n");
+ virBufferAddLit(&buf, " </permissions>\n");
+ virBufferAddLit(&buf, " </target>\n");
}
- virBufferAddLit(&buf,"</pool>\n");
+ virBufferAddLit(&buf, "</pool>\n");
if (virBufferError(&buf))
goto no_memory;
@@ -1488,7 +1489,7 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferAsprintf(buf, " <%s>\n", type);
if (def->path)
- virBufferAsprintf(buf," <path>%s</path>\n", def->path);
+ virBufferAsprintf(buf, " <path>%s</path>\n", def->path);
if (options->formatToString) {
const char *format = (options->formatToString)(def->format);
@@ -1498,23 +1499,23 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
def->format);
return -1;
}
- virBufferAsprintf(buf," <format type='%s'/>\n", format);
+ virBufferAsprintf(buf, " <format type='%s'/>\n", format);
}
- virBufferAddLit(buf," <permissions>\n");
- virBufferAsprintf(buf," <mode>0%o</mode>\n",
+ virBufferAddLit(buf, " <permissions>\n");
+ virBufferAsprintf(buf, " <mode>0%o</mode>\n",
def->perms.mode);
- virBufferAsprintf(buf," <owner>%u</owner>\n",
+ virBufferAsprintf(buf, " <owner>%u</owner>\n",
(unsigned int) def->perms.uid);
- virBufferAsprintf(buf," <group>%u</group>\n",
+ virBufferAsprintf(buf, " <group>%u</group>\n",
(unsigned int) def->perms.gid);
if (def->perms.label)
- virBufferAsprintf(buf," <label>%s</label>\n",
+ virBufferAsprintf(buf, " <label>%s</label>\n",
def->perms.label);
- virBufferAddLit(buf," </permissions>\n");
+ virBufferAddLit(buf, " </permissions>\n");
if (def->timestamps) {
virBufferAddLit(buf, " <timestamps>\n");
@@ -1571,8 +1572,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
return NULL;
virBufferAddLit(&buf, "<volume>\n");
- virBufferAsprintf(&buf," <name>%s</name>\n", def->name);
- virBufferAsprintf(&buf," <key>%s</key>\n", NULLSTR(def->key));
+ virBufferAsprintf(&buf, " <name>%s</name>\n", def->name);
+ virBufferAsprintf(&buf, " <key>%s</key>\n", NULLSTR(def->key));
virBufferAddLit(&buf, " <source>\n");
if (def->source.nextent) {
@@ -1599,9 +1600,9 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
}
virBufferAddLit(&buf, " </source>\n");
- virBufferAsprintf(&buf," <capacity unit='bytes'>%llu</capacity>\n",
+ virBufferAsprintf(&buf, " <capacity unit='bytes'>%llu</capacity>\n",
def->capacity);
- virBufferAsprintf(&buf," <allocation unit='bytes'>%llu</allocation>\n",
+ virBufferAsprintf(&buf, " <allocation unit='bytes'>%llu</allocation>\n",
def->allocation);
if (virStorageVolTargetDefFormat(options, &buf,
@@ -1613,7 +1614,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
&def->backingStore, "backingStore") < 0)
goto cleanup;
- virBufferAddLit(&buf,"</volume>\n");
+ virBufferAddLit(&buf, "</volume>\n");
if (virBufferError(&buf))
goto no_memory;

View File

@ -1,572 +0,0 @@
From a947da33c35e07bb68829c68b0c7c95a002a1407 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Wed, 20 Nov 2013 17:04:05 -0700
Subject: [PATCH] storage: use valid XML for awkward volume names
$ touch /var/lib/libvirt/images/'a<b>c'
$ virsh pool-refresh default
$ virsh vol-dumpxml 'a<b>c' default | head -n2
<volume>
<name>a<b>c</name>
Oops. That's not valid XML. And when we fix the XML
generation, it fails RelaxNG validation.
I'm also tired of seeing <key>(null)</key> in the example
output for volume xml; while we used NULLSTR() to avoid
a NULL deref rather than relying on glibc's printf
extension behavior, it's even better if we avoid the issue
in the first place. But this requires being careful that
we don't invalidate any storage backends that were relying
on key being unassigned during virStoragVolCreateXML[From].
I would have split this into two patches (one for escaping,
one for avoiding <key>(null)</key>), but since they both
end up touching a lot of the same test files, I ended up
merging it into one.
Note that this patch allows pretty much any volume name
that can appear in a directory (excluding . and .. because
those are special), but does nothing to change the current
(unenforced) RelaxNG claim that pool names will consist
only of letters, numbers, _, -, and +. Tightening the C
code to match RelaxNG patterns and/or relaxing the grammar
to match the C code for pool names is a task for another
day (but remember, we DID recently tighten C code for
domain names to exclude a leading '.').
* src/conf/storage_conf.c (virStoragePoolSourceFormat)
(virStoragePoolDefFormat, virStorageVolTargetDefFormat)
(virStorageVolDefFormat): Escape user-controlled strings.
(virStorageVolDefParseXML): Parse key, for use in unit tests.
* src/storage/storage_driver.c (storageVolCreateXML)
(storageVolCreateXMLFrom): Ensure parsed key doesn't confuse
volume creation.
* docs/schemas/basictypes.rng (volName): Relax definition.
* tests/storagepoolxml2xmltest.c (mymain): Test it.
* tests/storagevolxml2xmltest.c (mymain): Likewise.
* tests/storagepoolxml2xmlin/pool-dir-naming.xml: New file.
* tests/storagepoolxml2xmlout/pool-dir-naming.xml: Likewise.
* tests/storagevolxml2xmlin/vol-file-naming.xml: Likewise.
* tests/storagevolxml2xmlout/vol-file-naming.xml: Likewise.
* tests/storagevolxml2xmlout/vol-*.xml: Fix fallout.
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 6cc4d6a3fe82653c607c4f159901790298e80e1f)
---
docs/schemas/basictypes.rng | 9 ++-
src/conf/storage_conf.c | 72 ++++++++++------------
src/storage/storage_driver.c | 8 ++-
tests/storagepoolxml2xmlin/pool-dir-naming.xml | 18 ++++++
tests/storagepoolxml2xmlout/pool-dir-naming.xml | 18 ++++++
tests/storagepoolxml2xmltest.c | 1 +
tests/storagevolxml2xmlin/vol-file-backing.xml | 1 +
tests/storagevolxml2xmlin/vol-file-naming.xml | 20 ++++++
tests/storagevolxml2xmlout/vol-file-backing.xml | 2 +-
tests/storagevolxml2xmlout/vol-file-naming.xml | 17 +++++
tests/storagevolxml2xmlout/vol-file.xml | 1 -
tests/storagevolxml2xmlout/vol-logical-backing.xml | 2 +-
tests/storagevolxml2xmlout/vol-logical.xml | 2 +-
tests/storagevolxml2xmlout/vol-partition.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-1.1.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-lazy.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2.xml | 2 +-
tests/storagevolxml2xmlout/vol-sheepdog.xml | 1 -
tests/storagevolxml2xmltest.c | 1 +
21 files changed, 132 insertions(+), 53 deletions(-)
create mode 100644 tests/storagepoolxml2xmlin/pool-dir-naming.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-dir-naming.xml
create mode 100644 tests/storagevolxml2xmlin/vol-file-naming.xml
create mode 100644 tests/storagevolxml2xmlout/vol-file-naming.xml
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 34c2254..48806fc 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -291,8 +291,15 @@
</define>
<define name='volName'>
+ <!-- directory pools allow almost any file name as a volume name -->
<data type='string'>
- <param name="pattern">[a-zA-Z0-9_\+\-\.]+</param>
+ <param name="pattern">[^/]+</param>
+ <except>
+ <choice>
+ <value>.</value>
+ <value>..</value>
+ </choice>
+ </except>
</data>
</define>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 33e4caf..8b378c2 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1056,7 +1056,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
virBufferAddLit(buf, " <source>\n");
if ((options->flags & VIR_STORAGE_POOL_SOURCE_HOST) && src->nhost) {
for (i = 0; i < src->nhost; i++) {
- virBufferAsprintf(buf, " <host name='%s'", src->hosts[i].name);
+ virBufferEscapeString(buf, " <host name='%s'",
+ src->hosts[i].name);
if (src->hosts[i].port)
virBufferAsprintf(buf, " port='%d'", src->hosts[i].port);
virBufferAddLit(buf, "/>\n");
@@ -1067,8 +1068,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src->ndevice) {
for (i = 0; i < src->ndevice; i++) {
if (src->devices[i].nfreeExtent) {
- virBufferAsprintf(buf, " <device path='%s'>\n",
- src->devices[i].path);
+ virBufferEscapeString(buf, " <device path='%s'>\n",
+ src->devices[i].path);
for (j = 0; j < src->devices[i].nfreeExtent; j++) {
virBufferAsprintf(buf, " <freeExtent start='%llu' end='%llu'/>\n",
src->devices[i].freeExtents[j].start,
@@ -1076,15 +1077,14 @@ virStoragePoolSourceFormat(virBufferPtr buf,
}
virBufferAddLit(buf, " </device>\n");
} else {
- virBufferAsprintf(buf, " <device path='%s'/>\n",
- src->devices[i].path);
+ virBufferEscapeString(buf, " <device path='%s'/>\n",
+ src->devices[i].path);
}
}
}
- if ((options->flags & VIR_STORAGE_POOL_SOURCE_DIR) &&
- src->dir)
- virBufferAsprintf(buf, " <dir path='%s'/>\n", src->dir);
+ if (options->flags & VIR_STORAGE_POOL_SOURCE_DIR)
+ virBufferEscapeString(buf, " <dir path='%s'/>\n", src->dir);
if ((options->flags & VIR_STORAGE_POOL_SOURCE_ADAPTER)) {
if (src->adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST ||
@@ -1104,9 +1104,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
}
}
- if ((options->flags & VIR_STORAGE_POOL_SOURCE_NAME) &&
- src->name)
- virBufferAsprintf(buf, " <name>%s</name>\n", src->name);
+ if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME)
+ virBufferEscapeString(buf, " <name>%s</name>\n", src->name);
if ((options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) &&
src->initiator.iqn) {
@@ -1129,11 +1128,12 @@ virStoragePoolSourceFormat(virBufferPtr buf,
if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP ||
src->authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
- virBufferAsprintf(buf, " <auth type='%s' username='%s'>\n",
- virStoragePoolAuthTypeTypeToString(src->authType),
- (src->authType == VIR_STORAGE_POOL_AUTH_CHAP ?
- src->auth.chap.username :
- src->auth.cephx.username));
+ virBufferAsprintf(buf, " <auth type='%s' ",
+ virStoragePoolAuthTypeTypeToString(src->authType));
+ virBufferEscapeString(buf, "username='%s'>\n",
+ (src->authType == VIR_STORAGE_POOL_AUTH_CHAP ?
+ src->auth.chap.username :
+ src->auth.cephx.username));
virBufferAddLit(buf, " <secret");
if (src->auth.cephx.secret.uuidUsable) {
@@ -1149,13 +1149,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
virBufferAddLit(buf, " </auth>\n");
}
- if (src->vendor != NULL) {
- virBufferEscapeString(buf, " <vendor name='%s'/>\n", src->vendor);
- }
-
- if (src->product != NULL) {
- virBufferEscapeString(buf, " <product name='%s'/>\n", src->product);
- }
+ virBufferEscapeString(buf, " <vendor name='%s'/>\n", src->vendor);
+ virBufferEscapeString(buf, " <product name='%s'/>\n", src->product);
virBufferAddLit(buf, " </source>\n");
@@ -1182,7 +1177,7 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
goto cleanup;
}
virBufferAsprintf(&buf, "<pool type='%s'>\n", type);
- virBufferAsprintf(&buf, " <name>%s</name>\n", def->name);
+ virBufferEscapeString(&buf, " <name>%s</name>\n", def->name);
virUUIDFormat(def->uuid, uuid);
virBufferAsprintf(&buf, " <uuid>%s</uuid>\n", uuid);
@@ -1203,8 +1198,7 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
def->type != VIR_STORAGE_POOL_SHEEPDOG) {
virBufferAddLit(&buf, " <target>\n");
- if (def->target.path)
- virBufferAsprintf(&buf, " <path>%s</path>\n", def->target.path);
+ virBufferEscapeString(&buf, " <path>%s</path>\n", def->target.path);
virBufferAddLit(&buf, " <permissions>\n");
virBufferAsprintf(&buf, " <mode>0%o</mode>\n",
@@ -1214,9 +1208,8 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
virBufferAsprintf(&buf, " <group>%d</group>\n",
(int) def->target.perms.gid);
- if (def->target.perms.label)
- virBufferAsprintf(&buf, " <label>%s</label>\n",
- def->target.perms.label);
+ virBufferEscapeString(&buf, " <label>%s</label>\n",
+ def->target.perms.label);
virBufferAddLit(&buf, " </permissions>\n");
virBufferAddLit(&buf, " </target>\n");
@@ -1282,8 +1275,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
goto error;
}
- /* Auto-generated so deliberately ignore */
- /* ret->key = virXPathString("string(./key)", ctxt); */
+ /* Normally generated by pool refresh, but useful for unit tests */
+ ret->key = virXPathString("string(./key)", ctxt);
capacity = virXPathString("string(./capacity)", ctxt);
unit = virXPathString("string(./capacity/@unit)", ctxt);
@@ -1485,11 +1478,11 @@ static int
virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferPtr buf,
virStorageVolTargetPtr def,
- const char *type) {
+ const char *type)
+{
virBufferAsprintf(buf, " <%s>\n", type);
- if (def->path)
- virBufferAsprintf(buf, " <path>%s</path>\n", def->path);
+ virBufferEscapeString(buf, " <path>%s</path>\n", def->path);
if (options->formatToString) {
const char *format = (options->formatToString)(def->format);
@@ -1511,8 +1504,7 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
(unsigned int) def->perms.gid);
- if (def->perms.label)
- virBufferAsprintf(buf, " <label>%s</label>\n",
+ virBufferEscapeString(buf, " <label>%s</label>\n",
def->perms.label);
virBufferAddLit(buf, " </permissions>\n");
@@ -1572,8 +1564,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
return NULL;
virBufferAddLit(&buf, "<volume>\n");
- virBufferAsprintf(&buf, " <name>%s</name>\n", def->name);
- virBufferAsprintf(&buf, " <key>%s</key>\n", NULLSTR(def->key));
+ virBufferEscapeString(&buf, " <name>%s</name>\n", def->name);
+ virBufferEscapeString(&buf, " <key>%s</key>\n", def->key);
virBufferAddLit(&buf, " <source>\n");
if (def->source.nextent) {
@@ -1585,8 +1577,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
if (thispath != NULL)
virBufferAddLit(&buf, " </device>\n");
- virBufferAsprintf(&buf, " <device path='%s'>\n",
- def->source.extents[i].path);
+ virBufferEscapeString(&buf, " <device path='%s'>\n",
+ def->source.extents[i].path);
}
virBufferAsprintf(&buf,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 6c39284..702a118 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1554,6 +1554,9 @@ storageVolCreateXML(virStoragePoolPtr obj,
goto cleanup;
}
+ /* Wipe any key the user may have suggested, as volume creation
+ * will generate the canonical key. */
+ VIR_FREE(voldef->key);
if (backend->createVol(obj->conn, pool, voldef) < 0) {
goto cleanup;
}
@@ -1729,7 +1732,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
pool->volumes.count+1) < 0)
goto cleanup;
- /* 'Define' the new volume so we get async progress reporting */
+ /* 'Define' the new volume so we get async progress reporting.
+ * Wipe any key the user may have suggested, as volume creation
+ * will generate the canonical key. */
+ VIR_FREE(newvol->key);
if (backend->createVol(obj->conn, pool, newvol) < 0) {
goto cleanup;
}
diff --git a/tests/storagepoolxml2xmlin/pool-dir-naming.xml b/tests/storagepoolxml2xmlin/pool-dir-naming.xml
new file mode 100644
index 0000000..aa043be
--- /dev/null
+++ b/tests/storagepoolxml2xmlin/pool-dir-naming.xml
@@ -0,0 +1,18 @@
+<pool type='dir'>
+ <name>virtimages</name>
+ <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
+ <capacity>0</capacity>
+ <allocation>0</allocation>
+ <available>0</available>
+ <source>
+ </source>
+ <target>
+ <path>///var/////lib/libvirt/&lt;images&gt;//</path>
+ <permissions>
+ <mode>0700</mode>
+ <owner>-1</owner>
+ <group>-1</group>
+ <label>some_label_t</label>
+ </permissions>
+ </target>
+</pool>
diff --git a/tests/storagepoolxml2xmlout/pool-dir-naming.xml b/tests/storagepoolxml2xmlout/pool-dir-naming.xml
new file mode 100644
index 0000000..536f58c
--- /dev/null
+++ b/tests/storagepoolxml2xmlout/pool-dir-naming.xml
@@ -0,0 +1,18 @@
+<pool type='dir'>
+ <name>virtimages</name>
+ <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid>
+ <capacity unit='bytes'>0</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <available unit='bytes'>0</available>
+ <source>
+ </source>
+ <target>
+ <path>/var/lib/libvirt/&lt;images&gt;</path>
+ <permissions>
+ <mode>0700</mode>
+ <owner>-1</owner>
+ <group>-1</group>
+ <label>some_label_t</label>
+ </permissions>
+ </target>
+</pool>
diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c
index d59cff9..c7159c6 100644
--- a/tests/storagepoolxml2xmltest.c
+++ b/tests/storagepoolxml2xmltest.c
@@ -85,6 +85,7 @@ mymain(void)
ret = -1
DO_TEST("pool-dir");
+ DO_TEST("pool-dir-naming");
DO_TEST("pool-fs");
DO_TEST("pool-logical");
DO_TEST("pool-logical-nopath");
diff --git a/tests/storagevolxml2xmlin/vol-file-backing.xml b/tests/storagevolxml2xmlin/vol-file-backing.xml
index d23349e..73e7f28 100644
--- a/tests/storagevolxml2xmlin/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-file-backing.xml
@@ -1,5 +1,6 @@
<volume>
<name>sparse.img</name>
+ <key>/var/lib/libvirt/images/sparse.img</key>
<source/>
<capacity unit='GB'>10</capacity>
<allocation unit='MiB'>0</allocation>
diff --git a/tests/storagevolxml2xmlin/vol-file-naming.xml b/tests/storagevolxml2xmlin/vol-file-naming.xml
new file mode 100644
index 0000000..9a33e2b
--- /dev/null
+++ b/tests/storagevolxml2xmlin/vol-file-naming.xml
@@ -0,0 +1,20 @@
+<volume>
+ <name>&lt;sparse&gt;.img</name>
+ <source/>
+ <capacity unit="TiB">1</capacity>
+ <allocation unit="bytes">0</allocation>
+ <target>
+ <path>/var/lib/libvirt/images/&lt;sparse&gt;.img</path>
+ <permissions>
+ <mode>0</mode>
+ <owner>0744</owner>
+ <group>0</group>
+ <label>virt_image_t</label>
+ </permissions>
+ <timestamps>
+ <atime>1341933637.273190990</atime>
+ <mtime>1341930622.047245868</mtime>
+ <ctime>1341930622.047245868</ctime>
+ </timestamps>
+ </target>
+</volume>
diff --git a/tests/storagevolxml2xmlout/vol-file-backing.xml b/tests/storagevolxml2xmlout/vol-file-backing.xml
index c0f152e..8d2fb57 100644
--- a/tests/storagevolxml2xmlout/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-file-backing.xml
@@ -1,6 +1,6 @@
<volume>
<name>sparse.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/sparse.img</key>
<source>
</source>
<capacity unit='bytes'>10000000000</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-file-naming.xml b/tests/storagevolxml2xmlout/vol-file-naming.xml
new file mode 100644
index 0000000..7022b02
--- /dev/null
+++ b/tests/storagevolxml2xmlout/vol-file-naming.xml
@@ -0,0 +1,17 @@
+<volume>
+ <name>&lt;sparse&gt;.img</name>
+ <source>
+ </source>
+ <capacity unit='bytes'>1099511627776</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <target>
+ <path>/var/lib/libvirt/images/&lt;sparse&gt;.img</path>
+ <format type='raw'/>
+ <permissions>
+ <mode>00</mode>
+ <owner>744</owner>
+ <group>0</group>
+ <label>virt_image_t</label>
+ </permissions>
+ </target>
+</volume>
diff --git a/tests/storagevolxml2xmlout/vol-file.xml b/tests/storagevolxml2xmlout/vol-file.xml
index a3d6473..b97dd50 100644
--- a/tests/storagevolxml2xmlout/vol-file.xml
+++ b/tests/storagevolxml2xmlout/vol-file.xml
@@ -1,6 +1,5 @@
<volume>
<name>sparse.img</name>
- <key>(null)</key>
<source>
</source>
<capacity unit='bytes'>1099511627776</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-logical-backing.xml b/tests/storagevolxml2xmlout/vol-logical-backing.xml
index 6b010e3..bf34b08 100644
--- a/tests/storagevolxml2xmlout/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-logical-backing.xml
@@ -1,6 +1,6 @@
<volume>
<name>Swap</name>
- <key>(null)</key>
+ <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
</source>
<capacity unit='bytes'>2080374784</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-logical.xml b/tests/storagevolxml2xmlout/vol-logical.xml
index 7bf309e..e9b4e4b 100644
--- a/tests/storagevolxml2xmlout/vol-logical.xml
+++ b/tests/storagevolxml2xmlout/vol-logical.xml
@@ -1,6 +1,6 @@
<volume>
<name>Swap</name>
- <key>(null)</key>
+ <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
</source>
<capacity unit='bytes'>2080374784</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-partition.xml b/tests/storagevolxml2xmlout/vol-partition.xml
index 271964f..9be1cf1 100644
--- a/tests/storagevolxml2xmlout/vol-partition.xml
+++ b/tests/storagevolxml2xmlout/vol-partition.xml
@@ -1,6 +1,6 @@
<volume>
<name>sda1</name>
- <key>(null)</key>
+ <key>/dev/sda1</key>
<source>
</source>
<capacity unit='bytes'>106896384</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
index a7b5fed..fd3d606 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
@@ -1,6 +1,6 @@
<volume>
<name>OtherDemo.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
<capacity unit='bytes'>5368709120</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
index b7df8a6..99fb5ac 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
@@ -1,6 +1,6 @@
<volume>
<name>OtherDemo.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
<capacity unit='bytes'>5368709120</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
index 92b7875..3708ea7 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
@@ -1,6 +1,6 @@
<volume>
<name>OtherDemo.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
<capacity unit='bytes'>5368709120</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
index e2da702..f6a2e21 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
@@ -1,6 +1,6 @@
<volume>
<name>OtherDemo.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
<capacity unit='bytes'>5368709120</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml
index f931a62..b9adcb4 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2.xml
@@ -1,6 +1,6 @@
<volume>
<name>OtherDemo.img</name>
- <key>(null)</key>
+ <key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
<capacity unit='bytes'>5368709120</capacity>
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml
index 2f19af8..bd5d6d8 100644
--- a/tests/storagevolxml2xmlout/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -1,6 +1,5 @@
<volume>
<name>test2</name>
- <key>(null)</key>
<source>
</source>
<capacity unit='bytes'>1024</capacity>
diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c
index 5b0a60b..d62c29f 100644
--- a/tests/storagevolxml2xmltest.c
+++ b/tests/storagevolxml2xmltest.c
@@ -110,6 +110,7 @@ mymain(void)
while (0);
DO_TEST("pool-dir", "vol-file");
+ DO_TEST("pool-dir", "vol-file-naming");
DO_TEST("pool-dir", "vol-file-backing");
DO_TEST("pool-dir", "vol-qcow2");
DO_TEST("pool-dir", "vol-qcow2-1.1");

View File

@ -1,135 +0,0 @@
From ddbaa2a562b53ec3eb99820217df4d721ebfdefe Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 10 Oct 2013 10:53:56 +0200
Subject: [PATCH] qemu: Introduce qemuDomainDefCheckABIStability
https://bugzilla.redhat.com/show_bug.cgi?id=994364
Whenever we check for ABI stability, we have new xml (e.g. provided by
user, or obtained from snapshot, whatever) which we compare to old xml
and see if ABI won't break. However, if the new xml was produced via
virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE) it lacks some
devices, e.g. 'pci-root' controller. Hence, the ABI stability check
fails even though it is stable. Moreover, we can't simply fix
virDomainDefCheckABIStability because removing the correct devices is
task for the driver. For instance, qemu driver wants to remove the usb
controller too, while LXC driver doesn't. That's why we need special
qemu wrapper over virDomainDefCheckABIStability which removes the
correct devices from domain XML, produces MIGRATABLE xml and calls the
check ABI stability function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 7d704812b9c50cd3804dd1e7f9e2ea3e75fdc847)
---
src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++
src/qemu/qemu_domain.h | 3 +++
src/qemu/qemu_driver.c | 10 ++--------
src/qemu/qemu_migration.c | 4 ++--
4 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 968e323..f3e2ba1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2342,3 +2342,25 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
priv->qemuDevices = aliases;
return 0;
}
+
+bool
+qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
+ virDomainDefPtr src,
+ virDomainDefPtr dst)
+{
+ virDomainDefPtr migratableDefSrc = NULL;
+ virDomainDefPtr migratableDefDst = NULL;
+ const int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE;
+ bool ret = false;
+
+ if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) ||
+ !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags)))
+ goto cleanup;
+
+ ret = virDomainDefCheckABIStability(migratableDefSrc, migratableDefDst);
+
+cleanup:
+ virDomainDefFree(migratableDefSrc);
+ virDomainDefFree(migratableDefDst);
+ return ret;
+}
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 04f08a3..77e0c20 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -369,4 +369,7 @@ extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
virDomainObjPtr vm);
+bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
+ virDomainDefPtr src,
+ virDomainDefPtr dst);
#endif /* __QEMU_DOMAIN_H__ */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 58be308..d7f92f4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3085,7 +3085,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
VIR_DOMAIN_XML_INACTIVE))) {
goto endjob;
}
- if (!virDomainDefCheckABIStability(vm->def, def)) {
+ if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) {
virDomainDefFree(def);
goto endjob;
}
@@ -13030,7 +13030,6 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
qemuDomainObjPrivatePtr priv;
int rc;
virDomainDefPtr config = NULL;
- virDomainDefPtr migratableDef = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL;
@@ -13147,11 +13146,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
/* Transitions 5, 6, 8, 9 */
/* Check for ABI compatibility. We need to do this check against
* the migratable XML or it will always fail otherwise */
- if (!(migratableDef = qemuDomainDefCopy(driver, vm->def,
- VIR_DOMAIN_XML_MIGRATABLE)))
- goto cleanup;
-
- if (config && !virDomainDefCheckABIStability(migratableDef, config)) {
+ if (config && !qemuDomainDefCheckABIStability(driver, vm->def, config)) {
virErrorPtr err = virGetLastError();
if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) {
@@ -13356,7 +13351,6 @@ cleanup:
}
if (vm)
virObjectUnlock(vm);
- virDomainDefFree(migratableDef);
virObjectUnref(caps);
virObjectUnref(cfg);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 58f90c2..2db5ed0 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2043,7 +2043,7 @@ static char
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
- if (!virDomainDefCheckABIStability(vm->def, def))
+ if (!qemuDomainDefCheckABIStability(driver, vm->def, def))
goto cleanup;
rv = qemuDomainDefFormatLive(driver, def, false, true);
@@ -2250,7 +2250,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if (!newdef)
goto cleanup;
- if (!virDomainDefCheckABIStability(*def, newdef)) {
+ if (!qemuDomainDefCheckABIStability(driver, *def, newdef)) {
virDomainDefFree(newdef);
goto cleanup;
}

View File

@ -366,8 +366,8 @@
Summary: Library providing a simple virtualization API
Name: libvirt
Version: 1.1.3.4
Release: 4%{?dist}%{?extra_release}
Version: 1.1.3.5
Release: 1%{?dist}%{?extra_release}
License: LGPLv2+
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@ -378,18 +378,6 @@ URL: http://libvirt.org/
%endif
Source: http://libvirt.org/sources/%{?mainturl}libvirt-%{version}.tar.gz
# Fix libvirt-guests.service on host boot (bz #1031696)
Patch0001: 0001-Add-Documentation-fields-to-systemd-service-files.patch
Patch0002: 0002-virSystemdCreateMachine-Set-dependencies-for-slices.patch
Patch0003: 0003-libvirt-guests-Wait-for-libvirtd-to-initialize.patch
Patch0004: 0004-virNetServerRun-Notify-systemd-that-we-re-accepting-.patch
# Escape XML characters in volume XML (bz #1074528)
Patch0005: 0005-maint-fix-comma-style-issues-conf.patch
Patch0006: 0006-storage-use-valid-XML-for-awkward-volume-names.patch
# Fix migration failure occurring with VIR_DOMAIN_XML_MIGRATABLE (bz
# #1075174)
Patch0007: 0007-qemu-Introduce-qemuDomainDefCheckABIStability.patch
%if %{with_libvirtd}
Requires: libvirt-daemon = %{version}-%{release}
%if %{with_network}
@ -1173,18 +1161,6 @@ of recent versions of Linux (and other OSes).
%prep
%setup -q
# Fix libvirt-guests.service on host boot (bz #1031696)
%patch0001 -p1
%patch0002 -p1
%patch0003 -p1
%patch0004 -p1
# Escape XML characters in volume XML (bz #1074528)
%patch0005 -p1
%patch0006 -p1
# Fix migration failure occurring with VIR_DOMAIN_XML_MIGRATABLE (bz
# #1075174)
%patch0007 -p1
%build
%if ! %{with_xen}
%define _without_xen --without-xen
@ -2142,6 +2118,14 @@ fi
%endif
%changelog
* Sat May 03 2014 Cole Robinson <crobinso@redhat.com> - 1.1.3.5-1
- Rebased to version 1.1.3.5
- Fix QXL PCI address conflict (bz #1016775)
- Fix journald PRIORITY values (bz #1043550)
- Fix crash with filterref and update-device (bz #1093301)
- Fix 'cannot find session' error with iscsi (bz #1093791)
- Fix bond XML issues (bz #1084702)
* Tue Mar 18 2014 Cole Robinson <crobinso@redhat.com> - 1.1.3.4-4
- Fix migration failure occurring with VIR_DOMAIN_XML_MIGRATABLE (bz #1075174)

View File

@ -1 +1 @@
7242049e67b1ee5614c7cdbddfc8ff92 libvirt-1.1.3.4.tar.gz
e3faa36a48acc7070b2158c9abee7ffd libvirt-1.1.3.5.tar.gz