[libvirt] [libvirt-glib] Add gvir_storage_vol_resize()
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Add wrapper for virStorageVolResize().
---
libvirt-gobject/libvirt-gobject-storage-vol.c | 45 +++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-storage-vol.h | 20 +++++++++++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 491e2e6..f6f0c50 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -299,3 +299,48 @@ gboolean gvir_storage_vol_delete(GVirStorageVol *vol,
return TRUE;
}
+
+/**
+ * gvir_storage_vol_resize:
+ * @vol: the storage volume to resize
+ * @capacity: the new capacity of the volume
+ * @flags: the flags
+ * @err: Return location for errors, or NULL
+ *
+ * Changes the capacity of the storage volume @vol to @capacity.
+ *
+ * Returns: the new capacity of the volume on success, 0 otherwise
+ */
+gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
+ guint64 capacity,
+ GVirStorageVolResizeFlags flags,
+ GError **err)
+{
+ GVirStoragePoolInfo* pool_info = NULL;
+ GVirStorageVolInfo* volume_info = NULL;
+ gboolean ret = FALSE;
+
+ pool_info = gvir_storage_pool_get_info (vol->priv->pool, err);
+ if (err != NULL && *err != NULL)
+ goto cleanup;
+ volume_info = gvir_storage_vol_get_info (vol, err);
+ if (err != NULL && *err != NULL)
+ goto cleanup;
+
+ if (virStorageVolResize(vol->priv->handle, capacity, flags) < 0) {
+ gvir_set_error_literal(err,
+ GVIR_STORAGE_VOL_ERROR,
+ 0,
+ "Unable to resize volume storage");
+ goto cleanup;
+ }
+
+ ret = TRUE;
+
+cleanup:
+ if (pool_info)
+ g_boxed_free(GVIR_TYPE_STORAGE_POOL_INFO, pool_info);
+ if (volume_info)
+ gvir_storage_vol_info_free(volume_info);
+ return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h b/libvirt-gobject/libvirt-gobject-storage-vol.h
index 25f683a..459a2ac 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.h
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.h
@@ -23,6 +23,7 @@
#if !defined(__LIBVIRT_GOBJECT_H__) && !defined(LIBVIRT_GOBJECT_BUILD)
#error "Only <libvirt-gobject/libvirt-gobject.h> can be included directly."
#endif
+#include <libvirt/libvirt.h>
#ifndef __LIBVIRT_GOBJECT_STORAGE_VOL_H__
#define __LIBVIRT_GOBJECT_STORAGE_VOL_H__
@@ -65,6 +66,21 @@ typedef enum {
GVIR_STORAGE_VOL_STATE_DIR = 2, /* Directory-passthrough based volume */
} GVirStorageVolType;
+/**
+ * GVirStorageVolResizeFlags:
+ * @GVIR_STORAGE_VOL_RESIZE_NONE: No flags
+ * @GVIR_STORAGE_VOL_RESIZE_ALLOCATE: force allocation of new size
+ * @GVIR_STORAGE_VOL_RESIZE_DELTA: size is relative to current
+ * @GVIR_STORAGE_VOL_RESIZE_SHRINK: allow decrease in capacity. This combined
+ * with #GVIR_STORAGE_VOL_RESIZE_DELTA, implies a negative delta.
+ */
+typedef enum {
+ GVIR_STORAGE_VOL_RESIZE_NONE = 0,
+ GVIR_STORAGE_VOL_RESIZE_ALLOCATE = VIR_STORAGE_VOL_RESIZE_ALLOCATE,
+ GVIR_STORAGE_VOL_RESIZE_DELTA = VIR_STORAGE_VOL_RESIZE_DELTA,
+ GVIR_STORAGE_VOL_RESIZE_SHRINK = VIR_STORAGE_VOL_RESIZE_SHRINK,
+} GVirStorageVolResizeFlags;
+
typedef struct _GVirStorageVolInfo GVirStorageVolInfo;
struct _GVirStorageVolInfo
{
@@ -89,6 +105,10 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
GError **err);
GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol,
GError **err);
+gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
+ guint64 capacity,
+ GVirStorageVolResizeFlags flags,
+ GError **err);
G_END_DECLS
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a4f03f7..468bf65 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -126,6 +126,7 @@ LIBVIRT_GOBJECT_0.0.4 {
gvir_storage_vol_get_config;
gvir_storage_vol_get_info;
gvir_storage_vol_delete;
+ gvir_storage_vol_resize;
gvir_connection_handle_get_type;
--
1.7.7.6
12 years, 10 months
[libvirt] Generic processing of xml data
by Hendrik Schwartke
There are some changes made to the conf code to handle some new tags
like <title> or to add some "metadata" to a domain description in the
last days.
I'm wondering if there is a more generic (read better) way to handle
those extra data in xml config elements.
I think it would be far more reasonable to use xml namespaces to enable
libvirt to differentiate between config options which it has to process
and data which are unknown to libvirt and thus are only stored without
any further processing.
This distinction could then by easily used for expansions like the
<title>-tag, to store the x- and y-position of a guest in a graphical
visualization of virtual networks, to add some names of administrators
which are responsible for the guests, to add some hints to interfaces
concerning quality of service, etc...
I don't know how complex such in implementation would be but I think it
would be worth the effort.
Hendrik Schwartke
12 years, 10 months
[libvirt] [PATCH] qemu: Silent bogus warning about unitialized variable
by Jiri Denemark
GCC complaints about uninitialized use of len, which however is only
used when errors != NULL and in that case len is always initialized.
It's trivial to silence this by always initializing len.
---
Pushed as both trivial and build-breaking.
daemon/remote.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 8fbcf43..26ac4a6 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3608,7 +3608,7 @@ static int remoteDispatchDomainGetDiskErrors(
int rv = -1;
virDomainPtr dom = NULL;
virDomainDiskErrorPtr errors = NULL;
- int len;
+ int len = 0;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
--
1.7.8.4
12 years, 10 months
[libvirt] Unable to compile libvirt git src... python-config error
by Deepak C Shetty
Hi All,
I am getting this error, while trying to compile latest git src.
./autogen.sh --prefix=$HOME/usr --enable-compile-warnings=error
running bootstrap...
./bootstrap: Error: 'python-config' not found
./bootstrap: Please install the prerequisite programs
Failed to bootstrap, please investigate.
I am ubuntu, and all packages related to python-config are installed..
as seen by the 'i' below...
aptitude search python-config
i
python-configglue
- Glues together optparse.OptionParser and ConfigParser.ConfigParser
i
python-configobj
- simple but powerful config file reader and writer for Python
Can someone help, what i am missing ?
thanx,
deepak
12 years, 10 months
[libvirt] [PATCH 0/2][RFC] netlink events
by D. Herrendoerfer
From: "D. Herrendoerfer" <d.herrendoerfer(a)herrendoerfer.name>
I'd like to put this up for discussion.
This is the prototype for netlink events as discussed before,
it follows the design of the event_poll functions.
Included is the unfinished prototype netlink event callback for
virnetdevmacvtap.c as reference. We are still working with lldpad
to get the message finalized and tested.
Regards,
Dirk H.
D. Herrendoerfer (2):
Add netlink message event service
macvtap: listen for netlink messages from lldpad
daemon/Makefile.am | 3 +-
daemon/libvirtd.c | 7 +
src/Makefile.am | 1 +
src/libvirt_private.syms | 7 +
src/util/netlink-event.c | 363 +++++++++++++++++++++++++++++++++++++++++++
src/util/netlink-event.h | 63 ++++++++
src/util/netlink.c | 1 +
src/util/virnetdevmacvlan.c | 161 +++++++++++++++++++-
src/util/virnetdevmacvlan.h | 1 +
9 files changed, 605 insertions(+), 2 deletions(-)
create mode 100644 src/util/netlink-event.c
create mode 100644 src/util/netlink-event.h
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH] daemon: Allow overriding NOFILES ulimit for the daemon as well
by Michal Privoznik
One of my latest patches (d8db0f9690) created support for setting
the limit for the maximum of opened files by qemu user. However,
since libvirtd keeps one FD opened per domain (well, for qemu at least)
it will likely hit this limit on huge scenarios.
---
daemon/libvirtd.aug | 1 +
daemon/libvirtd.c | 37 +++++++++++++++++++++++++++++++++++++
daemon/libvirtd.conf | 9 +++++++++
3 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/daemon/libvirtd.aug b/daemon/libvirtd.aug
index 9d78bd7..278099b 100644
--- a/daemon/libvirtd.aug
+++ b/daemon/libvirtd.aug
@@ -58,6 +58,7 @@ module Libvirtd =
| int_entry "max_requests"
| int_entry "max_client_requests"
| int_entry "prio_workers"
+ | int_entry "max_files"
let logging_entry = int_entry "log_level"
| str_entry "log_filters"
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b1b542b..34bdd39 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -139,6 +139,8 @@ struct daemonConfig {
int max_requests;
int max_client_requests;
+ int max_files;
+
int log_level;
char *log_filters;
char *log_outputs;
@@ -1081,6 +1083,8 @@ daemonConfigLoad(struct daemonConfig *data,
GET_CONF_INT (conf, filename, max_requests);
GET_CONF_INT (conf, filename, max_client_requests);
+ GET_CONF_INT (conf, filename, max_files);
+
GET_CONF_INT (conf, filename, audit_level);
GET_CONF_INT (conf, filename, audit_logging);
@@ -1198,6 +1202,34 @@ static int daemonStateInit(virNetServerPtr srv)
return 0;
}
+/*
+ * daemonSetProcessLimits:
+ * @config: where to take limits from
+ *
+ * Set both soft and hard limits set in config file.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+static int
+daemonSetProcessLimits(struct daemonConfig *config)
+{
+ struct rlimit rlim;
+
+ if (config->max_files > 0) {
+ /* Max number of opened files is one greater than
+ * actual limit. See man setrlimit */
+ rlim.rlim_cur = rlim.rlim_max = config->max_files + 1;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ virReportSystemError(errno,
+ _("cannot set max opened files to %d"),
+ config->max_files);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
/* Print command-line usage. */
static void
daemonUsage(const char *argv0, bool privileged)
@@ -1429,6 +1461,11 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ if (daemonSetProcessLimits(config) < 0) {
+ /* Helper reported error */
+ exit(EXIT_FAILURE);
+ }
+
if (godaemon) {
char ebuf[1024];
diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf
index 3eab2be..70d5294 100644
--- a/daemon/libvirtd.conf
+++ b/daemon/libvirtd.conf
@@ -279,6 +279,15 @@
# and max_workers parameter
#max_client_requests = 5
+# If max_files is set to positive integer, the maximum number
+# of opened files for the daemon is set to given value. This
+# can be used to override host system default value.
+# Please keep in mind that in some drivers (like qemu) this
+# will affect the upper bound of domains which can run simultaneously.
+# That's because the daemon keeps one file opened per domain - monitor.
+# Well, at least one.
+#max_files = 0
+
#################################################################
#
# Logging controls
--
1.7.3.4
12 years, 10 months
[libvirt] virDomainNetGetActualBridgeName doesn't return the actual bridge
by Hendrik Schwartke
Hi,
calling virDomainNetGetActualBridgeName on a bridge with type
VIR_DOMAIN_NET_TYPE_NETWORK seems to return NULL in any case, because
iface->data.network.actual is NULL. Is that intented?
What is the best way to determine the bridge the interface is connected to?
Hendrik Schwartke
12 years, 10 months
[libvirt] [PATCH v3 0/5] Add virDomainGetDiskErrors API
by Jiri Denemark
We already provide ways to detect when a domain has been paused as a
result of I/O error, but there was no way of getting the exact error or
even the device that experienced it. This new API may be used for both.
Changes in version 3:
- special case errors == NULL, maxerrors == 0 returns size of the array
the caller should pass
- explicitly document that disks with no error are not returned and that
the caller must free disk names
- explicitly document what happens when maxerrors is lower then the
actual number of disk errors
- maxerrors turned unsigned
- the first patch was split into two (public API and RPC)
- python binding is back
Changes in version 2:
- the API is now called virDomainGetDiskErrors
- it returns a list (allocated by caller) of disks with errors instead
so that users don't have to call it multiple times to get all errors
- there's no python API yet since it can't be autogenerated; I'll send
a patch for it tomorrow
Jiri Denemark (5):
virDomainGetDiskErrors public API
Remote protocol for virDomainGetDiskErrors
qemu: Implement virDomainGetDiskErrors
virsh: Implement domblkerror command
python: Add binding for virDomainGetDiskErrors
daemon/remote.c | 103 +++++++++++++++++++++++++++++++++++++++
include/libvirt/libvirt.h.in | 32 ++++++++++++
python/generator.py | 3 +-
python/libvirt-override-api.xml | 6 ++
python/libvirt-override.c | 50 +++++++++++++++++++
src/driver.h | 7 +++
src/libvirt.c | 65 ++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 86 ++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 40 +++++++++++++++
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 8 +++
src/qemu/qemu_monitor_text.c | 15 ++++++
src/remote/remote_driver.c | 77 +++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 23 ++++++++-
src/remote_protocol-structs | 17 ++++++
tools/virsh.c | 78 +++++++++++++++++++++++++++++
tools/virsh.pod | 7 +++
19 files changed, 618 insertions(+), 2 deletions(-)
--
1.7.8.4
12 years, 10 months
[libvirt] [PATCH] python: correct a copy-paste error
by Alex.Jia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
* python/libvirt-override-virStream.py: fix a copy-paste error in sendAll().
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override-virStream.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/libvirt-override-virStream.py b/python/libvirt-override-virStream.py
index ff53a16..b5cec2a 100644
--- a/python/libvirt-override-virStream.py
+++ b/python/libvirt-override-virStream.py
@@ -86,7 +86,7 @@
ret = self.send(got)
if ret == -2:
- raise libvirtError("cannot use recvAll with "
+ raise libvirtError("cannot use sendAll with "
"nonblocking stream")
def recv(self, nbytes):
--
1.7.1
12 years, 10 months