[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Qemu-block] [PATCH v6 16/29] libqos: Use explicit QTes
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [Qemu-block] [PATCH v6 16/29] libqos: Use explicit QTestState for virtio operations |
Date: |
Tue, 5 Sep 2017 14:43:41 +0200 |
> typedef struct QVirtioDevice {
> const QVirtioBus *bus;
> + QTestState *qts;
> /* Device type */
> uint16_t device_type;
> } QVirtioDevice;
> @@ -35,12 +36,14 @@ typedef struct QVirtQueue {
> uint16_t last_used_idx;
> bool indirect;
> bool event;
> + QTestState *qts;
> } QVirtQueue;
>
> typedef struct QVRingIndirectDesc {
> uint64_t desc; /* This points to an array fo struct vring_desc */
> uint16_t index;
> uint16_t elem;
> + QTestState *qts;
> } QVRingIndirectDesc;
Adding QTestState to QVRingIndirectDesc and QVirtQueue sounds somewhat
ugly to me. I think they should either rather have a pointer to the
associated QVirtioDevice, or the functions where this is needed
(qvring_init() for example) should get a "QTestState *" parameter instead.
I agree with Thomas and even extend it to QVirtioDevice. If there is a
has-a hierarchy between libqos objects, only the topmost one (such as the
virtio mmio bus device, and the PCI host bridge---or possibly even the
machine object exclusively) should have a QTestState. Everyone else can
access it implicitly through operations on its bus.
Test code on the other hand can use global_qtest implicitly when they
prepare/read buffers that the devices do DMA from/to.
Paolo
Just my 0.02 €.
Thomas
[Qemu-devel] [PATCH v6 26/29] fw_cfg-test: Drop dependence on global_qtest, Eric Blake, 2017/09/01
[Qemu-devel] [PATCH v6 28/29] libqtest: Remove qtest_start() and qtest_end() shortcuts, Eric Blake, 2017/09/01