[libvirt] [PATCH] tests: avoid seclabeltest crash
by Eric Blake
Commit a56c347 introduced a use of random numbers into seclabel
handling, but failed to initialize the random number generator
in the testsuite.
* tests/seclabeltest.c (main): Initialize randomness.
---
Pushing under the build-breaker rule to avoid a SIGSEGV. I don't
know if Dan's pending patches for one-shot initializer cleanups
will be impacted or make this harder to forget in the future.
tests/seclabeltest.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/seclabeltest.c b/tests/seclabeltest.c
index 2f65ec1..7283ca1 100644
--- a/tests/seclabeltest.c
+++ b/tests/seclabeltest.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <errno.h>
#include "security/security_driver.h"
+#include "virrandom.h"
int
main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
@@ -13,10 +14,14 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
virSecurityManagerPtr mgr;
const char *doi, *model;
+ if (virThreadInitialize() < 0 ||
+ virRandomInitialize(time(NULL) ^ getpid()))
+ exit(1);
+
mgr = virSecurityManagerNew(NULL, "QEMU", false, true, false);
if (mgr == NULL) {
fprintf (stderr, "Failed to start security driver");
- exit (-1);
+ exit(1);
}
model = virSecurityManagerGetModel(mgr);
@@ -24,7 +29,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
fprintf (stderr, "Failed to copy secModel model: %s",
strerror (errno));
- exit (-1);
+ exit(1);
}
doi = virSecurityManagerGetDOI(mgr);
@@ -32,7 +37,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
fprintf (stderr, "Failed to copy secModel DOI: %s",
strerror (errno));
- exit (-1);
+ exit(1);
}
virSecurityManagerFree(mgr);
--
1.7.10.4
12 years, 9 months
[libvirt] [PATCHv2 0/5] Allow to query a guest's hostname
by Guido Günther
The following patches allow to query a guest's hostname. Once we also have
support to set the hostname via the domain's xml we can also print it in "virsh
dominfo" by default so I left it out for now.
I left the version at 0.9.14. It'd be happy to change this ot 0.10 should we
settle for that one.
Changes since last time:
* drop patch to print hostname in "virsh list"
* add remote protocoll support
* Addressed Eric's style comments
* openvzVEGetStringParam: Let virCommandRun do the error printing and missing
error handling
* Don't return empty hostnames but raise VIR_ERR_OPERATION_FAILED instead
Cheers,
-- Guido
Guido Günther (5):
Add virDomainGetHostname
virsh: Add domhostname
remote: Provide RPC call for domainGetHostname
openvz: Add openvzVEGetStringParam
openvz: Implement domainGetHostname
include/libvirt/libvirt.h.in | 2 ++
src/driver.h | 6 ++++++
src/libvirt.c | 45 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_openvz.syms | 2 +-
src/libvirt_public.syms | 5 +++++
src/openvz/openvz_driver.c | 42 +++++++++++++++++++++++++++++++++++++++
src/openvz/openvz_util.c | 32 ++++++++++++++++++++++++++++++
src/openvz/openvz_util.h | 1 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 12 ++++++++++-
src/remote_protocol-structs | 8 ++++++++
tools/virsh.c | 44 +++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 4 ++++
13 files changed, 202 insertions(+), 2 deletions(-)
--
1.7.10.4
12 years, 9 months
[libvirt] [PATCH 1/5] Add public API to register a callback to be invoked on connection close
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Define a new virConnectSetCloseCallback() public API which allows
registering a callback to be invoked when the connection to a
hypervisor is closed. The callback is provided with the reason for
the close, which may be 'error', 'eof' or 'keepalive'.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
include/libvirt/libvirt.h.in | 40 +++++++++++++++++++++++--------
src/datatypes.c | 4 ++++
src/datatypes.h | 5 ++++
src/libvirt.c | 53 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 +++++
5 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index e34438c..74b3f90 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -49,6 +49,17 @@ extern "C" {
* defines VIR_ENUM_SENTINELS. Enumerations for bit values do not
* have a *_LAST value, but additional bits may be defined. */
+/*
+ * virFreeCallback:
+ * @opaque: opaque user data provided at registration
+ *
+ * Type for a domain event callback when the event is deregistered and
+ * need to be freed, @opaque is provided along with the callback at
+ * registration time
+ */
+typedef void (*virFreeCallback)(void *opaque);
+
+
/**
* virConnect:
*
@@ -1148,6 +1159,25 @@ int virConnectSetKeepAlive(virConnectPtr conn,
int interval,
unsigned int count);
+typedef enum {
+ VIR_CONNECT_CLOSE_REASON_ERROR = 1, /* Misc I/O error */
+ VIR_CONNECT_CLOSE_REASON_EOF = 2, /* End-of-file from server */
+ VIR_CONNECT_CLOSE_REASON_KEEPALIVE = 3, /* Keepalive timer triggered */
+ VIR_CONNECT_CLOSE_REASON_CLIENT = 4, /* Client requested it */
+
+# ifdef VIR_ENUM_SENTINELS
+ VIR_CONNECT_CLOSE_REASON_LAST
+# endif
+} virConnectCloseReason;
+
+typedef void (*virConnectCloseFunc)(virConnectPtr conn,
+ int reason,
+ void *opaque);
+
+int virConnectSetCloseCallback(virConnectPtr conn,
+ virConnectCloseFunc cb,
+ void *opaque,
+ virFreeCallback freecb);
/*
* Capabilities of the connection / driver.
@@ -2861,16 +2891,6 @@ typedef int (*virConnectDomainEventCallback)(virConnectPtr conn,
int detail,
void *opaque);
-/*
- * virFreeCallback:
- * @opaque: opaque user data provided at registration
- *
- * Type for a domain event callback when the event is deregistered and
- * need to be freed, @opaque is provided along with the callback at
- * registration time
- */
-typedef void (*virFreeCallback)(void *opaque);
-
int virConnectDomainEventRegister(virConnectPtr conn,
virConnectDomainEventCallback cb,
void *opaque,
diff --git a/src/datatypes.c b/src/datatypes.c
index d718170..5d415b8 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -115,6 +115,10 @@ virReleaseConnect(virConnectPtr conn) {
virMutexLock(&conn->lock);
+ if (conn->closeOpaque &&
+ conn->closeFreeCallback)
+ conn->closeFreeCallback(conn->closeOpaque);
+
virResetError(&conn->err);
virURIFree(conn->uri);
diff --git a/src/datatypes.h b/src/datatypes.h
index fc284d2..af054ac 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -187,6 +187,11 @@ struct _virConnect {
virErrorFunc handler; /* associated handlet */
void *userData; /* the user data */
+ /* Per-connection close callback */
+ virConnectCloseFunc closeCallback;
+ void *closeOpaque;
+ virFreeCallback closeFreeCallback;
+
int refs; /* reference count */
};
diff --git a/src/libvirt.c b/src/libvirt.c
index df78e8a..8acb87f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -18613,6 +18613,59 @@ error:
/**
+ * virConnectSetCloseCallback:
+ * @conn: pointer to connection object
+ * @cb: callback to invoke upon close
+ * @opaque: user data to pass to @cb
+ * @freecb: callback to free @opaque
+ *
+ * Registers a callback to be invoked when the connection
+ * is closed. This callback is invoked when there is any
+ * condition that causes the socket connection to the
+ * hypervisor to be closed.
+ *
+ * This function is only applicable to hypervisor drivers
+ * which maintain a persistent open connection. Drivers
+ * which open a new connection for every operation will
+ * not invoke this.
+ *
+ * The @freecb must not invoke any other libvirt public
+ * APIs, since it is not called from a re-entrant safe
+ * context.
+ *
+ * Returns 0 on success, -1 on error
+ */
+int virConnectSetCloseCallback(virConnectPtr conn,
+ virConnectCloseFunc cb,
+ void *opaque,
+ virFreeCallback freecb)
+{
+ VIR_DEBUG("conn=%p", conn);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ virMutexLock(&conn->lock);
+
+ if (conn->closeOpaque &&
+ conn->closeFreeCallback)
+ conn->closeFreeCallback(conn->closeOpaque);
+
+ conn->closeCallback = cb;
+ conn->closeOpaque = opaque;
+ conn->closeFreeCallback = freecb;
+
+ virMutexUnlock(&conn->lock);
+
+ return 0;
+}
+
+/**
* virDomainSetBlockIoTune:
* @dom: pointer to domain object
* @disk: path to the block device, or device shorthand
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 2913a81..dab8725 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -544,4 +544,10 @@ LIBVIRT_0.9.13 {
virDomainSnapshotRef;
} LIBVIRT_0.9.11;
+
+LIBVIRT_0.9.14 {
+ global:
+ virConnectSetCloseCallback;
+} LIBVIRT_0.9.13;
+
# .... define new API here using predicted next version number ....
--
1.7.10.4
12 years, 9 months
[libvirt] [PATCH 00/50] Atomic APIs to list objects
by Osier Yang
Except the already supported APIs for domain and domain snapshot,
this series add the APIs for all the left objects, including
storage pool, storage vol, network, interface, node device,
nwfilter, secret.
* Storage pool:
- Support filtering the returned pool objects by active|inactive,
persistent|transient, autostart|no-autostart, and pool types.
- New options for virsh, --type to accept multiple pool types.
* Storage vol:
- Simply returns all the vol objects of a pool.
* Network:
- Support filtering the results using flags active|inactive,
persistent|transient, autostart|no-autostart
- New options for virsh.
* Interface:
- Support filtering the results using flags active|inactive.
It's still O(n) underlying, as interface driver doesn't manage
the objects itself, but using netcf lib instead. And netcf
APIs don't support returning the struct yet.
* Node Device:
- Support filtering the results using capabilities type of
the devices.
- Extend --cap to accept multiple capability type.
* Network Filter:
- Simply returns all the objects.
* Secret:
- Simply returns all the objects.
All the commands are tested with both new libvirt with the APIs
support, or old libvirt without the support.
By the way, I'm wondering if should split the virsh wood, it's really
big now, and still growing up. It might take a bit more time to
compile if it's splitted into multiple files (split it by the command
group?) though, but it's good for maintaining and eyes (I have a small
screen). Any opinions?
Osier Yang (50):
Fix indentions
list: Expose pool type via virStoragePoolGetInfo
list: Rename virdomainlist.[ch] for common use
list: Define new API virStorageListALlStoragePools
list: Add helpers for listing storage pool objects
list: Implement the RPC calls for virConnectListAllStoragePools
list: Implement listAllStoragePools for storage driver
list: Implement listAllStoragePools for test driver
list: Add helper to convert strings separated by ',' to array
virsh: Fix the wrong doc for pool-list
list: Change MATCH for common use in virsh
list: Use virConnectListAllStoragePools in virsh
virsh: Use vshPrint instead of printf
python: Expose virStorageListAllStoragePools to python binding
list: Define new API virStoragePoolListAllVolumes
list: Implemente RPC calls for virStoragePoolListAllVolumes
list: Implement virStoragePoolListAllVolumes for storage driver
list: Implement virStoragePoolListAllVolumes for test driver
list: Use virStoragePoolListAllVolumes in virsh
list: Expose virStoragePoolListAllVolumes to Python binding
list: Define new API virConnectListAllNetworks
list: Implement RPC calls for virConnectListAllNetworks
list: Add helpers to list network objects
list: Implement listAllNetworks for network driver
list: Implement listAllNetworks for test driver
list: Use virConnectListAllNetworks in virsh
list: Expose virConnectListAllNetworks to Python binding
daemon: Fix the wrong macro name
list: Define new API virConnectListAllInterfaces
list: Implemente RPC calls for virConnectListAllInterfaces
list: Implement listAllInterfaces
list: Use virConnectListAllInterfaces in virsh
list: Expose virConnectListAllInterfaces to Python binding
list: Define new API virConnectListAllNodeDevices
list: Implemente RPC calls for virConnectListAllNodeDevices
list: Add helpers for listing node devices
list: Implement listAllNodeDevices
list: Expose virConnectListAllNodeDevices to Python binding
virsh: Fix a bug of nodedev-list
list: Use virConnectListAllNodeDevices in virsh
list: Define new API virConnectListAllNWFilters
list: Implement RPC calls for virConnectListAllNWFilters
list: Implement listAllNWFilters
list: Use virConnectListAllNWFilters in virsh
list: Expose virConnectListAllNWFilters to Python binding
list: Define new API virConnectListAllSecrets
list: Implement RPC calls for virConnectListAllSecrets
list: Implement listAllSecrets
list: Use virConnectListAllSecrets in virsh
list: Expose virConnectListAllSecrets to Python binding
daemon/libvirtd.c | 2 +-
daemon/remote.c | 382 +++++
include/libvirt/libvirt.h.in | 117 ++-
python/generator.py | 11 +-
python/libvirt-override-api.xml | 44 +-
python/libvirt-override-virConnect.py | 72 +
python/libvirt-override-virStoragePool.py | 11 +
python/libvirt-override.c | 337 +++++
src/Makefile.am | 8 +-
src/conf/domain_conf.c | 2 +-
src/conf/storage_conf.h | 19 -
src/conf/virdomainlist.c | 222 ---
src/conf/virdomainlist.h | 84 --
src/conf/virobjectlist.c | 535 +++++++
src/conf/virobjectlist.h | 162 +++
src/datatypes.h | 48 +-
src/driver.h | 35 +-
src/interface/netcf_driver.c | 135 ++
src/libvirt.c | 429 ++++++-
src/libvirt_private.syms | 6 +-
src/libvirt_public.syms | 11 +
src/libxl/libxl_driver.c | 4 +-
src/lxc/lxc_driver.c | 4 +-
src/network/bridge_driver.c | 18 +
src/node_device/node_device_driver.c | 16 +
src/node_device/node_device_driver.h | 3 +
src/node_device/node_device_hal.c | 1 +
src/node_device/node_device_udev.c | 1 +
src/nwfilter/nwfilter_driver.c | 57 +
src/openvz/openvz_driver.c | 4 +-
src/qemu/qemu_driver.c | 4 +-
src/remote/remote_driver.c | 449 ++++++
src/remote/remote_protocol.x | 78 +-
src/remote_protocol-structs | 85 ++
src/secret/secret_driver.c | 58 +-
src/storage/storage_driver.c | 88 ++
src/test/test_driver.c | 105 ++-
src/uml/uml_driver.c | 4 +-
src/vbox/vbox_tmpl.c | 10 +-
src/vmware/vmware_driver.c | 4 +-
tests/virdrivermoduletest.c | 2 +-
tools/virsh.c | 2206 ++++++++++++++++++++++-------
tools/virsh.pod | 51 +-
43 files changed, 4982 insertions(+), 942 deletions(-)
create mode 100644 python/libvirt-override-virStoragePool.py
delete mode 100644 src/conf/virdomainlist.c
delete mode 100644 src/conf/virdomainlist.h
create mode 100644 src/conf/virobjectlist.c
create mode 100644 src/conf/virobjectlist.h
Regards,
Osier
12 years, 9 months
[libvirt] [PATCH] Disable NWFilter driver completely when unprivileged
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Running libvirtd unprivileged results in a warning message from
the NWFilter driver
virNWFilterSnoopLeaseFileRefresh:1882 : open("/var/run/libvirt/network/nwfilter.ltmp"): No such file or directory
Since it requires privileged network access, this driver should
not even run when unprivileged.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/nwfilter/nwfilter_driver.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 58d91f9..9034549 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -68,6 +68,9 @@ static int
nwfilterDriverStartup(int privileged) {
char *base = NULL;
+ if (!privileged)
+ return 0;
+
if (virNWFilterIPAddrMapInit() < 0)
return -1;
if (virNWFilterLearnInit() < 0)
--
1.7.10.4
12 years, 9 months
[libvirt] [PATCH v2] storage: netfs and iscsi need option srcSpec for resource discovery
by Guannan Ren
The option 'srcSpec' to virsh command find-storage-pool-sources
is optional for logical type of storage pool, but mandatory for
netfs and iscsi type.
When missing the option for netfs and iscsi, libvirt reports XML
parsing error due to null string option srcSpec.
error: Failed to find any netfs pool sources
error: (storage_source_specification):1: Document is empty
(null)
This patch adds a check for it, error info changed to:
error: Failed to find any netfs pool sources
error: internal error pool type 'netfs' need option \
--srcSpec for source discovery
---
src/storage/storage_driver.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index fbc630d..8486fdf 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -458,6 +458,14 @@ storageFindPoolSources(virConnectPtr conn,
goto cleanup;
}
+ if ((*srcSpec == '\0') && (backend_type == VIR_STORAGE_POOL_ISCSI ||
+ backend_type == VIR_STORAGE_POOL_NETFS)) {
+ virStorageReportError(VIR_ERR_INTERNAL_ERROR,
+ _("pool type '%s' needs option --srcSpec "
+ "for source discovery"), type);
+ goto cleanup;
+ }
+
ret = backend->findPoolSources(conn, srcSpec, flags);
cleanup:
--
1.7.7.5
12 years, 9 months
[libvirt] [PATCH] don't make lxc_driver static
by Gao feng
because it will be used in lxc_process.c
below is the error information
debug : virDriverLoadModule:66 : Module load lxc
error : virDriverLoadModule:78 : failed to load module
/usr/local/lib/libvirt/connection-driver/libvirt_driver_lxc.so
/usr/local/lib/libvirt/connection-driver/libvirt_driver_lxc.so:
undefined symbol: lxc_driver
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d7f052f..09c64b2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -72,7 +72,7 @@
static int lxcStartup(int privileged);
static int lxcShutdown(void);
-static lxc_driver_t *lxc_driver = NULL;
+lxc_driver_t *lxc_driver = NULL;
/* Functions */
--
1.7.7.6
12 years, 9 months
[libvirt] Libvirt/LXC/SystemD/SELinux Hackfest at Linux Plumbers, San Diego
by Daniel P. Berrange
Hi Folks,
This years Linux Plumbers Conference (LPC)[1] is taking place in San Diego
in the last week of August (co-located with LinuxCon).
Since there is alot of integration between libvirt / LXC / SystemD and
SELinux, and many of the key developers from those projects will be
at LPC, Lennart proposed we hold a hackfest at LPC on this subject
To quote Lennart's blog[2]:
"On 28th of August we'll have a hackfest on the topic of closer
integration of libvirt, LXC, systemd and SELinux, colocated with
LPC in San Diego, California. We'll have a number of key people
from these projects participating, including Dan Walsh, Eric Paris,
Daniel P. Berrange, Kay Sievers and myself.
Topics we'll cover: making Fedora/Linux boot entirely cleanly in
normal containers, teaching systemd's control tools minimal
container-awareness (such as being able to list all services
of all containers in one go, in addition to those running on
the host system), unified journal logging across multiple containers,
the systemd container interface, auditing and containers, running
multiple instances from the same /usr tree, and a lot more...
Who should attend? Everybody hacking on the mentioned projects
who wants to help integrating them with the goal of turning them
into a secure, reliable, powerful container solution for Linux.
Who should not attend? If you don't hack on any of these projects,
or if you are not interested in closer integration of at least two
of these projects.
How to register? Just show up. You get extra points however for
letting us know in advance (just send us an email). Attendance is
free."
NB, note the date - 28th of August is the Tuesday - ie the day *before*
the main LPC conference programme begins. We have space reserved in
the main hotel for the hackfest on this day.
Regards,
Daniel
[1] http://www.linuxplumbersconf.org/2012/
[2] http://0pointer.de/blog/hackfests.html
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
12 years, 9 months