appvm.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/python2 -O
  2. # vim: fileencoding=utf-8
  3. #
  4. # The Qubes OS Project, http://www.qubes-os.org
  5. #
  6. # Copyright (C) 2014-2016 Wojtek Porczyk <woju@invisiblethingslab.com>
  7. # Copyright (C) 2016 Marek Marczykowski <marmarek@invisiblethingslab.com>)
  8. # Copyright (C) 2016 Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License along
  21. # with this program; if not, write to the Free Software Foundation, Inc.,
  22. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. #
  24. ''' This module contains the AppVM implementation '''
  25. import qubes.events
  26. import qubes.vm.qubesvm
  27. from qubes.config import defaults
  28. class AppVM(qubes.vm.qubesvm.QubesVM):
  29. '''Application VM'''
  30. template = qubes.VMProperty('template',
  31. load_stage=4,
  32. vmclass=qubes.vm.templatevm.TemplateVM,
  33. ls_width=31,
  34. doc='Template, on which this AppVM is based.')
  35. def __init__(self, *args, **kwargs):
  36. self.volume_config = {
  37. 'root': {
  38. 'name': 'root',
  39. 'pool': 'default',
  40. 'volume_type': 'snapshot',
  41. 'internal': True
  42. },
  43. 'private': {
  44. 'name': 'private',
  45. 'pool': 'default',
  46. 'volume_type': 'origin',
  47. 'size': defaults['private_img_size'],
  48. 'internal': True
  49. },
  50. 'volatile': {
  51. 'name': 'volatile',
  52. 'pool': 'default',
  53. 'volume_type': 'volatile',
  54. 'size': defaults['root_img_size'],
  55. 'internal': True
  56. },
  57. 'kernel': {
  58. 'name': 'kernel',
  59. 'pool': 'linux-kernel',
  60. 'volume_type': 'read-only',
  61. 'internal': True
  62. }
  63. }
  64. super(AppVM, self).__init__(*args, **kwargs)
  65. @qubes.events.handler('domain-load')
  66. def on_domain_loaded(self, event):
  67. ''' When domain is loaded assert that this vm has a template.
  68. ''' # pylint: disable=unused-argument
  69. assert self.template