[libvirt] [libvirt-designer][PATCH 0/6] Another functional extension

and couple of fixes for clean RPM build. Michal Privoznik (6): Implement resources setting Create basic documentation domain.c: Document @error on public APIs spec: Remove unused rules Create manpage for virtxml spec: Cleanup for rpmlint .gitignore | 17 ++++ Makefile.am | 2 +- configure.ac | 1 + docs/Makefile.am | 42 ++++++++++ docs/libvirt-designer-docs.xml | 27 ++++++ examples/Makefile.am | 11 +++ examples/virtxml.c | 23 +++++ examples/virtxml.pod | 121 ++++++++++++++++++++++++++++ libvirt-designer.spec.in | 31 ++----- libvirt-designer/libvirt-designer-domain.c | 95 ++++++++++++++++++++++ libvirt-designer/libvirt-designer-domain.h | 10 +++ libvirt-designer/libvirt-designer.sym | 2 + 12 files changed, 358 insertions(+), 24 deletions(-) create mode 100644 docs/Makefile.am create mode 100644 docs/libvirt-designer-docs.xml create mode 100644 examples/virtxml.pod -- 1.7.8.6

Users can choose between minimum and recommended values for VCPU count and amount of RAM. Moreover, recommended values should inherit defaults from the minimum. --- examples/virtxml.c | 23 +++++++ libvirt-designer/libvirt-designer-domain.c | 91 ++++++++++++++++++++++++++++ libvirt-designer/libvirt-designer-domain.h | 10 +++ libvirt-designer/libvirt-designer.sym | 2 + 4 files changed, 126 insertions(+), 0 deletions(-) diff --git a/examples/virtxml.c b/examples/virtxml.c index 623ff60..c582d0b 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -491,6 +491,8 @@ main(int argc, char *argv[]) static char *platform_str = NULL; static char *arch_str = NULL; static char *connect_uri = NULL; + static char *resources_str = NULL; + GVirDesignerDomainResources resources; GOptionContext *context; static GOptionEntry entries[] = @@ -511,6 +513,8 @@ main(int argc, char *argv[]) "add disk to domain with PATH being source and FORMAT its format", "PATH[,FORMAT]"}, {"interface", 'i', 0, G_OPTION_ARG_CALLBACK, add_iface_str, "add interface with NETWORK source. Possible ARGs: mac, link={up,down}", "NETWORK[,ARG=VAL]"}, + {"resources", 'r', 0, G_OPTION_ARG_STRING, &resources_str, + "Set minimal or recommended values for cpu count and RAM amount", "{minimal|recommended}"}, {NULL} }; @@ -567,6 +571,25 @@ main(int argc, char *argv[]) CHECK_ERROR; } + if (resources_str) { + if (g_str_equal(resources_str, "minimal") || + g_str_equal(resources_str, "min")) + resources = GVIR_DESIGNER_DOMAIN_RESOURCES_MINIMAL; + else if (g_str_equal(resources_str, "recommended") || + g_str_equal(resources_str, "rec")) + resources = GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED; + else { + print_error("Unknown value '%s' for resources", resources_str); + goto cleanup; + } + gvir_designer_domain_setup_resources(domain, resources, &error); + CHECK_ERROR; + } else { + gvir_designer_domain_setup_resources(domain, + GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED, + NULL); + } + g_list_foreach(disk_str_list, add_disk, domain); g_list_foreach(iface_str_list, add_iface, domain); diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c index 194fdf5..1f734de 100644 --- a/libvirt-designer/libvirt-designer-domain.c +++ b/libvirt-designer/libvirt-designer-domain.c @@ -1033,3 +1033,94 @@ gvir_designer_domain_add_interface_network(GVirDesignerDomain *design, return ret; } + + +static void +gvir_designer_domain_get_resources(OsinfoResourcesList *res_list, + const gchar *design_arch, + gint *design_n_cpus, + gint64 *design_ram) +{ + GList *elem_list, *elem_iterator; + + if (!res_list) + return; + + elem_list = osinfo_list_get_elements(OSINFO_LIST(res_list)); + for (elem_iterator = elem_list; elem_iterator; elem_iterator = elem_iterator->next) { + OsinfoResources *res = OSINFO_RESOURCES(elem_iterator->data); + const char *arch = osinfo_resources_get_architecture(res); + gint n_cpus = -1; + gint64 ram = -1; + + if (g_str_equal(arch, "all") || + g_str_equal(arch, design_arch)) { + n_cpus = osinfo_resources_get_n_cpus(res); + ram = osinfo_resources_get_ram(res); + if (n_cpus > 0) { + *design_n_cpus = n_cpus; + } + if (ram > 0) { + /* libosinfo returns RAM in B, libvirt-gconfig takes it in KB */ + *design_ram = ram / 1024; + } + break; + } + } +} + + +/** + * gvir_designer_domain_setup_resources: + * @design: (transfer none): the domain designer instance + * @req: (transfer none): requirements to set + * + * Set minimal or recommended resources on @design. + * + * Returns: (transfer none): TRUE when successfully set, FALSE otherwise. + */ +gboolean gvir_designer_domain_setup_resources(GVirDesignerDomain *design, + GVirDesignerDomainResources req, + GError **error) +{ + g_return_val_if_fail(GVIR_DESIGNER_IS_DOMAIN(design), FALSE); + gboolean ret = FALSE; + OsinfoResourcesList *res_list_min = NULL, *res_list_rec = NULL; + GVirConfigDomainOs *os = gvir_config_domain_get_os(design->priv->config); + const gchar *design_arch = os ? gvir_config_domain_os_get_arch(os) : ""; + gint n_cpus = -1; + gint64 ram = -1; + + /* If user request recommended settings those may just override + * only a few settings when compared to minimal. So we must implement + * inheritance here. */ + res_list_min = osinfo_os_get_minimum_resources(design->priv->os); + res_list_rec = osinfo_os_get_recommended_resources(design->priv->os); + if (req ==GVIR_DESIGNER_DOMAIN_RESOURCES_MINIMAL) { + gvir_designer_domain_get_resources(res_list_min, design_arch, + &n_cpus, &ram); + } else if (req == GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED) { + gvir_designer_domain_get_resources(res_list_min, design_arch, + &n_cpus, &ram); + gvir_designer_domain_get_resources(res_list_rec, design_arch, + &n_cpus, &ram); + } else { + g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0, + "Unknown resources argument: '%d'", req); + goto cleanup; + } + + if ((n_cpus <= 0) && (ram <= 0)) { + g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0, + "Unable to find resources in libosinfo database"); + goto cleanup; + } + + if (n_cpus > 0) + gvir_config_domain_set_vcpus(design->priv->config, n_cpus); + if (ram > 0) + gvir_config_domain_set_memory(design->priv->config, ram); + +cleanup: + return ret; +} diff --git a/libvirt-designer/libvirt-designer-domain.h b/libvirt-designer/libvirt-designer-domain.h index 5097393..7c837e0 100644 --- a/libvirt-designer/libvirt-designer-domain.h +++ b/libvirt-designer/libvirt-designer-domain.h @@ -39,6 +39,11 @@ G_BEGIN_DECLS #define GVIR_DESIGNER_IS_DOMAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_DESIGNER_TYPE_DOMAIN)) #define GVIR_DESIGNER_DOMAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_DESIGNER_TYPE_DOMAIN, GVirDesignerDomainClass)) +typedef enum { + GVIR_DESIGNER_DOMAIN_RESOURCES_MINIMAL, + GVIR_DESIGNER_DOMAIN_RESOURCES_RECOMMENDED, +} GVirDesignerDomainResources; + typedef struct _GVirDesignerDomain GVirDesignerDomain; typedef struct _GVirDesignerDomainPrivate GVirDesignerDomainPrivate; typedef struct _GVirDesignerDomainClass GVirDesignerDomainClass; @@ -104,6 +109,11 @@ GVirConfigDomainDisk *gvir_designer_domain_add_disk_device(GVirDesignerDomain *d GVirConfigDomainInterface *gvir_designer_domain_add_interface_network(GVirDesignerDomain *design, const char *network, GError **error); + +gboolean gvir_designer_domain_setup_resources(GVirDesignerDomain *design, + GVirDesignerDomainResources req, + GError **error); + G_END_DECLS #endif /* __LIBVIRT_DESIGNER_DOMAIN_H__ */ diff --git a/libvirt-designer/libvirt-designer.sym b/libvirt-designer/libvirt-designer.sym index 317a07b..79db09f 100644 --- a/libvirt-designer/libvirt-designer.sym +++ b/libvirt-designer/libvirt-designer.sym @@ -13,6 +13,8 @@ LIBVIRT_DESIGNER_0.0.1 { gvir_designer_domain_add_disk_file; gvir_designer_domain_add_disk_device; gvir_designer_domain_add_interface_network; + gvir_designer_domain_setup_resources; + gvir_designer_domain_resources_get_type; gvir_designer_domain_setup_machine; gvir_designer_domain_setup_machine_full; -- 1.7.8.6

In fact, it's only bare skeleton for gtkdoc --- .gitignore | 16 +++++++++++++++ Makefile.am | 2 +- configure.ac | 1 + docs/Makefile.am | 42 ++++++++++++++++++++++++++++++++++++++++ docs/libvirt-designer-docs.xml | 27 +++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 1 deletions(-) create mode 100644 docs/Makefile.am create mode 100644 docs/libvirt-designer-docs.xml diff --git a/.gitignore b/.gitignore index d570af8..4272672 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,19 @@ Makefile.in /m4/ltversion.m4 /m4/lt~obsolete.m4 /stamp-h1 +docs/xml/ +docs/html/ +docs/*.stamp +docs/*-decl-list.txt +docs/*-decl.txt +docs/*-overrides.txt +docs/*-sections.txt +docs/*-undeclared.txt +docs/*-undocumented.txt +docs/*-unused.txt +docs/*.args +docs/*.hierarchy +docs/*.interfaces +docs/*.prerequisites +docs/*.signals +docs/*.types diff --git a/Makefile.am b/Makefile.am index ab06626..f5bcc47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = libvirt-designer examples +SUBDIRS = libvirt-designer examples docs ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index eb9c681..f082498 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,7 @@ AC_OUTPUT(Makefile libvirt-designer/Makefile libvirt-designer.spec libvirt-designer-1.0.pc + docs/Makefile examples/Makefile) AC_MSG_NOTICE([]) diff --git a/docs/Makefile.am b/docs/Makefile.am new file mode 100644 index 0000000..d52bf52 --- /dev/null +++ b/docs/Makefile.am @@ -0,0 +1,42 @@ +DOC_MODULE=libvirt-designer + +DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml + +DOC_SOURCE_DIR=$(top_srcdir)/libvirt-designer + +SCANGOBJ_OPTIONS= + +SCAN_OPTIONS=--rebuild-sections --rebuild-types + +MKDB_OPTIONS=--sgml-mode --output-format=xml + +MKTMPL_OPTIONS= + +MKHTML_OPTIONS= + +FIXXREF_OPTIONS= + +HFILE_GLOB=$(top_srcdir)/libvirt-designer/*.h +CFILE_GLOB=$(top_srcdir)/libvirt-designer/*.c + +IGNORE_HFILES= + +HTML_IMAGES= + +content_files= + +expand_content_files= + +GTKDOC_CFLAGS= \ + $(GOBJECT2_CFLAGS) \ + $(LIBOSINFO_CFLAGS) \ + $(LIBVIRT_GCONFIG_CFLAGS) \ + $(LIBVIRT_GOBJECT_CFLAGS) +GTKDOC_LIBS = \ + $(GOBJECT2_LIBS) \ + $(LIBOSINFO_LIBS) \ + $(LIBVIRT_GCONFIG_LIBS) \ + $(LIBVIRT_GOBJECT_LIBS) \ + $(top_builddir)/libvirt-designer/libvirt-designer-1.0.la + +include $(top_srcdir)/gtk-doc.make diff --git a/docs/libvirt-designer-docs.xml b/docs/libvirt-designer-docs.xml new file mode 100644 index 0000000..2a151ab --- /dev/null +++ b/docs/libvirt-designer-docs.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" +[ + <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> +]> +<book id="index"> + <bookinfo> + <title>Libvirt-designer Reference Manual</title> + </bookinfo> + + <chapter> + <title>Libvirt-designer</title> + <xi:include href="xml/libvirt-designer-domain.xml"/> + <xi:include href="xml/libvirt-designer-main.xml"/> + </chapter> + <chapter id="object-tree"> + <title>Object Hierarchy</title> + <xi:include href="xml/tree_index.sgml"/> + </chapter> + <index id="api-index-full"> + <title>API Index</title> + <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include> + </index> + + <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> +</book> -- 1.7.8.6

On Tue, Sep 18, 2012 at 05:52:25PM +0200, Michal Privoznik wrote:
In fact, it's only bare skeleton for gtkdoc
This seems to be missing a call to GTK_DOC_CHECK in configure.ac, and potentially DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes in Makefile.am Christophe

On 19.09.2012 17:48, Christophe Fergeau wrote:
On Tue, Sep 18, 2012 at 05:52:25PM +0200, Michal Privoznik wrote:
In fact, it's only bare skeleton for gtkdoc
This seems to be missing a call to GTK_DOC_CHECK in configure.ac, and potentially DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes in Makefile.am
GTK_DOC_CHECK is part of LIBVIRT_DESIGNER_GTK_MISC m4 macro (m4/virt-gtk-misc.m4) and already is in DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes *is* in Makefile.am. I am considering this as ACK then if there are no other objections. Michal
Christophe
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Hi, On Thu, Sep 20, 2012 at 04:18:47PM +0200, Michal Privoznik wrote:
On 19.09.2012 17:48, Christophe Fergeau wrote:
On Tue, Sep 18, 2012 at 05:52:25PM +0200, Michal Privoznik wrote:
In fact, it's only bare skeleton for gtkdoc
This seems to be missing a call to GTK_DOC_CHECK in configure.ac, and potentially DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes in Makefile.am
GTK_DOC_CHECK is part of LIBVIRT_DESIGNER_GTK_MISC m4 macro (m4/virt-gtk-misc.m4) and already is in DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc=yes *is* in Makefile.am.
I am considering this as ACK then if there are no other objections.
Ah, I wrongly assumed that there was no gtk-doc stuff in-tree, this was a wrong assumption ;) ACK from me, with the minor nit that using docs/reference/ for the API doc seems more typical than having it straight into doc. But that can be adjusted the day we have more doc to put there, so not much point in doing that now. Christophe

