qemu: Support per-device boot ordering

Support for this is included in qemu and seabios from upstream git.
This commit is contained in:
Jiri Denemark 2011-01-12 11:33:34 +01:00
parent 94234fa2f8
commit 3d44035824
6 changed files with 40 additions and 10 deletions

View File

@ -431,6 +431,7 @@ qemuCapsInitGuest(virCapsPtr caps,
int nmachines = 0; int nmachines = 0;
struct stat st; struct stat st;
unsigned int ncpus; unsigned int ncpus;
unsigned long long qemuCmdFlags;
int ret = -1; int ret = -1;
/* Check for existance of base emulator, or alternate base /* Check for existance of base emulator, or alternate base
@ -546,6 +547,11 @@ qemuCapsInitGuest(virCapsPtr caps,
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
goto error; goto error;
if (qemuCapsExtractVersionInfo(binary, NULL, &qemuCmdFlags) < 0 ||
((qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX) &&
!virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
goto error;
if (hvm) { if (hvm) {
if (virCapabilitiesAddGuestDomain(guest, if (virCapabilitiesAddGuestDomain(guest,
"qemu", "qemu",
@ -1047,6 +1053,7 @@ qemuCapsExtractDeviceStr(const char *qemu,
* '-device ?'. */ * '-device ?'. */
cmd = virCommandNewArgList(qemu, cmd = virCommandNewArgList(qemu,
"-device", "pci-assign,?", "-device", "pci-assign,?",
"-device", "virtio-blk-pci,?",
NULL); NULL);
virCommandAddEnvPassCommon(cmd); virCommandAddEnvPassCommon(cmd);
/* qemu -help goes to stdout, but qemu -device ? goes to stderr. */ /* qemu -help goes to stdout, but qemu -device ? goes to stderr. */
@ -1070,6 +1077,8 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
{ {
if (strstr(str, "pci-assign.configfd")) if (strstr(str, "pci-assign.configfd"))
*flags |= QEMUD_CMD_FLAG_PCI_CONFIGFD; *flags |= QEMUD_CMD_FLAG_PCI_CONFIGFD;
if (strstr(str, "virtio-blk-pci.bootindex"))
*flags |= QEMUD_CMD_FLAG_BOOTINDEX;
return 0; return 0;
} }

View File

@ -83,6 +83,7 @@ enum qemuCapsFlags {
QEMUD_CMD_FLAG_SPICE = (1LL << 46), /* Is -spice avail */ QEMUD_CMD_FLAG_SPICE = (1LL << 46), /* Is -spice avail */
QEMUD_CMD_FLAG_VGA_NONE = (1LL << 47), /* The 'none' arg for '-vga' */ 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_MIGRATE_QEMU_FD = (1LL << 48), /* -incoming fd:n */
QEMUD_CMD_FLAG_BOOTINDEX = (1LL << 49), /* -device bootindex property */
}; };
virCapsPtr qemuCapsInit(virCapsPtr old_caps); virCapsPtr qemuCapsInit(virCapsPtr old_caps);

View File

@ -1342,7 +1342,8 @@ error:
char * char *
qemuBuildDriveDevStr(virDomainDiskDefPtr disk) qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
unsigned long long qemuCmdFlags)
{ {
virBuffer opt = VIR_BUFFER_INITIALIZER; virBuffer opt = VIR_BUFFER_INITIALIZER;
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus); const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
@ -1382,6 +1383,8 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr disk)
} }
virBufferVSprintf(&opt, ",drive=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias); virBufferVSprintf(&opt, ",drive=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
virBufferVSprintf(&opt, ",id=%s", 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)) { if (virBufferError(&opt)) {
virReportOOMError(); virReportOOMError();
@ -1538,7 +1541,9 @@ qemuBuildNicStr(virDomainNetDefPtr net,
char * char *
qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan) qemuBuildNicDevStr(virDomainNetDefPtr net,
int vlan,
unsigned long long qemuCmdFlags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *nic; const char *nic;
@ -1563,6 +1568,8 @@ qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan)
net->mac[4], net->mac[5]); net->mac[4], net->mac[5]);
if (qemuBuildDeviceAddressStr(&buf, &net->info) < 0) if (qemuBuildDeviceAddressStr(&buf, &net->info) < 0)
goto error; goto error;
if (net->bootIndex && (qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX))
virBufferVSprintf(&buf, ",bootindex=%d", net->bootIndex);
if (virBufferError(&buf)) { if (virBufferError(&buf)) {
virReportOOMError(); virReportOOMError();
@ -3125,10 +3132,19 @@ qemuBuildCommandLine(virConnectPtr conn,
disk->info.addr.drive.unit disk->info.addr.drive.unit
? 'B' : 'A', ? 'B' : 'A',
disk->info.alias); disk->info.alias);
if (disk->bootIndex &&
(qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX)) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "isa-fdc.bootindex%c=%d",
disk->info.addr.drive.unit
? 'B' : 'A',
disk->bootIndex);
}
} else { } else {
virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, "-device");
if (!(optstr = qemuBuildDriveDevStr(disk))) if (!(optstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error; goto error;
virCommandAddArg(cmd, optstr); virCommandAddArg(cmd, optstr);
VIR_FREE(optstr); VIR_FREE(optstr);
@ -3352,7 +3368,7 @@ qemuBuildCommandLine(virConnectPtr conn,
} }
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, "-device");
if (!(nic = qemuBuildNicDevStr(net, vlan))) if (!(nic = qemuBuildNicDevStr(net, vlan, qemuCmdFlags)))
goto error; goto error;
virCommandAddArg(cmd, nic); virCommandAddArg(cmd, nic);
VIR_FREE(nic); VIR_FREE(nic);

