006QubesAdminVm.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_usage(self, file_or_dir):
  47. return 0
  48. def get_disk_utilization(self):
  49. return 0
  50. def get_disk_utilization_private_img(self):
  51. return 0
  52. def get_private_img_sz(self):
  53. return 0
  54. @property
  55. def ip(self):
  56. return "10.137.0.2"
  57. def start(self, **kwargs):
  58. raise QubesException ("Cannot start Dom0 fake domain!")
  59. def suspend(self):
  60. return
  61. def get_xl_dominfo(self):
  62. if dry_run:
  63. return
  64. domains = xl_ctx.list_domains()
  65. for dominfo in domains:
  66. if dominfo.domid == 0:
  67. return dominfo
  68. return None
  69. def get_xc_dominfo(self):
  70. if dry_run:
  71. return
  72. domains = xc.domain_getinfo(0, 1)
  73. return domains[0]
  74. def verify_files(self):
  75. return True
  76. register_qubes_vm_class(QubesAdminVm)