[libvirt] [PATCH v3 0/5] Active commit
by Eric Blake
I still don't have qemu capability detection working reliably,
but want to post this series right now so that it can be built
into a scratch build containing Peter's and my changes. (Or
put another way, I was testing what conflict resolutions are
required - patch 2/5 (virsh) and 5/5 (qemu_driver) has some
conflicts with Peter's addition of relative backing name; and
I think the resolutions were fairly simple).
These patches are tested on top of:
https://www.redhat.com/archives/libvir-list/2014-June/msg00492.html
I may still end up posting a v4 and/or pushing my series before
Peter's, once I get capability detection working the way I want.
Eric Blake (5):
virsh: improve blockcopy UI
virsh: expose new active commit controls
blockcommit: update error messages related to block jobs
blockcommit: track job type in xml
blockcommit: turn on active commit
docs/formatdomain.html.in | 20 +++---
docs/schemas/domaincommon.rng | 6 ++
src/conf/domain_conf.c | 26 ++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_driver.c | 56 ++++++++++++---
src/qemu/qemu_hotplug.c | 2 +-
src/qemu/qemu_process.c | 18 +++--
.../qemuxml2argv-disk-active-commit.xml | 37 ++++++++++
.../qemuxml2argvdata/qemuxml2argv-disk-mirror.xml | 4 +-
.../qemuxml2xmlout-disk-mirror-old.xml | 4 +-
tests/qemuxml2xmltest.c | 1 +
tools/virsh-domain.c | 83 +++++++++++++++++-----
tools/virsh.pod | 53 +++++++++-----
13 files changed, 242 insertions(+), 69 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml
--
1.9.3
10 years, 5 months
Re: [libvirt] [PATCH] libxl: fix domxml-to-native wrong output for qcow2 format
by Jim Fehlig
Bamvor Jian Zhang<bjzhang(a)suse.com> wrote:
> e.g. for these following disk configuration in libvirt.
> <disk type='file' device='disk'>
For Xen, using <driver name='qemu' .../> (which means qdisk) is only
supported by the libxl driver. The old xm/xend stack does not support qdisk.
> <driver name='qemu' type='qcow2'/>
> <source file='/var/lib/xen/images/001/disk0.qcow2'/>
> <target dev='hdc'/>
>
> without this patch, it will be
> "qemu:/var/lib/xen/images/001/disk0.qcow2,hdc,w"
Yeah, that won't work with xend or libxl :) .
> but it should be(if with this patch)
> "qcow2:/var/lib/xen/images/001/disk0.qcow2,hdc,w"
>
> Signed-off-by: Bamvor Jian Zhang <bjzhang(a)suse.com>
> ---
> src/xenxs/xen_xm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index b2db97d..29835b4 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1209,7 +1209,10 @@ xenFormatXMDisk(virConfValuePtr list,
> type = "aio";
> else
> type = virStorageFileFormatTypeToString(format);
> - virBufferAsprintf(&buf, "%s:", driver);
> + if (!STREQ(type, "qcow2"))
> + virBufferAsprintf(&buf, "%s:", driver);
> + else
> + virBufferAsprintf(&buf, "%s:", type);
But this only handles the specific case of <driver name='qemu' type='qcow2'/>.
With <driver name='qemu' type='raw'/>, I get
"qemu:/path/to/disk,hdc,w"
Unfortunately, this is a case where we are trying to use the xm config
parser to parse something that is xl-specific. With <driver name='qemu'.../>,
the corresponding xl disk config would look something like
disk = ['backendtype=qdisk,/var/lib/xen/images/001/disk0.qcow2,hdc,w']
With the type also specified, e.g. <driver name='qemu' type='qcow2'/>, the xl
disk config would be
disk = ['backendtype=qdisk,format=qcow2,/var/lib/xen/images/001/disk0.qcow2,hdc,w']
As I see it, the options are
1. start working on a xen-xl parser
2. map 'qemu' to 'tap'
We'll eventually need 1 anyhow. I haven't looked to see how much work that
would be. Certainly a lot of the xm parsing code could be used since xm
config is a subset of xl config.
Option 2 is really a no-op in the libxl stack, where qdisk is used in place
of tap anyhow. One could argue that mapping qemu to tap isn't too insane in
the xm/xend stack either, since much of the blktap userspace code was
originally based on qemu.
The below patch works for me. Can you give it a try? I'd like to hear wha
others think about taking the easy way out with option 2.
Regards,
Jim
>From 92c476cbe47009c43ebb4a3076a17347c8eea238 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig(a)suse.com>
Date: Thu, 12 Jun 2014 15:28:48 -0600
Subject: [PATCH] libxl: fix domxml-to-native with qemu disk driver
Disk config containing <driver name='qemu'.../> is converted to
the native config containg "qemu:/path/to/disk", which is not
understood by xm or xl.
This patch maps 'qemu' to 'tap'. In xl, tap is mapped to the qemu
backend (aka qdisk), making this change essentially a no-op. In
the xm stack, one could argue that mapping qemu to tap isn't too
insane, since much of the blktap userspace code was originally
based on qemu.
While at it, noticed that 'driver' wasn't being honored in
xenFormatXMDisk, so change the logic a bit to honor a
user-specified driver.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/xenxs/xen_xm.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index b2db97d..ebd525b 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1201,17 +1201,28 @@ xenFormatXMDisk(virConfValuePtr list,
int format = virDomainDiskGetFormat(disk);
const char *driver = virDomainDiskGetDriver(disk);
- if (src) {
- if (format) {
- const char *type;
+ /*
+ * In pre-libxl Xen, 'tap' provided the qemu driver functionality.
+ * In libxl Xen, qemu (aka qdisk) is in fact used. For backwards
+ * compatibility, tap == qdisk in libxl Xen, so it is safe to use
+ * 'tap' in libxl tool.
+ */
+ if (STREQ(driver, "qemu"))
+ driver = "tap";
- if (format == VIR_STORAGE_FILE_RAW)
- type = "aio";
- else
- type = virStorageFileFormatTypeToString(format);
+ if (src) {
+ if (driver) {
virBufferAsprintf(&buf, "%s:", driver);
- if (STREQ(driver, "tap"))
- virBufferAsprintf(&buf, "%s:", type);
+ if (format) {
+ const char *type;
+
+ if (format == VIR_STORAGE_FILE_RAW)
+ type = "aio";
+ else
+ type = virStorageFileFormatTypeToString(format);
+ if (STREQ(driver, "tap"))
+ virBufferAsprintf(&buf, "%s:", type);
+ }
} else {
switch (virDomainDiskGetType(disk)) {
case VIR_STORAGE_TYPE_FILE:
-- 1.8.4.5
10 years, 5 months
[libvirt] Qemu guest agent to install RPMs in guest VM from host machine
by Puneet Bakshi
Hi,
I want to be able to install RPM packages (available in host system at some
path) to the guest VM and want this facility to be available as a tool.
I am thinking of having a gemu guest agent (qemu-ga) running inside guest
VM. I did not find any available command ("virsh qemu-agent-command
<guest_vm> ...") which can do the same.
I am planning to implement a command in qemu guest agent, which I can
invoke from virsh like below.
"virsh qemu-agent-command vm_01 \
'{"execute":"guest-rpm-install", \
"arguments":{"path":"/usr/local/bin/ABC.rpm"}}
I am able to pass arguments from host to guest VM but how am I supposed to
pass the whole RPM image from host to guest (which the guest agent can
receive and install)?
Regards,
~Puneet
10 years, 5 months
[libvirt] [PATCH 0/2] Expose PCI Express capabilities
by Michal Privoznik
*** BLURB HERE ***
Michal Privoznik (2):
virpci: Introduce virPCIDeviceIsPCIExpress and friends
nodedev: Introduce <pci-express/> to PCI devices
docs/formatnode.html.in | 19 ++++
docs/schemas/nodedev.rng | 26 +++++
src/conf/node_device_conf.c | 123 ++++++++++++++++++++-
src/conf/node_device_conf.h | 31 +++++-
src/libvirt_private.syms | 3 +
src/node_device/node_device_udev.c | 31 ++++++
src/util/virpci.c | 81 +++++++++++++-
src/util/virpci.h | 8 ++
.../pci_8086_4238_pcie_wireless.xml | 26 +++++
tests/nodedevxml2xmltest.c | 1 +
10 files changed, 345 insertions(+), 4 deletions(-)
create mode 100644 tests/nodedevschemadata/pci_8086_4238_pcie_wireless.xml
--
2.0.0
10 years, 5 months
[libvirt] [PATCH] blockcommit: fix regression with explicit top argument
by Eric Blake
Commit f586965 accidentally changed the semantics of the
virDomainBlockCommit command; where it previously looked for
an explicit top argument from the top of the chain, it now
starts from the backing file of the top. Of course, until
we allow active commits, the only difference it makes is in
the quality of the error message, but with code for active
commit coming soon, we need to support an explicit mention
of the active layer.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Start looking
from top of chain.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ec72d9d..bf55f67 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15528,8 +15528,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (!top)
topSource = disk->src;
else if (virStorageFileParseChainIndex(disk->dst, top, &topIndex) < 0 ||
- !(topSource = virStorageFileChainLookup(disk->src,
- disk->src->backingStore,
+ !(topSource = virStorageFileChainLookup(disk->src, NULL,
top, topIndex,
&top_parent)))
goto endjob;
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] virNodeDevCapPCIDevParseXML: Initialize numa_node variable
by Michal Privoznik
With one of my recent patches (1c70277) libvirt's capable of
reporting NUMA node locality for PCI devices. The node ID is
stored in pci_dev.numa_node variable. However, since zero is
valid NUMA node ID, the default is -1 as it is in kernel too.
So, if the PCI device is not tied to any specific NUMA node, the
default is then NOT printed into XML. Therefore, when parsing
node device XML, the <node/> element is optional. But currently,
if it's not there, we must set sane default, otherwise after
parsing the in memory representation doesn't match the XML. We
are already doing this in other place: udevProcessPCI().
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/node_device_conf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 6153aa1..12e40e6 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1145,6 +1145,8 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
}
}
+ /* The default value is -1 since zero is valid NUMA node number */
+ data->pci_dev.numa_node = -1;
if (virNodeDevCapsDefParseIntOptional("number(./numa[1]/@node)", ctxt,
&data->pci_dev.numa_node, def,
_("invalid NUMA node ID supplied for '%s'")) < 0)
--
1.8.5.5
10 years, 5 months
[libvirt] [PATCHv4 0/4] virsh: Clean unsigned value parsing
by Peter Krempa
Jincheng Miao (1):
virsh: forbid negative vcpu argument to vcpupin
Peter Krempa (3):
virsh: Reject negative numbers in vshCommandOptUInt
virsh: Reject negative numbers in vshCommandOptUL
virsh: Reject negative numbers in vshCommandOptULongLong
tests/vcpupin | 29 ++++++++++-
tools/virsh-domain.c | 39 ++++++++-------
tools/virsh-volume.c | 8 +--
tools/virsh.c | 137 +++++++++++++++++++++++++++++++++++++++++----------
tools/virsh.h | 9 ++++
5 files changed, 172 insertions(+), 50 deletions(-)
--
1.9.3
10 years, 5 months
[libvirt] [PATCH 0/3] Resolve Coverity warnings
by John Ferlan
Resolve the "lower hanging fruit" Coverity issues from recent commits.
Still left outstanding is rework of virVBoxSnapshotConfAllChildren()
code and callers.
John Ferlan (3):
vbox_temp: Resolve Coverity warnings
vbox_snapshot_conf: Resolve Coverity warnings
libxl: Resolve Coverity warnings
src/libxl/libxl_migration.c | 6 ++----
src/vbox/vbox_snapshot_conf.c | 27 ++++++++++++++++++---------
src/vbox/vbox_tmpl.c | 10 +++++++++-
3 files changed, 29 insertions(+), 14 deletions(-)
--
1.9.3
10 years, 5 months
[libvirt] [PATCH] Fix crash when saving a domain with type none dac label
by Ján Tomko
qemuDomainGetImageIds did not check if there was a label
in the seclabel, thus crashing on
<seclabel type='none' model='dac'/>
---
src/qemu/qemu_domain.c | 3 ++-
src/qemu/qemu_driver.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 962698b..e40c5ec 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2409,7 +2409,8 @@ qemuDomainGetImageIds(virQEMUDriverConfigPtr cfg,
*gid = cfg->group;
}
- if (vm && (vmlabel = virDomainDefGetSecurityLabelDef(vm->def, "dac")))
+ if (vm && (vmlabel = virDomainDefGetSecurityLabelDef(vm->def, "dac")) &&
+ vmlabel->label)
virParseOwnershipIds(vmlabel->label, uid, gid);
if ((disklabel = virDomainDiskDefGetSecurityLabelDef(disk, "dac")) &&
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ec72d9d..e147d28 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2771,6 +2771,7 @@ qemuOpenFile(virQEMUDriverPtr driver,
/* TODO: Take imagelabel into account? */
if (vm &&
(seclabel = virDomainDefGetSecurityLabelDef(vm->def, "dac")) != NULL &&
+ seclabel->label != NULL &&
(virParseOwnershipIds(seclabel->label, &user, &group) < 0))
goto cleanup;
--
1.8.5.5
10 years, 5 months
[libvirt] [libvirt-glib PATCH v2] Add API to get security models from host capabilities
by Cédric Bosdonnat
---
Diff to v1:
* GVirConfigCapabilitiesSecmodel -> GVirConfigCapabilitiesHostSecModel
* Added gvir_config_capabilities_host_secmodel_get_doi
libvirt-gconfig/Makefile.am | 2 +
.../libvirt-gconfig-capabilities-host-secmodel.c | 62 +++++++++++++++++++
.../libvirt-gconfig-capabilities-host-secmodel.h | 69 ++++++++++++++++++++++
.../libvirt-gconfig-capabilities-host.c | 51 ++++++++++++++++
.../libvirt-gconfig-capabilities-host.h | 3 +
libvirt-gconfig/libvirt-gconfig.h | 1 +
libvirt-gconfig/libvirt-gconfig.sym | 6 ++
libvirt-gconfig/tests/test-capabilities-parse.c | 15 ++++-
libvirt-gconfig/tests/test-capabilities-parse.xml | 4 ++
9 files changed, 212 insertions(+), 1 deletion(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 83d521f..8a3ff0d 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -20,6 +20,7 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-capabilities-guest-arch.h \
libvirt-gconfig-capabilities-guest-domain.h \
libvirt-gconfig-capabilities-guest-feature.h \
+ libvirt-gconfig-capabilities-host-secmodel.h \
libvirt-gconfig-domain.h \
libvirt-gconfig-domain-address.h \
libvirt-gconfig-domain-address-pci.h \
@@ -107,6 +108,7 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-capabilities-guest-arch.c \
libvirt-gconfig-capabilities-guest-domain.c \
libvirt-gconfig-capabilities-guest-feature.c \
+ libvirt-gconfig-capabilities-host-secmodel.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-address.c \
libvirt-gconfig-domain-address-pci.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.c b/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.c
new file mode 100644
index 0000000..9cbb585
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.c
@@ -0,0 +1,62 @@
+/*
+ * libvirt-gconfig-capabilities-host-secmodel.c: libvirt security model capabilities
+ *
+ * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL, GVirConfigCapabilitiesHostSecModelPrivate))
+
+struct _GVirConfigCapabilitiesHostSecModelPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigCapabilitiesHostSecModel, gvir_config_capabilities_host_secmodel, GVIR_CONFIG_TYPE_OBJECT);
+
+static void gvir_config_capabilities_host_secmodel_class_init(GVirConfigCapabilitiesHostSecModelClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesHostSecModelPrivate));
+}
+
+static void gvir_config_capabilities_host_secmodel_init(GVirConfigCapabilitiesHostSecModel *secmodel)
+{
+ g_debug("Init GVirConfigCapabilitiesHostSecModel=%p", secmodel);
+
+ secmodel->priv = GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL_GET_PRIVATE(secmodel);
+}
+
+const gchar *
+gvir_config_capabilities_host_secmodel_get_model(GVirConfigCapabilitiesHostSecModel *secmodel)
+{
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(secmodel),
+ "model");
+}
+
+const gchar *
+gvir_config_capabilities_host_secmodel_get_doi(GVirConfigCapabilitiesHostSecModel *secmodel)
+{
+ return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(secmodel),
+ "doi");
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.h b/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.h
new file mode 100644
index 0000000..1606571
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.h
@@ -0,0 +1,69 @@
+/*
+ * libvirt-gconfig-capabilities-host-secmodel.h: libvirt security model capabilities
+ *
+ * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * 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, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+
+#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD)
+#error "Only <libvirt-gconfig/libvirt-gconfig.h> can be included directly."
+#endif
+
+#ifndef __LIBVIRT_GCONFIG_CAPABILITIES_HOST_SECMODEL_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_HOST_SECMODEL_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL (gvir_config_capabilities_host_secmodel_get_type ())
+#define GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL, GVirConfigCapabilitiesHostSecModel))
+#define GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL, GVirConfigCapabilitiesHostSecModelClass))
+#define GVIR_CONFIG_IS_CAPABILITIES_HOST_SECMODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL))
+#define GVIR_CONFIG_IS_CAPABILITIES_HOST_SECMODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL))
+#define GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL, GVirConfigCapabilitiesHostSecModelClass))
+
+typedef struct _GVirConfigCapabilitiesHostSecModel GVirConfigCapabilitiesHostSecModel;
+typedef struct _GVirConfigCapabilitiesHostSecModelPrivate GVirConfigCapabilitiesHostSecModelPrivate;
+typedef struct _GVirConfigCapabilitiesHostSecModelClass GVirConfigCapabilitiesHostSecModelClass;
+
+struct _GVirConfigCapabilitiesHostSecModel
+{
+ GVirConfigObject parent;
+
+ GVirConfigCapabilitiesHostSecModelPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigCapabilitiesHostSecModelClass
+{
+ GVirConfigObjectClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_capabilities_host_secmodel_get_type(void);
+
+const gchar *
+gvir_config_capabilities_host_secmodel_get_model(GVirConfigCapabilitiesHostSecModel *secmodel);
+
+const gchar *
+gvir_config_capabilities_host_secmodel_get_doi(GVirConfigCapabilitiesHostSecModel *secmodel);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_HOST_SECMODEL_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host.c b/libvirt-gconfig/libvirt-gconfig-capabilities-host.c
index 6a15206..07719d0 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities-host.c
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host.c
@@ -77,3 +77,54 @@ gvir_config_capabilities_host_get_cpu(GVirConfigCapabilitiesHost *host)
return GVIR_CONFIG_CAPABILITIES_CPU(object);
}
+
+struct GetSecModelData {
+ GVirConfigXmlDoc *doc;
+ const gchar *schema;
+ GList *secmodels;
+ GType type;
+};
+
+static gboolean add_secmodel(xmlNodePtr node, gpointer opaque)
+{
+ struct GetSecModelData* data = (struct GetSecModelData*)opaque;
+ GVirConfigObject *secmodel;
+
+ if (g_strcmp0((const gchar *)node->name, "secmodel") != 0)
+ return TRUE;
+
+ secmodel = gvir_config_object_new_from_tree
+ (data->type,
+ data->doc,
+ data->schema,
+ node);
+ if (secmodel != NULL)
+ data->secmodels = g_list_append(data->secmodels, secmodel);
+ else
+ g_debug("Failed to parse %s node", node->name);
+
+ return TRUE;
+}
+
+GList *
+gvir_config_capabilities_host_get_secmodels(GVirConfigCapabilitiesHost *host)
+{
+ struct GetSecModelData data;
+
+ g_return_val_if_fail(GVIR_CONFIG_IS_CAPABILITIES_HOST(host), NULL);
+
+ data.schema = gvir_config_object_get_schema(GVIR_CONFIG_OBJECT(host));
+ g_object_get(G_OBJECT(host), "doc", &data.doc, NULL);
+ g_return_val_if_fail(data.doc != NULL, NULL);
+ data.secmodels = NULL;
+ data.type = GVIR_CONFIG_TYPE_CAPABILITIES_HOST_SECMODEL;
+
+ gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(host),
+ NULL,
+ add_secmodel,
+ &data);
+
+ g_clear_object(&data.doc);
+
+ return data.secmodels;
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-host.h b/libvirt-gconfig/libvirt-gconfig-capabilities-host.h
index 34fbb4f..c3c7951 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities-host.h
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-host.h
@@ -67,6 +67,9 @@ gvir_config_capabilities_host_get_uuid(GVirConfigCapabilitiesHost *host);
GVirConfigCapabilitiesCpu *
gvir_config_capabilities_host_get_cpu(GVirConfigCapabilitiesHost *host);
+GList *
+gvir_config_capabilities_host_get_secmodels(GVirConfigCapabilitiesHost *host);
+
G_END_DECLS
#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_HOST_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 1582109..b494154 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -37,6 +37,7 @@
#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-domain.h>
#include <libvirt-gconfig/libvirt-gconfig-capabilities-guest-feature.h>
#include <libvirt-gconfig/libvirt-gconfig-capabilities-host.h>
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-host-secmodel.h>
#include <libvirt-gconfig/libvirt-gconfig-domain.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-address.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-address-pci.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index fc68050..0d33fdb 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -689,6 +689,12 @@ global:
LIBVIRT_GCONFIG_0.1.9 {
global:
+ gvir_config_capabilities_host_get_secmodels;
+
+ gvir_config_capabilities_host_secmodel_get_doi;
+ gvir_config_capabilities_host_secmodel_get_model;
+ gvir_config_capabilities_host_secmodel_get_type;
+
gvir_config_domain_chardev_source_spiceport_get_channel;
gvir_config_domain_chardev_source_spiceport_get_type;
gvir_config_domain_chardev_source_spiceport_new;
diff --git a/libvirt-gconfig/tests/test-capabilities-parse.c b/libvirt-gconfig/tests/test-capabilities-parse.c
index 8ede160..fdf41b6 100644
--- a/libvirt-gconfig/tests/test-capabilities-parse.c
+++ b/libvirt-gconfig/tests/test-capabilities-parse.c
@@ -35,7 +35,7 @@ static void verify_host_caps(GVirConfigCapabilitiesHost *host_caps)
{
GVirConfigCapabilitiesCpu *cpu_caps;
GVirConfigCapabilitiesCpuTopology *topology;
- GList *features, *iter;
+ GList *features, *iter, *secmodels;
const char *str;
g_assert(host_caps != NULL);
@@ -60,6 +60,19 @@ static void verify_host_caps(GVirConfigCapabilitiesHost *host_caps)
g_assert(gvir_config_capabilities_cpu_topology_get_threads(topology) == 2);
g_object_unref(G_OBJECT(topology));
g_object_unref(G_OBJECT(cpu_caps));
+
+ secmodels = gvir_config_capabilities_host_get_secmodels(host_caps);
+ g_assert(g_list_length(secmodels) == 2);
+ for (iter = secmodels; iter != NULL; iter = iter->next) {
+ GVirConfigCapabilitiesHostSecModel *secmodel;
+
+ g_assert(iter->data != NULL);
+ secmodel = GVIR_CONFIG_CAPABILITIES_HOST_SECMODEL(iter->data);
+ g_assert(gvir_config_capabilities_host_secmodel_get_model(secmodel) != NULL);
+ g_assert(gvir_config_capabilities_host_secmodel_get_doi(secmodel) != NULL);
+ g_object_unref(G_OBJECT(iter->data));
+ }
+ g_list_free(secmodels);
}
static void verify_guest_caps(GVirConfigCapabilitiesGuest *guest_caps)
diff --git a/libvirt-gconfig/tests/test-capabilities-parse.xml b/libvirt-gconfig/tests/test-capabilities-parse.xml
index 9c76085..477e3fe 100644
--- a/libvirt-gconfig/tests/test-capabilities-parse.xml
+++ b/libvirt-gconfig/tests/test-capabilities-parse.xml
@@ -40,6 +40,10 @@
<model>selinux</model>
<doi>0</doi>
</secmodel>
+ <secmodel>
+ <model>apparmor</model>
+ <doi>0</doi>
+ </secmodel>
</host>
<guest>
--
1.8.4.5
10 years, 5 months