006QubesAdminVm.py 2.6 KB

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