mirror of https://gitee.com/openkylin/libvirt.git
qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound"
More occurences of repeatedly dereferencing the same pointer stored in an array are replaced with the definition of a temporary pointer that is then used directly. No functional change.
This commit is contained in:
parent
9ca53303f8
commit
ac47e4a622
|
@ -211,11 +211,14 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
|
||||||
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
|
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
if (def->nets[i]->model &&
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
STREQ(def->nets[i]->model, "spapr-vlan"))
|
|
||||||
def->nets[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
if (net->model &&
|
||||||
if (qemuDomainAssignSpaprVIOAddress(def, &def->nets[i]->info,
|
STREQ(net->model, "spapr-vlan")) {
|
||||||
VIO_ADDR_NET) < 0)
|
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,9 +286,11 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
if (STREQ(def->nets[i]->model, "virtio") &&
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
|
||||||
def->nets[i]->info.type = type;
|
if (STREQ(net->model, "virtio") &&
|
||||||
|
net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||||
|
net->info.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,31 +1052,35 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||||
|
|
||||||
/* Network interfaces */
|
/* Network interfaces */
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
|
virDomainNetDefPtr net = def->nets[i];
|
||||||
|
|
||||||
/* type='hostdev' network devices might be USB, and are also
|
/* type='hostdev' network devices might be USB, and are also
|
||||||
* in hostdevs list anyway, so handle them with other hostdevs
|
* in hostdevs list anyway, so handle them with other hostdevs
|
||||||
* instead of here.
|
* instead of here.
|
||||||
*/
|
*/
|
||||||
if ((def->nets[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) ||
|
if ((net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) ||
|
||||||
!virDeviceInfoPCIAddressWanted(&def->nets[i]->info)) {
|
!virDeviceInfoPCIAddressWanted(&net->info)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->nets[i]->info,
|
if (virDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
|
||||||
flags) < 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sound cards */
|
/* Sound cards */
|
||||||
for (i = 0; i < def->nsounds; i++) {
|
for (i = 0; i < def->nsounds; i++) {
|
||||||
if (!virDeviceInfoPCIAddressWanted(&def->sounds[i]->info))
|
virDomainSoundDefPtr sound = def->sounds[i];
|
||||||
continue;
|
|
||||||
/* Skip ISA sound card, PCSPK and usb-audio */
|
if (!virDeviceInfoPCIAddressWanted(&sound->info))
|
||||||
if (def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_SB16 ||
|
|
||||||
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK ||
|
|
||||||
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_USB)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info,
|
/* Skip ISA sound card, PCSPK and usb-audio */
|
||||||
flags) < 0)
|
if (sound->model == VIR_DOMAIN_SOUND_MODEL_SB16 ||
|
||||||
|
sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK ||
|
||||||
|
sound->model == VIR_DOMAIN_SOUND_MODEL_USB) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue