cli: Support per-device <boot order=>

This commit is contained in:
Cole Robinson 2014-02-09 13:36:12 -05:00
parent fcac052cdc
commit 719f23a273
23 changed files with 61 additions and 25 deletions

View File

@ -17,8 +17,6 @@
<os>
<type arch="i686">hvm</type>
<loader>/foo/bar</loader>
<boot dev="network"/>
<boot dev="hd"/>
</os>
<idmap>
<uid start="0" target="1000" count="10"/>
@ -51,6 +49,7 @@
<target dev="hda" bus="ide"/>
<serial>WD-WMAP9A966149</serial>
<shareable/>
<boot order="2"/>
</disk>
<disk type="file" device="disk">
<driver error_policy="enospace"/>
@ -105,6 +104,7 @@
<virtualport type="802.1Qbg">
<parameters managerid="12" typeid="1193046" typeidversion="1" instanceid="09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b"/>
</virtualport>
<boot order="1"/>
</interface>
<input type="mouse" bus="ps2"/>
<serial type="tcp">
@ -118,8 +118,12 @@
<source>
<address domain="0" bus="0" slot="25" function="0"/>
</source>
<boot order="4"/>
</hostdev>
<smartcard mode="passthrough" type="spicevmc"/>
<redirdev bus="spicevmc" type="spicevmc">
<boot order="3"/>
</redirdev>
<tpm model="tpm-tis">
<backend type="passthrough">
<device path="/dev/tpm0"/>
@ -152,7 +156,6 @@
<os>
<type arch="i686">hvm</type>
<loader>/foo/bar</loader>
<boot dev="hd"/>
</os>
<idmap>
<uid start="0" target="1000" count="10"/>
@ -185,6 +188,7 @@
<target dev="hda" bus="ide"/>
<serial>WD-WMAP9A966149</serial>
<shareable/>
<boot order="2"/>
</disk>
<disk type="file" device="disk">
<driver error_policy="enospace"/>
@ -239,6 +243,7 @@
<virtualport type="802.1Qbg">
<parameters managerid="12" typeid="1193046" typeidversion="1" instanceid="09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b"/>
</virtualport>
<boot order="1"/>
</interface>
<input type="mouse" bus="ps2"/>
<serial type="tcp">
@ -252,8 +257,12 @@
<source>
<address domain="0" bus="0" slot="25" function="0"/>
</source>
<boot order="4"/>
</hostdev>
<smartcard mode="passthrough" type="spicevmc"/>
<redirdev bus="spicevmc" type="spicevmc">
<boot order="3"/>
</redirdev>
<tpm model="tpm-tis">
<backend type="passthrough">
<device path="/dev/tpm0"/>

View File

@ -7,6 +7,7 @@
<source>
<address bus="3" device="2"/>
</source>
<boot order="9"/>
+ <driver name="vfio"/>
</hostdev>
<hostdev mode="subsystem" type="pci" managed="yes">
@ -19,6 +20,7 @@
<source>
<address domain="0x0003" bus="0x00" slot="0x19" function="0x0"/>
</source>
<boot order="6"/>
+ <driver name="vfio"/>
</hostdev>
<redirdev bus="usb" type="tcp">

View File

@ -0,0 +1,2 @@
Domain 'test' defined successfully.
Changes will take effect after the next domain shutdown.

View File

@ -9,7 +9,7 @@
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
@@ -325,4 +320,5 @@
@@ -331,4 +326,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -21,7 +21,7 @@
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
@@ -325,4 +308,5 @@
@@ -331,4 +314,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -6,6 +6,7 @@
+ <disk device="floppy">
+ <source file="/foo/bar"/>
<target dev="fda" bus="fdc"/>
- <boot order="5"/>
- <address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
<disk type="dir" device="floppy">

View File

@ -2,6 +2,7 @@
<source file="/tmp/foobar2"/>
<target dev="vdc" bus="virtio"/>
- <shareable/>
<boot order="1"/>
+ <readonly/>
</disk>
<disk type="block" device="disk">

View File

