conf: store bootindex as unsigned int

The value is never negative thus there's no need to store it in a signed
type.
This commit is contained in:
Peter Krempa 2016-03-29 14:31:37 +02:00
parent 836bf4ba7c
commit e0a34e76ef
6 changed files with 34 additions and 34 deletions

View File

@ -423,13 +423,12 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def,
virDomainDiskDefPtr hdd, cd, userdef, diskdef; virDomainDiskDefPtr hdd, cd, userdef, diskdef;
virBuffer devicemap; virBuffer devicemap;
virCommandPtr cmd; virCommandPtr cmd;
int best_idx; unsigned int best_idx = UINT_MAX;
size_t i; size_t i;
if (def->os.bootloaderArgs != NULL) if (def->os.bootloaderArgs != NULL)
return virBhyveProcessBuildCustomLoaderCmd(def); return virBhyveProcessBuildCustomLoaderCmd(def);
best_idx = INT_MAX;
devicemap = (virBuffer)VIR_BUFFER_INITIALIZER; devicemap = (virBuffer)VIR_BUFFER_INITIALIZER;
/* Search disk list for CD or HDD device. We'll respect <boot order=''> if /* Search disk list for CD or HDD device. We'll respect <boot order=''> if

View File

@ -4412,7 +4412,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
unsigned int flags) unsigned int flags)
{ {
if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex)
virBufferAsprintf(buf, "<boot order='%d'/>\n", info->bootIndex); virBufferAsprintf(buf, "<boot order='%u'/>\n", info->bootIndex);
if (info->alias && if (info->alias &&
!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
@ -4820,16 +4820,16 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
virHashTablePtr bootHash) virHashTablePtr bootHash)
{ {
char *order; char *order;
int boot;
int ret = -1; int ret = -1;
order = virXMLPropString(node, "order"); if (!(order = virXMLPropString(node, "order"))) {
if (!order) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing boot order attribute")); "%s", _("missing boot order attribute"));
goto cleanup; goto cleanup;
} else if (virStrToLong_i(order, NULL, 10, &boot) < 0 || }
boot <= 0) {
if (virStrToLong_uip(order, NULL, 10, &info->bootIndex) < 0 ||
info->bootIndex == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("incorrect boot order '%s', expecting positive integer"), _("incorrect boot order '%s', expecting positive integer"),
order); order);
@ -4848,7 +4848,6 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
goto cleanup; goto cleanup;
} }
info->bootIndex = boot;
ret = 0; ret = 0;
cleanup: cleanup:
@ -22972,7 +22971,7 @@ virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
if (info->bootIndex == newinfo->bootIndex) { if (info->bootIndex == newinfo->bootIndex) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("boot order %d is already used by another device"), _("boot order %u is already used by another device"),
newinfo->bootIndex); newinfo->bootIndex);
return -1; return -1;
} }

View File

@ -368,7 +368,7 @@ struct _virDomainDeviceInfo {
char *romfile; char *romfile;
/* bootIndex is only used for disk, network interface, hostdev /* bootIndex is only used for disk, network interface, hostdev
* and redirdev devices */ * and redirdev devices */
int bootIndex; unsigned int bootIndex;
}; };

View File

