char *
qemuBuildNicDevStr(virDomainDef *def,
virDomainNetDef *net,
- unsigned int bootindex,
+ unsigned int bootindex G_GNUC_UNUSED,
size_t vhostfdSize,
virQEMUCaps *qemuCaps)
{
return NULL;
if (qemuBuildRomStr(&buf, &net->info) < 0)
return NULL;
- if (bootindex)
- virBufferAsprintf(&buf, ",bootindex=%u", bootindex);
+ if (net->info.effectiveBootIndex > 0)
+ virBufferAsprintf(&buf, ",bootindex=%u", net->info.effectiveBootIndex);
return virBufferContentAndReset(&buf);
}
char *
qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDef *dev,
- unsigned int bootIndex, /* used iff dev->info->bootIndex == 0 */
+ unsigned int bootIndex G_GNUC_UNUSED,
virQEMUCaps *qemuCaps G_GNUC_UNUSED)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
pcisrc->addr.slot,
pcisrc->addr.function);
virBufferAsprintf(&buf, ",id=%s", dev->info->alias);
- if (dev->info->bootIndex)
- bootIndex = dev->info->bootIndex;
- if (bootIndex)
- virBufferAsprintf(&buf, ",bootindex=%u", bootIndex);
+ if (dev->info->effectiveBootIndex > 0)
+ virBufferAsprintf(&buf, ",bootindex=%u", dev->info->effectiveBootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info) < 0)
return NULL;
if (qemuBuildRomStr(&buf, dev->info) < 0)
unsigned int bootCD = 0;
unsigned int bootFloppy = 0;
unsigned int bootDisk = 0;
+ unsigned int bootNetwork = 0;
if (def->os.nBootDevs == 0)
return;
break;
case VIR_DOMAIN_BOOT_NET:
- /* network boot is handled in network device formatting code */
+ bootNetwork = i + 1;
+ break;
+
case VIR_DOMAIN_BOOT_LAST:
default:
break;
break;
}
}
+
+ if (def->nnets > 0 && bootNetwork > 0) {
+ /* If network boot is enabled, the first network device gets enabled. If
+ * that one is backed by a host device, then we need to find the first
+ * corresponding host device */
+ if (virDomainNetGetActualType(def->nets[0]) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+ for (i = 0; i < def->nhostdevs; i++) {
+ virDomainHostdevDef *hostdev = def->hostdevs[i];
+ virDomainHostdevSubsys *subsys = &hostdev->source.subsys;
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+ hostdev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED &&
+ hostdev->parentnet) {
+ hostdev->info->effectiveBootIndex = bootNetwork;
+ break;
+ }
+ }
+ } else {
+ def->nets[0]->info.effectiveBootIndex = bootNetwork;
+ }
+ }
}