From cebeba7bd79421a30d9d233f0668d4ec4c4c9060 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 16 Sep 2009 13:07:48 +0100 Subject: [PATCH] Move docs/examples into examples/ * Makefile.am: Add examples/dominfo examples/domsuspend examples/python as SUBDIRS * configure.in: Update AC_OUTPUT for new/old Makefiles * docs/Makefile.am: Remove examples from SUBDIRS * docs/examples/info1.c: Move to examples/dominfo/info1.c * docs/examples/suspend.c: Move to examples/domsuspend/suspend.c * docs/examples: Remove all remaining files * docs/examples/python: Moved to examples/python/ * examples/dominfo/Makefile.am, examples/domsuspend/Makefile.am: New build files * libvirt.spec.in: Update to take account of moved examples --- Makefile.am | 3 +- configure.in | 6 +- docs/Makefile.am | 2 +- docs/examples/Makefile.am | 45 --- docs/examples/examples.xml | 86 ----- docs/examples/examples.xsl | 144 --------- docs/examples/index.html | 7 - docs/examples/index.py | 305 ------------------ docs/examples/python/Makefile.am | 4 - docs/examples/python/guava.xml | 22 -- docs/examples/python/papaya.xml | 26 -- examples/dominfo/.gitignore | 5 + examples/dominfo/Makefile.am | 10 + {docs/examples => examples/dominfo}/info1.c | 0 .../domsuspend}/.gitignore | 2 - examples/domsuspend/Makefile.am | 10 + .../domsuspend}/suspend.c | 0 {docs/examples => examples}/python/.gitignore | 0 examples/python/Makefile.am | 3 + {docs/examples => examples}/python/README | 0 {docs/examples => examples}/python/dominfo.py | 0 .../python/domrestore.py | 0 {docs/examples => examples}/python/domsave.py | 0 .../examples => examples}/python/domstart.py | 0 libvirt.spec.in | 17 +- 25 files changed, 45 insertions(+), 652 deletions(-) delete mode 100644 docs/examples/Makefile.am delete mode 100644 docs/examples/examples.xml delete mode 100644 docs/examples/examples.xsl delete mode 100644 docs/examples/index.html delete mode 100755 docs/examples/index.py delete mode 100644 docs/examples/python/Makefile.am delete mode 100644 docs/examples/python/guava.xml delete mode 100644 docs/examples/python/papaya.xml create mode 100644 examples/dominfo/.gitignore create mode 100644 examples/dominfo/Makefile.am rename {docs/examples => examples/dominfo}/info1.c (100%) rename {docs/examples => examples/domsuspend}/.gitignore (73%) create mode 100644 examples/domsuspend/Makefile.am rename {docs/examples => examples/domsuspend}/suspend.c (100%) rename {docs/examples => examples}/python/.gitignore (100%) create mode 100644 examples/python/Makefile.am rename {docs/examples => examples}/python/README (100%) rename {docs/examples => examples}/python/dominfo.py (100%) rename {docs/examples => examples}/python/domrestore.py (100%) rename {docs/examples => examples}/python/domsave.py (100%) rename {docs/examples => examples}/python/domstart.py (100%) diff --git a/Makefile.am b/Makefile.am index ff4595780..3b01d1f13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,8 @@ LCOV = lcov GENHTML = genhtml SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \ - python tests po examples/domain-events/events-c examples/hellolibvirt + python tests po examples/domain-events/events-c examples/hellolibvirt \ + examples/dominfo examples/domsuspend examples/python ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4 diff --git a/configure.in b/configure.in index 5d498ae85..cb5ce550b 100644 --- a/configure.in +++ b/configure.in @@ -1685,8 +1685,7 @@ test "x$srcdir" = x. && ! test -f COPYING && cp -f COPYING.LIB COPYING AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \ - docs/examples/Makefile docs/devhelp/Makefile \ - docs/examples/python/Makefile \ + docs/devhelp/Makefile \ docs/schemas/Makefile \ gnulib/lib/Makefile \ gnulib/tests/Makefile \ @@ -1703,6 +1702,9 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \ tests/xencapsdata/Makefile \ tests/confdata/Makefile \ examples/domain-events/events-c/Makefile \ + examples/domsuspend/Makefile \ + examples/dominfo/Makefile \ + examples/python/Makefile \ examples/hellolibvirt/Makefile) AC_MSG_NOTICE([]) diff --git a/docs/Makefile.am b/docs/Makefile.am index fd96ba413..4cd11b005 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS= schemas examples devhelp +SUBDIRS= schemas devhelp # The directory containing the source code (if it contains documentation). DOC_SOURCE_DIR=../src diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am deleted file mode 100644 index 5129b5cf2..000000000 --- a/docs/examples/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -# -*- buffer-read-only: t -*- vi: set ro: -# Beware this is autogenerated by index.py -SUBDIRS=python -INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include -DEPS = $(top_builddir)/src/libvirt.la -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la $(COVERAGE_LDFLAGS) - -rebuild: examples.xml index.html - -examples.xml: index.py info1.c suspend.c - -@($(srcdir)/index.py) - -index.html: examples.xml examples.xsl $(top_srcdir)/docs/site.xsl - -@(if [ -x $(XSLTPROC) ] ; then \ - $(XSLTPROC) examples.xsl examples.xml \ - && echo "Rebuilt web page" \ - && xmllint --valid --noout index.html; \ - fi) - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(HTML_DIR) - -@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml \ - $(srcdir)/*.xsl $(DESTDIR)$(HTML_DIR) - -EXTRA_DIST=examples.xsl index.py examples.xml - -noinst_PROGRAMS=info1 suspend - -info1_SOURCES=info1.c -info1_LDFLAGS= -info1_DEPENDENCIES= $(DEPS) -info1_LDADD= $(LDADDS) - -suspend_SOURCES=suspend.c -suspend_LDFLAGS= -suspend_DEPENDENCIES= $(DEPS) -suspend_LDADD= $(LDADDS) - -valgrind: - $(MAKE) CHECKER='valgrind' tests - -tests: $(noinst_PROGRAMS) - @(echo '## examples regression tests') - @($(CHECKER) ./info1) - @($(CHECKER) ./suspend) diff --git a/docs/examples/examples.xml b/docs/examples/examples.xml deleted file mode 100644 index 24c5a48a5..000000000 --- a/docs/examples/examples.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - Extract information about Xen domain 0 - Demonstrate the basic use of the library to connect to the hypervisor and extract domain information. - info1 - info1 - Daniel Veillard - see Copyright for the status of this software. -
Informations
- - - - - - - - - - -
- - Suspend a domain and then resume its execution - Demonstrate the basic use of the library to suspend and resume a domain. If no id is given on the command line this script will suspend and resume the first domain found which is not Domain 0. - suspend [id] - suspend - Daniel Veillard - see Copyright for the status of this software. -
Scheduling
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-
-
diff --git a/docs/examples/examples.xsl b/docs/examples/examples.xsl deleted file mode 100644 index b7ccba218..000000000 --- a/docs/examples/examples.xsl +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - ../ - Examples Menu - - -
- - -
- -
- - - - -
  • -
    - - - - - -
  • line : Type from
  • -
    - - - - - -
  • line : Function from
  • -
    - - - - - -
  • line : Macro from
  • -
    - - - -

    :

    -

    -

    Uses:

    -
      - - - - -
    -

    Usage:

    -

    -

    Author:

    -
    - - -
  • :

    -
      - - - -
    • :
    • -
      -
    -
  • -
    - - -

    The examples are stored per section depending on the main focus - of the example:

    -
      - - - - -
    -

    Getting the compilation options and libraries dependancies needed -to generate binaries from the examples is best done on Linux/Unix by using -the pkg-config data which should have been installed as part of make -install step or when installing the libvirt development package:

    -
    gcc -o example example.c `pkg-config libvirt --libs`
    -
    - - - - -

    Examples

    - -
    -
    - - - Libvirt set of C code examples - - - - - - - - - -
    -
    -
    - - - -
    - - - - - - diff --git a/docs/examples/index.html b/docs/examples/index.html deleted file mode 100644 index 6709b351d..000000000 --- a/docs/examples/index.html +++ /dev/null @@ -1,7 +0,0 @@ - - -Libvirt set of C code examples

    Libvirt set of C code examples

    The examples are stored per section depending on the main focus - of the example:

    Getting the compilation options and libraries dependancies needed -to generate binaries from the examples is best done on Linux/Unix by using -the pkg-config data which should have been installed as part of make -install step or when installing the libvirt development package:

    gcc -o example example.c `pkg-config libvirt --libs`

    Informations Examples

    info1.c: Extract information about Xen domain 0

    Demonstrate the basic use of the library to connect to the hypervisor and extract domain information.

    Uses:

    Usage:

    info1

    Author: Daniel Veillard

    Scheduling Examples

    suspend.c: Suspend a domain and then resume its execution

    Demonstrate the basic use of the library to suspend and resume a domain. If no id is given on the command line this script will suspend and resume the first domain found which is not Domain 0.

    Uses:

    Usage:

    suspend [id]

    Author: Daniel Veillard

    diff --git a/docs/examples/index.py b/docs/examples/index.py deleted file mode 100755 index 00c0dcfaa..000000000 --- a/docs/examples/index.py +++ /dev/null @@ -1,305 +0,0 @@ -#!/usr/bin/python -u -# -# Indexes the examples and build an XML description -# -import string -import glob -import sys -try: - import libxml2 -except: - sys.exit(1) -sys.path.insert(0, "..") -from apibuild import CParser, escape - -examples = [] -extras = ['examples.xsl', 'index.py'] -tests = [] -sections = {} -symbols = {} -api_dict = None -api_doc = None - -def load_api(): - global api_dict - global api_doc - - if api_dict != None: - return - api_dict = {} - try: - print "loading ../libvirt-api.xml" - api_doc = libxml2.parseFile("../libvirt-api.xml") - except: - print "failed to parse ../libvirt-api.xml" - sys.exit(1) - -def find_symbol(name): - global api_dict - global api_doc - - if api_doc == None: - load_api() - - if name == None: - return - if api_dict.has_key(name): - return api_dict[name] - ctxt = api_doc.xpathNewContext() - res = ctxt.xpathEval("/api/symbols/*[@name = '%s']" % (name)) - if type(res) == type([]) and len(res) >= 1: - if len(res) > 1: - print "Found %d references to %s in the API" % (len(res), name) - node = res[0] - typ = node.name - file = node.xpathEval("string(@file)") - info = node.xpathEval("string(info)") - else: - print "Reference %s not found in the API" % (name) - return None - ret = (typ, file, info) - api_dict[name] = ret - return ret - -def parse_top_comment(filename, comment): - res = {} - lines = string.split(comment, "\n") - item = None - for line in lines: - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - while line != "" and line[0] == '*': - line = line[1:] - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - try: - (it, line) = string.split(line, ":", 1) - item = it - while line != "" and (line[0] == ' ' or line[0] == '\t'): - line = line[1:] - if res.has_key(item): - res[item] = res[item] + " " + line - else: - res[item] = line - except: - if item != None: - if res.has_key(item): - res[item] = res[item] + " " + line - else: - res[item] = line - return res - -def parse(filename, output): - global symbols - global sections - - parser = CParser(filename) - parser.collect_references() - idx = parser.parse() - info = parse_top_comment(filename, parser.top_comment) - output.write(" \n" % filename) - try: - synopsis = info['synopsis'] - output.write(" %s\n" % escape(synopsis)); - except: - print "Example %s lacks a synopsis description" % (filename) - try: - purpose = info['purpose'] - output.write(" %s\n" % escape(purpose)); - except: - print "Example %s lacks a purpose description" % (filename) - try: - usage = info['usage'] - output.write(" %s\n" % escape(usage)); - except: - print "Example %s lacks an usage description" % (filename) - try: - test = info['test'] - output.write(" %s\n" % escape(test)); - progname=filename[0:-2] - command=string.replace(test, progname, './' + progname, 1) - tests.append(command) - except: - pass - try: - author = info['author'] - output.write(" %s\n" % escape(author)); - except: - print "Example %s lacks an author description" % (filename) - try: - copy = info['copy'] - output.write(" %s\n" % escape(copy)); - except: - print "Example %s lacks a copyright description" % (filename) - try: - section = info['section'] - output.write("
    %s
    \n" % escape(section)); - if sections.has_key(section): - sections[section].append(filename) - else: - sections[section] = [filename] - except: - print "Example %s lacks a section description" % (filename) - for topic in info.keys(): - if topic != "purpose" and topic != "usage" and \ - topic != "author" and topic != "copy" and \ - topic != "section" and topic != "synopsis" and topic != "test": - str = info[topic] - output.write(" %s\n" % ( - escape(topic), escape(str))) - output.write(" \n") - for include in idx.includes.keys(): - if include.find("libxml") != -1: - output.write(" %s\n" % (escape(include))) - output.write(" \n") - output.write(" \n") - for ref in idx.references.keys(): - id = idx.references[ref] - name = id.get_name() - line = id.get_lineno() - if symbols.has_key(name): - sinfo = symbols[name] - refs = sinfo[0] - # gather at most 5 references per symbols - if refs > 5: - continue - sinfo.append(filename) - sinfo[0] = refs + 1 - else: - symbols[name] = [1, filename] - info = find_symbol(name) - if info != None: - type = info[0] - file = info[1] - output.write(" <%s line='%d' file='%s' name='%s'/>\n" % (type, - line, file, name)) - else: - type = id.get_type() - output.write(" <%s line='%d' name='%s'/>\n" % (type, - line, name)) - - output.write(" \n") - output.write("
    \n") - - return idx - -def dump_symbols(output): - global symbols - - output.write(" \n") - keys = symbols.keys() - keys.sort() - for symbol in keys: - output.write(" \n" % (symbol)) - info = symbols[symbol] - i = 1 - while i < len(info): - output.write(" \n" % (info[i])) - i = i + 1 - output.write(" \n") - output.write(" \n") - -def dump_sections(output): - global sections - - output.write(" \n") - keys = sections.keys() - keys.sort() - for section in keys: - output.write("
    \n" % (section)) - info = sections[section] - i = 0 - while i < len(info): - output.write(" \n" % (info[i])) - i = i + 1 - output.write("
    \n") - output.write("
    \n") - -def dump_Makefile(): - for file in glob.glob('*.xml'): - extras.append(file) - Makefile="""# -*- buffer-read-only: t -*- vi: set ro: -# Beware this is autogenerated by index.py -SUBDIRS=python -INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include -DEPS = $(top_builddir)/src/libvirt.la -LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \ - $(COVERAGE_LDFLAGS) - -rebuild: examples.xml index.html - -examples.xml: index.py __C_SOURCES__ - -@($(srcdir)/index.py) - -index.html: examples.xml examples.xsl $(top_srcdir)/docs/site.xsl - -@(if [ -x $(XSLTPROC) ] ; then \\ - $(XSLTPROC) examples.xsl examples.xml \\ - && echo "Rebuilt web page" \\ - && xmllint --valid --noout index.html; \\ - fi) - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(HTML_DIR) - -@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml \\ - $(srcdir)/*.xsl $(DESTDIR)$(HTML_DIR) - -""" - EXTRA_DIST= string.join(extras, ' ') - Makefile = Makefile + "EXTRA_DIST=%s\n\n" % (EXTRA_DIST) - noinst_PROGRAMS= string.join(examples, ' ') - Makefile = Makefile + "noinst_PROGRAMS=%s\n\n" % (noinst_PROGRAMS) - for example in examples: - Makefile = Makefile + "%s_SOURCES=%s.c\n%s_LDFLAGS=\n%s_DEPENDENCIES= $(DEPS)\n%s_LDADD= $(LDADDS)\n\n" % (example, example, example, - example, example) - Makefile = Makefile + "valgrind:\n\t$(MAKE) CHECKER='valgrind' tests\n\n" - Makefile = Makefile + "tests: $(noinst_PROGRAMS)\n" - Makefile = Makefile + "\t@(echo '## examples regression tests')\n" -# Makefile = Makefile + "\t@(echo > .memdump)\n" - for test in tests: - Makefile = Makefile + "\t@($(CHECKER) %s)\n" % (test) -# Makefile = Makefile + '\t@(grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0" ; exit 0)\n' - - c_src = [("%s.c" % x) for x in examples] - Makefile = Makefile.replace("__C_SOURCES__", string.join(c_src, ' ')) - try: - old = open("Makefile.am", "r").read() - if old != Makefile: - n = open("Makefile.am", "w").write(Makefile) - print "Updated Makefile.am" - except: - print "Failed to read or save Makefile.am" - # - # Autogenerate the .cvsignore too ... - # - ignore = """.memdump -Makefile.in -Makefile -.deps -.libs -""" - for example in examples: - ignore = ignore + "%s\n" % (example) - try: - old = open(".cvsignore", "r").read() - if old != ignore: - n = open(".cvsignore", "w").write(ignore) - print "Updated .cvsignore" - except: - print "Failed to read or save .cvsignore" - -if __name__ == "__main__": - load_api() - output = open("examples.xml", "w") - output.write("\n") - - c_src = glob.glob('*.c') - c_src.sort() - for file in c_src: - parse(file, output) - examples.append(file[:-2]) - - dump_symbols(output) - dump_sections(output) - output.write("\n") - output.close() - dump_Makefile() diff --git a/docs/examples/python/Makefile.am b/docs/examples/python/Makefile.am deleted file mode 100644 index ae92d9406..000000000 --- a/docs/examples/python/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -EXTRA_DIST= \ - README \ - dominfo.py domrestore.py domsave.py domstart.py \ - guava.xml papaya.xml diff --git a/docs/examples/python/guava.xml b/docs/examples/python/guava.xml deleted file mode 100644 index 4cff17583..000000000 --- a/docs/examples/python/guava.xml +++ /dev/null @@ -1,22 +0,0 @@ - - guava - - linux - /var/xen/boot/vmlinuz-2.6.15-1.33_FC5guest - /var/xen/boot/initrd-2.6.15-1.33_FC5guest.img - ro root=/dev/VolGroup00/LogVol00 rhgb quiet - - 262144 - 1 - - - - - - - - -