qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE


From: Juan Quintela
Subject: [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE
Date: Mon, 7 Apr 2014 05:21:37 +0200

This is trick, to use devices that haven't been converted inside
vmstate state.  It was already used on the "wild", so create a macro
and convert the users.

Signed-off-by: Juan Quintela <address@hidden>
---
 hw/pci/msix.c               | 10 +---------
 hw/scsi/scsi-bus.c          | 10 +---------
 hw/usb/redirect.c           | 30 +++---------------------------
 include/migration/vmstate.h | 15 +++++++++++++++
 4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index 5c49bfc..93258f0 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -590,15 +590,7 @@ static VMStateInfo vmstate_info_msix = {
 const VMStateDescription vmstate_msix = {
     .name = "msix",
     .fields = (VMStateField[]) {
-        {
-            .name         = "msix",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,   /* ouch */
-            .info         = &vmstate_info_msix,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("msix", vmstate_info_msix),
         VMSTATE_END_OF_LIST()
     }
 };
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index a137c98..e11b16d 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1934,15 +1934,7 @@ const VMStateDescription vmstate_scsi_device = {
         VMSTATE_BOOL(sense_is_ua, SCSIDevice),
         VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice, 0, SCSI_SENSE_BUF_SIZE_OLD),
         VMSTATE_UINT32(sense_len, SCSIDevice),
-        {
-            .name         = "requests",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,   /* ouch */
-            .info         = &vmstate_info_scsi_requests,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("requests", vmstate_info_scsi_requests),
         VMSTATE_END_OF_LIST()
     },
     .subsections = (VMStateSubsection []) {
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 24e7e99..255a92b 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -2180,15 +2180,7 @@ static const VMStateDescription usbredir_ep_vmstate = {
         VMSTATE_UINT8(interrupt_error, struct endp_data),
         VMSTATE_UINT8(bufpq_prefilled, struct endp_data),
         VMSTATE_UINT8(bufpq_dropping_packets, struct endp_data),
-        {
-            .name         = "bufpq",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_ep_bufpq_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("bufpq", usbredir_ep_bufpq_vmstate_info),
         VMSTATE_INT32(bufpq_target_size, struct endp_data),
         VMSTATE_END_OF_LIST()
     },
@@ -2248,15 +2240,7 @@ static const VMStateDescription 
usbredir_ep_packet_id_queue_vmstate = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        {
-            .name         = "queue",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_ep_packet_id_q_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("queue", 
usbredir_ep_packet_id_q_vmstate_info),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -2312,15 +2296,7 @@ static const VMStateDescription usbredir_vmstate = {
     .fields = (VMStateField[]) {
         VMSTATE_USB_DEVICE(dev, USBRedirDevice),
         VMSTATE_TIMER(attach_timer, USBRedirDevice),
-        {
-            .name         = "parser",
-            .version_id   = 0,
-            .field_exists = NULL,
-            .size         = 0,
-            .info         = &usbredir_parser_vmstate_info,
-            .flags        = VMS_SINGLE,
-            .offset       = 0,
-        },
+        VMSTATE_OPENCODED_UNSAFE("parser", usbredir_parser_vmstate_info),
         VMSTATE_STRUCT_ARRAY(endpoint, USBRedirDevice, MAX_ENDPOINTS,
                              usbredir_ep_vmstate, struct endp_data),
         VMSTATE_STRUCT(cancelled, USBRedirDevice,
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 7418c64..d695244 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -218,6 +218,21 @@ extern const VMStateInfo vmstate_info_bitmap;
     .offset       = offsetof(_state, _field),                        \
 }

+/*
+ *  We have a field that is opencoded in old style, but we want to use
+ *  it with VMSTATE.  Well, just create a vmstate_info struct, and a
+ *  name.  VMSTATE don't know what is behind it, it is unsafe,
+ *  anything can happens.
+ */
+
+#define VMSTATE_OPENCODED_UNSAFE(_name, _info) {                     \
+    .name         = (_name),                                         \
+    .info         = &(_info),                                        \
+    .size         = 0,                                               \
+    .flags        = VMS_SINGLE,                                      \
+    .offset       = 0,                                               \
+}
+
 #define VMSTATE_2DARRAY(_field, _state, _n1, _n2, _test, _info, _type) { \
     .name         = (stringify(_field)),                                      \
     .field_exists = (_test),                                                  \
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]