mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
tests: Add virtio device initialization
Add functions to read and write virtio header fields. Add status bit setting in virtio-blk-device. Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
311e666aea
commit
46e0cf7629
8 changed files with 257 additions and 5 deletions
55
tests/libqos/virtio.c
Normal file
55
tests/libqos/virtio.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* libqos virtio driver
|
||||
*
|
||||
* Copyright (c) 2014 Marc Marí
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "libqtest.h"
|
||||
#include "libqos/virtio.h"
|
||||
|
||||
uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
|
||||
void *addr)
|
||||
{
|
||||
return bus->config_readb(d, addr);
|
||||
}
|
||||
|
||||
uint16_t qvirtio_config_readw(const QVirtioBus *bus, QVirtioDevice *d,
|
||||
void *addr)
|
||||
{
|
||||
return bus->config_readw(d, addr);
|
||||
}
|
||||
|
||||
uint32_t qvirtio_config_readl(const QVirtioBus *bus, QVirtioDevice *d,
|
||||
void *addr)
|
||||
{
|
||||
return bus->config_readl(d, addr);
|
||||
}
|
||||
|
||||
uint64_t qvirtio_config_readq(const QVirtioBus *bus, QVirtioDevice *d,
|
||||
void *addr)
|
||||
{
|
||||
return bus->config_readq(d, addr);
|
||||
}
|
||||
|
||||
void qvirtio_reset(const QVirtioBus *bus, QVirtioDevice *d)
|
||||
{
|
||||
bus->set_status(d, QVIRTIO_RESET);
|
||||
g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_RESET);
|
||||
}
|
||||
|
||||
void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d)
|
||||
{
|
||||
bus->set_status(d, bus->get_status(d) | QVIRTIO_ACKNOWLEDGE);
|
||||
g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_ACKNOWLEDGE);
|
||||
}
|
||||
|
||||
void qvirtio_set_driver(const QVirtioBus *bus, QVirtioDevice *d)
|
||||
{
|
||||
bus->set_status(d, bus->get_status(d) | QVIRTIO_DRIVER);
|
||||
g_assert_cmphex(bus->get_status(d), ==,
|
||||
QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue