]> xenbits.xensource.com Git - libvirt.git/commitdiff
Support booting from hostdev devices
authorJiri Denemark <jdenemar@redhat.com>
Thu, 3 Feb 2011 12:06:21 +0000 (13:06 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 3 Feb 2011 21:20:30 +0000 (22:20 +0100)
docs/formatdomain.html.in
docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h

index 48f82ae895b12bd041d24cd5a622e351de5de7eb..db0b762e28dd7e9b55d313e6da9298ea64adc241 100644 (file)
         to consider. The <code>boot</code> element can be repeated multiple
         times to setup a priority list of boot devices to try in turn. The
         <code>boot</code> element cannot be used if per-device boot elements
-        are used (see <a href="#elementsDisks">disks</a> and
-        <a href="#elementsNICS">network interfaces</a> sections below.
+        are used (see <a href="#elementsDisks">disks</a>,
+        <a href="#elementsNICS">network interfaces</a>, and
+        <a href="#elementsUSB">USB and PCI devices</a> sections below).
         <span class="since">Since 0.1.3, per-device boot since 0.8.8</span>
       </dd>
       <dt><code>bootmenu</code></dt>
         &lt;vendor id='0x1234'/&gt;
         &lt;product id='0xbeef'/&gt;
       &lt;/source&gt;
+      &lt;boot order='2'/&gt;
     &lt;/hostdev&gt;
   &lt;/devices&gt;
   ...</pre>
       &lt;source&gt;
         &lt;address bus='0x06' slot='0x02' function='0x0'/&gt;
       &lt;/source&gt;
+      &lt;boot order='1'/&gt;
     &lt;/hostdev&gt;
   &lt;/devices&gt;
   ...</pre>
       <code>id</code> attribute that specifies the USB vendor and product id.
       The ids can be given in decimal, hexadecimal (starting with 0x) or
       octal (starting with 0) form.</dd>
+      <dt><code>boot</code></dt>
+      <dd>Specifies that the device is bootable. The <code>order</code>
+      attribute determines the order in which devices will be tried during
+      boot sequence. The per-device <code>boot</code> elements cannot be
+      used together with general boot elements in
+      <a href="#elementsOSBIOS">BIOS bootloader</a> section.
+      <span class="since">Since 0.8.8</span></dd>
       <dt><code>address</code></dt>
       <dd>The <code>address</code> element for USB devices has a
       <code>bus</code> and <code>device</code> attribute to specify the
index e4e742333d03d1e9f2b15f4d6d120b2fdf42e4b2..8a2e7c70b5a11d5adb83cf61b993865c6bf14429 100644 (file)
           </choice>
         </element>
       </group>
+      <optional>
+        <ref name="deviceBoot"/>
+      </optional>
       <optional>
         <ref name="address"/>
       </optional>
index b1cc6c82e04d72c7b2c5a6d6c27e1f7c76a1c2be..aba4223d0481ecf25f477509d43f335de8608e5e 100644 (file)
@@ -4247,7 +4247,9 @@ out:
 
 static virDomainHostdevDefPtr
 virDomainHostdevDefParseXML(const xmlNodePtr node,
-                            int flags) {
+                            virBitmapPtr bootMap,
+                            int flags)
+{
 
     xmlNodePtr cur;
     virDomainHostdevDefPtr def;
@@ -4308,6 +4310,10 @@ virDomainHostdevDefParseXML(const xmlNodePtr node,
                 /* address is parsed as part of virDomainDeviceInfoParseXML */
             } else if (xmlStrEqual(cur->name, BAD_CAST "alias")) {
                 /* alias is parsed as part of virDomainDeviceInfoParseXML */
+            } else if (xmlStrEqual(cur->name, BAD_CAST "boot")) {
+                if (virDomainDeviceBootParseXML(cur, &def->bootIndex,
+                                                bootMap))
+                    goto error;
             } else {
                 virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                      _("unknown node %s"), cur->name);
@@ -4507,7 +4513,8 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "hostdev")) {
         dev->type = VIR_DOMAIN_DEVICE_HOSTDEV;
-        if (!(dev->data.hostdev = virDomainHostdevDefParseXML(node, flags)))
+        if (!(dev->data.hostdev = virDomainHostdevDefParseXML(node, NULL,
+                                                              flags)))
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "controller")) {
         dev->type = VIR_DOMAIN_DEVICE_CONTROLLER;
@@ -4767,7 +4774,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
     unsigned long deviceBoot;
 
     if (virXPathULong("count(./devices/disk[boot]"
-                      "|./devices/interface[boot])", ctxt, &deviceBoot) < 0) {
+                      "|./devices/interface[boot]"
+                      "|./devices/hostdev[boot])", ctxt, &deviceBoot) < 0) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                              _("cannot count boot devices"));
         goto cleanup;
@@ -5506,6 +5514,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         goto no_memory;
     for (i = 0 ; i < n ; i++) {
         virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(nodes[i],
+                                                                     bootMap,
                                                                      flags);
         if (!hostdev)
             goto error;
@@ -7280,6 +7289,9 @@ virDomainHostdevDefFormat(virBufferPtr buf,
 
     virBufferAddLit(buf, "      </source>\n");
 
+    if (def->bootIndex)
+        virBufferVSprintf(buf, "      <boot order='%d'/>\n", def->bootIndex);
+
     if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
         return -1;
 
index 871fa9ab06923cc5d6cdfb96a810be27ac84c659..feae203f6a114d540f697c574cc8b8dcd51e8b9e 100644 (file)
@@ -678,6 +678,7 @@ struct _virDomainHostdevDef {
         } caps;
     } source;
     char* target;
+    int bootIndex;
     virDomainDeviceInfo info; /* Guest address */
 };