From: Alexander Larsson <alexl(a)redhat.com>
This handles <smartcard> devices.
---
libvirt-gconfig/Makefile.am | 8 ++
.../libvirt-gconfig-domain-device-private.h | 3 +
libvirt-gconfig/libvirt-gconfig-domain-device.c | 2 +-
...rt-gconfig-domain-smartcard-host-certificates.c | 124 +++++++++++++++++++++
...rt-gconfig-domain-smartcard-host-certificates.h | 74 ++++++++++++
.../libvirt-gconfig-domain-smartcard-host.c | 75 +++++++++++++
.../libvirt-gconfig-domain-smartcard-host.h | 67 +++++++++++
.../libvirt-gconfig-domain-smartcard-passthrough.c | 116 +++++++++++++++++++
.../libvirt-gconfig-domain-smartcard-passthrough.h | 70 ++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-smartcard.c | 90 +++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-smartcard.h | 67 +++++++++++
libvirt-gconfig/libvirt-gconfig.h | 4 +
libvirt-gconfig/libvirt-gconfig.sym | 21 ++++
13 files changed, 720 insertions(+), 1 deletion(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.h
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard.c
create mode 100644 libvirt-gconfig/libvirt-gconfig-domain-smartcard.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 507e733..6b3b2cb 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -54,6 +54,10 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-domain-redirdev.h \
libvirt-gconfig-domain-seclabel.h \
libvirt-gconfig-domain-serial.h \
+ libvirt-gconfig-domain-smartcard.h \
+ libvirt-gconfig-domain-smartcard-host.h \
+ libvirt-gconfig-domain-smartcard-host-certificates.h \
+ libvirt-gconfig-domain-smartcard-passthrough.h \
libvirt-gconfig-domain-snapshot.h \
libvirt-gconfig-domain-sound.h \
libvirt-gconfig-domain-timer.h \
@@ -127,6 +131,10 @@ GCONFIG_SOURCE_FILES = \
libvirt-gconfig-domain-redirdev.c \
libvirt-gconfig-domain-seclabel.c \
libvirt-gconfig-domain-serial.c \
+ libvirt-gconfig-domain-smartcard.c \
+ libvirt-gconfig-domain-smartcard-host.c \
+ libvirt-gconfig-domain-smartcard-host-certificates.c \
+ libvirt-gconfig-domain-smartcard-passthrough.c \
libvirt-gconfig-domain-snapshot.c \
libvirt-gconfig-domain-sound.c \
libvirt-gconfig-domain-timer.c \
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
index 3ec83c3..d8ac47f 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
@@ -45,6 +45,9 @@ gvir_config_domain_graphics_new_from_tree(GVirConfigXmlDoc *doc,
GVirConfigDomainDevice *
gvir_config_domain_interface_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree);
+GVirConfigDomainDevice *
+gvir_config_domain_smartcard_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device.c
b/libvirt-gconfig/libvirt-gconfig-domain-device.c
index 60d6bcc..e3dbe8d 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device.c
@@ -72,7 +72,7 @@ gvir_config_domain_device_new_from_tree(GVirConfigXmlDoc *doc,
} else if (xmlStrEqual(tree->name, (xmlChar*)"redirdev")) {
type = GVIR_CONFIG_TYPE_DOMAIN_REDIRDEV;
} else if (xmlStrEqual(tree->name, (xmlChar*)"smartcard")) {
- goto unimplemented;
+ return gvir_config_domain_smartcard_new_from_tree(doc, tree);
} else if (xmlStrEqual(tree->name, (xmlChar*)"interface")) {
return gvir_config_domain_interface_new_from_tree(doc, tree);
} else if (xmlStrEqual(tree->name, (xmlChar*)"input")) {
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.c
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.c
new file mode 100644
index 0000000..c013be7
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.c
@@ -0,0 +1,124 @@
+/*
+ * libvirt-gconfig-domain-smartcard-host-certificates.c: libvirt domain smartcard
host-certificates configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_GET_PRIVATE(obj)
\
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
GVirConfigDomainSmartcardHostCertificatesPrivate))
+
+struct _GVirConfigDomainSmartcardHostCertificatesPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainSmartcardHostCertificates,
gvir_config_domain_smartcard_host_certificates, GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD);
+
+
+static void
gvir_config_domain_smartcard_host_certificates_class_init(GVirConfigDomainSmartcardHostCertificatesClass
*klass)
+{
+ g_type_class_add_private(klass,
sizeof(GVirConfigDomainSmartcardHostCertificatesPrivate));
+}
+
+
+static void
gvir_config_domain_smartcard_host_certificates_init(GVirConfigDomainSmartcardHostCertificates
*smartcard)
+{
+ g_debug("Init GVirConfigDomainSmartcardHostCertificates=%p", smartcard);
+
+ smartcard->priv =
GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_GET_PRIVATE(smartcard);
+}
+
+
+GVirConfigDomainSmartcardHostCertificates
*gvir_config_domain_smartcard_host_certificates_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
+ "smartcard", NULL);
+ gvir_config_object_set_attribute(object, "mode",
"host-certificates", NULL);
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES(object);
+}
+
+GVirConfigDomainSmartcardHostCertificates
*gvir_config_domain_smartcard_host_certificates_new_from_xml(const gchar *xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object =
gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
+ "smartcard", NULL, xml, error);
+ if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "mode"),
"host-certificates") != 0) {
+ g_object_unref(G_OBJECT(object));
+ return NULL;
+ }
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES(object);
+}
+
+/**
+ * gvir_config_domain_smartcard_host_certificates_set_database:
+ * @path: (allow-none):
+ */
+void
+gvir_config_domain_smartcard_host_certificates_set_database
(GVirConfigDomainSmartcardHostCertificates *smartcard,
+ const char *path)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST_CERTIFICATES(smartcard));
+
+ gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(smartcard),
+ "database", path);
+}
+
+/**
+ * gvir_config_domain_smartcard_host_certificates_set_certificates:
+ * @cert1: (allow-none):
+ * @cert2: (allow-none):
+ * @cert3: (allow-none):
+ */
+void
+gvir_config_domain_smartcard_host_certificates_set_certificates
(GVirConfigDomainSmartcardHostCertificates *smartcard,
+ const char *cert1,
+ const char *cert2,
+ const char *cert3)
+{
+ GVirConfigObject *child;
+
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST_CERTIFICATES(smartcard));
+
+ gvir_config_object_delete_children(GVIR_CONFIG_OBJECT(smartcard),
+ "certificate", NULL);
+
+ if (cert1 == NULL)
+ return;
+
+ child = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(smartcard),
"certificate");
+ gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(smartcard), NULL, cert1);
+ g_object_unref(G_OBJECT(child));
+
+ child = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(smartcard),
"certificate");
+ gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(smartcard), NULL, cert2);
+ g_object_unref(G_OBJECT(child));
+
+ child = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(smartcard),
"certificate");
+ gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(smartcard), NULL, cert3);
+ g_object_unref(G_OBJECT(child));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.h
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.h
new file mode 100644
index 0000000..3d370e3
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.h
@@ -0,0 +1,74 @@
+/*
+ * libvirt-gconfig-domain-smartcard-host-certificates.h: libvirt domain smartcard
host-certificates configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.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_DOMAIN_SMARTCARD_HOST_CERTIFICATES_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES
(gvir_config_domain_smartcard_host_certificates_get_type ())
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
GVirConfigDomainSmartcardHostCertificates))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_CLASS(klass)
(G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
GVirConfigDomainSmartcardHostCertificatesClass))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST_CERTIFICATES(obj)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST_CERTIFICATES_CLASS(klass)
(G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_GET_CLASS(obj)
(G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES,
GVirConfigDomainSmartcardHostCertificatesClass))
+
+typedef struct _GVirConfigDomainSmartcardHostCertificates
GVirConfigDomainSmartcardHostCertificates;
+typedef struct _GVirConfigDomainSmartcardHostCertificatesPrivate
GVirConfigDomainSmartcardHostCertificatesPrivate;
+typedef struct _GVirConfigDomainSmartcardHostCertificatesClass
GVirConfigDomainSmartcardHostCertificatesClass;
+
+struct _GVirConfigDomainSmartcardHostCertificates
+{
+ GVirConfigDomainSmartcard parent;
+
+ GVirConfigDomainSmartcardHostCertificatesPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainSmartcardHostCertificatesClass
+{
+ GVirConfigDomainSmartcardClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_smartcard_host_certificates_get_type(void);
+
+GVirConfigDomainSmartcardHostCertificates
*gvir_config_domain_smartcard_host_certificates_new(void);
+GVirConfigDomainSmartcardHostCertificates
*gvir_config_domain_smartcard_host_certificates_new_from_xml(const gchar *xml,
+ GError **error);
+
+void gvir_config_domain_smartcard_host_certificates_set_database
(GVirConfigDomainSmartcardHostCertificates *smartcard,
+ const char *path);
+void gvir_config_domain_smartcard_host_certificates_set_certificates
(GVirConfigDomainSmartcardHostCertificates *smartcard,
+ const char *cert1,
+ const char *cert2,
+ const char *cert3);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_HOST_CERTIFICATES_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.c
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.c
new file mode 100644
index 0000000..035c291
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.c
@@ -0,0 +1,75 @@
+/*
+ * libvirt-gconfig-domain-smartcard-host.c: libvirt domain smartcard host configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST,
GVirConfigDomainSmartcardHostPrivate))
+
+struct _GVirConfigDomainSmartcardHostPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainSmartcardHost, gvir_config_domain_smartcard_host,
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD);
+
+
+static void
gvir_config_domain_smartcard_host_class_init(GVirConfigDomainSmartcardHostClass *klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigDomainSmartcardHostPrivate));
+}
+
+
+static void gvir_config_domain_smartcard_host_init(GVirConfigDomainSmartcardHost
*smartcard)
+{
+ g_debug("Init GVirConfigDomainSmartcardHost=%p", smartcard);
+
+ smartcard->priv = GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_GET_PRIVATE(smartcard);
+}
+
+
+GVirConfigDomainSmartcardHost *gvir_config_domain_smartcard_host_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST,
+ "smartcard", NULL);
+ gvir_config_object_set_attribute(object, "mode", "host", NULL);
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_HOST(object);
+}
+
+GVirConfigDomainSmartcardHost *gvir_config_domain_smartcard_host_new_from_xml(const gchar
*xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST,
+ "smartcard", NULL, xml, error);
+ if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "mode"),
"host") != 0) {
+ g_object_unref(G_OBJECT(object));
+ return NULL;
+ }
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_HOST(object);
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.h
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.h
new file mode 100644
index 0000000..f1dcba2
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.h
@@ -0,0 +1,67 @@
+/*
+ * libvirt-gconfig-domain-smartcard-host.h: libvirt domain smartcard host configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.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_DOMAIN_SMARTCARD_HOST_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_HOST_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST
(gvir_config_domain_smartcard_host_get_type ())
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST(obj) (G_TYPE_CHECK_INSTANCE_CAST
((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST, GVirConfigDomainSmartcardHost))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST, GVirConfigDomainSmartcardHostClass))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_HOST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_HOST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS
((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST, GVirConfigDomainSmartcardHostClass))
+
+typedef struct _GVirConfigDomainSmartcardHost GVirConfigDomainSmartcardHost;
+typedef struct _GVirConfigDomainSmartcardHostPrivate
GVirConfigDomainSmartcardHostPrivate;
+typedef struct _GVirConfigDomainSmartcardHostClass GVirConfigDomainSmartcardHostClass;
+
+struct _GVirConfigDomainSmartcardHost
+{
+ GVirConfigDomainSmartcard parent;
+
+ GVirConfigDomainSmartcardHostPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainSmartcardHostClass
+{
+ GVirConfigDomainSmartcardClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_smartcard_host_get_type(void);
+
+GVirConfigDomainSmartcardHost *gvir_config_domain_smartcard_host_new(void);
+GVirConfigDomainSmartcardHost *gvir_config_domain_smartcard_host_new_from_xml(const gchar
*xml,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_HOST_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.c
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.c
new file mode 100644
index 0000000..10fd460
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.c
@@ -0,0 +1,116 @@
+/*
+ * libvirt-gconfig-domain-smartcard-passthrough.c: libvirt domain smartcard passthrough
configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_GET_PRIVATE(obj)
\
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
GVirConfigDomainSmartcardPassthroughPrivate))
+
+struct _GVirConfigDomainSmartcardPassthroughPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_TYPE(GVirConfigDomainSmartcardPassthrough,
gvir_config_domain_smartcard_passthrough, GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD);
+
+
+static void
gvir_config_domain_smartcard_passthrough_class_init(GVirConfigDomainSmartcardPassthroughClass
*klass)
+{
+ g_type_class_add_private(klass,
sizeof(GVirConfigDomainSmartcardPassthroughPrivate));
+}
+
+
+static void
gvir_config_domain_smartcard_passthrough_init(GVirConfigDomainSmartcardPassthrough
*smartcard)
+{
+ g_debug("Init GVirConfigDomainSmartcardPassthrough=%p", smartcard);
+
+ smartcard->priv =
GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_GET_PRIVATE(smartcard);
+}
+
+
+GVirConfigDomainSmartcardPassthrough *gvir_config_domain_smartcard_passthrough_new(void)
+{
+ GVirConfigObject *object;
+
+ object = gvir_config_object_new(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
+ "smartcard", NULL);
+ gvir_config_object_set_attribute(object, "mode", "passthrough",
NULL);
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH(object);
+}
+
+GVirConfigDomainSmartcardPassthrough
*gvir_config_domain_smartcard_passthrough_new_from_xml(const gchar *xml,
+ GError **error)
+{
+ GVirConfigObject *object;
+
+ object =
gvir_config_object_new_from_xml(GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
+ "smartcard", NULL, xml, error);
+ if (g_strcmp0(gvir_config_object_get_attribute(object, NULL, "mode"),
"passthrough") != 0) {
+ g_object_unref(G_OBJECT(object));
+ return NULL;
+ }
+ return GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH(object);
+}
+
+
+static void prepend_prop(xmlNodePtr node, xmlAttrPtr prop)
+{
+ if (node->properties == NULL) {
+ node->properties = prop;
+ } else {
+ prop->next = node->properties;
+ node->properties->prev = prop;
+ node->properties = prop;
+ }
+}
+
+void
+gvir_config_domain_smartcard_passthrough_set_source(GVirConfigDomainSmartcardPassthrough
*smartcard,
+ GVirConfigDomainChardevSource *source)
+{
+ xmlNodePtr smartcard_node;
+ xmlNodePtr source_node;
+ xmlNodePtr child;
+ xmlAttrPtr attr;
+
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SMARTCARD_PASSTHROUGH(smartcard));
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE(source));
+
+ smartcard_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(smartcard));
+ source_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(source));
+
+ g_return_if_fail((smartcard_node != NULL) && (source_node != NULL));
+
+ for (child = source_node->children; child != NULL; child = child->next) {
+ xmlUnlinkNode(child);
+ xmlAddChild(smartcard_node, child);
+ }
+
+ for (attr = source_node->properties; attr != NULL; attr = attr->next) {
+ xmlAttrPtr new_attr;
+ new_attr = xmlCopyProp(smartcard_node, attr);
+ prepend_prop(smartcard_node, new_attr);
+ }
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.h
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.h
new file mode 100644
index 0000000..c2bd50c
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.h
@@ -0,0 +1,70 @@
+/*
+ * libvirt-gconfig-domain-smartcard-passthrough.h: libvirt domain smartcard passthrough
configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.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_DOMAIN_SMARTCARD_PASSTHROUGH_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH
(gvir_config_domain_smartcard_passthrough_get_type ())
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
GVirConfigDomainSmartcardPassthrough))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST
((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
GVirConfigDomainSmartcardPassthroughClass))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_PASSTHROUGH(obj)
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_PASSTHROUGH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE
((klass), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_GET_CLASS(obj)
(G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH,
GVirConfigDomainSmartcardPassthroughClass))
+
+typedef struct _GVirConfigDomainSmartcardPassthrough
GVirConfigDomainSmartcardPassthrough;
+typedef struct _GVirConfigDomainSmartcardPassthroughPrivate
GVirConfigDomainSmartcardPassthroughPrivate;
+typedef struct _GVirConfigDomainSmartcardPassthroughClass
GVirConfigDomainSmartcardPassthroughClass;
+
+struct _GVirConfigDomainSmartcardPassthrough
+{
+ GVirConfigDomainSmartcard parent;
+
+ GVirConfigDomainSmartcardPassthroughPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainSmartcardPassthroughClass
+{
+ GVirConfigDomainSmartcardClass parent_class;
+
+ gpointer padding[20];
+};
+
+GType gvir_config_domain_smartcard_passthrough_get_type(void);
+
+GVirConfigDomainSmartcardPassthrough
*gvir_config_domain_smartcard_passthrough_new(void);
+GVirConfigDomainSmartcardPassthrough
*gvir_config_domain_smartcard_passthrough_new_from_xml(const gchar *xml,
+ GError **error);
+void
gvir_config_domain_smartcard_passthrough_set_source(GVirConfigDomainSmartcardPassthrough
*smartcard,
+ GVirConfigDomainChardevSource *source);
+
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_PASSTHROUGH_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard.c
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard.c
new file mode 100644
index 0000000..73ea867
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard.c
@@ -0,0 +1,90 @@
+/*
+ * libvirt-gconfig-domain-smartcard.c: libvirt domain smartcard configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include "libvirt-gconfig/libvirt-gconfig.h"
+#include "libvirt-gconfig/libvirt-gconfig-private.h"
+
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD,
GVirConfigDomainSmartcardPrivate))
+
+struct _GVirConfigDomainSmartcardPrivate
+{
+ gboolean unused;
+};
+
+G_DEFINE_ABSTRACT_TYPE(GVirConfigDomainSmartcard, gvir_config_domain_smartcard,
GVIR_CONFIG_TYPE_DOMAIN_DEVICE);
+
+
+static void gvir_config_domain_smartcard_class_init(GVirConfigDomainSmartcardClass
*klass)
+{
+ g_type_class_add_private(klass, sizeof(GVirConfigDomainSmartcardPrivate));
+}
+
+
+static void gvir_config_domain_smartcard_init(GVirConfigDomainSmartcard *smartcard)
+{
+ g_debug("Init GVirConfigDomainSmartcard=%p", smartcard);
+
+ smartcard->priv = GVIR_CONFIG_DOMAIN_SMARTCARD_GET_PRIVATE(smartcard);
+}
+
+/**
+ * gvir_config_domain_smartcard_set_address:
+ * @address: (allow-none):
+ */
+void gvir_config_domain_smartcard_set_address(GVirConfigDomainRedirdev *redirdev,
+ GVirConfigDomainAddress *address)
+{
+ g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_REDIRDEV(redirdev));
+ g_return_if_fail(address == NULL || GVIR_CONFIG_IS_DOMAIN_ADDRESS(address));
+
+ gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(redirdev),
+ "address",
+ GVIR_CONFIG_OBJECT(address));
+}
+
+G_GNUC_INTERNAL GVirConfigDomainDevice *
+gvir_config_domain_smartcard_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree)
+{
+ const char *mode;
+ GType gtype;
+
+ mode = gvir_config_xml_get_attribute_content(tree, "mode");
+ if (mode == NULL)
+ return NULL;
+
+ if (g_str_equal(mode, "host")) {
+ gtype = GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST;
+ } else if (g_str_equal(mode, "host-certificates")) {
+ gtype = GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_HOST_CERTIFICATES;
+ } else if (g_str_equal(mode, "passthrough")) {
+ gtype = GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD_PASSTHROUGH;
+ } else {
+ g_debug("Unknown domain smartcard node: %s", mode);
+ return NULL;
+ }
+
+ return GVIR_CONFIG_DOMAIN_DEVICE(gvir_config_object_new_from_tree(gtype, doc, NULL,
tree));
+}
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-smartcard.h
b/libvirt-gconfig/libvirt-gconfig-domain-smartcard.h
new file mode 100644
index 0000000..5136b02
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-domain-smartcard.h
@@ -0,0 +1,67 @@
+/*
+ * libvirt-gconfig-domain-smartcard.h: libvirt domain smartcard configuration
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Larsson <alexl(a)redhat.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_DOMAIN_SMARTCARD_H__
+#define __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_H__
+
+G_BEGIN_DECLS
+
+#define GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD
(gvir_config_domain_smartcard_get_type ())
+#define GVIR_CONFIG_DOMAIN_SMARTCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD, GVirConfigDomainSmartcard))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD, GVirConfigDomainSmartcardClass))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD))
+#define GVIR_CONFIG_IS_DOMAIN_SMARTCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD))
+#define GVIR_CONFIG_DOMAIN_SMARTCARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GVIR_CONFIG_TYPE_DOMAIN_SMARTCARD, GVirConfigDomainSmartcardClass))
+
+typedef struct _GVirConfigDomainSmartcard GVirConfigDomainSmartcard;
+typedef struct _GVirConfigDomainSmartcardPrivate GVirConfigDomainSmartcardPrivate;
+typedef struct _GVirConfigDomainSmartcardClass GVirConfigDomainSmartcardClass;
+
+struct _GVirConfigDomainSmartcard
+{
+ GVirConfigDomainDevice parent;
+
+ GVirConfigDomainSmartcardPrivate *priv;
+
+ /* Do not add fields to this struct */
+};
+
+struct _GVirConfigDomainSmartcardClass
+{
+ GVirConfigDomainDeviceClass parent_class;
+
+ gpointer padding[20];
+};
+
+
+GType gvir_config_domain_smartcard_get_type(void);
+
+void gvir_config_domain_smartcard_set_address(GVirConfigDomainRedirdev *redirdev,
+ GVirConfigDomainAddress *address);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_DOMAIN_SMARTCARD_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h
index 0428259..9feaba2 100644
--- a/libvirt-gconfig/libvirt-gconfig.h
+++ b/libvirt-gconfig/libvirt-gconfig.h
@@ -71,6 +71,10 @@
#include <libvirt-gconfig/libvirt-gconfig-domain-redirdev.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-seclabel.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-serial.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-smartcard.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-smartcard-host.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-smartcard-host-certificates.h>
+#include <libvirt-gconfig/libvirt-gconfig-domain-smartcard-passthrough.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-snapshot.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-sound.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-timer.h>
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 622e0f2..d9cff90 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -483,4 +483,25 @@ LIBVIRT_GCONFIG_0.1.4 {
gvir_config_domain_set_power_management;
} LIBVIRT_GCONFIG_0.1.3;
+LIBVIRT_GCONFIG_0.1.5 {
+ global:
+ gvir_config_domain_smartcard_get_type;
+ gvir_config_domain_smartcard_set_address;
+
+ gvir_config_domain_smartcard_host_get_type;
+ gvir_config_domain_smartcard_host_new;
+ gvir_config_domain_smartcard_host_new_from_xml;
+
+ gvir_config_domain_smartcard_host_certificates_get_type;
+ gvir_config_domain_smartcard_host_certificates_new;
+ gvir_config_domain_smartcard_host_certificates_new_from_xml;
+ gvir_config_domain_smartcard_host_certificates_set_database;
+ gvir_config_domain_smartcard_host_certificates_set_certificates;
+
+ gvir_config_domain_smartcard_passthrough_get_type;
+ gvir_config_domain_smartcard_passthrough_new;
+ gvir_config_domain_smartcard_passthrough_new_from_xml;
+ gvir_config_domain_smartcard_passthrough_set_source;
+} LIBVIRT_GCONFIG_0.1.4;
+
# .... define new API here using predicted next version number ....
--
1.8.0.1