[libvirt] [PATCH] lxc: fix logic bug
by Eric Blake
Detected by Coverity. We want to increment the size_t counter,
not the pointer to the counter.
* src/lxc/lxc_controller.c (lxcSetupLoopDevices): Use correct
precedence.
---
Pushing under the trivial rule.
src/lxc/lxc_controller.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 52d382e..51488e7 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -210,7 +210,7 @@ static int lxcSetupLoopDevices(virDomainDefPtr def, size_t *nloopDevs, int **loo
virReportOOMError();
goto cleanup;
}
- (*loopDevs)[*nloopDevs++] = fd;
+ (*loopDevs)[(*nloopDevs)++] = fd;
}
VIR_DEBUG("Setup all loop devices");
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] virsh: Update the help information for undefine command.
by tangchen
virsh undefine command can now undefine an active guest, but the help information is still the old.
This patch modifies it and make it coincident to the manpage of virsh.
Signed-off-by: tangchen <tangchen(a)cn.fujitsu.com>
---
tools/virsh.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 48f2b8a..c3b467e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1897,8 +1897,10 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
* "undefine" command
*/
static const vshCmdInfo info_undefine[] = {
- {"help", N_("undefine an inactive domain")},
- {"desc", N_("Undefine the configuration for an inactive domain.")},
+ {"help", N_("Undefine a domain, active or inactive.")},
+ {"desc", N_("Undefine a domain. If the domain is running, this converts \n"
+ " it to a transient domain, without stopping it. If the \n"
+ " domain is inactive, the domain configuration is removed.")},
{NULL, NULL}
};
--
1.7.3.1
--
Best Regards,
Tang chen
--------------------------------------------------
Tang Chen
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
No.6 Wenzhu Road, Nanjing, 210012, China
TEL: +86+25-86630566-8527
FUJITSU INTERNAL: 7998-8527
FAX: +86+25-83317685
EMail: tangchen(a)cn.fujitsu.com
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not an intended recipient of this communication, you are hereby notified that any dissemination, distribution or copying hereof is strictly prohibited. If you have received this communication in error, please notify me by reply e-mail, permanently delete this communication from your system, and destroy any hard copies you may have printed
13 years, 1 month
[libvirt] [PATCH 0/2] snapshot: allow editing disk-only snapshots
by Eric Blake
I tested that both of these patches in isolation were sufficient
to fix 'virsh snapshot-current dom name' when running the same
version of virsh as libvirtd (what will become 0.9.7). However,
both patches are required, so that both virsh 0.9.5 and libvirtd
0.9.7, as well as virsh 0.9.7 and libvirt 0.9.5, will work (leaving
only the combination of 0.9.5 in both virsh and libvirtd broken).
Eric Blake (2):
snapshot: let virsh edit disk snapshots
snapshot: simplify redefinition of disk snapshot
src/conf/domain_conf.c | 44 +++++++++++++++++++++++---------------------
tools/virsh.c | 5 +++++
2 files changed, 28 insertions(+), 21 deletions(-)
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH] snapshot: fix virsh error message typo
by Eric Blake
* tools/virsh.c (cmdSnapshotList): Spell exclusive correctly.
---
Pushing under the trivial rule.
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 48f2b8a..62581f6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -13133,19 +13133,19 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "parent")) {
if (vshCommandOptBool(cmd, "roots")) {
vshError(ctl, "%s",
- _("--parent and --roots are mutually exlusive"));
+ _("--parent and --roots are mutually exclusive"));
return false;
}
if (tree) {
vshError(ctl, "%s",
- _("--parent and --tree are mutually exlusive"));
+ _("--parent and --tree are mutually exclusive"));
return false;
}
parent_filter = 1;
} else if (vshCommandOptBool(cmd, "roots")) {
if (tree) {
vshError(ctl, "%s",
- _("--roots and --tree are mutually exlusive"));
+ _("--roots and --tree are mutually exclusive"));
return false;
}
flags |= VIR_DOMAIN_SNAPSHOT_LIST_ROOTS;
--
1.7.4.4
13 years, 1 month
[libvirt] [libvirt-glib] API to deal with storage pool(s)
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Add API to fetch, list, retrieve & find storage pool(s) on a connection.
---
libvirt-gobject/libvirt-gobject-connection.c | 279 ++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-connection.h | 12 +-
libvirt-gobject/libvirt-gobject.sym | 6 +
3 files changed, 296 insertions(+), 1 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 69c6956..c512e79 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -43,6 +43,7 @@ struct _GVirConnectionPrivate
virConnectPtr conn;
GHashTable *domains;
+ GHashTable *pools;
};
G_DEFINE_TYPE(GVirConnection, gvir_connection, G_TYPE_OBJECT);
@@ -357,6 +358,11 @@ void gvir_connection_close(GVirConnection *conn)
priv->domains = NULL;
}
+ if (priv->pools) {
+ g_hash_table_unref(priv->pools);
+ priv->pools = NULL;
+ }
+
if (priv->conn) {
virConnectClose(priv->conn);
priv->conn = NULL;
@@ -503,6 +509,148 @@ cleanup:
return ret;
}
+/**
+ * gvir_connection_fetch_storage_pools:
+ * @conn: the connection
+ * @cancellable: (allow-none)(transfer none): cancellation object
+ */
+gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
+ GCancellable *cancellable,
+ GError **err)
+{
+ GVirConnectionPrivate *priv = conn->priv;
+ GHashTable *pools;
+ gchar **inactive = NULL;
+ gint ninactive = 0;
+ gchar **active = NULL;
+ gint nactive = 0;
+ gboolean ret = FALSE;
+ gint i;
+ virConnectPtr vconn = NULL;
+
+ g_mutex_lock(priv->lock);
+ if (!priv->conn) {
+ *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+ 0,
+ "Connection is not open");
+ g_mutex_unlock(priv->lock);
+ goto cleanup;
+ }
+ vconn = priv->conn;
+ /* Stop another thread closing the connection just at the minute */
+ virConnectRef(vconn);
+ g_mutex_unlock(priv->lock);
+
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ if ((nactive = virConnectNumOfStoragePools(vconn)) < 0) {
+ *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+ 0,
+ "Unable to count pools");
+ goto cleanup;
+ }
+ if (nactive) {
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ active = g_new(gchar *, nactive);
+ if ((nactive = virConnectListStoragePools(vconn,
+ active,
+ nactive)) < 0) {
+ *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+ 0,
+ "Unable to list pools");
+ goto cleanup;
+ }
+ }
+
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ if ((ninactive = virConnectNumOfDefinedStoragePools(vconn)) < 0) {
+ *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+ 0,
+ "Unable to count pools");
+ goto cleanup;
+ }
+
+ if (ninactive) {
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ inactive = g_new(gchar *, ninactive);
+ if ((ninactive = virConnectListDefinedStoragePools(vconn,
+ inactive,
+ ninactive)) < 0) {
+ *err = gvir_error_new(GVIR_CONNECTION_ERROR,
+ 0,
+ "Unable to list pools %d", ninactive);
+ goto cleanup;
+ }
+ }
+
+ pools = g_hash_table_new_full(g_str_hash,
+ g_str_equal,
+ g_free,
+ g_object_unref);
+
+ for (i = 0 ; i < nactive ; i++) {
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ virStoragePoolPtr vpool;
+ GVirStoragePool *pool;
+
+ vpool = virStoragePoolLookupByName(vconn, active[i]);
+ if (!vpool)
+ continue;
+
+ pool = GVIR_STORAGE_POOL(g_object_new(GVIR_TYPE_STORAGE_POOL,
+ "handle", vpool,
+ NULL));
+
+ g_hash_table_insert(pools,
+ g_strdup(gvir_storage_pool_get_uuid(pool)),
+ pool);
+ }
+
+ for (i = 0 ; i < ninactive ; i++) {
+ if (g_cancellable_set_error_if_cancelled(cancellable, err))
+ goto cleanup;
+
+ virStoragePoolPtr vpool;
+ GVirStoragePool *pool;
+
+ vpool = virStoragePoolLookupByName(vconn, inactive[i]);
+ if (!vpool)
+ continue;
+
+ pool = GVIR_STORAGE_POOL(g_object_new(GVIR_TYPE_STORAGE_POOL,
+ "handle", vpool,
+ NULL));
+
+ g_hash_table_insert(pools,
+ g_strdup(gvir_storage_pool_get_uuid(pool)),
+ pool);
+ }
+
+ g_mutex_lock(priv->lock);
+ if (priv->pools)
+ g_hash_table_unref(priv->pools);
+ priv->pools = pools;
+ virConnectClose(vconn);
+ g_mutex_unlock(priv->lock);
+
+ ret = TRUE;
+
+cleanup:
+ g_free(active);
+ for (i = 0 ; i < ninactive ; i++)
+ g_free(inactive[i]);
+ g_free(inactive);
+ return ret;
+}
static void
gvir_connection_fetch_domains_helper(GSimpleAsyncResult *res,
@@ -566,6 +714,67 @@ gboolean gvir_connection_fetch_domains_finish(GVirConnection *conn,
return TRUE;
}
+static void
+gvir_connection_fetch_pools_helper(GSimpleAsyncResult *res,
+ GObject *object,
+ GCancellable *cancellable)
+{
+ GVirConnection *conn = GVIR_CONNECTION(object);
+ GError *err = NULL;
+
+ if (!gvir_connection_fetch_storage_pools(conn, cancellable, &err)) {
+ g_simple_async_result_set_from_error(res, err);
+ g_error_free(err);
+ }
+}
+
+/**
+ * gvir_connection_fetch_storage_pools_async:
+ * @conn: the connection
+ * @cancellable: (allow-none)(transfer none): cancellation object
+ * @callback: (transfer none): completion callback
+ * @opaque: (transfer none)(allow-none): opaque data for callback
+ */
+void gvir_connection_fetch_storage_pools_async(GVirConnection *conn,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer opaque)
+{
+ GSimpleAsyncResult *res;
+
+ res = g_simple_async_result_new(G_OBJECT(conn),
+ callback,
+ opaque,
+ gvir_connection_fetch_storage_pools);
+ g_simple_async_result_run_in_thread(res,
+ gvir_connection_fetch_pools_helper,
+ G_PRIORITY_DEFAULT,
+ cancellable);
+ g_object_unref(res);
+}
+
+/**
+ * gvir_connection_fetch_storage_pools_finish:
+ * @conn: the connection
+ * @result: (transfer none): async method result
+ */
+gboolean gvir_connection_fetch_storage_pools_finish(GVirConnection *conn,
+ GAsyncResult *result,
+ GError **err)
+{
+ g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE);
+ g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
+
+ if (G_IS_SIMPLE_ASYNC_RESULT(result)) {
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(result);
+ g_warn_if_fail (g_simple_async_result_get_source_tag(simple) ==
+ gvir_connection_fetch_storage_pools);
+ if (g_simple_async_result_propagate_error(simple, err))
+ return FALSE;
+ }
+
+ return TRUE;
+}
const gchar *gvir_connection_get_uri(GVirConnection *conn)
{
@@ -595,6 +804,25 @@ GList *gvir_connection_get_domains(GVirConnection *conn)
}
/**
+ * gvir_connection_get_storage_pools:
+ *
+ * Return value: (element-type LibvirtGObject.StoragePool) (transfer full): List
+ * of #GVirStoragePool
+ */
+GList *gvir_connection_get_storage_pools(GVirConnection *conn)
+{
+ GVirConnectionPrivate *priv = conn->priv;
+ GList *pools;
+
+ g_mutex_lock(priv->lock);
+ pools = g_hash_table_get_values(priv->pools);
+ g_list_foreach(pools, gvir_domain_ref, NULL);
+ g_mutex_unlock(priv->lock);
+
+ return pools;
+}
+
+/**
* gvir_connection_get_domain:
* @uuid: uuid string of the requested domain
*
@@ -613,6 +841,26 @@ GVirDomain *gvir_connection_get_domain(GVirConnection *conn,
return dom;
}
+/**
+ * gvir_connection_get_storage_pool:
+ * @uuid: uuid string of the requested storage pool
+ *
+ * Return value: (transfer full): the #GVirStoragePool, or NULL
+ */
+GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
+ const gchar *uuid)
+{
+ GVirConnectionPrivate *priv = conn->priv;
+ GVirStoragePool *pool;
+
+ g_mutex_lock(priv->lock);
+ pool = g_hash_table_lookup(priv->pools, uuid);
+ if (pool)
+ g_object_ref(pool);
+ g_mutex_unlock(priv->lock);
+
+ return pool;
+}
/**
* gvir_connection_find_domain_by_id:
@@ -677,6 +925,37 @@ GVirDomain *gvir_connection_find_domain_by_name(GVirConnection *conn,
return NULL;
}
+/**
+ * gvir_connection_find_storage_pool_by_name:
+ * @name: name of the requested storage pool
+ *
+ * Return value: (transfer full): the #GVirStoragePool, or NULL
+ */
+GVirStoragePool *gvir_connection_find_storage_pool_by_name(GVirConnection *conn,
+ const gchar *name)
+{
+ GVirConnectionPrivate *priv = conn->priv;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_mutex_lock(priv->lock);
+ g_hash_table_iter_init(&iter, priv->pools);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ GVirStoragePool *pool = value;
+ const gchar *thisname = gvir_storage_pool_get_name(pool);
+
+ if (strcmp(thisname, name) == 0) {
+ g_object_ref(pool);
+ g_mutex_unlock(priv->lock);
+ return pool;
+ }
+ }
+ g_mutex_unlock(priv->lock);
+
+ return NULL;
+}
+
static gpointer
gvir_connection_handle_copy(gpointer src)
{
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index c453bed..d05f792 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -141,14 +141,24 @@ GVirNodeDevice *gvir_connection_get_node_device(GVirConnection *conn,
GList *gvir_connection_get_secrets(GVirConnection *conn);
GVirSecret *gvir_connection_get_secret(GVirConnection *conn,
const gchar *uuid);
+#endif
+gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
+ GCancellable *cancellable,
+ GError **err);
+void gvir_connection_fetch_storage_pools_async(GVirConnection *conn,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer opaque);
+gboolean gvir_connection_fetch_storage_pools_finish(GVirConnection *conn,
+ GAsyncResult *result,
+ GError **err);
GList *gvir_connection_get_storage_pools(GVirConnection *conn);
GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
const gchar *uuid);
GVirStoragePool *gvir_connection_find_storage_pool_by_name(GVirConnection *conn,
const gchar *name);
-#endif
GVirStream *gvir_connection_get_stream(GVirConnection *conn,
gint flags);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index eae40a2..ff2f4cf 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -14,10 +14,16 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_connection_get_stream;
gvir_connection_fetch_domains;
+ gvir_connection_fetch_storage_pools;
+ gvir_connection_fetch_storage_pools_async;
+ gvir_connection_fetch_storage_pools_finish;
gvir_connection_get_domains;
+ gvir_connection_get_storage_pools;
gvir_connection_get_domain;
+ gvir_connection_get_storage_pool;
gvir_connection_find_domain_by_id;
gvir_connection_find_domain_by_name;
+ gvir_connection_find_storage_pool_by_name;
gvir_connection_create_domain;
gvir_domain_get_type;
--
1.7.6.2
13 years, 1 month
[libvirt] [PATCH] remote_driver: Avoid double free in EventControl building
by Michal Privoznik
Don't xdr_free event data as they are freed by our caller
virNetClientProgramDispatch.
---
src/remote/remote_driver.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 83f4f3c..2b2f41e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3315,7 +3315,6 @@ remoteDomainBuildEventControlError(virNetClientProgramPtr prog ATTRIBUTE_UNUSED,
return;
event = virDomainEventControlErrorNewFromDom(dom);
- xdr_free ((xdrproc_t) &xdr_remote_domain_event_control_error_msg, (char *) &msg);
virDomainFree(dom);
--
1.7.3.4
13 years, 1 month
[libvirt] [PATCH] build: fix 'make distcheck' with pdwtags installed
by Eric Blake
I am getting this failure with 'make distcheck':
GEN ../../src/remote_protocol-structs
/bin/sh: ../../src/remote_protocol-structs-t: Permission denied
make[4]: *** [../../src/remote_protocol-structs] Error 1
since it attempts a sub-run of a VPATH 'make check' where $(srcdir)
is intentionally read-only. I'm not sure which commit introduced
the problem, although I suspect it was around 62dee6f when I
refactored protocol struct checking to be more powerful.
$(@F) is required by POSIX, and although it is not yet portable
to all make implementations, we already require GNU make.
* src/Makefile.am (PDWTAGS): Generate temp file into current
directory, since $(srcdir) is read-only during distcheck.
---
src/Makefile.am | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 738ee91..9650139 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -255,9 +255,9 @@ PDWTAGS = \
-e ' exit 8;' \
-e ' }' \
-e '}' \
- > $@-t; \
+ > $(@F)-t; \
case $$? in 8) exit 0;; 0) ;; *) exit 1;; esac; \
- diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \
+ diff -u $(@F)-t $@; st=$$?; rm -f $(@F)-t; exit $$st; \
else \
echo 'WARNING: you lack pdwtags; skipping the $@ test' >&2; \
echo 'WARNING: install the dwarves package to get pdwtags' >&2; \
--
1.7.4.4
13 years, 1 month
[libvirt] [PATCH 2/2] xenParseXM: don't dereference NULL pointer when script is empty
by Guido Günther
O.k. to apply?
-- Guido
---
src/xenxs/xen_xm.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index d057043..30188e2 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -697,8 +697,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
}
- if (bridge[0] || STREQ(script, "vif-bridge") ||
- STREQ(script, "vif-vnic")) {
+ if (bridge[0] || (script && (STREQ(script, "vif-bridge") ||
+ STREQ(script, "vif-vnic")))) {
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
} else {
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
@@ -715,7 +715,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
!(net->data.bridge.ipaddr = strdup(ip)))
goto no_memory;
} else {
- if (script[0] &&
+ if (script && script[0] &&
!(net->data.ethernet.script = strdup(script)))
goto no_memory;
if (ip[0] &&
--
1.7.6.3
13 years, 1 month