[virt-tools-list] [PATCH virt-install] virtinst: Add --transient flag.
Richard W.M. Jones
rjones at redhat.com
Wed Jun 1 13:32:56 UTC 2016
If this flag is specified, --import|--boot will create a transient
libvirt domain, ie. one which goes away when the guest shuts down or
the host is rebooted.
---
man/virt-install.pod | 9 +++++++++
virt-install | 4 ++++
virtinst/guest.py | 4 +++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/man/virt-install.pod b/man/virt-install.pod
index 0537693..01ba5ab 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -1559,6 +1559,15 @@ Show program's version number and exit
Set the autostart flag for a domain. This causes the domain to be started
on host boot up.
+=item B<--transient>
+
+Use --import or --boot and --transient if you want a transient libvirt
+VM. These VMs exist only until the domain is shut down or the host
+server is restarted. Libvirt forgets the XML configuration of the VM
+after either of these events. Note that the VM's disks will not be
+deleted. See:
+L<http://wiki.libvirt.org/page/VM_lifecycle#Transient_guest_domains_vs_Persistent_guest_domains>
+
=item B<--print-xml> [STEP]
Print the generated XML of the guest, instead of defining it. By default this WILL do storage creation (can be disabled with --dry-run). This option implies --quiet.
diff --git a/virt-install b/virt-install
index 6d1aa96..da74a25 100755
--- a/virt-install
+++ b/virt-install
@@ -594,6 +594,7 @@ def build_guest_instance(conn, options, parsermap):
guest.installer.extraargs = options.extra_args or []
guest.installer.initrd_injections = options.initrd_inject
guest.autostart = options.autostart
+ guest.transient = options.transient
if options.name:
guest.name = options.name
@@ -1002,6 +1003,9 @@ def parse_args():
misc.add_argument("--autostart", action="store_true", dest="autostart",
default=False,
help=_("Have domain autostart on host boot up."))
+ misc.add_argument("--transient", action="store_true", dest="transient",
+ default=False,
+ help=_("Create a transient domain."))
misc.add_argument("--wait", type=int, dest="wait",
help=_("Minutes to wait for install to complete."))
diff --git a/virtinst/guest.py b/virtinst/guest.py
index e38a2e3..336658d 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -112,6 +112,7 @@ class Guest(XMLBuilder):
XMLBuilder.__init__(self, *args, **kwargs)
self.autostart = False
+ self.transient = False
self.replace = False
# Allow virt-manager to override the default graphics type
@@ -425,7 +426,8 @@ class Guest(XMLBuilder):
self.domain = dom
meter.end(0)
- self.domain = self.conn.defineXML(final_xml)
+ if not self.transient:
+ self.domain = self.conn.defineXML(final_xml)
if is_initial:
try:
logging.debug("XML fetched from libvirt object:\n%s",
--
2.7.4
More information about the virt-tools-list
mailing list