to prevent warnings when generating the documentation. --- libvirt-designer/libvirt-designer-domain.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c index 1f734de..8423357 100644 --- a/libvirt-designer/libvirt-designer-domain.c +++ b/libvirt-designer/libvirt-designer-domain.c @@ -901,6 +901,7 @@ error: * @design: (transfer none): the domain designer instance * @filepath: (transfer none): the path to a file * @format: (transfer none): disk format + * @error: return location for a #GError, or NULL * * Add a new disk to the domain. * @@ -930,6 +931,7 @@ GVirConfigDomainDisk *gvir_designer_domain_add_disk_file(GVirDesignerDomain *des * gvir_designer_domain_add_disk_device: * @design: (transfer none): the domain designer instance * @devpath: (transfer none): path to the device + * @error: return location for a #GError, or NULL * * Add given device as a new disk to the domain designer instance. * @@ -1011,6 +1013,7 @@ cleanup: * gvir_designer_domain_add_interface_network: * @design: (transfer none): the domain designer instance * @network: (transfer none): network name + * @error: return location for a #GError, or NULL * * Add new network interface card into @design. The interface is * of 'network' type with @network used as the source network. @@ -1074,6 +1077,7 @@ gvir_designer_domain_get_resources(OsinfoResourcesList *res_list, * gvir_designer_domain_setup_resources: * @design: (transfer none): the domain designer instance * @req: (transfer none): requirements to set + * @error: return location for a #GError, or NULL * * Set minimal or recommended resources on @design. * -- 1.7.8.6

and update to reflect virtxml binary. --- libvirt-designer.spec.in | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-) diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in index b4107ea..1d5f4b6 100644 --- a/libvirt-designer.spec.in +++ b/libvirt-designer.spec.in @@ -21,6 +21,7 @@ URL: http://libvirt.org/ Source0: http://libvirt.org/%{name}/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libvirt-gconfig-devel >= 0.0.9 +BuildRequires: libvirt-gobject-devel >= 0.1.3 %if %{with_introspection} BuildRequires: gobject-introspection-devel %endif @@ -64,7 +65,6 @@ headers %install rm -rf $RPM_BUILD_ROOT -chmod a-x examples/*.py examples/*.pl examples/*.js %__make install DESTDIR=$RPM_BUILD_ROOT rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt-designer-1.0.a rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt-designer-1.0.la @@ -77,23 +77,11 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) -%{_sysconfdir}/bash_completion.d/virt-designer-service-bash-completion.sh -%config(noreplace) %{_sysconfdir}/cron.daily/virt-designer-service.logrotate -%dir %{_sysconfdir}/libvirt-designer/services -%{_bindir}/virt-designer -%{_bindir}/virt-designer-service -%{_mandir}/man1/virt-designer.1* -%{_mandir}/man1/virt-designer-service.1* +%{_bindir}/virtxml %files libs %defattr(-,root,root,-) %doc README COPYING AUTHORS ChangeLog NEWS -%dir %{_sysconfdir}/libvirt-designer -%dir %{_sysconfdir}/libvirt-designer/scratch -%config %{_sysconfdir}/libvirt-designer/scratch/README -%{_libexecdir}/libvirt-designer-init-common -%{_libexecdir}/libvirt-designer-init-lxc -%{_libexecdir}/libvirt-designer-init-qemu %{_libdir}/libvirt-designer-1.0.so.* %if %{with_introspection} %{_libdir}/girepository-1.0/LibvirtDesigner-1.0.typelib @@ -101,10 +89,6 @@ rm -rf $RPM_BUILD_ROOT %files devel %defattr(-,root,root,-) -%doc examples/virt-designer.pl -%doc examples/virt-designer.py -%doc examples/virt-designer.js -%doc examples/virt-designer-mkinitrd.py %{_libdir}/libvirt-designer-1.0.so %{_libdir}/pkgconfig/libvirt-designer-1.0.pc %dir %{_includedir}/libvirt-designer-1.0 @@ -114,6 +98,6 @@ rm -rf $RPM_BUILD_ROOT %if %{with_introspection} %{_datadir}/gir-1.0/LibvirtDesigner-1.0.gir %endif -%{_datadir}/gtk-doc/html/Libvirt-designer +%{_datadir}/gtk-doc/html/libvirt-designer %changelog -- 1.7.8.6