View File

@ -62,7 +62,8 @@ char * qemuBuildNicStr(virDomainNetDefPtr net,
/* Current, best practice */ /* Current, best practice */
char * qemuBuildNicDevStr(virDomainNetDefPtr net, char * qemuBuildNicDevStr(virDomainNetDefPtr net,
int vlan); int vlan,
unsigned long long qemuCmdFlags);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk, char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
unsigned long long qemuCmdFlags); unsigned long long qemuCmdFlags);
@ -75,7 +76,8 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
unsigned long long qemuCmdFlags); unsigned long long qemuCmdFlags);
/* Current, best practice */ /* Current, best practice */
char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk); char * qemuBuildDriveDevStr(virDomainDiskDefPtr disk,
unsigned long long qemuCmdFlags);
char * qemuBuildFSDevStr(virDomainFSDefPtr fs); char * qemuBuildFSDevStr(virDomainFSDefPtr fs);
/* Current, best practice */ /* Current, best practice */
char * qemuBuildControllerDevStr(virDomainControllerDefPtr def); char * qemuBuildControllerDevStr(virDomainControllerDefPtr def);

View File

@ -6050,6 +6050,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
*/ */
for (i = 0 ; i < def->nnets ; i++) { for (i = 0 ; i < def->nnets ; i++) {
virDomainNetDefPtr net = def->nets[i]; virDomainNetDefPtr net = def->nets[i];
int bootIndex = net->bootIndex;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK || if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
net->type == VIR_DOMAIN_NET_TYPE_DIRECT) { net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
VIR_FREE(net->data.network.name); VIR_FREE(net->data.network.name);
@ -6072,6 +6073,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
net->data.ethernet.script = script; net->data.ethernet.script = script;
net->data.ethernet.ipaddr = ipaddr; net->data.ethernet.ipaddr = ipaddr;
} }
net->bootIndex = bootIndex;
} }
for (i = 0 ; i < def->ngraphics ; i++) { for (i = 0 ; i < def->ngraphics ; i++) {
if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && if (def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&

View File

@ -169,7 +169,7 @@ int qemuDomainAttachPciDiskDevice(struct qemud_driver *driver,
if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags))) if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags)))
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(disk))) if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error; goto error;
} }
@ -380,7 +380,7 @@ int qemuDomainAttachSCSIDisk(struct qemud_driver *driver,
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (qemuAssignDeviceDiskAlias(disk, qemuCmdFlags) < 0) if (qemuAssignDeviceDiskAlias(disk, qemuCmdFlags) < 0)
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(disk))) if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error; goto error;
} }
@ -493,7 +493,7 @@ int qemuDomainAttachUsbMassstorageDevice(struct qemud_driver *driver,
goto error; goto error;
if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags))) if (!(drivestr = qemuBuildDriveStr(disk, 0, qemuCmdFlags)))
goto error; goto error;
if (!(devstr = qemuBuildDriveDevStr(disk))) if (!(devstr = qemuBuildDriveDevStr(disk, qemuCmdFlags)))
goto error; goto error;
} }
@ -675,7 +675,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
} }
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (!(nicstr = qemuBuildNicDevStr(net, vlan))) if (!(nicstr = qemuBuildNicDevStr(net, vlan, qemuCmdFlags)))
goto try_remove; goto try_remove;
} else { } else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan))) if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))