[libvirt] RFC: dhcp <option> element revisited
by Laine Stump
Before 1.0.3, Pieter Hollants kindly implemented the XML I had earlier
suggested to support configure-by-number dhcp options in libvirt networks.
https://www.redhat.com/archives/libvir-list/2013-February/msg01251.html
I also posted a followup patch for a "force" attribute to options:
https://www.redhat.com/archives/libvir-list/2013-February/msg01349.html
I actually pushed a slightly fixed version of Pieter's patch, and was
looking for an ACK to mine when Eric questioned whether it was all
really ready to push since we hadn't implemented *named* options
(although there is no official RFC standard for the names of options,
dnsmasq uses a pretty good set of lowercase-dash-separated names that
make sense, and would certainly make it easier to decode the config). At
the time I had just started trying to write such a patch, and was
realizing that the XML we'd come up with didn't have any provision to
easily deal with an option that took a list of values (multiple IP
addresses, multiple domain names, etc); for numbered options we could
just punt on this and say "put the multiple values in the single 'value'
attribute, separated by commas", but we all know that's a cop-out, so I
decided to temporarily pull Pieter's patch to avoid regrets over getting
something suboptimal in an official release.
That's all the history. Now on to discussing how we should modify these
patches to be exactly what we want.
I tried digging down into the data of the options to try and make an
exhaustive XML representation, with the results below (these would all
go directly inside the <dhcp> element of a libvirt network). But it's
starting to seem like the deeper I go, the deeper it gets (the
classless-static-route option is the current "deepest", and I haven't
even attempted to do anything about vendor-specific options), so I'm
starting to wonder where to draw the line - see the "STEPPING BACK"
section at the bottom.
1) numeric option, single value:
<option code='119'>
<value type='domain' data='a.example.com'/>
</option>
(Note that I changed "number" to "code" after seeing that suggestion in
[1] because that's what it's called in the RFC).
(Also note that the actual encoding of option 119's data is more
complicated than described here [2], but it's complicated enough that I
think whatever dhcp server implementation is underneath libvirt will
need to know the details anyway and decided what we should go for with
the "type" attribute is enough for libvirt to validate the input, not
necessarily to encode it into a DHCP response packet; any translation
from the validated input will be handled internally to the backend
driver (currently bridge_driver.c which uses dnsmasq) (I'm actually
wondering if type is needed in the XML at all, since the type of any
piece of data is always either implicit, or unknown (in which case we
just accept any text and pass it through to the backend driver).)
2) numeric option, multiple values:
<option code='119' force='yes'>
<value type='domain' data='a.example.com'/>
<value type='domain' data='b.example.com'/>
<value type='domain' data='c.example.com'/>
</option>
3) named option, single simple value:
<option name='ip-forward-enable'>
<value type='boolean' data='yes'/>
</option>
4) named option, multiple simple values:
<option name='dns-server'>
<value type='ipv4Addr' data='10.1.1.1'/>
<value type='ipv4Addr' data='10.1.1.2'/>
</option>
<option
(for all named options and known numeric options, the "type" field would
be optional, as libvirt will already have an internal table associating
option names/code with the type of data, as well as whether or not
multiples are allowed)
5) named option, multiple compound values:
<option name='classless-static-route'>
<value type='compound'>
<value type='ipv4Addr' data='1.2.3.0'/>
<value type='ipv4Prefix' data='24'/>
<value type='ipv4Addr' data='192.168.122.5'/>
</value>
<value type='compound'>
<value type='ipv4Addr' data='1.2.4.0'/>
<value type='ipv4Prefix' data='24'/>
<value type='ipv4Addr' data='192,.168.122.6'/>
</value>
</option>
(I suppose this could also be done as a flat list, since every static
route needs all three)
The types I can see that we need (to describe everything in RFC2132
(except vendor-specific options) and the other options I know about) are:
ipv4Addr
ipv4Prefix
text
path
domain
boolean
number
ANOTHER POSSIBILITY
===================
Another way of dealing with options that permit lists of multiple values
- just specify the option multiple times, e.g.:
<option name='dnsServer' type='ipv4Addr' data='10.1.1.1'/>
<option name='dnsServer' type='ipv4Addr' data='10.1.1.2'/>
============================
BTW - another point; I had earlier said that we didn't need to worry
about an option number blacklist/whitelist. After looking through the
options in RFC 2132, I've changed my mind - many of the option codes
(particularly those in the 50's) aren't really general purpose options,
but are used by dhcp as integral parts of implementing the exchange
sequence between the server and client. So I think what we need to do is
have a whitelist that has an entry for every dhcp option we are willing
to accept. It would contain:
uint8 code;
const char *name; /* could be "", in which case we don't recognize a
name for it */
unsigned int flags; /* whether or not multiple values are allowed,
name recognized by dnsmasq */
/* some representation of type here - what to do about the "compound"
type? */
STEPPING BACK
-------------
So are we going too far with this? Or should we dial it back to the
original proposal in Pieter's patch and just say that
1) if <option> is used, the data is passed through unqualified to the
dhcp implementation
2) only "simple", known option types with a single no-repeating value
can be specified this
way (and data type is implied)(this would be enforced with the
"whitelist")
3) then implement separate elements for the complicated/repeating
options, e.g.:
<route destination='1.2.3.0' prefix='24' nextHop='192.168.122.5'/>
<route destination='1.2.4.0' prefix='24' nextHop='192.168.122.6'/>
...
<dnsServer address='10.1.1.1'/>
<dnsServer address='10.1.1.2'/>
Or maybe to simplify the parser this would work as:
<option name='classless-static-route' destination='1.2.3.0'
prefix='24' nextHop='192.168.122.5'/>
<option name='classless-static-route' destination='1.2.4.0'
prefix='24' nextHop='192.168.122.6'/>
...
<option name='dns-server address='10.1.1.1'/>
<option name='dns-server address='10.1.1.2'/>
Either of these definitely seems more compact and easy to understand
than all that ranting and raving at the top of this message...
Any other suggestions?
===
[1] https://bugzilla.redhat.com/show_bug.cgi?id=666556
[2] https://tools.ietf.org/rfc/rfc3397.txt
11 years, 7 months
[libvirt] [PATCH v3 00/11] Add support for guests with TPM passthrough device
by Stefan Berger
Hello!
The following set of patches adds support to libvirt for
adding a TPM passthrough device to a QEMU guest. Support for
this was recently accepted into QEMU.
This set of patches borrows a lot from the recently added support
for rng's.
Regards,
Stefan
---
v2->v3:
- followed tree to 03122d7b
- some bits fixed
v1->v2:
- Followed Daniel Berrange's comments
(except for the one on de-consolidating the JSON monitor code)
11 years, 7 months
[libvirt] [PATCH v2] Allow multiple parameters for schedinfo
by Martin Kletzander
virsh schedinfo was able to set only one parameter at a time (not
counting the deprecated options), but it is useful to set more at
once, so this patch adds the possibility to do stuff like this:
virsh schedinfo <domain> cpu_shares=0 vcpu_period=0 vcpu_quota=0 \
emulator_period=0 emulator_quota=0
Invalid scheduler options are reported as well. These were previously
reported only if the command hadn't updated any values (when
cmdSchedInfoUpdate returned 0).
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=810078
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=919372
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=919375
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
v2:
- correctly report unsupported options
- man page updated
tests/virsh-schedinfo | 4 +-
tools/virsh-domain.c | 119 ++++++++++++++++++++++++++++----------------------
tools/virsh.pod | 4 +-
3 files changed, 72 insertions(+), 55 deletions(-)
diff --git a/tests/virsh-schedinfo b/tests/virsh-schedinfo
index 4f462f8..37f7bd3 100755
--- a/tests/virsh-schedinfo
+++ b/tests/virsh-schedinfo
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that virsh schedinfo --set invalid=val fails
-# Copyright (C) 2010-2011 Red Hat, Inc.
+# Copyright (C) 2010-2011, 2013 Red Hat, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ fi
. "$srcdir/test-lib.sh"
printf 'Scheduler : fair\n\n' > exp-out || framework_failure
-printf 'error: invalid scheduler option: j=k\n' > exp-err || framework_failure
+printf 'error: invalid scheduler option: j\n' > exp-err || framework_failure
fail=0
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 128e516..cc2eddc 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3918,16 +3918,14 @@ static const vshCmdOptDef opts_schedinfo[] = {
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
- {.name = "set",
- .type = VSH_OT_STRING,
- .help = N_("parameter=value")
- },
{.name = "weight",
.type = VSH_OT_INT,
+ .flags = VSH_OFLAG_REQ_OPT,
.help = N_("weight for XEN_CREDIT")
},
{.name = "cap",
.type = VSH_OT_INT,
+ .flags = VSH_OFLAG_REQ_OPT,
.help = N_("cap for XEN_CREDIT")
},
{.name = "current",
@@ -3942,72 +3940,100 @@ static const vshCmdOptDef opts_schedinfo[] = {
.type = VSH_OT_BOOL,
.help = N_("get/set value from running domain")
},
+ {.name = "set",
+ .type = VSH_OT_ARGV,
+ .flags = VSH_OFLAG_NONE,
+ .help = N_("parameter=value")
+ },
{.name = NULL}
};
static int
+cmdSchedInfoUpdateOne(vshControl *ctl,
+ virTypedParameterPtr src_params, int nsrc_params,
+ virTypedParameterPtr *params,
+ int *nparams, int *maxparams,
+ const char *field, const char *value)
+{
+ virTypedParameterPtr param;
+ int ret = -1;
+ int i;
+
+ for (i = 0; i < nsrc_params; i++) {
+ param = &(src_params[i]);
+
+ if (STRNEQ(field, param->field))
+ continue;
+
+ if (virTypedParamsAddFromString(params, nparams, maxparams,
+ field, param->type,
+ value) < 0) {
+ vshSaveLibvirtError();
+ goto cleanup;
+ }
+ ret = 0;
+ break;
+ }
+
+ if (ret < 0)
+ vshError(ctl, _("invalid scheduler option: %s"), field);
+
+ cleanup:
+ return ret;
+}
+
+static int
cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd,
virTypedParameterPtr src_params, int nsrc_params,
virTypedParameterPtr *update_params)
{
- const char *set_arg;
char *set_field = NULL;
char *set_val = NULL;
- virTypedParameterPtr param;
+ const char *val = NULL;
+ const vshCmdOpt *opt = NULL;
virTypedParameterPtr params = NULL;
int nparams = 0;
int maxparams = 0;
int ret = -1;
int rv;
- int val;
- int i;
- if (vshCommandOptString(cmd, "set", &set_arg) > 0) {
- set_field = vshStrdup(ctl, set_arg);
+ while ((opt = vshCommandOptArgv(cmd, opt))) {
+ set_field = vshStrdup(ctl, opt->data);
if (!(set_val = strchr(set_field, '='))) {
- vshError(ctl, "%s", _("Invalid syntax for --set, expecting name=value"));
+ vshError(ctl, "%s", _("Invalid syntax for --set, "
+ "expecting name=value"));
goto cleanup;
}
*set_val = '\0';
set_val++;
- }
- for (i = 0; i < nsrc_params; i++) {
- param = &(src_params[i]);
-
- /* Legacy 'weight' and 'cap' parameter */
- if (param->type == VIR_TYPED_PARAM_UINT &&
- (STREQ(param->field, "weight") || STREQ(param->field, "cap")) &&
- (rv = vshCommandOptInt(cmd, param->field, &val)) != 0) {
- if (rv < 0) {
- vshError(ctl, _("Invalid value of %s"), param->field);
- goto cleanup;
- }
-
- if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
- param->field, val) < 0) {
- vshSaveLibvirtError();
- goto cleanup;
- }
+ if (cmdSchedInfoUpdateOne(ctl, src_params, nsrc_params,
+ ¶ms, &nparams, &maxparams,
+ set_field, set_val) < 0)
+ goto cleanup;
- continue;
- }
+ VIR_FREE(set_field);
+ }
- if (set_field && STREQ(set_field, param->field)) {
- if (virTypedParamsAddFromString(¶ms, &nparams, &maxparams,
- set_field, param->type,
- set_val) < 0) {
- vshSaveLibvirtError();
- goto cleanup;
- }
+ rv = vshCommandOptStringReq(ctl, cmd, "cap", &val);
+ if (rv < 0 ||
+ (val &&
+ cmdSchedInfoUpdateOne(ctl, src_params, nsrc_params,
+ ¶ms, &nparams, &maxparams,
+ "cap", val) < 0))
+ goto cleanup;
- continue;
- }
- }
+ rv = vshCommandOptStringReq(ctl, cmd, "weight", &val);
+ if (rv < 0 ||
+ (val &&
+ cmdSchedInfoUpdateOne(ctl, src_params, nsrc_params,
+ ¶ms, &nparams, &maxparams,
+ "weight", val) < 0))
+ goto cleanup;
- *update_params = params;
ret = nparams;
+ *update_params = params;
params = NULL;
cleanup:
@@ -4102,15 +4128,6 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
if (ret == -1)
goto cleanup;
} else {
- /* See if we've tried to --set var=val. If so, the fact that
- we reach this point (with update == 0) means that "var" did
- not match any of the settable parameters. Report the error. */
- const char *var_value_pair = NULL;
- if (vshCommandOptString(cmd, "set", &var_value_pair) > 0) {
- vshError(ctl, _("invalid scheduler option: %s"),
- var_value_pair);
- goto cleanup;
- }
/* When not doing --set, --live and --config do not mix. */
if (live && config) {
vshError(ctl, "%s",
diff --git a/tools/virsh.pod b/tools/virsh.pod
index b5e632e..6111e58 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1281,8 +1281,8 @@ except that it does some error checking.
The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment
variables, and defaults to C<vi>.
-=item B<schedinfo> [I<--set> B<parameter=value>] I<domain> [[I<--config>]
-[I<--live>] | [I<--current>]]
+=item B<schedinfo> I<domain> [[I<--config>] [I<--live>] | [I<--current>]]
+[[I<--set>] B<parameter=value>]...
=item B<schedinfo> [I<--weight> B<number>] [I<--cap> B<number>]
I<domain>
--
1.8.1.5
11 years, 7 months
[libvirt] [PATCH v5 0/3] Keep original file label
by Michal Privoznik
Yet another rework of $subj. I am still not solving atomicity
problem for now. See diff to the patches if you want to know
what's changed.
Michal Privoznik (3):
virFile: Add APIs for extended attributes handling
virfile: Introduce internal API for managing ACL
security_dac: Favour ACLs over chown()
configure.ac | 2 +
libvirt.spec.in | 1 +
m4/virt-acl.m4 | 9 ++
src/Makefile.am | 4 +-
src/libvirt_private.syms | 6 +
src/security/security_dac.c | 309 +++++++++++++++++++++++++++++++++++++++-----
src/util/virfile.c | 295 ++++++++++++++++++++++++++++++++++++++++++
src/util/virfile.h | 28 ++++
8 files changed, 623 insertions(+), 31 deletions(-)
create mode 100644 m4/virt-acl.m4
--
1.8.1.5
11 years, 7 months
[libvirt] [libvirt-glib] build: Replace obsolete macro in configure.ac
by Christophe Fergeau
From: Stefano Facchini <stefano.facchini(a)gmail.com>
Fix the build for newer automake
---
AUTHORS | 1 +
configure.ac | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/AUTHORS b/AUTHORS
index 6cec5d7..db05f64 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,5 +17,6 @@ Patches have been received from:
Timo Juhani Lindfors <timo.lindfors(a)iki.fi>
Alexander Larsson <alexl(a)redhat.com>
Claudio Bley <cbley(a)av-test.de>
+ Stefano Facchini <stefano.facchini(a)gmail.com>
... send patches to get your name added ...
diff --git a/configure.ac b/configure.ac
index 96dbf5a..2bf9c1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
AC_INIT(libvirt-glib, 0.1.7)
AC_CONFIG_SRCDIR(libvirt-glib/libvirt-glib-main.c)
AC_CONFIG_AUX_DIR([build-aux])
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
dnl Make automake keep quiet about wildcards & other GNUmake-isms
AM_INIT_AUTOMAKE([-Wno-portability])
--
1.8.1.4
11 years, 7 months
[libvirt] [libvirt-glib] config: Fix 2 leaks in domain memory setters
by Christophe Fergeau
---
libvirt-gconfig/libvirt-gconfig-domain.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index be572ab..7ef0be8 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -414,6 +414,7 @@ void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory)
gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(node),
"unit", "KiB",
NULL);
+ g_object_unref(G_OBJECT(node));
g_object_notify(G_OBJECT(domain), "memory");
}
@@ -439,6 +440,7 @@ void gvir_config_domain_set_current_memory(GVirConfigDomain *domain,
gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(node),
"unit", "KiB",
NULL);
+ g_object_unref(G_OBJECT(node));
g_object_notify(G_OBJECT(domain), "current-memory");
}
--
1.8.1.4
11 years, 7 months
[libvirt] [libvirt-glib 1/4] gconfig: Add GVirConfigStoragePool getters
by Christophe Fergeau
---
libvirt-gconfig/libvirt-gconfig-storage-pool.c | 143 +++++++++++++++++++++++++
libvirt-gconfig/libvirt-gconfig-storage-pool.h | 8 ++
libvirt-gconfig/libvirt-gconfig.sym | 12 +++
3 files changed, 163 insertions(+)
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
index 4ad9fc1..b06c24c 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
@@ -74,6 +74,25 @@ GVirConfigStoragePool *gvir_config_storage_pool_new_from_xml(const gchar *xml,
return GVIR_CONFIG_STORAGE_POOL(object);
}
+/**
+ * gvir_config_storage_pool_get_pool_type:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the type of the pool.
+ *
+ * Returns: #Gname of @pool.
+ */
+GVirConfigStoragePoolType gvir_config_storage_pool_get_pool_type(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool),
+ GVIR_CONFIG_STORAGE_POOL_TYPE_DIR);
+
+ return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(pool),
+ NULL, "type",
+ GVIR_CONFIG_TYPE_STORAGE_POOL_TYPE,
+ GVIR_CONFIG_STORAGE_POOL_TYPE_DIR);
+}
+
void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
GVirConfigStoragePoolType type)
{
@@ -87,6 +106,22 @@ void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
}
/**
+ * gvir_config_storage_pool_get_name:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the name of the pool.
+ *
+ * Returns: name of @pool.
+ */
+const char *gvir_config_storage_pool_get_name(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool),
+ "name");
+}
+
+/**
* gvir_config_storage_pool_set_name:
* @name: (allow-none):
*/
@@ -100,6 +135,22 @@ void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
}
/**
+ * gvir_config_storage_pool_get_uuid:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the unique identifier for @pool.
+ *
+ * Returns: unique identifier for @pool.
+ */
+const char *gvir_config_storage_pool_get_uuid(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool),
+ "uuid");
+}
+
+/**
* gvir_config_storage_pool_set_uuid:
* @uuid: (allow-none):
*/
@@ -112,6 +163,22 @@ void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool,
"uuid", uuid);
}
+/**
+ * gvir_config_storage_pool_get_capacity:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the total storage capacity for the pool.
+ *
+ * Returns: total storage capacity in bytes.
+ */
+guint64 gvir_config_storage_pool_get_capacity(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+ return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+ "capacity");
+}
+
void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
guint64 capacity)
{
@@ -121,6 +188,22 @@ void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
"capacity", capacity);
}
+/**
+ * gvir_config_storage_pool_get_allocation:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the total storage allocation for the pool.
+ *
+ * Returns: total storage allocation in bytes.
+ */
+guint64 gvir_config_storage_pool_get_allocation(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+ return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+ "allocation");
+}
+
void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
guint64 allocation)
{
@@ -130,6 +213,22 @@ void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
"allocation", allocation);
}
+/**
+ * gvir_config_storage_pool_get_available:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the free space available for allocating new volumes in the pool.
+ *
+ * Returns: free space available in bytes.
+ */
+guint64 gvir_config_storage_pool_get_available(GVirConfigStoragePool *pool)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+ return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+ "available");
+}
+
void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
guint64 available)
{
@@ -140,6 +239,28 @@ void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
}
/**
+ * gvir_config_storage_pool_get_source:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the source for @pool
+ *
+ * Returns: (transfer full): a new #GVirConfigStoragePoolSource instance.
+ */
+GVirConfigStoragePoolSource *gvir_config_storage_pool_get_source(GVirConfigStoragePool *pool)
+{
+ GVirConfigObject *object;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+ object = gvir_config_object_get_child_with_type
+ (GVIR_CONFIG_OBJECT(pool),
+ "source",
+ GVIR_CONFIG_TYPE_STORAGE_POOL_SOURCE);
+
+ return GVIR_CONFIG_STORAGE_POOL_SOURCE(object);
+}
+
+/**
* gvir_config_storage_pool_set_source:
* @source: (allow-none):
*/
@@ -156,6 +277,28 @@ void gvir_config_storage_pool_set_source(GVirConfigStoragePool *pool,
}
/**
+ * gvir_config_storage_pool_get_target:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the target for @pool
+ *
+ * Returns: (transfer full): a new #GVirConfigStoragePoolTarget instance.
+ */
+GVirConfigStoragePoolTarget *gvir_config_storage_pool_get_target(GVirConfigStoragePool *pool)
+{
+ GVirConfigObject *object;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+ object = gvir_config_object_get_child_with_type
+ (GVIR_CONFIG_OBJECT(pool),
+ "target",
+ GVIR_CONFIG_TYPE_STORAGE_POOL_TARGET);
+
+ return GVIR_CONFIG_STORAGE_POOL_TARGET(object);
+}
+
+/**
* gvir_config_storage_pool_set_target:
* @target: (allow-none):
*/
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.h b/libvirt-gconfig/libvirt-gconfig-storage-pool.h
index 9005482..ac4141e 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.h
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.h
@@ -76,20 +76,28 @@ GVirConfigStoragePool *gvir_config_storage_pool_new(void);
GVirConfigStoragePool *gvir_config_storage_pool_new_from_xml(const gchar *xml,
GError **error);
+guint64 gvir_config_storage_pool_get_allocation(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
guint64 allocation);
+guint64 gvir_config_storage_pool_get_available(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
guint64 available);
+guint64 gvir_config_storage_pool_get_capacity(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
guint64 capacity);
+const char *gvir_config_storage_pool_get_name(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
const char *name);
+GVirConfigStoragePoolType gvir_config_storage_pool_get_pool_type(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
GVirConfigStoragePoolType type);
+GVirConfigStoragePoolSource *gvir_config_storage_pool_get_source(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_source(GVirConfigStoragePool *pool,
GVirConfigStoragePoolSource *source);
+GVirConfigStoragePoolTarget *gvir_config_storage_pool_get_target(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_target(GVirConfigStoragePool *pool,
GVirConfigStoragePoolTarget *target);
+const char *gvir_config_storage_pool_get_uuid(GVirConfigStoragePool *pool);
void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool,
const char *uuid);
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index a1b2cc1..93b2e33 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -512,4 +512,16 @@ LIBVIRT_GCONFIG_0.1.6 {
gvir_config_domain_graphics_spice_image_compression_get_type;
} LIBVIRT_GCONFIG_0.1.5;
+LIBVIRT_GCONFIG_0.1.7 {
+ global:
+ gvir_config_storage_pool_get_allocation;
+ gvir_config_storage_pool_get_available;
+ gvir_config_storage_pool_get_capacity;
+ gvir_config_storage_pool_get_name;
+ gvir_config_storage_pool_get_pool_type;
+ gvir_config_storage_pool_get_source;
+ gvir_config_storage_pool_get_target;
+ gvir_config_storage_pool_get_uuid;
+} LIBVIRT_GCONFIG_0.1.6;
+
# .... define new API here using predicted next version number ....
--
1.8.1.4
11 years, 7 months
[libvirt] [libvirt-glib] gconfig: Add calls to [gs]et_virt_type to domain tests
by Christophe Fergeau
Setting GVirConfigDomain::virt_type is required for a working
domain configuration, using it in the test programs will be helpful
if people are using this as a base when starting to use libvirt-gconfig
---
examples/config-demo.py | 1 +
libvirt-gconfig/tests/test-domain-create.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/examples/config-demo.py b/examples/config-demo.py
index 508bbc5..268c439 100644
--- a/examples/config-demo.py
+++ b/examples/config-demo.py
@@ -3,6 +3,7 @@
from gi.repository import LibvirtGConfig;
domain = LibvirtGConfig.Domain.new()
+domain.set_virt_type(LibvirtGConfig.DomainVirtType.KVM)
domain.set_name("foo")
domain.set_memory(1024*1024) # 1 GB
domain.set_vcpus(2)
diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c
index 20fedc5..e30f643 100644
--- a/libvirt-gconfig/tests/test-domain-create.c
+++ b/libvirt-gconfig/tests/test-domain-create.c
@@ -111,6 +111,9 @@ int main(int argc, char **argv)
domain = gvir_config_domain_new();
g_assert(domain != NULL);
+
+ gvir_config_domain_set_virt_type(domain, GVIR_CONFIG_DOMAIN_VIRT_KVM);
+ g_assert(gvir_config_domain_get_virt_type(domain) == GVIR_CONFIG_DOMAIN_VIRT_KVM);
gvir_config_domain_set_name(domain, "foo");
g_str_const_check(gvir_config_domain_get_name(domain), "foo");
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCHv2 0/4] Add domain modification impact flags to hot-management commands
by Peter Krempa
A respin of the series that changes some virsh commands to handle flags more
sanely. This version fixes comments by Martin, Laine and Eric.
This series omits already acked patches.
Peter Krempa (4):
virsh: Fix semantics of --config for "update-device" command
virsh-domain: Add --live, --config, --current logic to
cmdDetachInterface
virsh-domain: Add --live, --config, --current logic to cmdDetachDevice
virsh-domain: Add --live, --config, --current logic to cmdDetachDisk
tools/virsh-domain.c | 182 +++++++++++++++++++++++++++++++++++++--------------
tools/virsh.pod | 81 +++++++++++++++++------
2 files changed, 194 insertions(+), 69 deletions(-)
--
1.8.1.5
11 years, 7 months
[libvirt] [PATCH 0/3] Refactor formatting of MAC addresses and domif-getlink virsh command
by Peter Krempa
This series refactors libvirt XML code generator to create uniform
mac addresses with lowercase hex characters and refactors the domif-getlink
command to avoid a bug and too complex code.
Peter Krempa (3):
util: Change virMacAddrFormat to lowercase hex characters
conf: Use virMacAddrFormat while generating domain XML files
virsh-domain-monitor: Refactor cmdDomIfGetLink
src/conf/domain_conf.c | 7 +-
src/util/virmacaddr.c | 2 +-
tests/networkxml2xmlout/bandwidth-network.xml | 2 +-
.../networkxml2xmlout/dhcp6host-routed-network.xml | 2 +-
tests/networkxml2xmlout/empty-allow-ipv6.xml | 2 +-
tests/networkxml2xmlout/isolated-network.xml | 2 +-
tests/networkxml2xmlout/routed-network.xml | 2 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx | 4 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-5.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-esx-in-the-wild-6.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx | 4 +-
tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx | 2 +-
tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx | 2 +-
tools/virsh-domain-monitor.c | 100 ++++++++-------------
21 files changed, 62 insertions(+), 87 deletions(-)
--
1.8.1.5
11 years, 7 months