Skip to content

Commit 08a0aee

Browse files
author
Juan Quintela
committed
migration: Split qemu-file.h
Split the file into public and internal interfaces. I have to rename the external one because we can't have two include files with the same name in the same directory. Build system gets confused. The only exported functions are the ones that handle basic types. Signed-off-by: Juan Quintela <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]>
1 parent 107da9a commit 08a0aee

20 files changed

+186
-169
lines changed

hw/i2c/i2c-ddc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "qemu/osdep.h"
20+
#include "qemu-common.h"
2021
#include "qemu/log.h"
2122
#include "hw/i2c/i2c.h"
2223
#include "hw/i2c/i2c-ddc.h"

hw/intc/s390_flic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "qemu/osdep.h"
1414
#include "qemu/error-report.h"
1515
#include "hw/sysbus.h"
16-
#include "migration/qemu-file.h"
1716
#include "hw/s390x/s390_flic.h"
1817
#include "trace.h"
1918
#include "hw/qdev.h"

hw/intc/s390_flic_kvm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "qemu/error-report.h"
1818
#include "hw/sysbus.h"
1919
#include "sysemu/kvm.h"
20-
#include "migration/qemu-file.h"
2120
#include "hw/s390x/s390_flic.h"
2221
#include "hw/s390x/adapter.h"
2322
#include "trace.h"

hw/s390x/s390-skeys.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "qemu/osdep.h"
1313
#include "hw/boards.h"
1414
#include "qmp-commands.h"
15-
#include "migration/qemu-file.h"
1615
#include "hw/s390x/storage-keys.h"
1716
#include "qemu/error-report.h"
1817
#include "sysemu/kvm.h"

include/hw/hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "exec/memory.h"
1212
#include "hw/irq.h"
1313
#include "migration/vmstate.h"
14-
#include "migration/qemu-file.h"
14+
#include "migration/qemu-file-types.h"
1515
#include "qemu/module.h"
1616
#include "sysemu/reset.h"
1717

include/migration/qemu-file-types.h

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
* QEMU System Emulator
3+
*
4+
* Copyright (c) 2003-2008 Fabrice Bellard
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef QEMU_FILE_H
26+
#define QEMU_FILE_H
27+
28+
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, size_t size);
29+
void qemu_put_byte(QEMUFile *f, int v);
30+
31+
#define qemu_put_sbyte qemu_put_byte
32+
33+
void qemu_put_be16(QEMUFile *f, unsigned int v);
34+
void qemu_put_be32(QEMUFile *f, unsigned int v);
35+
void qemu_put_be64(QEMUFile *f, uint64_t v);
36+
size_t qemu_get_buffer(QEMUFile *f, uint8_t *buf, size_t size);
37+
38+
int qemu_get_byte(QEMUFile *f);
39+
40+
static inline unsigned int qemu_get_ubyte(QEMUFile *f)
41+
{
42+
return (unsigned int)qemu_get_byte(f);
43+
}
44+
45+
#define qemu_get_sbyte qemu_get_byte
46+
47+
unsigned int qemu_get_be16(QEMUFile *f);
48+
unsigned int qemu_get_be32(QEMUFile *f);
49+
uint64_t qemu_get_be64(QEMUFile *f);
50+
51+
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
52+
{
53+
qemu_put_be64(f, *pv);
54+
}
55+
56+
static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
57+
{
58+
qemu_put_be32(f, *pv);
59+
}
60+
61+
static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
62+
{
63+
qemu_put_be16(f, *pv);
64+
}
65+
66+
static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
67+
{
68+
qemu_put_byte(f, *pv);
69+
}
70+
71+
static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
72+
{
73+
*pv = qemu_get_be64(f);
74+
}
75+
76+
static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
77+
{
78+
*pv = qemu_get_be32(f);
79+
}
80+
81+
static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
82+
{
83+
*pv = qemu_get_be16(f);
84+
}
85+
86+
static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
87+
{
88+
*pv = qemu_get_byte(f);
89+
}
90+
91+
/* Signed versions for type safety */
92+
static inline void qemu_put_sbe16(QEMUFile *f, int v)
93+
{
94+
qemu_put_be16(f, (unsigned int)v);
95+
}
96+
97+
static inline void qemu_put_sbe32(QEMUFile *f, int v)
98+
{
99+
qemu_put_be32(f, (unsigned int)v);
100+
}
101+
102+
static inline void qemu_put_sbe64(QEMUFile *f, int64_t v)
103+
{
104+
qemu_put_be64(f, (uint64_t)v);
105+
}
106+
107+
static inline int qemu_get_sbe16(QEMUFile *f)
108+
{
109+
return (int)qemu_get_be16(f);
110+
}
111+
112+
static inline int qemu_get_sbe32(QEMUFile *f)
113+
{
114+
return (int)qemu_get_be32(f);
115+
}
116+
117+
static inline int64_t qemu_get_sbe64(QEMUFile *f)
118+
{
119+
return (int64_t)qemu_get_be64(f);
120+
}
121+
122+
static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv)
123+
{
124+
qemu_put_8s(f, (const uint8_t *)pv);
125+
}
126+
127+
static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv)
128+
{
129+
qemu_put_be16s(f, (const uint16_t *)pv);
130+
}
131+
132+
static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv)
133+
{
134+
qemu_put_be32s(f, (const uint32_t *)pv);
135+
}
136+
137+
static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv)
138+
{
139+
qemu_put_be64s(f, (const uint64_t *)pv);
140+
}
141+
142+
static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv)
143+
{
144+
qemu_get_8s(f, (uint8_t *)pv);
145+
}
146+
147+
static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv)
148+
{
149+
qemu_get_be16s(f, (uint16_t *)pv);
150+
}
151+
152+
static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv)
153+
{
154+
qemu_get_be32s(f, (uint32_t *)pv);
155+
}
156+
157+
static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
158+
{
159+
qemu_get_be64s(f, (uint64_t *)pv);
160+
}
161+
162+
int qemu_file_rate_limit(QEMUFile *f);
163+
164+
#endif

migration/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "migration/block.h"
2727
#include "migration/migration.h"
2828
#include "sysemu/blockdev.h"
29-
#include "migration/qemu-file.h"
29+
#include "qemu-file.h"
3030
#include "migration/vmstate.h"
3131
#include "sysemu/block-backend.h"
3232

migration/colo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "sysemu/sysemu.h"
1616
#include "qemu-file-channel.h"
1717
#include "migration/migration.h"
18-
#include "migration/qemu-file.h"
18+
#include "qemu-file.h"
1919
#include "savevm.h"
2020
#include "migration/colo.h"
2121
#include "migration/block.h"

migration/migration.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "migration/migration.h"
2222
#include "savevm.h"
2323
#include "qemu-file-channel.h"
24-
#include "migration/qemu-file.h"
24+
#include "qemu-file.h"
2525
#include "migration/vmstate.h"
2626
#include "sysemu/sysemu.h"
2727
#include "block/block.h"

migration/postcopy-ram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "qemu-common.h"
2222
#include "exec/target_page.h"
2323
#include "migration/migration.h"
24-
#include "migration/qemu-file.h"
24+
#include "qemu-file.h"
2525
#include "savevm.h"
2626
#include "postcopy-ram.h"
2727
#include "sysemu/sysemu.h"

0 commit comments

Comments
 (0)