[libvirt] [PATCH 0/2] Fixes for Mac OS X
by Ryota Ozaki
These patches enable libvirtd to run on Mac OS X.
We still cannot build libvirtd from libvirt git repository
due to a prcgen problem(*) though, we can build with libvirt
tarballs, that means that we can use libvirtd installed by
HomeBrew.
(*) https://www.redhat.com/archives/libvirt-users/2013-February/msg00033.html
I tested the patches on Mac OS X 10.8.5.
Ryota Ozaki (2):
rpc: fix getsockopt for LOCAL_PEERCRED on Mac OS X
nodeinfo: make freebsdNodeGetCPUCount work on Mac OS X
src/nodeinfo.c | 15 ++++++++++++---
src/rpc/virnetsocket.c | 4 ++++
2 files changed, 16 insertions(+), 3 deletions(-)
--
1.8.4
11 years, 2 months
[libvirt] [PATCH] build: fix build on 32-bit platforms
by Eric Blake
qemumonitorjsontest.c: In function 'testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo':
qemumonitorjsontest.c:1134: warning: integer constant is too large for 'long' type
* tests/qemumonitorjsontest.c
(testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo)
(testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo): Use correct
type.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
tests/qemumonitorjsontest.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 026beee..cd83592 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -1131,7 +1131,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBalloonInfo(const void *data)
if (qemuMonitorJSONGetBalloonInfo(qemuMonitorTestGetMonitor(test), &currmem) < 0)
goto cleanup;
- if (currmem != (4294967296/1024)) {
+ if (currmem != (4294967296ULL/1024)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"Unexpected currmem value: %llu", currmem);
goto cleanup;
@@ -1389,7 +1389,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockStatsInfo(const void *data)
&extent) < 0)
goto cleanup;
- if (extent != 5256018944) {
+ if (extent != 5256018944ULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"Invalid extent: %llu, expected 5256018944",
extent);
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] build: fix build on RHEL 5
by Eric Blake
On RHEL 5, compilation fails with:
storage/storage_backend.c: In function 'createRawFile':
storage/storage_backend.c:339: warning: implicit declaration of function 'fallocate'
storage/storage_backend.c:339: warning: nested extern declaration of 'fallocate' [-Wnested-externs]
But:
$ grep HAVE_FALLOCATE config.h
/* #undef HAVE_FALLOCATE */
Huh? It turns out that in kernels that old, fallocate() is not
implemented (config.h is correct), but <linux/fs.h> defines
HAVE_FALLOCATE as an empty witness macro for a completely
different purpose. Since storage_backend.c is including
<linux/fs.h> on RHEL 5, we are hosed by the kernel definition.
Newer kernels no longer pollute the namespace, and it's fairly
easy to convert to an expression that works with both the old
kernel witness and the new-style config.h (undefined or 1).
Problem introduced in commit 532fef3.
* src/storage/storage_backend.c (createRawFile): Avoid namespace
pollution from kernel, by checking HAVE_FALLOCATE for a value.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
src/storage/storage_backend.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 5f1bc66..662af32 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -329,7 +329,8 @@ createRawFile(int fd, virStorageVolDefPtr vol,
goto cleanup;
}
-#ifdef HAVE_FALLOCATE
+/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
+#if HAVE_FALLOCATE - 0
/* Try to preallocate all requested disk space, but fall back to
* other methods if this fails with ENOSYS or EOPNOTSUPP.
* NOTE: do not use posix_fallocate; posix_fallocate falls back
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] build: fix build --without-remote
by Eric Blake
I tried to test ./configure --without-lxc --without-remote.
First, the build failed with some odd errors, such as an
inability to build xen, or link failures for virNetTLSInit.
But when you think about it, once there is no remote code,
all of libvirtd is useless, any stateful driver that depends
on libvirtd is also not worth compiling, and any libraries
used only by RPC code are not needed. So I patched
configure.ac to make for some saner defaults when an
explicit disable is attempted. Similarly, since we have
migrated virnetdevbridge into generic code, the workaround
for Linux kernel stupidity must not depend on stateful
drivers being in use.
Then there's 'make check' that needs segragation.
Wow - quite a bit of cleanup to make --without-remote useful :)
* configure.ac: Let --without-remote toggle defaults on stateful
drivers and other libraries. Pick up Linux kernel workarounds
even when qemu and lxc are not being compiled.
* tests/Makefile.am (test_programs): Factor out programs that
require remote.
* src/libvirt_private.syms (rpc/virnet*.h): Move...
* src/libvirt_remote.syms: ...into new file.
* src/Makefile.am (SYM_FILES): Ship new syms file.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Looks big, but most of it is motion of text from splitting a file.
It fixes a build failure, but --enable-remote is not a regression
for this particular release (it's been broken for a while), so I'll
wait for a review even if it misses 1.1.3.
configure.ac | 16 +++-
src/Makefile.am | 6 ++
src/libvirt_private.syms | 199 --------------------------------------------
src/libvirt_remote.syms | 210 +++++++++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 19 +++--
5 files changed, 243 insertions(+), 207 deletions(-)
create mode 100644 src/libvirt_remote.syms
diff --git a/configure.ac b/configure.ac
index 553015a..b82dc8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,8 +198,22 @@ fi
AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"])
AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" = "yes"])
+# The daemon requires remote support. Likewise, if we are not using
+# RPC, we don't need several libraries.
+if test "$with_remote" = "no" ; then
+ with_libvirtd=no
+ with_gnutls=no
+ with_ssh2=no
+ with_sasl=no
+fi
+# Stateful drivers are useful only when building the daemon.
if test "$with_libvirtd" = "no" ; then
with_qemu=no
+ with_xen=no
+ with_lxc=no
+ with_libxl=no
+ with_uml=no
+ with_vbox=no
fi
# Check for compiler and library settings.
@@ -1053,7 +1067,6 @@ dnl
dnl check for kernel headers required by src/bridge.c
dnl
if test "$with_linux" = "yes"; then
- if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then
# Various kernel versions have headers that are not self-standing, but
# yet are incompatible with the corresponding glibc headers. In order
# to guarantee compilation across a wide range of versions (from RHEL 5
@@ -1087,7 +1100,6 @@ if test "$with_linux" = "yes"; then
#endif
#include <linux/in6.h>
]])
- fi
fi
diff --git a/src/Makefile.am b/src/Makefile.am
index 8632b18..201c268 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1756,6 +1756,12 @@ else ! WITH_LIBVIRTD
SYM_FILES += $(srcdir)/libvirt_daemon.syms
endif ! WITH_LIBVIRTD
+if WITH_REMOTE
+USED_SYM_FILES += $(srcdir)/libvirt_remote.syms
+else ! WITH_REMOTE
+SYM_FILES += $(srcdir)/libvirt_remote.syms
+endif ! WITH_REMOTE
+
if WITH_OPENVZ
USED_SYM_FILES += $(srcdir)/libvirt_openvz.syms
else ! WITH_OPENVZ
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 48e4b04..62aab9b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -831,205 +831,6 @@ nodeGetMemoryStats;
nodeSetMemoryParameters;
-# rpc/virnetclient.h
-virNetClientAddProgram;
-virNetClientAddStream;
-virNetClientClose;
-virNetClientDupFD;
-virNetClientGetFD;
-virNetClientHasPassFD;
-virNetClientIsEncrypted;
-virNetClientIsOpen;
-virNetClientKeepAliveIsSupported;
-virNetClientKeepAliveStart;
-virNetClientKeepAliveStop;
-virNetClientLocalAddrString;
-virNetClientNewExternal;
-virNetClientNewLibSSH2;
-virNetClientNewSSH;
-virNetClientNewTCP;
-virNetClientNewUNIX;
-virNetClientRegisterAsyncIO;
-virNetClientRegisterKeepAlive;
-virNetClientRemoteAddrString;
-virNetClientRemoveStream;
-virNetClientSendNonBlock;
-virNetClientSendNoReply;
-virNetClientSendWithReply;
-virNetClientSendWithReplyStream;
-virNetClientSetCloseCallback;
-
-
-# rpc/virnetclientprogram.h
-virNetClientProgramCall;
-virNetClientProgramDispatch;
-virNetClientProgramGetProgram;
-virNetClientProgramGetVersion;
-virNetClientProgramMatches;
-virNetClientProgramNew;
-
-
-# rpc/virnetclientstream.h
-virNetClientStreamEOF;
-virNetClientStreamEventAddCallback;
-virNetClientStreamEventRemoveCallback;
-virNetClientStreamEventUpdateCallback;
-virNetClientStreamMatches;
-virNetClientStreamNew;
-virNetClientStreamQueuePacket;
-virNetClientStreamRaiseError;
-virNetClientStreamRecvPacket;
-virNetClientStreamSendPacket;
-virNetClientStreamSetError;
-
-
-# rpc/virnetmessage.h
-virNetMessageClear;
-virNetMessageDecodeHeader;
-virNetMessageDecodeLength;
-virNetMessageDecodeNumFDs;
-virNetMessageDecodePayload;
-virNetMessageDupFD;
-virNetMessageEncodeHeader;
-virNetMessageEncodeNumFDs;
-virNetMessageEncodePayload;
-virNetMessageEncodePayloadRaw;
-virNetMessageFree;
-virNetMessageNew;
-virNetMessageQueuePush;
-virNetMessageQueueServe;
-virNetMessageSaveError;
-xdr_virNetMessageError;
-
-
-# rpc/virnetserver.h
-virNetServerAddProgram;
-virNetServerAddService;
-virNetServerAddShutdownInhibition;
-virNetServerAddSignalHandler;
-virNetServerAutoShutdown;
-virNetServerClose;
-virNetServerIsPrivileged;
-virNetServerKeepAliveRequired;
-virNetServerNew;
-virNetServerNewPostExecRestart;
-virNetServerPreExecRestart;
-virNetServerQuit;
-virNetServerRemoveShutdownInhibition;
-virNetServerRun;
-virNetServerUpdateServices;
-
-
-# rpc/virnetserverclient.h
-virNetServerClientAddFilter;
-virNetServerClientClose;
-virNetServerClientDelayedClose;
-virNetServerClientGetAuth;
-virNetServerClientGetFD;
-virNetServerClientGetIdentity;
-virNetServerClientGetPrivateData;
-virNetServerClientGetReadonly;
-virNetServerClientGetSELinuxContext;
-virNetServerClientGetUNIXIdentity;
-virNetServerClientImmediateClose;
-virNetServerClientInit;
-virNetServerClientInitKeepAlive;
-virNetServerClientIsClosed;
-virNetServerClientIsLocal;
-virNetServerClientIsSecure;
-virNetServerClientLocalAddrString;
-virNetServerClientNeedAuth;
-virNetServerClientNew;
-virNetServerClientNewPostExecRestart;
-virNetServerClientPreExecRestart;
-virNetServerClientRemoteAddrString;
-virNetServerClientRemoveFilter;
-virNetServerClientSendMessage;
-virNetServerClientSetAuth;
-virNetServerClientSetCloseHook;
-virNetServerClientSetDispatcher;
-virNetServerClientStartKeepAlive;
-virNetServerClientWantClose;
-
-
-# rpc/virnetservermdns.h
-virNetServerMDNSAddEntry;
-virNetServerMDNSAddGroup;
-virNetServerMDNSEntryFree;
-virNetServerMDNSFree;
-virNetServerMDNSGroupFree;
-virNetServerMDNSNew;
-virNetServerMDNSRemoveEntry;
-virNetServerMDNSRemoveGroup;
-virNetServerMDNSStart;
-virNetServerMDNSStop;
-
-
-# rpc/virnetserverprogram.h
-virNetServerProgramDispatch;
-virNetServerProgramGetID;
-virNetServerProgramGetPriority;
-virNetServerProgramGetVersion;
-virNetServerProgramMatches;
-virNetServerProgramNew;
-virNetServerProgramSendReplyError;
-virNetServerProgramSendStreamData;
-virNetServerProgramSendStreamError;
-virNetServerProgramUnknownError;
-
-
-# rpc/virnetserverservice.h
-virNetServerServiceClose;
-virNetServerServiceGetAuth;
-virNetServerServiceGetMaxRequests;
-virNetServerServiceGetPort;
-virNetServerServiceIsReadonly;
-virNetServerServiceNewFD;
-virNetServerServiceNewPostExecRestart;
-virNetServerServiceNewTCP;
-virNetServerServiceNewUNIX;
-virNetServerServicePreExecRestart;
-virNetServerServiceSetDispatcher;
-virNetServerServiceToggle;
-
-
-# rpc/virnetsocket.h
-virNetSocketAccept;
-virNetSocketAddIOCallback;
-virNetSocketClose;
-virNetSocketDupFD;
-virNetSocketGetFD;
-virNetSocketGetPort;
-virNetSocketGetSELinuxContext;
-virNetSocketGetUNIXIdentity;
-virNetSocketHasCachedData;
-virNetSocketHasPassFD;
-virNetSocketHasPendingData;
-virNetSocketIsLocal;
-virNetSocketListen;
-virNetSocketLocalAddrString;
-virNetSocketNewConnectCommand;
-virNetSocketNewConnectExternal;
-virNetSocketNewConnectLibSSH2;
-virNetSocketNewConnectSockFD;
-virNetSocketNewConnectSSH;
-virNetSocketNewConnectTCP;
-virNetSocketNewConnectUNIX;
-virNetSocketNewListenFD;
-virNetSocketNewListenTCP;
-virNetSocketNewListenUNIX;
-virNetSocketNewPostExecRestart;
-virNetSocketPreExecRestart;
-virNetSocketRead;
-virNetSocketRecvFD;
-virNetSocketRemoteAddrString;
-virNetSocketRemoveIOCallback;
-virNetSocketSendFD;
-virNetSocketSetBlocking;
-virNetSocketUpdateIOCallback;
-virNetSocketWrite;
-
-
# security/security_driver.h
virSecurityDriverLookup;
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
new file mode 100644
index 0000000..d482a55
--- /dev/null
+++ b/src/libvirt_remote.syms
@@ -0,0 +1,210 @@
+#
+# Private symbols used in RPC operations. Add symbols here, and see
+# Makefile.am for more details.
+#
+# Keep this file sorted by header name, then by symbols with each header.
+#
+
+# rpc/virnetclient.h
+virNetClientAddProgram;
+virNetClientAddStream;
+virNetClientClose;
+virNetClientDupFD;
+virNetClientGetFD;
+virNetClientHasPassFD;
+virNetClientIsEncrypted;
+virNetClientIsOpen;
+virNetClientKeepAliveIsSupported;
+virNetClientKeepAliveStart;
+virNetClientKeepAliveStop;
+virNetClientLocalAddrString;
+virNetClientNewExternal;
+virNetClientNewLibSSH2;
+virNetClientNewSSH;
+virNetClientNewTCP;
+virNetClientNewUNIX;
+virNetClientRegisterAsyncIO;
+virNetClientRegisterKeepAlive;
+virNetClientRemoteAddrString;
+virNetClientRemoveStream;
+virNetClientSendNonBlock;
+virNetClientSendNoReply;
+virNetClientSendWithReply;
+virNetClientSendWithReplyStream;
+virNetClientSetCloseCallback;
+
+
+# rpc/virnetclientprogram.h
+virNetClientProgramCall;
+virNetClientProgramDispatch;
+virNetClientProgramGetProgram;
+virNetClientProgramGetVersion;
+virNetClientProgramMatches;
+virNetClientProgramNew;
+
+
+# rpc/virnetclientstream.h
+virNetClientStreamEOF;
+virNetClientStreamEventAddCallback;
+virNetClientStreamEventRemoveCallback;
+virNetClientStreamEventUpdateCallback;
+virNetClientStreamMatches;
+virNetClientStreamNew;
+virNetClientStreamQueuePacket;
+virNetClientStreamRaiseError;
+virNetClientStreamRecvPacket;
+virNetClientStreamSendPacket;
+virNetClientStreamSetError;
+
+
+# rpc/virnetmessage.h
+virNetMessageClear;
+virNetMessageDecodeHeader;
+virNetMessageDecodeLength;
+virNetMessageDecodeNumFDs;
+virNetMessageDecodePayload;
+virNetMessageDupFD;
+virNetMessageEncodeHeader;
+virNetMessageEncodeNumFDs;
+virNetMessageEncodePayload;
+virNetMessageEncodePayloadRaw;
+virNetMessageFree;
+virNetMessageNew;
+virNetMessageQueuePush;
+virNetMessageQueueServe;
+virNetMessageSaveError;
+xdr_virNetMessageError;
+
+
+# rpc/virnetserver.h
+virNetServerAddProgram;
+virNetServerAddService;
+virNetServerAddShutdownInhibition;
+virNetServerAddSignalHandler;
+virNetServerAutoShutdown;
+virNetServerClose;
+virNetServerIsPrivileged;
+virNetServerKeepAliveRequired;
+virNetServerNew;
+virNetServerNewPostExecRestart;
+virNetServerPreExecRestart;
+virNetServerQuit;
+virNetServerRemoveShutdownInhibition;
+virNetServerRun;
+virNetServerUpdateServices;
+
+
+# rpc/virnetserverclient.h
+virNetServerClientAddFilter;
+virNetServerClientClose;
+virNetServerClientDelayedClose;
+virNetServerClientGetAuth;
+virNetServerClientGetFD;
+virNetServerClientGetIdentity;
+virNetServerClientGetPrivateData;
+virNetServerClientGetReadonly;
+virNetServerClientGetSELinuxContext;
+virNetServerClientGetUNIXIdentity;
+virNetServerClientImmediateClose;
+virNetServerClientInit;
+virNetServerClientInitKeepAlive;
+virNetServerClientIsClosed;
+virNetServerClientIsLocal;
+virNetServerClientIsSecure;
+virNetServerClientLocalAddrString;
+virNetServerClientNeedAuth;
+virNetServerClientNew;
+virNetServerClientNewPostExecRestart;
+virNetServerClientPreExecRestart;
+virNetServerClientRemoteAddrString;
+virNetServerClientRemoveFilter;
+virNetServerClientSendMessage;
+virNetServerClientSetAuth;
+virNetServerClientSetCloseHook;
+virNetServerClientSetDispatcher;
+virNetServerClientStartKeepAlive;
+virNetServerClientWantClose;
+
+
+# rpc/virnetservermdns.h
+virNetServerMDNSAddEntry;
+virNetServerMDNSAddGroup;
+virNetServerMDNSEntryFree;
+virNetServerMDNSFree;
+virNetServerMDNSGroupFree;
+virNetServerMDNSNew;
+virNetServerMDNSRemoveEntry;
+virNetServerMDNSRemoveGroup;
+virNetServerMDNSStart;
+virNetServerMDNSStop;
+
+
+# rpc/virnetserverprogram.h
+virNetServerProgramDispatch;
+virNetServerProgramGetID;
+virNetServerProgramGetPriority;
+virNetServerProgramGetVersion;
+virNetServerProgramMatches;
+virNetServerProgramNew;
+virNetServerProgramSendReplyError;
+virNetServerProgramSendStreamData;
+virNetServerProgramSendStreamError;
+virNetServerProgramUnknownError;
+
+
+# rpc/virnetserverservice.h
+virNetServerServiceClose;
+virNetServerServiceGetAuth;
+virNetServerServiceGetMaxRequests;
+virNetServerServiceGetPort;
+virNetServerServiceIsReadonly;
+virNetServerServiceNewFD;
+virNetServerServiceNewPostExecRestart;
+virNetServerServiceNewTCP;
+virNetServerServiceNewUNIX;
+virNetServerServicePreExecRestart;
+virNetServerServiceSetDispatcher;
+virNetServerServiceToggle;
+
+
+# rpc/virnetsocket.h
+virNetSocketAccept;
+virNetSocketAddIOCallback;
+virNetSocketClose;
+virNetSocketDupFD;
+virNetSocketGetFD;
+virNetSocketGetPort;
+virNetSocketGetSELinuxContext;
+virNetSocketGetUNIXIdentity;
+virNetSocketHasCachedData;
+virNetSocketHasPassFD;
+virNetSocketHasPendingData;
+virNetSocketIsLocal;
+virNetSocketListen;
+virNetSocketLocalAddrString;
+virNetSocketNewConnectCommand;
+virNetSocketNewConnectExternal;
+virNetSocketNewConnectLibSSH2;
+virNetSocketNewConnectSockFD;
+virNetSocketNewConnectSSH;
+virNetSocketNewConnectTCP;
+virNetSocketNewConnectUNIX;
+virNetSocketNewListenFD;
+virNetSocketNewListenTCP;
+virNetSocketNewListenUNIX;
+virNetSocketNewPostExecRestart;
+virNetSocketPreExecRestart;
+virNetSocketRead;
+virNetSocketRecvFD;
+virNetSocketRemoteAddrString;
+virNetSocketRemoveIOCallback;
+virNetSocketSendFD;
+virNetSocketSetBlocking;
+virNetSocketUpdateIOCallback;
+virNetSocketWrite;
+
+
+# Let emacs know we want case-insensitive sorting
+# Local Variables:
+# sort-fold-case: t
+# End:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 17a2a72..9a6453b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -114,8 +114,8 @@ test_helpers = commandhelper ssh test_conf
test_programs = virshtest sockettest \
nodeinfotest virbuftest \
commandtest seclabeltest \
- virhashtest virnetmessagetest virnetsockettest \
- viratomictest virnetserverclienttest \
+ virhashtest \
+ viratomictest \
utiltest shunloadtest \
virtimetest viruritest virkeyfiletest \
virauthconfigtest \
@@ -131,6 +131,17 @@ test_programs = virshtest sockettest \
virstoragetest \
$(NULL)
+if WITH_REMOTE
+test_programs += \
+ virnetmessagetest \
+ virnetsockettest \
+ virnetserverclienttest \
+ $(NULL)
+if WITH_GNUTLS
+test_programs += virnettlscontexttest virnettlssessiontest
+endif WITH_GNUTLS
+endif WITH_REMOTE
+
if WITH_LINUX
test_programs += fchosttest
endif WITH_LINUX
@@ -144,10 +155,6 @@ test_programs += virdbustest \
virsystemdtest
endif WITH_DBUS
-if WITH_GNUTLS
-test_programs += virnettlscontexttest virnettlssessiontest
-endif WITH_GNUTLS
-
if WITH_SECDRIVER_SELINUX
if WITH_ATTR
test_programs += securityselinuxtest
--
1.8.3.1
11 years, 2 months
[libvirt] Second pass at patch to get different SELinux Labels for virt-sandbox
by Dan Walsh
selinux-policy-3.12.1-87.fc21
selinux-policy-3.12.1-87.fc20
Now have lxc_contexts files that look like
> cat /etc/selinux/targeted/contexts/lxc_contexts
lxc=system_u:system_r:svirt_lxc_net_t:s0
qemu=system_u:system_r:svirt_qemu_net_t:s0
kvm=system_u:system_r:svirt_qemu_net_t:s0
process=system_u:system_r:svirt_lxc_net_t:s0
file=system_u:object_r:svirt_sandbox_file_t:s0
content=system_u:object_r:virt_var_lib_t:s0
[sandbox PATCH] virt-sandbox patch to launch containers with proper
11 years, 2 months
[libvirt] [PATCH] docs: aclpolkit: Fix a heading typo
by Cole Robinson
---
docs/aclpolkit.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/aclpolkit.html.in b/docs/aclpolkit.html.in
index 1a09139..91b5296 100644
--- a/docs/aclpolkit.html.in
+++ b/docs/aclpolkit.html.in
@@ -303,7 +303,7 @@
</p>
- <h2><a name="checks">Writing acces control policies</a></h2>
+ <h2><a name="checks">Writing access control policies</a></h2>
<p>
If using versions of polkit prior to 0.106 then it is only
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] storage: fix file allocation behavior in file cloning
by Oskari Saarenmaa
Fixed the safezero call for allocating the rest of the file after cloning
an existing volume; it used to always use a zero offset, causing it to
only allocate the beginning of the file.
Also modified file creation to try to use fallocate(2) to pre-allocate
disk space before copying any data to make sure it fails early on if disk
is full and makes sure we can skip zero blocks when copying file contents.
If fallocate isn't available we will zero out the rest of the file after
cloning and only use sparse cloning if client requested a lower allocation
than the input volume's capacity.
Signed-off-by: Oskari Saarenmaa <os(a)ohmu.fi>
---
the safezero mmap issue fixed in my previous patch never showed up because
all safezero calls previously had 0 offset (or maybe everyone's using
posix_fallocate)
configure.ac | 8 ++++----
src/storage/storage_backend.c | 35 ++++++++++++++++++++++++++++++-----
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 553015a..220d95b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,10 +253,10 @@ AC_CHECK_SIZEOF([long])
dnl Availability of various common functions (non-fatal if missing),
dnl and various less common threadsafe functions
-AC_CHECK_FUNCS_ONCE([cfmakeraw geteuid getgid getgrnam_r getmntent_r \
- getpwuid_r getuid kill mmap newlocale posix_fallocate posix_memalign \
- prlimit regexec sched_getaffinity setgroups setns setrlimit symlink \
- sysctlbyname])
+AC_CHECK_FUNCS_ONCE([cfmakeraw fallocate geteuid getgid getgrnam_r \
+ getmntent_r getpwuid_r getuid kill mmap newlocale posix_fallocate \
+ posix_memalign prlimit regexec sched_getaffinity setgroups setns \
+ setrlimit symlink sysctlbyname])
dnl Availability of pthread functions (if missing, win32 threading is
dnl assumed). Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index b7edf85..5f1bc66 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -129,7 +129,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
int fd,
unsigned long long *total,
- int is_dest_file)
+ int want_sparse)
{
int inputfd = -1;
int amtread = -1;
@@ -191,7 +191,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
interval = ((wbytes > amtleft) ? amtleft : wbytes);
int offset = amtread - amtleft;
- if (is_dest_file && memcmp(buf+offset, zerobuf, interval) == 0) {
+ if (want_sparse && memcmp(buf+offset, zerobuf, interval) == 0) {
if (lseek(fd, interval, SEEK_CUR) < 0) {
ret = -errno;
virReportSystemError(errno,
@@ -315,6 +315,7 @@ static int
createRawFile(int fd, virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol)
{
+ int need_alloc = 1;
int ret = 0;
unsigned long long remain;
@@ -328,17 +329,41 @@ createRawFile(int fd, virStorageVolDefPtr vol,
goto cleanup;
}
+#ifdef HAVE_FALLOCATE
+ /* Try to preallocate all requested disk space, but fall back to
+ * other methods if this fails with ENOSYS or EOPNOTSUPP.
+ * NOTE: do not use posix_fallocate; posix_fallocate falls back
+ * to writing zeroes block by block in case fallocate isn't
+ * available, and since we're going to copy data from another
+ * file it doesn't make sense to write the file twice. */
+ if (fallocate(fd, 0, 0, vol->allocation) == 0) {
+ need_alloc = 0;
+ } else if (errno != ENOSYS && errno != EOPNOTSUPP) {
+ ret = -errno;
+ virReportSystemError(errno,
+ _("cannot allocate %llu bytes in file '%s'"),
+ vol->allocation, vol->target.path);
+ goto cleanup;
+ }
+#endif
+
remain = vol->allocation;
if (inputvol) {
- ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, 1);
+ /* allow zero blocks to be skipped if we've requested sparse
+ * allocation (allocation < capacity) or we have already
+ * been able to allocate the required space. */
+ int want_sparse = (need_alloc == 0) ||
+ (vol->allocation < inputvol->capacity);
+
+ ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
if (ret < 0) {
goto cleanup;
}
}
- if (remain) {
- if (safezero(fd, 0, remain) < 0) {
+ if (remain && need_alloc) {
+ if (safezero(fd, vol->allocation - remain, remain) < 0) {
ret = -errno;
virReportSystemError(errno, _("cannot fill file '%s'"),
vol->target.path);
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] virfile: safezero: fall back to writing block by block if mmap fails
by Oskari Saarenmaa
mmap can fail on 32-bit systems if we're trying to zero out a lot of data.
Fall back to using block-by-block writing in that case. While we could map
smaller blocks it's unlikely that this code is used a lot and its easier to
just fall back to one of the existing methods.
Also modified the block-by-block zeroing to not allocate a megabyte of
zeroes if we're writing less than that.
Signed-off-by: Oskari Saarenmaa <os(a)ohmu.fi>
---
src/util/virfile.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 16f8101..f662127 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1032,16 +1032,18 @@ safezero(int fd, off_t offset, off_t len)
errno = ret;
return -1;
}
+
#else
-# ifdef HAVE_MMAP
int
safezero(int fd, off_t offset, off_t len)
{
- static long pagemask = 0;
- off_t map_skip;
int r;
char *buf;
+ unsigned long long remain, bytes;
+# ifdef HAVE_MMAP
+ static long pagemask = 0;
+ off_t map_skip;
/* align offset and length, rounding offset down and length up */
if (pagemask == 0)
@@ -1057,30 +1059,23 @@ safezero(int fd, off_t offset, off_t len)
buf = mmap(NULL, len + map_skip, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, offset - map_skip);
- if (buf == MAP_FAILED)
- return -1;
+ if (buf != MAP_FAILED) {
+ memset(buf + map_skip, 0, len);
+ munmap(buf, len + map_skip);
- memset(buf + map_skip, 0, len);
- munmap(buf, len + map_skip);
-
- return 0;
-}
-
-# else /* HAVE_MMAP */
+ return 0;
+ }
-int
-safezero(int fd, off_t offset, off_t len)
-{
- int r;
- char *buf;
- unsigned long long remain, bytes;
+ /* fall back to writing zeroes using safewrite if mmap fails (for
+ * example because of virtual memory limits) */
+# endif /* HAVE_MMAP */
if (lseek(fd, offset, SEEK_SET) < 0)
return -1;
/* Split up the write in small chunks so as not to allocate lots of RAM */
remain = len;
- bytes = 1024 * 1024;
+ bytes = MAX(1024 * 1024, len);
r = VIR_ALLOC_N(buf, bytes);
if (r < 0) {
@@ -1104,7 +1099,6 @@ safezero(int fd, off_t offset, off_t len)
VIR_FREE(buf);
return 0;
}
-# endif /* HAVE_MMAP */
#endif /* HAVE_POSIX_FALLOCATE */
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH v2] test: Fix coverity warnings
by Cole Robinson
---
v2:
Address Eric's suggestion
Address additional coverity warnings pointed out by John
src/test/test_driver.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 255cc2b..c2e530e 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -6547,16 +6547,12 @@ testDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
{
virDomainObjPtr vm = NULL;
int ret = -1;
- virDomainSnapshotObjPtr snap = NULL;
virCheckFlags(0, -1);
if (!(vm = testDomObjFromSnapshot(snapshot)))
goto cleanup;
- if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
- goto cleanup;
-
ret = (vm->current_snapshot &&
STREQ(snapshot->name, vm->current_snapshot->def->name));
@@ -6573,14 +6569,13 @@ testDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
{
virDomainObjPtr vm = NULL;
int ret = -1;
- virDomainSnapshotObjPtr snap = NULL;
virCheckFlags(0, -1);
if (!(vm = testDomObjFromSnapshot(snapshot)))
goto cleanup;
- if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
+ if (!testSnapObjFromSnapshot(vm, snapshot))
goto cleanup;
ret = 1;
@@ -6679,8 +6674,8 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
goto cleanup;
if (redefine) {
- if (!virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
- &update_current, flags) < 0)
+ if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
+ &update_current, flags) < 0)
goto cleanup;
} else {
if (!(def->dom = virDomainDefCopy(vm->def,
@@ -7078,6 +7073,8 @@ cleanup:
testDomainEventQueue(privconn, event);
if (event2)
testDomainEventQueue(privconn, event2);
+ } else {
+ virDomainEventFree(event2);
}
virObjectUnlock(vm);
testDriverUnlock(privconn);
--
1.8.3.1
11 years, 2 months