diff --git a/atapi_pt_helper/src/Makefile.am b/atapi_pt_helper/src/Makefile.am index 8dba3e28..f8f8c044 100644 --- a/atapi_pt_helper/src/Makefile.am +++ b/atapi_pt_helper/src/Makefile.am @@ -34,7 +34,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -CFLAGS = -Wall -Werror +CFLAGS += -Wall -Werror CPROTO=cproto INCLUDES = ${X_CFLAGS} diff --git a/libdmbus/AUTHORS b/libdmbus/AUTHORS deleted file mode 100644 index e69de29b..00000000 diff --git a/libdmbus/COPYING b/libdmbus/COPYING deleted file mode 100644 index e9ab0b39..00000000 --- a/libdmbus/COPYING +++ /dev/null @@ -1,458 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/libdmbus/ChangeLog b/libdmbus/ChangeLog deleted file mode 100644 index e69de29b..00000000 diff --git a/libdmbus/Makefile.am b/libdmbus/Makefile.am deleted file mode 100644 index 34123c83..00000000 --- a/libdmbus/Makefile.am +++ /dev/null @@ -1,61 +0,0 @@ -# -# -# Makefile.am: -# -# -# $Id:$ -# -# $Log:$ -# -# -# - -# -# Copyright (c) 2011 Citrix Systems, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - - -SUBDIRS = src app -EXTRA_DIST = version-major version-minor version-micro version-files version-md5sums -bin_SCRIPTS = libdmbus-config - -pkgconfigdir = ${libdir}/pkgconfig -pkgconfig_DATA = libdmbus.pc -libdmbus.pc.src: libdmbus.pc.src.in -libdmbus.pc: libdmbus.pc.src - @SED@ -f version.sed < libdmbus.pc.src > libdmbus.pc || rm -f libdmbus.pc - -libdmbus-config.src: libdmbus-config.src.in -libdmbus-config: libdmbus-config.src version.sed - @SED@ -f version.sed < libdmbus-config.src > libdmbus-config || rm -f libdmbus-config - chmod +x $@ - -VFD = ${srcdir} -VF = ${shell cat ${VFD}/version-files} -VFS = ${VF:%=${VFD}/%} -VCHK = ${shell cat ${VFS} | @MD5SUM@ | @AWK@ '{ print $$1 }' } -VNUM = ${shell @GREP@ ${VCHK} ${VFD}/version-md5sums | @AWK@ '{ print $$2 }' } -VDEF = ${shell echo `cat ${VFD}/version-major`.`cat ${VFD}/version-minor`.`cat ${VFD}/version-micro` } - -version.sed: $(VFD)/version-files $(VFD)/version-major \ - $(VFD)/version-minor $(VFD)/version-micro \ - $(VFD)/version-md5sums ${VFS} Makefile - if [ .${VNUM} = . ]; then \ - echo "s/%VERSION%/${VDEF}-E/g" > version.sed; \ - else \ - echo "s/%VERSION%/${VNUM}/g" > version.sed; \ - fi diff --git a/libdmbus/NEWS b/libdmbus/NEWS deleted file mode 100644 index e69de29b..00000000 diff --git a/libdmbus/README b/libdmbus/README deleted file mode 100644 index e69de29b..00000000 diff --git a/libdmbus/app/Makefile.am b/libdmbus/app/Makefile.am deleted file mode 100644 index 6c542fef..00000000 --- a/libdmbus/app/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (c) 2011 Citrix Systems, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - -INCLUDES = -I$(srcdir)/../src ${LIBARGO_INC} - -AM_CFLAGS=-g -W -Wall - -bin_PROGRAMS = -noinst_PROGRAMS = server server_static client client_static - - -server_SOURCES = server.c -server_LDADD =../src/libdmbus.la ${LIBARGO_LIB} - -server_static_SOURCES = server.c -server_static_LDADD =../src/libdmbus.la ${LIBARGO_LIB} -server_static_LDFLAGS = -all-static - -client_SOURCES = client.c -client_LDADD = ${LIBARGO_LIB} - -client_static_SOURCES = client.c -client_static_LDADD = ${LIBARGO_LIB} -client_static_LDFLAGS = -all-static diff --git a/libdmbus/app/client.c b/libdmbus/app/client.c deleted file mode 100644 index d4027e79..00000000 --- a/libdmbus/app/client.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 Citrix Systems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -int main(void) -{ - return 0; -} - diff --git a/libdmbus/app/server.c b/libdmbus/app/server.c deleted file mode 100644 index 4be645d7..00000000 --- a/libdmbus/app/server.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 Citrix Systems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -int main(void) -{ - return 0; -} diff --git a/libdmbus/configure.ac b/libdmbus/configure.ac deleted file mode 100644 index c53982fc..00000000 --- a/libdmbus/configure.ac +++ /dev/null @@ -1,134 +0,0 @@ -# -# Copyright (c) 2011 Citrix Systems, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - -# Prelude. -AC_PREREQ(2.13) -AC_INIT(src/dmbus.c.in) - -LT_INIT - -LIBDMBUS_MAJOR_VERSION=`cat $srcdir/version-major` -LIBDMBUS_MINOR_VERSION=`cat $srcdir/version-minor` -LIBDMBUS_MICRO_VERSION=`cat $srcdir/version-micro` - -LIBDMBUS_INTERFACE_VERSION_MIN=$LIBDMBUS_MINOR_VERSION -LIBDMBUS_INTERFACE_VERSION_MAX=$LIBDMBUS_MINOR_VERSION -LIBDMBUS_INTERFACE_REVISION=1 - -LIBDMBUS_VERSION=$LIBDMBUS_MAJOR_VERSION.$LIBDMBUS_MINOR_VERSION.$LIBDMBUS_MICRO_VERSION - -AC_SUBST(LIBDMBUS_MAJOR_VERSION) -AC_SUBST(LIBDMBUS_MINOR_VERSION) -AC_SUBST(LIBDMBUS_MICRO_VERSION) -AC_SUBST(LIBDMBUS_VERSION) - -AC_SUBST(LIBDMBUS_INTERFACE_VERSION_MIN) -AC_SUBST(LIBDMBUS_INTERFACE_VERSION_MAX) -AC_SUBST(LIBDMBUS_INTERFACE_REVISION) - -LT_RELEASE=$LIBDMBUS_MAJOR_VERSION.$LIBDMBUS_MINOR_VERSION -LT_CURRENT=$LIBDMBUS_INTERFACE_VERSION_MAX -LT_REVISION=$LIBDMBUS_MICRO_VERSION -LT_AGE=`expr $LIBDMBUS_INTERFACE_VERSION_MAX - $LIBDMBUS_INTERFACE_VERSION_MIN` - -AC_SUBST(LT_RELEASE) -AC_SUBST(LT_CURRENT) -AC_SUBST(LT_REVISION) -AC_SUBST(LT_AGE) - -VERSION=$LIBDMBUS_VERSION -PACKAGE=libdmbus - -AM_INIT_AUTOMAKE($PACKAGE,$VERSION) - -# Checks for programs. -AC_PROG_CC -AM_PROG_CC_C_O -PKG_PROG_PKG_CONFIG([0.22]) -AC_PROG_AWK -AC_CHECK_PROG(MD5SUM, md5sum, md5sum) -AC_CHECK_PROG(GREP, grep, grep) -AC_CHECK_PROG(SED, sed, sed) - -# Checks for header files. -AC_CHECK_HEADERS([unistd.h fcntl.h errno.h stdlib.h stdint.h stropts.h syslog.h string.h stdio.h stdarg.h]) -AC_CHECK_HEADERS([sys/types.h sys/stat.h sys/mman.h]) -#AC_CHECK_HEADERS([pthread.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_INLINE -AC_C_CONST -AC_HEADER_TIME -AC_STRUCT_TM - -# Checks for libargo - -AC_ARG_WITH([libargo], - AC_HELP_STRING([--with-libargo=PATH], [Path to prefix where libargo is installed]), - [LIBARGO_PREFIX=$with_libargo], []) - -case "x$LIBARGO_PREFIX" in - x|xno|xyes) - LIBARGO_INC="" - LIBARGO_LIB="-largo" - ;; - *) - LIBARGO_INC="-I${LIBARGO_PREFIX}/include" - LIBARGO_LIB="-L${LIBARGO_PREFIX}/lib -largo" - ;; -esac - -AC_SUBST(LIBARGO_INC) -AC_SUBST(LIBARGO_LIB) - -have_libargo=true - -ORIG_LDFLAGS="${LDFLAGS}" -ORIG_CPPFLAGS="${CPPFLAGS}" - LDFLAGS="${LDFLAGS} ${LIBARGO_LIB}" - CPPFLAGS="${CPPFLAGS} ${LIBARGO_INC}" - AC_CHECK_HEADERS([libargo.h], [], [have_libargo=false]) - AC_CHECK_FUNC([argo_socket], [], [have_libargo=false]) -LDFLAGS="${ORIG_LDFLAGS}" -CPPFLAGS="${ORIG_CPPFLAGS}" - -if test "x$have_libargo" = "xfalse"; then - AC_MSG_ERROR([ -*** libargo is required. -]) -fi - -AC_PATH_PROG([SHA1SUM], sha1sum, []) -if test "x${SHA1SUM}" = "x"; then - AC_MSG_ERROR([ -*** sha1sum is required. -]) -fi - -# Output files. -AC_CONFIG_MACRO_DIR([m4]) -AM_CONFIG_HEADER(src/config.h) - -AC_CONFIG_FILES([Makefile - src/Makefile - app/Makefile - libdmbus.pc.src]) -AC_CONFIG_FILES([libdmbus-config.src], - [chmod +x libdmbus-config.src]) - -AC_OUTPUT diff --git a/libdmbus/libdmbus-config.src.in b/libdmbus/libdmbus-config.src.in deleted file mode 100644 index 5b9b0f78..00000000 --- a/libdmbus/libdmbus-config.src.in +++ /dev/null @@ -1,77 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -exec_prefix_set=no - -usage() -{ - cat <&2 -fi - -while test $# -gt 0; do - case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; - esac - - case $1 in - --prefix=*) - prefix=$optarg - if test $exec_prefix_set = no ; then - exec_prefix=$optarg - fi - ;; - --prefix) - echo_prefix=yes - ;; - --exec-prefix=*) - exec_prefix=$optarg - exec_prefix_set=yes - ;; - --exec-prefix) - echo_exec_prefix=yes - ;; - --version) - echo %VERSION% - exit 0 - ;; - --cflags) - if test "@includedir@" != /usr/include ; then - includes="-I@includedir@" - fi - echo_cflags=yes - ;; - --libs) - echo_libs=yes - ;; - *) - usage 1 1>&2 - ;; - esac - shift -done - -if test "$echo_prefix" = "yes"; then - echo $prefix -fi -if test "$echo_exec_prefix" = "yes"; then - echo $exec_prefix -fi -if test "$echo_cflags" = "yes"; then - echo $includes @LIBARGO_INC@ -fi -if test "$echo_libs" = "yes"; then - echo -L@libdir@ -ldmbus @LIBARGO_LIB@ -fi diff --git a/libdmbus/libdmbus.pc.src.in b/libdmbus/libdmbus.pc.src.in deleted file mode 100644 index bb2ff34a..00000000 --- a/libdmbus/libdmbus.pc.src.in +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libdmbus -Description: Library Surface Manager Plugin -Version: @VERSION@ -Libs: -L${libdir} -ldmbus @LIBARGO_LIB@ -Cflags: -I${includedir} @LIBARGO_INC@ diff --git a/libdmbus/src/Makefile.am b/libdmbus/src/Makefile.am deleted file mode 100644 index fed4054d..00000000 --- a/libdmbus/src/Makefile.am +++ /dev/null @@ -1,76 +0,0 @@ -# -# -# Makefile.am: -# -# -# $Id:$ -# -# $Log:$ -# -# -# - -# -# Copyright (c) 2012 Citrix Systems, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# - - -INCLUDES = - -SRCS = dmbus.c - -DMBUSSRCS=${SRCS} - -noinst_HEADERS = project.h - -libdmbus_la_SOURCES = ${DMBUSSRCS} -libdmbus_la_LDFLAGS = \ - -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ - -release $(LT_RELEASE) \ - -export-dynamic - -BUILT_SOURCES = libdmbus.h dmbus.c dmbus.sha1 - -lib_LTLIBRARIES = libdmbus.la - -include_HEADERS = libdmbus.h -AM_CFLAGS = -g - -VFD = ${srcdir}/.. -VF = ${shell cat ${VFD}/version-files} -VFS = ${VF:%=${VFD}/%} -VCHK = ${shell cat ${VFS} | @MD5SUM@ | @AWK@ '{ print $$1 }' } -VNUM = ${shell @GREP@ ${VCHK} ${VFD}/version-md5sums | @AWK@ '{ print $$2 }' } -VDEF = ${shell echo `cat ${VFD}/version-major`.`cat ${VFD}/version-minor`.`cat ${VFD}/version-micro` } - -dmbus.c: dmbus.c.in rpc_definitions.m4 rpcgen.m4 dmbus.sha1 - cat rpc_definitions.m4 dmbus.c.in | m4 > dmbus.c -libdmbus.h: libdmbus.h.in rpc_definitions.m4 rpcgen.m4 dmbus.sha1 - cat rpc_definitions.m4 libdmbus.h.in | m4 > libdmbus.h -dmbus.sha1: rpc_definitions.m4 rpcgen.m4 libdmbus.h.in dmbus.c.in - cat $^ | ${SHA1SUM} - | cut -d ' ' -f 1 > dmbus.sha1 - -version.h: $(VFD)/version-files $(VFD)/version-major \ - $(VFD)/version-minor $(VFD)/version-micro \ - $(VFD)/version-md5sums ${VFS} Makefile - if [ .${VNUM} = . ]; then \ - echo "#define FULL_VERSION \"libdmbus Version ${VDEF} + Edits\"" > version.h; \ - echo ${VDEF}-E > version-num; \ - else \ - echo "#define FULL_VERSION \"libdmbus Version ${VNUM}\"" > version.h; \ - echo ${VNUM} > version-num; \ - fi diff --git a/libdmbus/src/dmbus.c.in b/libdmbus/src/dmbus.c.in deleted file mode 100644 index 0b34cc19..00000000 --- a/libdmbus/src/dmbus.c.in +++ /dev/null @@ -1,343 +0,0 @@ -/* -** Julian Pidancet -** -** WARNING: This file is generated. Be sure you are editing rpc_definitions.m4 -** or dmbus.c.in instead of dmbus.c. Otherwise your changes WILL BE LOST. -*/ - -#include "project.h" - -typedef struct client_node -{ - struct client_node *next; - struct client_node **pprev; -} client_node; - -struct dmbus_service -{ - xen_argo_addr_t addr; - int fd; - unsigned short service_id; - client_node *client_list; - - struct dmbus_service_ops *service_ops; -}; - -struct dmbus_client -{ - client_node link; /* Must be first */ - - xen_argo_addr_t addr; - int fd; - void *priv; - int domain; - DeviceType dev_type; - struct dmbus_rpc_ops *rpc_ops; - - uint8_t buff[DMBUS_MAX_MSG_LEN]; - size_t len; -}; - -static struct dmbus_service *s = NULL; - -/* - * Warning: - * These function have to be made atomic if this library is linked against - * a multithreaded program. - */ -static void client_list_insert(struct dmbus_client *c) -{ - c->link.next = s->client_list; - c->link.pprev = &s->client_list; - if (s->client_list) - s->client_list->pprev = &c->link.next; - s->client_list = &c->link; -} - -static void client_list_remove(struct dmbus_client *c) -{ - if (c->link.next) - c->link.next->pprev = c->link.pprev; - *(c->link.pprev) = c->link.next; -} - -void dmbus_cleanup(void) -{ - argo_close(s->fd); - free(s); - s = NULL; -} - -int dmbus_init(int service_id, - struct dmbus_service_ops *service_ops) -{ - int rc; - - if (s) { - errno = EEXIST; - return -1; - } - - if (service_id < 0 || service_id >= DMBUS_SERVICE_MAX) { - errno = ENOENT; - return -1; - } - - s = calloc(1, sizeof (*s)); - if (!s) { - errno = ENOMEM; - return -1; - } - - s->fd = argo_socket(SOCK_STREAM); - if (s->fd == -1) { - rc = -1; - goto out_free; - } - s->service_id = service_id; - s->service_ops = service_ops; - - s->addr.aport = DMBUS_BASE_PORT + service_id; - s->addr.domain_id = XEN_ARGO_DOMID_ANY; - - rc = argo_bind(s->fd, &s->addr, XEN_ARGO_DOMID_ANY); - if (rc == -1) { - goto out_close; - } - - rc = argo_listen(s->fd, 128); - if (rc == -1) { - goto out_close; - } - - s->client_list = NULL; - - return s->fd; - -out_close: - argo_close(s->fd); -out_free: - free(s); - s = NULL; - - return rc; -} - -static int check_hash(uint8_t *remote) -{ - uint8_t hash[20]; - const char *hash_str = DMBUS_SHA1_STRING; - size_t i; - - for (i = 0; i < sizeof (hash); i++) { - unsigned int c; - - sscanf(hash_str + 2 * i, "%02x", &c); - hash[i] = c; - } - - return memcmp(remote, hash, 20); -} - -static int recv_prologue(int fd, struct dmbus_conn_prologue *p) -{ - fd_set s; - struct timeval t; - int rc; - int b = 0; - - FD_ZERO(&s); - FD_SET(fd, &s); - t.tv_sec = 1; - t.tv_usec = 0; - - while (b != sizeof (*p)) { - rc = select(fd + 1, &s, NULL, NULL, &t); - if (rc < 0) /* select() failed */ - return rc; - if (rc == 0) { /* timeout */ - errno = EBUSY; - return -1; - } - - rc = argo_recv(fd, (char *)p + b, sizeof (*p) - b, MSG_DONTWAIT); - if (rc < 0) /* argo_recv() failed */ - return rc; - if (rc == 0) { /* other end left */ - errno = EPIPE; - return -1; - } - - b += rc; - } - - return 0; -} - -void dmbus_handle_connect(int fd) -{ - struct dmbus_client *c; - int rc; - struct dmbus_conn_prologue prologue; - struct msg_device_model_ready msg; - int b = 0; - - c = calloc(1, sizeof (*c)); - if (!c) - return; - - c->fd = argo_accept(fd, &c->addr); - if (c->fd == -1) { - free(c); - return; - } - - rc = recv_prologue(c->fd, &prologue); - if (rc) { - argo_close(c->fd); - free(c); - return; - } - - c->domain = prologue.domain; - c->dev_type = prologue.type; - - if (check_hash(prologue.hash)) { - /* Moan as loud as possible */ - - syslog(LOG_DAEMON | LOG_ALERT, "%s: WARNING, This service and the " - "device model don't use the same version of the dmbus interface, " - "Misery WILL happen !\n", __func__); - fprintf(stderr, "%s: WARNING, This service and the " - "device model don't use the same version of the dmbus interface, " - "Misery WILL happen !\n", __func__); - } - - if (s->service_ops->connect) { - rc = s->service_ops->connect(c, c->domain, c->dev_type, - c->addr.domain_id, - c->fd, - &c->rpc_ops, - &c->priv); - - if (rc) { - /* Connect failed */ - argo_close(c->fd); - free(c); - return; - } - else - device_model_ready(c, &msg, sizeof (msg)); - } - - client_list_insert(c); -} - -void dmbus_client_disconnect(dmbus_client_t client) -{ - struct dmbus_client *c = client; - - if (s->service_ops->disconnect) - s->service_ops->disconnect(c, c->priv); - - argo_close(c->fd); - client_list_remove(c); - free(c); -} - -/* TODO: if argo_send fails, we may want to tell the caller... */ -static void send_msg(struct dmbus_client *c, - int msgtype, - void *data, - size_t len) -{ - struct dmbus_msg_hdr *hdr = data; - int rc; - size_t b = 0; - - hdr->msg_type = msgtype; - hdr->msg_len = len; - - while (b < len) { - /* - * Let's not let argo_send crash the program: - * Use MSG_NOSIGNAL to avoid the SIGPIPE. - */ - rc = argo_send(c->fd, data + b, len - b, MSG_NOSIGNAL); - if (rc == -1) - return; - - b += rc; - } -} - -static void broadcast_msg(int msgtype, - void *data, - size_t len) -{ - client_node *node; - - for (node = s->client_list; node; node = node->next) { - struct dmbus_client *c; - - c = (struct dmbus_client *)node; - send_msg(c, msgtype, data, len); - } -} - -static void pop_message(struct dmbus_client *c) -{ - size_t l; - union dmbus_msg *m = (union dmbus_msg *)c->buff; - - l = m->hdr.msg_len; - memmove(c->buff, c->buff + l, c->len - l); - c->len -= l; -} - -void dmbus_handle_events(dmbus_client_t client) -{ - int rc; - struct dmbus_client *c = client; - union dmbus_msg *m = (union dmbus_msg *)c->buff; - - rc = argo_recv(c->fd, c->buff + c->len, sizeof (c->buff) - c->len, MSG_DONTWAIT); - switch (rc) { - case 0: - dmbus_client_disconnect(client); - case -1: - return; - default: - c->len += rc; - } - - while ( (c->len >= sizeof (struct dmbus_msg_hdr)) && - (c->len >= m->hdr.msg_len) ) { - - /* Message is complete, ship it ! */ - - switch (m->hdr.msg_type) { - /** - * WARNING: - * - * The following section contains generated code. - */ -SERV_MSG_HANDLERS - /** - * End of generated code section. - */ - } - - pop_message(c); - } -} - -/** - * WARNING: - * - * The following section contains generated code. - */ -DM_RPC_FUNCS -/** - * End of generated code section. - */ diff --git a/libdmbus/src/libdmbus.h.in b/libdmbus/src/libdmbus.h.in deleted file mode 100644 index cc881ab8..00000000 --- a/libdmbus/src/libdmbus.h.in +++ /dev/null @@ -1,158 +0,0 @@ -/* -** Julian Pidancet -** -** WARNING: This file is generated. Be sure you are editing rpc_definitions.m4 -** or dmbus.h.in instead of dmbus.h. Otherwise your changes WILL BE LOST. -*/ - -#ifndef __DMBUS_H__ -# define __DMBUS_H__ - -# include -# include - -# ifdef __cplusplus -extern "C" -{ -# endif - /** - * SHA1 Hash of the interface source files. - */ -INTERFACE_HASH - - /** - * dmbus services definitions - */ -# define DMBUS_BASE_PORT 4000 - enum dmbus_service_id - { - DMBUS_SERVICE_DUMMY = 0, /* Only for test programs */ - DMBUS_SERVICE_SURFMAN = 1, - DMBUS_SERVICE_INPUT = 2, - - DMBUS_SERVICE_MAX, - }; - - /** - * dmbus types definitions - */ -# define DMBUS_ID_INVALID ((uint32_t)-1) - enum - { - DEVICE_TYPE_XENFB = 0, - DEVICE_TYPE_VESA, - DEVICE_TYPE_XENGFX, - DEVICE_TYPE_PASSTHROUGH, - DEVICE_TYPE_EMULATION, - DEVICE_TYPE_INPUT, - DEVICE_TYPE_INPUT_PVM - }; - enum - { - FRAMEBUFFER_FORMAT_RGB555 = (1 << 0), - FRAMEBUFFER_FORMAT_BGR555 = (1 << 1), - FRAMEBUFFER_FORMAT_RGB565 = (1 << 2), - FRAMEBUFFER_FORMAT_BGR565 = (1 << 3), - FRAMEBUFFER_FORMAT_RGB888 = (1 << 4), - FRAMEBUFFER_FORMAT_BGR888 = (1 << 5), - FRAMEBUFFER_FORMAT_RGBX8888 = (1 << 6), - FRAMEBUFFER_FORMAT_BGRX8888 = (1 << 7), - }; - - typedef uint32_t DeviceType; - typedef uint32_t FramebufferFormat; - typedef struct { - uint8_t b[256]; - } Buff256; - - typedef struct { - uint8_t slot; - char name[26]; - uint32_t evbits; - uint64_t bits[1]; - } InputConfig; - - typedef void *dmbus_client_t; - - struct dmbus_rpc_ops; - struct dmbus_service_ops - { - int (*connect)(dmbus_client_t client, - int domain, - DeviceType type, - int dm_domain, - int fd, - struct dmbus_rpc_ops **ops, - void **priv); - void (*disconnect)(dmbus_client_t client, void *priv); - }; - -# define DMBUS_MAX_MSG_LEN 512 -# define DMBUS_PACKED __attribute__ ((packed)) - /** - * dmbus connection prologue - */ - struct dmbus_conn_prologue - { - uint32_t domain; - DeviceType type; - uint8_t hash[20]; - } DMBUS_PACKED; - - /** - * dmbus message format - */ - union dmbus_msg - { - struct dmbus_msg_hdr - { - uint32_t msg_len; - uint32_t msg_type; - uint32_t return_value; - } DMBUS_PACKED hdr; - - /** - * WARNING: - * - * The following section contains generated definitions. - */ -MSG_STRUCTS - /** - * End of generated definitions section. - */ - - }; - - struct dmbus_rpc_ops - { - /** - * WARNING: - * - * The following section contains generated definitions. - */ -SERV_MSG_OPS - /** - * End of generated definitions section. - */ - }; - -/** - * WARNING: - * - * The following section contains generated definitions. - */ -DM_RPC_DEFS -/** - * End of generated definitions section. - */ -void dmbus_cleanup(void); -int dmbus_init(int service_id, struct dmbus_service_ops *service_ops); -void dmbus_handle_connect(int fd); -void dmbus_handle_events(dmbus_client_t client); -void dmbus_client_disconnect(dmbus_client_t client); - -#ifdef __cplusplus -} -#endif - -#endif /* __DMBUS_H__ */ diff --git a/libdmbus/src/project.h b/libdmbus/src/project.h deleted file mode 100644 index cf83cbd8..00000000 --- a/libdmbus/src/project.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 Citrix Systems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __PROJECT_H__ -# define __PROJECT_H__ - -# include "config.h" - -# ifdef HAVE_DLFCN_H -# include -# endif - -# ifdef HAVE_ERRNO_H -# include -# endif - -# ifdef HAVE_FCNTL_H -# include -# endif - -# ifdef HAVE_INTTYPES_H -# include -# endif - -# ifdef HAVE_MEMORY_H -# include -# endif - -# ifdef HAVE_STDINT_H -# include -# endif - -# ifdef HAVE_STDIO_H -# include -# endif - -# ifdef HAVE_STDLIB_H -# include -# endif - -# ifdef HAVE_STRINGS_H -# include -# endif - -# ifdef HAVE_STRING_H -# include -# endif - -# ifdef HAVE_STROPTS_H -# include -# endif - -# ifdef HAVE_SYSLOG_H -# include -# endif - -# ifdef HAVE_SYS_MMAN_H -# include -# endif - -# ifdef HAVE_SYS_STAT_H -# include -# endif - -# ifdef HAVE_SYS_TYPES_H -# include -# endif - -# ifdef HAVE_UNISTD_H -# include -# endif - -# ifdef HAVE_PTHREAD_H -# include -# endif - -# ifdef HAVE_STDARG_H -# include -# endif - -# include -# include - -# include - -# include "libdmbus.h" - -#endif /* __PROJECT_H__ */ diff --git a/libdmbus/src/rpc_definitions.m4 b/libdmbus/src/rpc_definitions.m4 deleted file mode 100644 index 5d3eabe3..00000000 --- a/libdmbus/src/rpc_definitions.m4 +++ /dev/null @@ -1,81 +0,0 @@ -divert(-1) -# rpc_definitions.m4 -# -# Macros: -# DEFINE_MESSAGE(id, name, format...) -# Define a message type with the given format. -# The message ID is fixed by the user and not generated so the -# comunicating ends can remain backward compatible with older -# versions of the library. -# -# DEFINE_IN_RPC_NO_RETURN(in_message_type) -# Define an asynchronous, inbound (dm to service) RPC using -# in_message_type as a previously defined input message type. -# The caller does not expect a reply message. -# -# DEFINE_IN_RPC_WITH_RETURN(in_message_type, out_message_type) -# Define a synchronous, inbound (dm to service) RPC using -# in_message_type as a previously defined input message type. -# The caller expects a reply of the out_message_type message type. -# -# DEFINE_OUT_RPC(out_message_type) -# Define an asynchronous, outbound (service to dm) RPC using -# out_message_type as a previously defined output message type. -# The RPC is directed to a unique connected client. -# -# DEFINE_BROADCAST_RPC(out_message_type) -# Define an asynchronous, outbound (service to dm) RPC using -# out_message_type as a previously defined output message type. -# The RPC is broadcasted to all connected clients. -# -include(rpcgen.m4) - -# Surfman -DEFINE_MESSAGE(0, display_resize, uint8_t DisplayID, - uint16_t width, - uint16_t height, - uint32_t linesize, - uint64_t lfb_addr, - uint8_t lfb_traceable, - FramebufferFormat format, - uint32_t fb_offset) -DEFINE_MESSAGE(1, display_get_info, uint8_t DisplayID) -DEFINE_MESSAGE(2, display_info, uint8_t DisplayID, - uint16_t max_xres, - uint16_t max_yres, - uint16_t align) -DEFINE_MESSAGE(8, empty_reply) - -DEFINE_IN_RPC_WITH_RETURN(display_resize, empty_reply) -DEFINE_IN_RPC_WITH_RETURN(display_get_info, display_info) - -# Input - -DEFINE_MESSAGE(16, switcher_abs, int32_t enabled) -DEFINE_MESSAGE(17, switcher_pvm_domid, uint32_t domid, int32_t slot) -DEFINE_MESSAGE(18, switcher_domid, uint32_t domid, int32_t slot) -DEFINE_MESSAGE(19, switcher_leds, int32_t led_code) -DEFINE_MESSAGE(20, switcher_shutdown, int32_t reason) - -DEFINE_MESSAGE(21, dom0_input_event, uint16_t type, - uint16_t code, - int32_t value) -DEFINE_MESSAGE(24, input_config_reset, uint8_t slot) -DEFINE_MESSAGE(25, input_config, InputConfig c) -DEFINE_MESSAGE(26, input_wakeup) - -DEFINE_IN_RPC_NO_RETURN(switcher_abs) -DEFINE_IN_RPC_NO_RETURN(switcher_pvm_domid) -DEFINE_IN_RPC_NO_RETURN(switcher_domid) -DEFINE_IN_RPC_NO_RETURN(switcher_leds) -DEFINE_IN_RPC_NO_RETURN(switcher_shutdown) -DEFINE_OUT_RPC(dom0_input_event) -DEFINE_OUT_RPC(input_config) -DEFINE_OUT_RPC(input_config_reset) -DEFINE_OUT_RPC(input_wakeup) - -# Common message -DEFINE_MESSAGE(23, device_model_ready) -DEFINE_OUT_RPC(device_model_ready) # Indicate the service is ready to emulate the new domain - -divert(0)dnl diff --git a/libdmbus/src/rpcgen.m4 b/libdmbus/src/rpcgen.m4 deleted file mode 100644 index b7b4f067..00000000 --- a/libdmbus/src/rpcgen.m4 +++ /dev/null @@ -1,86 +0,0 @@ -define(`foreach',`ifelse(eval($#>2),1,`pushdef(`$1',`$3')$2`'popdef(`$1')`'ifelse(eval($#>3),1,`$0(`$1',`$2',shift(shift(shift($@))))')')') -define(`list', `ifelse($#,2,$2,$2$1`foreach($1,shift(shift($@)))')')dnl list(separator,e1,e2,e3) -define(`capitalize', `translit($1, `a-z', `A-Z')') -define(`comma',`,') - -define(MSGSTRUCT, `struct msg_$1 -{ - struct dmbus_msg_hdr hdr; -foreach(`X',` X; -',shift($@))} DMBUS_PACKED $1;') - - -define(`MSG_STRUCTS',`') -define(`SERV_MSG_OPS',`') -define(`SERV_MSG_HANDLERS',`') -define(`DM_RPC_FUNCS',`') -define(`DM_RPC_DEFS',`') - - -define(`DEFINE_MESSAGE', `define(`MSGID_'$2,DMBUS_MSG_`'capitalize($2))'dnl - `define(`MSG_STRUCTS',MSG_STRUCTS -`#define' MSGID_$2 $1 -MSGSTRUCT(shift($@)))'dnl -) - -define(`DEFINE_IN_RPC_NO_RETURN', `define(`SERV_MSG_OPS', SERV_MSG_OPS`'dnl -void (*$1)(``void *priv, struct msg_$1 *msg, size_t msglen''); -)'dnl -`define(`SERV_MSG_HANDLERS', SERV_MSG_HANDLERS`'dnl -case MSGID_$1: -{ - size_t len = m->hdr.msg_len; - - if (c->rpc_ops->$1) { - c->rpc_ops->$1(``c->priv, &m->''$1``, len''); - } - break; -} -)'dnl -) - -define(`DEFINE_IN_RPC_WITH_RETURN', `define(`SERV_MSG_OPS', SERV_MSG_OPS`'dnl -int (*$1)(``void *priv, struct msg_$1 *msg, size_t msglen, struct msg_$2 *out''); -)'dnl -`define(`SERV_MSG_HANDLERS', SERV_MSG_HANDLERS`'dnl -case MSGID_$1: -{ - struct msg_$2 out; - size_t len = m->hdr.msg_len; - int ret = -1; - - if (c->rpc_ops->$1) { - ret = c->rpc_ops->$1(``c->priv, &m->''$1``, len, &out''); - } - out.hdr.return_value = (uint32_t) ret; - send_msg(``c, ''MSGID_$2``, &out, sizeof (out)''); - break; -} -)'dnl -) - -define(`DEFINE_OUT_RPC', `define(`DM_RPC_DEFS', DM_RPC_DEFS -`void '$1`(dmbus_client_t client, struct msg_'$1` *msg, size_t msglen);')'dnl - `define(`DM_RPC_FUNCS', DM_RPC_FUNCS -`void '$1`(dmbus_client_t client, struct msg_'$1` *msg, size_t msglen)' -{ - struct dmbus_client *c = client; - - send_msg(c, MSGID_$1, msg, msglen); -} -)'dnl -) - -define(`DEFINE_BROADCAST_RPC', `define(`DM_RPC_DEFS', DM_RPC_DEFS -`void '$1`(struct msg_'$1` *msg, size_t msglen);')'dnl - `define(`DM_RPC_FUNCS', DM_RPC_FUNCS -`void '$1`(struct msg_'$1` *msg, size_t msglen)' -{ - broadcast_msg(MSGID_$1, msg, msglen); -} -)'dnl -) - -define(`INTERFACE_HASH',dnl -`# define DMBUS_SHA1_STRING "'substr(include(dmbus.sha1), 0, 40)`"'dnl -) diff --git a/libdmbus/version-files b/libdmbus/version-files deleted file mode 100644 index a128c98d..00000000 --- a/libdmbus/version-files +++ /dev/null @@ -1,3 +0,0 @@ -src/libdmbus.h.in -src/dmbus.c -src/project.h diff --git a/libdmbus/version-major b/libdmbus/version-major deleted file mode 100644 index 573541ac..00000000 --- a/libdmbus/version-major +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libdmbus/version-md5sums b/libdmbus/version-md5sums deleted file mode 100644 index e69de29b..00000000 diff --git a/libdmbus/version-micro b/libdmbus/version-micro deleted file mode 100644 index 573541ac..00000000 --- a/libdmbus/version-micro +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/libdmbus/version-minor b/libdmbus/version-minor deleted file mode 100644 index d00491fd..00000000 --- a/libdmbus/version-minor +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/qmp_helper/src/Makefile.am b/qmp_helper/src/Makefile.am index 6ebf1035..19c25aa4 100644 --- a/qmp_helper/src/Makefile.am +++ b/qmp_helper/src/Makefile.am @@ -17,7 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -CFLAGS = -Wall -Werror +CFLAGS += -Wall -Werror CPROTO=cproto INCLUDES = ${X_CFLAGS} diff --git a/varstored-watch/COPYING b/varstored-watch/COPYING new file mode 100644 index 00000000..d8cf7d46 --- /dev/null +++ b/varstored-watch/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/varstored-watch/Makefile b/varstored-watch/Makefile new file mode 100644 index 00000000..44988954 --- /dev/null +++ b/varstored-watch/Makefile @@ -0,0 +1,11 @@ +CFLAGS += -g -Wall -Werror +LDLIBS = -lxenctrl -lxenstore + +all: varstored-watch + +clean: + rm -f varstored-watch *.o + +install: + install -d ${DESTDIR}/usr/sbin + install -m 0755 varstored-watch ${DESTDIR}/usr/sbin diff --git a/varstored-watch/varstored-watch.c b/varstored-watch/varstored-watch.c new file mode 100644 index 00000000..efd8b1d9 --- /dev/null +++ b/varstored-watch/varstored-watch.c @@ -0,0 +1,182 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct option varstored_watch_option[] = { + {"domid", 1, NULL, 'd'}, + {"uuid", 1, NULL, 'u'}, + {NULL, 0, NULL, 0} +}; + +static pid_t +start_varstored(char *domid_str, char *uuid) +{ + const char *path = "/usr/sbin/varstored"; + pid_t pid; + char *process_name = NULL; + char *vpid = NULL; + char *uuid_param = NULL; + domid_t domid; + int ret; + + domid = (domid_t) strtol(domid_str, NULL, 0); + + ret = asprintf(&process_name, "varstored-%d", domid); + if (ret == -1) { + syslog(LOG_ERR, "asprintf process_name failed: %d, %s", errno, + strerror(errno)); + return -1; + } + ret = asprintf(&vpid, "/var/run/varstored-pid-%d", domid); + if (ret == -1) { + syslog(LOG_ERR, "asprintf pidfile failed: %d, %s", errno, + strerror(errno)); + return -1; + } + ret = asprintf(&uuid_param, "uuid:%s", uuid); + if (ret == -1) { + syslog(LOG_ERR, "asprintf uuid failed: %d, %s", errno, strerror(errno)); + return -1; + } + + pid = fork(); + if (pid == -1) { + syslog(LOG_ERR, "Failed to fork varstored"); + } else if (pid == 0) { + execl(path, process_name, + "--depriv", + "--domain", domid_str, + "--backend", "oxtdb", + "--pidfile", vpid, + "--arg", uuid_param, + "--gid", "415", + "--uid", "416", + NULL); + } + // Free the strings. + free(process_name); + free(vpid); + free(uuid_param); + + return pid; +} + +#define XS_VARSTORED_WATCH_PID_PATH "/local/domain/%s/varstored-watch-pid" + +static bool +xs_write_pid(struct xs_handle *xsh, char * domid) +{ + char *varstore_watch_pid = NULL; + char *key = NULL; + bool ret = false; + + /* write out the pid so libxl can tear us down on guest shutdown */ + if (asprintf(&varstore_watch_pid, "%u", getpid()) != -1) + if (asprintf(&key, XS_VARSTORED_WATCH_PID_PATH, domid) != -1) + ret = xs_write(xsh, 0, key, varstore_watch_pid, strlen(varstore_watch_pid)); + + free(key); + free(varstore_watch_pid); + return ret; +} + +static void +usage(const char *prog) +{ + int i; + + fprintf(stderr, "Usage: %s \n\n", prog); + + for (i = 0; i < 2; i++) { + if (varstored_watch_option[i].has_arg) { + fprintf(stderr, "\t--%s \n", + varstored_watch_option[i].name); + } else { + fprintf(stderr, "\t--%s\n", varstored_watch_option[i].name); + } + } + + fprintf(stderr, "\n"); +} + +int +main(int argc, char **argv) +{ + int rc; + struct xs_handle *xsh = NULL; + char *domid_str = NULL; + char *uuid = NULL; + const char *prog; + pid_t varstored_pid; + + prog = basename(argv[0]); + + while (1) { + char c; + + c = getopt_long(argc, argv, "", varstored_watch_option, NULL); + if (c == -1) + break; + + switch (c) { + case 'd': + domid_str = strdup(optarg); + break; + case 'u': + uuid = strdup(optarg); + break; + default: + usage(prog); + exit(2); + } + } + + if (domid_str == NULL || uuid == NULL) { + usage(prog); + exit(2); + } + + xsh = xs_open(0); + if (!xsh) { + syslog(LOG_ERR, "Couldn't open xenstore: %d, %s", errno, strerror(errno)); + return -1; + } + + if (!xs_write_pid(xsh, domid_str)) { + syslog(LOG_ERR, "Failed to write pid to xenstore: %d, %s\n", errno, strerror(errno)); + xs_close(xsh); + return -1; + } + + xs_close(xsh); + + //Start varstored for the first time. + varstored_pid = start_varstored(domid_str, uuid); + if (varstored_pid == -1) { + syslog(LOG_ERR, "Failed to fork varstored\n"); + return -1; + } + + //Start loop for restarting varstored if it goes down. + while (true) { + waitpid(varstored_pid, &rc, 0); + if (WIFEXITED(rc)) { + syslog(LOG_ERR, "Varstored failed to start normally and exited...not retrying. Exit status %d\n", WEXITSTATUS(rc)); + break; + } else if (WIFSIGNALED(rc)) { + syslog(LOG_ERR, "Varstored killed by signal %d, restarting.\n", WTERMSIG(rc)); + varstored_pid = start_varstored(domid_str, uuid); + } + } + + return 0; +} diff --git a/xcpmd/src/Makefile.am b/xcpmd/src/Makefile.am index f78d3d2b..46452355 100644 --- a/xcpmd/src/Makefile.am +++ b/xcpmd/src/Makefile.am @@ -57,7 +57,7 @@ xcpmd_LDFLAGS = -rdynamic # # RPC generated stubs. # -DBUS_CLIENT_IDLS = xenmgr xenmgr_vm db +DBUS_CLIENT_IDLS = xenmgr xenmgr_vm db vglass input_daemon DBUS_SERVER_IDLS = xcpmd BUILT_SOURCES = \ @@ -81,6 +81,8 @@ pkglib_LTLIBRARIES = \ acpi-module.la \ default-actions-module.la \ default-inputs-module.la \ + displayhandler-module.la \ + idle-detect-module.la \ vm-actions-module.la \ vm-events-module.la @@ -104,6 +106,20 @@ default_actions_module_la_SOURCES = \ rules.h default_actions_module_la_LDFLAGS = -avoid-version -module -shared +displayhandler_module_la_SOURCES = \ + displayhandler-module.c \ + rules.h +displayhandler_module_la_LDFLAGS = -avoid-version -module -shared + +idle_detect_module_la_SOURCES = \ + idle-detect-module.c \ + idle-detect-module.h \ + project.h \ + rpcgen/input_daemon_client.h \ + rules.h \ + vm-utils.h \ + xcpmd.h +idle_detect_module_la_LDFLAGS = -avoid-version -module -shared vm_actions_module_la_SOURCES = \ vm-actions-module.c \ diff --git a/xcpmd/src/acpi-events.c b/xcpmd/src/acpi-events.c index dacf3c12..c360b08b 100644 --- a/xcpmd/src/acpi-events.c +++ b/xcpmd/src/acpi-events.c @@ -34,20 +34,13 @@ #include "rules.h" #include "acpi-module.h" #include "battery.h" +#include "rpcgen/vglass_client.h" static int acpi_events_fd = -1; static struct event acpi_event; static struct ev_wrapper ** acpi_event_table; -void adjust_brightness(int increase, int force) { - (void) increase; - if (force || (pm_quirks & PM_QUIRK_SW_ASSIST_BCL) || (pm_quirks & PM_QUIRK_HP_HOTKEY_INPUT)) { - xcpmd_log(LOG_WARNING, "Brightness adjustment not implemented yet."); - } -} - - int get_ac_adapter_status(void) { char data[128]; @@ -250,13 +243,15 @@ static void handle_bcl_event(enum BCL_CMD cmd) { xcpmd_log(LOG_INFO, "Brightness up button pressed event\n"); xenstore_write("1", XS_BCL_CMD); xenstore_write("1", XS_BCL_EVENT_PATH); - adjust_brightness(1, 0); + mil_af_secureview_vglass_increase_brightness_(xcdbus_conn, + "mil.af.secureview.vglass", "/mil/af/secureview/vglass"); } else if (cmd == BCL_DOWN) { xcpmd_log(LOG_INFO, "Brightness down button pressed event\n"); xenstore_write("2", XS_BCL_CMD); xenstore_write("1", XS_BCL_EVENT_PATH); - adjust_brightness(0, 0); + mil_af_secureview_vglass_increase_brightness_(xcdbus_conn, + "mil.af.secureview.vglass", "/mil/af/secureview/vglass"); } else if (cmd == BCL_CYCLE) { //Qemu doesn't currently support this key, but these can be uncommented @@ -277,7 +272,7 @@ static void handle_ac_adapter_event(uint32_t data) { struct ev_wrapper * e = acpi_event_table[EVENT_ON_AC]; xenstore_write_int(data, XS_AC_ADAPTER_STATE_PATH); - notify_com_citrix_xenclient_xcpmd_ac_adapter_state_changed(xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH); + notify_com_citrix_xenclient_xcpmd_ac_adapter_state_changed(xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH, data == ACPI_AC_STATUS_ONLINE); switch(data) { case ACPI_AC_STATUS_OFFLINE: @@ -599,8 +594,7 @@ int acpi_events_initialize(void) { } addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, ACPID_SOCKET_PATH, strlen(ACPID_SOCKET_PATH)); - addr.sun_path[strlen(ACPID_SOCKET_PATH)] = '\0'; + strncpy(addr.sun_path, ACPID_SOCKET_PATH, strlen(ACPID_SOCKET_PATH) + 1); for (i = 0; ; i++) { ret = connect(acpi_events_fd, (struct sockaddr *)&addr, sizeof(addr)); diff --git a/xcpmd/src/acpi-module.c b/xcpmd/src/acpi-module.c index 2eb632bf..49c30764 100644 --- a/xcpmd/src/acpi-module.c +++ b/xcpmd/src/acpi-module.c @@ -70,6 +70,7 @@ struct cond_table_row { char * prototype; char * pretty_prototype; unsigned int event_index; + void (* on_instantiate)(struct condition *); }; @@ -89,24 +90,24 @@ static struct event_data_row event_data[] = { static struct cond_table_row condition_data[] = { - {"onBacklightUpBtn" , bcl_up_pressed , "n" , "void" , EVENT_BCL } , - {"onBacklightDownBtn" , bcl_down_pressed , "n" , "void" , EVENT_BCL } , - {"onPowerBtn" , pbtn_pressed , "n" , "void" , EVENT_PWR_BTN } , - {"onSleepBtn" , sbtn_pressed , "n" , "void" , EVENT_SLP_BTN } , - {"onSuspendBtn" , susp_pressed , "n" , "void" , EVENT_SUSP_BTN } , - {"whileLidClosed" , lid_closed , "n" , "void" , EVENT_LID } , - {"whileLidOpen" , lid_open , "n" , "void" , EVENT_LID } , - {"whileUsingAc" , on_ac , "n" , "void" , EVENT_ON_AC } , - {"whileUsingBatt" , on_battery , "n" , "void" , EVENT_ON_AC } , - {"whileInTabletMode" , tablet_mode , "n" , "void" , EVENT_TABLET_MODE } , - {"whileNotInTabletMode" , non_tablet_mode , "n" , "void" , EVENT_TABLET_MODE } , - {"whileBattGreaterThan" , battery_greater_than , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS } , - {"whileBattLessThan" , battery_less_than , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS } , - {"whileBattEqualTo" , battery_equal_to , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS } , - {"whileBattPresent" , battery_present , "i" , "int battNum" , EVENT_BATT_INFO } , - {"whileOverallBattGreaterThan" , overall_battery_greater_than , "i" , "int percentage" , EVENT_BATT_STATUS } , - {"whileOverallBattLessThan" , overall_battery_less_than , "i" , "int percentage" , EVENT_BATT_STATUS } , - {"whileOverallBattEqualTo" , overall_battery_equal_to , "i" , "int percentage" , EVENT_BATT_STATUS } + {"onBacklightUpBtn" , bcl_up_pressed , "n" , "void" , EVENT_BCL , NULL } , + {"onBacklightDownBtn" , bcl_down_pressed , "n" , "void" , EVENT_BCL , NULL } , + {"onPowerBtn" , pbtn_pressed , "n" , "void" , EVENT_PWR_BTN , NULL } , + {"onSleepBtn" , sbtn_pressed , "n" , "void" , EVENT_SLP_BTN , NULL } , + {"onSuspendBtn" , susp_pressed , "n" , "void" , EVENT_SUSP_BTN , NULL } , + {"whileLidClosed" , lid_closed , "n" , "void" , EVENT_LID , NULL } , + {"whileLidOpen" , lid_open , "n" , "void" , EVENT_LID , NULL } , + {"whileUsingAc" , on_ac , "n" , "void" , EVENT_ON_AC , NULL } , + {"whileUsingBatt" , on_battery , "n" , "void" , EVENT_ON_AC , NULL } , + {"whileInTabletMode" , tablet_mode , "n" , "void" , EVENT_TABLET_MODE , NULL } , + {"whileNotInTabletMode" , non_tablet_mode , "n" , "void" , EVENT_TABLET_MODE , NULL } , + {"whileBattGreaterThan" , battery_greater_than , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS , NULL } , + {"whileBattLessThan" , battery_less_than , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS , NULL } , + {"whileBattEqualTo" , battery_equal_to , "i, i" , "int battNum, int percentage" , EVENT_BATT_STATUS , NULL } , + {"whileBattPresent" , battery_present , "i" , "int battNum" , EVENT_BATT_INFO , NULL } , + {"whileOverallBattGreaterThan" , overall_battery_greater_than , "i" , "int percentage" , EVENT_BATT_STATUS , NULL } , + {"whileOverallBattLessThan" , overall_battery_less_than , "i" , "int percentage" , EVENT_BATT_STATUS , NULL } , + {"whileOverallBattEqualTo" , overall_battery_equal_to , "i" , "int percentage" , EVENT_BATT_STATUS , NULL } }; static unsigned int num_conditions = sizeof(condition_data) / sizeof(condition_data[0]); @@ -140,7 +141,7 @@ __attribute__((constructor)) static void init_module() { //Add all condition_types to the condition_type list. for (i=0; i < num_conditions; ++i) { struct cond_table_row entry = condition_data[i]; - add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, _acpi_event_table[entry.event_index]); + add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, _acpi_event_table[entry.event_index], entry.on_instantiate); } } diff --git a/xcpmd/src/battery.c b/xcpmd/src/battery.c index 433ed3b1..1d651d3e 100644 --- a/xcpmd/src/battery.c +++ b/xcpmd/src/battery.c @@ -491,6 +491,8 @@ int update_battery_status(unsigned int battery_index) { char *ptr; struct battery_status status; + struct battery_info info; + memset(&info, 0, sizeof(struct battery_info)); memset(&status, 0, sizeof(struct battery_status)); if (battery_index >= num_battery_structs_allocd) @@ -530,7 +532,13 @@ int update_battery_status(unsigned int battery_index) { memset(data, 0, sizeof(data)); if (fgets(data, sizeof(data), file) == NULL) { - xcpmd_log(LOG_ERR, "Failed to read %s", filename); + if (errno != ENODEV) { + // ACPI batteries can return ENODEV for current_now. + // skip that so we don't spam the log. + xcpmd_log(LOG_ERR, "Failed to read %s errno %d", filename, + errno); + } + fclose(file); continue; } @@ -543,6 +551,9 @@ int update_battery_status(unsigned int battery_index) { //Set the attribute represented by this file. set_battery_status_attribute(dp->d_name, ptr, &status); + + //Set the attribute represented by this file. + set_battery_info_attribute(dp->d_name, ptr, &info); } } @@ -561,73 +572,10 @@ int update_battery_status(unsigned int battery_index) { status.remaining_capacity = status.energy_now; } - closedir(battery_dir); memcpy(&last_status[battery_index], &status, sizeof(struct battery_status)); #ifdef XCPMD_DEBUG print_battery_status(battery_index); #endif - return 1; -} - - -//Gets a battery's info from the sysfs and stores it in last_info. -int update_battery_info(unsigned int battery_index) { - - DIR *battery_dir; - struct dirent * dp; - FILE *file; - char filename[295]; - char data[128]; - char *ptr; - - struct battery_info info; - memset(&info, 0, sizeof(struct battery_info)); - - if (battery_index >= num_battery_structs_allocd) - return 0; - - if (battery_slot_exists(battery_index) == NO) { - memcpy(&last_info[battery_index], &info, sizeof(struct battery_info)); - return 0; - } - - battery_dir = get_battery_dir(battery_index); - if (!battery_dir) { - xcpmd_log(LOG_ERR, "opendir in update_battery_info() for directory %s/BAT%d failed with error %d\n", BATTERY_DIR_PATH, battery_index, errno); - return 0; - } - - //Loop over the files in the directory. - while ((dp = readdir(battery_dir)) != NULL) { - - //Convert from dirent to file and read out the data. - if (dp->d_type == DT_REG) { - - memset(filename, 0, sizeof(filename)); - snprintf(filename, sizeof (filename), "%s/BAT%u/%s", BATTERY_DIR_PATH, battery_index, dp->d_name); - - file = fopen(filename, "r"); - if (file == NULL) - continue; - - memset(data, 0, sizeof(data)); - if (fgets(data, sizeof(data), file) == NULL) { - xcpmd_log(LOG_ERR, "Failed to read %s", filename); - continue; - } - - fclose(file); - - //Trim off leading spaces. - ptr = data; - while(*ptr == ' ') - ptr += sizeof(char); - - //Set the attribute represented by this file. - set_battery_info_attribute(dp->d_name, ptr, &info); - - } - } //In sysfs, the charge nodes are for batteries reporting in mA and //the energy nodes are for mW. @@ -836,7 +784,6 @@ void update_batteries(void) { //calculations of aggregate data (e.g., warning level). for (i=0; i < num_batteries_to_update; ++i) { update_battery_status(i); - update_battery_info(i); } //Write back to the xenstore and only send notifications if things have changed. @@ -911,9 +858,16 @@ void update_batteries(void) { } if ((old_array_size != new_array_size) || (memcmp(old_status, last_status, new_array_size * sizeof(struct battery_status)))) { - //Here for compatibility--should eventually be removed - xenstore_write("1", XS_BATTERY_STATUS_CHANGE_EVENT_PATH); - notify_com_citrix_xenclient_xcpmd_battery_status_changed(xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH); + static int previous_percent; + int current_percent = get_overall_battery_percentage(); + + if (current_percent != previous_percent) { + previous_percent = current_percent; + //Here for compatibility--should eventually be removed + xenstore_write("1", XS_BATTERY_STATUS_CHANGE_EVENT_PATH); + notify_com_citrix_xenclient_xcpmd_battery_status_changed( + xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH, current_percent); + } } if (present_batteries_changed) { @@ -1008,6 +962,7 @@ int get_num_batteries_present(void) { if (fgets(data, sizeof(data), file) == NULL) { xcpmd_log(LOG_ERR, "Failed to read %s", filename); + fclose(file); continue; } diff --git a/xcpmd/src/default-inputs-module.c b/xcpmd/src/default-inputs-module.c index d1e51a64..12b0632e 100644 --- a/xcpmd/src/default-inputs-module.c +++ b/xcpmd/src/default-inputs-module.c @@ -53,6 +53,7 @@ struct cond_table_row { char * prototype; char * pretty_prototype; unsigned int event_index; + void (* on_instantiate)(struct condition *); }; @@ -62,7 +63,7 @@ static const struct event_data_row event_data[] = { }; static const struct cond_table_row condition_table[] = { - {"dummy_condition", dummy_condition, "n", "void", DUMMY_EVENT} + {"dummy_condition", dummy_condition, "n", "void", DUMMY_EVENT, NULL} }; static const unsigned int num_events = sizeof(event_data) / sizeof(event_data[0]); @@ -87,7 +88,7 @@ static void __attribute__((constructor)) init_module() { for (i=0; i < condition_table_size; ++i) { struct cond_table_row entry = condition_table[i]; - add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, default_event_table[entry.event_index]); + add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, default_event_table[entry.event_index], entry.on_instantiate); } } diff --git a/xcpmd/src/displayhandler-module.c b/xcpmd/src/displayhandler-module.c new file mode 100644 index 00000000..1b64b959 --- /dev/null +++ b/xcpmd/src/displayhandler-module.c @@ -0,0 +1,66 @@ +#include "project.h" +#include "xcpmd.h" +#include "rpcgen/vglass_client.h" +#include "rules.h" + +//Function prototypes +void screen_on(struct arg_node * args); +void screen_off(struct arg_node * args); + + +//Private data structures +struct action_table_row { + char * name; + void (* func)(struct arg_node *); + char * prototype; + char * pretty_prototype; +}; + + +//Private data +static struct action_table_row action_table[] = { + {"screenOn" , screen_on , "n" , "void" } , + {"screenOff" , screen_off , "n" , "void" } +}; + +static unsigned int num_action_types = sizeof(action_table) / sizeof(action_table[0]); +static int times_loaded = 0; + + +//Registers this module's action types. +//The constructor attribute causes this function to run at load (dlopen()) time. +__attribute__ ((constructor)) static void init_module() { + + unsigned int i; + + if (times_loaded > 0) + return; + + for (i=0; i < num_action_types; ++i) { + add_action_type(action_table[i].name, action_table[i].func, action_table[i].prototype, action_table[i].pretty_prototype); + } +} + + +//Cleans up after this module. +//The destructor attribute causes this to run at unload (dlclose()) time. +__attribute__ ((destructor)) static void uninit_module() { + + --times_loaded; + + //if (times_loaded > 0) + // return; + + return; +} + + +//Actions +void screen_on(struct arg_node * args) { + mil_af_secureview_vglass_set_dpms_(xcdbus_conn, "mil.af.secureview.vglass", "/mil/af/secureview/vglass", false); +} + + +void screen_off(struct arg_node * args) { + mil_af_secureview_vglass_set_dpms_(xcdbus_conn, "mil.af.secureview.vglass", "/mil/af/secureview/vglass", true); +} diff --git a/xcpmd/src/idle-detect-module.c b/xcpmd/src/idle-detect-module.c new file mode 100644 index 00000000..1e2b4f56 --- /dev/null +++ b/xcpmd/src/idle-detect-module.c @@ -0,0 +1,288 @@ +/* + * idle-detect-module.c + * + * XCPMD module that provides display power management actions. + * + * Copyright (c) 2015 Assured Information Security, Inc. + * + * Author: + * Jennifer Temkin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "project.h" +#include "xcpmd.h" +#include "rpcgen/input_daemon_client.h" +#include "rules.h" +#include "modules.h" +#include "vm-utils.h" +#include "idle-detect-module.h" + +#define DAR_TIMER_NAME "dar-shutdown" + +//Private data structures +struct event_data_row { + char * name; + bool is_stateless; + enum arg_type value_type; + union arg_u reset_value; + unsigned int index; +}; + +struct cond_table_row { + char * name; + bool (* func)(struct ev_wrapper *, struct arg_node *); + char * prototype; + char * pretty_prototype; + unsigned int event_index; + void (* on_instantiate)(struct condition *); +}; + +struct timer { + struct list_head list; + char * name; + int timeout; + bool set; + struct event set_event; +}; + + +//Function prototypes +static DBusHandlerResult idle_timeout_handler(DBusConnection * connection, DBusMessage * dbus_message, void * user_data); +static void dar_idle_instantiate(struct condition * condition); +static bool dar_idle(struct ev_wrapper * event, struct arg_node * args); +static void set_timer(int fd, short event, void *opaque); +static struct timer * get_timer(char * name); +static struct timer * add_timer_to_list(char * name, int timeout); + + +//Private data +static struct event_data_row event_data[] = { + {"event_on_idle", IS_STATELESS, ARG_STR, { .str = "" }, EVENT_ON_IDLE} +}; + +static struct cond_table_row condition_data[] = { +// {"WhenIdleFor", on_idle, "i", "int timeout_seconds", EVENT_ON_IDLE, on_idle_instantiate} + {"whenDarIdleTimeout", dar_idle, "i", "int timeout_seconds", EVENT_ON_IDLE, dar_idle_instantiate} +}; + +static unsigned int num_events = sizeof(event_data) / sizeof(event_data[0]); +static unsigned int num_conditions = sizeof(condition_data) / sizeof(condition_data[0]); + +static struct timer timer_list; + + +//Public data +struct ev_wrapper ** _idle_event_table; + + +//Initializes the module. +//The constructor attribute causes this function to run at load (dlopen()) time. +__attribute__((constructor)) static void init_module() { + + unsigned i; + + //Allocate space for event tables. + _idle_event_table = (struct ev_wrapper **)malloc(num_events * sizeof(struct ev_wrapper *)); + if (!(_idle_event_table)) { + xcpmd_log(LOG_ERR, "Failed to allocate memory\n"); + return; + } + + //Add all events to the event list. + for (i=0; i < num_events; ++i) { + struct event_data_row entry = event_data[i]; + _idle_event_table[entry.index] = add_event(entry.name, entry.is_stateless, entry.value_type, entry.reset_value); + } + + //Add all condition_types to the condition_type list. + for (i=0; i < num_conditions; ++i) { + struct cond_table_row entry = condition_data[i]; + add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, _idle_event_table[entry.event_index], entry.on_instantiate); + } + + //Initialize internal timer list + INIT_LIST_HEAD(&timer_list.list); + + //Set up a match and filter to get signals. + add_dbus_filter("type='signal',interface='com.citrix.xenclient.input',member='idle_timeout'", idle_timeout_handler, NULL, NULL); +} + + +//Cleans up after this module. +//The destructor attribute causes this to run at unload (dlclose()) time. +__attribute__((destructor)) static void uninit_module() { + + struct timer * t, *tmp; + + //Free event tables. + free(_idle_event_table); + + //Remove DBus filter. + remove_dbus_filter("type='signal',interface='com.citrix.xenclient.input',member='idle_timeout'", idle_timeout_handler, NULL); + + //Delete timer list. + list_for_each_entry_safe(t, tmp, &timer_list.list, list) { + list_del(&t->list); + free(t->name); + t->name = NULL; + evtimer_del(&t->set_event); + free(t); + } +} + + +//Adds a timer to our internal list. +struct timer * add_timer_to_list(char * name, int timeout) { + + struct timer * new_timer; + + new_timer = (struct timer *)malloc(sizeof (struct timer)); + if (new_timer == NULL) { + xcpmd_log(LOG_ERR, "Failed to allocate memory\n"); + return NULL; + } + + new_timer->name = clone_string(name); + if (new_timer->name == NULL) { + free(new_timer); + return NULL; + } + + new_timer->set = false; + new_timer->timeout = timeout; + event_set(&new_timer->set_event, -1, EV_TIMEOUT, set_timer, new_timer); + list_add(&new_timer->list, &timer_list.list); + + return new_timer; +} + + +//Checks if a timer is already in our internal list. +struct timer * get_timer(char * name) { + + struct timer * t; + struct timer * found = NULL; + + list_for_each_entry(t, &timer_list.list, list) { + if (strcmp(t->name, name) == 0) { + found = t; + break; + } + } + + return found; +} + + +//Instantiation callbacks +void dar_idle_instantiate(struct condition * condition) { + + int timeout; + struct timer * timer; + + timeout = get_arg(&condition->args, 0)->arg.i; + timer = get_timer(DAR_TIMER_NAME); + + //Does this timer exist yet? + if (timer == NULL) { + timer = add_timer_to_list(DAR_TIMER_NAME, timeout); + } + + //Is this timer receiving a new timeout value? + if (timer->timeout != timeout) { + timer->set = false; + timer->timeout = timeout; + } + + //Does this timer still need to tell the input server? + if (timer->set == false) { + set_timer(0, 0, timer); + } +} + + +void set_timer(int fd, short event, void *opaque) { + + struct timeval tv; + struct timer * timer = (struct timer *)opaque; + + xcpmd_log(LOG_DEBUG, "Sanity test."); + + if (timer == NULL || timer->name == NULL || get_timer(timer->name) == NULL) { + xcpmd_log(LOG_DEBUG, "Timer event fired, but timer object seems to have disappeared?"); + return; + } + + //Don't set a timeout of 0--at the time of writing, this causes the input server to constantly emit signals. + if (timer->timeout == 0) { + xcpmd_log(LOG_DEBUG, "Timer %s has a timeout of zero; not setting.\n", timer->name); + timer->set = true; + } + else if (com_citrix_xenclient_input_update_idle_timer_(xcdbus_conn, INPUT_SERVICE, INPUT_PATH, timer->name, timer->timeout * 60)) { + xcpmd_log(LOG_DEBUG, "Updating timer %s with timeout %i.\n", timer->name, timer->timeout * 60); + timer->set = true; + } + else { + xcpmd_log(LOG_DEBUG, "Updating timer %s failed; retrying...\n", timer->name); + memset(&tv, 0, sizeof(tv)); + tv.tv_sec = 5; + evtimer_add(&timer->set_event, &tv); + } +} + +//Condition checkers +bool dar_idle(struct ev_wrapper * event, struct arg_node * args) { + + return (strcmp(event->value.str, DAR_TIMER_NAME) == 0); +} + + +//This signal handler is called whenever a matched signal is received. +DBusHandlerResult idle_timeout_handler(DBusConnection * connection, DBusMessage * dbus_message, void * user_data) { + + //type = dbus_message_get_type(dbus_message); + //path = dbus_message_get_path(dbus_message); + //interface = dbus_message_get_interface(dbus_message); + //member = dbus_message_get_member(dbus_message); + //xcpmd_log(LOG_DEBUG, "DBus message: type=%i, interface=%s, path=%s, member=%s\n", type, interface, path, member); + + DBusError error; + char * timer_name; + struct timer * timer; + struct ev_wrapper * e; + DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (dbus_message_is_signal(dbus_message, "com.citrix.xenclient.input", "idle_timeout")) { + + dbus_error_init(&error); + if (!dbus_message_get_args(dbus_message, &error, DBUS_TYPE_STRING, &timer_name, DBUS_TYPE_INVALID)) { + xcpmd_log(LOG_ERR, "dbus_message_get_args() failed: %s (%s).\n", error.name, error.message); + } + dbus_error_free(&error); + + timer = get_timer(timer_name); + if (timer != NULL) { + if (timer->timeout > 0) { + e = _idle_event_table[EVENT_ON_IDLE]; + e->value.str = timer_name; + handle_events(e); + } + ret = DBUS_HANDLER_RESULT_HANDLED; + } + } + + return ret; +} diff --git a/xcpmd/src/idle-detect-module.h b/xcpmd/src/idle-detect-module.h new file mode 100644 index 00000000..2cdd4828 --- /dev/null +++ b/xcpmd/src/idle-detect-module.h @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2015 Assured Information Security, Inc. +* +* Author: +* Jennifer Temkin +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License version 2 +* as published by the Free Software Foundation +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __IDLE_DETECT_MODULES_H__ +#define __IDLE_DETECT_MODULES_H__ + +#define EVENT_ON_IDLE 0 + +#endif diff --git a/xcpmd/src/modules.c b/xcpmd/src/modules.c index 98fb4b55..b1acdb7d 100644 --- a/xcpmd/src/modules.c +++ b/xcpmd/src/modules.c @@ -45,9 +45,11 @@ //Private data static char * _module_list[] = { MODULE_PATH "acpi-module.so", - MODULE_PATH "vm-actions-module.so", MODULE_PATH "default-actions-module.so", - MODULE_PATH "vm-events-module.so" + MODULE_PATH "displayhandler-module.so", + MODULE_PATH "idle-detect-module.so", + MODULE_PATH "vm-actions-module.so", + MODULE_PATH "vm-events-module.so", }; diff --git a/xcpmd/src/rules.c b/xcpmd/src/rules.c index eb1ada9f..5a959477 100644 --- a/xcpmd/src/rules.c +++ b/xcpmd/src/rules.c @@ -141,7 +141,7 @@ struct ev_wrapper * add_event(char * event_name, bool is_stateless, enum arg_typ //Allocates memory! //Creates a new condition_type and adds it to the shared list of condition_types. //Returns the new condition type. -struct condition_type * add_condition_type(char * name, bool (* check)(struct ev_wrapper *, struct arg_node *), char * prototype, char * pretty_prototype, struct ev_wrapper * event) { +struct condition_type * add_condition_type(char * name, bool (* check)(struct ev_wrapper *, struct arg_node *), char * prototype, char * pretty_prototype, struct ev_wrapper * event, void (* on_instantiate)(struct condition *)) { struct condition_type * new_condition_type = (struct condition_type *)malloc(sizeof(struct condition_type)); if (new_condition_type == NULL) { @@ -154,6 +154,7 @@ struct condition_type * add_condition_type(char * name, bool (* check)(struct ev new_condition_type->prototype = prototype; new_condition_type->pretty_prototype = pretty_prototype; new_condition_type->event = event; + new_condition_type->on_instantiate = on_instantiate; list_add_tail(&(new_condition_type->list), &(condition_types.list)); @@ -225,7 +226,6 @@ struct condition * new_condition(struct condition_type * type) { return NULL; } - new_condition->type = type; new_condition->is_true = false; new_condition->is_inverted = false; @@ -334,6 +334,11 @@ void add_condition_to_rule(struct rule * rule, struct condition * condition) { condition->rule = rule; list_add_tail(&(condition->list), &(rule->conditions.list)); + + //Perform any initialization tasks that need doing. + if (condition->type->on_instantiate) { + condition->type->on_instantiate(condition); + } } diff --git a/xcpmd/src/rules.h b/xcpmd/src/rules.h index d403ce99..f98bc516 100644 --- a/xcpmd/src/rules.h +++ b/xcpmd/src/rules.h @@ -150,6 +150,7 @@ struct condition_type { char * prototype; char * pretty_prototype; struct ev_wrapper * event; + void (* on_instantiate)(struct condition *); //Called whenever this condition_type is instantiated. }; @@ -219,7 +220,7 @@ extern struct db_var db_vars; //Function prototypes struct ev_wrapper * add_event(char * event_name, bool is_stateless, enum arg_type value_type, union arg_u reset_value); -struct condition_type * add_condition_type(char * name, bool (* check)(struct ev_wrapper *, struct arg_node *), char * prototype, char * pretty_prototype, struct ev_wrapper * event); +struct condition_type * add_condition_type(char * name, bool (* check)(struct ev_wrapper *, struct arg_node *), char * prototype, char * pretty_prototype, struct ev_wrapper * event, void (*on_instantiate)(struct condition *)); struct action_type * add_action_type(char * name, void (* action_func)(struct arg_node *), char * prototype, char * pretty_prototype); struct rule * new_rule(char * id); diff --git a/xcpmd/src/vm-events-module.c b/xcpmd/src/vm-events-module.c index 8436a8c9..5fa08b63 100644 --- a/xcpmd/src/vm-events-module.c +++ b/xcpmd/src/vm-events-module.c @@ -74,6 +74,7 @@ struct cond_table_row { char * prototype; char * pretty_prototype; unsigned int event_index; + void (* on_instantiate)(struct condition *); }; @@ -88,24 +89,24 @@ static struct event_data_row event_data[] = { }; static struct cond_table_row condition_data[] = { - {"whenAnyVmCreating" , any_vm_creating , "n" , "void" , EVENT_VM_CREATING } , - {"whenAnyVmStopping" , any_vm_stopping , "n" , "void" , EVENT_VM_STOPPING } , - {"whenAnyVmRebooting" , any_vm_rebooting , "n" , "void" , EVENT_VM_REBOOTING } , - {"whenAnyVmRunning" , any_vm_running , "n" , "void" , EVENT_VM_RUNNING } , - {"whenAnyVmStopped" , any_vm_stopped , "n" , "void" , EVENT_VM_STOPPED } , - {"whenAnyVmPaused" , any_vm_paused , "n" , "void" , EVENT_VM_PAUSED } , - {"whenVmUuidCreating" , vm_with_uuid_creating , "s" , "string uuid" , EVENT_VM_CREATING } , - {"whenVmUuidStopping" , vm_with_uuid_stopping , "s" , "string uuid" , EVENT_VM_STOPPING } , - {"whenVmUuidRebooting" , vm_with_uuid_rebooting , "s" , "string uuid" , EVENT_VM_REBOOTING } , - {"whenVmUuidRunning" , vm_with_uuid_running , "s" , "string uuid" , EVENT_VM_RUNNING } , - {"whenVmUuidStopped" , vm_with_uuid_stopped , "s" , "string uuid" , EVENT_VM_STOPPED } , - {"whenVmUuidPaused" , vm_with_uuid_paused , "s" , "string uuid" , EVENT_VM_PAUSED } , - {"whenVmCreating" , vm_with_name_creating , "s" , "string name" , EVENT_VM_CREATING } , - {"whenVmStopping" , vm_with_name_stopping , "s" , "string name" , EVENT_VM_STOPPING } , - {"whenVmRebooting" , vm_with_name_rebooting , "s" , "string name" , EVENT_VM_REBOOTING } , - {"whenVmRunning" , vm_with_name_running , "s" , "string name" , EVENT_VM_RUNNING } , - {"whenVmStopped" , vm_with_name_stopped , "s" , "string name" , EVENT_VM_STOPPED } , - {"whenVmPaused" , vm_with_name_paused , "s" , "string name" , EVENT_VM_PAUSED } + {"whenAnyVmCreating" , any_vm_creating , "n" , "void" , EVENT_VM_CREATING , NULL } , + {"whenAnyVmStopping" , any_vm_stopping , "n" , "void" , EVENT_VM_STOPPING , NULL } , + {"whenAnyVmRebooting" , any_vm_rebooting , "n" , "void" , EVENT_VM_REBOOTING , NULL } , + {"whenAnyVmRunning" , any_vm_running , "n" , "void" , EVENT_VM_RUNNING , NULL } , + {"whenAnyVmStopped" , any_vm_stopped , "n" , "void" , EVENT_VM_STOPPED , NULL } , + {"whenAnyVmPaused" , any_vm_paused , "n" , "void" , EVENT_VM_PAUSED , NULL } , + {"whenVmUuidCreating" , vm_with_uuid_creating , "s" , "string uuid" , EVENT_VM_CREATING , NULL } , + {"whenVmUuidStopping" , vm_with_uuid_stopping , "s" , "string uuid" , EVENT_VM_STOPPING , NULL } , + {"whenVmUuidRebooting" , vm_with_uuid_rebooting , "s" , "string uuid" , EVENT_VM_REBOOTING , NULL } , + {"whenVmUuidRunning" , vm_with_uuid_running , "s" , "string uuid" , EVENT_VM_RUNNING , NULL } , + {"whenVmUuidStopped" , vm_with_uuid_stopped , "s" , "string uuid" , EVENT_VM_STOPPED , NULL } , + {"whenVmUuidPaused" , vm_with_uuid_paused , "s" , "string uuid" , EVENT_VM_PAUSED , NULL } , + {"whenVmCreating" , vm_with_name_creating , "s" , "string name" , EVENT_VM_CREATING , NULL } , + {"whenVmStopping" , vm_with_name_stopping , "s" , "string name" , EVENT_VM_STOPPING , NULL } , + {"whenVmRebooting" , vm_with_name_rebooting , "s" , "string name" , EVENT_VM_REBOOTING , NULL } , + {"whenVmRunning" , vm_with_name_running , "s" , "string name" , EVENT_VM_RUNNING , NULL } , + {"whenVmStopped" , vm_with_name_stopped , "s" , "string name" , EVENT_VM_STOPPED , NULL } , + {"whenVmPaused" , vm_with_name_paused , "s" , "string name" , EVENT_VM_PAUSED , NULL } }; static unsigned int num_events = sizeof(event_data) / sizeof(event_data[0]); @@ -138,7 +139,7 @@ __attribute__((constructor)) static void init_module() { //Add all condition_types to the condition_type list. for (i=0; i < num_conditions; ++i) { struct cond_table_row entry = condition_data[i]; - add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, _vm_event_table[entry.event_index]); + add_condition_type(entry.name, entry.func, entry.prototype, entry.pretty_prototype, _vm_event_table[entry.event_index], entry.on_instantiate); } //Set up a match and filter to get signals. diff --git a/xcpmd/src/xcpmd.h b/xcpmd/src/xcpmd.h index ce7acecc..d80c2e92 100644 --- a/xcpmd/src/xcpmd.h +++ b/xcpmd/src/xcpmd.h @@ -43,6 +43,8 @@ #define XENMGR_PATH "/" #define DB_SERVICE "com.citrix.xenclient.db" #define DB_PATH "/" +#define INPUT_SERVICE "com.citrix.xenclient.input" +#define INPUT_PATH "/" #define PCI_INVALID_VALUE 0xffffffff #define EFI_LINE_SIZE 64