@ -1525,7 +1525,7 @@ qemuCheckIOThreads(const virDomainDef *def,
char * char *
qemuBuildDriveDevStr(const virDomainDef *def, qemuBuildDriveDevStr(const virDomainDef *def,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
int bootindex, unsigned int bootindex,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
virBuffer opt = VIR_BUFFER_INITIALIZER; virBuffer opt = VIR_BUFFER_INITIALIZER;
@ -1770,7 +1770,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
virBufferAsprintf(&opt, ",drive=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias); virBufferAsprintf(&opt, ",drive=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
virBufferAsprintf(&opt, ",id=%s", disk->info.alias); virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
virBufferAsprintf(&opt, ",bootindex=%d", bootindex); virBufferAsprintf(&opt, ",bootindex=%u", bootindex);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
if (disk->blockio.logical_block_size > 0) if (disk->blockio.logical_block_size > 0)
virBufferAsprintf(&opt, ",logical_block_size=%u", virBufferAsprintf(&opt, ",logical_block_size=%u",
@ -1828,7 +1828,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
bool emitBootindex) bool emitBootindex)
{ {
size_t i; size_t i;
int bootCD = 0, bootFloppy = 0, bootDisk = 0; unsigned int bootCD = 0;
unsigned int bootFloppy = 0;
unsigned int bootDisk = 0;
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER; virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
char *fdc_opts_str = NULL; char *fdc_opts_str = NULL;
@ -1852,7 +1854,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
char *optstr; char *optstr;
int bootindex = 0; unsigned int bootindex = 0;
virDomainDiskDefPtr disk = def->disks[i]; virDomainDiskDefPtr disk = def->disks[i];
bool withDeviceArg = false; bool withDeviceArg = false;
bool deviceFlagMasked = false; bool deviceFlagMasked = false;
@ -1945,7 +1947,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
VIR_FREE(optstr); VIR_FREE(optstr);
if (bootindex) { if (bootindex) {
if (virAsprintf(&optstr, "bootindex%c=%d", if (virAsprintf(&optstr, "bootindex%c=%u",
disk->info.addr.drive.unit disk->info.addr.drive.unit
? 'B' : 'A', ? 'B' : 'A',
bootindex) < 0) bootindex) < 0)
@ -3046,7 +3048,7 @@ char *
qemuBuildNicDevStr(virDomainDefPtr def, qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int vlan, int vlan,
int bootindex, unsigned int bootindex,
size_t vhostfdSize, size_t vhostfdSize,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
@ -3175,7 +3177,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
if (qemuBuildRomStr(&buf, &net->info, qemuCaps) < 0) if (qemuBuildRomStr(&buf, &net->info, qemuCaps) < 0)
goto error; goto error;
if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) if (bootindex && virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX))
virBufferAsprintf(&buf, ",bootindex=%d", bootindex); virBufferAsprintf(&buf, ",bootindex=%u", bootindex);
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto error; goto error;
@ -4213,7 +4215,7 @@ qemuOpenPCIConfig(virDomainHostdevDefPtr dev)
char * char *
qemuBuildPCIHostdevDevStr(const virDomainDef *def, qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,
int bootIndex, /* used iff dev->info->bootIndex == 0 */ unsigned int bootIndex, /* used iff dev->info->bootIndex == 0 */
const char *configfd, const char *configfd,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
@ -4258,7 +4260,7 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
if (dev->info->bootIndex) if (dev->info->bootIndex)
bootIndex = dev->info->bootIndex; bootIndex = dev->info->bootIndex;
if (bootIndex) if (bootIndex)
virBufferAsprintf(&buf, ",bootindex=%d", bootIndex); virBufferAsprintf(&buf, ",bootindex=%u", bootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0) if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
goto error; goto error;
if (qemuBuildRomStr(&buf, dev->info, qemuCaps) < 0) if (qemuBuildRomStr(&buf, dev->info, qemuCaps) < 0)
@ -4324,7 +4326,7 @@ qemuBuildUSBHostdevDevStr(const virDomainDef *def,
} }
virBufferAsprintf(&buf, ",id=%s", dev->info->alias); virBufferAsprintf(&buf, ",id=%s", dev->info->alias);
if (dev->info->bootIndex) if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex); virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0) if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
goto error; goto error;
@ -4577,7 +4579,7 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
dev->info->alias, dev->info->alias); dev->info->alias, dev->info->alias);
if (dev->info->bootIndex) if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%d", dev->info->bootIndex); virBufferAsprintf(&buf, ",bootindex=%u", dev->info->bootIndex);
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
goto error; goto error;
@ -4790,7 +4792,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
const virDomainDef *def, const virDomainDef *def,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
qemuBuildCommandLineCallbacksPtr callbacks, qemuBuildCommandLineCallbacksPtr callbacks,
int *bootHostdevNet) unsigned int *bootHostdevNet)
{ {
size_t i; size_t i;
@ -4883,7 +4885,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
char *configfd_name = NULL; char *configfd_name = NULL;
int bootIndex = hostdev->info->bootIndex; unsigned int bootIndex = hostdev->info->bootIndex;
/* bootNet will be non-0 if boot order was set and no other /* bootNet will be non-0 if boot order was set and no other
* net devices were encountered * net devices were encountered
@ -7665,7 +7667,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
virDomainDefPtr def, virDomainDefPtr def,
virDomainNetDefPtr net, virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
int bootindex) unsigned int bootindex)
{ {
virBuffer chardev_buf = VIR_BUFFER_INITIALIZER; virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
virBuffer netdev_buf = VIR_BUFFER_INITIALIZER; virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
@ -7750,7 +7752,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virDomainNetDefPtr net, virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
int vlan, int vlan,
int bootindex, unsigned int bootindex,
virNetDevVPortProfileOp vmop, virNetDevVPortProfileOp vmop,
bool standalone, bool standalone,
size_t *nnicindexes, size_t *nnicindexes,
@ -8041,7 +8043,7 @@ qemuBuildNetCommandLine(virCommandPtr cmd,
bool emitBootindex, bool emitBootindex,
size_t *nnicindexes, size_t *nnicindexes,
int **nicindexes, int **nicindexes,
int *bootHostdevNet) unsigned int *bootHostdevNet)
{ {
size_t i; size_t i;
int last_good_net = -1; int last_good_net = -1;
@ -8052,7 +8054,7 @@ qemuBuildNetCommandLine(virCommandPtr cmd,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
virCommandAddArgList(cmd, "-net", "none", NULL); virCommandAddArgList(cmd, "-net", "none", NULL);
} else { } else {
int bootNet = 0; unsigned int bootNet = 0;
if (emitBootindex) { if (emitBootindex) {
/* convert <boot dev='network'/> to bootindex since we didn't emit /* convert <boot dev='network'/> to bootindex since we didn't emit
@ -8694,7 +8696,7 @@ qemuBuildRedirdevDevStr(const virDomainDef *def,
"supported by this version of QEMU")); "supported by this version of QEMU"));
goto error; goto error;
} }
virBufferAsprintf(&buf, ",bootindex=%d", dev->info.bootIndex); virBufferAsprintf(&buf, ",bootindex=%u", dev->info.bootIndex);
} }
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
@ -9203,7 +9205,7 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
bool emitBootindex = false; bool emitBootindex = false;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int bootHostdevNet = 0; unsigned int bootHostdevNet = 0;
VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d " VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "

View File

@ -105,7 +105,7 @@ char *qemuBuildNicStr(virDomainNetDefPtr net,
char *qemuBuildNicDevStr(virDomainDefPtr def, char *qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net, virDomainNetDefPtr net,
int vlan, int vlan,
int bootindex, unsigned int bootindex,
size_t vhostfdSize, size_t vhostfdSize,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
@ -121,7 +121,7 @@ char *qemuBuildDriveStr(virConnectPtr conn,
/* Current, best practice */ /* Current, best practice */
char *qemuBuildDriveDevStr(const virDomainDef *def, char *qemuBuildDriveDevStr(const virDomainDef *def,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
int bootindex, unsigned int bootindex,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);
/* Current, best practice */ /* Current, best practice */
@ -151,7 +151,7 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
/* Current, best practice */ /* Current, best practice */
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def, char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev, virDomainHostdevDefPtr dev,
int bootIndex, unsigned int bootIndex,
const char *configfd, const char *configfd,
virQEMUCapsPtr qemuCaps); virQEMUCapsPtr qemuCaps);

View File

@ -6981,7 +6981,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
*/ */
for (i = 0; i < vm->def->nnets; i++) { for (i = 0; i < vm->def->nnets; i++) {
virDomainNetDefPtr net = vm->def->nets[i]; virDomainNetDefPtr net = vm->def->nets[i];
int bootIndex = net->info.bootIndex; unsigned int bootIndex = net->info.bootIndex;
char *model = net->model; char *model = net->model;
virMacAddr mac = net->mac; virMacAddr mac = net->mac;