From 83e335f9d2345f095bc118089523bb62b5ea2f3b Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Thu, 3 Feb 2011 13:06:21 +0100 Subject: [PATCH] Support booting from hostdev devices --- docs/formatdomain.html.in | 14 ++++++++++++-- docs/schemas/domain.rng | 3 +++ src/conf/domain_conf.c | 18 +++++++++++++++--- src/conf/domain_conf.h | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 48f82ae895..db0b762e28 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -109,8 +109,9 @@ to consider. The boot element can be repeated multiple times to setup a priority list of boot devices to try in turn. The boot element cannot be used if per-device boot elements - are used (see disks and - network interfaces sections below. + are used (see disks, + network interfaces, and + USB and PCI devices sections below). Since 0.1.3, per-device boot since 0.8.8
bootmenu
@@ -929,6 +930,7 @@ <vendor id='0x1234'/> <product id='0xbeef'/> </source> + <boot order='2'/> </hostdev> </devices> ... @@ -942,6 +944,7 @@ <source> <address bus='0x06' slot='0x02' function='0x0'/> </source> + <boot order='1'/> </hostdev> </devices> ... @@ -964,6 +967,13 @@ id 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. +
boot
+
Specifies that the device is bootable. The order + attribute determines the order in which devices will be tried during + boot sequence. The per-device boot elements cannot be + used together with general boot elements in + BIOS bootloader section. + Since 0.8.8
address
The address element for USB devices has a bus and device attribute to specify the diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index e4e742333d..8a2e7c70b5 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -1692,6 +1692,9 @@ + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b1cc6c82e0..aba4223d04 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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, " \n"); + if (def->bootIndex) + virBufferVSprintf(buf, " \n", def->bootIndex); + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 871fa9ab06..feae203f6a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -678,6 +678,7 @@ struct _virDomainHostdevDef { } caps; } source; char* target; + int bootIndex; virDomainDeviceInfo info; /* Guest address */ };