Improve vmstate_vmbus_dev handling
cover Improve vmstate_vmbus_dev handling
I accidentally came accross vmstate_vmbus_dev and noticed that it is currently not used at all ... wire it up and make it static, since it is only used in one file.
Thomas Huth (2):
hw/hyperv/vmbus: Wire up vmstate_vmbus_dev
hw/hyperv/vmbus: Make vmstate_vmbus_dev static
hw/hyperv/vmbus.c | 29 +++++++++++++++-------------- include/hw/hyperv/vmbus.h | 3 --- 2 files changed, 15 insertions(+), 17 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/2 hw/hyperv/vmbus: Wire up vmstate_vmbus_dev
The vmstate_vmbus_dev structure is currently completely unused. Looks like this has been forgotten to get wired up in the vmbus_dev_class_init() function.
--- hw/hyperv/vmbus.c | 1 + 1 file changed, 1 insertion(+)
hw/hyperv/vmbus.c +1 -0
@@ -2445,6 +2445,7 @@ static void vmbus_dev_class_init(ObjectClass *klass, void *data) kdev->realize = vmbus_dev_realize; kdev->unrealize = vmbus_dev_unrealize; kdev->reset = vmbus_dev_reset; + kdev->vmsd = &vmstate_vmbus_dev; } static Property vmbus_dev_instanceid =
Signature · 1 line
2.27.0
PATCH 2/2 hw/hyperv/vmbus: Make vmstate_vmbus_dev static
In reply to Thomas Huthvmstate_vmbus_dev is only used in vmbus.c, no need to export this via the vmbus.h header file.
--- hw/hyperv/vmbus.c | 28 ++++++++++++++-------------- include/hw/hyperv/vmbus.h | 3 --- 2 files changed, 14 insertions(+), 17 deletions(-)
hw/hyperv/vmbus.c +14 -14
@@ -2438,6 +2438,20 @@ static void vmbus_dev_unrealize(DeviceState *dev)free_channels (vdev); } +static const VMStateDescription vmstate_vmbus_dev = { + .name =TYPE_VMBUS_DEVICE , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_UINT8_ARRAY (instanceid.data, VMBusDevice,16 ), +VMSTATE_UINT16 (num_channels, VMBusDevice), +VMSTATE_STRUCT_VARRAY_POINTER_UINT16 (channels, VMBusDevice, + num_channels, vmstate_channel, + VMBusChannel), +VMSTATE_END_OF_LIST () + } +}; +static void vmbus_dev_class_init (ObjectClass *klass,void *data) {DeviceClass *kdev =DEVICE_CLASS (klass);
@@ -2464,20 +2478,6 @@ static void vmbus_dev_instance_init(Object *obj) } } -const VMStateDescription vmstate_vmbus_dev = { - .name =TYPE_VMBUS_DEVICE , - .version_id =0 , - .minimum_version_id =0 , - .fields = (VMStateField []) { -VMSTATE_UINT8_ARRAY (instanceid.data, VMBusDevice,16 ), -VMSTATE_UINT16 (num_channels, VMBusDevice), -VMSTATE_STRUCT_VARRAY_POINTER_UINT16 (channels, VMBusDevice, - num_channels, vmstate_channel, - VMBusChannel), -VMSTATE_END_OF_LIST () - } -}; -/* vmbus generic device base */ static const TypeInfo vmbus_dev_type_info = { .name =TYPE_VMBUS_DEVICE ,
include/hw/hyperv/vmbus.h +0 -3
@@ -13,7 +13,6 @@#include "sysemu/sysemu.h" #include "sysemu/dma.h" #include "hw/qdev-core.h" -#include "migration/vmstate.h" #include "hw/hyperv/vmbus-proto.h" #include "qemu/uuid.h" #include "qom/object.h"
@@ -85,8 +84,6 @@ struct VMBusDevice {AddressSpace *dma_as; }; -extern const VMStateDescription vmstate_vmbus_dev; -/* * A unit of work parsed out of a message in the receive (i.e. guest->host) * ring buffer of a channel. It's supposed to be subclassed (through
Signature · 1 line
2.27.0
Hi Thomas,
Quoted 4 lines · Thomas Huth
I accidentally came accross
vmstate_vmbus_devand noticed that it is currently not used at all ... wire it up and make it static, since it is only used in one file.
Quoted 8 lines
Thomas Huth (2):
hw/hyperv/vmbus: Wire upvmstate_vmbus_dev
hw/hyperv/vmbus: Makevmstate_vmbus_devstatichw/hyperv/vmbus.c | 29 +++++++++++++++-------------- include/hw/hyperv/vmbus.h | 3 --- 2 files changed, 15 insertions(+), 17 deletions(-)
I think the idea is to embed vmstate_vmbus_dev into a child device VMStateDescription using VMSTATE_STRUCT() - since particular VMBus devices aren't merged yet there are currently no users of it.
This is similar how USB devices VMState is organized - see vmstate_usb_device and VMSTATE_USB_DEVICE() macro.
Thanks,
Maciej
Quoted 11 lines · Maciej S. Szmigiero
Hi Thomas,
Quoted 8 lines · Thomas Huth
I accidentally came accross
vmstate_vmbus_devand noticed that it is currently not used at all ... wire it up and make it static, since it is only used in one file.Thomas Huth (2):
hw/hyperv/vmbus: Wire upvmstate_vmbus_dev
hw/hyperv/vmbus: Makevmstate_vmbus_devstatic
Quoted 8 lines
Quoted 4 lines
hw/hyperv/vmbus.c | 29 +++++++++++++++--------------
include/hw/hyperv/vmbus.h| 3 ---2 files changed, 15 insertions(+), 17 deletions(-)I think the idea is to embed
vmstate_vmbus_devinto a child device VMStateDescription usingVMSTATE_STRUCT()- since particular VMBus devices aren't merged yet there are currently no users of it.
Ok, then never mind. But some comments in the source code would be really helpful - in the current shape, it simply looks like an oversight...
Thomas