Skip to content

Commit c40ae5a

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc,virtio,pci: bug fixes Fixes all over the place. Specifically this fixes a bug which made windows guests lose device config (such as the configured fixed IP) after upgrading to the new QEMU. Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Tue 02 Mar 2021 14:19:51 GMT # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "[email protected]" # gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full] # gpg: aka "Michael S. Tsirkin <[email protected]>" [full] # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: vhost: simplify vhost_dev_init() fail_busyloop label hw/pci: Have safer pcie_bus_realize() by checking error path virtio-net: handle zero mac for a vdpa peer i386/acpi: restore device paths for pre-5.1 vms Signed-off-by: Peter Maydell <[email protected]>
2 parents 07dbfdd + 1d8d014 commit c40ae5a

File tree

7 files changed

+30
-10
lines changed

7 files changed

+30
-10
lines changed

hw/i386/acpi-build.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12771277
dev = aml_device("PCI0");
12781278
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A03")));
12791279
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
1280-
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
1280+
aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
12811281
aml_append(sb_scope, dev);
12821282
aml_append(dsdt, sb_scope);
12831283

@@ -1296,7 +1296,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
12961296
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08")));
12971297
aml_append(dev, aml_name_decl("_CID", aml_eisaid("PNP0A03")));
12981298
aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
1299-
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
1299+
aml_append(dev, aml_name_decl("_UID", aml_int(pcmc->pci_root_uid)));
13001300
aml_append(dev, build_q35_osc_method());
13011301
aml_append(sb_scope, dev);
13021302
if (mcfg_valid) {

hw/i386/pc_piix.c

+2
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ static void pc_i440fx_machine_options(MachineClass *m)
405405
{
406406
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
407407
pcmc->default_nic_model = "e1000";
408+
pcmc->pci_root_uid = 0;
408409

409410
m->family = "pc_piix";
410411
m->desc = "Standard PC (i440FX + PIIX, 1996)";
@@ -448,6 +449,7 @@ static void pc_i440fx_5_1_machine_options(MachineClass *m)
448449
compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
449450
compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
450451
pcmc->kvmclock_create_always = false;
452+
pcmc->pci_root_uid = 1;
451453
}
452454

453455
DEFINE_I440FX_MACHINE(v5_1, "pc-i440fx-5.1", NULL,

hw/i386/pc_q35.c

+2
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static void pc_q35_machine_options(MachineClass *m)
329329
{
330330
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
331331
pcmc->default_nic_model = "e1000e";
332+
pcmc->pci_root_uid = 0;
332333

333334
m->family = "pc_q35";
334335
m->desc = "Standard PC (Q35 + ICH9, 2009)";
@@ -375,6 +376,7 @@ static void pc_q35_5_1_machine_options(MachineClass *m)
375376
compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len);
376377
compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len);
377378
pcmc->kvmclock_create_always = false;
379+
pcmc->pci_root_uid = 1;
378380
}
379381

380382
DEFINE_Q35_MACHINE(v5_1, "pc-q35-5.1", NULL,

hw/net/virtio-net.c

+12
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
126126
VirtIONet *n = VIRTIO_NET(vdev);
127127
struct virtio_net_config netcfg;
128128
NetClientState *nc = qemu_get_queue(n->nic);
129+
static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
129130

130131
int ret = 0;
131132
memset(&netcfg, 0 , sizeof(struct virtio_net_config));
@@ -151,6 +152,17 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
151152
ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
152153
n->config_size);
153154
if (ret != -1) {
155+
/*
156+
* Some NIC/kernel combinations present 0 as the mac address. As
157+
* that is not a legal address, try to proceed with the
158+
* address from the QEMU command line in the hope that the
159+
* address has been configured correctly elsewhere - just not
160+
* reported by the device.
161+
*/
162+
if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) {
163+
info_report("Zero hardware mac address detected. Ignoring.");
164+
memcpy(netcfg.mac, n->mac, ETH_ALEN);
165+
}
154166
memcpy(config, &netcfg, n->config_size);
155167
}
156168
}

hw/pci/pci.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
132132
static void pcie_bus_realize(BusState *qbus, Error **errp)
133133
{
134134
PCIBus *bus = PCI_BUS(qbus);
135+
Error *local_err = NULL;
135136

136-
pci_bus_realize(qbus, errp);
137+
pci_bus_realize(qbus, &local_err);
138+
if (local_err) {
139+
error_propagate(errp, local_err);
140+
return;
141+
}
137142

138143
/*
139144
* A PCI-E bus can support extended config space if it's the root

hw/virtio/vhost.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -1388,18 +1388,16 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
13881388
error_report("vhost backend memory slots limit is less"
13891389
" than current number of present memory slots");
13901390
r = -1;
1391-
if (busyloop_timeout) {
1392-
goto fail_busyloop;
1393-
} else {
1394-
goto fail;
1395-
}
1391+
goto fail_busyloop;
13961392
}
13971393

13981394
return 0;
13991395

14001396
fail_busyloop:
1401-
while (--i >= 0) {
1402-
vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
1397+
if (busyloop_timeout) {
1398+
while (--i >= 0) {
1399+
vhost_virtqueue_set_busyloop_timeout(hdev, hdev->vq_index + i, 0);
1400+
}
14031401
}
14041402
fail:
14051403
hdev->nvqs = n_initialized_vqs;

include/hw/i386/pc.h

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct PCMachineClass {
105105
int legacy_acpi_table_size;
106106
unsigned acpi_data_size;
107107
bool do_not_add_smb_acpi;
108+
int pci_root_uid;
108109

109110
/* SMBIOS compat: */
110111
bool smbios_defaults;

0 commit comments

Comments
 (0)