006QubesDom0NetVm.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 QubesDom0NetVm(QubesNetVm):
  27. def __init__(self, **kwargs):
  28. super(QubesDom0NetVm, self).__init__(qid=0, name="dom0", netid=0,
  29. dir_path=None,
  30. private_img = None,
  31. template = None,
  32. label = defaults["template_label"],
  33. **kwargs)
  34. self.xid = 0
  35. def is_running(self):
  36. return True
  37. def get_xid(self):
  38. return 0
  39. def get_power_state(self):
  40. return "Running"
  41. def get_disk_usage(self, file_or_dir):
  42. return 0
  43. def get_disk_utilization(self):
  44. return 0
  45. def get_disk_utilization_private_img(self):
  46. return 0
  47. def get_private_img_sz(self):
  48. return 0
  49. @property
  50. def ip(self):
  51. return "10.137.0.2"
  52. def start(self, **kwargs):
  53. raise QubesException ("Cannot start Dom0 fake domain!")
  54. def suspend(self):
  55. return
  56. def get_xl_dominfo(self):
  57. if dry_run:
  58. return
  59. domains = xl_ctx.list_domains()
  60. for dominfo in domains:
  61. if dominfo.domid == 0:
  62. return dominfo
  63. return None
  64. def get_xc_dominfo(self):
  65. if dry_run:
  66. return
  67. domains = xc.domain_getinfo(0, 1)
  68. return domains[0]
  69. def create_xml_element(self):
  70. return None
  71. def verify_files(self):
  72. return True
  73. register_qubes_vm_class(QubesDom0NetVm)