--- .gitignore | 1 + examples/Makefile.am | 11 ++++ examples/virtxml.pod | 121 ++++++++++++++++++++++++++++++++++++++++++++++ libvirt-designer.spec.in | 1 + 4 files changed, 134 insertions(+), 0 deletions(-) create mode 100644 examples/virtxml.pod diff --git a/.gitignore b/.gitignore index 4272672..03b75ce 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ docs/*.interfaces docs/*.prerequisites docs/*.signals docs/*.types +examples/*.1 diff --git a/examples/Makefile.am b/examples/Makefile.am index 32549a0..de0603b 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -18,6 +18,17 @@ virtxml_LDFLAGS = \ $(LIBVIRT_GCONFIG_LIBS) \ $(LIBVIRT_GOBJECT_LIBS) +POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)" + +virtxml.1: virtxml.pod + $(AM_V_GEN)$(POD2MAN) $< $@ + if WITH_EXAMPLES bin_PROGRAMS = virtxml + +EXTRA_DIST = virtxml.pod + +man1_MANS = virtxml.1 + +CLEANFILES = $(man1_MANS) endif diff --git a/examples/virtxml.pod b/examples/virtxml.pod new file mode 100644 index 0000000..80a4edf --- /dev/null +++ b/examples/virtxml.pod @@ -0,0 +1,121 @@ +=head1 NAME + +virtxml - Generate domain XML + +=head1 SYNOPSIS + +B<virrtxml> [I<OPTION>]... + +=head1 DESCRIPTION + +The B<virtxml> is a command line tool for generating XML documents for +libvirt domains. However, it cooperates with libosinfo database to guess +the correct combination of attributes (e.g. disk driver, NIC model). + +The B<virtxml> does not feed libvirt with generated XML though. For now, +it's a proof of concept. + +=head1 OPTIONS + +The basic structure of arguments passed to B<virtxml> is: + + virtxml [-c URI] [OPTION] [OPTION] ... + +However, arguments have no pre-defined order so users can type them +in any order they like. + +=head2 General Options + +=over 2 + +=item -c URI, --connect=URI + +The libvirt connection URI which is used for querying capabilities of the +host. + +=item --list-os + +List IDs of operating systems known to libosinfo + +=item --list-platform + +List IDs of platforms known to libosinfo + +=item -o OS, --os=OS + +Specify operating system that will be ran on the domain. I<OS> is an ID +which can be obtained via B<--list-os>. + +=item -p PLATFORM, --platform=PLATFORM + +Specify platform (hypervisor) under which will the domain run. I<PLATFORM> +is and ID which can be obtained via I<--list-platform>. + +=item -a ARCH, --architecture=ARCH + +Set domain's architecture + +=item -d PATH[,FORMAT] --disk=PATH[,FORMAT] + +Add I<PATH> as a disk to the domain. To specify its format (e.g. raw, +qcow2, phy) use I<FORMAT>. + +=item -i NETWORK[,ARG=VAL] + +Add an interface of type network with I<NETWORK> source. Moreover, some +other configuration knobs can be set (possible I<ARG>s): I<mac>, +I<link>={up|down} + +=item -r RESOURCE, --resources=RESOURCES + +Set I<minimal> or I<recommended> resources on the domain XML. By default, +the I<recommended> is used. + +=back + +Usually, both B<--os> and B<--platform> are required as they are needed to +make the right decision on driver, model, ... when adding a new device. +However, when adding a disk which is installation medium (e.g. a CD-ROM or +DVD), B<virtxml> tries to guess the OS. Something similar is done with +platform. Usually, the platform is guessed from connection URI. + +=head1 EXAMPLES + +Domain with Fedora 17 from locally stored ISO and one NIC with mac +00:11:22:33:44:55 and link set down: + + # virtxml -d Fedora-17-x86_64-Live-KDE.iso \ + -i default,mac=00:11:22:33:44:55,link=down + +To add multiple devices just use appropriate argument multiple times: + + # virtxml -d /tmp/Fedora-17-x86_64-Live-KDE.iso,raw \ + -d /var/lib/libvirt/images/f17.img,qcow2 \ + -i default,mac=00:11:22:33:44:55,link=down \ + -i blue_network \ + -r minimal + +=head1 AUTHORS + +Written by Michal Privoznik, Daniel P. Berrange and team of other +contributors. See the AUTHORS file in the source distribution for the +complete list of credits. + +=head1 BUGS + +Report any bugs discovered to the libvirt community via the mailing +list C<http://libvirt.org/contact.html> or bug tracker C<http://libvirt.org/bugs.html>. +Alternatively report bugs to your software distributor / vendor. + +=head1 COPYRIGHT + +Copyright (C) 2012 Red Hat, Inc. and various contributors. +This is free software. You may redistribute copies of it under the terms of +the GNU General Public License C<http://www.gnu.org/licenses/gpl.html>. There +is NO WARRANTY, to the extent permitted by law. + +=head1 SEE ALSO + +C<virsh(1)>, C<virt-clone(1)>, C<virt-manager(1)>, the project website C<http://virt-manager.org> + +=cut diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in index 1d5f4b6..ede7185 100644 --- a/libvirt-designer.spec.in +++ b/libvirt-designer.spec.in @@ -78,6 +78,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %{_bindir}/virtxml +%{_mandir}/man1/virtxml.1* %files libs %defattr(-,root,root,-) -- 1.7.8.6

On Tue, Sep 18, 2012 at 05:52:28PM +0200, Michal Privoznik wrote:
--- .gitignore | 1 + examples/Makefile.am | 11 ++++ examples/virtxml.pod | 121 ++++++++++++++++++++++++++++++++++++++++++++++
It's weird to have it in examples/ while one of the commit adds a docs/ directory. I'd move the gtkdoc to docs/reference, and the manpage to docs/.
diff --git a/examples/virtxml.pod b/examples/virtxml.pod new file mode 100644 index 0000000..80a4edf --- /dev/null +++ b/examples/virtxml.pod @@ -0,0 +1,121 @@ +=head1 NAME + +virtxml - Generate domain XML + +=head1 SYNOPSIS + +B<virrtxml> [I<OPTION>]...
virtxml
+ +=head1 DESCRIPTION + +The B<virtxml> is a command line tool for generating XML documents for
I'd drop the 'The'
+libvirt domains. However, it cooperates with libosinfo database to guess +the correct combination of attributes (e.g. disk driver, NIC model). + +The B<virtxml> does not feed libvirt with generated XML though. For now, +it's a proof of concept.
ditto
+ +=head1 OPTIONS + +The basic structure of arguments passed to B<virtxml> is: + + virtxml [-c URI] [OPTION] [OPTION] ... + +However, arguments have no pre-defined order so users can type them +in any order they like. + +=head2 General Options + +=over 2 + +=item -c URI, --connect=URI + +The libvirt connection URI which is used for querying capabilities of the +host. + +=item --list-os + +List IDs of operating systems known to libosinfo + +=item --list-platform + +List IDs of platforms known to libosinfo + +=item -o OS, --os=OS + +Specify operating system that will be ran on the domain. I<OS> is an ID +which can be obtained via B<--list-os>.
"that will be run" I think
+ +=item -p PLATFORM, --platform=PLATFORM + +Specify platform (hypervisor) under which will the domain run. I<PLATFORM> +is and ID which can be obtained via I<--list-platform>.
under which the domain will run
+ +=item -a ARCH, --architecture=ARCH + +Set domain's architecture + +=item -d PATH[,FORMAT] --disk=PATH[,FORMAT] + +Add I<PATH> as a disk to the domain. To specify its format (e.g. raw, +qcow2, phy) use I<FORMAT>. + +=item -i NETWORK[,ARG=VAL] + +Add an interface of type network with I<NETWORK> source. Moreover, some +other configuration knobs can be set (possible I<ARG>s): I<mac>, +I<link>={up|down} + +=item -r RESOURCE, --resources=RESOURCES + +Set I<minimal> or I<recommended> resources on the domain XML. By default, +the I<recommended> is used. + +=back + +Usually, both B<--os> and B<--platform> are required as they are needed to +make the right decision on driver, model, ... when adding a new device. +However, when adding a disk which is installation medium (e.g. a CD-ROM or
an installation medium
+DVD), B<virtxml> tries to guess the OS. Something similar is done with +platform. Usually, the platform is guessed from connection URI. +
"from the connection URI" maybe (?) Christophe

On Wed, Sep 19, 2012 at 06:06:44PM +0200, Christophe Fergeau wrote:
On Tue, Sep 18, 2012 at 05:52:28PM +0200, Michal Privoznik wrote:
--- .gitignore | 1 + examples/Makefile.am | 11 ++++ examples/virtxml.pod | 121 ++++++++++++++++++++++++++++++++++++++++++++++
It's weird to have it in examples/ while one of the commit adds a docs/ directory. I'd move the gtkdoc to docs/reference, and the manpage to docs/.
Actually, I'd not add any virtxml.pod file at all - just embed the POD docs in the actual virtxml.c source file, inside a C comment. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

In order to prevent warnings and errors from rpmlint we need to cleanup spec file: capitalization summary and spell check (s/runtime/run-time/) --- libvirt-designer.spec.in | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in index ede7185..a8fefff 100644 --- a/libvirt-designer.spec.in +++ b/libvirt-designer.spec.in @@ -14,7 +14,7 @@ Name: @PACKAGE@ Version: @VERSION@ Release: 1%{?dist}%{?extra_release} -Summary: libvirt configuration designer +Summary: Libvirt configuration designer Group: Development/Tools License: LGPLv2+ URL: http://libvirt.org/ @@ -28,11 +28,11 @@ BuildRequires: gobject-introspection-devel %package libs Group: Development/Libraries -Summary: libvirt configuration designer libraries +Summary: Libvirt configuration designer libraries %package devel Group: Development/Libraries -Summary: libvirt configuration designer development headers +Summary: Libvirt configuration designer development headers Requires: %{name}-libs = %{version}-%{release} Requires: libvirt-gconfig-devel >= 0.0.9 @@ -41,7 +41,7 @@ This package provides the libvirt configuration designer command line tools. %description libs -This package provides the libvirt configuration designer runtime +This package provides the libvirt configuration designer run-time libraries. %description devel -- 1.7.8.6

--- diff to v1: -move content from virtxml.pod to virtxml.c -wording and spelling as pointed out by Christophe .gitignore | 1 + examples/Makefile.am | 9 +++ examples/virtxml.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ libvirt-designer.spec.in | 1 + 4 files changed, 138 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 4272672..03b75ce 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ docs/*.interfaces docs/*.prerequisites docs/*.signals docs/*.types +examples/*.1 diff --git a/examples/Makefile.am b/examples/Makefile.am index 32549a0..ae2667e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -18,6 +18,15 @@ virtxml_LDFLAGS = \ $(LIBVIRT_GCONFIG_LIBS) \ $(LIBVIRT_GOBJECT_LIBS) +POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)" + +%.1: %.c Makefile + $(AM_V_GEN)$(POD2MAN) $< $@ + if WITH_EXAMPLES bin_PROGRAMS = virtxml + +man1_MANS = virtxml.1 + +CLEANFILES = $(man1_MANS) endif diff --git a/examples/virtxml.c b/examples/virtxml.c index c582d0b..2918ee0 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -606,3 +606,130 @@ cleanup: gvir_connection_close(conn); return ret; } + +/* +=pod + + +=head1 NAME + +virtxml - Generate domain XML + +=head1 SYNOPSIS + +B<virtxml> [I<OPTION>]... + +=head1 DESCRIPTION + +B<virtxml> is a command line tool for generating XML documents for +libvirt domains. However, it cooperates with libosinfo database to guess +the correct combination of attributes (e.g. disk driver, NIC model). + +B<virtxml> does not feed libvirt with generated XML though. For now, +it's a proof of concept. + +=head1 OPTIONS + +The basic structure of arguments passed to B<virtxml> is: + + virtxml [-c URI] [OPTION] [OPTION] ... + +However, arguments have no pre-defined order so users can type them +in any order they like. + +=head2 General Options + +=over 2 + +=item -c URI, --connect=URI + +The libvirt connection URI which is used for querying capabilities of the +host. + +=item --list-os + +List IDs of operating systems known to libosinfo + +=item --list-platform + +List IDs of platforms known to libosinfo + +=item -o OS, --os=OS + +Specify operating system that will be run on the domain. I<OS> is an ID +which can be obtained via B<--list-os>. + +=item -p PLATFORM, --platform=PLATFORM + +Specify platform (hypervisor) under which the domain will run. I<PLATFORM> +is and ID which can be obtained via I<--list-platform>. + +=item -a ARCH, --architecture=ARCH + +Set domain's architecture + +=item -d PATH[,FORMAT] --disk=PATH[,FORMAT] + +Add I<PATH> as a disk to the domain. To specify its format (e.g. raw, +qcow2, phy) use I<FORMAT>. + +=item -i NETWORK[,ARG=VAL] + +Add an interface of type network with I<NETWORK> source. Moreover, some +other configuration knobs can be set (possible I<ARG>s): I<mac>, +I<link>={up|down} + +=item -r RESOURCE, --resources=RESOURCES + +Set I<minimal> or I<recommended> resources on the domain XML. By default, +the I<recommended> is used. + +=back + +Usually, both B<--os> and B<--platform> are required as they are needed to +make the right decision on driver, model, ... when adding a new device. +However, when adding a disk which is an installation medium (e.g. a CD-ROM or +DVD), B<virtxml> tries to guess the OS. Something similar is done with +platform. Usually, the platform is guessed from the connection URI. + +=head1 EXAMPLES + +Domain with Fedora 17 from locally stored ISO and one NIC with mac +00:11:22:33:44:55 and link set down: + + # virtxml -d Fedora-17-x86_64-Live-KDE.iso \ + -i default,mac=00:11:22:33:44:55,link=down + +To add multiple devices just use appropriate argument multiple times: + + # virtxml -d /tmp/Fedora-17-x86_64-Live-KDE.iso,raw \ + -d /var/lib/libvirt/images/f17.img,qcow2 \ + -i default,mac=00:11:22:33:44:55,link=down \ + -i blue_network \ + -r minimal + +=head1 AUTHORS + +Written by Michal Privoznik, Daniel P. Berrange and team of other +contributors. See the AUTHORS file in the source distribution for the +complete list of credits. + +=head1 BUGS + +Report any bugs discovered to the libvirt community via the mailing +list C<http://libvirt.org/contact.html> or bug tracker C<http://libvirt.org/bugs.html>. +Alternatively report bugs to your software distributor / vendor. + +=head1 COPYRIGHT + +Copyright (C) 2012 Red Hat, Inc. and various contributors. +This is free software. You may redistribute copies of it under the terms of +the GNU General Public License C<http://www.gnu.org/licenses/gpl.html>. There +is NO WARRANTY, to the extent permitted by law. + +=head1 SEE ALSO + +C<virsh(1)>, C<virt-clone(1)>, C<virt-manager(1)>, the project website C<http://virt-manager.org> + +=cut +*/ diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in index 1d5f4b6..ede7185 100644 --- a/libvirt-designer.spec.in +++ b/libvirt-designer.spec.in @@ -78,6 +78,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %{_bindir}/virtxml +%{_mandir}/man1/virtxml.1* %files libs %defattr(-,root,root,-) -- 1.7.8.6