@ -2,9 +2,7 @@
<os>
<type arch="i686">hvm</type>
- <loader>/usr/lib/xen/boot/hvmloader</loader>
- <boot dev="hd"/>
+ <loader>foo.bar</loader>
+ <boot dev="network"/>
+ <bios useserial="yes"/>
+ <init>/bin/bash</init>
</os>

View File

@ -9,7 +9,7 @@
<feature policy="require" name="tm2"/>
<feature policy="require" name="est"/>
<feature policy="require" name="ss"/>
@@ -54,6 +54,7 @@
@@ -53,6 +53,7 @@
<feature policy="require" name="ds_cpl"/>
<feature policy="require" name="xtpr"/>
<feature policy="require" name="acpi"/>

View File

@ -3,8 +3,8 @@
<disk type="block" device="floppy">
- <source dev="/dev/null"/>
<target dev="fda" bus="fdc"/>
<boot order="5"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
Domain 'test-many-devices' defined successfully.
Changes will take effect after the next domain shutdown.

View File

@ -4,6 +4,7 @@
- <source dev="/dev/null"/>
+ <source dev="/dev/zero" startupPolicy="optional"/>
<target dev="fda" bus="fdc"/>
<boot order="5"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
+ <readonly/>
</disk>

View File

@ -1,4 +1,4 @@
<boot dev="hd"/>
<loader>/usr/lib/xen/boot/hvmloader</loader>
</os>
<idmap>
- <uid start="0" target="1000" count="10"/>

View File

@ -12,7 +12,7 @@
<memory unit="KiB">409600</memory>
<currentMemory unit="KiB">204800</currentMemory>
<blkiotune>
@@ -325,4 +325,5 @@
@@ -331,4 +331,5 @@
<address type="isa" iobase="0x505"/>
</panic>
</devices>

View File

@ -1,5 +1,5 @@
<address domain="0x0003" bus="0x00" slot="0x19" function="0x0"/>
</source>
<boot order="6"/>
</hostdev>
- <redirdev bus="usb" type="tcp">
- <source mode="connect" host="localhost" service="4000"/>

View File

@ -1,4 +1,4 @@
</virtualport>
<boot order="3"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x07" function="0x0"/>
</interface>
- <smartcard mode="host">

View File

@ -6,7 +6,7 @@
<numatune>
<memory mode="interleave" placement="auto"/>
</numatune>
@@ -54,6 +54,7 @@
@@ -53,6 +53,7 @@
<feature policy="require" name="ds_cpl"/>
<feature policy="require" name="xtpr"/>
<feature policy="require" name="acpi"/>

View File

@ -4,12 +4,13 @@
- <disk type="block" device="floppy">
- <source dev="/dev/null"/>
- <target dev="fda" bus="fdc"/>
- <boot order="5"/>
- <address type="drive" controller="0" bus="0" target="0" unit="0"/>
- </disk>
<disk type="dir" device="floppy">
<source dir="/tmp"/>
<target dev="fdb" bus="fdc"/>
@@ -92,12 +87,6 @@
@@ -92,12 +86,6 @@
<target dev="hdb" bus="ide"/>
<readonly/>
<address type="drive" controller="0" bus="0" target="0" unit="1"/>

View File

