mirror of https://github.com/xqemu/xqemu.git
libqos: add PCI management in qtest_vboot()/qtest_shutdown()
Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
cf716b31cb
commit
2ecd7e2f25
|
@ -390,7 +390,7 @@ static void data_test_init(e1000e_device *d)
|
||||||
qtest_start(cmdline);
|
qtest_start(cmdline);
|
||||||
g_free(cmdline);
|
g_free(cmdline);
|
||||||
|
|
||||||
test_bus = qpci_init_pc();
|
test_bus = qpci_init_pc(NULL);
|
||||||
g_assert_nonnull(test_bus);
|
g_assert_nonnull(test_bus);
|
||||||
|
|
||||||
test_alloc = pc_alloc_init();
|
test_alloc = pc_alloc_init();
|
||||||
|
|
|
@ -38,7 +38,7 @@ static QPCIBus *test_start_get_bus(const TestData *s)
|
||||||
cmdline = g_strdup_printf("-smp %d", s->num_cpus);
|
cmdline = g_strdup_printf("-smp %d", s->num_cpus);
|
||||||
qtest_start(cmdline);
|
qtest_start(cmdline);
|
||||||
g_free(cmdline);
|
g_free(cmdline);
|
||||||
return qpci_init_pc();
|
return qpci_init_pc(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_i440fx_defaults(gconstpointer opaque)
|
static void test_i440fx_defaults(gconstpointer opaque)
|
||||||
|
|
|
@ -143,7 +143,7 @@ static QPCIDevice *get_pci_device(uint16_t *bmdma_base)
|
||||||
uint16_t vendor_id, device_id;
|
uint16_t vendor_id, device_id;
|
||||||
|
|
||||||
if (!pcibus) {
|
if (!pcibus) {
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find PCI device and verify it's the right one */
|
/* Find PCI device and verify it's the right one */
|
||||||
|
|
|
@ -105,7 +105,7 @@ static void setup_vm_cmd(IVState *s, const char *cmd, bool msix)
|
||||||
uint64_t barsize;
|
uint64_t barsize;
|
||||||
|
|
||||||
s->qtest = qtest_start(cmd);
|
s->qtest = qtest_start(cmd);
|
||||||
s->pcibus = qpci_init_pc();
|
s->pcibus = qpci_init_pc(NULL);
|
||||||
s->dev = get_device(s->pcibus);
|
s->dev = get_device(s->pcibus);
|
||||||
|
|
||||||
s->reg_base = qpci_iomap(s->dev, 0, &barsize);
|
s->reg_base = qpci_iomap(s->dev, 0, &barsize);
|
||||||
|
|
|
@ -128,7 +128,7 @@ QPCIDevice *get_ahci_device(uint32_t *fingerprint)
|
||||||
uint32_t ahci_fingerprint;
|
uint32_t ahci_fingerprint;
|
||||||
QPCIBus *pcibus;
|
QPCIBus *pcibus;
|
||||||
|
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
|
|
||||||
/* Find the AHCI PCI device and verify it's the right one. */
|
/* Find the AHCI PCI device and verify it's the right one. */
|
||||||
ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));
|
ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "libqos/libqos-pc.h"
|
#include "libqos/libqos-pc.h"
|
||||||
#include "libqos/malloc-pc.h"
|
#include "libqos/malloc-pc.h"
|
||||||
|
#include "libqos/pci-pc.h"
|
||||||
|
|
||||||
static QOSOps qos_ops = {
|
static QOSOps qos_ops = {
|
||||||
.init_allocator = pc_alloc_init_flags,
|
.init_allocator = pc_alloc_init_flags,
|
||||||
.uninit_allocator = pc_alloc_uninit
|
.uninit_allocator = pc_alloc_uninit,
|
||||||
|
.qpci_init = qpci_init_pc,
|
||||||
|
.qpci_free = qpci_free_pc,
|
||||||
};
|
};
|
||||||
|
|
||||||
QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap)
|
QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap)
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "libqos/libqos-spapr.h"
|
#include "libqos/libqos-spapr.h"
|
||||||
#include "libqos/malloc-spapr.h"
|
#include "libqos/malloc-spapr.h"
|
||||||
|
#include "libqos/pci-spapr.h"
|
||||||
|
|
||||||
static QOSOps qos_ops = {
|
static QOSOps qos_ops = {
|
||||||
.init_allocator = spapr_alloc_init_flags,
|
.init_allocator = spapr_alloc_init_flags,
|
||||||
.uninit_allocator = spapr_alloc_uninit
|
.uninit_allocator = spapr_alloc_uninit,
|
||||||
|
.qpci_init = qpci_init_spapr,
|
||||||
|
.qpci_free = qpci_free_spapr,
|
||||||
};
|
};
|
||||||
|
|
||||||
QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap)
|
QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap)
|
||||||
|
|
|
@ -20,8 +20,13 @@ QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
|
||||||
cmdline = g_strdup_vprintf(cmdline_fmt, ap);
|
cmdline = g_strdup_vprintf(cmdline_fmt, ap);
|
||||||
qs->qts = qtest_start(cmdline);
|
qs->qts = qtest_start(cmdline);
|
||||||
qs->ops = ops;
|
qs->ops = ops;
|
||||||
if (ops && ops->init_allocator) {
|
if (ops) {
|
||||||
qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
|
if (ops->init_allocator) {
|
||||||
|
qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
|
||||||
|
}
|
||||||
|
if (ops->qpci_init && qs->alloc) {
|
||||||
|
qs->pcibus = ops->qpci_init(qs->alloc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(cmdline);
|
g_free(cmdline);
|
||||||
|
@ -49,9 +54,15 @@ QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...)
|
||||||
*/
|
*/
|
||||||
void qtest_shutdown(QOSState *qs)
|
void qtest_shutdown(QOSState *qs)
|
||||||
{
|
{
|
||||||
if (qs->alloc && qs->ops && qs->ops->uninit_allocator) {
|
if (qs->ops) {
|
||||||
qs->ops->uninit_allocator(qs->alloc);
|
if (qs->pcibus && qs->ops->qpci_free) {
|
||||||
qs->alloc = NULL;
|
qs->ops->qpci_free(qs->pcibus);
|
||||||
|
qs->pcibus = NULL;
|
||||||
|
}
|
||||||
|
if (qs->alloc && qs->ops->uninit_allocator) {
|
||||||
|
qs->ops->uninit_allocator(qs->alloc);
|
||||||
|
qs->alloc = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qtest_quit(qs->qts);
|
qtest_quit(qs->qts);
|
||||||
g_free(qs);
|
g_free(qs);
|
||||||
|
|
|
@ -8,11 +8,14 @@
|
||||||
typedef struct QOSOps {
|
typedef struct QOSOps {
|
||||||
QGuestAllocator *(*init_allocator)(QAllocOpts);
|
QGuestAllocator *(*init_allocator)(QAllocOpts);
|
||||||
void (*uninit_allocator)(QGuestAllocator *);
|
void (*uninit_allocator)(QGuestAllocator *);
|
||||||
|
QPCIBus *(*qpci_init)(QGuestAllocator *alloc);
|
||||||
|
void (*qpci_free)(QPCIBus *bus);
|
||||||
} QOSOps;
|
} QOSOps;
|
||||||
|
|
||||||
typedef struct QOSState {
|
typedef struct QOSState {
|
||||||
QTestState *qts;
|
QTestState *qts;
|
||||||
QGuestAllocator *alloc;
|
QGuestAllocator *alloc;
|
||||||
|
QPCIBus *pcibus;
|
||||||
QOSOps *ops;
|
QOSOps *ops;
|
||||||
} QOSState;
|
} QOSState;
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ static void qpci_pc_iounmap(QPCIBus *bus, void *data)
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
}
|
}
|
||||||
|
|
||||||
QPCIBus *qpci_init_pc(void)
|
QPCIBus *qpci_init_pc(QGuestAllocator *alloc)
|
||||||
{
|
{
|
||||||
QPCIBusPC *ret;
|
QPCIBusPC *ret;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@
|
||||||
#define LIBQOS_PCI_PC_H
|
#define LIBQOS_PCI_PC_H
|
||||||
|
|
||||||
#include "libqos/pci.h"
|
#include "libqos/pci.h"
|
||||||
|
#include "libqos/malloc.h"
|
||||||
|
|
||||||
QPCIBus *qpci_init_pc(void);
|
QPCIBus *qpci_init_pc(QGuestAllocator *alloc);
|
||||||
void qpci_free_pc(QPCIBus *bus);
|
void qpci_free_pc(QPCIBus *bus);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,7 +42,7 @@ static void test_smram_lock(void)
|
||||||
QPCIDevice *pcidev;
|
QPCIDevice *pcidev;
|
||||||
QDict *response;
|
QDict *response;
|
||||||
|
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
g_assert(pcibus != NULL);
|
g_assert(pcibus != NULL);
|
||||||
|
|
||||||
pcidev = qpci_device_find(pcibus, 0);
|
pcidev = qpci_device_find(pcibus, 0);
|
||||||
|
|
|
@ -35,7 +35,7 @@ static QPCIDevice *get_device(void)
|
||||||
{
|
{
|
||||||
QPCIDevice *dev;
|
QPCIDevice *dev;
|
||||||
|
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev);
|
qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev);
|
||||||
g_assert(dev != NULL);
|
g_assert(dev != NULL);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ static void test_init(TestData *d)
|
||||||
qtest_irq_intercept_in(qs, "ioapic");
|
qtest_irq_intercept_in(qs, "ioapic");
|
||||||
g_free(s);
|
g_free(s);
|
||||||
|
|
||||||
bus = qpci_init_pc();
|
bus = qpci_init_pc(NULL);
|
||||||
d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));
|
d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));
|
||||||
g_assert(d->dev != NULL);
|
g_assert(d->dev != NULL);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ static void pci_init(void)
|
||||||
if (pcibus) {
|
if (pcibus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
g_assert(pcibus != NULL);
|
g_assert(pcibus != NULL);
|
||||||
|
|
||||||
qusb_pci_init_one(pcibus, &uhci1, QPCI_DEVFN(0x1d, 0), 4);
|
qusb_pci_init_one(pcibus, &uhci1, QPCI_DEVFN(0x1d, 0), 4);
|
||||||
|
|
|
@ -23,7 +23,7 @@ static void test_port(int port)
|
||||||
struct qhc uhci;
|
struct qhc uhci;
|
||||||
|
|
||||||
g_assert(port > 0);
|
g_assert(port > 0);
|
||||||
pcibus = qpci_init_pc();
|
pcibus = qpci_init_pc(NULL);
|
||||||
g_assert(pcibus != NULL);
|
g_assert(pcibus != NULL);
|
||||||
qusb_pci_init_one(pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);
|
qusb_pci_init_one(pcibus, &uhci, QPCI_DEVFN(0x1d, 0), 4);
|
||||||
uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);
|
uhci_port_test(&uhci, port - 1, UHCI_PORT_CCS);
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void init_virtio_dev(TestServer *s)
|
||||||
QVirtioPCIDevice *dev;
|
QVirtioPCIDevice *dev;
|
||||||
uint32_t features;
|
uint32_t features;
|
||||||
|
|
||||||
bus = qpci_init_pc();
|
bus = qpci_init_pc(NULL);
|
||||||
g_assert_nonnull(bus);
|
g_assert_nonnull(bus);
|
||||||
|
|
||||||
dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
|
dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
|
||||||
|
@ -884,7 +884,7 @@ static void test_multiqueue(void)
|
||||||
qtest_start(cmd);
|
qtest_start(cmd);
|
||||||
g_free(cmd);
|
g_free(cmd);
|
||||||
|
|
||||||
bus = qpci_init_pc();
|
bus = qpci_init_pc(NULL);
|
||||||
dev = virtio_net_pci_init(bus, PCI_SLOT);
|
dev = virtio_net_pci_init(bus, PCI_SLOT);
|
||||||
|
|
||||||
alloc = pc_alloc_init();
|
alloc = pc_alloc_init();
|
||||||
|
|
|
@ -63,7 +63,7 @@ static QVirtIO9P *qvirtio_9p_pci_init(void)
|
||||||
|
|
||||||
v9p = g_new0(QVirtIO9P, 1);
|
v9p = g_new0(QVirtIO9P, 1);
|
||||||
v9p->alloc = pc_alloc_init();
|
v9p->alloc = pc_alloc_init();
|
||||||
v9p->bus = qpci_init_pc();
|
v9p->bus = qpci_init_pc(NULL);
|
||||||
|
|
||||||
dev = qvirtio_pci_device_find(v9p->bus, VIRTIO_ID_9P);
|
dev = qvirtio_pci_device_find(v9p->bus, VIRTIO_ID_9P);
|
||||||
g_assert_nonnull(dev);
|
g_assert_nonnull(dev);
|
||||||
|
|
|
@ -75,7 +75,7 @@ static QPCIBus *pci_test_start(void)
|
||||||
g_free(tmp_path);
|
g_free(tmp_path);
|
||||||
g_free(cmdline);
|
g_free(cmdline);
|
||||||
|
|
||||||
return qpci_init_pc();
|
return qpci_init_pc(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm_test_start(void)
|
static void arm_test_start(void)
|
||||||
|
|
|
@ -62,7 +62,7 @@ static QPCIBus *pci_test_start(int socket)
|
||||||
qtest_start(cmdline);
|
qtest_start(cmdline);
|
||||||
g_free(cmdline);
|
g_free(cmdline);
|
||||||
|
|
||||||
return qpci_init_pc();
|
return qpci_init_pc(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev)
|
static void driver_init(const QVirtioBus *bus, QVirtioDevice *dev)
|
||||||
|
|
|
@ -146,7 +146,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
|
||||||
|
|
||||||
vs = g_new0(QVirtIOSCSI, 1);
|
vs = g_new0(QVirtIOSCSI, 1);
|
||||||
vs->alloc = pc_alloc_init();
|
vs->alloc = pc_alloc_init();
|
||||||
vs->bus = qpci_init_pc();
|
vs->bus = qpci_init_pc(NULL);
|
||||||
|
|
||||||
dev = qvirtio_pci_device_find(vs->bus, VIRTIO_ID_SCSI);
|
dev = qvirtio_pci_device_find(vs->bus, VIRTIO_ID_SCSI);
|
||||||
vs->dev = (QVirtioDevice *)dev;
|
vs->dev = (QVirtioDevice *)dev;
|
||||||
|
|
Loading…
Reference in New Issue