ACK Christophe On Thu, Sep 20, 2012 at 04:18:34PM +0200, Michal Privoznik wrote:
---
diff to v1: -move content from virtxml.pod to virtxml.c -wording and spelling as pointed out by Christophe
.gitignore | 1 + examples/Makefile.am | 9 +++ examples/virtxml.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++ libvirt-designer.spec.in | 1 + 4 files changed, 138 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore index 4272672..03b75ce 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,4 @@ docs/*.interfaces docs/*.prerequisites docs/*.signals docs/*.types +examples/*.1 diff --git a/examples/Makefile.am b/examples/Makefile.am index 32549a0..ae2667e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -18,6 +18,15 @@ virtxml_LDFLAGS = \ $(LIBVIRT_GCONFIG_LIBS) \ $(LIBVIRT_GOBJECT_LIBS)
+POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)" + +%.1: %.c Makefile + $(AM_V_GEN)$(POD2MAN) $< $@ + if WITH_EXAMPLES bin_PROGRAMS = virtxml + +man1_MANS = virtxml.1 + +CLEANFILES = $(man1_MANS) endif diff --git a/examples/virtxml.c b/examples/virtxml.c index c582d0b..2918ee0 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -606,3 +606,130 @@ cleanup: gvir_connection_close(conn); return ret; } + +/* +=pod + + +=head1 NAME + +virtxml - Generate domain XML + +=head1 SYNOPSIS + +B<virtxml> [I<OPTION>]... + +=head1 DESCRIPTION + +B<virtxml> is a command line tool for generating XML documents for +libvirt domains. However, it cooperates with libosinfo database to guess +the correct combination of attributes (e.g. disk driver, NIC model). + +B<virtxml> does not feed libvirt with generated XML though. For now, +it's a proof of concept. + +=head1 OPTIONS + +The basic structure of arguments passed to B<virtxml> is: + + virtxml [-c URI] [OPTION] [OPTION] ... + +However, arguments have no pre-defined order so users can type them +in any order they like. + +=head2 General Options + +=over 2 + +=item -c URI, --connect=URI + +The libvirt connection URI which is used for querying capabilities of the +host. + +=item --list-os + +List IDs of operating systems known to libosinfo + +=item --list-platform + +List IDs of platforms known to libosinfo + +=item -o OS, --os=OS + +Specify operating system that will be run on the domain. I<OS> is an ID +which can be obtained via B<--list-os>. + +=item -p PLATFORM, --platform=PLATFORM + +Specify platform (hypervisor) under which the domain will run. I<PLATFORM> +is and ID which can be obtained via I<--list-platform>. + +=item -a ARCH, --architecture=ARCH + +Set domain's architecture + +=item -d PATH[,FORMAT] --disk=PATH[,FORMAT] + +Add I<PATH> as a disk to the domain. To specify its format (e.g. raw, +qcow2, phy) use I<FORMAT>. + +=item -i NETWORK[,ARG=VAL] + +Add an interface of type network with I<NETWORK> source. Moreover, some +other configuration knobs can be set (possible I<ARG>s): I<mac>, +I<link>={up|down} + +=item -r RESOURCE, --resources=RESOURCES + +Set I<minimal> or I<recommended> resources on the domain XML. By default, +the I<recommended> is used. + +=back + +Usually, both B<--os> and B<--platform> are required as they are needed to +make the right decision on driver, model, ... when adding a new device. +However, when adding a disk which is an installation medium (e.g. a CD-ROM or +DVD), B<virtxml> tries to guess the OS. Something similar is done with +platform. Usually, the platform is guessed from the connection URI. + +=head1 EXAMPLES + +Domain with Fedora 17 from locally stored ISO and one NIC with mac +00:11:22:33:44:55 and link set down: + + # virtxml -d Fedora-17-x86_64-Live-KDE.iso \ + -i default,mac=00:11:22:33:44:55,link=down + +To add multiple devices just use appropriate argument multiple times: + + # virtxml -d /tmp/Fedora-17-x86_64-Live-KDE.iso,raw \ + -d /var/lib/libvirt/images/f17.img,qcow2 \ + -i default,mac=00:11:22:33:44:55,link=down \ + -i blue_network \ + -r minimal + +=head1 AUTHORS + +Written by Michal Privoznik, Daniel P. Berrange and team of other +contributors. See the AUTHORS file in the source distribution for the +complete list of credits. + +=head1 BUGS + +Report any bugs discovered to the libvirt community via the mailing +list C<http://libvirt.org/contact.html> or bug tracker C<http://libvirt.org/bugs.html>. +Alternatively report bugs to your software distributor / vendor. + +=head1 COPYRIGHT + +Copyright (C) 2012 Red Hat, Inc. and various contributors. +This is free software. You may redistribute copies of it under the terms of +the GNU General Public License C<http://www.gnu.org/licenses/gpl.html>. There +is NO WARRANTY, to the extent permitted by law. + +=head1 SEE ALSO + +C<virsh(1)>, C<virt-clone(1)>, C<virt-manager(1)>, the project website C<http://virt-manager.org> + +=cut +*/ diff --git a/libvirt-designer.spec.in b/libvirt-designer.spec.in index 1d5f4b6..ede7185 100644 --- a/libvirt-designer.spec.in +++ b/libvirt-designer.spec.in @@ -78,6 +78,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %{_bindir}/virtxml +%{_mandir}/man1/virtxml.1*
%files libs %defattr(-,root,root,-) -- 1.7.8.6
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Michal Privoznik