ext/windows: copy private.img on windows TemplateBasedVM creation

This is a workaround for missing private.img initialization in Qubes
Windows Tools.

QubesOS/qubes-issues#3585
This commit is contained in:
Marek Marczykowski-Górecki 2018-07-16 22:02:05 +02:00
parent e6edbabf94
commit 0e089ca38d
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -17,6 +17,7 @@
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
import asyncio
import qubes.ext
@ -49,8 +50,9 @@ class WindowsFeatures(qubes.ext.Extension):
if guest_os == 'Windows' and qrexec:
vm.features['rpc-clipboard'] = True
@qubes.ext.handler('domain-add', system=True)
def on_domain_add(self, app, _event, vm, **kwargs):
@qubes.ext.handler('domain-create-on-disk')
@asyncio.coroutine
def on_domain_create_on_disk(self, vm, _event, **kwargs):
# pylint: disable=no-self-use,unused-argument
if getattr(vm, 'template', None) is None:
# handle only template-based vms
@ -61,4 +63,11 @@ class WindowsFeatures(qubes.ext.Extension):
# ignore non-windows templates
return
# TODO: consider copying template's root volume here
if vm.volumes['private'].save_on_stop:
# until windows tools get ability to prepare private.img on its own,
# copy one from the template
vm.log.info('Windows template - cloning private volume')
import_op = vm.volumes['private'].import_volume(
template.volumes['private'])
if asyncio.iscoroutine(import_op):
yield from import_op