@ -545,15 +545,16 @@ c.add_compare("""--hvm --pxe \
--controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \
--controller usb,model=ich9-uhci2,address=0:0:4.1,index=0,master=2 \
--controller usb,model=ich9-uhci3,address=0:0:4.2,index=0,master=4 \
--disk %(EXISTUPPER)s,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149 \
--disk %(EXISTUPPER)s,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149,boot_order=2 \
--disk %(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace \
--disk device=cdrom,bus=sata,read_bytes_sec=1,read_iops_sec=2,total_bytes_sec=10,total_iops_sec=20,write_bytes_sec=5,write_iops_sec=6 \
--serial tcp,host=:2222,mode=bind,protocol=telnet \
--filesystem /source,/target,mode=squash \
--network user,mac=12:34:56:78:11:22 \
--network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3 \
--network type=direct,source=eth5,source_mode=vepa,target=mytap12,virtualport_type=802.1Qbg,virtualport_managerid=12,virtualport_typeid=1193046,virtualport_typeidversion=1,virtualport_instanceid=09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b \
--network type=direct,source=eth5,source_mode=vepa,target=mytap12,virtualport_type=802.1Qbg,virtualport_managerid=12,virtualport_typeid=1193046,virtualport_typeidversion=1,virtualport_instanceid=09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b,boot_order=1 \
--channel spicevmc \
--redirdev spicevmc,boot_order=3
--smartcard passthrough,type=spicevmc \
--tpm /dev/tpm0 \
--panic default \
@ -562,7 +563,7 @@ c.add_compare("""--hvm --pxe \
--blkiotune weight=200,device_path=/dev/sdc,device_weight=300 \
--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10 \
--boot loader=/foo/bar \
--host-device net_00_1c_25_10_b1_e4 \
--host-device net_00_1c_25_10_b1_e4,boot_order=4 \
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234 \
--clock offset=localtime,hpet_present=no,rtc_tickpolicy=merge \
--pm suspend_to_mem=yes,suspend_to_disk=no \
@ -788,6 +789,7 @@ c.add_compare("--build-xml --cpu pentium3,+x2apic", "build-cpu")
c.add_compare("--build-xml --tpm /dev/tpm", "build-tpm")
c.add_compare("--build-xml --blkiotune weight=100,device_path=/dev/sdf,device_weight=200", "build-blkiotune")
c.add_compare("--build-xml --idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10", "build-idmap")
c.add_compare("test --edit --boot network,cdrom", "edit-bootorder")
c = vixml.add_category("simple edit diff", "test-many-devices --edit --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
@ -800,7 +802,7 @@ c.add_compare("--cpu model=pentium2,+x2apic,forbid=pbe", "edit-simple-cpu")
c.add_compare("--numatune 1-5,7,mode=strict", "edit-simple-numatune")
c.add_compare("--blkiotune weight=500,device_path=/dev/sdf,device_weight=600", "edit-simple-blkiotune")
c.add_compare("--idmap uid_start=0,uid_target=2000,uid_count=30,gid_start=0,gid_target=3000,gid_count=40", "edit-simple-idmap")
c.add_compare("--boot loader=foo.bar,network,useserial=on,init=/bin/bash", "edit-simple-boot")
c.add_compare("--boot loader=foo.bar,useserial=on,init=/bin/bash", "edit-simple-boot")
c.add_compare("--security label=foo,bar,baz,UNKNOWN=val,relabel=on", "edit-simple-security")
c.add_compare("--features eoi=on,hyperv_relaxed=off,acpi=", "edit-simple-features")
c.add_compare("--clock offset=localtime,hpet_present=yes,kvmclock_present=no,rtc_tickpolicy=merge", "edit-simple-clock")

View File

@ -72,7 +72,6 @@
<os>
<type arch='i686'>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/>
</os>
<idmap>
<uid start='0' target='1000' count='10'/>
@ -132,6 +131,7 @@
<disk type='block' device='floppy'>
<source dev='/dev/null'/>
<target dev='fda' bus='fdc'/>
<boot order='5'/>
</disk>
<disk type='dir' device='floppy'>
<source dir='/tmp'/>
@ -157,6 +157,7 @@
<driver name="qemu" type="qcow2" cache="none"/>
<source file='/tmp/foobar2'/>
<target dev='vdc' bus='virtio'/>
<boot order='1'/>
<shareable/>
</disk>
<disk type='block' device='disk'>
@ -193,6 +194,7 @@
<source bridge='brempty'/>
<mac address='22:22:33:44:AA:BB'/>
<model type='virtio'/>
<boot order='123'/>
</interface>
<interface type='bridge'>
<source bridge='br0'/>
@ -200,12 +202,13 @@
<model type='e1000'/>
</interface>
<interface type='ethernet'>
<mac address='00:11:7f:33:44:55'/>
<script path='/etc/qemu-ifup'/>
<target dev='nic02'/>
<mac address='00:11:7f:33:44:55'/>
<script path='/etc/qemu-ifup'/>
<target dev='nic02'/>
</interface>
<interface type="direct">
<mac address="F0:11:22:33:44:5F"/>
<boot order='3'/>
<source dev="eth0.1" mode="vepa"/>
<virtualport type="802.1Qbg">
<parameters managerid="12" typeid="1193046" typeidversion="1" instanceid="09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b"/>
@ -262,6 +265,7 @@
<source>
<address bus='0x03' device='0x02'/>
</source>
<boot order='9'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
@ -272,6 +276,7 @@
<source>
<address domain="0x03" bus='0x00' slot='0x19' function="0x0"/>
</source>
<boot order='6'/>
</hostdev>
@ -350,6 +355,7 @@
</redirdev>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='4'/>
<boot order='7'/>
</redirdev>
<redirfilter>
<usbdev class='0x08' vendor='0x15E1' product='0x2007' version='1.10' allow='yes'/>

View File

@ -34,7 +34,6 @@ def sanitize_file_xml(xml):
class XMLParseTest(unittest.TestCase):
def _roundtrip_compare(self, filename):
expectXML = sanitize_file_xml(file(filename).read())
guest = virtinst.Guest(conn, parsexml=expectXML)
@ -329,6 +328,8 @@ class XMLParseTest(unittest.TestCase):
check("iotune_tis", None, 5)
check("iotune_tbs", None, 6)
check = self._make_checker(disk6.boot)
check("order", None, 7, None)
self._alter_compare(guest.get_xml_config(), outfile)

View File

@ -1603,6 +1603,7 @@ class ParserDisk(VirtCLIParser):
self.set_param("sourceStartupPolicy", "startup_policy")
self.set_param("read_only", "readonly", is_onoff=True)
self.set_param("shareable", "shareable", is_onoff=True)
self.set_param("boot.order", "boot_order")
self.set_param("iotune_rbs", "read_bytes_sec")
self.set_param("iotune_wbs", "write_bytes_sec")
@ -1702,6 +1703,7 @@ class ParserNetwork(VirtCLIParser):
self.set_param("model", "model")
self.set_param("macaddr", "mac", setter_cb=set_mac_cb)
self.set_param("filterref", "filterref")
self.set_param("boot.order", "boot_order")
self.set_param("driver_name", "driver_name")
self.set_param("driver_queues", "driver_queues")
@ -1830,6 +1832,7 @@ class ParserRedir(VirtCLIParser):
self.set_param("bus", "bus")
self.set_param("type", "type")
self.set_param("boot.order", "boot_order")
def set_server_cb(opts, inst, cliname, val):
ignore = opts = cliname
@ -2120,6 +2123,7 @@ class ParserHostdev(VirtCLIParser):
self.set_param(None, "name", setter_cb=set_name_cb)
self.set_param("driver_name", "driver_name")
self.set_param("boot.order", "boot_order")
###########################

View File

@ -27,6 +27,11 @@ class VirtualDeviceAlias(XMLBuilder):
name = XMLProperty("./@name")
class VirtualDeviceBoot(XMLBuilder):
_XML_ROOT_NAME = "boot"
order = XMLProperty("./@order", is_int=True)
class VirtualDeviceAddress(XMLBuilder):
"""
Examples:
@ -157,6 +162,7 @@ class VirtualDevice(XMLBuilder):
alias = XMLChildProperty(VirtualDeviceAlias, is_single=True)
address = XMLChildProperty(VirtualDeviceAddress, is_single=True)
boot = XMLChildProperty(VirtualDeviceBoot, is_single=True)
def setup(self, meter=None):

View File

@ -128,7 +128,9 @@ class Installer(object):
bootorder = self._build_boot_order(isinstall, guest)
if not bootconfig.bootorder:
bootconfig.bootorder = bootorder
# Per device <boot order> is not compatible with os/boot.
if not any(d.boot.order for d in guest.get_all_devices()):
bootconfig.bootorder = bootorder
if not isinstall:
return