Support for this is included in qemu and seabios from git.
---
src/qemu/qemu_capabilities.c | 28 +++++++++++++++++++++++++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 15 +++++++++++----
src/qemu/qemu_command.h | 6 ++++--
src/qemu/qemu_driver.c | 2 ++
src/qemu/qemu_hotplug.c | 8 ++++----
6 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0fb6ec9..6558d6e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -486,6 +486,7 @@ qemuCapsInitGuest(virCapsPtr caps,
int nmachines = 0;
struct stat st;
unsigned int ncpus;
+ unsigned long long qemuCmdFlags;
int ret = -1;
/* Check for existance of base emulator, or alternate base
@@ -601,6 +602,11 @@ qemuCapsInitGuest(virCapsPtr caps,
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
goto error;
+ if (qemuCapsExtractVersionInfo(binary, NULL, &qemuCmdFlags) < 0 ||
+ ((qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX) &&
+ !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
+ goto error;
+
if (hvm) {
if (virCapabilitiesAddGuestDomain(guest,
"qemu",
@@ -1127,6 +1133,24 @@ qemuCapsParsePCIDeviceStrs(const char *qemu,
VIR_FREE(pciassign);
}
+static void
+qemuCapsParseBlockDeviceStrs(const char *qemu,
+ unsigned long long *flags)
+{
+ char *block = qemuCapsExtractDeviceProps(qemu, "virtio-blk-pci");
+
+ if (!block)
+ return;
+
+ if (strstr(block, "virtio-blk-pci.bootindex")) {
+ VIR_DEBUG0("je tam");
+ *flags |= QEMUD_CMD_FLAG_BOOTINDEX;
+ }
+
+ VIR_FREE(block);
+}
+
+
int qemuCapsExtractVersionInfo(const char *qemu,
unsigned int *retversion,
unsigned long long *retflags)
@@ -1170,8 +1194,10 @@ int qemuCapsExtractVersionInfo(const char *qemu,
&version, &is_kvm, &kvm_version) == -1)
goto cleanup2;
- if (flags & QEMUD_CMD_FLAG_DEVICE)
+ if (flags & QEMUD_CMD_FLAG_DEVICE) {
qemuCapsParsePCIDeviceStrs(qemu, &flags);
+ qemuCapsParseBlockDeviceStrs(qemu, &flags);
+ }
if (retversion)
*retversion = version;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ee648f0..f0ffbc8 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -83,6 +83,7 @@ enum qemuCapsFlags {
QEMUD_CMD_FLAG_SPICE = (1LL << 46), /* Is -spice avail */
QEMUD_CMD_FLAG_VGA_NONE = (1LL << 47), /* The 'none' arg for
'-vga' */
QEMUD_CMD_FLAG_MIGRATE_QEMU_FD = (1LL << 48), /* -incoming fd:n */
+ QEMUD_CMD_FLAG_BOOTINDEX = (1LL << 49), /* -device bootindex property */
};
virCapsPtr qemuCapsInit(virCapsPtr old_caps);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 86c5bb5..c19ef36 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1308,7 +1308,8 @@ error:
char *
-qemuBuildDriveDevStr(virDomainDiskDefPtr disk)
+qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
+ unsigned long long qemuCmdFlags)
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
@@ -1348,6 +1349,8 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk)
}
virBufferVSprintf(&opt, ",drive=%s%s", QEMU_DRIVE_HOST_PREFIX,
disk->info.alias);
virBufferVSprintf(&opt, ",id=%s", disk->info.alias);
+ if (disk->bootIndex && (qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX))
+ virBufferVSprintf(&opt, ",bootindex=%d", disk->bootIndex);
if (virBufferError(&opt)) {
virReportOOMError();
@@ -1504,7 +1507,9 @@ qemuBuildNicStr(virDomainNetDefPtr net,
char *
-qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan)
+qemuBuildNicDevStr(virDomainNetDefPtr net,
+ int vlan,
+ unsigned long long qemuCmdFlags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *nic;
@@ -1529,6 +1534,8 @@ qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan)
net->mac[4], net->mac[5]);
if (qemuBuildDeviceAddressStr(&buf, &net->info) < 0)
goto error;
+ if (net->bootIndex && (qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX))
+ virBufferVSprintf(&buf, ",bootindex=%d", net->bootIndex);
if (virBufferError(&buf)) {
virReportOOMError();
@@ -3085,7 +3092,7 @@ qemuBuildCommandLine(virConnectPtr conn,
} else {
virCommandAddArg(cmd, "-device");
- if (!(optstr = qemuBuildDriveDevStr(disk)))
+ if (!(optstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, optstr);
VIR_FREE(optstr);
@@ -3306,7 +3313,7 @@ qemuBuildCommandLine(virConnectPtr conn,
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
virCommandAddArg(cmd, "-device");
- if (!(nic = qemuBuildNicDevStr(net, vlan)))
+ if (!(nic = qemuBuildNicDevStr(net, vlan, qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, nic);
VIR_FREE(nic);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 4c42a10..9e9d5f5 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -62,7 +62,8 @@ char * qemuBuildNicStr(virDomainNetDefPtr net,
/* Current, best practice */
char * qemuBuildNicDevStr(virDomainNetDefPtr net,
- int vlan);
+ int vlan,
+ unsigned long long qemuCmdFlags);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
unsigned long long qemuCmdFlags);
@@ -75,7 +76,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
unsigned long long qemuCmdFlags);
/* Current, best practice */
-char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk);
+char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
+ unsigned long long qemuCmdFlags);
char * qemuBuildFSDevStr(virDomainFSDefPtr fs);
/* Current, best practice */
char * qemuBuildControllerDevStr(virDomainControllerDefPtr def);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9eb9cd5..cfb56bc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6054,6 +6054,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
*/
for (i = 0 ; i < def->nnets ; i++) {
virDomainNetDefPtr net = def->nets[i];
+ int bootIndex = net->bootIndex;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
VIR_FREE(net->data.network.name);
@@ -6076,6 +6077,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
net->data.ethernet.script = script;
net->data.ethernet.ipaddr = ipaddr;
}
+ net->bootIndex = bootIndex;
}
for (i = 0 ; i < def->ngraphics ; i++) {
if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1dc036c..3b4a673 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -169,7 +169,7 @@ int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver,
if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags)))
goto error;
- if (!(devstr = qemuBuildDriveDevStr(disk)))
+ if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error;
}
@@ -380,7 +380,7 @@ int qemuDomainAttachSCSIDisk(struct qemud_driver *driver,
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (qemuAssignDeviceDiskAlias(disk, qemuCmdFlags) < 0)
goto error;
- if (!(devstr = qemuBuildDriveDevStr(disk)))
+ if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error;
}
@@ -493,7 +493,7 @@ int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver,
goto error;
if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags)))
goto error;
- if (!(devstr = qemuBuildDriveDevStr(disk)))
+ if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error;
}
@@ -675,7 +675,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
- if (!(nicstr = qemuBuildNicDevStr(net, vlan)))
+ if (!(nicstr = qemuBuildNicDevStr(net, vlan, qemuCmdFlags)))
goto try_remove;
} else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
--
1.7.4.rc1