[libvirt] [libvirt-glib] Make memory-handling more explicit in API doc
by Christophe Fergeau
Explain how the return value of the (transfer full) methods should
be freed. I also made some cosmetic changes in the API doc of some
of the files as I was modifying them.
---
libvirt-gconfig/libvirt-gconfig-domain-os.c | 11 ++-
libvirt-gconfig/libvirt-gconfig-domain.c | 28 ++++--
libvirt-gobject/libvirt-gobject-connection.c | 94 +++++++++++++-------
libvirt-gobject/libvirt-gobject-domain-device.c | 8 +-
libvirt-gobject/libvirt-gobject-domain-disk.c | 4 +-
libvirt-gobject/libvirt-gobject-domain-interface.c | 4 +-
libvirt-gobject/libvirt-gobject-domain-snapshot.c | 4 +-
libvirt-gobject/libvirt-gobject-domain.c | 16 ++--
libvirt-gobject/libvirt-gobject-interface.c | 3 +-
libvirt-gobject/libvirt-gobject-manager.c | 8 +-
libvirt-gobject/libvirt-gobject-network-filter.c | 4 +-
libvirt-gobject/libvirt-gobject-network.c | 3 +-
libvirt-gobject/libvirt-gobject-node-device.c | 4 +-
libvirt-gobject/libvirt-gobject-secret.c | 4 +-
libvirt-gobject/libvirt-gobject-storage-pool.c | 19 ++--
libvirt-gobject/libvirt-gobject-storage-vol.c | 6 +-
16 files changed, 157 insertions(+), 63 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.c b/libvirt-gconfig/libvirt-gconfig-domain-os.c
index 6e3cabd..9a1648a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.c
@@ -83,6 +83,7 @@ void gvir_config_domain_os_set_os_type(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_kernel:
+ * @os: a #GVirConfigDomainOs
* @kernel: (allow-none): The kernel path
*/
void gvir_config_domain_os_set_kernel(GVirConfigDomainOs *os,
@@ -94,6 +95,7 @@ void gvir_config_domain_os_set_kernel(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_ramdisk:
+ * @os: a #GVirConfigDomainOs
* @ramdisk: (allow-none): The ramdisk path
*/
void gvir_config_domain_os_set_ramdisk(GVirConfigDomainOs *os,
@@ -105,6 +107,7 @@ void gvir_config_domain_os_set_ramdisk(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_cmdline:
+ * @os: a #GVirConfigDomainOs
* @cmdline: (allow-none): The direct boot commandline
*/
void gvir_config_domain_os_set_cmdline(GVirConfigDomainOs *os,
@@ -116,6 +119,7 @@ void gvir_config_domain_os_set_cmdline(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_init:
+ * @os: a #GVirConfigDomainOs
* @init: (allow-none):
*/
void gvir_config_domain_os_set_init(GVirConfigDomainOs *os,
@@ -127,6 +131,7 @@ void gvir_config_domain_os_set_init(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_loader:
+ * @os: a #GVirConfigDomainOs
* @loader: (allow-none):
*/
void gvir_config_domain_os_set_loader(GVirConfigDomainOs *os,
@@ -183,6 +188,7 @@ void gvir_config_domain_os_set_smbios_mode(GVirConfigDomainOs *os,
/**
* gvir_config_domain_os_set_boot_devices:
+ * @os: a #GVirConfigDomainOs
* @boot_devices: (in) (element-type LibvirtGConfig.DomainOsBootDevice):
*/
void gvir_config_domain_os_set_boot_devices(GVirConfigDomainOs *os, GList *boot_devices)
@@ -246,8 +252,11 @@ static gboolean add_boot_device(xmlNodePtr node, gpointer opaque)
/**
* gvir_config_domain_os_get_boot_devices:
+ * @os: a #GVirConfigDomainOs
*
- * Gets the list of devices attached to @os
+ * Gets the list of devices attached to @os. The returned list should be
+ * freed with g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
*
* Returns: (element-type LibvirtGConfig.DomainOsBootDevice) (transfer full):
* a newly allocated #GList of #GVirConfigDomainOsBootDevice.
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index 9076a76..b6b43f0 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -206,6 +206,7 @@ const char *gvir_config_domain_get_name(GVirConfigDomain *domain)
/**
* gvir_config_domain_set_name:
+ * @domain: a #GVirConfigDomain
* @name: (allow-none):
*/
void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name)
@@ -223,6 +224,7 @@ const char *gvir_config_domain_get_description(GVirConfigDomain *domain)
/**
* gvir_config_domain_set_description:
+ * @domain: a #GVirConfigDomain
* @description: (allow-none):
*/
void gvir_config_domain_set_description(GVirConfigDomain *domain, const char *description)
@@ -234,7 +236,7 @@ void gvir_config_domain_set_description(GVirConfigDomain *domain, const char *de
/**
* gvir_config_domain_get_memory:
- * @domain: A domain configuration object.
+ * @domain: a #GVirConfigDomain
*
* Returns: amount of RAM in kilobytes (i.e. blocks of 1024 bytes).
*/
@@ -246,7 +248,7 @@ guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain)
/**
* gvir_config_domain_set_memory:
- * @domain: A domain configuration object.
+ * @domain: a #GVirConfigDomain
* @memory: The amount of RAM in kilobytes.
*
* Sets the amount of RAM allocated to @domain in kilobytes (i.e. blocks of 1024 bytes).
@@ -285,8 +287,11 @@ static gboolean add_feature(xmlNodePtr node, gpointer opaque)
/**
* gvir_config_domain_get_features:
+ * @domain: a #GVirConfigDomain
*
- * Returns: (transfer full):
+ * Returns: (transfer full): The returned list should be freed with
+ * g_strfreev() when no longer needed.
+
*/
GStrv gvir_config_domain_get_features(GVirConfigDomain *domain)
{
@@ -323,6 +328,7 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain,
/**
* gvir_config_domain_set_clock:
+ * @domain: a #GVirConfigDomain
* @klock: (allow-none):
*/
void gvir_config_domain_set_clock(GVirConfigDomain *domain,
@@ -338,10 +344,12 @@ void gvir_config_domain_set_clock(GVirConfigDomain *domain,
/**
* gvir_config_domain_get_os:
+ * @domain: a #GVirConfigDomain
*
* Gets the operating system configuration of @domain
*
- * Returns: (transfer full):
+ * Returns: (transfer full): A #GVirConfigDomainOs. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirConfigDomainOs *gvir_config_domain_get_os(GVirConfigDomain *domain)
{
@@ -358,7 +366,8 @@ GVirConfigDomainOs *gvir_config_domain_get_os(GVirConfigDomain *domain)
/**
* gvir_config_domain_set_os:
- * @os: (allow-none):
+ * @domain: a #GVirConfigDomain
+ * @os: (allow-none): the os configuration to set
*/
void gvir_config_domain_set_os(GVirConfigDomain *domain,
GVirConfigDomainOs *os)
@@ -373,7 +382,8 @@ void gvir_config_domain_set_os(GVirConfigDomain *domain,
/**
* gvir_config_domain_set_seclabel:
- * @seclabel: (allow-none):
+ * @domain: a #GVirConfigDomain
+ * @seclabel: (allow-none): the security label configuration to set
*/
void gvir_config_domain_set_seclabel(GVirConfigDomain *domain,
GVirConfigDomainSeclabel *seclabel)
@@ -410,6 +420,7 @@ void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
/**
* gvir_config_domain_set_devices:
+ * @domain: a #GVirConfigDomain
* @devices: (in) (element-type LibvirtGConfig.DomainDevice):
*/
void gvir_config_domain_set_devices(GVirConfigDomain *domain,
@@ -480,8 +491,11 @@ static gboolean add_device(xmlNodePtr node, gpointer opaque)
/**
* gvir_config_domain_get_devices:
+ * @domain: a #GVirConfigDomain
*
- * Gets the list of devices attached to @domain
+ * Gets the list of devices attached to @domain. The returned list should
+ * be freed with g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
*
* Returns: (element-type LibvirtGConfig.DomainDevice) (transfer full):
* a newly allocated #GList of #GVirConfigDomainDevice.
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 6469ebc..b12669d 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -400,7 +400,7 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
/**
* gvir_connection_open:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
*/
gboolean gvir_connection_open(GVirConnection *conn,
@@ -474,7 +474,7 @@ gvir_connection_open_helper(GSimpleAsyncResult *res,
/**
* gvir_connection_open_async:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
* @callback: (scope async): completion callback
* @user_data: (closure): opaque data for callback
@@ -500,7 +500,7 @@ void gvir_connection_open_async(GVirConnection *conn,
/**
* gvir_connection_open_finish:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @result: (transfer none): async method result
*/
gboolean gvir_connection_open_finish(GVirConnection *conn,
@@ -606,7 +606,7 @@ error:
/**
* gvir_connection_fetch_domains:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
*/
gboolean gvir_connection_fetch_domains(GVirConnection *conn,
@@ -735,7 +735,7 @@ cleanup:
/**
* gvir_connection_fetch_storage_pools:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
*/
gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
@@ -879,7 +879,7 @@ gvir_connection_fetch_domains_helper(GSimpleAsyncResult *res,
/**
* gvir_connection_fetch_domains_async:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
* @callback: (scope async): completion callback
* @user_data: (closure): opaque data for callback
@@ -904,7 +904,7 @@ void gvir_connection_fetch_domains_async(GVirConnection *conn,
/**
* gvir_connection_fetch_domains_finish:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @result: (transfer none): async method result
*/
gboolean gvir_connection_fetch_domains_finish(GVirConnection *conn,
@@ -938,7 +938,7 @@ gvir_connection_fetch_pools_helper(GSimpleAsyncResult *res,
/**
* gvir_connection_fetch_storage_pools_async:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
* @callback: (scope async): completion callback
* @user_data: (closure): opaque data for callback
@@ -963,7 +963,7 @@ void gvir_connection_fetch_storage_pools_async(GVirConnection *conn,
/**
* gvir_connection_fetch_storage_pools_finish:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @result: (transfer none): async method result
*/
gboolean gvir_connection_fetch_storage_pools_finish(GVirConnection *conn,
@@ -994,8 +994,13 @@ static void gvir_domain_ref(gpointer obj, gpointer ignore G_GNUC_UNUSED)
/**
* gvir_connection_get_domains:
+ * @conn: a #GVirConnection
*
- * Return value: (element-type LibvirtGObject.Domain) (transfer full): List of #GVirDomain
+ * Gets a list of the domains available through @conn.
+ *
+ * Return value: (element-type LibvirtGObject.Domain) (transfer full): List
+ * of #GVirDomain. The returned list should be freed with g_list_free(),
+ * after its elements have been unreffed with g_object_unref().
*/
GList *gvir_connection_get_domains(GVirConnection *conn)
{
@@ -1014,9 +1019,14 @@ GList *gvir_connection_get_domains(GVirConnection *conn)
/**
* gvir_connection_get_storage_pools:
+ * @conn: a #GVirConnection
+ *
+ * Gets a list of the storage pools available through @conn.
*
* Return value: (element-type LibvirtGObject.StoragePool) (transfer full): List
- * of #GVirStoragePool
+ * of #GVirStoragePool. The returned list should be freed with
+ * g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
*/
GList *gvir_connection_get_storage_pools(GVirConnection *conn)
{
@@ -1035,9 +1045,11 @@ GList *gvir_connection_get_storage_pools(GVirConnection *conn)
/**
* gvir_connection_get_domain:
+ * @conn: a #GVirConnection
* @uuid: uuid string of the requested domain
*
- * Return value: (transfer full): the #GVirDomain, or NULL
+ * Return value: (transfer full): the #GVirDomain, or NULL. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirDomain *gvir_connection_get_domain(GVirConnection *conn,
const gchar *uuid)
@@ -1054,9 +1066,11 @@ GVirDomain *gvir_connection_get_domain(GVirConnection *conn,
/**
* gvir_connection_get_storage_pool:
+ * @conn: a #GVirConnection
* @uuid: uuid string of the requested storage pool
*
- * Return value: (transfer full): the #GVirStoragePool, or NULL
+ * Return value: (transfer full): the #GVirStoragePool, or NULL. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
const gchar *uuid)
@@ -1075,9 +1089,11 @@ GVirStoragePool *gvir_connection_get_storage_pool(GVirConnection *conn,
/**
* gvir_connection_find_domain_by_id:
+ * @conn: a #GVirConnection
* @id: id of the requested domain
*
- * Return value: (transfer full): the #GVirDomain, or NULL
+ * Return value: (transfer full): the #GVirDomain, or NULL. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirDomain *gvir_connection_find_domain_by_id(GVirConnection *conn,
gint id)
@@ -1107,9 +1123,11 @@ GVirDomain *gvir_connection_find_domain_by_id(GVirConnection *conn,
/**
* gvir_connection_find_domain_by_name:
+ * @conn: a #GVirConnection
* @name: name of the requested domain
*
- * Return value: (transfer full): the #GVirDomain, or NULL
+ * Return value: (transfer full): the #GVirDomain, or NULL. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirDomain *gvir_connection_find_domain_by_name(GVirConnection *conn,
const gchar *name)
@@ -1141,9 +1159,11 @@ GVirDomain *gvir_connection_find_domain_by_name(GVirConnection *conn,
/**
* gvir_connection_find_storage_pool_by_name:
+ * @conn: a #GVirConnection
* @name: name of the requested storage pool
*
- * Return value: (transfer full): the #GVirStoragePool, or NULL
+ * Return value: (transfer full): the #GVirStoragePool, or NULL. The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirStoragePool *gvir_connection_find_storage_pool_by_name(GVirConnection *conn,
const gchar *name)
@@ -1193,9 +1213,11 @@ G_DEFINE_BOXED_TYPE(GVirConnectionHandle, gvir_connection_handle,
/**
* gvir_connection_get_stream:
+ * @conn: a #GVirConnection
* @flags: flags to use for the stream
*
- * Return value: (transfer full): a #GVirStream stream, or NULL
+ * Return value: (transfer full): a #GVirStream stream, or NULL.The returned
+ * object should be unreffed with g_object_unref() when no longer needed.
*/
GVirStream *gvir_connection_get_stream(GVirConnection *self,
guint flags)
@@ -1215,13 +1237,15 @@ GVirStream *gvir_connection_get_stream(GVirConnection *self,
/**
* gvir_connection_create_domain:
- * @conn: the connection on which to create the domain
+ * @conn: a #GVirConnection on which to create the domain
* @conf: the configuration for the new domain
*
* Create the configuration file for a new persistent domain.
* The returned domain will initially be in the shutoff state.
*
- * Returns: (transfer full): the newly created domain
+ * Returns: (transfer full): the newly created domain, or NULL if an error
+ * occurred. The returned object should be unreffed with g_object_unref()
+ * when no longer needed.
*/
GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
GVirConfigDomain *conf,
@@ -1261,13 +1285,15 @@ GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
/**
* gvir_connection_start_domain:
- * @conn: the connection on which to create the domain
+ * @conn: a #GVirConnection on which to create the domain
* @conf: the configuration for the new domain
*
* Start a new transient domain without persistent configuration.
* The returned domain will initially be running.
*
- * Returns: (transfer full): the newly created domain
+ * Returns: (transfer full): the newly created domain, or NULL if an error
+ * occurred. The returned object should be unreffed with g_object_unref()
+ * when no longer needed.
*/
GVirDomain *gvir_connection_start_domain(GVirConnection *conn,
GVirConfigDomain *conf,
@@ -1308,12 +1334,14 @@ GVirDomain *gvir_connection_start_domain(GVirConnection *conn,
/**
* gvir_connection_create_storage_pool:
- * @conn: the connection on which to create the pool
+ * @conn: a #GVirConnection on which to create the pool
* @conf: the configuration for the new storage pool
* @flags: the flags
* @err: return location for any #GError
*
- * Returns: (transfer full): the newly created storage pool
+ * Returns: (transfer full): the newly created storage pool, or NULL if an
+ * error occurred. The returned list should be freed with g_list_free(),
+ * after its elements have been unreffed with g_object_unref().
*/
GVirStoragePool *gvir_connection_create_storage_pool
(GVirConnection *conn,
@@ -1352,10 +1380,12 @@ GVirStoragePool *gvir_connection_create_storage_pool
/**
* gvir_connection_get_node_info:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @err: return location for any #GError
*
- * Returns: (transfer full): the info
+ * Returns: (transfer full): the info, or NULL if an error occurred. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
*/
GVirNodeInfo *gvir_connection_get_node_info(GVirConnection *conn,
GError **err)
@@ -1386,10 +1416,12 @@ GVirNodeInfo *gvir_connection_get_node_info(GVirConnection *conn,
/**
* gvir_connection_get_capabilities:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @err: return location for any #GError
*
- * Return value: (transfer full): a #GVirConfigCapabilities or NULL
+ * Return value: (transfer full): a #GVirConfigCapabilities or NULL. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
*/
GVirConfigCapabilities *gvir_connection_get_capabilities(GVirConnection *conn,
GError **err)
@@ -1436,7 +1468,7 @@ gvir_connection_get_capabilities_helper(GSimpleAsyncResult *res,
/**
* gvir_connection_get_capabilities_async:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @cancellable: (allow-none)(transfer none): cancellation object
* @callback: (scope async): completion callback
* @user_data: (closure): opaque data for callback
@@ -1461,10 +1493,12 @@ void gvir_connection_get_capabilities_async(GVirConnection *conn,
/**
* gvir_connection_get_capabilities_finish:
- * @conn: the connection
+ * @conn: a #GVirConnection
* @result: (transfer none): async method result
*
- * Return value: (transfer full): a #GVirConfigCapabilities or NULL.
+ * Return value: (transfer full): a #GVirConfigCapabilities or NULL. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
*/
GVirConfigCapabilities *
gvir_connection_get_capabilities_finish(GVirConnection *conn,
diff --git a/libvirt-gobject/libvirt-gobject-domain-device.c b/libvirt-gobject/libvirt-gobject-domain-device.c
index db50c09..9a65468 100644
--- a/libvirt-gobject/libvirt-gobject-domain-device.c
+++ b/libvirt-gobject/libvirt-gobject-domain-device.c
@@ -161,7 +161,9 @@ virDomainPtr gvir_domain_device_get_domain_handle(GVirDomainDevice *self)
* gvir_domain_device_get_domain:
* @device: the domain device
*
- * Returns: (transfer full): the associated domain
+ * Returns: (transfer full): the associated domain. The returned object
+ * should be unreffed with g_object_unref() when no longer needed.
+
*/
GVirDomain *gvir_domain_device_get_domain(GVirDomainDevice *device)
{
@@ -172,7 +174,9 @@ GVirDomain *gvir_domain_device_get_domain(GVirDomainDevice *device)
* gvir_domain_device_get_config:
* @device: the domain device
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
+
*/
GVirConfigDomainDevice *gvir_domain_device_get_config(GVirDomainDevice *device)
{
diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c
index fb85328..607e26c 100644
--- a/libvirt-gobject/libvirt-gobject-domain-disk.c
+++ b/libvirt-gobject/libvirt-gobject-domain-disk.c
@@ -112,7 +112,9 @@ static const gchar *gvir_domain_disk_get_path(GVirDomainDisk *self)
* within the stats structure may be returned as -1, which indicates
* that the hypervisor does not support that particular statistic.
*
- * Returns: (transfer full): the stats or %NULL in case of error
+ * Returns: (transfer full): the stats or %NULL in case of error.The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
**/
GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **err)
{
diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c
index 9f4b30d..7087cbc 100644
--- a/libvirt-gobject/libvirt-gobject-domain-interface.c
+++ b/libvirt-gobject/libvirt-gobject-domain-interface.c
@@ -114,7 +114,9 @@ static const gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
* within the stats structure may be returned as -1, which indicates
* that the hypervisor does not support that particular statistic.
*
- * Returns: (transfer full): the stats or %NULL in case of error
+ * Returns: (transfer full): the stats or %NULL in case of error. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
**/
GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *self, GError **err)
{
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index dbf0c51..d06d4d5 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -185,7 +185,9 @@ const gchar *gvir_domain_snapshot_get_name(GVirDomainSnapshot *snapshot)
* @snapshot: the domain_snapshot
* @flags: the flags
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
+
*/
GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
(GVirDomainSnapshot *snapshot,
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index e5113d4..9be568a 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -455,7 +455,8 @@ gboolean gvir_domain_reboot(GVirDomain *dom,
* @dom: the domain
* @flags: the flags
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
guint flags,
@@ -549,7 +550,8 @@ gboolean gvir_domain_set_config(GVirDomain *domain,
* gvir_domain_get_info:
* @dom: the domain
*
- * Returns: (transfer full): the info
+ * Returns: (transfer full): the info. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom,
GError **err)
@@ -631,7 +633,8 @@ void gvir_domain_get_info_async(GVirDomain *dom,
*
* Finishes the operation started by #gvir_domain_get_info_async.
*
- * Returns: (transfer full): the info
+ * Returns: (transfer full): the info. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirDomainInfo *gvir_domain_get_info_finish(GVirDomain *dom,
GAsyncResult *result,
@@ -661,7 +664,8 @@ GVirDomainInfo *gvir_domain_get_info_finish(GVirDomain *dom,
* @monitor_id: monitor ID to take screenshot from
* @flags: extra flags, currently unused
*
- * Returns: (transfer full): mime-type of the image format, or NULL upon error.
+ * Returns: (transfer full): a newly allocated string containing the
+ * mime-type of the image format, or NULL upon error.
*/
gchar *gvir_domain_screenshot(GVirDomain *dom,
GVirStream *stream,
@@ -958,7 +962,9 @@ gboolean gvir_domain_get_saved(GVirDomain *dom)
* @domain: the domain
* @err: place-holder for possible errors, or NULL
*
- * Gets the list of devices attached to @domain
+ * Gets the list of devices attached to @domain. The returned list should
+ * be freed with g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
*
* Returns: (element-type LibvirtGObject.DomainDevice) (transfer full): a newly
* allocated #GList of #GVirDomainDevice.
diff --git a/libvirt-gobject/libvirt-gobject-interface.c b/libvirt-gobject/libvirt-gobject-interface.c
index a8e299c..883cf92 100644
--- a/libvirt-gobject/libvirt-gobject-interface.c
+++ b/libvirt-gobject/libvirt-gobject-interface.c
@@ -177,7 +177,8 @@ const gchar *gvir_interface_get_name(GVirInterface *iface)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirConfigInterface *gvir_interface_get_config(GVirInterface *iface,
guint flags,
diff --git a/libvirt-gobject/libvirt-gobject-manager.c b/libvirt-gobject/libvirt-gobject-manager.c
index 010e8da..c44e711 100644
--- a/libvirt-gobject/libvirt-gobject-manager.c
+++ b/libvirt-gobject/libvirt-gobject-manager.c
@@ -161,7 +161,9 @@ void gvir_manager_remove_connection(GVirManager *man,
/**
* gvir_manager_get_connections:
*
- * Returns: (transfer full)(element-type GVirConnection): the connections
+ * Returns: (transfer full)(element-type GVirConnection): the connections.
+ * The returned list should be freed with g_list_free(), after its elements
+ * have been unreffed with g_object_unref().
*/
GList *gvir_manager_get_connections(GVirManager *man)
{
@@ -181,7 +183,9 @@ GList *gvir_manager_get_connections(GVirManager *man)
/**
* gvir_manager_find_connection_by_uri:
*
- * Returns: (transfer full)(allow-none): the connection,or NULL
+ * Returns: (transfer full)(allow-none): the connection,or NULL. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
*/
GVirConnection *gvir_manager_find_connection_by_uri(GVirManager *man,
const gchar *uri)
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index 103174b..b3db236 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -208,7 +208,9 @@ const gchar *gvir_network_filter_get_uuid(GVirNetworkFilter *filter)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
+
*/
GVirConfigNetworkFilter *gvir_network_filter_get_config
(GVirNetworkFilter *filter,
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 2d195d9..17378ec 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -205,7 +205,8 @@ const gchar *gvir_network_get_uuid(GVirNetwork *network)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network,
guint flags,
diff --git a/libvirt-gobject/libvirt-gobject-node-device.c b/libvirt-gobject/libvirt-gobject-node-device.c
index 6f81f1a..0a4b6a6 100644
--- a/libvirt-gobject/libvirt-gobject-node-device.c
+++ b/libvirt-gobject/libvirt-gobject-node-device.c
@@ -177,7 +177,9 @@ const gchar *gvir_node_device_get_name(GVirNodeDevice *device)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
+
*/
GVirConfigNodeDevice *gvir_node_device_get_config(GVirNodeDevice *device,
guint flags,
diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c
index 299fdca..b0aff13 100644
--- a/libvirt-gobject/libvirt-gobject-secret.c
+++ b/libvirt-gobject/libvirt-gobject-secret.c
@@ -193,7 +193,9 @@ const gchar *gvir_secret_get_uuid(GVirSecret *secret)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
+
*/
GVirConfigSecret *gvir_secret_get_config(GVirSecret *secret,
guint flags,
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index f09f122..e79c8e5 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -237,7 +237,8 @@ const gchar *gvir_storage_pool_get_uuid(GVirStoragePool *pool)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
guint flags,
@@ -264,7 +265,8 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
* @pool: the storage_pool
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the info
+ * Returns: (transfer full): the info. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool,
GError **err)
@@ -486,8 +488,10 @@ static void gvir_storage_vol_ref(gpointer obj, gpointer ignore G_GNUC_UNUSED)
* gvir_storage_pool_get_volumes:
* @pool: the storage pool
*
- * Return value: (element-type LibvirtGObject.StorageVol) (transfer full): List
- * of #GVirStorageVol
+ * Return value: (element-type LibvirtGObject.StorageVol) (transfer full):
+ * List of #GVirStorageVol. The returned list should be freed with
+ * g_list_free(), after its elements have been unreffed with
+ * g_object_unref().
*/
GList *gvir_storage_pool_get_volumes(GVirStoragePool *pool)
{
@@ -509,7 +513,9 @@ GList *gvir_storage_pool_get_volumes(GVirStoragePool *pool)
* @pool: the storage pool
* @name: Name of the requested storage volume
*
- * Return value: (transfer full): the #GVirStorageVol, or NULL
+ * Return value: (transfer full): the #GVirStorageVol, or NULL. The
+ * returned object should be unreffed with g_object_unref() when no longer
+ * needed.
*/
GVirStorageVol *gvir_storage_pool_get_volume(GVirStoragePool *pool,
const gchar *name)
@@ -532,7 +538,8 @@ GVirStorageVol *gvir_storage_pool_get_volume(GVirStoragePool *pool,
* @conf: the configuration for the new volume
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the newly created volume
+ * Returns: (transfer full): the newly created volume. The returned object
+ * should be unreffed with g_object_unref() when no longer needed.
*/
GVirStorageVol *gvir_storage_pool_create_volume
(GVirStoragePool *pool,
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index cd02b38..9e59576 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -227,7 +227,8 @@ const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol, GError **error)
* @flags: the flags
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the config
+ * Returns: (transfer full): the config. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
guint flags,
@@ -254,7 +255,8 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
* @vol: the storage_vol
* @err: Place-holder for possible errors
*
- * Returns: (transfer full): the info
+ * Returns: (transfer full): the info. The returned object should be
+ * unreffed with g_object_unref() when no longer needed.
*/
GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol,
GError **err)
--
1.7.10.1
12 years, 6 months
[libvirt] [PATCH] virsh: Allow users to reedit rejected XML
by Michal Privoznik
If users {net-,pool-,}edit but make a mistake in XML all changes
are permanently lost. However, if virsh is running in interactive
mode we can as user if he wants to re-edit the file and correct
the mistakes.
---
tools/console.c | 40 +++++++++++++++++++++++++---------------
tools/console.h | 1 +
tools/virsh.c | 41 +++++++++++++++++++++++++++++++++++------
3 files changed, 61 insertions(+), 21 deletions(-)
diff --git a/tools/console.c b/tools/console.c
index 34fde05..90e54e3 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -298,13 +298,36 @@ vshGetEscapeChar(const char *s)
return *s;
}
+int vshMakeStdinRaw(struct termios *ttyattr, bool report_errors) {
+ struct termios rawattr;
+
+ if (tcgetattr(STDIN_FILENO, ttyattr) < 0) {
+ if (report_errors)
+ VIR_ERROR(_("unable to get tty attributes: %s"),
+ strerror(errno));
+ return -1;
+ }
+
+ rawattr = *ttyattr;
+ cfmakeraw(&rawattr);
+
+ if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &rawattr) < 0) {
+ if (report_errors)
+ VIR_ERROR(_("unable to set tty attributes: %s"),
+ strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
int vshRunConsole(virDomainPtr dom,
const char *dev_name,
const char *escape_seq,
unsigned int flags)
{
int ret = -1;
- struct termios ttyattr, rawattr;
+ struct termios ttyattr;
void (*old_sigquit)(int);
void (*old_sigterm)(int);
void (*old_sigint)(int);
@@ -317,21 +340,8 @@ int vshRunConsole(virDomainPtr dom,
result in it being echoed back already), and
also ensure Ctrl-C, etc is blocked, and misc
other bits */
- if (tcgetattr(STDIN_FILENO, &ttyattr) < 0) {
- VIR_ERROR(_("unable to get tty attributes: %s"),
- strerror(errno));
- return -1;
- }
-
- rawattr = ttyattr;
- cfmakeraw(&rawattr);
-
- if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &rawattr) < 0) {
- VIR_ERROR(_("unable to set tty attributes: %s"),
- strerror(errno));
+ if (vshMakeStdinRaw(&ttyattr, true) < 0)
goto resettty;
- }
-
/* Trap all common signals so that we can safely restore
the original terminal settings on STDIN before the
diff --git a/tools/console.h b/tools/console.h
index 2b5440c..97c97cd 100644
--- a/tools/console.h
+++ b/tools/console.h
@@ -30,6 +30,7 @@ int vshRunConsole(virDomainPtr dom,
const char *escape_seq,
unsigned int flags);
+int vshMakeStdinRaw(struct termios *ttyattr, bool report_errors);
# endif /* !WIN32 */
#endif /* __VIR_CONSOLE_H__ */
diff --git a/tools/virsh.c b/tools/virsh.c
index dd9292a..3537e2e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -33,6 +33,7 @@
#include <signal.h>
#include <poll.h>
#include <strings.h>
+#include <termios.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
@@ -15806,11 +15807,14 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
virDomainPtr dom = NULL;
+ virDomainPtr dom_edited = NULL;
char *tmp = NULL;
char *doc = NULL;
char *doc_edited = NULL;
char *doc_reread = NULL;
unsigned int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE;
+ int c = 0;
+ struct termios ttyattr;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -15828,6 +15832,7 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
tmp = editWriteToTempFile (ctl, doc);
if (!tmp) goto cleanup;
+reedit:
/* Start the editor. */
if (editFile (ctl, tmp) == -1) goto cleanup;
@@ -15858,19 +15863,43 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
}
/* Everything checks out, so redefine the domain. */
- virDomainFree (dom);
- dom = virDomainDefineXML(ctl->conn, doc_edited);
- if (!dom)
- goto cleanup;
+ dom_edited = virDomainDefineXML(ctl->conn, doc_edited);
+ if (!dom_edited) {
+ /* Redefine failed. If we are in interactive mode ask user
+ * if he wants to re-edit the XML. */
+ if (!ctl->imode ||
+ vshMakeStdinRaw(&ttyattr, false) < 0)
+ goto cleanup;
+
+ virshReportError(ctl);
+
+ while (true) {
+ vshPrint(ctl, "\rFailed. Try again? (y/Y/n/N) [Y]:");
+ c = getchar();
+ c = c_toupper(c);
+ if (c == '\n' || c == '\r' || c == 'Y' || c == 'N')
+ break;
+ }
+
+ tcsetattr(STDIN_FILENO, TCSAFLUSH, &ttyattr);
+
+ if (c == 'N')
+ goto cleanup;
+
+ vshPrint(ctl, "\r\n");
+ goto reedit;
+ }
vshPrint (ctl, _("Domain %s XML configuration edited.\n"),
virDomainGetName(dom));
ret = true;
- cleanup:
+cleanup:
if (dom)
- virDomainFree (dom);
+ virDomainFree(dom);
+ if (dom_edited)
+ virDomainFree(dom_edited);
VIR_FREE(doc);
VIR_FREE(doc_edited);
--
1.7.8.5
12 years, 6 months
[libvirt] [PATCHv2 0/3] Fix output of virsh vcpuinfo after cpu hotplug
by Peter Krempa
A respin of the series fixing guest rollback, a memory leak and making
the vCPU thread re-detection safe to use with older qemu versions.
Peter Krempa (3):
qemu: Refactor qemuDomainSetVcpusFlags
qemu: Re-detect virtual cpu threads after cpu hot (un)plug.
qemu: Don't skip detection of virtual cpu's on non KVM targets
src/qemu/qemu_driver.c | 55 ++++++++++++++++++++++++++++++++--------------
src/qemu/qemu_process.c | 21 ++++++-----------
2 files changed, 46 insertions(+), 30 deletions(-)
--
1.7.3.4
12 years, 6 months
[libvirt] [PATCH] nodeinfo: Get the correct CPU number on AMD Magny Cours platform
by Osier Yang
"Instead of developing one CPU with 12 cores, the Magny Cours is
actually two 6 core “Bulldozer” CPUs combined in to one package"
I.e, each package has two NUMA nodes, and the two numa nodes share
the same core ID set (0-6), which means parsing the cores number
from sysfs doesn't work in this case.
And the wrong CPU number could cause three problems for libvirt:
1) performance lost
A domain without "cpuset" or "placement='auto'" (to drive numad)
specified will be only pinned to part of the CPUs.
2) domain can be started
If a domain uses numad, and the advisory nodeset returned from
numad contains node which exceeds the range of wrong total CPU
number. The domain will fail to start, as the bitmask passed to
sched_setaffinity could be fully filled with zero.
3) wrong CPU number affects lots of stuffs.
E.g. for command "virsh vcpuinfo", "virsh vcpupin", it will always
output with the truncated CPU list.
For more details:
https://www.redhat.com/archives/libvir-list/2012-May/msg00607.html
This patch is to fix the problem by parsing /proc/cpuinfo to get
the value of field "cpu cores", and use it as nodeinfo->cores if
it's greater than the cores number from sysfs.
---
src/nodeinfo.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 56b9f54..87a6ad6 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -211,6 +211,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
cpu_set_t core_mask;
cpu_set_t socket_mask;
int online;
+ unsigned int cpu_cores = 0;
nodeinfo->cpus = 0;
nodeinfo->mhz = 0;
@@ -251,6 +252,23 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
&& (*p == '\0' || *p == '.' || c_isspace(*p)))
nodeinfo->mhz = ui;
}
+
+ if (STRPREFIX(buf, "cpu cores")) {
+ char *p;
+ unsigned int ui;
+ buf += 9;
+ while (*buf && c_isspace(*buf))
+ buf++;
+ if (*buf != ':' || !buf[1]) {
+ nodeReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("parsing cpuinfo cpu MHz"));
+ return -1;
+ }
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
+ /* Accept trailing fractional part. */
+ && (*p == '\0' || *p == '.' || c_isspace(*p)))
+ cpu_cores = ui;
+ }
# elif defined(__powerpc__) || \
defined(__powerpc64__)
char *buf = line;
@@ -353,6 +371,16 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
return -1;
}
+ /* Platform like AMD Magny Cours has two NUMA nodes each package, and
+ * the two nodes share the same core ID set, it results in the cores
+ * number calculated from sysfs is not the actual cores number. Use
+ * "cpu cores" in /proc/cpuinfo as the cores number instead in this case.
+ * More details about the problem:
+ * https://www.redhat.com/archives/libvir-list/2012-May/msg00607.html
+ */
+ if (cpu_cores && (cpu_cores > nodeinfo->cores))
+ nodeinfo->cores = cpu_cores;
+
/* nodeinfo->sockets is supposed to be a number of sockets per NUMA node,
* however if NUMA nodes are not composed of whole sockets, we just lie
* about the number of NUMA nodes and force apps to check capabilities XML
--
1.7.7.3
12 years, 6 months
[libvirt] [PATCH] docs: Serialize running apibuild.py
by Cole Robinson
Use a witness file approach like we do for python/generator.py,
as suggested by Eric. Fixes the build issue reported here:
https://www.redhat.com/archives/libvir-list/2012-April/msg01435.html
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
.gitignore | 1 +
docs/Makefile.am | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 14a21d0..3cc30e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,6 +54,7 @@
/daemon/libvirtd.init
/daemon/libvirtd.pod
/daemon/libvirtd.service
+/docs/apibuild.py.stamp
/docs/devhelp/libvirt.devhelp
/docs/hvsupport.html.in
/docs/libvirt-api.xml
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 53328f7..9bcc866 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -200,12 +200,19 @@ python_generated_files = \
$(srcdir)/libvirt-qemu-api.xml \
$(srcdir)/libvirt-qemu-refs.xml
-$(python_generated_files): $(srcdir)/apibuild.py \
+APIBUILD="$(srcdir)/apibuild.py"
+APIBUILD_STAMP="$(APIBUILD).stamp"
+
+$(python_generated_files): $(APIBUILD_STAMP)
+
+$(APIBUILD_STAMP): $(srcdir)/apibuild.py \
$(srcdir)/../include/libvirt/*.h \
$(srcdir)/../src/libvirt.c \
$(srcdir)/../src/libvirt-qemu.c \
$(srcdir)/../src/util/virterror.c
- $(AM_V_GEN)srcdir=$(srcdir) $(PYTHON) $(srcdir)/apibuild.py
+ $(AM_V_GEN)srcdir=$(srcdir) $(PYTHON) $(APIBUILD)
+ touch $@
+
check-local: all
@@ -215,6 +222,7 @@ clean-local:
maintainer-clean-local: clean-local
rm -rf $(srcdir)/libvirt-api.xml $(srcdir)/libvirt-refs.xml todo.html.in hvsupport.html.in
rm -rf $(srcdir)/libvirt-qemu-api.xml $(srcdir)/libvirt-qemu-refs.xml
+ rm -rf $(APIBUILD_STAMP)
rebuild: api qemu_api all
--
1.7.7.6
12 years, 6 months
[libvirt] [libvirt-glib 1/4] More generic gvir_config_object_add_child()
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gconfig/libvirt-gconfig-domain-channel.c | 6 ++++--
libvirt-gconfig/libvirt-gconfig-domain-console.c | 3 ++-
libvirt-gconfig/libvirt-gconfig-domain-disk.c | 18 ++++++++++++------
libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 6 ++++--
libvirt-gconfig/libvirt-gconfig-domain.c | 6 ++++--
libvirt-gconfig/libvirt-gconfig-object-private.h | 5 ++++-
libvirt-gconfig/libvirt-gconfig-object.c | 13 ++++++++-----
.../libvirt-gconfig-storage-pool-source.c | 3 ++-
8 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-channel.c b/libvirt-gconfig/libvirt-gconfig-domain-channel.c
index a4f9527..f81cea2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-channel.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-channel.c
@@ -77,7 +77,8 @@ void gvir_config_domain_channel_set_target_type(GVirConfigDomainChannel *channel
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHANNEL(channel));
gvir_config_object_add_child_with_attribute_enum(GVIR_CONFIG_OBJECT(channel),
- "target", "type",
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "type",
GVIR_CONFIG_TYPE_DOMAIN_CHANNEL_TARGET_TYPE,
type);
}
@@ -89,5 +90,6 @@ void gvir_config_domain_channel_set_target_name(GVirConfigDomainChannel *channel
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHANNEL(channel));
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(channel),
- "target", "name", name);
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "name", name);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-console.c b/libvirt-gconfig/libvirt-gconfig-domain-console.c
index db97322..954f9d2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-console.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-console.c
@@ -76,7 +76,8 @@ void gvir_config_domain_console_set_target_type(GVirConfigDomainConsole *console
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CONSOLE(console));
gvir_config_object_add_child_with_attribute_enum(GVIR_CONFIG_OBJECT(console),
- "target", "type",
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "type",
GVIR_CONFIG_TYPE_DOMAIN_CONSOLE_TARGET_TYPE,
type);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index a29ea47..d5a5b70 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -136,7 +136,8 @@ void gvir_config_domain_disk_set_startup_policy(GVirConfigDomainDisk *disk,
str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_DISK_STARTUP_POLICY, policy);
g_return_if_fail(str != NULL);
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "source", "startupPolicy", str);
+ "source", GVIR_CONFIG_TYPE_OBJECT,
+ "startupPolicy", str);
}
void gvir_config_domain_disk_set_source(GVirConfigDomainDisk *disk,
@@ -172,7 +173,8 @@ void gvir_config_domain_disk_set_driver_name(GVirConfigDomainDisk *disk,
{
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "driver", "name", driver_name);
+ "driver", GVIR_CONFIG_TYPE_OBJECT,
+ "name", driver_name);
}
void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
@@ -180,7 +182,8 @@ void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
{
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "driver", "type", driver_type);
+ "driver", GVIR_CONFIG_TYPE_OBJECT,
+ "type", driver_type);
}
void gvir_config_domain_disk_set_driver_cache(GVirConfigDomainDisk *disk,
@@ -192,7 +195,8 @@ void gvir_config_domain_disk_set_driver_cache(GVirConfigDomainDisk *disk,
cache_str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_DISK_CACHE_TYPE, cache_type);
g_return_if_fail(cache_str != NULL);
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "driver", "cache", cache_str);
+ "driver", GVIR_CONFIG_TYPE_OBJECT,
+ "cache", cache_str);
}
void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
@@ -204,7 +208,8 @@ void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
bus_str = gvir_config_genum_get_nick(GVIR_CONFIG_TYPE_DOMAIN_DISK_BUS, bus);
g_return_if_fail(bus_str != NULL);
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "target", "bus", bus_str);
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "bus", bus_str);
}
void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk,
@@ -212,7 +217,8 @@ void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk,
{
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk));
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
- "target", "dev", dev);
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "dev", dev);
}
GVirConfigDomainDiskType
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
index 904a7a3..8dcdff2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
@@ -99,7 +99,8 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys
GVirConfigObject *node;
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), "driver");
+ node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys),
+ "driver", GVIR_CONFIG_TYPE_OBJECT);
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
if (type != GVIR_CONFIG_DOMAIN_FILESYS_DRIVER_DEFAULT)
gvir_config_object_set_attribute_with_type(
@@ -146,7 +147,8 @@ void gvir_config_domain_filesys_set_target(GVirConfigDomainFilesys *filesys,
{
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_FILESYS(filesys));
gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(filesys),
- "target", "dir", path);
+ "target", GVIR_CONFIG_TYPE_OBJECT,
+ "dir", path);
}
void gvir_config_domain_filesys_set_readonly(GVirConfigDomainFilesys *filesys,
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index c8cd1c5..04915ab 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -401,7 +401,8 @@ void gvir_config_domain_add_device(GVirConfigDomain *domain,
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_DEVICE(device));
devices_node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
- "devices");
+ "devices",
+ GVIR_CONFIG_TYPE_OBJECT);
gvir_config_object_attach_add(devices_node, GVIR_CONFIG_OBJECT(device));
g_object_unref(G_OBJECT(devices_node));
@@ -465,7 +466,8 @@ gboolean gvir_config_domain_set_custom_xml(GVirConfigDomain *domain,
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
metadata = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
- "metadata");
+ "metadata",
+ GVIR_CONFIG_TYPE_OBJECT);
custom_xml = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_OBJECT,
NULL, NULL, xml, error);
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index a6b7395..ba9c676 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -54,13 +54,16 @@ void gvir_config_object_set_node_content_uint64(GVirConfigObject *object,
const char *node_name,
guint64 value);
GVirConfigObject *gvir_config_object_add_child(GVirConfigObject *object,
- const char *child_name);
+ const char *child_name,
+ GType child_type);
void gvir_config_object_add_child_with_attribute(GVirConfigObject *object,
const char *child_name,
+ GType child_type,
const char *attr_name,
const char *attr_value);
void gvir_config_object_add_child_with_attribute_enum(GVirConfigObject *object,
const char *child_name,
+ GType child_type,
const char *attr_name,
GType attr_type,
unsigned int attr_value);
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index ee3584a..df4836d 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -367,7 +367,8 @@ gvir_config_object_foreach_child(GVirConfigObject *object,
G_GNUC_INTERNAL GVirConfigObject *
gvir_config_object_add_child(GVirConfigObject *object,
- const char *child_name)
+ const char *child_name,
+ GType child_type)
{
xmlNodePtr new_node;
xmlNodePtr old_node;
@@ -380,13 +381,13 @@ gvir_config_object_add_child(GVirConfigObject *object,
FALSE);
if (old_node != NULL) {
xmlFreeNode(new_node);
- return GVIR_CONFIG_OBJECT(g_object_new(GVIR_CONFIG_TYPE_OBJECT,
+ return GVIR_CONFIG_OBJECT(g_object_new(child_type,
"doc", object->priv->doc,
"node", old_node,
NULL));
}
- return GVIR_CONFIG_OBJECT(g_object_new(GVIR_CONFIG_TYPE_OBJECT,
+ return GVIR_CONFIG_OBJECT(g_object_new(child_type,
"doc", object->priv->doc,
"node", new_node,
NULL));
@@ -395,12 +396,13 @@ gvir_config_object_add_child(GVirConfigObject *object,
G_GNUC_INTERNAL void
gvir_config_object_add_child_with_attribute(GVirConfigObject *object,
const char *child_name,
+ GType child_type,
const char *attr_name,
const char *attr_value)
{
GVirConfigObject *child;
- child = gvir_config_object_add_child(object, child_name);
+ child = gvir_config_object_add_child(object, child_name, child_type);
gvir_config_object_set_attribute(child, attr_name, attr_value, NULL);
g_object_unref(G_OBJECT(child));
}
@@ -408,13 +410,14 @@ gvir_config_object_add_child_with_attribute(GVirConfigObject *object,
void gvir_config_object_add_child_with_attribute_enum(GVirConfigObject *object,
const char *child_name,
+ GType child_type,
const char *attr_name,
GType attr_type,
unsigned int attr_value)
{
GVirConfigObject *child;
- child = gvir_config_object_add_child(object, child_name);
+ child = gvir_config_object_add_child(object, child_name, child_type);
gvir_config_object_set_attribute_with_type(child, attr_name, attr_type, attr_value, NULL);
g_object_unref(G_OBJECT(child));
}
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
index d92c692..e78989c 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
@@ -91,7 +91,8 @@ void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource
g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(source), "device");
+ node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(source),
+ "device", GVIR_CONFIG_TYPE_OBJECT);
g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node));
gvir_config_object_set_attribute(node, "path", device_path, NULL);
g_object_unref(G_OBJECT(node));
--
1.7.7.6
12 years, 6 months
Re: [libvirt] [Libguestfs] get virtual machine`s ip address
by Richard W.M. Jones
On Thu, May 10, 2012 at 08:24:31AM -0700, THO HUYNH wrote:
> I`m writing 2 simple socket programs: Client program runs on guest,
> server program runs on host machine.
>
> The server need the dom xml name of the guest which is running the
> client program and the only information the server program has is
> the guest`s ip address. [...] Is there another way to get the dom
> xml name of a guest from an ip address (if the ip address belongs to
> that guest).
CC'd to libvir-list, since this is really a libvirt question.
The trouble with the architecture you've described is that it relies
on the IP source address for authentication, one of those things you
should never do if you care about security:
https://en.wikipedia.org/wiki/IP_address_spoofing
Maybe because it's TCP, and it's a closed system with a firewall, you
can get away with it.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
12 years, 6 months
[libvirt] [PATCH 0/3] Fix output of virsh vcpuinfo after cpu hotplug
by Peter Krempa
The informations about virtual processors stored by libvirt were not
updated after a cpu hotplug.
Peter Krempa (3):
qemu: Refactor qemuDomainSetVcpusFlags
qemu: Re-detect virtual cpu threads after cpu hot (un)plug.
qemu: Don't skip detection of virtual cpu's on non KVM targets
src/qemu/qemu_driver.c | 48 +++++++++++++++++++++++++++++++---------------
src/qemu/qemu_process.c | 12 -----------
2 files changed, 32 insertions(+), 28 deletions(-)
--
1.7.3.4
12 years, 6 months
Re: [libvirt] [Qemu-devel] [PATCH v12 0/4] support to migrate with IPv6 address
by Eric Blake
[adding libvirt]
On 05/11/2012 12:46 AM, Amos Kong wrote:
> On 05/11/2012 02:12 AM, Michael Roth wrote:
>> On Thu, May 10, 2012 at 11:29:48AM -0600, Eric Blake wrote:
>>> On 05/10/2012 10:27 AM, Amos Kong wrote:
>>>> Those patches updated help functions in qemu-socket.c,
>>>> and used them in migrate-tcp.c to supporting IPv6 migration.
>> addr parsing now relies on qemu-sockets.c:inet_parse(), which has supported
>> [ip6addr]:port for a while, as opposed to net.c:parse_host_port(), which
>> didn't.
>
> yeah.
>
> I didn't change qemu monitor cmd interface in this patchset,
> and the transport of data is done by qemu, not libvirt.
>
> I guess libvirt only needs to update addr string parse,
> for example:
>
> ---- GOOD
> start a VM:
> # qemu-kvm --enable-kvm -boot n -incoming tcp:ipv6alias:16514 -vnc :1
> -monitor stdio -name qemu-vm1
>
> try to migrate vm by virsh with addr alias
> # virsh migrate libivrt-vm2 tcp:ipv6alias
> (connection can establish)
>
> --- FAIL
> start a VM:
> # qemu-kvm-apply-my-patches --enable-kvm -boot n -incoming
> tcp:[2002::3:4]:16514 -vnc :1 -monitor stdio -name qemu-vm1
>
> try to migrate vm by virsh with ipv6 addr:
> # virsh migrate libvirt-vm2 tcp:[2002::3:4]
> error: invalid argument: could not parse connection URI tcp:[2002::3:4]
Thanks for researching that. Looks like it should be fixed in libvirt
to match, then.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
12 years, 6 months
[libvirt] Problem of host CPU topology parsing
by Osier Yang
Hi,
We have problem of host CPU topology parsing on special
platforms (general platforms are fine). E.g.
On a AMD machine with 48 CPUs [1] (4 sockets, 6 cores indeed
[2]), VIR_NODEINFO_MAXCPUS [3] will always return 24 as the
total CPU number.
As a result, a domain without "cpuset" or "placement='auto'"
(which drives numad) will only be pinned to part of the
host CPUs (in the case of the 48 CPUS AMD machine, domain
process will be pinned to only the first 24 CPUs), which
cause the performance lost. And actually it's also functional
bug, as the "cpuset" specified by user could be truncated.
If a domain uses "placement='auto'", and the advisory
nodeset returned from numad has node(s) exceeds the wrong
max CPU number, the domain will fail to start, as the
bitmask passed to sched_setaffinity is fully filled with
zero.
"nodeinfo.cpus" has the right number though, but I'm not
sure if it should be used as the max CPU number.
VIR_NODEINFO_MAXCPUS is used in many places, and I'd never
want to fix something here, but break other things there.
Anyone has thought on how to sort the fucky topology out?
[1] http://fpaste.org/MTtz/
[2] http://fpaste.org/mtoA/, http://fpaste.org/EPLd/
[3] #define VIR_NODEINFO_MAXCPUS(nodeinfo)
((nodeinfo).nodes*(nodeinfo).sockets*(nodeinfo).cores*(nodeinfo).threads)
Regards,
Osier
12 years, 6 months