Codebase list libvirt-glib / 71266c3
New upstream version 0.0.2 Guido Günther 12 years ago
40 changed file(s) with 1014 addition(s) and 323 deletion(s). Raw diff Collapse all Expand all
0
10 GNU LESSER GENERAL PUBLIC LICENSE
21 Version 2.1, February 1999
32
43 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
65 Everyone is permitted to copy and distribute verbatim copies
76 of this license document, but changing it is not allowed.
87
2221 Free Software Foundation and other authors who decide to use it. You
2322 can use it too, but we suggest you first think carefully about whether
2423 this license or the ordinary General Public License is the better
25 strategy to use in any particular case, based on the explanations
26 below.
24 strategy to use in any particular case, based on the explanations below.
2725
2826 When we speak of free software, we are referring to freedom of use,
2927 not price. Our General Public Licenses are designed to make sure that
5654 that what they have is not the original version, so that the original
5755 author's reputation will not be affected by problems that might be
5856 introduced by others.
59 ^L
57
6058 Finally, software patents pose a constant threat to the existence of
6159 any free program. We wish to make sure that a company cannot
6260 effectively restrict the users of a free program by obtaining a
8886 special circumstances.
8987
9088 For example, on rare occasions, there may be a special need to
91 encourage the widest possible use of a certain library, so that it
92 becomes a de-facto standard. To achieve this, non-free programs must
93 be allowed to use the library. A more frequent case is that a free
89 encourage the widest possible use of a certain library, so that it becomes
90 a de-facto standard. To achieve this, non-free programs must be
91 allowed to use the library. A more frequent case is that a free
9492 library does the same job as widely used non-free libraries. In this
9593 case, there is little to gain by limiting the free library to free
9694 software only, so we use the Lesser General Public License.
112110 "work based on the library" and a "work that uses the library". The
113111 former contains code derived from the library, whereas the latter must
114112 be combined with the library in order to run.
115 ^L
113
116114 GNU LESSER GENERAL PUBLIC LICENSE
117115 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
118116
137135 "Source code" for a work means the preferred form of the work for
138136 making modifications to it. For a library, complete source code means
139137 all the source code for all modules it contains, plus any associated
140 interface definition files, plus the scripts used to control
141 compilation and installation of the library.
138 interface definition files, plus the scripts used to control compilation
139 and installation of the library.
142140
143141 Activities other than copying, distribution and modification are not
144142 covered by this License; they are outside its scope. The act of
217215 ordinary GNU General Public License has appeared, then you can specify
218216 that version instead if you wish.) Do not make any other change in
219217 these notices.
220 ^L
218
221219 Once this change is made in a given copy, it is irreversible for
222220 that copy, so the ordinary GNU General Public License applies to all
223221 subsequent copies and derivative works made from that copy.
268266 distribute the object code for the work under the terms of Section 6.
269267 Any executables containing that work also fall under Section 6,
270268 whether or not they are linked directly with the Library itself.
271 ^L
269
272270 6. As an exception to the Sections above, you may also combine or
273271 link a "work that uses the Library" with the Library to produce a
274272 work containing portions of the Library, and distribute that work
304302 the user installs one, as long as the modified version is
305303 interface-compatible with the version that the work was made with.
306304
307 c) Accompany the work with a written offer, valid for at least
308 three years, to give the same user the materials specified in
309 Subsection 6a, above, for a charge no more than the cost of
310 performing this distribution.
305 c) Accompany the work with a written offer, valid for at
306 least three years, to give the same user the materials
307 specified in Subsection 6a, above, for a charge no more
308 than the cost of performing this distribution.
311309
312310 d) If distribution of the work is made by offering access to copy
313311 from a designated place, offer equivalent access to copy the above
330328 accompany the operating system. Such a contradiction means you cannot
331329 use both them and the Library together in an executable that you
332330 distribute.
333 ^L
331
334332 7. You may place library facilities that are a work based on the
335333 Library side-by-side in a single library together with other library
336334 facilities not covered by this License, and distribute such a combined
371369 restrictions on the recipients' exercise of the rights granted herein.
372370 You are not responsible for enforcing compliance by third parties with
373371 this License.
374 ^L
372
375373 11. If, as a consequence of a court judgment or allegation of patent
376374 infringement or for any other reason (not limited to patent issues),
377375 conditions are imposed on you (whether by court order, agreement or
385383 the only way you could satisfy both it and this License would be to
386384 refrain entirely from distribution of the Library.
387385
388 If any portion of this section is held invalid or unenforceable under
389 any particular circumstance, the balance of the section is intended to
390 apply, and the section as a whole is intended to apply in other
391 circumstances.
386 If any portion of this section is held invalid or unenforceable under any
387 particular circumstance, the balance of the section is intended to apply,
388 and the section as a whole is intended to apply in other circumstances.
392389
393390 It is not the purpose of this section to induce you to infringe any
394391 patents or other property right claims or to contest validity of any
406403
407404 12. If the distribution and/or use of the Library is restricted in
408405 certain countries either by patents or by copyrighted interfaces, the
409 original copyright holder who places the Library under this License
410 may add an explicit geographical distribution limitation excluding those
411 countries, so that distribution is permitted only in or among
412 countries not thus excluded. In such case, this License incorporates
413 the limitation as if written in the body of this License.
406 original copyright holder who places the Library under this License may add
407 an explicit geographical distribution limitation excluding those countries,
408 so that distribution is permitted only in or among countries not thus
409 excluded. In such case, this License incorporates the limitation as if
410 written in the body of this License.
414411
415412 13. The Free Software Foundation may publish revised and/or new
416413 versions of the Lesser General Public License from time to time.
424421 the Free Software Foundation. If the Library does not specify a
425422 license version number, you may choose any version ever published by
426423 the Free Software Foundation.
427 ^L
424
428425 14. If you wish to incorporate parts of the Library into other free
429426 programs whose distribution conditions are incompatible with these,
430427 write to the author to ask for permission. For software which is
458455 DAMAGES.
459456
460457 END OF TERMS AND CONDITIONS
461 ^L
458
462459 How to Apply These Terms to Your New Libraries
463460
464461 If you develop a new library, and you want it to be of the greatest
465462 possible use to the public, we recommend making it free software that
466463 everyone can redistribute and change. You can do so by permitting
467 redistribution under these terms (or, alternatively, under the terms
468 of the ordinary General Public License).
469
470 To apply these terms, attach the following notices to the library.
471 It is safest to attach them to the start of each source file to most
472 effectively convey the exclusion of warranty; and each file should
473 have at least the "copyright" line and a pointer to where the full
474 notice is found.
475
464 redistribution under these terms (or, alternatively, under the terms of the
465 ordinary General Public License).
466
467 To apply these terms, attach the following notices to the library. It is
468 safest to attach them to the start of each source file to most effectively
469 convey the exclusion of warranty; and each file should have at least the
470 "copyright" line and a pointer to where the full notice is found.
476471
477472 <one line to give the library's name and a brief idea of what it does.>
478473 Copyright (C) <year> <name of author>
489484
490485 You should have received a copy of the GNU Lesser General Public
491486 License along with this library; if not, write to the Free Software
492 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
487 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
493488
494489 Also add information on how to contact you by electronic and paper mail.
495490
496 You should also get your employer (if you work as a programmer) or
497 your school, if any, to sign a "copyright disclaimer" for the library,
498 if necessary. Here is a sample; alter the names:
491 You should also get your employer (if you work as a programmer) or your
492 school, if any, to sign a "copyright disclaimer" for the library, if
493 necessary. Here is a sample; alter the names:
499494
500495 Yoyodyne, Inc., hereby disclaims all copyright interest in the
501 library `Frob' (a library for tweaking knobs) written by James
502 Random Hacker.
496 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
503497
504498 <signature of Ty Coon>, 1 April 1990
505499 Ty Coon, President of Vice
506500
507501 That's all there is to it!
508
509
0 2011-11-22 Daniel P. Berrange <berrange@redhat.com>
1
2 Update NEWs with more 0.0.2 release notes
3
4 Update COPYING file to have newer FSF address
5
6 Update RPM specfile with latest Fedora review feedback
7
8 Don't reference GError **err parameter if it is NULL
9
10 Ensure domains & pools hash tables in connection are non-NULL
11
12 Add API for creating transient domains
13
14 Uncomment & fix code for returning config objects
15
16 Change all flags from guint64 to guint to match libvirt type
17
18 Add support for writing to streams
19
20 2011-11-22 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
21
22 Release 0.0.2
23
24 2011-11-21 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
25
26 Add API to redefine an existing domain
27
28 2011-11-18 Guido Günther <agx@sigxcpu.org>
29
30 Adjust example to pygobject-3.0
31 which doesn't allow to "import gtk" anymore. Use the gir version
32 instead.
33
34 2011-11-17 Daniel P. Berrange <berrange@redhat.com>
35
36 Add libxml-2.0 to libvirt-gconfig-1.0.pc
37 The libvirt-gconfig header files depend on the libxml header
38 files, so this must be expressed in the pkgconfig file to
39 ensure the include path for libxml2 gets added to the compiler
40 args
41
42 2011-11-16 Marc-André Lureau <marcandre.lureau@redhat.com>
43
44 Expicitely call virInitialize() to avoid connection races
45 Credits to Daniel for pointing out the solution.
46
047 2011-11-16 Daniel P. Berrange <berrange@redhat.com>
148
249 Fix typo in libvirt-gobject-1.0.pc.in
0 0.0.2 - Nov 22, 2011
1 ====================
2
3 - Add API to redefine an existing domain.
4 - Expicitely call virInitialize() to avoid connection races.
5 - Adjust example to latest pygobject-3.0.
6 - Add missing deps on libxml2-devel & libtool.
7 - Add support for writing to streams
8 - Add API for creating transient domains
9 - Change all flags parameters to be guint
10 - Uncomment & fix code for returning object config
11 - Ensure pools & domains hashes are non-NULL to avoid SEGV
12 - Don't de-reference GError instances which are NULL
13 - Update COPYING file to have latest FSF address
14 - Update RPM specfile to include Fedora review feedback
15
016 0.0.1 - Nov 16, 2011
117 ====================
218
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.68 for libvirt-glib 0.0.1.
2 # Generated by GNU Autoconf 2.68 for libvirt-glib 0.0.2.
33 #
44 #
55 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
566566 # Identity of this package.
567567 PACKAGE_NAME='libvirt-glib'
568568 PACKAGE_TARNAME='libvirt-glib'
569 PACKAGE_VERSION='0.0.1'
570 PACKAGE_STRING='libvirt-glib 0.0.1'
569 PACKAGE_VERSION='0.0.2'
570 PACKAGE_STRING='libvirt-glib 0.0.2'
571571 PACKAGE_BUGREPORT=''
572572 PACKAGE_URL=''
573573
13721372 # Omit some internal or obsolete options to make the list less imposing.
13731373 # This message is too long to be a string in the A/UX 3.1 sh.
13741374 cat <<_ACEOF
1375 \`configure' configures libvirt-glib 0.0.1 to adapt to many kinds of systems.
1375 \`configure' configures libvirt-glib 0.0.2 to adapt to many kinds of systems.
13761376
13771377 Usage: $0 [OPTION]... [VAR=VALUE]...
13781378
14421442
14431443 if test -n "$ac_init_help"; then
14441444 case $ac_init_help in
1445 short | recursive ) echo "Configuration of libvirt-glib 0.0.1:";;
1445 short | recursive ) echo "Configuration of libvirt-glib 0.0.2:";;
14461446 esac
14471447 cat <<\_ACEOF
14481448
15871587 test -n "$ac_init_help" && exit $ac_status
15881588 if $ac_init_version; then
15891589 cat <<\_ACEOF
1590 libvirt-glib configure 0.0.1
1590 libvirt-glib configure 0.0.2
15911591 generated by GNU Autoconf 2.68
15921592
15931593 Copyright (C) 2010 Free Software Foundation, Inc.
18651865 This file contains any messages produced by compilers while
18661866 running configure, to aid debugging if configure makes a mistake.
18671867
1868 It was created by libvirt-glib $as_me 0.0.1, which was
1868 It was created by libvirt-glib $as_me 0.0.2, which was
18691869 generated by GNU Autoconf 2.68. Invocation command line was
18701870
18711871 $ $0 $@
26842684
26852685 # Define the identity of the package.
26862686 PACKAGE='libvirt-glib'
2687 VERSION='0.0.1'
2687 VERSION='0.0.2'
26882688
26892689
26902690 cat >>confdefs.h <<_ACEOF
1368613686 # report actual input values of CONFIG_FILES etc. instead of their
1368713687 # values after options handling.
1368813688 ac_log="
13689 This file was extended by libvirt-glib $as_me 0.0.1, which was
13689 This file was extended by libvirt-glib $as_me 0.0.2, which was
1369013690 generated by GNU Autoconf 2.68. Invocation command line was
1369113691
1369213692 CONFIG_FILES = $CONFIG_FILES
1375213752 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1375313753 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1375413754 ac_cs_version="\\
13755 libvirt-glib config.status 0.0.1
13755 libvirt-glib config.status 0.0.2
1375613756 configured by $0, generated by GNU Autoconf 2.68,
1375713757 with options \\"\$ac_cs_config\\"
1375813758
0
1 AC_INIT(libvirt-glib, 0.0.1)
0 AC_INIT(libvirt-glib, 0.0.2)
21 AC_CONFIG_SRCDIR(libvirt-glib/libvirt-glib-main.c)
32 AC_CONFIG_AUX_DIR([build-aux])
43 AM_CONFIG_HEADER(config.h)
2020 </tr></table>
2121 <div class="chapter">
2222 <div class="titlepage"><div><div><h2 class="title">
23 <a name="id406188"></a>Libvirt-gconfig</h2></div></div></div>
23 <a name="id410353"></a>Libvirt-gconfig</h2></div></div></div>
2424 <span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span>
2525 </div>
2626 <div class="footer">
2020 </tr></table>
2121 <div class="chapter">
2222 <div class="titlepage"><div><div><h2 class="title">
23 <a name="id375025"></a>Libvirt-glib</h2></div></div></div>
23 <a name="id479404"></a>Libvirt-glib</h2></div></div></div>
2424 <span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span>
2525 </div>
2626 <div class="footer">
2020 </tr></table>
2121 <div class="chapter">
2222 <div class="titlepage"><div><div><h2 class="title">
23 <a name="id464659"></a>Libvirt-gobject</h2></div></div></div>
23 <a name="id382227"></a>Libvirt-gobject</h2></div></div></div>
2424 <span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span><span style="color: red">&lt;xi:include&gt;&lt;/xi:include&gt;</span>
2525 </div>
2626 <div class="footer">
00
1 import gtk
1 from gi.repository import Gtk
22 import libvirt
33 import getopt
44 import sys
4646
4747 print "Using uri:" + uri
4848
49 LibvirtGLib.init("")
49 LibvirtGLib.init(0, "")
5050 LibvirtGLib.event_register()
51 # libvirtglib.eventRegister()
5251 vc = libvirt.open(uri)
5352
5453 #Add 2 callbacks to prove this works with more than just one
5554 vc.domainEventRegister(myDomainEventCallback1,None)
5655 vc.domainEventRegister(myDomainEventCallback2,None)
5756
58 gtk.main()
57 Gtk.main()
5958
6059 if __name__ == "__main__":
6160 main()
55 Name: libvirt-gconfig
66 Version: @VERSION@
77 Description: libvirt GConfig library
8 Requires: gobject-2.0
8 Requires: gobject-2.0 libxml-2.0
99 Libs: -L${libdir} -lvirt-gconfig-1.0
1010 Cflags: -I${includedir}/libvirt-gconfig-1.0
6262 if (!g_thread_supported())
6363 g_thread_init(NULL);
6464
65 virInitialize();
66
6567 return TRUE;
6668 }
6769
55 %if 0%{?fedora} >= 15
66 %define with_introspection 1
77 %endif
8 %if 0%{?fedora} < 15
8 %if 0%{?fedora} && 0%{?fedora} < 15
99 %define with_python 1
1010 %endif
1111 %if 0%{?rhel} > 6
1212 %define with_introspection 1
1313 %endif
14 %if 0%{?rhel} < 7
14 %if 0%{?rhel} && 0%{?rhel} < 7
1515 %define with_python 1
1616 %endif
1717
1818
1919 Name: libvirt-glib
20 Version: 0.0.1
20 Version: 0.0.2
2121 Release: 1%{?dist}%{?extra_release}
2222 Summary: libvirt glib integration for events
2323 Group: Development/Libraries
2424 License: LGPLv2+
2525 URL: http://libvirt.org/
26 Source0: http://libvirt.org/%{name}/%{name}-%{version}.tar.gz
26 Source0: ftp://libvirt.org/libvirt/glib/%{name}-%{version}.tar.gz
2727 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
2828
2929 BuildRequires: glib2-devel >= 2.10.0
3434 %if 0%{?fedora} == 12
3535 BuildRequires: gir-repository-devel
3636 %endif
37 BuildRequires: gjs-devel
3837 %endif
3938 BuildRequires: libxml2-devel
4039 # Hack due to https://bugzilla.redhat.com/show_bug.cgi?id=613466
134133 %clean
135134 rm -rf $RPM_BUILD_ROOT
136135
136 %post -p /sbin/ldconfig
137
138 %postun -p /sbin/ldconfig
139
140 %post -n libvirt-gconfig -p /sbin/ldconfig
141
142 %postun -n libvirt-gconfig -p /sbin/ldconfig
143
144 %post -n libvirt-gobject -p /sbin/ldconfig
145
146 %postun -n libvirt-gobject -p /sbin/ldconfig
147
137148 %files
138149 %defattr(-,root,root,-)
139150 %doc README COPYING AUTHORS ChangeLog NEWS
205216 %endif
206217
207218 %changelog
208 * Sun Oct 19 2008 Daniel P. Berrange <berrange@redhat.com> - 0.0.1-1
209 - Initial release
210
55 %if 0%{?fedora} >= 15
66 %define with_introspection 1
77 %endif
8 %if 0%{?fedora} < 15
8 %if 0%{?fedora} && 0%{?fedora} < 15
99 %define with_python 1
1010 %endif
1111 %if 0%{?rhel} > 6
1212 %define with_introspection 1
1313 %endif
14 %if 0%{?rhel} < 7
14 %if 0%{?rhel} && 0%{?rhel} < 7
1515 %define with_python 1
1616 %endif
1717
2323 Group: Development/Libraries
2424 License: LGPLv2+
2525 URL: http://libvirt.org/
26 Source0: http://libvirt.org/%{name}/%{name}-%{version}.tar.gz
26 Source0: ftp://libvirt.org/libvirt/glib/%{name}-%{version}.tar.gz
2727 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
2828
2929 BuildRequires: glib2-devel >= 2.10.0
3434 %if 0%{?fedora} == 12
3535 BuildRequires: gir-repository-devel
3636 %endif
37 BuildRequires: gjs-devel
3837 %endif
3938 BuildRequires: libxml2-devel
4039 # Hack due to https://bugzilla.redhat.com/show_bug.cgi?id=613466
134133 %clean
135134 rm -rf $RPM_BUILD_ROOT
136135
136 %post -p /sbin/ldconfig
137
138 %postun -p /sbin/ldconfig
139
140 %post -n libvirt-gconfig -p /sbin/ldconfig
141
142 %postun -n libvirt-gconfig -p /sbin/ldconfig
143
144 %post -n libvirt-gobject -p /sbin/ldconfig
145
146 %postun -n libvirt-gobject -p /sbin/ldconfig
147
137148 %files
138149 %defattr(-,root,root,-)
139150 %doc README COPYING AUTHORS ChangeLog NEWS
205216 %endif
206217
207218 %changelog
208 * Sun Oct 19 2008 Daniel P. Berrange <berrange@redhat.com> - 0.0.1-1
209 - Initial release
210
4444
4545 libvirt_gobject_1_0_ladir = $(includedir)/libvirt-gobject-1.0/libvirt-gobject
4646 libvirt_gobject_1_0_la_HEADERS = \
47 $(GOBJECT_HEADER_FILES) \
48 libvirt-gobject-input-stream.h
47 $(GOBJECT_HEADER_FILES)
4948 nodist_libvirt_gobject_1_0_la_HEADERS = \
5049 libvirt-gobject-enums.h
5150 libvirt_gobject_1_0_la_SOURCES = \
5352 $(GOBJECT_SOURCE_FILES) \
5453 libvirt-gobject-domain-device-private.h \
5554 libvirt-gobject-compat.h \
56 libvirt-gobject-input-stream.c
55 libvirt-gobject-input-stream.h \
56 libvirt-gobject-input-stream.c \
57 libvirt-gobject-output-stream.h \
58 libvirt-gobject-output-stream.c
5759 nodist_libvirt_gobject_1_0_la_SOURCES = \
5860 $(GOBJECT_GENERATED_FILES)
5961 libvirt_gobject_1_0_la_CFLAGS = \
9494 libvirt_gobject_1_0_la-libvirt-gobject-connection.lo \
9595 libvirt_gobject_1_0_la-libvirt-gobject-manager.lo
9696 am_libvirt_gobject_1_0_la_OBJECTS = $(am__objects_2) $(am__objects_3) \
97 libvirt_gobject_1_0_la-libvirt-gobject-input-stream.lo
97 libvirt_gobject_1_0_la-libvirt-gobject-input-stream.lo \
98 libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo
9899 am__objects_4 = libvirt_gobject_1_0_la-libvirt-gobject-enums.lo
99100 nodist_libvirt_gobject_1_0_la_OBJECTS = $(am__objects_4)
100101 libvirt_gobject_1_0_la_OBJECTS = $(am_libvirt_gobject_1_0_la_OBJECTS) \
344345
345346 libvirt_gobject_1_0_ladir = $(includedir)/libvirt-gobject-1.0/libvirt-gobject
346347 libvirt_gobject_1_0_la_HEADERS = \
347 $(GOBJECT_HEADER_FILES) \
348 libvirt-gobject-input-stream.h
348 $(GOBJECT_HEADER_FILES)
349349
350350 nodist_libvirt_gobject_1_0_la_HEADERS = \
351351 libvirt-gobject-enums.h
355355 $(GOBJECT_SOURCE_FILES) \
356356 libvirt-gobject-domain-device-private.h \
357357 libvirt-gobject-compat.h \
358 libvirt-gobject-input-stream.c
358 libvirt-gobject-input-stream.h \
359 libvirt-gobject-input-stream.c \
360 libvirt-gobject-output-stream.h \
361 libvirt-gobject-output-stream.c
359362
360363 nodist_libvirt_gobject_1_0_la_SOURCES = \
361364 $(GOBJECT_GENERATED_FILES)
485488 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-network-filter.Plo@am__quote@
486489 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-network.Plo@am__quote@
487490 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-node-device.Plo@am__quote@
491 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-output-stream.Plo@am__quote@
488492 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-secret.Plo@am__quote@
489493 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-storage-pool.Plo@am__quote@
490494 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-storage-vol.Plo@am__quote@
649653 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvirt-gobject-input-stream.c' object='libvirt_gobject_1_0_la-libvirt-gobject-input-stream.lo' libtool=yes @AMDEPBACKSLASH@
650654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
651655 @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvirt_gobject_1_0_la_CFLAGS) $(CFLAGS) -c -o libvirt_gobject_1_0_la-libvirt-gobject-input-stream.lo `test -f 'libvirt-gobject-input-stream.c' || echo '$(srcdir)/'`libvirt-gobject-input-stream.c
656
657 libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo: libvirt-gobject-output-stream.c
658 @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvirt_gobject_1_0_la_CFLAGS) $(CFLAGS) -MT libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo -MD -MP -MF $(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-output-stream.Tpo -c -o libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo `test -f 'libvirt-gobject-output-stream.c' || echo '$(srcdir)/'`libvirt-gobject-output-stream.c
659 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-output-stream.Tpo $(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-output-stream.Plo
660 @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libvirt-gobject-output-stream.c' object='libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo' libtool=yes @AMDEPBACKSLASH@
662 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
663 @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvirt_gobject_1_0_la_CFLAGS) $(CFLAGS) -c -o libvirt_gobject_1_0_la-libvirt-gobject-output-stream.lo `test -f 'libvirt-gobject-output-stream.c' || echo '$(srcdir)/'`libvirt-gobject-output-stream.c
652664
653665 libvirt_gobject_1_0_la-libvirt-gobject-enums.lo: libvirt-gobject-enums.c
654666 @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libvirt_gobject_1_0_la_CFLAGS) $(CFLAGS) -MT libvirt_gobject_1_0_la-libvirt-gobject-enums.lo -MD -MP -MF $(DEPDIR)/libvirt_gobject_1_0_la-libvirt-gobject-enums.Tpo -c -o libvirt_gobject_1_0_la-libvirt-gobject-enums.lo `test -f 'libvirt-gobject-enums.c' || echo '$(srcdir)/'`libvirt-gobject-enums.c
233233
234234 priv = conn->priv = GVIR_CONNECTION_GET_PRIVATE(conn);
235235
236 memset(priv, 0, sizeof(*priv));
237
238236 priv->lock = g_mutex_new();
237 priv->domains = g_hash_table_new_full(g_str_hash,
238 g_str_equal,
239 NULL,
240 g_object_unref);
241 priv->pools = g_hash_table_new_full(g_str_hash,
242 g_str_equal,
243 NULL,
244 g_object_unref);
239245 }
240246
241247
382388
383389 g_mutex_lock(priv->lock);
384390 if (priv->conn) {
385 *err = g_error_new(GVIR_CONNECTION_ERROR,
386 0,
387 "Connection %s is already open",
388 priv->uri);
391 if (err)
392 *err = g_error_new(GVIR_CONNECTION_ERROR,
393 0,
394 "Connection %s is already open",
395 priv->uri);
389396 g_mutex_unlock(priv->lock);
390397 return FALSE;
391398 }
392399
393400 if (!(priv->conn = virConnectOpen(priv->uri))) {
394 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
395 0,
396 "Unable to open %s",
397 priv->uri);
401 if (err)
402 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
403 0,
404 "Unable to open %s",
405 priv->uri);
398406 g_mutex_unlock(priv->lock);
399407 return FALSE;
400408 }
533541 gint i;
534542
535543 if ((n = count_func(vconn)) < 0) {
536 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
537 0,
538 "Unable to count %s", name);
544 if (err)
545 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
546 0,
547 "Unable to count %s", name);
539548 goto error;
540549 }
541550
545554
546555 lst = g_new(gchar *, n);
547556 if ((n = list_func(vconn, lst, n)) < 0) {
548 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
549 0,
550 "Unable to list %s %d", name, n);
557 if (err)
558 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
559 0,
560 "Unable to list %s %d", name, n);
551561 goto error;
552562 }
553563 }
580590 gboolean ret = FALSE;
581591 gint i;
582592 virConnectPtr vconn = NULL;
593 GError *lerr = NULL;
583594
584595 g_mutex_lock(priv->lock);
585596 if (!priv->conn) {
586 *err = g_error_new(GVIR_CONNECTION_ERROR,
587 0,
588 "Connection is not open");
597 if (err)
598 *err = g_error_new(GVIR_CONNECTION_ERROR,
599 0,
600 "Connection is not open");
589601 g_mutex_unlock(priv->lock);
590602 goto cleanup;
591603 }
598610 goto cleanup;
599611
600612 if ((nactive = virConnectNumOfDomains(vconn)) < 0) {
601 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
602 0,
603 "Unable to count domains");
613 if (err)
614 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
615 0,
616 "Unable to count domains");
604617 goto cleanup;
605618 }
606619 if (nactive) {
609622
610623 active = g_new(gint, nactive);
611624 if ((nactive = virConnectListDomains(vconn, active, nactive)) < 0) {
612 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
613 0,
614 "Unable to list domains");
625 if (err)
626 *err = gvir_error_new(GVIR_CONNECTION_ERROR,
627 0,
628 "Unable to list domains");
615629 goto cleanup;
616630 }
617631 }
625639 virConnectListDefinedDomains,
626640 cancellable,
627641 &ninactive,
628 err);
629 if (*err != NULL)
642 &lerr);
643 if (lerr) {
644 g_propagate_error(err, lerr);
645 lerr = NULL;
630646 goto cleanup;
647 }
631648
632649 doms = g_hash_table_new_full(g_str_hash,
633650 g_str_equal,
705722 gboolean ret = FALSE;
706723 gint i;
707724 virConnectPtr vconn = NULL;
725 GError *lerr = NULL;
708726
709727 g_mutex_lock(priv->lock);
710728 if (!priv->conn) {
711 *err = g_error_new(GVIR_CONNECTION_ERROR,
712 0,
713 "Connection is not open");
729 if (err)
730 *err = g_error_new(GVIR_CONNECTION_ERROR,
731 0,
732 "Connection is not open");
714733 g_mutex_unlock(priv->lock);
715734 goto cleanup;
716735 }
728747 virConnectListStoragePools,
729748 cancellable,
730749 &nactive,
731 err);
732 if (*err != NULL)
750 &lerr);
751 if (lerr) {
752 g_propagate_error(err, lerr);
753 lerr = NULL;
733754 goto cleanup;
755 }
734756
735757 if (g_cancellable_set_error_if_cancelled(cancellable, err))
736758 goto cleanup;
741763 virConnectListDefinedStoragePools,
742764 cancellable,
743765 &ninactive,
744 err);
745 if (*err != NULL)
766 &lerr);
767 if (lerr) {
768 g_propagate_error(err, lerr);
769 lerr = NULL;
746770 goto cleanup;
771 }
747772
748773 pools = g_hash_table_new_full(g_str_hash,
749774 g_str_equal,
11441169 * Return value: (transfer full): a #GVirStream stream, or NULL
11451170 */
11461171 GVirStream *gvir_connection_get_stream(GVirConnection *self,
1147 gint flags)
1172 guint flags)
11481173 {
11491174 GVirConnectionClass *klass;
11501175
11611186
11621187 /**
11631188 * gvir_connection_create_domain:
1164 * @conn: the connection on which to create the dmain
1189 * @conn: the connection on which to create the domain
11651190 * @conf: the configuration for the new domain
1191 *
1192 * Create the configuration file for a new persistent domain.
1193 * The returned domain will initially be in the shutoff state.
1194 *
11661195 * Returns: (transfer full): the newly created domain
11671196 */
11681197 GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
11691198 GVirConfigDomain *conf,
11701199 GError **err)
11711200 {
1172 const gchar *xml;
1201 gchar *xml;
11731202 virDomainPtr handle;
11741203 GVirConnectionPrivate *priv = conn->priv;
11751204
11771206
11781207 g_return_val_if_fail(xml != NULL, NULL);
11791208
1180 if (!(handle = virDomainDefineXML(priv->conn, xml))) {
1181 *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
1182 0,
1183 "Failed to create domain");
1209 handle = virDomainDefineXML(priv->conn, xml);
1210 g_free(xml);
1211 if (!handle) {
1212 if (err)
1213 *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
1214 0,
1215 "Failed to create domain");
11841216 return NULL;
11851217 }
11861218
11931225 g_mutex_lock(priv->lock);
11941226 g_hash_table_insert(priv->domains,
11951227 (gpointer)gvir_domain_get_uuid(domain),
1196 domain);
1197 g_mutex_unlock(priv->lock);
1198
1199 return g_object_ref(domain);
1228 g_object_ref(domain));
1229 g_mutex_unlock(priv->lock);
1230
1231 return domain;
1232 }
1233
1234 /**
1235 * gvir_connection_start_domain:
1236 * @conn: the connection on which to create the domain
1237 * @conf: the configuration for the new domain
1238 *
1239 * Start a new transient domain without persistent configuration.
1240 * The returned domain will initially be running.
1241 *
1242 * Returns: (transfer full): the newly created domain
1243 */
1244 GVirDomain *gvir_connection_start_domain(GVirConnection *conn,
1245 GVirConfigDomain *conf,
1246 guint flags,
1247 GError **err)
1248 {
1249 gchar *xml;
1250 virDomainPtr handle;
1251 GVirConnectionPrivate *priv = conn->priv;
1252
1253 xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
1254
1255 g_return_val_if_fail(xml != NULL, NULL);
1256
1257 handle = virDomainCreateXML(priv->conn, xml, flags);
1258 g_free(xml);
1259 if (!handle) {
1260 if (err)
1261 *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
1262 0,
1263 "Failed to create domain");
1264 return NULL;
1265 }
1266
1267 GVirDomain *domain;
1268
1269 domain = GVIR_DOMAIN(g_object_new(GVIR_TYPE_DOMAIN,
1270 "handle", handle,
1271 NULL));
1272
1273 g_mutex_lock(priv->lock);
1274 g_hash_table_insert(priv->domains,
1275 (gpointer)gvir_domain_get_uuid(domain),
1276 g_object_ref(domain));
1277 g_mutex_unlock(priv->lock);
1278
1279 return domain;
12001280 }
12011281
12021282 /**
12111291 GVirStoragePool *gvir_connection_create_storage_pool
12121292 (GVirConnection *conn,
12131293 GVirConfigStoragePool *conf,
1214 guint64 flags G_GNUC_UNUSED,
1294 guint flags,
12151295 GError **err) {
12161296 const gchar *xml;
12171297 virStoragePoolPtr handle;
12211301
12221302 g_return_val_if_fail(xml != NULL, NULL);
12231303
1224 if (!(handle = virStoragePoolDefineXML(priv->conn, xml, 0))) {
1225 *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
1226 flags,
1227 "Failed to create storage pool");
1304 if (!(handle = virStoragePoolDefineXML(priv->conn, xml, flags))) {
1305 if (err)
1306 *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
1307 flags,
1308 "Failed to create storage pool");
12281309 return NULL;
12291310 }
12301311
109109 GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
110110 GVirConfigDomain *conf,
111111 GError **err);
112 GVirDomain *gvir_connection_start_domain(GVirConnection *conn,
113 GVirConfigDomain *conf,
114 guint flags,
115 GError **err);
112116
113117 #if 0
114118 GList *gvir_connection_get_interfaces(GVirConnection *conn);
162166 GVirStoragePool *gvir_connection_create_storage_pool
163167 (GVirConnection *conn,
164168 GVirConfigStoragePool *conf,
165 guint64 flags,
169 guint flags,
166170 GError **err);
167171
168172
169173 GVirStream *gvir_connection_get_stream(GVirConnection *conn,
170 gint flags);
174 guint flags);
171175
172176 G_END_DECLS
173177
196196 */
197197 GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
198198 (GVirDomainSnapshot *snapshot,
199 guint64 flags,
199 guint flags,
200200 GError **err)
201201 {
202202 GVirDomainSnapshotPrivate *priv = snapshot->priv;
209209 return NULL;
210210 }
211211
212 #if 0
213 GVirConfigDomainSnapshot *conf = gvir_config_domain_snapshot_new(xml);
214
215 g_free(xml);
212 GVirConfigDomainSnapshot *conf = gvir_config_domain_snapshot_new_from_xml(xml, err);
213
214 free(xml);
216215 return conf;
217 #endif
218 return NULL;
219 }
216 }
6565
6666 GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config
6767 (GVirDomainSnapshot *snapshot,
68 guint64 flags,
68 guint flags,
6969 GError **err);
7070
7171 G_END_DECLS
286286 gint ret;
287287
288288 if ((ret = virDomainGetID(priv->handle)) < 0) {
289 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
290 0,
291 "Unable to get ID for domain");
289 if (err)
290 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
291 0,
292 "Unable to get ID for domain");
292293 }
293294 return ret;
294295 }
300301 * @flags: the flags
301302 */
302303 gboolean gvir_domain_start(GVirDomain *dom,
303 guint64 flags G_GNUC_UNUSED,
304 guint flags,
304305 GError **err)
305306 {
306307 GVirDomainPrivate *priv = dom->priv;
307
308 if (virDomainCreate(priv->handle) < 0) {
309 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
310 0,
311 "Unable to start domain");
308 int ret;
309
310 if (flags)
311 ret = virDomainCreateWithFlags(priv->handle, flags);
312 else
313 ret = virDomainCreate(priv->handle);
314 if (ret < 0) {
315 if (err)
316 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
317 0,
318 "Unable to start domain");
312319 return FALSE;
313320 }
314321
327334 GVirDomainPrivate *priv = dom->priv;
328335
329336 if (virDomainResume(priv->handle) < 0) {
330 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
331 0,
332 "Unable to resume domain");
337 if (err)
338 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
339 0,
340 "Unable to resume domain");
333341 return FALSE;
334342 }
335343
342350 * @flags: the flags
343351 */
344352 gboolean gvir_domain_stop(GVirDomain *dom,
345 guint64 flags G_GNUC_UNUSED,
353 guint flags,
346354 GError **err)
347355 {
348356 GVirDomainPrivate *priv = dom->priv;
349
350 if (virDomainDestroy(priv->handle) < 0) {
351 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
352 0,
353 "Unable to stop domain");
357 int ret;
358
359 if (flags)
360 ret = virDomainDestroyFlags(priv->handle, flags);
361 else
362 ret = virDomainDestroy(priv->handle);
363 if (ret < 0) {
364 if (err)
365 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
366 0,
367 "Unable to stop domain");
354368 return FALSE;
355369 }
356370
363377 * @flags: the flags
364378 */
365379 gboolean gvir_domain_delete(GVirDomain *dom,
366 guint64 flags G_GNUC_UNUSED,
380 guint flags,
367381 GError **err)
368382 {
369383 GVirDomainPrivate *priv = dom->priv;
370
371 if (virDomainUndefine(priv->handle) < 0) {
372 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
373 0,
374 "Unable to delete domain");
384 int ret;
385
386 if (flags)
387 ret = virDomainUndefineFlags(priv->handle, flags);
388 else
389 ret = virDomainUndefine(priv->handle);
390 if (ret < 0) {
391 if (err)
392 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
393 0,
394 "Unable to delete domain");
375395 return FALSE;
376396 }
377397
384404 * @flags: the flags
385405 */
386406 gboolean gvir_domain_shutdown(GVirDomain *dom,
387 guint64 flags G_GNUC_UNUSED,
407 guint flags G_GNUC_UNUSED,
388408 GError **err)
389409 {
390410 GVirDomainPrivate *priv = dom->priv;
391411
392412 if (virDomainShutdown(priv->handle) < 0) {
393 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
394 0,
395 "Unable to shutdown domain");
413 if (err)
414 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
415 0,
416 "Unable to shutdown domain");
396417 return FALSE;
397418 }
398419
405426 * @flags: the flags
406427 */
407428 gboolean gvir_domain_reboot(GVirDomain *dom,
408 guint64 flags,
429 guint flags,
409430 GError **err)
410431 {
411432 GVirDomainPrivate *priv = dom->priv;
412433
413434 if (virDomainReboot(priv->handle, flags) < 0) {
414 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
415 0,
416 "Unable to reboot domain");
435 if (err)
436 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
437 0,
438 "Unable to reboot domain");
417439 return FALSE;
418440 }
419441
427449 * Returns: (transfer full): the config
428450 */
429451 GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
430 guint64 flags,
452 guint flags,
431453 GError **err)
432454 {
433455 GVirDomainPrivate *priv = dom->priv;
434456 gchar *xml;
435457
436458 if (!(xml = virDomainGetXMLDesc(priv->handle, flags))) {
437 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
438 0,
439 "Unable to get domain XML config");
459 if (err)
460 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
461 0,
462 "Unable to get domain XML config");
440463 return NULL;
441464 }
442465
448471 return conf;
449472 }
450473
474 /**
475 * gvir_domain_set_config:
476 * @domain: the domain
477 * @conf: the new configuration for the domain
478 * @err: (allow-none): Place-holder for error or NULL
479 *
480 * Resets configuration of an existing domain.
481 *
482 * Note: If domain is already running, the new configuration will not take
483 * affect until domain reboots.
484 *
485 * Returns: TRUE on success, FALSE if an error occurred.
486 */
487 gboolean gvir_domain_set_config(GVirDomain *domain,
488 GVirConfigDomain *conf,
489 GError **err)
490 {
491 gchar *xml;
492 virConnectPtr conn;
493 virDomainPtr handle;
494 gchar uuid[VIR_UUID_STRING_BUFLEN];
495 GVirDomainPrivate *priv = domain->priv;
496
497 g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE);
498 g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE);
499 g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
500
501 xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
502
503 g_return_val_if_fail(xml != NULL, FALSE);
504
505 if ((conn = virDomainGetConnect(priv->handle)) == NULL) {
506 if (err != NULL)
507 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
508 0,
509 "Failed to get domain connection");
510 g_free (xml);
511
512 return FALSE;
513 }
514
515 handle = virDomainDefineXML(conn, xml);
516 g_free (xml);
517
518 if (handle == NULL) {
519 if (err != NULL)
520 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
521 0,
522 "Failed to set "
523 "domain configuration");
524 return FALSE;
525 }
526
527 virDomainGetUUIDString(handle, uuid);
528 virDomainFree(handle);
529
530 if (g_strcmp0 (uuid, priv->uuid) != 0) {
531 if (err != NULL)
532 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
533 0,
534 "Failed to set "
535 "domain configuration");
536
537 return FALSE;
538 }
539
540 return TRUE;
541 }
451542
452543 /**
453544 * gvir_domain_get_info:
462553 GVirDomainInfo *ret;
463554
464555 if (virDomainGetInfo(priv->handle, &info) < 0) {
465 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
466 0,
467 "Unable to get domain info");
556 if (err)
557 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
558 0,
559 "Unable to get domain info");
468560 return NULL;
469561 }
470562
488580 */
489581 gchar *gvir_domain_screenshot(GVirDomain *dom,
490582 GVirStream *stream,
491 guint64 monitor_id,
492 guint64 flags,
583 guint monitor_id,
584 guint flags,
493585 GError **err)
494586 {
495587 GVirDomainPrivate *priv;
506598 st,
507599 monitor_id,
508600 flags))) {
509 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
510 0,
511 "Unable to take a screenshot");
601 if (err)
602 *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR,
603 0,
604 "Unable to take a screenshot");
512605 goto end;
513606 }
514607 end:
9999 GError **err);
100100
101101 gboolean gvir_domain_start(GVirDomain *dom,
102 guint64 flags,
102 guint flags,
103103 GError **err);
104104 gboolean gvir_domain_resume(GVirDomain *dom,
105105 GError **err);
106106 gboolean gvir_domain_stop(GVirDomain *dom,
107 guint64 flags,
107 guint flags,
108108 GError **err);
109109 gboolean gvir_domain_delete(GVirDomain *dom,
110 guint64 flags,
110 guint flags,
111111 GError **err);
112112 gboolean gvir_domain_shutdown(GVirDomain *dom,
113 guint64 flags,
113 guint flags,
114114 GError **err);
115115 gboolean gvir_domain_reboot(GVirDomain *dom,
116 guint64 flags,
116 guint flags,
117117 GError **err);
118118
119119 GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom,
120120 GError **err);
121121
122122 GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom,
123 guint64 flags,
123 guint flags,
124124 GError **err);
125 gboolean gvir_domain_set_config(GVirDomain *domain,
126 GVirConfigDomain *conf,
127 GError **err);
125128
126129 gchar *gvir_domain_screenshot(GVirDomain *dom,
127130 GVirStream *stream,
128 guint64 monitor_id,
129 guint64 flags,
131 guint monitor_id,
132 guint flags,
130133 GError **err);
131134
132135 G_END_DECLS
185185 * Returns: (transfer full): the config
186186 */
187187 GVirConfigInterface *gvir_interface_get_config(GVirInterface *iface,
188 guint64 flags,
188 guint flags,
189189 GError **err)
190190 {
191191 GVirInterfacePrivate *priv = iface->priv;
192192 gchar *xml;
193193
194194 if (!(xml = virInterfaceGetXMLDesc(priv->handle, flags))) {
195 *err = gvir_error_new_literal(GVIR_INTERFACE_ERROR,
196 0,
197 "Unable to get interface XML config");
195 if (err)
196 *err = gvir_error_new_literal(GVIR_INTERFACE_ERROR,
197 0,
198 "Unable to get interface XML config");
198199 return NULL;
199200 }
200201
201 #if 0
202 GVirConfigInterface *conf = gvir_config_interface_new(xml);
203
204 g_free(xml);
202 GVirConfigInterface *conf = gvir_config_interface_new_from_xml(xml, err);
203
204 free(xml);
205205 return conf;
206 #endif
207 return NULL;
208 }
206 }
6464 const gchar *gvir_interface_get_name(GVirInterface *iface);
6565
6666 GVirConfigInterface *gvir_interface_get_config(GVirInterface *iface,
67 guint64 flags,
67 guint flags,
6868 GError **err);
6969
7070 G_END_DECLS
211211 */
212212 GVirConfigNetworkFilter *gvir_network_filter_get_config
213213 (GVirNetworkFilter *filter,
214 guint64 flags,
214 guint flags,
215215 GError **err)
216216 {
217217 GVirNetworkFilterPrivate *priv = filter->priv;
218218 gchar *xml;
219219
220220 if (!(xml = virNWFilterGetXMLDesc(priv->handle, flags))) {
221 *err = gvir_error_new_literal(GVIR_NETWORK_FILTER_ERROR,
222 0,
223 "Unable to get network_filter XML config");
221 if (err)
222 *err = gvir_error_new_literal(GVIR_NETWORK_FILTER_ERROR,
223 0,
224 "Unable to get network_filter XML config");
224225 return NULL;
225226 }
226227
227 #if 0
228 GVirConfigNetworkFilter *conf = gvir_config_network_filter_new(xml);
229
230 g_free(xml);
228 GVirConfigNetworkFilter *conf = gvir_config_network_filter_new_from_xml(xml, err);
229
230 free(xml);
231231 return conf;
232 #endif
233 return NULL;
234 }
232 }
6565
6666 GVirConfigNetworkFilter *gvir_network_filter_get_config
6767 (GVirNetworkFilter *filter,
68 guint64 flags,
68 guint flags,
6969 GError **err);
7070
7171 G_END_DECLS
207207 * Returns: (transfer full): the config
208208 */
209209 GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network,
210 guint64 flags,
210 guint flags,
211211 GError **err)
212212 {
213213 GVirNetworkPrivate *priv = network->priv;
214214 gchar *xml;
215215
216216 if (!(xml = virNetworkGetXMLDesc(priv->handle, flags))) {
217 *err = gvir_error_new_literal(GVIR_NETWORK_ERROR,
218 0,
219 "Unable to get network XML config");
217 if (err)
218 *err = gvir_error_new_literal(GVIR_NETWORK_ERROR,
219 0,
220 "Unable to get network XML config");
220221 return NULL;
221222 }
222223
223 #if 0
224 GVirConfigNetwork *conf = gvir_config_network_new(xml);
225
226 g_free(xml);
224 GVirConfigNetwork *conf = gvir_config_network_new_from_xml(xml, err);
225
226 free(xml);
227227 return conf;
228 #endif
229 return NULL;
230 }
228 }
6868 const gchar *gvir_network_get_uuid(GVirNetwork *network);
6969
7070 GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network,
71 guint64 flags,
71 guint flags,
7272 GError **err);
7373
7474 G_END_DECLS
186186 * Returns: (transfer full): the config
187187 */
188188 GVirConfigNodeDevice *gvir_node_device_get_config(GVirNodeDevice *device,
189 guint64 flags,
189 guint flags,
190190 GError **err)
191191 {
192192 GVirNodeDevicePrivate *priv = device->priv;
193193 gchar *xml;
194194
195195 if (!(xml = virNodeDeviceGetXMLDesc(priv->handle, flags))) {
196 *err = gvir_error_new_literal(GVIR_NODE_DEVICE_ERROR,
197 0,
198 "Unable to get node_device XML config");
196 if (err)
197 *err = gvir_error_new_literal(GVIR_NODE_DEVICE_ERROR,
198 0,
199 "Unable to get node_device XML config");
199200 return NULL;
200201 }
201202
202 #if 0
203 GVirConfigNodeDevice *conf = gvir_config_node_device_new(xml);
204
205 g_free(xml);
203 GVirConfigNodeDevice *conf = gvir_config_node_device_new_from_xml(xml, err);
204
205 free(xml);
206206 return conf;
207 #endif
208
209 return NULL;
210 }
207 }
6363 const gchar *gvir_node_device_get_name(GVirNodeDevice *device);
6464
6565 GVirConfigNodeDevice *gvir_node_device_get_config(GVirNodeDevice *device,
66 guint64 flags,
66 guint flags,
6767 GError **err);
6868
6969 G_END_DECLS
0 /*
1 * libvirt-gobject-output-stream.h: libvirt gobject integration
2 *
3 * Copyright (C) 2011 Red Hat
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Daniel P. Berrange <berrange@redhat.com>
20 * Marc-André Lureau <marcandre.lureau@redhat.com>
21 */
22
23 #include <config.h>
24
25 #include <libvirt/virterror.h>
26 #include <string.h>
27
28 #include "libvirt-glib/libvirt-glib.h"
29 #include "libvirt-gobject/libvirt-gobject.h"
30 #include "libvirt-gobject-output-stream.h"
31
32 extern gboolean debugFlag;
33
34 #define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0)
35
36 #define gvir_output_stream_get_type _gvir_output_stream_get_type
37 G_DEFINE_TYPE(GVirOutputStream, gvir_output_stream, G_TYPE_OUTPUT_STREAM);
38
39 enum
40 {
41 PROP_0,
42 PROP_STREAM
43 };
44
45 struct _GVirOutputStreamPrivate
46 {
47 GVirStream *stream;
48
49 /* pending operation metadata */
50 GSimpleAsyncResult *result;
51 GCancellable *cancellable;
52 const void * buffer;
53 gsize count;
54 };
55
56 static void gvir_output_stream_get_property(GObject *object,
57 guint prop_id,
58 GValue *value,
59 GParamSpec *pspec)
60 {
61 GVirOutputStream *stream = GVIR_OUTPUT_STREAM(object);
62
63 switch (prop_id) {
64 case PROP_STREAM:
65 g_value_set_object(value, stream->priv->stream);
66 break;
67
68 default:
69 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
70 }
71 }
72
73 static void gvir_output_stream_set_property(GObject *object,
74 guint prop_id,
75 const GValue *value,
76 GParamSpec *pspec)
77 {
78 GVirOutputStream *stream = GVIR_OUTPUT_STREAM(object);
79
80 switch (prop_id) {
81 case PROP_STREAM:
82 stream->priv->stream = g_value_get_object(value);
83 break;
84
85 default:
86 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
87 }
88 }
89
90 static void gvir_output_stream_finalize(GObject *object)
91 {
92 GVirOutputStream *stream = GVIR_OUTPUT_STREAM(object);
93
94 DEBUG("Finalize output stream GVirStream=%p", stream->priv->stream);
95 stream->priv->stream = NULL; // unowned
96
97 if (G_OBJECT_CLASS(gvir_output_stream_parent_class)->finalize)
98 (*G_OBJECT_CLASS(gvir_output_stream_parent_class)->finalize)(object);
99 }
100
101 static void
102 gvir_output_stream_write_ready(virStreamPtr st G_GNUC_UNUSED,
103 int events,
104 void *opaque)
105 {
106 GVirOutputStream *stream = GVIR_OUTPUT_STREAM(opaque);
107 GVirOutputStreamPrivate *priv = stream->priv;
108 GSimpleAsyncResult *simple;
109 GError *error = NULL;
110 gssize result;
111
112 g_return_if_fail(events & VIR_STREAM_EVENT_WRITABLE);
113
114 result = gvir_stream_send(priv->stream, priv->buffer, priv->count,
115 priv->cancellable, &error);
116
117 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
118 g_warn_if_reached();
119 return;
120 }
121
122 simple = stream->priv->result;
123 stream->priv->result = NULL;
124
125 if (result >= 0)
126 g_simple_async_result_set_op_res_gssize(simple, result);
127
128 if (error)
129 g_simple_async_result_take_error(simple, error);
130
131 if (priv->cancellable) {
132 g_object_unref(stream->priv->cancellable);
133 priv->cancellable = NULL;
134 }
135
136 g_simple_async_result_complete(simple);
137 g_object_unref(simple);
138
139 return;
140 }
141
142 static void gvir_output_stream_write_async(GOutputStream *stream,
143 const void *buffer,
144 gsize count,
145 int io_priority G_GNUC_UNUSED,
146 GCancellable *cancellable,
147 GAsyncReadyCallback callback,
148 gpointer user_data)
149 {
150 GVirOutputStream *output_stream = GVIR_OUTPUT_STREAM(stream);
151 virStreamPtr handle;
152
153 g_return_if_fail(GVIR_IS_OUTPUT_STREAM(stream));
154 g_return_if_fail(output_stream->priv->result == NULL);
155
156 g_object_get(output_stream->priv->stream, "handle", &handle, NULL);
157
158 if (virStreamEventAddCallback(handle, VIR_STREAM_EVENT_WRITABLE,
159 gvir_output_stream_write_ready, stream, NULL) < 0) {
160 g_simple_async_report_error_in_idle(G_OBJECT(stream),
161 callback,
162 user_data,
163 G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
164 "Couldn't add event callback %s",
165 G_STRFUNC);
166 goto end;
167 }
168
169 output_stream->priv->result =
170 g_simple_async_result_new(G_OBJECT(stream), callback, user_data,
171 gvir_output_stream_write_async);
172 if (cancellable)
173 g_object_ref(cancellable);
174 output_stream->priv->cancellable = cancellable;
175 output_stream->priv->buffer = buffer;
176 output_stream->priv->count = count;
177
178 end:
179 virStreamFree(handle);
180 }
181
182
183 static gssize gvir_output_stream_write_finish(GOutputStream *stream,
184 GAsyncResult *result,
185 GError **error G_GNUC_UNUSED)
186 {
187 GVirOutputStream *output_stream = GVIR_OUTPUT_STREAM(stream);
188 GSimpleAsyncResult *simple;
189 virStreamPtr handle;
190 gssize count;
191
192 g_return_val_if_fail(GVIR_IS_OUTPUT_STREAM(stream), -1);
193 g_object_get(output_stream->priv->stream, "handle", &handle, NULL);
194
195 simple = G_SIMPLE_ASYNC_RESULT(result);
196
197 g_warn_if_fail(g_simple_async_result_get_source_tag(simple) == gvir_output_stream_write_async);
198
199 count = g_simple_async_result_get_op_res_gssize(simple);
200
201 virStreamEventRemoveCallback(handle);
202 virStreamFree(handle);
203
204 return count;
205 }
206
207
208 static void gvir_output_stream_class_init(GVirOutputStreamClass *klass)
209 {
210 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
211 GOutputStreamClass *goutputstream_class = G_OUTPUT_STREAM_CLASS(klass);
212
213 g_type_class_add_private(klass, sizeof(GVirOutputStreamPrivate));
214
215 gobject_class->finalize = gvir_output_stream_finalize;
216 gobject_class->get_property = gvir_output_stream_get_property;
217 gobject_class->set_property = gvir_output_stream_set_property;
218
219 goutputstream_class->write_fn = NULL;
220 goutputstream_class->write_async = gvir_output_stream_write_async;
221 goutputstream_class->write_finish = gvir_output_stream_write_finish;
222
223 g_object_class_install_property(gobject_class, PROP_STREAM,
224 g_param_spec_object("stream",
225 "stream",
226 "GVirStream",
227 GVIR_TYPE_STREAM, G_PARAM_CONSTRUCT_ONLY |
228 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229 }
230
231 static void gvir_output_stream_init(GVirOutputStream *stream)
232 {
233 stream->priv = G_TYPE_INSTANCE_GET_PRIVATE(stream, GVIR_TYPE_OUTPUT_STREAM, GVirOutputStreamPrivate);
234 }
235
236 GVirOutputStream* _gvir_output_stream_new(GVirStream *stream)
237 {
238 return GVIR_OUTPUT_STREAM(g_object_new(GVIR_TYPE_OUTPUT_STREAM, "stream", stream, NULL));
239 }
0 /*
1 * libvirt-gobject-output-stream.h: libvirt gobject integration
2 *
3 * Copyright (C) 2011 Red Hat
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Daniel P. Berrange <berrange@redhat.com>
20 * Marc-André Lureau <marcandre.lureau@redhat.com>
21 */
22
23 #if !defined(__LIBVIRT_GOBJECT_H__) && !defined(LIBVIRT_GOBJECT_BUILD)
24 #error "Only <libvirt-gobject/libvirt-gobject.h> can be included directly."
25 #endif
26
27 #ifndef __LIBVIRT_GOBJECT_OUTPUT_STREAM_H__
28 #define __LIBVIRT_GOBJECT_OUTPUT_STREAM_H__
29
30 #include <gio/gio.h>
31 #include "libvirt-gobject-stream.h"
32
33 G_BEGIN_DECLS
34
35 #define GVIR_TYPE_OUTPUT_STREAM (_gvir_output_stream_get_type ())
36 #define GVIR_OUTPUT_STREAM(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
37 GVIR_TYPE_OUTPUT_STREAM, GVirOutputStream))
38 #define GVIR_OUTPUT_STREAM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
39 GVIR_TYPE_OUTPUT_STREAM, GVirOutputStreamClass))
40 #define GVIR_IS_OUTPUT_STREAM(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
41 GVIR_TYPE_OUTPUT_STREAM))
42 #define GVIR_IS_OUTPUT_STREAM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
43 GVIR_TYPE_OUTPUT_STREAM))
44 #define GVIR_OUTPUT_STREAM_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
45 GVIR_TYPE_OUTPUT_STREAM, GVirOutputStreamClass))
46
47 typedef struct _GVirOutputStreamPrivate GVirOutputStreamPrivate;
48 typedef struct _GVirOutputStreamClass GVirOutputStreamClass;
49 typedef struct _GVirOutputStream GVirOutputStream;
50
51 struct _GVirOutputStreamClass
52 {
53 GOutputStreamClass parent_class;
54 };
55
56 struct _GVirOutputStream
57 {
58 GOutputStream parent_instance;
59 GVirOutputStreamPrivate *priv;
60 };
61
62 GType _gvir_output_stream_get_type (void) G_GNUC_CONST;
63 GVirOutputStream * _gvir_output_stream_new (GVirStream *stream);
64
65 G_END_DECLS
66
67 #endif /* __LIBVIRT_GOBJECT_OUTPUT_STREAM_H__ */
197197 * Returns: (transfer full): the config
198198 */
199199 GVirConfigSecret *gvir_secret_get_config(GVirSecret *secret,
200 guint64 flags,
200 guint flags,
201201 GError **err)
202202 {
203203 GVirSecretPrivate *priv = secret->priv;
204204 gchar *xml;
205205
206206 if (!(xml = virSecretGetXMLDesc(priv->handle, flags))) {
207 *err = gvir_error_new_literal(GVIR_SECRET_ERROR,
208 0,
209 "Unable to get secret XML config");
207 if (err)
208 *err = gvir_error_new_literal(GVIR_SECRET_ERROR,
209 0,
210 "Unable to get secret XML config");
210211 return NULL;
211212 }
212213
213 #if 0
214 GVirConfigSecret *conf = gvir_config_secret_new(xml);
215
216 g_free(xml);
214 GVirConfigSecret *conf = gvir_config_secret_new_from_xml(xml, err);
215
216 free(xml);
217217 return conf;
218 #endif
219
220 return NULL;
221 }
218 }
6565 const gchar *gvir_secret_get_uuid(GVirSecret *secret);
6666
6767 GVirConfigSecret *gvir_secret_get_config(GVirSecret *secret,
68 guint64 flags,
68 guint flags,
6969 GError **err);
7070
7171 G_END_DECLS
222222 * Returns: (transfer full): the config
223223 */
224224 GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
225 guint64 flags,
225 guint flags,
226226 GError **err)
227227 {
228228 GVirStoragePoolPrivate *priv = pool->priv;
229229 gchar *xml;
230230
231231 if (!(xml = virStoragePoolGetXMLDesc(priv->handle, flags))) {
232 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
233 0,
234 "Unable to get storage_pool XML config");
232 if (err)
233 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
234 0,
235 "Unable to get storage_pool XML config");
235236 return NULL;
236237 }
237238
238 #if 0
239 GVirConfigStoragePool *conf = gvir_config_storage_pool_new(xml);
240
241 g_free(xml);
239 GVirConfigStoragePool *conf = gvir_config_storage_pool_new_from_xml(xml, err);
240
241 free(xml);
242242 return conf;
243 #endif
244 return NULL;
245243 }
246244
247245 typedef gint (* CountFunction) (virStoragePoolPtr vpool);
305303 gboolean ret = FALSE;
306304 gint i;
307305 virStoragePoolPtr vpool = NULL;
306 GError *lerr = NULL;
308307
309308 vpool = priv->handle;
310309
311310 if (virStoragePoolRefresh(vpool, 0) < 0) {
312 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
313 0,
314 "Unable to refresh storage pool");
311 if (err)
312 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
313 0,
314 "Unable to refresh storage pool");
315315 goto cleanup;
316316 }
317317
318318 volumes = fetch_list(vpool,
319 "Storage Volumes",
320 virStoragePoolNumOfVolumes,
321 virStoragePoolListVolumes,
322 cancellable,
323 &nvolumes,
324 err);
325 if (*err != NULL)
319 "Storage Volumes",
320 virStoragePoolNumOfVolumes,
321 virStoragePoolListVolumes,
322 cancellable,
323 &nvolumes,
324 &lerr);
325 if (lerr) {
326 g_propagate_error(err, lerr);
327 lerr = NULL;
326328 goto cleanup;
329 }
327330
328331 if (g_cancellable_set_error_if_cancelled(cancellable, err))
329332 goto cleanup;
497500 g_return_val_if_fail(xml != NULL, NULL);
498501
499502 if (!(handle = virStorageVolCreateXML(priv->handle, xml, 0))) {
500 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
501 0,
502 "Failed to create volume");
503 if (err)
504 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
505 0,
506 "Failed to create volume");
503507 return NULL;
504508 }
505509
527531 * Return value: #True on success, #False otherwise.
528532 */
529533 gboolean gvir_storage_pool_build (GVirStoragePool *pool,
530 guint64 flags,
534 guint flags,
531535 GError **err)
532536 {
533537 if (virStoragePoolBuild(pool->priv->handle, flags)) {
534 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
535 0,
536 "Failed to build storage pool");
538 if (err)
539 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
540 0,
541 "Failed to build storage pool");
537542 return FALSE;
538543 }
539544
541546 }
542547
543548 typedef struct {
544 guint64 flags;
549 guint flags;
545550 } StoragePoolBuildData;
546551
547552 static void
573578 * @user_data: (closure): opaque data for callback
574579 */
575580 void gvir_storage_pool_build_async (GVirStoragePool *pool,
576 guint64 flags,
581 guint flags,
577582 GCancellable *cancellable,
578583 GAsyncReadyCallback callback,
579584 gpointer user_data)
631636 * Return value: #True on success, #False otherwise.
632637 */
633638 gboolean gvir_storage_pool_start (GVirStoragePool *pool,
634 guint64 flags,
639 guint flags,
635640 GError **err)
636641 {
637642 if (virStoragePoolCreate(pool->priv->handle, flags)) {
638 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
639 0,
640 "Failed to start storage pool");
643 if (err)
644 *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR,
645 0,
646 "Failed to start storage pool");
641647 return FALSE;
642648 }
643649
673679 * @user_data: (closure): opaque data for callback
674680 */
675681 void gvir_storage_pool_start_async (GVirStoragePool *pool,
676 guint64 flags,
682 guint flags,
677683 GCancellable *cancellable,
678684 GAsyncReadyCallback callback,
679685 gpointer user_data)
6565 const gchar *gvir_storage_pool_get_uuid(GVirStoragePool *pool);
6666
6767 GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool,
68 guint64 flags,
68 guint flags,
6969 GError **err);
7070
7171 gboolean gvir_storage_pool_refresh(GVirStoragePool *pool,
8888 GError **err);
8989
9090 gboolean gvir_storage_pool_build (GVirStoragePool *pool,
91 guint64 flags,
91 guint flags,
9292 GError **err);
9393 void gvir_storage_pool_build_async (GVirStoragePool *pool,
94 guint64 flags,
94 guint flags,
9595 GCancellable *cancellable,
9696 GAsyncReadyCallback callback,
9797 gpointer user_data);
100100 GError **err);
101101
102102 gboolean gvir_storage_pool_start (GVirStoragePool *pool,
103 guint64 flags,
103 guint flags,
104104 GError **err);
105105 void gvir_storage_pool_start_async (GVirStoragePool *pool,
106 guint64 flags,
106 guint flags,
107107 GCancellable *cancellable,
108108 GAsyncReadyCallback callback,
109109 gpointer user_data);
197197 * Returns: (transfer full): the config
198198 */
199199 GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
200 guint64 flags,
200 guint flags,
201201 GError **err)
202202 {
203203 GVirStorageVolPrivate *priv = vol->priv;
204204 gchar *xml;
205205
206206 if (!(xml = virStorageVolGetXMLDesc(priv->handle, flags))) {
207 *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR,
208 0,
209 "Unable to get storage_vol XML config");
207 if (err)
208 *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR,
209 0,
210 "Unable to get storage_vol XML config");
210211 return NULL;
211212 }
212213
213 #if 0
214 GVirConfigStorageVol *conf = gvir_config_storage_vol_new(xml);
215
216 g_free(xml);
214 GVirConfigStorageVol *conf = gvir_config_storage_vol_new_from_xml(xml, err);
215
216 free(xml);
217217 return conf;
218 #endif
219 return NULL;
220 }
218 }
6464 const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol);
6565
6666 GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol,
67 guint64 flags,
67 guint flags,
6868 GError **err);
6969
7070 G_END_DECLS
3131 #include "libvirt-gobject-compat.h"
3232
3333 #include "libvirt-gobject/libvirt-gobject-input-stream.h"
34 #include "libvirt-gobject/libvirt-gobject-output-stream.h"
3435
3536 extern gboolean debugFlag;
3637
4344 {
4445 virStreamPtr handle;
4546 GInputStream *input_stream;
46 gboolean in_dispose;
47 GOutputStream *output_stream;
4748 };
4849
4950 G_DEFINE_TYPE(GVirStream, gvir_stream, G_TYPE_IO_STREAM);
7677 }
7778
7879
80 static GOutputStream* gvir_stream_get_output_stream(GIOStream *io_stream)
81 {
82 GVirStream *self = GVIR_STREAM(io_stream);
83
84 if (self->priv->output_stream == NULL)
85 self->priv->output_stream = (GOutputStream *)_gvir_output_stream_new(self);
86
87 return self->priv->output_stream;
88 }
89
90
7991 static gboolean gvir_stream_close(GIOStream *io_stream,
8092 GCancellable *cancellable, G_GNUC_UNUSED GError **error)
8193 {
8496 if (self->priv->input_stream)
8597 g_input_stream_close(self->priv->input_stream, cancellable, NULL);
8698
87 if (self->priv->in_dispose)
88 return TRUE;
99 if (self->priv->output_stream)
100 g_output_stream_close(self->priv->output_stream, cancellable, NULL);
89101
90102 return TRUE; /* FIXME: really close the stream? */
91103 }
200212 object_class->set_property = gvir_stream_set_property;
201213
202214 stream_class->get_input_stream = gvir_stream_get_input_stream;
215 stream_class->get_output_stream = gvir_stream_get_output_stream;
203216 stream_class->close_fn = gvir_stream_close;
204217 stream_class->close_async = gvir_stream_close_async;
205218 stream_class->close_finish = gvir_stream_close_finish;
338351
339352 return r;
340353 }
354
355
356 /**
357 * gvir_stream_send:
358 * @stream: the stream
359 * @buffer: a buffer to write data from (which should be at least @size
360 * bytes long).
361 * @size: the number of bytes you want to write to the stream
362 * @cancellable: (allow-none): a %GCancellable or %NULL
363 * @error: #GError for error reporting, or %NULL to ignore.
364 *
365 * Send data (up to @size bytes) from a stream.
366 * On error -1 is returned and @error is set accordingly.
367 *
368 * gvir_stream_send() can return any number of bytes, up to
369 * @size. If more than @size bytes have been sendd, the additional
370 * data will be returned in future calls to gvir_stream_send().
371 *
372 * If there is no data available, a %G_IO_ERROR_WOULD_BLOCK error will be
373 * returned.
374 *
375 * Returns: Number of bytes read, or 0 if the end of stream reached,
376 * or -1 on error.
377 */
378 gssize gvir_stream_send(GVirStream *self, const gchar *buffer, gsize size,
379 GCancellable *cancellable, GError **error)
380 {
381 int got;
382
383 g_return_val_if_fail(GVIR_IS_STREAM(self), -1);
384 g_return_val_if_fail(buffer != NULL, -1);
385
386 if (g_cancellable_set_error_if_cancelled (cancellable, error))
387 return -1;
388
389 got = virStreamSend(self->priv->handle, buffer, size);
390
391 if (got == -2) { /* blocking */
392 g_set_error(error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, NULL);
393 } else if (got < 0) {
394 g_set_error(error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
395 "Got virStreamRecv error in %s", G_STRFUNC);
396 }
397
398 return got;
399 }
400
401 struct stream_source_helper {
402 GVirStream *self;
403 GVirStreamSourceFunc func;
404 gpointer user_data;
405 };
406
407 static int
408 stream_source(virStreamPtr st G_GNUC_UNUSED,
409 char *bytes, size_t nbytes, void *opaque)
410 {
411 struct stream_source_helper *helper = opaque;
412
413 return helper->func(helper->self, bytes, nbytes, helper->user_data);
414 }
415
416 /**
417 * gvir_stream_send_all:
418 * @stream: the stream
419 * @func: (scope notified): the callback for writing data to application
420 * @user_data: (closure): data to be passed to @callback
421 * Returns: the number of bytes consumed or -1 upon error
422 *
423 * Send the entire data stream, sending the data to the
424 * requested data source. This is simply a convenient alternative
425 * to virStreamRecv, for apps that do blocking-I/o.
426 */
427 gssize
428 gvir_stream_send_all(GVirStream *self, GVirStreamSourceFunc func, gpointer user_data, GError **err)
429 {
430 struct stream_source_helper helper = {
431 .self = self,
432 .func = func,
433 .user_data = user_data
434 };
435 int r;
436
437 g_return_val_if_fail(GVIR_IS_STREAM(self), -1);
438 g_return_val_if_fail(func != NULL, -1);
439
440 r = virStreamSendAll(self->priv->handle, stream_source, &helper);
441 if (r < 0) {
442 if (err != NULL)
443 *err = gvir_error_new_literal(GVIR_STREAM_ERROR,
444 0,
445 "Unable to perform SendAll");
446 }
447
448 return r;
449 }
7070 * Returns: the number of bytes filled, 0 upon end
7171 * of file, or -1 upon error
7272 */
73 typedef gint (* GVirStreamSinkFunc) (GVirStream *stream,
74 const gchar *buf,
75 gsize nbytes,
76 gpointer user_data);
73 typedef gint (* GVirStreamSinkFunc)(GVirStream *stream,
74 const gchar *buf,
75 gsize nbytes,
76 gpointer user_data);
77
78 /**
79 * GVirStreamSourceFunc:
80 * @stream: a #GVirStream
81 * @buf: (out) (array length=nbytes) (transfer none): data pointer
82 * @nbytes: data size
83 * @user_data: user data passed to the function
84 * Returns: the number of bytes filled, 0 upon end
85 * of file, or -1 upon error
86 */
87 typedef gint (* GVirStreamSourceFunc)(GVirStream *stream,
88 gchar *buf,
89 gsize nbytes,
90 gpointer user_data);
7791
7892 GType gvir_stream_get_type(void);
7993 GType gvir_stream_handle_get_type(void);
8094
81 gssize gvir_stream_receive_all(GVirStream *stream, GVirStreamSinkFunc func, gpointer user_data, GError **err);
95 gssize gvir_stream_receive_all(GVirStream *stream, GVirStreamSinkFunc func, gpointer user_data, GError **error);
8296 gssize gvir_stream_receive(GVirStream *stream, gchar *buffer, gsize size, GCancellable *cancellable, GError **error);
97
98 gssize gvir_stream_send_all(GVirStream *stream, GVirStreamSourceFunc func, gpointer user_data, GError **error);
99 gssize gvir_stream_send(GVirStream *stream, const gchar *buffer, gsize size, GCancellable *cancellable, GError **error);
83100
84101 G_END_DECLS
85102
2727 gvir_connection_find_storage_pool_by_name;
2828 gvir_connection_create_domain;
2929 gvir_connection_create_storage_pool;
30 gvir_connection_start_domain;
3031
3132 gvir_domain_device_get_type;
3233
5253 gvir_domain_shutdown;
5354 gvir_domain_reboot;
5455 gvir_domain_get_config;
56 gvir_domain_set_config;
5557 gvir_domain_get_info;
5658 gvir_domain_screenshot;
5759