qubesadmin.vm package

Module contents

Qubes VM objects.

class qubesadmin.vm.DispVM(app, name, klass=None)[source]

Bases: qubesadmin.vm.QubesVM

Disposable VM

classmethod from_appvm(app, appvm)[source]

Returns a wrapper for calling service in a new DispVM based on given AppVM. If appvm is none, use default DispVM template

class qubesadmin.vm.DispVMWrapper(app, name, klass=None)[source]

Bases: qubesadmin.vm.QubesVM

Wrapper class for new DispVM, supporting only service call

Note that when running in dom0, one need to manually kill the DispVM after service call ends.

cleanup()[source]

Cleanup after DispVM usage

run_service(service, **kwargs)[source]

Run service on this VM

Parameters:service (str) – service name
Return type:subprocess.Popen
class qubesadmin.vm.QubesVM(app, name, klass=None)[source]

Bases: qubesadmin.base.PropertyHolder

Qubes domain.

appvms

Returns a generator containing all domains based on the current TemplateVM.

Do not check vm type of self, core (including its extentions) have ultimate control what can be a template of what.

connected_vms

Return a generator containing all domains connected to the current NetVM.

devices = None
features = None
firewall = None
force_shutdown()[source]

Deprecated alias for kill()

get_disk_utilization()[source]

Get total disk usage of the VM

get_power_state()[source]

Return power state description string.

Return value may be one of those:

return value meaning
'Halted' Machine is not active.
'Transient' Machine is running, but does not have guid or qrexec available.
'Running' Machine is ready and running.
'Paused' Machine is paused.
'Suspended' Machine is S3-suspended.
'Halting' Machine is in process of shutting down (OS shutdown).
'Dying' Machine is in process of shutting down (cleanup).
'Crashed' Machine crashed and is unusable.
'NA' Machine is in unknown state.

See also

http://wiki.libvirt.org/page/VM_lifecycle
Description of VM life cycle from the point of view of libvirt.
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainState
Libvirt’s enum describing precise state of a domain.
is_halted()[source]

Check whether this domain’s state is ‘Halted’ :returns: True if this domain is halted, False otherwise. :rtype: bool

is_networked()[source]

Check whether this VM can reach network (firewall notwithstanding).

Returns:True if is machine can reach network, False otherwise.
Return type:bool
is_paused()[source]

Check whether this domain is paused.

Returns:True if this domain is paused, False otherwise.
Return type:bool
is_running()[source]

Check whether this domain is running.

Returns:True if this domain is started, False otherwise.
Return type:bool
kill()[source]

Kill domain (forcefuly shutdown).

Returns:
klass

Qube class

log = None
name

Domain name

pause()[source]

Pause domain.

Pause its execution without any prior notification.

Returns:
prepare_input_for_vmshell(command, input=None)[source]

Prepare shell input for the given command and optional (real) input

run(command, input=None, **kwargs)[source]

Run a shell command inside the domain using qubes.VMShell qrexec.

run_service(service, **kwargs)[source]

Run service on this VM

Parameters:service (str) – service name
Return type:subprocess.Popen
run_service_for_stdio(service, input=None, **kwargs)[source]

Run a service, pass an optional input and return (stdout, stderr).

Raises an exception if return code != 0.

args and kwargs are passed verbatim to run_service().

Warning

There are some combinations if stdio-related kwargs, which are not filtered for problems originating between the keyboard and the chair.

shutdown(force=False)[source]

Shutdown domain.

Returns:
start()[source]

Start domain.

Returns:
tags = None
unpause()[source]

Unpause domain.

Opposite to pause().

Returns:
volumes

VM disk volumes