[libvirt] [libvirt-glib 1/4] gobject: don't try to use pool's volumes before a successful refresh
by Christophe Fergeau
gvir_storage_pool_refresh must be called and must be successful before
trying to use gvir_storage_pool_get_volume,
gvir_storage_pool_get_volumes and gvir_storage_pool_create_volume.
As the storage pool refresh can fail for reasons external to
libvirt/libvirt-gobject, the library user should check _refresh
errors. This commit outputs runtime warnings when these functions
are called and GVirObjectStoragePool::priv::volumes is NULL.
---
libvirt-gobject/libvirt-gobject-storage-pool.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 7f50037..a4316e9 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -523,6 +523,8 @@ GList *gvir_storage_pool_get_volumes(GVirStoragePool *pool)
if (priv->volumes != NULL) {
volumes = g_hash_table_get_values(priv->volumes);
g_list_foreach(volumes, gvir_storage_vol_ref, NULL);
+ } else {
+ g_warn_if_reached();
}
g_mutex_unlock(priv->lock);
@@ -548,9 +550,14 @@ GVirStorageVol *gvir_storage_pool_get_volume(GVirStoragePool *pool,
priv = pool->priv;
g_mutex_lock(priv->lock);
- volume = g_hash_table_lookup(priv->volumes, name);
- if (volume)
- g_object_ref(volume);
+ if (priv->volumes != NULL) {
+ volume = g_hash_table_lookup(priv->volumes, name);
+ if (volume)
+ g_object_ref(volume);
+ } else {
+ g_warn_if_reached();
+ volume = NULL;
+ }
g_mutex_unlock(priv->lock);
return volume;
@@ -604,7 +611,14 @@ GVirStorageVol *gvir_storage_pool_create_volume
}
g_mutex_lock(priv->lock);
- g_hash_table_insert(priv->volumes, g_strdup(name), volume);
+ if (priv->volumes != NULL) {
+ g_hash_table_insert(priv->volumes, g_strdup(name), volume);
+ } else {
+ g_warn_if_reached();
+ g_object_unref(G_OBJECT(volume));
+ g_mutex_unlock(priv->lock);
+ return NULL;
+ }
g_mutex_unlock(priv->lock);
return g_object_ref(volume);
--
1.7.12.1
12 years
[libvirt] Is possible that cpu_maps.xml changed during different releases?
by Jiang, Yunhong
Hi, all
I have two questions to the cpu_maps.xml in different releases, hope someone can give me some hints:
a) Will it be possible that the features defined in cpu_maps.xml for one specific CPU model (like Nehalem) will be different? For example, one feature is not listed for Nehalem in release x.y, and added in release x.y+1?
2) Is the format of the cpu_maps.xml fine defined or will be it changed during releases? I asked this because currently the features defined in the capabilities only list features not included in the definition in cpu_maps.xml for the corresponding model. So if I want to get the full features supported by the host, I have to parse the capabilities and the cpu_maps.xml. I didn't find the definition for cpu_maps.xml format, although the capabilities format is well defined in http://libvirt.org/guide/html/Application_Development_Guide-Connections-C....
Thanks
--jyh
12 years
[libvirt] [libvirt-glib] Introduce gvir_warning/gvir_critical
by Christophe Fergeau
They are similar to g_warning/g_critical, but also log the last
libvirt error. They are meant to be called right after a libvirt
call failed, in other cases g_warning/g_critical are still to be
used.
---
libvirt-glib/libvirt-glib-error.c | 34 +++++++++++++++++++++++
libvirt-glib/libvirt-glib-error.h | 2 ++
libvirt-glib/libvirt-glib.sym | 5 ++++
libvirt-gobject/libvirt-gobject-connection.c | 4 +--
libvirt-gobject/libvirt-gobject-domain-snapshot.c | 2 +-
libvirt-gobject/libvirt-gobject-domain.c | 14 ++--------
libvirt-gobject/libvirt-gobject-interface.c | 2 +-
libvirt-gobject/libvirt-gobject-network-filter.c | 17 ++++--------
libvirt-gobject/libvirt-gobject-network.c | 14 ++--------
libvirt-gobject/libvirt-gobject-node-device.c | 4 +--
libvirt-gobject/libvirt-gobject-secret.c | 11 ++------
libvirt-gobject/libvirt-gobject-storage-pool.c | 17 +++---------
libvirt-gobject/libvirt-gobject-storage-vol.c | 2 +-
libvirt-gobject/libvirt-gobject-stream.c | 2 +-
14 files changed, 66 insertions(+), 64 deletions(-)
diff --git a/libvirt-glib/libvirt-glib-error.c b/libvirt-glib/libvirt-glib-error.c
index 7356aed..5c97da4 100644
--- a/libvirt-glib/libvirt-glib-error.c
+++ b/libvirt-glib/libvirt-glib-error.c
@@ -257,3 +257,37 @@ void gvir_set_error_valist(GError **error,
g_free(message);
}
+
+static void
+gvir_log_valist(GLogLevelFlags level, const gchar *format, va_list args)
+{
+ gchar *message;
+ virErrorPtr verr = virGetLastError();
+
+ message = g_strdup_vprintf(format, args);
+
+ if (verr)
+ g_log(G_LOG_DOMAIN, level, "%s: %s", message, verr->message);
+ else
+ g_log(G_LOG_DOMAIN, level, "%s", message);
+
+ g_free(message);
+}
+
+void gvir_warning(const gchar *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ gvir_log_valist(G_LOG_LEVEL_WARNING, format, args);
+ va_end(args);
+}
+
+void gvir_critical(const gchar *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ gvir_log_valist(G_LOG_LEVEL_CRITICAL, format, args);
+ va_end(args);
+}
diff --git a/libvirt-glib/libvirt-glib-error.h b/libvirt-glib/libvirt-glib-error.h
index 9e44383..1421047 100644
--- a/libvirt-glib/libvirt-glib-error.h
+++ b/libvirt-glib/libvirt-glib-error.h
@@ -59,6 +59,8 @@ void gvir_set_error_valist(GError **error,
const gchar *format,
va_list args);
+void gvir_critical(const gchar *format, ...);
+void gvir_warning(const gchar *format, ...);
G_END_DECLS
diff --git a/libvirt-glib/libvirt-glib.sym b/libvirt-glib/libvirt-glib.sym
index 53b8907..d9ddb07 100644
--- a/libvirt-glib/libvirt-glib.sym
+++ b/libvirt-glib/libvirt-glib.sym
@@ -15,4 +15,9 @@ LIBVIRT_GLIB_0.0.7 {
*;
};
+LIBVIRT_GLIB_0.1.4 {
+ gvir_critical;
+ gvir_warning;
+} LIBVIRT_GLIB_0.0.7;
+
# .... define new API here using predicted next version number ....
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 9628989..e6ccfd0 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -273,7 +273,7 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
GVirConnectionPrivate *priv = gconn->priv;
if (virDomainGetUUIDString(dom, uuid) < 0) {
- g_warning("Failed to get domain UUID on %p", dom);
+ gvir_warning("Failed to get domain UUID on %p", dom);
return 0;
}
@@ -463,7 +463,7 @@ gboolean gvir_connection_open(GVirConnection *conn,
}
if (virConnectDomainEventRegister(priv->conn, domain_event_cb, conn, NULL) == -1)
- g_warning("Failed to register domain events, ignoring");
+ gvir_warning("Failed to register domain events, ignoring");
g_mutex_unlock(priv->lock);
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 11a073c..ce60ea0 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -167,7 +167,7 @@ const gchar *gvir_domain_snapshot_get_name(GVirDomainSnapshot *snapshot)
const char *name;
if (!(name = virDomainSnapshotGetName(priv->handle))) {
- g_warning("Failed to get domain_snapshot name on %p", priv->handle);
+ gvir_warning("Failed to get domain_snapshot name on %p", priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 8ade3ea..9d4e232 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -135,16 +135,8 @@ static void gvir_domain_constructed(GObject *object)
G_OBJECT_CLASS(gvir_domain_parent_class)->constructed(object);
/* xxx we may want to turn this into an initable */
- if (virDomainGetUUIDString(priv->handle, priv->uuid) < 0) {
- virErrorPtr verr = virGetLastError();
- if (verr) {
- g_warning("Failed to get domain UUID on %p: %s",
- priv->handle, verr->message);
- } else {
- g_warning("Failed to get domain UUID on %p",
- priv->handle);
- }
- }
+ if (virDomainGetUUIDString(priv->handle, priv->uuid) < 0)
+ gvir_warning("Failed to get domain UUID on %p", priv->handle);
}
@@ -292,7 +284,7 @@ const gchar *gvir_domain_get_name(GVirDomain *dom)
priv = dom->priv;
if (!(name = virDomainGetName(priv->handle))) {
- g_warning("Failed to get domain name on %p", priv->handle);
+ gvir_warning("Failed to get domain name on %p", priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-interface.c b/libvirt-gobject/libvirt-gobject-interface.c
index ecabb41..4523100 100644
--- a/libvirt-gobject/libvirt-gobject-interface.c
+++ b/libvirt-gobject/libvirt-gobject-interface.c
@@ -164,7 +164,7 @@ const gchar *gvir_interface_get_name(GVirInterface *iface)
g_return_val_if_fail(GVIR_IS_INTERFACE(iface), NULL);
if (!(name = virInterfaceGetName(iface->priv->handle))) {
- g_warning("Failed to get interface name on %p", iface->priv->handle);
+ gvir_warning("Failed to get interface name on %p", iface->priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index 00b1ed2..54c1eeb 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -118,16 +118,9 @@ static void gvir_network_filter_constructed(GObject *object)
G_OBJECT_CLASS(gvir_network_filter_parent_class)->constructed(object);
/* xxx we may want to turn this into an initable */
- if (virNWFilterGetUUIDString(priv->handle, priv->uuid) < 0) {
- virErrorPtr verr = virGetLastError();
- if (verr) {
- g_warning("Failed to get network filter UUID on %p: %s",
- priv->handle, verr->message);
- } else {
- g_warning("Failed to get network filter UUID on %p",
- priv->handle);
- }
- }
+ if (virNWFilterGetUUIDString(priv->handle, priv->uuid) < 0)
+ gvir_warning("Failed to get network filter UUID on %p",
+ priv->handle);
}
@@ -187,8 +180,8 @@ const gchar *gvir_network_filter_get_name(GVirNetworkFilter *filter)
g_return_val_if_fail(GVIR_IS_NETWORK_FILTER(filter), NULL);
if (!(name = virNWFilterGetName(filter->priv->handle))) {
- g_warning("Failed to get network_filter name on %p",
- filter->priv->handle);
+ gvir_warning("Failed to get network_filter name on %p",
+ filter->priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 9625ece..0f17ecc 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -117,16 +117,8 @@ static void gvir_network_constructed(GObject *object)
G_OBJECT_CLASS(gvir_network_parent_class)->constructed(object);
/* xxx we may want to turn this into an initable */
- if (virNetworkGetUUIDString(priv->handle, priv->uuid) < 0) {
- virErrorPtr verr = virGetLastError();
- if (verr) {
- g_warning("Failed to get network UUID on %p: %s",
- priv->handle, verr->message);
- } else {
- g_warning("Failed to get network UUID on %p",
- priv->handle);
- }
- }
+ if (virNetworkGetUUIDString(priv->handle, priv->uuid) < 0)
+ gvir_warning("Failed to get network UUID on %p", priv->handle);
}
static void gvir_network_class_init(GVirNetworkClass *klass)
@@ -185,7 +177,7 @@ const gchar *gvir_network_get_name(GVirNetwork *network)
g_return_val_if_fail(GVIR_IS_NETWORK(network), NULL);
if (!(name = virNetworkGetName(network->priv->handle))) {
- g_warning("Failed to get network name on %p", network->priv->handle);
+ gvir_warning("Failed to get network name on %p", network->priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-node-device.c b/libvirt-gobject/libvirt-gobject-node-device.c
index eb314ed..781fc5d 100644
--- a/libvirt-gobject/libvirt-gobject-node-device.c
+++ b/libvirt-gobject/libvirt-gobject-node-device.c
@@ -164,8 +164,8 @@ const gchar *gvir_node_device_get_name(GVirNodeDevice *device)
g_return_val_if_fail(GVIR_IS_NODE_DEVICE(device), NULL);
if (!(name = virNodeDeviceGetName(device->priv->handle))) {
- g_warning("Failed to get node_device name on %p",
- device->priv->handle);
+ gvir_warning("Failed to get node_device name on %p",
+ device->priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c
index 8bfee88..01b8ed1 100644
--- a/libvirt-gobject/libvirt-gobject-secret.c
+++ b/libvirt-gobject/libvirt-gobject-secret.c
@@ -118,15 +118,8 @@ static void gvir_secret_constructed(GObject *object)
G_OBJECT_CLASS(gvir_secret_parent_class)->constructed(object);
/* xxx we may want to turn this into an initable */
- if (virSecretGetUUIDString(priv->handle, priv->uuid) < 0) {
- virErrorPtr verr = virGetLastError();
- if (verr) {
- g_warning("Failed to get secret UUID on %p: %s",
- priv->handle, verr->message);
- } else {
- g_warning("Failed to get secret UUID on %p", priv->handle);
- }
- }
+ if (virSecretGetUUIDString(priv->handle, priv->uuid) < 0)
+ gvir_warning("Failed to get secret UUID on %p", priv->handle);
}
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index a09e5a7..adcdda7 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -128,15 +128,8 @@ static void gvir_storage_pool_constructed(GObject *object)
G_OBJECT_CLASS(gvir_storage_pool_parent_class)->constructed(object);
/* xxx we may want to turn this into an initable */
- if (virStoragePoolGetUUIDString(priv->handle, priv->uuid) < 0) {
- virErrorPtr verr = virGetLastError();
- if (verr) {
- g_warning("Failed to get storage pool UUID on %p: %s",
- priv->handle, verr->message);
- } else {
- g_warning("Failed to get storage pool UUID on %p", priv->handle);
- }
- }
+ if (virStoragePoolGetUUIDString(priv->handle, priv->uuid) < 0)
+ gvir_warning("Failed to get storage pool UUID on %p", priv->handle);
}
@@ -215,10 +208,8 @@ const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool)
g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), NULL);
- if (!(name = virStoragePoolGetName(pool->priv->handle))) {
- g_warning("Failed to get storage_pool name on %p", pool->priv->handle);
- return NULL;
- }
+ if (!(name = virStoragePoolGetName(pool->priv->handle)))
+ gvir_warning("Failed to get storage_pool name on %p", pool->priv->handle);
return name;
}
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 9256445..c7ebb45 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -200,7 +200,7 @@ const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol)
g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), NULL);
if (!(name = virStorageVolGetName(vol->priv->handle))) {
- g_warning("Failed to get storage_vol name on %p", vol->priv->handle);
+ gvir_warning("Failed to get storage_vol name on %p", vol->priv->handle);
return NULL;
}
diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c
index fa1a32c..f0e43d0 100644
--- a/libvirt-gobject/libvirt-gobject-stream.c
+++ b/libvirt-gobject/libvirt-gobject-stream.c
@@ -218,7 +218,7 @@ static void gvir_stream_finalize(GObject *object)
gvir_stream_update_events(self);
if (virStreamFinish(priv->handle) < 0)
- g_critical("cannot finish stream");
+ gvir_critical("cannot finish stream");
virStreamFree(priv->handle);
}
--
1.7.12.1
12 years
[libvirt] [libvirt-glib] Add gvir_domain_update_device() and enums needed for it
by Alexander Larsson
This is a wrapper for virDomainUpdateDeviceFlags.
---
libvirt-gobject/libvirt-gobject-domain.c | 42 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 17 +++++++++++++
libvirt-gobject/libvirt-gobject.sym | 7 ++++++
3 files changed, 66 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 8ade3ea..a00a042 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1428,6 +1428,48 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
return g_list_reverse (ret);
}
+
+/**
+ * gvir_domain_update_device:
+ * @dom: the domain
+ * @device: A modified device config
+ * @flags: bitwise-OR of #GVirDomainUpdateDeviceFlags
+ * @err: (allow-none):Place-holder for error or NULL
+ *
+ * Update the configuration of a device.
+ *
+ * Returns: TRUE if device was updated successfully, FALSE otherwise.
+ */
+gboolean
+gvir_domain_update_device(GVirDomain *dom,
+ GVirConfigDomainDevice *device,
+ guint flags,
+ GError **err)
+{
+ gchar *xml;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+ g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DEVICE(device), FALSE);
+
+ xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(device));
+ g_return_val_if_fail(xml != NULL, FALSE);
+
+ if (virDomainUpdateDeviceFlags(dom->priv->handle,
+ xml, flags) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Failed to update device");
+ g_free (xml);
+
+ return FALSE;
+ }
+
+ g_free (xml);
+ return TRUE;
+}
+
+
/**
* gvir_domain_create_snapshot:
* @dom: the domain
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6e7b10d..a622a46 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -158,6 +158,18 @@ typedef enum {
GVIR_DOMAIN_SNAPSHOT_ATOMIC = VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC,
} GVirDomainSnapshotCreateFlags;
+/**
+ * GVirDomainUpdateDeviceFlags:
+ * @GVIR_DOMAIN_UPDATE_DEVICE_CURRENT: Update current domain state
+ * @GVIR_DOMAIN_UPDATE_DEVICE_LIVE: Update state for only active domains
+ * @GVIR_DOMAIN_UPDATE_DEVICE_CONFIG: Update state for persistent state only
+ */
+typedef enum {
+ GVIR_DOMAIN_UPDATE_DEVICE_CURRENT = VIR_DOMAIN_AFFECT_CURRENT,
+ GVIR_DOMAIN_UPDATE_DEVICE_LIVE = VIR_DOMAIN_AFFECT_LIVE,
+ GVIR_DOMAIN_UPDATE_DEVICE_CONFIG = VIR_DOMAIN_AFFECT_CONFIG,
+} GVirDomainUpdateDeviceFlags;
+
typedef struct _GVirDomainInfo GVirDomainInfo;
struct _GVirDomainInfo
{
@@ -294,6 +306,11 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
GList *gvir_domain_get_devices(GVirDomain *domain,
GError **err);
+gboolean gvir_domain_update_device(GVirDomain *dom,
+ GVirConfigDomainDevice *device,
+ guint flags,
+ GError **err);
+
GVirDomainSnapshot *
gvir_domain_create_snapshot(GVirDomain *dom,
GVirConfigDomainSnapshot *custom_conf,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 3a40a8a..2034e89 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -204,4 +204,11 @@ LIBVIRT_GOBJECT_0.1.3 {
gvir_domain_wakeup_finish;
} LIBVIRT_GOBJECT_0.1.2;
+LIBVIRT_GOBJECT_0.1.4 {
+ global:
+ gvir_domain_update_device_flags_get_type;
+ gvir_domain_update_device;
+} LIBVIRT_GOBJECT_0.1.3;
+
+
# .... define new API here using predicted next version number ....
--
1.7.12.1
12 years
[libvirt] [PATCH] qemu: Don't force port=0 for SPICE
by Michal Privoznik
If domain uses only TLS port we don't want to add
'port=0' explicitly to command line.
---
src/qemu/qemu_command.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1e96982..440fd62 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6023,6 +6023,8 @@ qemuBuildCommandLine(virConnectPtr conn,
char *netAddr = NULL;
int ret;
int defaultMode = def->graphics[0]->data.spice.defaultMode;
+ int port = def->graphics[0]->data.spice.port;
+ int tlsPort = def->graphics[0]->data.spice.tlsPort;
if (!qemuCapsGet(caps, QEMU_CAPS_SPICE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -6030,17 +6032,19 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
- virBufferAsprintf(&opt, "port=%u", def->graphics[0]->data.spice.port);
+ if (port > 0 || tlsPort <= 0)
+ virBufferAsprintf(&opt, "port=%u", port);
- if (def->graphics[0]->data.spice.tlsPort > 0) {
+ if (tlsPort > 0) {
if (!driver->spiceTLS) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spice TLS port set in XML configuration,"
" but TLS is disabled in qemu.conf"));
goto error;
}
- virBufferAsprintf(&opt, ",tls-port=%u",
- def->graphics[0]->data.spice.tlsPort);
+ if (port > 0)
+ virBufferAddChar(&opt, ',');
+ virBufferAsprintf(&opt, "tls-port=%u", tlsPort);
}
switch (virDomainGraphicsListenGetType(def->graphics[0], 0)) {
--
1.7.8.6
12 years
[libvirt] [PATCHv3 0/5] Add initial support for reverting snapshots
by Peter Krempa
This series adds basic support for reverting to a snapshot. For more advanced
support we need the creation of snapshot branches.
As of now, we will be able just to invalidate the snapshot tree from the point
we're reverting to.
I'll follow up with patches that add ability to delete children snapshots when reverting
to a deeper tree.
Peter Krempa (5):
qemu: Split out guts of qemuDomainSaveImageStartVM() to allow reuse
snapshot: qemu: Fix detection of external snapshots when deleting
snapshot: Add flag VIR_DOMAIN_SNAPSHOT_REVERT_STOPPED
snapshot: Add flag to allow hypervisor restart when reverting
snapshots
snapshot: qemu: Implement reverting of external snapshots
include/libvirt/libvirt.h.in | 3 +
src/conf/snapshot_conf.c | 17 ++
src/conf/snapshot_conf.h | 2 +
src/libvirt.c | 36 ++--
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 383 ++++++++++++++++++++++++++++++++++++++++---
tools/virsh-snapshot.c | 7 +
tools/virsh.pod | 19 ++-
8 files changed, 423 insertions(+), 45 deletions(-)
--
1.8.0
12 years
[libvirt] [libvirt-glib] gobject: Add gvir_storage_pool_get_{active, persistent}
by Christophe Fergeau
---
This goes on top of the "[libvirt-glib 1/4] gobject: don't try to use
pool's volumes before a successful refresh" series.
Christophe
libvirt-gobject/libvirt-gobject-storage-pool.c | 15 +++++++++++++++
libvirt-gobject/libvirt-gobject-storage-pool.h | 2 ++
libvirt-gobject/libvirt-gobject.sym | 2 ++
3 files changed, 19 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 96670df..8f579a1 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -223,6 +223,21 @@ const gchar *gvir_storage_pool_get_uuid(GVirStoragePool *pool)
}
+gboolean gvir_storage_pool_get_active(GVirStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE);
+
+ return virStoragePoolIsActive(pool->priv->handle);
+}
+
+
+gboolean gvir_storage_pool_get_persistent(GVirStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE);
+
+ return virStoragePoolIsPersistent(pool->priv->handle);
+}
+
/**
* gvir_storage_pool_get_config:
* @pool: the storage_pool
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index 1a1aae5..467f8f8 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -82,6 +82,8 @@ GType gvir_storage_pool_handle_get_type(void);
const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool);
const gchar *gvir_storage_pool_get_uuid(GVirStoragePool *pool);
+gboolean gvir_storage_pool_get_active(GVirStoragePool *pool);
+gboolean gvir_storage_pool_get_persistent(GVirStoragePool *pool);
GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
guint flags,
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a06d35f..8b9b605 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -208,6 +208,8 @@ LIBVIRT_GOBJECT_0.1.4 {
gvir_storage_pool_delete;
gvir_storage_pool_delete_async;
gvir_storage_pool_delete_finish;
+ gvir_storage_pool_get_active;
+ gvir_storage_pool_get_persistent;
gvir_storage_pool_stop;
gvir_storage_pool_stop_async;
gvir_storage_pool_stop_finish;
--
1.8.0
12 years
[libvirt] [PATCH] tests: Remove temporary directories in qemumonitorjsontest
by Peter Krempa
qemumonitorjsontest creates a temporary directory to hold the socket
that is simulating the monitor socket. The directory containing the
socket wasn't disposed properly at the end of the test leaving garbage
in the temporary folder.
---
tests/qemumonitortestutils.c | 60 ++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 27 deletions(-)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 7f7c855..b55d867 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -65,6 +65,8 @@ struct _qemuMonitorTest {
qemuMonitorPtr mon;
+ char *tmpdir;
+
size_t nitems;
qemuMonitorTestItemPtr *items;
@@ -378,6 +380,11 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test)
qemuMonitorTestItemFree(test->items[i]);
VIR_FREE(test->items);
+ if (test->tmpdir && rmdir(test->tmpdir) < 0)
+ VIR_WARN("Failed to remove tempdir: %s", strerror(errno));
+
+ VIR_FREE(test->tmpdir);
+
virMutexDestroy(&test->lock);
VIR_FREE(test);
}
@@ -438,31 +445,11 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
{
qemuMonitorTestPtr test = NULL;
virDomainChrSourceDef src;
+ char *path = NULL;
+ char *tmpdir_template = NULL;
- char *tmpdir = NULL, *path = NULL;
- char template[] = "/tmp/libvirt_XXXXXX";
-
- tmpdir = mkdtemp(template);
- if (tmpdir == NULL) {
- virReportSystemError(errno, "%s",
- "Failed to create temporary directory");
- goto error;
- }
-
- if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", tmpdir) < 0) {
- virReportOOMError();
- goto error;
- }
-
- memset(&src, 0, sizeof(src));
- src.type = VIR_DOMAIN_CHR_TYPE_UNIX;
- src.data.nix.path = (char *)path;
- src.data.nix.listen = false;
-
- if (VIR_ALLOC(test) < 0) {
- virReportOOMError();
- return NULL;
- }
+ if (VIR_ALLOC(test) < 0)
+ goto no_memory;
if (virMutexInit(&test->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -471,6 +458,20 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
return NULL;
}
+ if (!(tmpdir_template = strdup("/tmp/libvirt_XXXXXX")))
+ goto no_memory;
+
+ if (!(test->tmpdir = mkdtemp(tmpdir_template))) {
+ virReportSystemError(errno, "%s",
+ "Failed to create temporary directory");
+ goto error;
+ }
+
+ tmpdir_template = NULL;
+
+ if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", test->tmpdir) < 0)
+ goto no_memory;
+
test->json = json;
if (!(test->vm = virDomainObjNew(caps)))
goto error;
@@ -482,6 +483,10 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
&test->server) < 0)
goto error;
+ memset(&src, 0, sizeof(src));
+ src.type = VIR_DOMAIN_CHR_TYPE_UNIX;
+ src.data.nix.path = (char *)path;
+ src.data.nix.listen = false;
if (virNetSocketListen(test->server, 1) < 0)
goto error;
@@ -522,13 +527,14 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
virMutexUnlock(&test->lock);
cleanup:
- if (tmpdir)
- if (rmdir(tmpdir) < 0)
- VIR_WARN("Failed to remove tempdir: %s", strerror(errno));
VIR_FREE(path);
return test;
+no_memory:
+ virReportOOMError();
+
error:
+ VIR_FREE(tmpdir_template);
qemuMonitorTestFree(test);
goto cleanup;
}
--
1.8.0
12 years
[libvirt] [PATCH] tests: Fix qemumonitorjsontest deadlock when the machine is under load
by Peter Krempa
When doing the qemumonitorjsontest on a machine under heavy load the
test tends to deadlock from time to time. This patch adds the hack to
break the event loop that is used in virsh.
---
tests/qemumonitortestutils.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 93d2f62..7f7c855 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -331,9 +331,17 @@ static void qemuMonitorTestItemFree(qemuMonitorTestItemPtr item)
}
+static void
+qemuMonitorTestFreeTimer(int timer ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED)
+{
+ /* nothing to be done here */
+}
+
+
void qemuMonitorTestFree(qemuMonitorTestPtr test)
{
size_t i;
+ int timer = -1;
if (!test)
return;
@@ -341,6 +349,8 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test)
virMutexLock(&test->lock);
if (test->running) {
test->quit = true;
+ /* HACK: Add a dummy timeout to break event loop */
+ timer = virEventAddTimeout(0, qemuMonitorTestFreeTimer, NULL, NULL);
}
virMutexUnlock(&test->lock);
@@ -361,6 +371,9 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test)
if (test->running)
virThreadJoin(&test->thread);
+ if (timer != -1)
+ virEventRemoveTimeout(timer);
+
for (i = 0 ; i < test->nitems ; i++)
qemuMonitorTestItemFree(test->items[i]);
VIR_FREE(test->items);
--
1.8.0
12 years