From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0A6-00084h-MH for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:24:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WX0A0-0000Ca-8h for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:23:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9216) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WX0A0-0000CT-0a for qemu-devel@nongnu.org; Sun, 06 Apr 2014 23:23:48 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s373Nlcj002691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Apr 2014 23:23:47 -0400 From: Juan Quintela Date: Mon, 7 Apr 2014 05:21:37 +0200 Message-Id: <1396840915-10384-80-git-send-email-quintela@redhat.com> In-Reply-To: <1396840915-10384-1-git-send-email-quintela@redhat.com> References: <1396840915-10384-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 79/97] vmstate: Create VMSTATE_OPENCODED_UNSAFE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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