From 455542ac7fe66c713966cce2fbac1498a08fa56e Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Tue, 14 Jul 2020 01:48:19 +0800 Subject: [PATCH] Add admin.vm.volume.Clear call (QubesOS/qubes-issues#5946) --- qubesadmin/storage.py | 4 ++++ qubesadmin/tools/qvm_template_postprocess.py | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qubesadmin/storage.py b/qubesadmin/storage.py index e4959b5..7487f77 100644 --- a/qubesadmin/storage.py +++ b/qubesadmin/storage.py @@ -236,6 +236,10 @@ class Volume(object): 'ImportWithSize', payload=size_line.encode(), payload_stream=stream) + def clear_data(self): + ''' Clear existing volume content. ''' + self._qubesd_call('Clear') + def clone(self, source): ''' Clone data from sane volume of another VM. diff --git a/qubesadmin/tools/qvm_template_postprocess.py b/qubesadmin/tools/qvm_template_postprocess.py index 31696b1..ca5ec7f 100644 --- a/qubesadmin/tools/qvm_template_postprocess.py +++ b/qubesadmin/tools/qvm_template_postprocess.py @@ -124,8 +124,7 @@ def import_root_img(vm, source_dir): def reset_private_img(vm): '''Clear private volume''' - with open('/dev/null', 'rb') as null: - vm.volumes['private'].import_data(stream=null) + vm.volumes['private'].clear_data() def import_appmenus(vm, source_dir):