mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
guest: Only use define+start logic for vz
Handling this for qemu, which may need UNDEFINE_NVRAM flags to do the cleanup, is a pain, so move this logic to only apply to vz driver which doesn't support createXML Mentioned on list: https://www.redhat.com/archives/virt-tools-list/2017-April/msg00037.html
This commit is contained in:
parent
7aee124d9a
commit
8181e86098
@ -784,6 +784,8 @@ c.add_compare("--disk %(BLOCKVOL)s --cdrom %(EXISTIMG1)s --livecd --hvm", "xen-h
|
||||
#####################
|
||||
|
||||
c = vinst.add_category("vz", "--connect %(URI-VZ)s --noautoconsole")
|
||||
c.add_valid("--container") # validate the special define+start logic
|
||||
c.add_invalid("--container --transient") # doesn't support --transient
|
||||
c.add_compare(""" \
|
||||
--container \
|
||||
--filesystem type=template,source=centos-7-x86_64,target="/" \
|
||||
|
@ -383,6 +383,31 @@ class Guest(XMLBuilder):
|
||||
|
||||
return install_xml, final_xml
|
||||
|
||||
def _manual_transient_create(self, install_xml, final_xml, needs_boot):
|
||||
"""
|
||||
For hypervisors (like vz) that don't implement createXML,
|
||||
we need to define+start, and undefine on start failure
|
||||
"""
|
||||
domain = self.conn.defineXML(install_xml or final_xml)
|
||||
if not needs_boot:
|
||||
return domain
|
||||
|
||||
# Handle undefining the VM if the initial startup fails
|
||||
try:
|
||||
domain.create()
|
||||
except:
|
||||
import sys
|
||||
exc_info = sys.exc_info()
|
||||
try:
|
||||
domain.undefine()
|
||||
except:
|
||||
pass
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
|
||||
if install_xml and install_xml != final_xml:
|
||||
domain = self.conn.defineXML(final_xml)
|
||||
return domain
|
||||
|
||||
def _create_guest(self, meter, install_xml, final_xml, doboot, transient):
|
||||
"""
|
||||
Actually do the XML logging, guest defining/creating
|
||||
@ -392,27 +417,19 @@ class Guest(XMLBuilder):
|
||||
meter_label = _("Creating domain...")
|
||||
meter = util.ensure_meter(meter)
|
||||
meter.start(size=None, text=meter_label)
|
||||
needs_boot = doboot or self.installer.has_install_phase()
|
||||
|
||||
if self.type == "vz":
|
||||
if transient:
|
||||
raise RuntimeError(_("Domain type 'vz' doesn't support "
|
||||
"transient installs."))
|
||||
domain = self._manual_transient_create(
|
||||
install_xml, final_xml, needs_boot)
|
||||
|
||||
if transient:
|
||||
domain = self.conn.createXML(install_xml or final_xml, 0)
|
||||
else:
|
||||
# Not all hypervisors (vz) support createXML, so avoid it here
|
||||
domain = self.conn.defineXML(install_xml or final_xml)
|
||||
|
||||
# Handle undefining the VM if the initial startup fails
|
||||
if doboot or self.installer.has_install_phase():
|
||||
try:
|
||||
domain.create()
|
||||
except:
|
||||
import sys
|
||||
exc_info = sys.exc_info()
|
||||
try:
|
||||
domain.undefine()
|
||||
except:
|
||||
pass
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
|
||||
if install_xml and install_xml != final_xml:
|
||||
if transient or needs_boot:
|
||||
domain = self.conn.createXML(install_xml or final_xml, 0)
|
||||
if not transient:
|
||||
domain = self.conn.defineXML(final_xml)
|
||||
|
||||
self.domain = domain
|
||||
|
Loading…
Reference in New Issue
Block a user