@@ -66,4 +66,5 @@ void usb_test_hotplug(const char *hcd_id, const int port,
g_assert(response);
g_assert(qdict_haskey(response, "event"));
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
+ QDECREF(response);
}
@@ -397,7 +397,8 @@ static void test_migrate(void)
usleep(10 * 1000);
} while (dest_byte_a == dest_byte_b);
- qmp("{ 'execute' : 'stop'}");
+ rsp = qmp("{ 'execute' : 'stop'}");
+ QDECREF(rsp);
/* With it stopped, check nothing changes */
qtest_memread(to, start_address, &dest_byte_c, 1);
sleep(1);
@@ -27,6 +27,7 @@ static void test_panic(void)
data = qdict_get_qdict(response, "data");
g_assert(qdict_haskey(data, "action"));
g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
+ QDECREF(response);
}
int main(int argc, char **argv)
@@ -26,6 +26,7 @@ static void test_mirror(void)
char send_buf[] = "Hello! filter-mirror~";
char sock_path[] = "filter-mirror.XXXXXX";
char *recv_buf;
+ QDict *resp;
uint32_t size = sizeof(send_buf);
size = htonl(size);
@@ -57,7 +58,8 @@ static void test_mirror(void)
};
/* send a qmp command to guarantee that 'connected' is setting to true. */
- qmp("{ 'execute' : 'query-status'}");
+ resp = qmp("{ 'execute' : 'query-status'}");
+ QDECREF(resp);
ret = iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock[0]);
@@ -69,6 +69,7 @@ static void test_redirector_tx(void)
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
+ QDict *resp;
uint32_t size = sizeof(send_buf);
size = htonl(size);
@@ -99,7 +100,8 @@ static void test_redirector_tx(void)
g_assert_cmpint(recv_sock, !=, -1);
/* send a qmp command to guarantee that 'connected' is setting to true. */
- qmp("{ 'execute' : 'query-status'}");
+ resp = qmp("{ 'execute' : 'query-status'}");
+ QDECREF(resp);
struct iovec iov[] = {
{
@@ -145,6 +147,7 @@ static void test_redirector_rx(void)
char sock_path0[] = "filter-redirector0.XXXXXX";
char sock_path1[] = "filter-redirector1.XXXXXX";
char *recv_buf;
+ QDict *resp;
uint32_t size = sizeof(send_buf);
size = htonl(size);
@@ -184,7 +187,8 @@ static void test_redirector_rx(void)
send_sock = unix_connect(sock_path1, NULL);
g_assert_cmpint(send_sock, !=, -1);
/* send a qmp command to guarantee that 'connected' is setting to true. */
- qmp("{ 'execute' : 'query-status'}");
+ resp = qmp("{ 'execute' : 'query-status'}");
+ QDECREF(resp);
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
@@ -416,6 +416,7 @@ static void pci_config(void)
int n_size = TEST_IMAGE_SIZE / 2;
void *addr;
uint64_t capacity;
+ QDict *resp;
bus = pci_test_start();
@@ -430,8 +431,10 @@ static void pci_config(void)
qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
- qmp("{ 'execute': 'block_resize', 'arguments': { 'device': 'drive0', "
- " 'size': %d } }", n_size);
+ resp = qmp("{ 'execute': 'block_resize', 'arguments': "
+ "{ 'device': 'drive0', 'size': %d } }", n_size);
+ QDECREF(resp);
+
qvirtio_wait_config_isr(&qvirtio_pci, &dev->vdev, QVIRTIO_BLK_TIMEOUT_US);
capacity = qvirtio_config_readq(&qvirtio_pci, &dev->vdev,
@@ -459,6 +462,7 @@ static void pci_msix(void)
uint32_t free_head;
uint8_t status;
char *data;
+ QDict *resp;
bus = pci_test_start();
alloc = pc_alloc_init();
@@ -488,8 +492,9 @@ static void pci_msix(void)
qvirtio_set_driver_ok(&qvirtio_pci, &dev->vdev);
- qmp("{ 'execute': 'block_resize', 'arguments': { 'device': 'drive0', "
- " 'size': %d } }", n_size);
+ resp = qmp("{ 'execute': 'block_resize', 'arguments': "
+ "{ 'device': 'drive0', 'size': %d } }", n_size);
+ QDECREF(resp);
qvirtio_wait_config_isr(&qvirtio_pci, &dev->vdev, QVIRTIO_BLK_TIMEOUT_US);
@@ -717,6 +722,7 @@ static void mmio_basic(void)
QGuestAllocator *alloc;
int n_size = TEST_IMAGE_SIZE / 2;
uint64_t capacity;
+ QDict *resp;
arm_test_start();
@@ -734,8 +740,9 @@ static void mmio_basic(void)
test_basic(&qvirtio_mmio, &dev->vdev, alloc, vq,
QVIRTIO_MMIO_DEVICE_SPECIFIC);
- qmp("{ 'execute': 'block_resize', 'arguments': { 'device': 'drive0', "
- " 'size': %d } }", n_size);
+ resp = qmp("{ 'execute': 'block_resize', 'arguments': "
+ "{ 'device': 'drive0', 'size': %d } }", n_size);
+ QDECREF(resp);
qvirtio_wait_queue_isr(&qvirtio_mmio, &dev->vdev, vq,
QVIRTIO_BLK_TIMEOUT_US);
@@ -159,13 +159,15 @@ static void rx_stop_cont_test(const QVirtioBus *bus, QVirtioDevice *dev,
},
};
int ret;
+ QDict *resp;
req_addr = guest_alloc(alloc, 64);
free_head = qvirtqueue_add(vq, req_addr, 64, true, false);
qvirtqueue_kick(bus, dev, vq, free_head);
- qmp("{ 'execute' : 'stop'}");
+ resp = qmp("{ 'execute' : 'stop'}");
+ QDECREF(resp);
ret = iov_send(socket, iov, 2, 0, sizeof(len) + sizeof(test));
g_assert_cmpint(ret, ==, sizeof(test) + sizeof(len));
@@ -173,8 +175,10 @@ static void rx_stop_cont_test(const QVirtioBus *bus, QVirtioDevice *dev,
/* We could check the status, but this command is more importantly to
* ensure the packet data gets queued in QEMU, before we do 'cont'.
*/
- qmp("{ 'execute' : 'query-status'}");
- qmp("{ 'execute' : 'cont'}");
+ resp = qmp("{ 'execute' : 'query-status'}");
+ QDECREF(resp);
+ resp = qmp("{ 'execute' : 'cont'}");
+ QDECREF(resp);
qvirtio_wait_queue_isr(bus, dev, vq, QVIRTIO_NET_TIMEOUT_US);
memread(req_addr + VNET_HDR_SIZE, buffer, sizeof(test));