mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
cli: Add --install bootdev=X,kernel=X,initrd=Z
This is the beginning of a big --install option, which will be used for tweaking less common elements of the install process
This commit is contained in:
parent
a4a577bd23
commit
1f4a5a1b43
@ -1,77 +1,3 @@
|
||||
<domain type="kvm">
|
||||
<name>rhel6.4</name>
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
<metadata>
|
||||
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
|
||||
<libosinfo:os id="http://redhat.com/rhel/6.4"/>
|
||||
</libosinfo:libosinfo>
|
||||
</metadata>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu>2</vcpu>
|
||||
<os>
|
||||
<type arch="x86_64" machine="pc">hvm</type>
|
||||
<boot dev="network"/>
|
||||
<boot dev="hd"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<vmport state="off"/>
|
||||
</features>
|
||||
<cpu mode="host-model"/>
|
||||
<clock offset="utc">
|
||||
<timer name="rtc" tickpolicy="catchup"/>
|
||||
<timer name="pit" tickpolicy="delay"/>
|
||||
<timer name="hpet" present="no"/>
|
||||
</clock>
|
||||
<on_reboot>destroy</on_reboot>
|
||||
<pm>
|
||||
<suspend-to-mem enabled="no"/>
|
||||
<suspend-to-disk enabled="no"/>
|
||||
</pm>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<disk type="file" device="disk">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<source file="/dev/default-pool/testvol1.img"/>
|
||||
<target dev="vda" bus="virtio"/>
|
||||
</disk>
|
||||
<controller type="usb" index="0" model="ich9-ehci1"/>
|
||||
<controller type="usb" index="0" model="ich9-uhci1">
|
||||
<master startport="0"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci2">
|
||||
<master startport="2"/>
|
||||
</controller>
|
||||
<controller type="usb" index="0" model="ich9-uhci3">
|
||||
<master startport="4"/>
|
||||
</controller>
|
||||
<interface type="bridge">
|
||||
<source bridge="testsuitebr0"/>
|
||||
<mac address="00:11:22:33:44:55"/>
|
||||
<model type="virtio"/>
|
||||
</interface>
|
||||
<console type="pty"/>
|
||||
<channel type="unix">
|
||||
<source mode="bind"/>
|
||||
<target type="virtio" name="org.qemu.guest_agent.0"/>
|
||||
</channel>
|
||||
<channel type="spicevmc">
|
||||
<target type="virtio" name="com.redhat.spice.0"/>
|
||||
</channel>
|
||||
<input type="tablet" bus="usb"/>
|
||||
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
|
||||
<image compression="off"/>
|
||||
</graphics>
|
||||
<sound model="ich6"/>
|
||||
<video>
|
||||
<model type="qxl"/>
|
||||
</video>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
<redirdev bus="usb" type="spicevmc"/>
|
||||
</devices>
|
||||
</domain>
|
||||
<domain type="kvm">
|
||||
<name>rhel6.4</name>
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
|
@ -907,8 +907,8 @@ c.add_compare("--connect " + utils.URIs.kvm_session + " --disk size=8 --os-varia
|
||||
c.add_compare("--disk none --location %(ISO-NO-OS)s,kernel=frib.img,initrd=/frob.img", "location-manual-kernel", prerun_check=missing_isoinfo) # --location with an unknown ISO but manually specified kernel paths
|
||||
c.add_compare("--disk %(EXISTIMG1)s --location %(ISOTREE)s --nonetworks", "location-iso", prerun_check=missing_isoinfo) # Using --location iso mounting
|
||||
c.add_compare("--disk %(EXISTIMG1)s --cdrom %(ISOLABEL)s", "cdrom-centos-label") # Using --cdrom with centos CD label, should use virtio etc.
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel5.4", "kvm-rhel5") # RHEL5 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --install bootdev=network --os-variant rhel5.4", "kvm-rhel5") # RHEL5 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --install kernel=./foo,initrd=./bar --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults
|
||||
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7", prerun_check=has_old_osinfo) # RHEL7 defaults
|
||||
c.add_compare("--connect " + utils.URIs.kvm_nodomcaps + " --disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-cpu-default-fallback", prerun_check=has_old_osinfo) # No domcaps, so mode=host-model isn't safe, so we fallback to host-model-only
|
||||
c.add_compare("--connect " + utils.URIs.kvm_nodomcaps + " --cpu host-copy --disk none --pxe", "kvm-hostcopy-fallback") # No domcaps so need to use capabilities for CPU host-copy
|
||||
|
18
virt-install
18
virt-install
@ -421,9 +421,15 @@ def build_installer(options, guest):
|
||||
location_kernel = None
|
||||
location_initrd = None
|
||||
install_bootdev = None
|
||||
installdata = None
|
||||
install_kernel = None
|
||||
install_initrd = None
|
||||
|
||||
has_installer = True
|
||||
|
||||
if options.install:
|
||||
installdata = cli.parse_install(options.install)
|
||||
|
||||
if options.unattended:
|
||||
if options.os_variant.is_none or options.os_variant.is_auto:
|
||||
fail(_("--unattended requires an explicit --os-variant"))
|
||||
@ -453,6 +459,10 @@ def build_installer(options, guest):
|
||||
cdrom = options.cdrom
|
||||
elif options.pxe:
|
||||
install_bootdev = "network"
|
||||
elif installdata:
|
||||
install_bootdev = installdata.bootdev
|
||||
install_kernel = installdata.kernel
|
||||
install_initrd = installdata.initrd
|
||||
elif (guest.os.is_container() or
|
||||
options.import_install or
|
||||
options.xmlonly or
|
||||
@ -470,7 +480,9 @@ def build_installer(options, guest):
|
||||
location=location,
|
||||
location_kernel=location_kernel,
|
||||
location_initrd=location_initrd,
|
||||
install_bootdev=install_bootdev)
|
||||
install_bootdev=install_bootdev,
|
||||
install_kernel=install_kernel,
|
||||
install_initrd=install_initrd)
|
||||
if cdrom and options.livecd:
|
||||
installer.livecd = True
|
||||
if options.unattended:
|
||||
@ -823,7 +835,9 @@ def parse_args():
|
||||
insg.add_argument("--initrd-inject", action="append",
|
||||
help=_("Add given file to root of initrd from --location"))
|
||||
insg.add_argument("--unattended", nargs="?", const=1,
|
||||
help=_("Perform a unattended installation"))
|
||||
help=_("Perform an unattended installation"))
|
||||
insg.add_argument("--install",
|
||||
help=_("Specify fine grained install options"))
|
||||
|
||||
# Takes a URL and just prints to stdout the detected distro name
|
||||
insg.add_argument("--test-media-detection", help=argparse.SUPPRESS)
|
||||
|
@ -1557,6 +1557,35 @@ def parse_check(checks):
|
||||
parser.parse(get_global_state())
|
||||
|
||||
|
||||
#####################
|
||||
# --install parsing #
|
||||
#####################
|
||||
|
||||
class ParserInstall(VirtCLIParser):
|
||||
cli_arg_name = "install"
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
VirtCLIParser._init_class(**kwargs)
|
||||
cls.add_arg("bootdev", "bootdev", can_comma=True)
|
||||
cls.add_arg("kernel", "kernel", can_comma=True)
|
||||
cls.add_arg("initrd", "initrd", can_comma=True)
|
||||
|
||||
|
||||
class InstallData:
|
||||
def __init__(self):
|
||||
self.bootdev = None
|
||||
self.kernel = None
|
||||
self.initrd = None
|
||||
|
||||
|
||||
def parse_install(optstr):
|
||||
installdata = InstallData()
|
||||
parser = ParserInstall(optstr or None)
|
||||
parser.parse(installdata)
|
||||
return installdata
|
||||
|
||||
|
||||
######################
|
||||
# --location parsing #
|
||||
######################
|
||||
|
@ -30,13 +30,15 @@ class Installer(object):
|
||||
:param location: An install tree URI, local directory, or ISO/CDROM path.
|
||||
Largely handled by installtreemedia helper class. Maps to virt-install
|
||||
--location
|
||||
:param install_bootdev: The VM bootdev to use (HD, NETWORK, CDROM, FLOPPY)
|
||||
:param location_kernel: URL pointing to a kernel to fetch, or a relative
|
||||
path to indicate where the kernel is stored in location
|
||||
:param location_initrd: location_kernel, but pointing to an initrd
|
||||
:param install_kernel: Kernel to install off of
|
||||
:param install initrd: Initrd to install off of
|
||||
"""
|
||||
def __init__(self, conn, cdrom=None, location=None, install_bootdev=None,
|
||||
location_kernel=None, location_initrd=None):
|
||||
location_kernel=None, location_initrd=None,
|
||||
install_kernel=None, install_initrd=None):
|
||||
self.conn = conn
|
||||
|
||||
self.livecd = False
|
||||
@ -68,9 +70,13 @@ class Installer(object):
|
||||
cdrom = InstallerTreeMedia.validate_path(self.conn, cdrom)
|
||||
self._cdrom = cdrom
|
||||
self._install_bootdev = "cdrom"
|
||||
if location:
|
||||
elif location:
|
||||
self._treemedia = InstallerTreeMedia(self.conn, location,
|
||||
location_kernel, location_initrd)
|
||||
elif install_kernel or install_initrd:
|
||||
self._install_kernel = os.path.realpath(install_kernel)
|
||||
self._install_initrd = os.path.realpath(install_initrd)
|
||||
self._install_bootdev = None
|
||||
|
||||
|
||||
###################
|
||||
|
Loading…
x
Reference in New Issue
Block a user