[libvirt] Postgresql binding to other localhosts by libra instances.
by Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I see several postgresql instances trying to bind to 127.0.0.1
audit_log-ex-lg-node4.prod.rhcloud.com-2012-03-12
audit_log-ex-std-node18.prod.rhcloud.com-2012-03-12
audit_log-ex-std-node5.prod.rhcloud.com-2012-03-12
uid=6b44af7291524783ad6ed1bc1b55aed5
uid=8d3252d15512409c97f9d3b9167cc2bc
uid=e1f70ff7ee3a438a8d513ca953a3dc7c
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAk9fJIsACgkQrlYvE4MpobNSPACYlgWtte2TcatDKgsfaVbz8WSY
XQCcCatA688MoFasF5sQUpQ6DSaNVKU=
=WEVQ
-----END PGP SIGNATURE-----
12 years, 8 months
[libvirt] These two machines look like they have dontaudit rules disabled.
by Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
audit_log-ex-std-node22.prod.rhcloud.com-2012-03-12
audit_log-ex-std-node24.prod.rhcloud.com-2012-03-12
semodule -B
Will turn dontaudit rules back on.
22:31:32.791:507663) : avc: denied { siginh } for pid=15258
comm=trap-user scontext=system_u:system_r:sshd_t:s0-s0:c0.c1023
tcontext=unconfined_u:system_r:libra_t:s0:c5,c641 tclass=process
grep siginh * | audit2allow
#============= sshd_t ==============
#!!!! This avc has a dontaudit rule in the current policy
allow sshd_t libra_t:process siginh;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9fIj4ACgkQrlYvE4MpobM44gCeJEqC+EV3HN57pL2j/hv9hMYO
cewAnjYiI6hehUpwqVEQJ3bX4Dz3eS95
=GqCQ
-----END PGP SIGNATURE-----
12 years, 8 months
[libvirt] libvirt hooks stopped vs crashed
by Ante Karamatic
Hi all
I've noticed libvirt's qemu hook doesn't make a difference between
crashed and stopped VM. While I do understand that crashed VM is
essentially a stopped VM, I'd be interested in providing (and working
on) a patch that would differentiate these two cases.
What I'm interested in is if there's a reason, unknown to me, why this
wasn't implemented in the first place. And of course, does it make sense
to differentiate those two.
Thank you!
--
Ante Karamatic
12 years, 8 months
[libvirt] [PATCH] qemu: Fix (managed)save and snapshots with host mode CPU
by Jiri Denemark
When host-model and host-passthrouh CPU modes were introduced, qemu
driver was properly modify to update guest CPU definition during
migration so that we use the right CPU at the destination. However,
similar treatment is needed for (managed)save and snapshots since they
need to save the exact CPU so that a domain can be properly restored.
To avoid repetition of such situation, all places that need live XML
share the code which generates it.
As a side effect, this patch fixes error reporting from
qemuDomainSnapshotWriteMetadata().
---
src/conf/domain_conf.c | 3 ++-
src/qemu/qemu_domain.c | 23 +++++++++++++++++++----
src/qemu/qemu_domain.h | 4 ++++
src/qemu/qemu_driver.c | 9 +++------
src/qemu/qemu_migration.c | 8 ++------
5 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b185fe7..01bd56b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13561,7 +13561,8 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
virBuffer buf = VIR_BUFFER_INITIALIZER;
int i;
- virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
+ virCheckFlags(VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_UPDATE_CPU, NULL);
flags |= VIR_DOMAIN_XML_INACTIVE;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2fed91e..f8b7c96 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -47,6 +47,10 @@
#define QEMU_NAMESPACE_HREF "http://libvirt.org/schemas/domain/qemu/1.0"
+#define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \
+ (VIR_DOMAIN_XML_SECURE | \
+ VIR_DOMAIN_XML_UPDATE_CPU)
+
VIR_ENUM_DECL(qemuDomainJob)
VIR_ENUM_IMPL(qemuDomainJob, QEMU_JOB_LAST,
"none",
@@ -1192,6 +1196,19 @@ char *qemuDomainFormatXML(struct qemud_driver *driver,
return qemuDomainDefFormatXML(driver, def, flags);
}
+char *
+qemuDomainDefFormatLive(struct qemud_driver *driver,
+ virDomainDefPtr def,
+ bool inactive)
+{
+ unsigned int flags = QEMU_DOMAIN_FORMAT_LIVE_FLAGS;
+
+ if (inactive)
+ flags |= VIR_DOMAIN_XML_INACTIVE;
+
+ return qemuDomainDefFormatXML(driver, def, flags);
+}
+
void qemuDomainObjTaint(struct qemud_driver *driver,
virDomainObjPtr obj,
@@ -1436,11 +1453,9 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virUUIDFormat(vm->def->uuid, uuidstr);
newxml = virDomainSnapshotDefFormat(uuidstr, snapshot->def,
- VIR_DOMAIN_XML_SECURE, 1);
- if (newxml == NULL) {
- virReportOOMError();
+ QEMU_DOMAIN_FORMAT_LIVE_FLAGS, 1);
+ if (newxml == NULL)
return -1;
- }
if (virAsprintf(&snapDir, "%s/%s", snapshotDir, vm->def->name) < 0) {
virReportOOMError();
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 1333d8c..f8e943f 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -232,6 +232,10 @@ char *qemuDomainFormatXML(struct qemud_driver *driver,
virDomainObjPtr vm,
unsigned int flags);
+char *qemuDomainDefFormatLive(struct qemud_driver *driver,
+ virDomainDefPtr def,
+ bool inactive);
+
void qemuDomainObjTaint(struct qemud_driver *driver,
virDomainObjPtr obj,
enum virDomainTaintFlags taint,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index be678f3..55f389f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2584,11 +2584,9 @@ qemuDomainSaveInternal(struct qemud_driver *driver, virDomainPtr dom,
virDomainDefFree(def);
goto endjob;
}
- xml = virDomainDefFormat(def, (VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE));
+ xml = qemuDomainDefFormatLive(driver, def, true);
} else {
- xml = virDomainDefFormat(vm->def, (VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE));
+ xml = qemuDomainDefFormatLive(driver, vm->def, true);
}
if (!xml) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
@@ -10170,8 +10168,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
} else {
/* Easiest way to clone inactive portion of vm->def is via
* conversion in and back out of xml. */
- if (!(xml = virDomainDefFormat(vm->def, (VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE))) ||
+ if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true)) ||
!(def->dom = virDomainDefParseString(driver->caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 92d046a..81b2d5b 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1092,13 +1092,9 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
if (!virDomainDefCheckABIStability(vm->def, def))
goto cleanup;
- rv = qemuDomainDefFormatXML(driver, def,
- VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_UPDATE_CPU);
+ rv = qemuDomainDefFormatLive(driver, def, false);
} else {
- rv = qemuDomainFormatXML(driver, vm,
- VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_UPDATE_CPU);
+ rv = qemuDomainDefFormatLive(driver, vm->def, false);
}
cleanup:
--
1.7.8.5
12 years, 8 months
[libvirt] [PATCH] qemu: A typo which causes non-exsiting NIC detachment failed
by Guannan Ren
---
src/qemu/qemu_hotplug.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1e56354..e088a49 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2081,13 +2081,6 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
}
}
- if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
- ret = qemuDomainDetachThisHostDevice(driver, vm,
- virDomainNetGetActualHostdev(detach),
- -1);
- goto cleanup;
- }
-
if (!detach) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("network device %02x:%02x:%02x:%02x:%02x:%02x not found"),
@@ -2097,6 +2090,13 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
goto cleanup;
}
+ if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+ ret = qemuDomainDetachThisHostDevice(driver, vm,
+ virDomainNetGetActualHostdev(detach),
+ -1);
+ goto cleanup;
+ }
+
if (!virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
--
1.7.7.5
12 years, 8 months
[libvirt] [PATCH] graphics: Cleanup port policy
by Michal Privoznik
Even though we say in documentation setting (tls-)port to -1 is legacy
compat style for enabling autoport, we're roughly doing this for VNC.
However, in case of SPICE auto enable autoport iff both port & tlsPort
are equal -1 as documentation says autoport plays with both.
---
src/conf/domain_conf.c | 30 ++++++++++++++++++++----------
src/conf/domain_conf.h | 5 +++++
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_process.c | 33 ++++++++++++++++++++-------------
4 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b185fe7..d142512 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5929,6 +5929,10 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
VIR_FREE(port);
goto error;
}
+ /* Legacy compat syntax, used -1 for auto-port */
+ if (def->data.rdp.port == -1)
+ def->data.rdp.autoport = 1;
+
VIR_FREE(port);
} else {
def->data.rdp.port = 0;
@@ -5936,14 +5940,15 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
}
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
- if (STREQ(autoport, "yes")) {
- if (flags & VIR_DOMAIN_XML_INACTIVE)
- def->data.rdp.port = 0;
+ if (STREQ(autoport, "yes"))
def->data.rdp.autoport = 1;
- }
+
VIR_FREE(autoport);
}
+ if (def->data.rdp.autoport && (flags & VIR_DOMAIN_XML_INACTIVE))
+ def->data.rdp.port = 0;
+
if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
if (STREQ(replaceUser, "yes")) {
def->data.rdp.replaceUser = 1;
@@ -6009,16 +6014,21 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
}
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
- if (STREQ(autoport, "yes")) {
- if (flags & VIR_DOMAIN_XML_INACTIVE) {
- def->data.spice.port = 0;
- def->data.spice.tlsPort = 0;
- }
+ if (STREQ(autoport, "yes"))
def->data.spice.autoport = 1;
- }
VIR_FREE(autoport);
}
+ if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) {
+ /* Legacy compat syntax, used -1 for auto-port */
+ def->data.spice.autoport = 1;
+ }
+
+ if (def->data.spice.autoport && (flags & VIR_DOMAIN_XML_INACTIVE)) {
+ def->data.spice.port = 0;
+ def->data.spice.tlsPort = 0;
+ }
+
def->data.spice.keymap = virXMLPropString(node, "keymap");
if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 6fc307e..6da22f4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1183,6 +1183,11 @@ struct _virDomainGraphicsListenDef {
};
struct _virDomainGraphicsDef {
+ /* Port value discipline:
+ * Value -1 is legacy syntax indicating that it should be auto-allocated.
+ * Value 0 means port wasn't specified in XML at all.
+ * Positive value is actual port number given in XML.
+ */
int type;
union {
struct {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 996763c..b6dd1f1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5375,7 +5375,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virBufferAsprintf(&opt, "port=%u", def->graphics[0]->data.spice.port);
- if (def->graphics[0]->data.spice.tlsPort) {
+ if (def->graphics[0]->data.spice.tlsPort > 0) {
if (!driver->spiceTLS) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("spice TLS port set in XML configuration,"
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1ac892f..ef311d1 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3169,28 +3169,35 @@ int qemuProcessStart(virConnectPtr conn,
goto cleanup;
}
vm->def->graphics[0]->data.vnc.port = port;
- } else if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
- vm->def->graphics[0]->data.spice.autoport) {
- int port = qemuProcessNextFreePort(driver, QEMU_VNC_PORT_MIN);
- int tlsPort = -1;
- if (port < 0) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Unable to find an unused SPICE port"));
- goto cleanup;
+ } else if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+ int port = -1;
+ if (vm->def->graphics[0]->data.spice.autoport ||
+ vm->def->graphics[0]->data.spice.port == -1) {
+ port = qemuProcessNextFreePort(driver, QEMU_VNC_PORT_MIN);
+
+ if (port < 0) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Unable to find an unused SPICE port"));
+ goto cleanup;
+ }
+
+ vm->def->graphics[0]->data.spice.port = port;
}
- if (driver->spiceTLS) {
- tlsPort = qemuProcessNextFreePort(driver, port + 1);
+ if (driver->spiceTLS &&
+ (vm->def->graphics[0]->data.spice.autoport ||
+ vm->def->graphics[0]->data.spice.tlsPort == -1)) {
+ int tlsPort = qemuProcessNextFreePort(driver,
+ vm->def->graphics[0]->data.spice.port + 1);
if (tlsPort < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to find an unused SPICE TLS port"));
qemuProcessReturnPort(driver, port);
goto cleanup;
}
- }
- vm->def->graphics[0]->data.spice.port = port;
- vm->def->graphics[0]->data.spice.tlsPort = tlsPort;
+ vm->def->graphics[0]->data.spice.tlsPort = tlsPort;
+ }
}
}
--
1.7.8.5
12 years, 8 months
[libvirt] [PATCH] docs: fix usage example on setting log levels
by Eric Blake
Reported by Michael S. Tsirkin.
* docs/logging.html.in (log_examples): Use correct libvirtd.conf
syntax.
---
Pushing under the trivial rule.
docs/logging.html.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/logging.html.in b/docs/logging.html.in
index ebacdac..22b5422 100644
--- a/docs/logging.html.in
+++ b/docs/logging.html.in
@@ -170,8 +170,8 @@ export LIBVIRT_LOG_OUTPUTS="1:file:virsh.log"</pre>
put the correct breakpoints when running under a debugger.</p>
<p>To activate full debug of the libvirt entry points, utility
functions and the QEmu/KVM driver, set:</p>
- <pre>log_filters=1:libvirt 1:util 1:qemu
-log_output=1:file:/var/log/libvirt/libvirtd.log</pre>
+ <pre>log_filters="1:libvirt 1:util 1:qemu"
+log_outputs="1:file:/var/log/libvirt/libvirtd.log"</pre>
<p>in libvirtd.conf and restart the daemon will allow to
gather a copious amount of debugging traces for the operations done
in those areas.</p>
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH 0/2] add user and system times to domain cpu stats
by Eric Blake
See also https://bugzilla.redhat.com/show_bug.cgi?id=800366
Eric Blake (2):
cpustats: collect VM user and sys times
cpustats: report user and sys times
include/libvirt/libvirt.h.in | 12 ++++++++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 45 ++++++++++++++++++++++++++++++------
src/util/cgroup.c | 51 ++++++++++++++++++++++++++++++++++++++++-
src/util/cgroup.h | 4 ++-
src/util/virtypedparam.h | 5 ++-
tools/virsh.c | 12 +++++----
7 files changed, 112 insertions(+), 18 deletions(-)
--
1.7.7.6
12 years, 8 months
[libvirt] [libvirt-glib] All string getters should return 'const'
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
There is no need for all the memory (de)allocations and especially
forcing the app developers to free the strings. They can always
g_strdup() the returned string if they need.
---
libvirt-gconfig/libvirt-gconfig-domain-disk.c | 13 ++---
libvirt-gconfig/libvirt-gconfig-domain-disk.h | 8 ++--
libvirt-gconfig/libvirt-gconfig-domain-graphics.c | 3 +-
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 9 ++--
libvirt-gconfig/libvirt-gconfig-domain-interface.h | 6 +-
libvirt-gconfig/libvirt-gconfig-domain.c | 8 ++--
libvirt-gconfig/libvirt-gconfig-domain.h | 4 +-
libvirt-gconfig/libvirt-gconfig-helpers-private.h | 16 +++---
libvirt-gconfig/libvirt-gconfig-helpers.c | 54 +++++++++----------
libvirt-gconfig/libvirt-gconfig-object-private.h | 10 ++--
libvirt-gconfig/libvirt-gconfig-object.c | 13 ++---
libvirt-gconfig/tests/test-domain-create.c | 18 ++++---
libvirt-gconfig/tests/test-domain-parse.c | 3 +-
libvirt-gobject/libvirt-gobject-domain-disk.c | 10 ++--
libvirt-gobject/libvirt-gobject-domain-interface.c | 7 +--
15 files changed, 87 insertions(+), 95 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.c b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
index afa7eda..2944739 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.c
@@ -76,16 +76,15 @@ gvir_config_domain_disk_new_from_tree(GVirConfigXmlDoc *doc,
GVirConfigObject *object;
GVirConfigDomainDisk *disk;
GVirConfigDomainDiskType type;
- xmlChar *type_str;
+ const xmlChar *type_str;
type_str = gvir_config_xml_get_attribute_content(tree, "type");
if (type_str == NULL)
return NULL;
type = gvir_config_genum_get_value(GVIR_CONFIG_TYPE_DOMAIN_DISK_TYPE,
- (char *)type_str,
+ (const char *)type_str,
GVIR_CONFIG_DOMAIN_DISK_FILE);
- xmlFree(type_str);
if (type == -1)
return NULL;
@@ -236,7 +235,7 @@ gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk)
GVIR_CONFIG_DOMAIN_DISK_SNAPSHOT_NO);
}
-char *
+const char *
gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk)
{
const char *attribute_name;
@@ -263,7 +262,7 @@ gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk)
"source", attribute_name);
}
-char *
+const char *
gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL);
@@ -272,7 +271,7 @@ gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk)
"driver", "name");
}
-char *
+const char *
gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL);
@@ -307,7 +306,7 @@ gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk)
GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
}
-char *
+const char *
gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_DISK(disk), NULL);
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-disk.h b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
index 4b16b80..916421d 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-disk.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-disk.h
@@ -123,12 +123,12 @@ void gvir_config_domain_disk_set_target_dev(GVirConfigDomainDisk *disk,
GVirConfigDomainDiskType gvir_config_domain_disk_get_disk_type(GVirConfigDomainDisk *disk);
GVirConfigDomainDiskGuestDeviceType gvir_config_domain_disk_get_guest_device_type(GVirConfigDomainDisk *disk);
GVirConfigDomainDiskSnapshotType gvir_config_domain_disk_get_snapshot_type(GVirConfigDomainDisk *disk);
-char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk);
+const char *gvir_config_domain_disk_get_source(GVirConfigDomainDisk *disk);
GVirConfigDomainDiskCacheType gvir_config_domain_disk_get_driver_cache(GVirConfigDomainDisk *disk);
-char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk);
-char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk);
+const char *gvir_config_domain_disk_get_driver_name(GVirConfigDomainDisk *disk);
+const char *gvir_config_domain_disk_get_driver_type(GVirConfigDomainDisk *disk);
GVirConfigDomainDiskBus gvir_config_domain_disk_get_target_bus(GVirConfigDomainDisk *disk);
-char *gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk);
+const char *gvir_config_domain_disk_get_target_dev(GVirConfigDomainDisk *disk);
void gvir_config_domain_disk_set_readonly(GVirConfigDomainDisk *disk,
gboolean readonly);
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-graphics.c b/libvirt-gconfig/libvirt-gconfig-domain-graphics.c
index 05a2f01..c79406e 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-graphics.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-graphics.c
@@ -53,7 +53,7 @@ G_GNUC_INTERNAL GVirConfigDomainDevice *
gvir_config_domain_graphics_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree)
{
- xmlChar *type;
+ const xmlChar *type;
GType gtype;
type = gvir_config_xml_get_attribute_content(tree, "type");
@@ -74,7 +74,6 @@ gvir_config_domain_graphics_new_from_tree(GVirConfigXmlDoc *doc,
g_debug("Unknown graphics node: %s", type);
return NULL;
}
- xmlFree(type);
return GVIR_CONFIG_DOMAIN_DEVICE(gvir_config_object_new_from_tree(gtype, doc, NULL, tree));
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index 5fe27a1..6f539a2 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -96,7 +96,7 @@ void gvir_config_domain_interface_set_model(GVirConfigDomainInterface *interface
"model", "type", model);
}
-char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface)
+const char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
@@ -115,7 +115,7 @@ GVirConfigDomainInterfaceLinkState gvir_config_domain_interface_get_link_state(G
GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_DEFAULT);
}
-char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface)
+const char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
@@ -123,7 +123,7 @@ char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface)
"mac", "address");
}
-char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface)
+const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface)
{
g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
@@ -135,7 +135,7 @@ G_GNUC_INTERNAL GVirConfigDomainDevice *
gvir_config_domain_interface_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree)
{
- xmlChar *type;
+ const xmlChar *type;
GType gtype;
type = gvir_config_xml_get_attribute_content(tree, "type");
@@ -160,7 +160,6 @@ gvir_config_domain_interface_new_from_tree(GVirConfigXmlDoc *doc,
g_debug("Unknown domain interface node: %s", type);
return NULL;
}
- xmlFree(type);
return GVIR_CONFIG_DOMAIN_DEVICE(gvir_config_object_new_from_tree(gtype, doc, NULL, tree));
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.h b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
index 567f95a..c8c4fb3 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
@@ -72,10 +72,10 @@ void gvir_config_domain_interface_set_mac(GVirConfigDomainInterface *interface,
const char *mac_address);
void gvir_config_domain_interface_set_model(GVirConfigDomainInterface *interface,
const char *model);
-char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface);
+const char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface);
GVirConfigDomainInterfaceLinkState gvir_config_domain_interface_get_link_state(GVirConfigDomainInterface *interface);
-char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface);
-char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface);
+const char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface);
+const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index 177c926..33a69e3 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -54,10 +54,10 @@ static void gvir_config_domain_get_property(GObject *object,
switch (prop_id) {
case PROP_NAME:
- g_value_take_string(value, gvir_config_domain_get_name(domain));
+ g_value_set_string(value, gvir_config_domain_get_name(domain));
break;
case PROP_DESCRIPTION:
- g_value_take_string(value, gvir_config_domain_get_description(domain));
+ g_value_set_string(value, gvir_config_domain_get_description(domain));
break;
case PROP_MEMORY:
g_value_set_uint64(value, gvir_config_domain_get_memory(domain));
@@ -198,7 +198,7 @@ void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomain
}
-char *gvir_config_domain_get_name(GVirConfigDomain *domain)
+const char *gvir_config_domain_get_name(GVirConfigDomain *domain)
{
return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(domain),
"name");
@@ -211,7 +211,7 @@ void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name)
g_object_notify(G_OBJECT(domain), "name");
}
-char *gvir_config_domain_get_description(GVirConfigDomain *domain)
+const char *gvir_config_domain_get_description(GVirConfigDomain *domain)
{
return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(domain),
"description");
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
index 769d2f0..1dbfd95 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -100,9 +100,9 @@ GVirConfigDomain *gvir_config_domain_new_from_xml(const gchar *xml, GError **err
GVirConfigDomain *gvir_config_domain_new(void);
void gvir_config_domain_set_virt_type(GVirConfigDomain *domain, GVirConfigDomainVirtType type);
-char *gvir_config_domain_get_name(GVirConfigDomain *domain);
+const char *gvir_config_domain_get_name(GVirConfigDomain *domain);
void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name);
-char *gvir_config_domain_get_description(GVirConfigDomain *domain);
+const char *gvir_config_domain_get_description(GVirConfigDomain *domain);
void gvir_config_domain_set_description(GVirConfigDomain *domain, const char *description);
guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain);
void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory);
diff --git a/libvirt-gconfig/libvirt-gconfig-helpers-private.h b/libvirt-gconfig/libvirt-gconfig-helpers-private.h
index 514aeb0..aa53874 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-helpers-private.h
@@ -50,15 +50,15 @@ void gvir_config_xml_foreach_child(xmlNodePtr node,
GVirConfigXmlNodeIterator iter_func,
gpointer opaque);
xmlNode * gvir_config_xml_get_element (xmlNode *node, ...);
-xmlChar * gvir_config_xml_get_child_element_content (xmlNode *node,
- const char *child_name);
-char *gvir_config_xml_get_child_element_content_glib (xmlNode *node,
- const char *child_name);
-xmlChar *gvir_config_xml_get_attribute_content(xmlNodePtr node,
- const char *attr_name);
+const xmlChar * gvir_config_xml_get_child_element_content (xmlNode *node,
+ const char *child_name);
+const char *gvir_config_xml_get_child_element_content_glib (xmlNode *node,
+ const char *child_name);
+const xmlChar *gvir_config_xml_get_attribute_content(xmlNodePtr node,
+ const char *attr_name);
char *gvir_config_xml_node_to_string(xmlNodePtr node);
-char *gvir_config_xml_get_attribute_content_glib(xmlNodePtr node,
- const char *attr_name);
+const char *gvir_config_xml_get_attribute_content_glib(xmlNodePtr node,
+ const char *attr_name);
const char *gvir_config_genum_get_nick (GType enum_type, gint value);
int gvir_config_genum_get_value (GType enum_type, const char *nick, gint default_value);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index 5f4ebe9..49c7f90 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -220,56 +220,54 @@ gvir_config_xml_get_element (xmlNode *node, ...)
return node;
}
-xmlChar *
-gvir_config_xml_get_child_element_content (xmlNode *node,
+const xmlChar *
+gvir_config_xml_get_child_element_content (xmlNode *node,
const char *child_name)
{
- xmlNode *child_node;
+ xmlNode *child_node;
- child_node = gvir_config_xml_get_element (node, child_name, NULL);
- if (!child_node)
- return NULL;
-
- return xmlNodeGetContent (child_node);
-}
-
-static char *libxml_str_to_glib(xmlChar *str)
-{
- char *g_str;
-
- if (str == NULL)
+ child_node = gvir_config_xml_get_element(node, child_name, NULL);
+ if (!child_node || !(child_node->children))
return NULL;
- g_str = g_strdup((char *)str);
- xmlFree(str);
- return g_str;
+ return child_node->children->content;
}
-char *
-gvir_config_xml_get_child_element_content_glib (xmlNode *node,
+const char *
+gvir_config_xml_get_child_element_content_glib (xmlNode *node,
const char *child_name)
{
- xmlChar *content;
+ const xmlChar *content;
- content = gvir_config_xml_get_child_element_content (node, child_name);
+ content = gvir_config_xml_get_child_element_content(node, child_name);
- return libxml_str_to_glib(content);
+ return (const char *)content;
}
-G_GNUC_INTERNAL xmlChar *
+G_GNUC_INTERNAL const xmlChar *
gvir_config_xml_get_attribute_content(xmlNodePtr node, const char *attr_name)
{
- return xmlGetProp(node, (const xmlChar*)attr_name);
+ xmlAttr *attr;
+
+ for (attr = node->properties; attr; attr = attr->next) {
+ if (attr->name == NULL)
+ continue;
+
+ if (strcmp (attr_name, (char *)attr->name) == 0)
+ break;
+ }
+
+ return attr->children->content;
}
-G_GNUC_INTERNAL char *
+G_GNUC_INTERNAL const char *
gvir_config_xml_get_attribute_content_glib(xmlNodePtr node, const char *attr_name)
{
- xmlChar *attr;
+ const xmlChar *attr;
attr = gvir_config_xml_get_attribute_content(node, attr_name);
- return libxml_str_to_glib(attr);
+ return (const char *) attr;
}
const char *gvir_config_genum_get_nick (GType enum_type, gint value)
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index 41cbfe8..a6b7395 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -31,17 +31,17 @@ GVirConfigObject *gvir_config_object_new_from_tree(GType type,
const char *schema,
xmlNodePtr tree);
xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config);
-char *gvir_config_object_get_node_content(GVirConfigObject *object,
- const char *node_name);
+const 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);
+const 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,
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index b637960..d99a0a2 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -274,7 +274,7 @@ gvir_config_object_get_xml_node(GVirConfigObject *config)
return config->priv->node;
}
-G_GNUC_INTERNAL char *
+G_GNUC_INTERNAL const char *
gvir_config_object_get_node_content(GVirConfigObject *object,
const char *node_name)
{
@@ -287,7 +287,7 @@ gvir_config_object_get_node_content(GVirConfigObject *object,
return gvir_config_xml_get_child_element_content_glib(node, node_name);
}
-G_GNUC_INTERNAL char *
+G_GNUC_INTERNAL const char *
gvir_config_object_get_attribute(GVirConfigObject *object,
const char *node_name,
const char *attr_name)
@@ -559,7 +559,7 @@ gvir_config_object_get_node_content_uint64(GVirConfigObject *object,
const char *node_name)
{
xmlNodePtr node;
- xmlChar *str;
+ const xmlChar *str;
guint64 value;
node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object));
@@ -571,7 +571,6 @@ gvir_config_object_get_node_content_uint64(GVirConfigObject *object,
return 0;
value = g_ascii_strtoull((char *)str, NULL, 0);
- xmlFree(str);
return value;
}
@@ -583,7 +582,7 @@ gvir_config_object_get_node_content_genum(GVirConfigObject *object,
gint default_value)
{
xmlNodePtr node;
- xmlChar *str;
+ const xmlChar *str;
gint value;
node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object));
@@ -595,7 +594,6 @@ gvir_config_object_get_node_content_genum(GVirConfigObject *object,
return default_value;
value = gvir_config_genum_get_value(enum_type, (char *)str, default_value);
- xmlFree(str);
return value;
}
@@ -608,7 +606,7 @@ gvir_config_object_get_attribute_genum(GVirConfigObject *object,
gint default_value)
{
xmlNodePtr node;
- xmlChar *attr_val;
+ const xmlChar *attr_val;
gint value;
g_return_val_if_fail(attr_name != NULL, default_value);
@@ -629,7 +627,6 @@ gvir_config_object_get_attribute_genum(GVirConfigObject *object,
value = gvir_config_genum_get_value(enum_type, (char *)attr_val,
default_value);
- xmlFree(attr_val);
return value;
}
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index a92413d..8c9a6ba 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -32,10 +32,14 @@
const char *features[] = { "foo", "bar", "baz", NULL };
+#define g_str_const_check(str1, str2) G_STMT_START { \
+ g_assert((str1) != NULL); \
+ g_assert(g_strcmp0((str1), (str2)) == 0); \
+} G_STMT_END
+
#define g_str_check(str1, str2) G_STMT_START { \
char *alloced_str = (str1); \
- g_assert(alloced_str != NULL); \
- g_assert(g_strcmp0(alloced_str, (str2)) == 0); \
+ g_str_const_check(alloced_str, (str2)); \
g_free(alloced_str); \
} G_STMT_END
@@ -51,7 +55,7 @@ int main(int argc, char **argv)
domain = gvir_config_domain_new();
g_assert(domain != NULL);
gvir_config_domain_set_name(domain, "foo");
- g_str_check(gvir_config_domain_get_name(domain), "foo");
+ g_str_const_check(gvir_config_domain_get_name(domain), "foo");
gvir_config_domain_set_memory(domain, 1234);
g_assert(gvir_config_domain_get_memory(domain) == 1234);
@@ -113,12 +117,12 @@ int main(int argc, char **argv)
g_assert(gvir_config_domain_disk_get_disk_type(disk) == GVIR_CONFIG_DOMAIN_DISK_FILE);
g_assert(gvir_config_domain_disk_get_guest_device_type(disk) == GVIR_CONFIG_DOMAIN_DISK_GUEST_DEVICE_DISK);
- g_str_check(gvir_config_domain_disk_get_source(disk), "/tmp/foo/bar");
+ g_str_const_check(gvir_config_domain_disk_get_source(disk), "/tmp/foo/bar");
g_assert(gvir_config_domain_disk_get_driver_cache(disk) == GVIR_CONFIG_DOMAIN_DISK_CACHE_NONE);
- g_str_check(gvir_config_domain_disk_get_driver_name(disk), "qemu");
- g_str_check(gvir_config_domain_disk_get_driver_type(disk), "qcow2");
+ g_str_const_check(gvir_config_domain_disk_get_driver_name(disk), "qemu");
+ g_str_const_check(gvir_config_domain_disk_get_driver_type(disk), "qcow2");
g_assert(gvir_config_domain_disk_get_target_bus(disk) == GVIR_CONFIG_DOMAIN_DISK_BUS_IDE);
- g_str_check(gvir_config_domain_disk_get_target_dev(disk), "hda");
+ g_str_const_check(gvir_config_domain_disk_get_target_dev(disk), "hda");
/* network interfaces node */
diff --git a/libvirt-gconfig/tests/test-domain-parse.c b/libvirt-gconfig/tests/test-domain-parse.c
index c264ff9..11880de 100644
--- a/libvirt-gconfig/tests/test-domain-parse.c
+++ b/libvirt-gconfig/tests/test-domain-parse.c
@@ -34,7 +34,7 @@
int main(int argc, char **argv)
{
GVirConfigDomain *domain;
- char *name;
+ const char *name;
GStrv features;
char *xml;
GError *error = NULL;
@@ -69,7 +69,6 @@ int main(int argc, char **argv)
name = gvir_config_domain_get_name(domain);
g_assert(name != NULL);
g_assert(strcmp(name, "foo") == 0);
- g_free(name);
g_assert(gvir_config_domain_get_memory(domain) == 987654321);
diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c
index d8fb63d..fb85328 100644
--- a/libvirt-gobject/libvirt-gobject-domain-disk.c
+++ b/libvirt-gobject/libvirt-gobject-domain-disk.c
@@ -90,10 +90,10 @@ gvir_domain_disk_stats_free(GVirDomainDiskStats *stats)
G_DEFINE_BOXED_TYPE(GVirDomainDiskStats, gvir_domain_disk_stats,
gvir_domain_disk_stats_copy, gvir_domain_disk_stats_free)
-static gchar *gvir_domain_disk_get_path(GVirDomainDisk *self)
+static const gchar *gvir_domain_disk_get_path(GVirDomainDisk *self)
{
GVirConfigDomainDevice *config;
- gchar *path;
+ const gchar *path;
config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
path = gvir_config_domain_disk_get_target_dev(GVIR_CONFIG_DOMAIN_DISK(config));
@@ -119,7 +119,7 @@ GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **e
GVirDomainDiskStats *ret = NULL;
virDomainBlockStatsStruct stats;
virDomainPtr handle;
- gchar *path;
+ const gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_DISK(self), NULL);
@@ -142,7 +142,6 @@ GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **e
end:
virDomainFree(handle);
- g_free(path);
return ret;
}
@@ -164,7 +163,7 @@ gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
{
gboolean ret = FALSE;
virDomainPtr handle;
- gchar *path;
+ const gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_DISK(self), FALSE);
g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
@@ -183,6 +182,5 @@ gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
end:
virDomainFree(handle);
- g_free(path);
return ret;
}
diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c
index 4436466..9f4b30d 100644
--- a/libvirt-gobject/libvirt-gobject-domain-interface.c
+++ b/libvirt-gobject/libvirt-gobject-domain-interface.c
@@ -88,10 +88,10 @@ gvir_domain_interface_stats_free(GVirDomainInterfaceStats *stats)
G_DEFINE_BOXED_TYPE(GVirDomainInterfaceStats, gvir_domain_interface_stats,
gvir_domain_interface_stats_copy, gvir_domain_interface_stats_free)
-static gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
+static const gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
{
GVirConfigDomainDevice *config;
- gchar *path = NULL;
+ const gchar *path = NULL;
config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
if (GVIR_CONFIG_IS_DOMAIN_INTERFACE_USER(self))
@@ -121,7 +121,7 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
GVirDomainInterfaceStats *ret = NULL;
virDomainInterfaceStatsStruct stats;
virDomainPtr handle;
- gchar *path;
+ const gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_INTERFACE(self), NULL);
@@ -151,6 +151,5 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
end:
virDomainFree(handle);
- g_free(path);
return ret;
}
--
1.7.7.6
12 years, 8 months
[libvirt] Per-guest configurable user/group for QEMU processes
by Marcelo Cerri
Hi,
I'm starting working on an improvement for libvirt to be able to support
per-guest configurable user and group IDs for QEMU processes. Currently,
libvirt uses a configurable pair of user and group, which is defined in
qemu.conf, for all qemu processes when running in privileged mode.
This topic was already commented in qemu mailing list
(http://lists.nongnu.org/archive/html/qemu-devel/2011-10/msg00758.html)
but, as this requires changes in libvirt API, I'd like to discuss what
would be the best solution for it.
A solution (as proposed in the link above) would be to extend the
security driver model to allow multiple drivers. In this case, an
example of the XML definition would be:
...
<seclabel type='dynamic' model='selinux'>
<label>system_u:system_r:svirt_t:s0:c633,c712</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c633,c712</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac'>
<label>102:102</label>
<imagelabel>102:102</imagelabel>
</seclabel>
...
I don't know if this is a clean solution because the usual option would
be to enclose the block above in a "<seclabels>" tag. But as this would
break the actual API, it's not viable.
Another option is to expose the stack security driver that already
exists internally in libvirt (maybe extending it to support more than
two security drivers):
...
<seclabel type='stack'>
<seclabel type='dynamic' model='selinux'>
<label>system_u:system_r:svirt_t:s0:c633,c712</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c633,c712</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac'>
<label>102:102</label>
<imagelabel>102:102</imagelabel>
</seclabel>
</seclabel>
...
In that case, a nested seclabel only would be allowed when type='stack'.
Independently of how multiple security drivers can be expressed in the
XML, another problem would be how functions as virDomainGetSecurityLabel
should behave.
A third option is to just not support multiple security drivers and
include a new tag for DAC:
...
<seclabel type='dynamic' model='selinux'>
<label>system_u:system_r:svirt_t:s0:c633,c712</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c633,c712</imagelabel>
</seclabel>
<dac process='102:102' image='102:102'/>
...
Please let me know your opinions about this topic.
Regards,
Marcelo
12 years, 8 months