[libvirt] [libvirt-glib 1/2] Add more parsing helpers to GVirConfigObject
by Christophe Fergeau
Add gvir_config_object_get_node_content_genum,
gvir_config_object_get_attribute
and gvir_config_object_get_attribute_genum to complement the existing
methods. They all act on a child node of the current node. The
_get_attribute functions can also act on the root node of the
GVirConfigObject instance if it's passed NULL instead of a child name.
---
libvirt-gconfig/libvirt-gconfig-object-private.h | 12 +++
libvirt-gconfig/libvirt-gconfig-object.c | 80 ++++++++++++++++++++++
2 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index 7c6575e..692e369 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -35,6 +35,18 @@ char *gvir_config_object_get_node_content(GVirConfigObject *object,
const char *node_name);
guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object,
const char *node_name);
+gint gvir_config_object_get_node_content_genum(GVirConfigObject *object,
+ const char *node_name,
+ GType enum_type,
+ gint default_value);
+char *gvir_config_object_get_attribute(GVirConfigObject *object,
+ const char *node_name,
+ const char *attr_name);
+gint gvir_config_object_get_attribute_genum(GVirConfigObject *object,
+ const char *node_name,
+ const char *attr_name,
+ GType enum_type,
+ gint default_value);
void gvir_config_object_set_node_content(GVirConfigObject *object,
const char *node_name,
const char *value);
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 5c7639f..2b2fd55 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -301,6 +301,28 @@ gvir_config_object_get_node_content(GVirConfigObject *object,
return gvir_config_xml_get_child_element_content_glib(node, node_name);
}
+G_GNUC_INTERNAL char *
+gvir_config_object_get_attribute(GVirConfigObject *object,
+ const char *node_name,
+ const char *attr_name)
+{
+ xmlNodePtr node;
+
+ g_return_val_if_fail(attr_name != NULL, NULL);
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object));
+ if (node == NULL)
+ return NULL;
+
+ if (node_name != NULL) {
+ node = gvir_config_xml_get_element(node, node_name, NULL);
+ if (node == NULL)
+ return NULL;
+ }
+
+ return gvir_config_xml_get_attribute_content_glib(node, attr_name);
+}
+
static xmlNodePtr
gvir_config_object_set_child_internal(GVirConfigObject *object,
xmlNodePtr child,
@@ -511,6 +533,64 @@ gvir_config_object_get_node_content_uint64(GVirConfigObject *object,
return value;
}
+G_GNUC_INTERNAL gint
+gvir_config_object_get_node_content_genum(GVirConfigObject *object,
+ const char *node_name,
+ GType enum_type,
+ gint default_value)
+{
+ xmlNodePtr node;
+ xmlChar *str;
+ gint value;
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object));
+ if (node == NULL)
+ return default_value;
+
+ str = gvir_config_xml_get_child_element_content(node, node_name);
+ if (!str)
+ return default_value;
+
+ value = gvir_config_genum_get_value(enum_type, (char *)str, default_value);
+ xmlFree(str);
+
+ return value;
+}
+
+G_GNUC_INTERNAL gint
+gvir_config_object_get_attribute_genum(GVirConfigObject *object,
+ const char *node_name,
+ const char *attr_name,
+ GType enum_type,
+ gint default_value)
+{
+ xmlNodePtr node;
+ xmlChar *attr_val;
+ gint value;
+
+ g_return_val_if_fail(attr_name != NULL, default_value);
+
+ node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object));
+ if (node == NULL)
+ return default_value;
+
+ if (node_name != NULL) {
+ node = gvir_config_xml_get_element(node, node_name, NULL);
+ if (node == NULL)
+ return default_value;
+ }
+
+ attr_val = gvir_config_xml_get_attribute_content(node, attr_name);
+ if (attr_val == NULL)
+ return default_value;
+
+ value = gvir_config_genum_get_value(enum_type, (char *)attr_val,
+ default_value);
+ xmlFree(attr_val);
+
+ return value;
+}
+
GVirConfigObject *gvir_config_object_new_from_xml(GType type,
const char *root_name,
const char *schema,
--
1.7.7.5
12 years, 10 months
[libvirt] [libvirt-glib] Add {replace,add}_with_attribute
by Christophe Fergeau
These functions may seem very specialized, and the same can easily
be achieved with 2 separate API calls, but since this is something
that is commonly done, these helpers save quite a few lines of code.
---
libvirt-gconfig/libvirt-gconfig-domain-disk.c | 49 ++++++--------------
libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 19 ++------
.../libvirt-gconfig-domain-interface-bridge.c | 9 +---
.../libvirt-gconfig-domain-interface-network.c | 9 +---
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 27 ++--------
libvirt-gconfig/libvirt-gconfig-object-private.h | 8 +++
libvirt-gconfig/libvirt-gconfig-object.c | 25 ++++++++++
7 files changed, 62 insertions(+), 84 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index e517d65..aa5ab81 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -130,13 +130,9 @@ void gvir_config_domain_disk_set_snapshot_type(GVirConfigDomainDisk *disk,
void gvir_config_domain_disk_set_source(GVirConfigDomainDisk *disk,
const char *source)
{
- GVirConfigObject *source_node;
const char *attribute_name;
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk));
- source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(disk),
- "source");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(source_node));
switch (disk->priv->type) {
case GVIR_CONFIG_DOMAIN_DISK_FILE:
@@ -154,62 +150,45 @@ void gvir_config_domain_disk_set_source(GVirConfigDomainDisk *disk,
default:
g_return_if_reached();
}
- gvir_config_object_set_attribute(source_node,
- attribute_name, source,
- NULL);
- g_object_unref(G_OBJECT(source_node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
+ "source",
+ attribute_name, source);
}
void gvir_config_domain_disk_set_driver_name(GVirConfigDomainDisk *disk,
const char *driver_name)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "driver");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "name", driver_name, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
+ "driver", "name", driver_name);
}
void gvir_config_domain_disk_set_driver_type(GVirConfigDomainDisk *disk,
const char *driver_type)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "driver");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "type", driver_type, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
+ "driver", "type", driver_type);
}
void gvir_config_domain_disk_set_target_bus(GVirConfigDomainDisk *disk,
GVirConfigDomainDiskBus bus)
{
- GVirConfigObject *node;
+ const char *bus_str;
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "target");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute_with_type(node,
- "bus",
- GVIR_TYPE_CONFIG_DOMAIN_DISK_BUS,
- bus,
- NULL);
- g_object_unref(G_OBJECT(node));
+ bus_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_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);
}
void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk,
const char *dev)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_DISK(disk));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), "target");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "dev", dev, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(disk),
+ "target", "dev", dev);
}
GVirConfigDomainDiskType
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
index ab33e50..ef942f8 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
@@ -114,13 +114,9 @@ void gvir_config_domain_filesys_set_driver_type(GVirConfigDomainFilesys *filesys
void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys,
const char *source)
{
- GVirConfigObject *source_node;
const char *attribute_name;
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_FILESYS(filesys));
- source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(filesys),
- "source");
- g_return_if_fail(source_node != NULL);
switch (filesys->priv->type) {
case GVIR_CONFIG_DOMAIN_FILESYS_MOUNT:
@@ -139,23 +135,18 @@ void gvir_config_domain_filesys_set_source(GVirConfigDomainFilesys *filesys,
g_return_if_reached();
}
- gvir_config_object_set_attribute(source_node,
- attribute_name, source,
- NULL);
- g_object_unref(G_OBJECT(source_node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(filesys),
+ "source",
+ attribute_name, source);
}
void gvir_config_domain_filesys_set_target(GVirConfigDomainFilesys *filesys,
const char *path)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_FILESYS(filesys));
- node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(filesys), "target");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "dir", path, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_add_child_with_attribute(GVIR_CONFIG_OBJECT(filesys),
+ "target", "dir", path);
}
void gvir_config_domain_filesys_set_readonly(GVirConfigDomainFilesys *filesys,
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
index 9bf6853..61d3563 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-bridge.c
@@ -79,13 +79,8 @@ GVirConfigDomainInterfaceBridge *gvir_config_domain_interface_bridge_new_from_xm
void gvir_config_domain_interface_bridge_set_source(GVirConfigDomainInterfaceBridge *interface,
const char *brname)
{
- GVirConfigObject *source_node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_INTERFACE_BRIDGE(interface));
- source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface),
- "source");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(source_node));
- gvir_config_object_set_attribute(source_node, "bridge", brname, NULL);
- g_object_unref(G_OBJECT(source_node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
+ "source", "bridge", brname);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
index 433c02a..6f24708 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
@@ -78,13 +78,8 @@ GVirConfigDomainInterfaceNetwork *gvir_config_domain_interface_network_new_from_
void gvir_config_domain_interface_network_set_source(GVirConfigDomainInterfaceNetwork *interface,
const char *source)
{
- GVirConfigObject *source_node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_INTERFACE_NETWORK(interface));
- source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface),
- "source");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(source_node));
- gvir_config_object_set_attribute(source_node, "network", source, NULL);
- g_object_unref(G_OBJECT(source_node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
+ "source", "network", source);
}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index ba3c9e3..0f427ff 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -54,15 +54,10 @@ static void gvir_config_domain_interface_init(GVirConfigDomainInterface *interfa
void gvir_config_domain_interface_set_ifname(GVirConfigDomainInterface *interface,
const char *ifname)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_INTERFACE(interface));
- node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface),
- "target");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "device", ifname, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
+ "target", "device", ifname);
}
void gvir_config_domain_interface_set_link_state(GVirConfigDomainInterface *interface,
@@ -86,29 +81,19 @@ void gvir_config_domain_interface_set_link_state(GVirConfigDomainInterface *inte
void gvir_config_domain_interface_set_mac(GVirConfigDomainInterface *interface,
const char *mac_address)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_INTERFACE(interface));
- node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface),
- "mac");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "address", mac_address, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
+ "mac", "address", mac_address);
}
void gvir_config_domain_interface_set_model(GVirConfigDomainInterface *interface,
const char *model)
{
- GVirConfigObject *node;
-
g_return_if_fail(GVIR_IS_CONFIG_DOMAIN_INTERFACE(interface));
- node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface),
- "model");
- g_return_if_fail(GVIR_IS_CONFIG_OBJECT(node));
- gvir_config_object_set_attribute(node, "type", model, NULL);
- g_object_unref(G_OBJECT(node));
+ gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
+ "model", "type", model);
}
G_GNUC_INTERNAL GVirConfigDomainDevice *
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index f7c1f68..38c129f 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -43,8 +43,16 @@ void gvir_config_object_set_node_content_uint64(GVirConfigObject *object,
guint64 value);
GVirConfigObject *gvir_config_object_add_child(GVirConfigObject *object,
const char *child_name);
+void gvir_config_object_add_child_with_attribute(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ const char *attr_value);
GVirConfigObject *gvir_config_object_replace_child(GVirConfigObject *object,
const char *child_name);
+void gvir_config_object_replace_child_with_attribute(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ const char *attr_value);
void gvir_config_object_delete_child(GVirConfigObject *object,
const char *child_name);
void gvir_config_object_set_child(GVirConfigObject *object,
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 4f95189..7a6d062 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -363,6 +363,19 @@ gvir_config_object_add_child(GVirConfigObject *object,
NULL));
}
+G_GNUC_INTERNAL void
+gvir_config_object_add_child_with_attribute(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ const char *attr_value)
+{
+ GVirConfigObject *child;
+
+ child = gvir_config_object_add_child(object, child_name);
+ gvir_config_object_set_attribute(child, attr_name, attr_value, NULL);
+ g_object_unref(G_OBJECT(child));
+}
+
G_GNUC_INTERNAL GVirConfigObject *
gvir_config_object_replace_child(GVirConfigObject *object,
const char *child_name)
@@ -381,6 +394,18 @@ gvir_config_object_replace_child(GVirConfigObject *object,
NULL));
}
+G_GNUC_INTERNAL void
+gvir_config_object_replace_child_with_attribute(GVirConfigObject *object,
+ const char *child_name,
+ const char *attr_name,
+ const char *attr_value)
+{
+ GVirConfigObject *child;
+
+ child = gvir_config_object_replace_child(object, child_name);
+ gvir_config_object_set_attribute(child, attr_name, attr_value, NULL);
+ g_object_unref(G_OBJECT(child));
+}
G_GNUC_INTERNAL void
gvir_config_object_delete_child(GVirConfigObject *object,
--
1.7.7.4
12 years, 10 months
[libvirt] [libvirt-glib 1/2] Add gvir_gconfig_object_remove_attribute helper
by Christophe Fergeau
---
libvirt-gconfig/libvirt-gconfig-object-private.h | 2 ++
libvirt-gconfig/libvirt-gconfig-object.c | 11 +++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index ea06a67..38c129f 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -64,6 +64,8 @@ void gvir_config_object_set_attribute(GVirConfigObject *object,
...) G_GNUC_NULL_TERMINATED;
void gvir_config_object_set_attribute_with_type(GVirConfigObject *object,
...) G_GNUC_NULL_TERMINATED;
+void gvir_config_object_remove_attribute(GVirConfigObject *object,
+ const char *attr_name);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index a75db6e..52a2a0d 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -680,3 +680,14 @@ gvir_config_object_attach(GVirConfigObject *parent, GVirConfigObject *child)
child->priv->doc = g_object_ref(G_OBJECT(parent->priv->doc));
}
}
+
+G_GNUC_INTERNAL void
+gvir_config_object_remove_attribute(GVirConfigObject *object,
+ const char *attr_name)
+{
+ int status;
+
+ do {
+ status = xmlUnsetProp(object->priv->node, (xmlChar *)attr_name);
+ } while (status == 0);
+}
--
1.7.7.4
12 years, 10 months
[libvirt] [PATCH] Fix xenstore serial console path for HVM guests
by Jim Fehlig
The console path in xenstore is /local/domain/<id>/console/tty
for PV guests (PV console) and /local/domain/<id>/serial/0/tty
(serial console) for HVM guests. Similar to Xen's in-tree console
client, read the correct path for PV vs HVM.
---
src/xen/xend_internal.c | 5 ++++-
src/xen/xs_internal.c | 19 +++++++++++++++++++
src/xen/xs_internal.h | 2 ++
3 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 0c0b6cb..1d8e035 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1761,7 +1761,10 @@ xenDaemonDomainFetch(virConnectPtr conn,
id = xenGetDomIdFromSxpr(root, priv->xendConfigVersion);
xenUnifiedLock(priv);
- tty = xenStoreDomainGetConsolePath(conn, id);
+ if (sexpr_lookup(root, "domain/image/hvm"))
+ tty = xenStoreDomainGetSerialConsolePath(conn, id);
+ else
+ tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(priv);
if (!(def = xenParseSxpr(root,
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index a28e6cc..86e5519 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -852,6 +852,25 @@ char * xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
return virDomainDoStoreQuery(conn, domid, "console/tty");
}
+/**
+ * xenStoreDomainGetSerailConsolePath:
+ * @conn: the hypervisor connection
+ * @domid: id of the domain
+ *
+ * Return the path to the pseudo TTY on which the guest domain's
+ * serial console is attached.
+ *
+ * Returns the path to the serial console. It is the callers
+ * responsibilty to free() the return string. Returns NULL
+ * on error
+ *
+ * The caller must hold the lock on the privateData
+ * associated with the 'conn' parameter.
+ */
+char * xenStoreDomainGetSerialConsolePath(virConnectPtr conn, int domid) {
+ return virDomainDoStoreQuery(conn, domid, "serial/0/tty");
+}
+
/*
* xenStoreDomainGetNetworkID:
diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h
index 0278799..f7e487b 100644
--- a/src/xen/xs_internal.h
+++ b/src/xen/xs_internal.h
@@ -45,6 +45,8 @@ int xenStoreDomainGetVNCPort(virConnectPtr conn,
int domid);
char * xenStoreDomainGetConsolePath(virConnectPtr conn,
int domid);
+char * xenStoreDomainGetSerialConsolePath(virConnectPtr conn,
+ int domid);
char * xenStoreDomainGetNetworkID(virConnectPtr conn,
int id,
const char *mac);
--
1.7.7
12 years, 10 months
[libvirt] [libvirt-glib 1/4] Introduce libvirt-gconfig-private.h
by Christophe Fergeau
This header groups all libvirt-gconfig private headers.
---
libvirt-gconfig/Makefile.am | 1 +
.../libvirt-gconfig-domain-chardev-source-pty.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-chardev.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-clock.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-device.c | 1 +
libvirt-gconfig/libvirt-gconfig-domain-disk.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-filesys.c | 3 +-
.../libvirt-gconfig-domain-graphics-sdl.c | 3 +-
.../libvirt-gconfig-domain-graphics-spice.c | 3 +-
.../libvirt-gconfig-domain-graphics-vnc.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-input.c | 3 +-
.../libvirt-gconfig-domain-interface-network.c | 3 +-
.../libvirt-gconfig-domain-interface-user.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 2 +-
.../libvirt-gconfig-domain-memballoon.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-os.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-seclabel.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-sound.c | 2 +-
libvirt-gconfig/libvirt-gconfig-domain-video.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain.c | 3 +-
libvirt-gconfig/libvirt-gconfig-object.c | 4 +--
libvirt-gconfig/libvirt-gconfig-private.h | 30 ++++++++++++++++++++
.../libvirt-gconfig-storage-permissions.c | 2 +-
.../libvirt-gconfig-storage-pool-source.c | 2 +-
.../libvirt-gconfig-storage-pool-target.c | 2 +-
libvirt-gconfig/libvirt-gconfig-storage-pool.c | 2 +-
.../libvirt-gconfig-storage-vol-backing-store.c | 2 +-
.../libvirt-gconfig-storage-vol-target.c | 2 +-
libvirt-gconfig/libvirt-gconfig-storage-vol.c | 2 +-
29 files changed, 58 insertions(+), 42 deletions(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-private.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 6342431..d9eb25a 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -51,6 +51,7 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-storage-vol-backing-store.h \
libvirt-gconfig-storage-vol-target.h
noinst_HEADERS = \
+ libvirt-gconfig-private.h \
libvirt-gconfig-helpers-private.h \
libvirt-gconfig-object-private.h \
libvirt-gconfig-xml-doc.h
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
index 1965444..e3c4c25 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_CHARDEV_SOURCE_PTY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_CHARDEV_SOURCE_PTY, GVirConfigDomainChardevSourcePtyPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev.c
index 1359f8f..620773c 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_CHARDEV_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_CHARDEV, GVirConfigDomainChardevPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-clock.c b/libvirt-gconfig/libvirt-gconfig-domain-clock.c
index 16d75d5..3cb8ffb 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-clock.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-clock.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_CLOCK_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_CLOCK, GVirConfigDomainClockPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device.c b/libvirt-gconfig/libvirt-gconfig-domain-device.c
index 980ae70..8fcf60f 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device.c
@@ -23,6 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_DEVICE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_DEVICE, GVirConfigDomainDevicePrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index 18cdb1c..1f60213 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_DISK_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_DISK, GVirConfigDomainDiskPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
index 6c3aa9d..ef942f8 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-filesys.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_FILESYS_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_FILESYS, GVirConfigDomainFilesysPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
index c60e72b..1e33a1b 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-sdl.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_GRAPHICS_SDL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SDL, GVirConfigDomainGraphicsSdlPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
index 321b914..7aa3e2c 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-spice.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_SPICE, GVirConfigDomainGraphicsSpicePrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
index f7fd6db..b00a155 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics-vnc.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_GRAPHICS_VNC_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_GRAPHICS_VNC, GVirConfigDomainGraphicsVncPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-input.c b/libvirt-gconfig/libvirt-gconfig-domain-input.c
index 5bc70c8..bacc693 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-input.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-input.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_INPUT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INPUT, GVirConfigDomainInputPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
index becddc8..6f24708 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-network.c
@@ -25,8 +25,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_INTERFACE_NETWORK_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_NETWORK, GVirConfigDomainInterfaceNetworkPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c b/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
index 2c03af2..25770e0 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-user.c
@@ -25,8 +25,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_INTERFACE_USER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE_USER, GVirConfigDomainInterfaceUserPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index 834ce5d..2d87040 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -25,7 +25,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_INTERFACE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_INTERFACE, GVirConfigDomainInterfacePrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-memballoon.c b/libvirt-gconfig/libvirt-gconfig-domain-memballoon.c
index ca74a72..9df7e52 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-memballoon.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-memballoon.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_MEMBALLOON_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_MEMBALLOON, GVirConfigDomainMemballoonPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.c b/libvirt-gconfig/libvirt-gconfig-domain-os.c
index 2b0cdff..6818abf 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_OS_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_OS, GVirConfigDomainOsPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c b/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
index 7537a78..2d69c6f 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_SECLABEL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_SECLABEL, GVirConfigDomainSeclabelPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-sound.c b/libvirt-gconfig/libvirt-gconfig-domain-sound.c
index 56149ca..abf9a14 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-sound.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-sound.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_SOUND_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_SOUND, GVirConfigDomainSoundPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-video.c b/libvirt-gconfig/libvirt-gconfig-domain-video.c
index bba8073..90c71da 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-video.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-video.c
@@ -23,8 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_VIDEO_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN_VIDEO, GVirConfigDomainVideoPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index c5df963..ed48d57 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -24,8 +24,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_DOMAIN_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DOMAIN, GVirConfigDomainPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index cf71264..ce6cd21 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -28,9 +28,7 @@
#include <libxml/relaxng.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
-#include "libvirt-gconfig/libvirt-gconfig-xml-doc.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_OBJECT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_OBJECT, GVirConfigObjectPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-private.h b/libvirt-gconfig/libvirt-gconfig-private.h
new file mode 100644
index 0000000..e985ebd
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-private.h
@@ -0,0 +1,30 @@
+/*
+ * libvirt-gconfig-private.h: libvirt domain device configuration
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Christophe Fergeau <cfergeau(a)gmail.com>
+ */
+
+#ifndef __LIBVIRT_GCONFIG_PRIVATE_H__
+#define __LIBVIRT_GCONFIG_PRIVATE_H__
+
+#include <libvirt-gconfig/libvirt-gconfig-helpers-private.h>
+#include <libvirt-gconfig/libvirt-gconfig-object-private.h>
+#include <libvirt-gconfig/libvirt-gconfig-xml-doc.h>
+
+#endif /* __LIBVIRT_GCONFIG_PRIVATE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
index c5f9f49..49e28ac 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_PERMISSIONS_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_STORAGE_PERMISSIONS, GVirConfigStoragePermissionsPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
index b2223a2..fafb755 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_POOL_SOURCE_GET_PRIVATE(obj) \
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
index a5af381..4ce5a12 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_POOL_TARGET_GET_PRIVATE(obj) \
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
index 95609bb..c22e160 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
@@ -25,7 +25,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_POOL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_STORAGE_POOL, GVirConfigStoragePoolPrivate))
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c b/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
index 2530ed3..1791ba0 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_VOL_BACKING_STORE_GET_PRIVATE(obj) \
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c b/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
index 6a3bb0c..373f684 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
@@ -23,7 +23,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_VOL_TARGET_GET_PRIVATE(obj) \
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol.c b/libvirt-gconfig/libvirt-gconfig-storage-vol.c
index 079a5fd..1864447 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol.c
@@ -24,7 +24,7 @@
#include <config.h>
#include "libvirt-gconfig/libvirt-gconfig.h"
-#include "libvirt-gconfig/libvirt-gconfig-object-private.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
#define GVIR_CONFIG_STORAGE_VOL_GET_PRIVATE(obj) \
--
1.7.7.5
12 years, 10 months
Re: [libvirt] [libvirt-glib] Correct namespace prefix for GVirConfig symbols
by Zeeshan Ali (Khattak)
On Thu, Dec 22, 2011 at 1:43 AM, Zeeshan Ali (Khattak)
<zeeshanak(a)gnome.org> wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
>
> Breaks API and ABI on the fundamental level but lets fix this now while
> we don't guarantee any API/ABI stability.
Forgot to mention that this patch is on top of Christophe's ACK'ed but
unmerged 'Add GVirConfigDomainSound' tree.
--
Regards,
Zeeshan Ali (Khattak)
FSF member#5124
12 years, 10 months
[libvirt] [PATCH] schemas: Allow '.' in CPU feature name
by Jiri Denemark
We already support CPU features with '.' in their name (e.g., sse4.1) so
we should not forbid that in the schema.
---
docs/schemas/domaincommon.rng | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7a8f7f4..353faea 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2921,7 +2921,7 @@
</define>
<define name="featureName">
<data type="string">
- <param name='pattern'>[a-zA-Z0-9\-_]+</param>
+ <param name='pattern'>[a-zA-Z0-9\-_\.]+</param>
</data>
</define>
<define name="timeDelta">
--
1.7.8.2
12 years, 10 months
[libvirt] [PATCH][TCK] add test case for block job lifecycle testing
by xhu
diff --git a/scripts/domain/400-blockjob-lifecycle.t b/scripts/domain/400-blockjob-lifecycle.t
new file mode 100644
index 0000000..f4d0c39
--- /dev/null
+++ b/scripts/domain/400-blockjob-lifecycle.t
@@ -0,0 +1,136 @@
+# -*- perl -*-
+#
+# Copyright (C) 2011-2012 Red Hat, Inc.
+# Copyright (C) 2011 Xiaoqiang Hu <xhu(a)redhat.com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/400-block-pull-abort-info.t - verify the lifecycle of block job:
+block pull, set block job speed, get block job info and abort block job
+
+=head1 DESCRIPTION
+
+The test case validates that it is fine to block pull, set block job speed
+, get block job info and abort block job for domain using qed img with
+qed backing img
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 16;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::Spec::Functions qw(catfile);
+use File::stat;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+my $xml = $tck->generic_pool("dir")
+ ->mode("0755")->as_xml;
+
+diag "Defining transient storage pool $xml";
+my $pool;
+
+ok_pool(sub { $pool = $conn->define_storage_pool($xml) }, "define transient storage pool");
+lives_ok(sub { $pool->build(0) }, "built storage pool");
+lives_ok(sub { $pool->create }, "started storage pool");
+
+my $volbackxml = $tck->generic_volume("tck-back", "qed", 1024*1024*50)->allocation(0)->as_xml;
+
+my ($volback, $pathback);
+diag "back $volbackxml";
+ok_volume(sub { $volback = $pool->create_volume($volbackxml) }, "create raw backing file volume");
+
+my $st;
+$pathback = xpath($volback, "string(/volume/target/path)");
+$st = stat($pathback);
+
+ok($st, "path $pathback exists");
+
+ok($st->size < 1024*1024, "size is < 1M");
+
+my $volmainxml = $tck->generic_volume("tck-main", "qed", 1024*1024*50)
+ ->backing_file($pathback)
+ ->backing_format("qed")
+ ->allocation(0)->as_xml;
+
+my ($volmain, $pathmain);
+diag "main $volmainxml";
+ok_volume(sub { $volmain = $pool->create_volume($volmainxml) }, "create qed backing file volume");
+
+$pathmain = xpath($volmain, "string(/volume/target/path)");
+$st = stat($pathmain);
+
+ok($st, "path $pathmain exists");
+
+ok($st->size < 1024*1024, "size is < 1M");
+
+# define the guest at a qed image
+# and the backing store in this qed image.
+$xml = $tck->generic_domain("tck")
+ ->disk(format => { name => "qemu", type => "qed" },
+ type => "file",
+ src => $pathmain,
+ dst => "vdb")
+ ->as_xml;
+
+diag "Defining an inactive domain config $xml";
+my $dom;
+ok_domain(sub { $dom = $conn->define_domain($xml) }, "defined persistent domain config");
+
+diag "Starting inactive domain config";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+
+# start to block pull and bandwidth is 1MB/S
+my ($bandwidth, $flags, $jobinfo);
+# 1024 KB/S - 1MB/S
+$bandwidth = 1*1024;
+$flags=0;
+$dom->block_pull($pathmain, $bandwidth, $flags);
+# $jobinfo is a hash reference summarising the execution state of the block job.
+# and it has four keys:cur, end, bandwidth, type
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "start to block pull and block job bandwidth is $bandwidth");
+
+$dom->abort_block_job($pathmain, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{type} == 0, "abort block job");
+
+$dom->block_pull($pathmain, $bandwidth, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "continue to block pull and block job bandwidth is $bandwidth");
+
+# set block job bandwidth to 2MB/S
+$bandwidth = 2*1024;
+$dom->set_block_job_speed($pathmain, $bandwidth, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "block job bandwidth is set to $bandwidth");
+
+# wait for the end of block pull
+while($jobinfo->{cur} < $jobinfo->{end} && $jobinfo->{type} == 1) {
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ sleep 1
+}
+
+ok($jobinfo->{type} == 0, "block pull is finished");
+# end
--
1.7.1
12 years, 10 months
[libvirt] [PATCH] virCommand: Properly handle POLLHUP
by Michal Privoznik
It is a good practise to set revents to zero before doing any poll().
Moreover, we should check if event we waited for really occurred or
if any of fds we were polling on didn't encountered hangup.
---
src/util/command.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c
index f5effdf..9b553f0 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -1620,16 +1620,19 @@ virCommandProcessIO(virCommandPtr cmd)
if (infd != -1) {
fds[nfds].fd = infd;
fds[nfds].events = POLLOUT;
+ fds[nfds].revents = 0;
nfds++;
}
if (outfd != -1) {
fds[nfds].fd = outfd;
fds[nfds].events = POLLIN;
+ fds[nfds].revents = 0;
nfds++;
}
if (errfd != -1) {
fds[nfds].fd = errfd;
fds[nfds].events = POLLIN;
+ fds[nfds].revents = 0;
nfds++;
}
@@ -1645,8 +1648,8 @@ virCommandProcessIO(virCommandPtr cmd)
}
for (i = 0; i < nfds ; i++) {
- if (fds[i].fd == errfd ||
- fds[i].fd == outfd) {
+ if (fds[i].revents & POLLIN &&
+ (fds[i].fd == errfd || fds[i].fd == outfd)) {
char data[1024];
char **buf;
size_t *len;
@@ -1684,7 +1687,7 @@ virCommandProcessIO(virCommandPtr cmd)
memcpy(*buf + *len, data, done);
*len += done;
}
- } else {
+ } else if (fds[i].revents & POLLOUT) {
int done;
/* Coverity 5.3.0 can't see that we only get here if
@@ -1708,8 +1711,18 @@ virCommandProcessIO(virCommandPtr cmd)
VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
}
}
+ } else if (fds[i].revents & POLLHUP) {
+ if (fds[i].fd == errfd) {
+ VIR_DEBUG("hangup on stderr");
+ errfd = -1;
+ } else if (fds[i].fd == outfd) {
+ VIR_DEBUG("hangup on stdout");
+ outfd = -1;
+ } else {
+ VIR_DEBUG("hangup on stdin");
+ infd = -1;
+ }
}
-
}
}
--
1.7.3.4
12 years, 10 months
[libvirt] [libvirt-glib] Add docs for gvir_config_domain_set/get_memory
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Its not obvious what units these functions deal with so docs are
critical for these functions.
---
libvirt-gconfig/libvirt-gconfig-domain.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index 3261755..c20dee8 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -196,12 +196,25 @@ void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name)
g_object_notify(G_OBJECT(domain), "name");
}
+/**
+ * gvir_config_domain_get_memory:
+ * @domain: A domain configuration object.
+ *
+ * Returns: amount of RAM, in kilobytes.
+ */
guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain)
{
return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
"memory");
}
+/**
+ * gvir_config_domain_set_memory:
+ * @domain: A domain configuration object.
+ * @memory: The amount of RAM.
+ *
+ * Sets the amount of RAM allocated to @domain, in kilobytes.
+ */
void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory)
{
gvir_config_object_set_node_content_uint64(GVIR_CONFIG_OBJECT(domain),
--
1.7.7.5
12 years, 10 months