006QubesAdminVm.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/python2
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
  6. # Copyright (C) 2013 Marek Marczykowski <marmarek@invisiblethingslab.com>
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. #
  22. #
  23. from qubes.qubes import QubesNetVm,register_qubes_vm_class,xl_ctx,xc
  24. from qubes.qubes import defaults
  25. from qubes.qubes import QubesException,dry_run
  26. class QubesAdminVm(QubesNetVm):
  27. # In which order load this VM type from qubes.xml
  28. load_order = 10
  29. def __init__(self, **kwargs):
  30. super(QubesAdminVm, self).__init__(qid=0, name="dom0", netid=0,
  31. dir_path=None,
  32. private_img = None,
  33. template = None,
  34. label = defaults["template_label"],
  35. **kwargs)
  36. self.xid = 0
  37. @property
  38. def type(self):
  39. return "AdminVM"
  40. def is_running(self):
  41. return True
  42. def get_xid(self):
  43. return 0
  44. def get_power_state(self):
  45. return "Running"
  46. def get_disk_utilization(self):
  47. return 0
  48. def get_disk_utilization_private_img(self):
  49. return 0
  50. def get_private_img_sz(self):
  51. return 0
  52. @property
  53. def ip(self):
  54. return "10.137.0.2"
  55. def start(self, **kwargs):
  56. raise QubesException ("Cannot start Dom0 fake domain!")
  57. def suspend(self):
  58. return
  59. def get_xl_dominfo(self):
  60. if dry_run:
  61. return
  62. domains = xl_ctx.list_domains()
  63. for dominfo in domains:
  64. if dominfo.domid == 0:
  65. return dominfo
  66. return None
  67. def get_xc_dominfo(self):
  68. if dry_run:
  69. return
  70. domains = xc.domain_getinfo(0, 1)
  71. return domains[0]
  72. def verify_files(self):
  73. return True
  74. register_qubes_vm_class(QubesAdminVm)