mirror of https://github.com/xemu-project/xemu.git
tests: fix vhost-user-test leaks
Spotted by ASAN. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
fb6faea888
commit
0c0eb30260
|
@ -27,6 +27,12 @@ typedef struct QVirtioPCIForeachData {
|
||||||
void *user_data;
|
void *user_data;
|
||||||
} QVirtioPCIForeachData;
|
} QVirtioPCIForeachData;
|
||||||
|
|
||||||
|
void qvirtio_pci_device_free(QVirtioPCIDevice *dev)
|
||||||
|
{
|
||||||
|
g_free(dev->pdev);
|
||||||
|
g_free(dev);
|
||||||
|
}
|
||||||
|
|
||||||
static QVirtioPCIDevice *qpcidevice_to_qvirtiodevice(QPCIDevice *pdev)
|
static QVirtioPCIDevice *qpcidevice_to_qvirtiodevice(QPCIDevice *pdev)
|
||||||
{
|
{
|
||||||
QVirtioPCIDevice *vpcidev;
|
QVirtioPCIDevice *vpcidev;
|
||||||
|
|
|
@ -34,6 +34,8 @@ extern const QVirtioBus qvirtio_pci;
|
||||||
void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,
|
void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type,
|
||||||
void (*func)(QVirtioDevice *d, void *data), void *data);
|
void (*func)(QVirtioDevice *d, void *data), void *data);
|
||||||
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type);
|
QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type);
|
||||||
|
void qvirtio_pci_device_free(QVirtioPCIDevice *dev);
|
||||||
|
|
||||||
void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
|
void qvirtio_pci_device_enable(QVirtioPCIDevice *d);
|
||||||
void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
|
void qvirtio_pci_device_disable(QVirtioPCIDevice *d);
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct TestServer {
|
typedef struct TestServer {
|
||||||
|
QPCIBus *bus;
|
||||||
gchar *socket_path;
|
gchar *socket_path;
|
||||||
gchar *mig_path;
|
gchar *mig_path;
|
||||||
gchar *chr_name;
|
gchar *chr_name;
|
||||||
|
@ -160,14 +161,13 @@ static const char *root;
|
||||||
|
|
||||||
static void init_virtio_dev(TestServer *s)
|
static void init_virtio_dev(TestServer *s)
|
||||||
{
|
{
|
||||||
QPCIBus *bus;
|
|
||||||
QVirtioPCIDevice *dev;
|
QVirtioPCIDevice *dev;
|
||||||
uint32_t features;
|
uint32_t features;
|
||||||
|
|
||||||
bus = qpci_init_pc(NULL);
|
s->bus = qpci_init_pc(NULL);
|
||||||
g_assert_nonnull(bus);
|
g_assert_nonnull(s->bus);
|
||||||
|
|
||||||
dev = qvirtio_pci_device_find(bus, VIRTIO_ID_NET);
|
dev = qvirtio_pci_device_find(s->bus, VIRTIO_ID_NET);
|
||||||
g_assert_nonnull(dev);
|
g_assert_nonnull(dev);
|
||||||
|
|
||||||
qvirtio_pci_device_enable(dev);
|
qvirtio_pci_device_enable(dev);
|
||||||
|
@ -180,6 +180,7 @@ static void init_virtio_dev(TestServer *s)
|
||||||
qvirtio_set_features(&dev->vdev, features);
|
qvirtio_set_features(&dev->vdev, features);
|
||||||
|
|
||||||
qvirtio_set_driver_ok(&dev->vdev);
|
qvirtio_set_driver_ok(&dev->vdev);
|
||||||
|
qvirtio_pci_device_free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wait_for_fds(TestServer *s)
|
static void wait_for_fds(TestServer *s)
|
||||||
|
@ -507,6 +508,8 @@ static gboolean _test_server_free(TestServer *server)
|
||||||
g_free(server->mig_path);
|
g_free(server->mig_path);
|
||||||
|
|
||||||
g_free(server->chr_name);
|
g_free(server->chr_name);
|
||||||
|
qpci_free_pc(server->bus);
|
||||||
|
|
||||||
g_free(server);
|
g_free(server);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue