#!/usr/bin/python2 # # The Qubes OS Project, http://www.qubes-os.org # # Copyright (C) 2013 Marek Marczykowski # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. # from __future__ import absolute_import import ConfigParser import os import os.path import shutil import subprocess import sys import qubes.qubesutils from qubes.qubes import QubesException, defaults, system_path CONFIG_FILE = '/etc/qubes/storage.conf' class QubesVmStorage(object): """ Class for handling VM virtual disks. This is base class for all other implementations, mostly with Xen on Linux in mind. """ def __init__(self, vm, private_img_size = None, root_img_size = None, modules_img = None, modules_img_rw = False): self.vm = vm self.vmdir = vm.dir_path if private_img_size: self.private_img_size = private_img_size else: self.private_img_size = defaults['private_img_size'] if root_img_size: self.root_img_size = root_img_size else: self.root_img_size = defaults['root_img_size'] self.root_dev = "xvda" self.private_dev = "xvdb" self.volatile_dev = "xvdc" self.modules_dev = "xvdd" # For now compute this path still in QubesVm self.modules_img = modules_img self.modules_img_rw = modules_img_rw # Additional drive (currently used only by HVM) self.drive = None def format_disk_dev(self, path, script, vdev, rw=True, type="disk", domain=None): if path is None: return '' template = " \n" \ " \n" \ " \n" \ " \n" \ "{params}" \ " \n" params = "" if not rw: params += " \n" if domain: params += " \n" % domain if script: params += "