mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-08-15' into staging
- Fix for ctrl queue in the virtio-net QOS driver - Improve Valgrind reports in the tests that use the null-co driver - Get rid of global_qtest related code in libqtest and libqos # gpg: Signature made Thu 15 Aug 2019 18:28:16 BST # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full] # gpg: aka "Thomas Huth <thuth@redhat.com>" [full] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * remotes/huth-gitlab/tags/pull-request-2019-08-15: tests/libqtest: Make qmp_assert_success() independent from global_qtest tests/libqtest: Make qtest_qmp_device_add/del independent from global_qtest tests/libqtest: Clean up qtest_cb_for_every_machine() wrt global_qtest tests/libqtest: Remove unused function hmp() tests/libqos: Make virtio-pci code independent from global_qtest tests/libqos: Make generic virtio code independent from global_qtest tests: Set read-zeroes on for null-co driver libqos: Account for the ctrl queue in virtio-net qtest: Rename qtest.c:qtest_init() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -24,6 +24,6 @@ static inline bool qtest_enabled(void)
|
||||
|
||||
bool qtest_driver(void);
|
||||
|
||||
void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp);
|
||||
void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **errp);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -748,8 +748,7 @@ static void qtest_event(void *opaque, int event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
|
||||
void qtest_server_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)
|
||||
{
|
||||
Chardev *chr;
|
||||
|
||||
|
||||
@@ -77,18 +77,19 @@ static void test_plug_with_device_add_x86(gconstpointer data)
|
||||
const PlugTestData *td = data;
|
||||
char *args;
|
||||
unsigned int s, c, t;
|
||||
QTestState *qts;
|
||||
|
||||
args = g_strdup_printf("-machine %s -cpu %s "
|
||||
"-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
|
||||
td->machine, td->cpu_model,
|
||||
td->sockets, td->cores, td->threads, td->maxcpus);
|
||||
qtest_start(args);
|
||||
qts = qtest_init(args);
|
||||
|
||||
for (s = 1; s < td->sockets; s++) {
|
||||
for (c = 0; c < td->cores; c++) {
|
||||
for (t = 0; t < td->threads; t++) {
|
||||
char *id = g_strdup_printf("id-%i-%i-%i", s, c, t);
|
||||
qtest_qmp_device_add(td->device_model, id,
|
||||
qtest_qmp_device_add(qts, td->device_model, id,
|
||||
"{'socket-id':%u, 'core-id':%u,"
|
||||
" 'thread-id':%u}",
|
||||
s, c, t);
|
||||
@@ -97,7 +98,7 @@ static void test_plug_with_device_add_x86(gconstpointer data)
|
||||
}
|
||||
}
|
||||
|
||||
qtest_end();
|
||||
qtest_quit(qts);
|
||||
g_free(args);
|
||||
}
|
||||
|
||||
@@ -106,20 +107,22 @@ static void test_plug_with_device_add_coreid(gconstpointer data)
|
||||
const PlugTestData *td = data;
|
||||
char *args;
|
||||
unsigned int c;
|
||||
QTestState *qts;
|
||||
|
||||
args = g_strdup_printf("-machine %s -cpu %s "
|
||||
"-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
|
||||
td->machine, td->cpu_model,
|
||||
td->sockets, td->cores, td->threads, td->maxcpus);
|
||||
qtest_start(args);
|
||||
qts = qtest_init(args);
|
||||
|
||||
for (c = 1; c < td->cores; c++) {
|
||||
char *id = g_strdup_printf("id-%i", c);
|
||||
qtest_qmp_device_add(td->device_model, id, "{'core-id':%u}", c);
|
||||
qtest_qmp_device_add(qts, td->device_model, id,
|
||||
"{'core-id':%u}", c);
|
||||
g_free(id);
|
||||
}
|
||||
|
||||
qtest_end();
|
||||
qtest_quit(qts);
|
||||
g_free(args);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ static void test_drive_del_device_del(void)
|
||||
QTestState *qts;
|
||||
|
||||
/* Start with a drive used by a device that unplugs instantaneously */
|
||||
qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,format=raw"
|
||||
qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
|
||||
"file.read-zeroes=on,format=raw"
|
||||
" -device virtio-scsi-%s"
|
||||
" -device scsi-hd,drive=drive0,id=dev0",
|
||||
qvirtio_get_dev_type());
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * alloc)
|
||||
{
|
||||
QTestState *qts = global_qtest; /* TODO: get rid of global_qtest here */
|
||||
|
||||
qtest_qmp_device_add("e1000e", "e1000e_net", "{'addr': '0x06'}");
|
||||
qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}");
|
||||
qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06);
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ static void test_ivshmem_hotplug(void)
|
||||
qts = qtest_init("-object memory-backend-ram,size=1M,id=mb1");
|
||||
|
||||
global_qtest = qts; /* TODO: Get rid of global_qtest here */
|
||||
qtest_qmp_device_add("ivshmem-plain", "iv1",
|
||||
qtest_qmp_device_add(qts, "ivshmem-plain", "iv1",
|
||||
"{'addr': %s, 'memdev': 'mb1'}",
|
||||
stringify(PCI_SLOT_HP));
|
||||
if (strcmp(arch, "ppc64") != 0) {
|
||||
|
||||
+3
-3
@@ -37,20 +37,20 @@ void uhci_port_test(struct qhc *hc, int port, uint16_t expect)
|
||||
g_assert((value & mask) == (expect & mask));
|
||||
}
|
||||
|
||||
void usb_test_hotplug(const char *hcd_id, const char *port,
|
||||
void usb_test_hotplug(QTestState *qts, const char *hcd_id, const char *port,
|
||||
void (*port_check)(void))
|
||||
{
|
||||
char *id = g_strdup_printf("usbdev%s", port);
|
||||
char *bus = g_strdup_printf("%s.0", hcd_id);
|
||||
|
||||
qtest_qmp_device_add("usb-tablet", id, "{'port': %s, 'bus': %s}",
|
||||
qtest_qmp_device_add(qts, "usb-tablet", id, "{'port': %s, 'bus': %s}",
|
||||
port, bus);
|
||||
|
||||
if (port_check) {
|
||||
port_check();
|
||||
}
|
||||
|
||||
qtest_qmp_device_del(id);
|
||||
qtest_qmp_device_del(qts, id);
|
||||
|
||||
g_free(bus);
|
||||
g_free(id);
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc,
|
||||
void uhci_port_test(struct qhc *hc, int port, uint16_t expect);
|
||||
void uhci_deinit(struct qhc *hc);
|
||||
|
||||
void usb_test_hotplug(const char *bus_name, const char *port,
|
||||
void usb_test_hotplug(QTestState *qts, const char *bus_name, const char *port,
|
||||
void (*port_check)(void));
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,7 @@ static void virtio_net_setup(QVirtioNet *interface)
|
||||
} else {
|
||||
interface->n_queues = 2;
|
||||
}
|
||||
interface->n_queues++; /* Account for the ctrl queue */
|
||||
|
||||
interface->queues = g_new(QVirtQueue *, interface->n_queues);
|
||||
for (i = 0; i < interface->n_queues; i++) {
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct QVirtioNetDevice QVirtioNetDevice;
|
||||
|
||||
struct QVirtioNet {
|
||||
QVirtioDevice *vdev;
|
||||
int n_queues;
|
||||
int n_queues; /* total number of virtqueues (rx, tx, ctrl) */
|
||||
QVirtQueue **queues;
|
||||
};
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
|
||||
/* No ISR checking should be done if masked, but read anyway */
|
||||
return qpci_msix_pending(dev->pdev, vqpci->msix_entry);
|
||||
} else {
|
||||
data = readl(vqpci->msix_addr);
|
||||
data = qtest_readl(dev->pdev->bus->qts, vqpci->msix_addr);
|
||||
if (data == vqpci->msix_data) {
|
||||
writel(vqpci->msix_addr, 0);
|
||||
qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -162,9 +162,9 @@ static bool qvirtio_pci_get_config_isr_status(QVirtioDevice *d)
|
||||
/* No ISR checking should be done if masked, but read anyway */
|
||||
return qpci_msix_pending(dev->pdev, dev->config_msix_entry);
|
||||
} else {
|
||||
data = readl(dev->config_msix_addr);
|
||||
data = qtest_readl(dev->pdev->bus->qts, dev->config_msix_addr);
|
||||
if (data == dev->config_msix_data) {
|
||||
writel(dev->config_msix_addr, 0);
|
||||
qtest_writel(dev->pdev->bus->qts, dev->config_msix_addr, 0);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -95,7 +95,8 @@ static void virtio_scsi_register_nodes(void)
|
||||
};
|
||||
|
||||
QOSGraphEdgeOptions opts = {
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw",
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
|
||||
"file.read-zeroes=on,format=raw",
|
||||
.after_cmd_line = "-device scsi-hd,bus=vs0.0,drive=drv0",
|
||||
};
|
||||
|
||||
|
||||
+44
-37
@@ -101,7 +101,7 @@ void qvirtio_wait_queue_isr(QVirtioDevice *d,
|
||||
* The virtqueue interrupt must not be raised, making this useful for testing
|
||||
* event_index functionality.
|
||||
*/
|
||||
uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
|
||||
uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
|
||||
QVirtQueue *vq,
|
||||
uint64_t addr,
|
||||
gint64 timeout_us)
|
||||
@@ -126,7 +126,7 @@ uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
|
||||
*
|
||||
* This function waits for the next completed request on the used ring.
|
||||
*/
|
||||
void qvirtio_wait_used_elem(QVirtioDevice *d,
|
||||
void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
|
||||
QVirtQueue *vq,
|
||||
uint32_t desc_idx,
|
||||
uint32_t *len,
|
||||
@@ -140,7 +140,7 @@ void qvirtio_wait_used_elem(QVirtioDevice *d,
|
||||
clock_step(100);
|
||||
|
||||
if (d->bus->get_queue_isr_status(d, vq) &&
|
||||
qvirtqueue_get_buf(vq, &got_desc_idx, len)) {
|
||||
qvirtqueue_get_buf(qts, vq, &got_desc_idx, len)) {
|
||||
g_assert_cmpint(got_desc_idx, ==, desc_idx);
|
||||
return;
|
||||
}
|
||||
@@ -193,8 +193,9 @@ void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
|
||||
0);
|
||||
}
|
||||
|
||||
QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
|
||||
QGuestAllocator *alloc, uint16_t elem)
|
||||
QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevice *d,
|
||||
QGuestAllocator *alloc,
|
||||
uint16_t elem)
|
||||
{
|
||||
int i;
|
||||
QVRingIndirectDesc *indirect = g_malloc(sizeof(*indirect));
|
||||
@@ -205,41 +206,41 @@ QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
|
||||
|
||||
for (i = 0; i < elem - 1; ++i) {
|
||||
/* indirect->desc[i].addr */
|
||||
writeq(indirect->desc + (16 * i), 0);
|
||||
qtest_writeq(qs, indirect->desc + (16 * i), 0);
|
||||
/* indirect->desc[i].flags */
|
||||
writew(indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
|
||||
qtest_writew(qs, indirect->desc + (16 * i) + 12, VRING_DESC_F_NEXT);
|
||||
/* indirect->desc[i].next */
|
||||
writew(indirect->desc + (16 * i) + 14, i + 1);
|
||||
qtest_writew(qs, indirect->desc + (16 * i) + 14, i + 1);
|
||||
}
|
||||
|
||||
return indirect;
|
||||
}
|
||||
|
||||
void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data,
|
||||
uint32_t len, bool write)
|
||||
void qvring_indirect_desc_add(QTestState *qts, QVRingIndirectDesc *indirect,
|
||||
uint64_t data, uint32_t len, bool write)
|
||||
{
|
||||
uint16_t flags;
|
||||
|
||||
g_assert_cmpint(indirect->index, <, indirect->elem);
|
||||
|
||||
flags = readw(indirect->desc + (16 * indirect->index) + 12);
|
||||
flags = qtest_readw(qts, indirect->desc + (16 * indirect->index) + 12);
|
||||
|
||||
if (write) {
|
||||
flags |= VRING_DESC_F_WRITE;
|
||||
}
|
||||
|
||||
/* indirect->desc[indirect->index].addr */
|
||||
writeq(indirect->desc + (16 * indirect->index), data);
|
||||
qtest_writeq(qts, indirect->desc + (16 * indirect->index), data);
|
||||
/* indirect->desc[indirect->index].len */
|
||||
writel(indirect->desc + (16 * indirect->index) + 8, len);
|
||||
qtest_writel(qts, indirect->desc + (16 * indirect->index) + 8, len);
|
||||
/* indirect->desc[indirect->index].flags */
|
||||
writew(indirect->desc + (16 * indirect->index) + 12, flags);
|
||||
qtest_writew(qts, indirect->desc + (16 * indirect->index) + 12, flags);
|
||||
|
||||
indirect->index++;
|
||||
}
|
||||
|
||||
uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write,
|
||||
bool next)
|
||||
uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data,
|
||||
uint32_t len, bool write, bool next)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
vq->num_free--;
|
||||
@@ -253,16 +254,17 @@ uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write,
|
||||
}
|
||||
|
||||
/* vq->desc[vq->free_head].addr */
|
||||
writeq(vq->desc + (16 * vq->free_head), data);
|
||||
qtest_writeq(qts, vq->desc + (16 * vq->free_head), data);
|
||||
/* vq->desc[vq->free_head].len */
|
||||
writel(vq->desc + (16 * vq->free_head) + 8, len);
|
||||
qtest_writel(qts, vq->desc + (16 * vq->free_head) + 8, len);
|
||||
/* vq->desc[vq->free_head].flags */
|
||||
writew(vq->desc + (16 * vq->free_head) + 12, flags);
|
||||
qtest_writew(qts, vq->desc + (16 * vq->free_head) + 12, flags);
|
||||
|
||||
return vq->free_head++; /* Return and increase, in this order */
|
||||
}
|
||||
|
||||
uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
|
||||
uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq,
|
||||
QVRingIndirectDesc *indirect)
|
||||
{
|
||||
g_assert(vq->indirect);
|
||||
g_assert_cmpint(vq->size, >=, indirect->elem);
|
||||
@@ -271,34 +273,36 @@ uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect)
|
||||
vq->num_free--;
|
||||
|
||||
/* vq->desc[vq->free_head].addr */
|
||||
writeq(vq->desc + (16 * vq->free_head), indirect->desc);
|
||||
qtest_writeq(qts, vq->desc + (16 * vq->free_head), indirect->desc);
|
||||
/* vq->desc[vq->free_head].len */
|
||||
writel(vq->desc + (16 * vq->free_head) + 8,
|
||||
qtest_writel(qts, vq->desc + (16 * vq->free_head) + 8,
|
||||
sizeof(struct vring_desc) * indirect->elem);
|
||||
/* vq->desc[vq->free_head].flags */
|
||||
writew(vq->desc + (16 * vq->free_head) + 12, VRING_DESC_F_INDIRECT);
|
||||
qtest_writew(qts, vq->desc + (16 * vq->free_head) + 12,
|
||||
VRING_DESC_F_INDIRECT);
|
||||
|
||||
return vq->free_head++; /* Return and increase, in this order */
|
||||
}
|
||||
|
||||
void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head)
|
||||
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
|
||||
uint32_t free_head)
|
||||
{
|
||||
/* vq->avail->idx */
|
||||
uint16_t idx = readw(vq->avail + 2);
|
||||
uint16_t idx = qtest_readw(qts, vq->avail + 2);
|
||||
/* vq->used->flags */
|
||||
uint16_t flags;
|
||||
/* vq->used->avail_event */
|
||||
uint16_t avail_event;
|
||||
|
||||
/* vq->avail->ring[idx % vq->size] */
|
||||
writew(vq->avail + 4 + (2 * (idx % vq->size)), free_head);
|
||||
qtest_writew(qts, vq->avail + 4 + (2 * (idx % vq->size)), free_head);
|
||||
/* vq->avail->idx */
|
||||
writew(vq->avail + 2, idx + 1);
|
||||
qtest_writew(qts, vq->avail + 2, idx + 1);
|
||||
|
||||
/* Must read after idx is updated */
|
||||
flags = readw(vq->avail);
|
||||
avail_event = readw(vq->used + 4 +
|
||||
sizeof(struct vring_used_elem) * vq->size);
|
||||
flags = qtest_readw(qts, vq->avail);
|
||||
avail_event = qtest_readw(qts, vq->used + 4 +
|
||||
sizeof(struct vring_used_elem) * vq->size);
|
||||
|
||||
/* < 1 because we add elements to avail queue one by one */
|
||||
if ((flags & VRING_USED_F_NO_NOTIFY) == 0 &&
|
||||
@@ -317,12 +321,13 @@ void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head)
|
||||
*
|
||||
* Returns: true if an element was ready, false otherwise
|
||||
*/
|
||||
bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len)
|
||||
bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx,
|
||||
uint32_t *len)
|
||||
{
|
||||
uint16_t idx;
|
||||
uint64_t elem_addr;
|
||||
uint64_t elem_addr, addr;
|
||||
|
||||
idx = readw(vq->used + offsetof(struct vring_used, idx));
|
||||
idx = qtest_readw(qts, vq->used + offsetof(struct vring_used, idx));
|
||||
if (idx == vq->last_used_idx) {
|
||||
return false;
|
||||
}
|
||||
@@ -333,23 +338,25 @@ bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len)
|
||||
sizeof(struct vring_used_elem);
|
||||
|
||||
if (desc_idx) {
|
||||
*desc_idx = readl(elem_addr + offsetof(struct vring_used_elem, id));
|
||||
addr = elem_addr + offsetof(struct vring_used_elem, id);
|
||||
*desc_idx = qtest_readl(qts, addr);
|
||||
}
|
||||
|
||||
if (len) {
|
||||
*len = readw(elem_addr + offsetof(struct vring_used_elem, len));
|
||||
addr = elem_addr + offsetof(struct vring_used_elem, len);
|
||||
*len = qtest_readw(qts, addr);
|
||||
}
|
||||
|
||||
vq->last_used_idx++;
|
||||
return true;
|
||||
}
|
||||
|
||||
void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx)
|
||||
void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t idx)
|
||||
{
|
||||
g_assert(vq->event);
|
||||
|
||||
/* vq->avail->used_event */
|
||||
writew(vq->avail + 4 + (2 * vq->size), idx);
|
||||
qtest_writew(qts, vq->avail + 4 + (2 * vq->size), idx);
|
||||
}
|
||||
|
||||
void qvirtio_start_device(QVirtioDevice *vdev)
|
||||
|
||||
+16
-12
@@ -114,11 +114,11 @@ void qvirtio_set_driver_ok(QVirtioDevice *d);
|
||||
|
||||
void qvirtio_wait_queue_isr(QVirtioDevice *d,
|
||||
QVirtQueue *vq, gint64 timeout_us);
|
||||
uint8_t qvirtio_wait_status_byte_no_isr(QVirtioDevice *d,
|
||||
uint8_t qvirtio_wait_status_byte_no_isr(QTestState *qts, QVirtioDevice *d,
|
||||
QVirtQueue *vq,
|
||||
uint64_t addr,
|
||||
gint64 timeout_us);
|
||||
void qvirtio_wait_used_elem(QVirtioDevice *d,
|
||||
void qvirtio_wait_used_elem(QTestState *qts, QVirtioDevice *d,
|
||||
QVirtQueue *vq,
|
||||
uint32_t desc_idx,
|
||||
uint32_t *len,
|
||||
@@ -131,17 +131,21 @@ void qvirtqueue_cleanup(const QVirtioBus *bus, QVirtQueue *vq,
|
||||
|
||||
void qvring_init(QTestState *qts, const QGuestAllocator *alloc, QVirtQueue *vq,
|
||||
uint64_t addr);
|
||||
QVRingIndirectDesc *qvring_indirect_desc_setup(QVirtioDevice *d,
|
||||
QGuestAllocator *alloc, uint16_t elem);
|
||||
void qvring_indirect_desc_add(QVRingIndirectDesc *indirect, uint64_t data,
|
||||
uint32_t len, bool write);
|
||||
uint32_t qvirtqueue_add(QVirtQueue *vq, uint64_t data, uint32_t len, bool write,
|
||||
bool next);
|
||||
uint32_t qvirtqueue_add_indirect(QVirtQueue *vq, QVRingIndirectDesc *indirect);
|
||||
void qvirtqueue_kick(QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head);
|
||||
bool qvirtqueue_get_buf(QVirtQueue *vq, uint32_t *desc_idx, uint32_t *len);
|
||||
QVRingIndirectDesc *qvring_indirect_desc_setup(QTestState *qs, QVirtioDevice *d,
|
||||
QGuestAllocator *alloc,
|
||||
uint16_t elem);
|
||||
void qvring_indirect_desc_add(QTestState *qts, QVRingIndirectDesc *indirect,
|
||||
uint64_t data, uint32_t len, bool write);
|
||||
uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data,
|
||||
uint32_t len, bool write, bool next);
|
||||
uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq,
|
||||
QVRingIndirectDesc *indirect);
|
||||
void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq,
|
||||
uint32_t free_head);
|
||||
bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_idx,
|
||||
uint32_t *len);
|
||||
|
||||
void qvirtqueue_set_used_event(QVirtQueue *vq, uint16_t idx);
|
||||
void qvirtqueue_set_used_event(QTestState *qts, QVirtQueue *vq, uint16_t idx);
|
||||
|
||||
void qvirtio_start_device(QVirtioDevice *vdev);
|
||||
|
||||
|
||||
+13
-24
@@ -1111,13 +1111,13 @@ QDict *qmp(const char *fmt, ...)
|
||||
return response;
|
||||
}
|
||||
|
||||
void qmp_assert_success(const char *fmt, ...)
|
||||
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
QDict *response;
|
||||
|
||||
va_start(ap, fmt);
|
||||
response = qtest_vqmp(global_qtest, fmt, ap);
|
||||
response = qtest_vqmp(qts, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
g_assert(response);
|
||||
@@ -1130,17 +1130,6 @@ void qmp_assert_success(const char *fmt, ...)
|
||||
qobject_unref(response);
|
||||
}
|
||||
|
||||
char *hmp(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = qtest_vhmp(global_qtest, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool qtest_big_endian(QTestState *s)
|
||||
{
|
||||
return s->big_endian;
|
||||
@@ -1200,9 +1189,10 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
|
||||
QObject *qobj;
|
||||
QString *qstr;
|
||||
const char *mname;
|
||||
QTestState *qts;
|
||||
|
||||
qtest_start("-machine none");
|
||||
response = qmp("{ 'execute': 'query-machines' }");
|
||||
qts = qtest_init("-machine none");
|
||||
response = qtest_qmp(qts, "{ 'execute': 'query-machines' }");
|
||||
g_assert(response);
|
||||
list = qdict_get_qlist(response, "return");
|
||||
g_assert(list);
|
||||
@@ -1220,7 +1210,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
|
||||
}
|
||||
}
|
||||
|
||||
qtest_end();
|
||||
qtest_quit(qts);
|
||||
qobject_unref(response);
|
||||
}
|
||||
|
||||
@@ -1256,7 +1246,7 @@ QDict *qtest_qmp_receive_success(QTestState *s,
|
||||
/*
|
||||
* Generic hot-plugging test via the device_add QMP command.
|
||||
*/
|
||||
void qtest_qmp_device_add(const char *driver, const char *id,
|
||||
void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
QDict *args, *response;
|
||||
@@ -1270,7 +1260,8 @@ void qtest_qmp_device_add(const char *driver, const char *id,
|
||||
qdict_put_str(args, "driver", driver);
|
||||
qdict_put_str(args, "id", id);
|
||||
|
||||
response = qmp("{'execute': 'device_add', 'arguments': %p}", args);
|
||||
response = qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}",
|
||||
args);
|
||||
g_assert(response);
|
||||
g_assert(!qdict_haskey(response, "event")); /* We don't expect any events */
|
||||
g_assert(!qdict_haskey(response, "error"));
|
||||
@@ -1303,19 +1294,17 @@ static void device_deleted_cb(void *opaque, const char *name, QDict *data)
|
||||
*
|
||||
* But the order of arrival may vary - so we've got to detect both.
|
||||
*/
|
||||
void qtest_qmp_device_del(const char *id)
|
||||
void qtest_qmp_device_del(QTestState *qts, const char *id)
|
||||
{
|
||||
bool got_event = false;
|
||||
QDict *rsp;
|
||||
|
||||
qtest_qmp_send(global_qtest,
|
||||
"{'execute': 'device_del', 'arguments': {'id': %s}}",
|
||||
qtest_qmp_send(qts, "{'execute': 'device_del', 'arguments': {'id': %s}}",
|
||||
id);
|
||||
rsp = qtest_qmp_receive_success(global_qtest, device_deleted_cb,
|
||||
&got_event);
|
||||
rsp = qtest_qmp_receive_success(qts, device_deleted_cb, &got_event);
|
||||
qobject_unref(rsp);
|
||||
if (!got_event) {
|
||||
rsp = qtest_qmp_receive(global_qtest);
|
||||
rsp = qtest_qmp_receive(qts);
|
||||
g_assert_cmpstr(qdict_get_try_str(rsp, "event"),
|
||||
==, "DEVICE_DELETED");
|
||||
qobject_unref(rsp);
|
||||
|
||||
+9
-15
@@ -666,7 +666,8 @@ static inline void qtest_end(void)
|
||||
QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
||||
|
||||
/**
|
||||
* qmp_assert_success:
|
||||
* qtest_qmp_assert_success:
|
||||
* @qts: QTestState instance to operate on
|
||||
* @fmt...: QMP message to send to qemu, formatted like
|
||||
* qobject_from_jsonf_nofail(). See parse_escape() for what's
|
||||
* supported after '%'.
|
||||
@@ -674,7 +675,8 @@ QDict *qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
||||
* Sends a QMP message to QEMU and asserts that a 'return' key is present in
|
||||
* the response.
|
||||
*/
|
||||
void qmp_assert_success(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
||||
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
|
||||
GCC_FMT_ATTR(2, 3);
|
||||
|
||||
/*
|
||||
* qmp_eventwait:
|
||||
@@ -687,16 +689,6 @@ static inline void qmp_eventwait(const char *event)
|
||||
return qtest_qmp_eventwait(global_qtest, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* hmp:
|
||||
* @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
|
||||
*
|
||||
* Send HMP command to QEMU via QMP's human-monitor-command.
|
||||
*
|
||||
* Returns: the command's output. The caller should g_free() it.
|
||||
*/
|
||||
char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
|
||||
|
||||
/**
|
||||
* get_irq:
|
||||
* @num: Interrupt to observe.
|
||||
@@ -956,6 +948,7 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
|
||||
|
||||
/**
|
||||
* qtest_qmp_device_add:
|
||||
* @qts: QTestState instance to operate on
|
||||
* @driver: Name of the device that should be added
|
||||
* @id: Identification string
|
||||
* @fmt...: QMP message to send to qemu, formatted like
|
||||
@@ -964,16 +957,17 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
|
||||
*
|
||||
* Generic hot-plugging test via the device_add QMP command.
|
||||
*/
|
||||
void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
|
||||
...) GCC_FMT_ATTR(3, 4);
|
||||
void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
|
||||
const char *fmt, ...) GCC_FMT_ATTR(4, 5);
|
||||
|
||||
/**
|
||||
* qtest_qmp_device_del:
|
||||
* @qts: QTestState instance to operate on
|
||||
* @id: Identification string
|
||||
*
|
||||
* Generic hot-unplugging test via the device_del QMP command.
|
||||
*/
|
||||
void qtest_qmp_device_del(const char *id);
|
||||
void qtest_qmp_device_del(QTestState *qts, const char *id);
|
||||
|
||||
/**
|
||||
* qmp_rsp_is_err:
|
||||
|
||||
@@ -75,7 +75,8 @@ static void megasas_register_nodes(void)
|
||||
{
|
||||
QOSGraphEdgeOptions opts = {
|
||||
.extra_device_opts = "addr=04.0,id=scsi0",
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw",
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
|
||||
"file.read-zeroes=on,format=raw",
|
||||
.after_cmd_line = "-device scsi-hd,bus=scsi0.0,drive=drv0",
|
||||
};
|
||||
|
||||
|
||||
+2
-1
@@ -70,7 +70,8 @@ static void nvme_register_nodes(void)
|
||||
{
|
||||
QOSGraphEdgeOptions opts = {
|
||||
.extra_device_opts = "addr=04.0,drive=drv0,serial=foo",
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw",
|
||||
.before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
|
||||
"file.read-zeroes=on,format=raw",
|
||||
};
|
||||
|
||||
add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
|
||||
|
||||
+1
-1
@@ -187,7 +187,7 @@ static void send_cmd_that_blocks(QTestState *s, const char *id)
|
||||
" 'arguments': {"
|
||||
" 'driver': 'blkdebug', 'node-name': %s,"
|
||||
" 'config': %s,"
|
||||
" 'image': { 'driver': 'null-co' } } }",
|
||||
" 'image': { 'driver': 'null-co', 'read-zeroes': true } } }",
|
||||
id, id, fifo_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "qemu/main-loop.h"
|
||||
#include "block/blockjob_int.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
|
||||
typedef struct {
|
||||
BlockJob common;
|
||||
@@ -96,7 +97,9 @@ static BlockJob *test_block_job_start(unsigned int iterations,
|
||||
|
||||
data = g_new0(TestBlockJobCBData, 1);
|
||||
|
||||
bs = bdrv_open("null-co://", NULL, NULL, 0, &error_abort);
|
||||
QDict *opt = qdict_new();
|
||||
qdict_put_str(opt, "file.read-zeroes", "on");
|
||||
bs = bdrv_open("null-co://", NULL, opt, 0, &error_abort);
|
||||
g_assert_nonnull(bs);
|
||||
|
||||
snprintf(job_id, sizeof(job_id), "job%u", counter++);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user