Commit faf07963cb03f98d52ca1f7fde7482a3cb309bcc

Authored by pbrook
1 parent 28c5af54

Split block API from vl.h.

Remove QEMU_TOOL. Replace with QEMU_IMG and NEED_CPU_H.
Avoid linking qemu-img against whole system emulatior.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3578 c046a42c-6fe2-441c-8c8c-71466251a162
Makefile
@@ -13,7 +13,6 @@ BASE_LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS) @@ -13,7 +13,6 @@ BASE_LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)
13 13
14 CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP 14 CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP
15 CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 15 CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
16 -CPPFLAGS += -DQEMU_TOOL  
17 LIBS= 16 LIBS=
18 ifdef CONFIG_STATIC 17 ifdef CONFIG_STATIC
19 BASE_LDFLAGS += -static 18 BASE_LDFLAGS += -static
@@ -33,15 +32,23 @@ subdir-%: dyngen$(EXESUF) libqemu_common.a @@ -33,15 +32,23 @@ subdir-%: dyngen$(EXESUF) libqemu_common.a
33 32
34 recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS)) 33 recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
35 34
  35 +#######################################################################
  36 +# BLOCK_OBJS is code used by both qemu system emulation and qemu-img
  37 +
  38 +BLOCK_OBJS=cutils.o
  39 +BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
  40 +BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
  41 +BLOCK_OBJS+=block-qcow2.o block-parallels.o
  42 +
36 ###################################################################### 43 ######################################################################
37 -# libqemu_common.a: target indepedent part of system emulation. The 44 +# libqemu_common.a: Target indepedent part of system emulation. The
38 # long term path is to suppress *all* target specific code in case of 45 # long term path is to suppress *all* target specific code in case of
39 # system emulation, i.e. a single QEMU executable should support all 46 # system emulation, i.e. a single QEMU executable should support all
40 # CPUs and machines. 47 # CPUs and machines.
41 48
42 -OBJS+=cutils.o readline.o console.o  
43 -#OBJS+=block.o block-raw.o  
44 -OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o block-parallels.o 49 +OBJS=$(BLOCK_OBJS)
  50 +OBJS+=readline.o console.o
  51 +OBJS+=block.o
45 52
46 ifdef CONFIG_WIN32 53 ifdef CONFIG_WIN32
47 OBJS+=tap-win32.o 54 OBJS+=tap-win32.o
@@ -105,9 +112,12 @@ libqemu_common.a: $(OBJS) @@ -105,9 +112,12 @@ libqemu_common.a: $(OBJS)
105 112
106 ###################################################################### 113 ######################################################################
107 114
108 -qemu-img$(EXESUF): qemu-img.o block.o block-raw.o libqemu_common.a 115 +qemu-img$(EXESUF): qemu-img.o qemu-img-block.o qemu-img-block-raw.o $(BLOCK_OBJS)
109 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS) 116 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ -lz $(LIBS)
110 117
  118 +qemu-img-%.o: %.c
  119 + $(CC) $(CFLAGS) $(CPPFLAGS) -DQEMU_IMG $(BASE_CFLAGS) -c -o $@ $<
  120 +
111 %.o: %.c 121 %.o: %.c
112 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $< 122 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
113 123
Makefile.target
@@ -24,7 +24,7 @@ TARGET_BASE_ARCH:=sparc @@ -24,7 +24,7 @@ TARGET_BASE_ARCH:=sparc
24 endif 24 endif
25 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH) 25 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
26 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw 26 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
27 -CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP 27 +CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP -DNEED_CPU_H
28 ifdef CONFIG_DARWIN_USER 28 ifdef CONFIG_DARWIN_USER
29 VPATH+=:$(SRC_PATH)/darwin-user 29 VPATH+=:$(SRC_PATH)/darwin-user
30 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH) 30 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
@@ -398,7 +398,7 @@ endif @@ -398,7 +398,7 @@ endif
398 # must use static linking to avoid leaving stuff in virtual address space 398 # must use static linking to avoid leaving stuff in virtual address space
399 VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o 399 VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o
400 # XXX: suppress QEMU_TOOL tests 400 # XXX: suppress QEMU_TOOL tests
401 -VL_OBJS+=block.o block-raw.o 401 +VL_OBJS+=block-raw.o
402 VL_OBJS+=irq.o 402 VL_OBJS+=irq.o
403 403
404 ifdef CONFIG_ALSA 404 ifdef CONFIG_ALSA
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 -#include "vl.h" 30 +#include "qemu-common.h"
31 #include "aes.h" 31 #include "aes.h"
32 32
33 #define NDEBUG 33 #define NDEBUG
block-bochs.c
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE. 23 * THE SOFTWARE.
24 */ 24 */
25 -#include "vl.h" 25 +#include "qemu-common.h"
26 #include "block_int.h" 26 #include "block_int.h"
27 27
28 /**************************************************************/ 28 /**************************************************************/
block-cloop.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 #include <zlib.h> 26 #include <zlib.h>
27 27
block-cow.c
@@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 #ifndef _WIN32 24 #ifndef _WIN32
25 -#include "vl.h" 25 +#include "qemu-common.h"
26 #include "block_int.h" 26 #include "block_int.h"
27 #include <sys/mman.h> 27 #include <sys/mman.h>
28 28
block-dmg.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 #include "bswap.h" 26 #include "bswap.h"
27 #include <zlib.h> 27 #include <zlib.h>
block-parallels.c
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE. 24 * THE SOFTWARE.
25 */ 25 */
26 -#include "vl.h" 26 +#include "qemu-common.h"
27 #include "block_int.h" 27 #include "block_int.h"
28 28
29 /**************************************************************/ 29 /**************************************************************/
block-qcow.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 #include <zlib.h> 26 #include <zlib.h>
27 #include "aes.h" 27 #include "aes.h"
block-qcow2.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 #include <zlib.h> 26 #include <zlib.h>
27 #include "aes.h" 27 #include "aes.h"
block-raw.c
@@ -21,16 +21,16 @@ @@ -21,16 +21,16 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
  24 +#ifdef QEMU_IMG
  25 +#include "qemu-common.h"
  26 +#else
24 #include "vl.h" 27 #include "vl.h"
  28 +#endif
25 #include "block_int.h" 29 #include "block_int.h"
26 #include <assert.h> 30 #include <assert.h>
27 #ifndef _WIN32 31 #ifndef _WIN32
28 #include <aio.h> 32 #include <aio.h>
29 33
30 -#ifndef QEMU_TOOL  
31 -#include "exec-all.h"  
32 -#endif  
33 -  
34 #ifdef CONFIG_COCOA 34 #ifdef CONFIG_COCOA
35 #include <paths.h> 35 #include <paths.h>
36 #include <sys/param.h> 36 #include <sys/param.h>
@@ -59,8 +59,9 @@ @@ -59,8 +59,9 @@
59 59
60 //#define DEBUG_FLOPPY 60 //#define DEBUG_FLOPPY
61 61
62 -#define DEBUG_BLOCK  
63 -#if defined(DEBUG_BLOCK) && !defined(QEMU_TOOL) 62 +//#define DEBUG_BLOCK
  63 +#if defined(DEBUG_BLOCK) && !defined(QEMU_IMG)
  64 +#include "exec-all.h"
64 #define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \ 65 #define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \
65 { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0) 66 { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0)
66 #else 67 #else
@@ -242,7 +243,7 @@ static int aio_initialized = 0; @@ -242,7 +243,7 @@ static int aio_initialized = 0;
242 243
243 static void aio_signal_handler(int signum) 244 static void aio_signal_handler(int signum)
244 { 245 {
245 -#ifndef QEMU_TOOL 246 +#ifndef QEMU_IMG
246 CPUState *env = cpu_single_env; 247 CPUState *env = cpu_single_env;
247 if (env) { 248 if (env) {
248 /* stop the currently executing cpu because a timer occured */ 249 /* stop the currently executing cpu because a timer occured */
@@ -352,7 +353,7 @@ void qemu_aio_wait(void) @@ -352,7 +353,7 @@ void qemu_aio_wait(void)
352 sigset_t set; 353 sigset_t set;
353 int nb_sigs; 354 int nb_sigs;
354 355
355 -#ifndef QEMU_TOOL 356 +#ifndef QEMU_IMG
356 if (qemu_bh_poll()) 357 if (qemu_bh_poll())
357 return; 358 return;
358 #endif 359 #endif
@@ -693,7 +694,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -693,7 +694,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
693 return 0; 694 return 0;
694 } 695 }
695 696
696 -#if defined(__linux__) && !defined(QEMU_TOOL) 697 +#if defined(__linux__) && !defined(QEMU_IMG)
697 698
698 /* Note: we do not have a reliable method to detect if the floppy is 699 /* Note: we do not have a reliable method to detect if the floppy is
699 present. The current method is to try to open the floppy at every 700 present. The current method is to try to open the floppy at every
@@ -976,7 +977,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) @@ -976,7 +977,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
976 } else { 977 } else {
977 create_flags = OPEN_EXISTING; 978 create_flags = OPEN_EXISTING;
978 } 979 }
979 -#ifdef QEMU_TOOL 980 +#ifdef QEMU_IMG
980 overlapped = FILE_ATTRIBUTE_NORMAL; 981 overlapped = FILE_ATTRIBUTE_NORMAL;
981 #else 982 #else
982 overlapped = FILE_FLAG_OVERLAPPED; 983 overlapped = FILE_FLAG_OVERLAPPED;
@@ -1039,7 +1040,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, @@ -1039,7 +1040,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset,
1039 } 1040 }
1040 1041
1041 #if 0 1042 #if 0
1042 -#ifndef QEMU_TOOL 1043 +#ifndef QEMU_IMG
1043 static void raw_aio_cb(void *opaque) 1044 static void raw_aio_cb(void *opaque)
1044 { 1045 {
1045 RawAIOCB *acb = opaque; 1046 RawAIOCB *acb = opaque;
@@ -1078,7 +1079,7 @@ static RawAIOCB *raw_aio_setup(BlockDriverState *bs, @@ -1078,7 +1079,7 @@ static RawAIOCB *raw_aio_setup(BlockDriverState *bs,
1078 acb->ov.OffsetHigh = offset >> 32; 1079 acb->ov.OffsetHigh = offset >> 32;
1079 acb->ov.hEvent = acb->hEvent; 1080 acb->ov.hEvent = acb->hEvent;
1080 acb->count = nb_sectors * 512; 1081 acb->count = nb_sectors * 512;
1081 -#ifndef QEMU_TOOL 1082 +#ifndef QEMU_IMG
1082 qemu_add_wait_object(acb->ov.hEvent, raw_aio_cb, acb); 1083 qemu_add_wait_object(acb->ov.hEvent, raw_aio_cb, acb);
1083 #endif 1084 #endif
1084 return acb; 1085 return acb;
@@ -1100,7 +1101,7 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs, @@ -1100,7 +1101,7 @@ static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs,
1100 qemu_aio_release(acb); 1101 qemu_aio_release(acb);
1101 return NULL; 1102 return NULL;
1102 } 1103 }
1103 -#ifdef QEMU_TOOL 1104 +#ifdef QEMU_IMG
1104 qemu_aio_release(acb); 1105 qemu_aio_release(acb);
1105 #endif 1106 #endif
1106 return (BlockDriverAIOCB *)acb; 1107 return (BlockDriverAIOCB *)acb;
@@ -1122,7 +1123,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, @@ -1122,7 +1123,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,
1122 qemu_aio_release(acb); 1123 qemu_aio_release(acb);
1123 return NULL; 1124 return NULL;
1124 } 1125 }
1125 -#ifdef QEMU_TOOL 1126 +#ifdef QEMU_IMG
1126 qemu_aio_release(acb); 1127 qemu_aio_release(acb);
1127 #endif 1128 #endif
1128 return (BlockDriverAIOCB *)acb; 1129 return (BlockDriverAIOCB *)acb;
@@ -1130,7 +1131,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs, @@ -1130,7 +1131,7 @@ static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,
1130 1131
1131 static void raw_aio_cancel(BlockDriverAIOCB *blockacb) 1132 static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
1132 { 1133 {
1133 -#ifndef QEMU_TOOL 1134 +#ifndef QEMU_IMG
1134 RawAIOCB *acb = (RawAIOCB *)blockacb; 1135 RawAIOCB *acb = (RawAIOCB *)blockacb;
1135 BlockDriverState *bs = acb->common.bs; 1136 BlockDriverState *bs = acb->common.bs;
1136 BDRVRawState *s = bs->opaque; 1137 BDRVRawState *s = bs->opaque;
@@ -1238,7 +1239,7 @@ void qemu_aio_wait_start(void) @@ -1238,7 +1239,7 @@ void qemu_aio_wait_start(void)
1238 1239
1239 void qemu_aio_wait(void) 1240 void qemu_aio_wait(void)
1240 { 1241 {
1241 -#ifndef QEMU_TOOL 1242 +#ifndef QEMU_IMG
1242 qemu_bh_poll(); 1243 qemu_bh_poll();
1243 #endif 1244 #endif
1244 } 1245 }
@@ -1344,7 +1345,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) @@ -1344,7 +1345,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
1344 } 1345 }
1345 create_flags = OPEN_EXISTING; 1346 create_flags = OPEN_EXISTING;
1346 1347
1347 -#ifdef QEMU_TOOL 1348 +#ifdef QEMU_IMG
1348 overlapped = FILE_ATTRIBUTE_NORMAL; 1349 overlapped = FILE_ATTRIBUTE_NORMAL;
1349 #else 1350 #else
1350 overlapped = FILE_FLAG_OVERLAPPED; 1351 overlapped = FILE_FLAG_OVERLAPPED;
block-vmdk.c
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 * THE SOFTWARE. 23 * THE SOFTWARE.
24 */ 24 */
25 25
26 -#include "vl.h" 26 +#include "qemu-common.h"
27 #include "block_int.h" 27 #include "block_int.h"
28 28
29 #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D') 29 #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
block-vpc.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 26
27 /**************************************************************/ 27 /**************************************************************/
block-vvfat.c
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 #include <sys/stat.h> 25 #include <sys/stat.h>
26 #include <dirent.h> 26 #include <dirent.h>
27 #include <assert.h> 27 #include <assert.h>
28 -#include "vl.h" 28 +#include "qemu-common.h"
29 #include "block_int.h" 29 #include "block_int.h"
30 30
31 #ifndef S_IWGRP 31 #ifndef S_IWGRP
@@ -21,7 +21,11 @@ @@ -21,7 +21,11 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
  24 +#ifdef QEMU_IMG
  25 +#include "qemu-common.h"
  26 +#else
24 #include "vl.h" 27 #include "vl.h"
  28 +#endif
25 #include "block_int.h" 29 #include "block_int.h"
26 30
27 #ifdef _BSD 31 #ifdef _BSD
@@ -53,7 +57,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, @@ -53,7 +57,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
53 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, 57 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
54 const uint8_t *buf, int nb_sectors); 58 const uint8_t *buf, int nb_sectors);
55 59
56 -static BlockDriverState *bdrv_first; 60 +BlockDriverState *bdrv_first;
57 static BlockDriver *first_drv; 61 static BlockDriver *first_drv;
58 62
59 int path_is_absolute(const char *path) 63 int path_is_absolute(const char *path)
@@ -859,6 +863,7 @@ void bdrv_flush(BlockDriverState *bs) @@ -859,6 +863,7 @@ void bdrv_flush(BlockDriverState *bs)
859 bdrv_flush(bs->backing_hd); 863 bdrv_flush(bs->backing_hd);
860 } 864 }
861 865
  866 +#ifndef QEMU_IMG
862 void bdrv_info(void) 867 void bdrv_info(void)
863 { 868 {
864 BlockDriverState *bs; 869 BlockDriverState *bs;
@@ -898,6 +903,7 @@ void bdrv_info(void) @@ -898,6 +903,7 @@ void bdrv_info(void)
898 term_printf("\n"); 903 term_printf("\n");
899 } 904 }
900 } 905 }
  906 +#endif
901 907
902 void bdrv_get_backing_filename(BlockDriverState *bs, 908 void bdrv_get_backing_filename(BlockDriverState *bs,
903 char *filename, int filename_size) 909 char *filename, int filename_size)
@@ -1102,7 +1108,7 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb) @@ -1102,7 +1108,7 @@ void bdrv_aio_cancel(BlockDriverAIOCB *acb)
1102 /**************************************************************/ 1108 /**************************************************************/
1103 /* async block device emulation */ 1109 /* async block device emulation */
1104 1110
1105 -#ifdef QEMU_TOOL 1111 +#ifdef QEMU_IMG
1106 static BlockDriverAIOCB *bdrv_aio_read_em(BlockDriverState *bs, 1112 static BlockDriverAIOCB *bdrv_aio_read_em(BlockDriverState *bs,
1107 int64_t sector_num, uint8_t *buf, int nb_sectors, 1113 int64_t sector_num, uint8_t *buf, int nb_sectors,
1108 BlockDriverCompletionFunc *cb, void *opaque) 1114 BlockDriverCompletionFunc *cb, void *opaque)
@@ -1172,7 +1178,7 @@ static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb) @@ -1172,7 +1178,7 @@ static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb)
1172 qemu_bh_cancel(acb->bh); 1178 qemu_bh_cancel(acb->bh);
1173 qemu_aio_release(acb); 1179 qemu_aio_release(acb);
1174 } 1180 }
1175 -#endif /* !QEMU_TOOL */ 1181 +#endif /* !QEMU_IMG */
1176 1182
1177 /**************************************************************/ 1183 /**************************************************************/
1178 /* sync block device emulation */ 1184 /* sync block device emulation */
block.h 0 โ†’ 100644
  1 +#ifndef BLOCK_H
  2 +#define BLOCK_H
  3 +
  4 +/* block.c */
  5 +typedef struct BlockDriverState BlockDriverState;
  6 +typedef struct BlockDriver BlockDriver;
  7 +
  8 +extern BlockDriver bdrv_raw;
  9 +extern BlockDriver bdrv_host_device;
  10 +extern BlockDriver bdrv_cow;
  11 +extern BlockDriver bdrv_qcow;
  12 +extern BlockDriver bdrv_vmdk;
  13 +extern BlockDriver bdrv_cloop;
  14 +extern BlockDriver bdrv_dmg;
  15 +extern BlockDriver bdrv_bochs;
  16 +extern BlockDriver bdrv_vpc;
  17 +extern BlockDriver bdrv_vvfat;
  18 +extern BlockDriver bdrv_qcow2;
  19 +extern BlockDriver bdrv_parallels;
  20 +
  21 +typedef struct BlockDriverInfo {
  22 + /* in bytes, 0 if irrelevant */
  23 + int cluster_size;
  24 + /* offset at which the VM state can be saved (0 if not possible) */
  25 + int64_t vm_state_offset;
  26 +} BlockDriverInfo;
  27 +
  28 +typedef struct QEMUSnapshotInfo {
  29 + char id_str[128]; /* unique snapshot id */
  30 + /* the following fields are informative. They are not needed for
  31 + the consistency of the snapshot */
  32 + char name[256]; /* user choosen name */
  33 + uint32_t vm_state_size; /* VM state info size */
  34 + uint32_t date_sec; /* UTC date of the snapshot */
  35 + uint32_t date_nsec;
  36 + uint64_t vm_clock_nsec; /* VM clock relative to boot */
  37 +} QEMUSnapshotInfo;
  38 +
  39 +#define BDRV_O_RDONLY 0x0000
  40 +#define BDRV_O_RDWR 0x0002
  41 +#define BDRV_O_ACCESS 0x0003
  42 +#define BDRV_O_CREAT 0x0004 /* create an empty file */
  43 +#define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */
  44 +#define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to
  45 + use a disk image format on top of
  46 + it (default for
  47 + bdrv_file_open()) */
  48 +
  49 +#ifndef QEMU_IMG
  50 +void bdrv_info(void);
  51 +#endif
  52 +
  53 +void bdrv_init(void);
  54 +BlockDriver *bdrv_find_format(const char *format_name);
  55 +int bdrv_create(BlockDriver *drv,
  56 + const char *filename, int64_t size_in_sectors,
  57 + const char *backing_file, int flags);
  58 +BlockDriverState *bdrv_new(const char *device_name);
  59 +void bdrv_delete(BlockDriverState *bs);
  60 +int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
  61 +int bdrv_open(BlockDriverState *bs, const char *filename, int flags);
  62 +int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
  63 + BlockDriver *drv);
  64 +void bdrv_close(BlockDriverState *bs);
  65 +int bdrv_read(BlockDriverState *bs, int64_t sector_num,
  66 + uint8_t *buf, int nb_sectors);
  67 +int bdrv_write(BlockDriverState *bs, int64_t sector_num,
  68 + const uint8_t *buf, int nb_sectors);
  69 +int bdrv_pread(BlockDriverState *bs, int64_t offset,
  70 + void *buf, int count);
  71 +int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
  72 + const void *buf, int count);
  73 +int bdrv_truncate(BlockDriverState *bs, int64_t offset);
  74 +int64_t bdrv_getlength(BlockDriverState *bs);
  75 +void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
  76 +int bdrv_commit(BlockDriverState *bs);
  77 +void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
  78 +/* async block I/O */
  79 +typedef struct BlockDriverAIOCB BlockDriverAIOCB;
  80 +typedef void BlockDriverCompletionFunc(void *opaque, int ret);
  81 +
  82 +BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
  83 + uint8_t *buf, int nb_sectors,
  84 + BlockDriverCompletionFunc *cb, void *opaque);
  85 +BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
  86 + const uint8_t *buf, int nb_sectors,
  87 + BlockDriverCompletionFunc *cb, void *opaque);
  88 +void bdrv_aio_cancel(BlockDriverAIOCB *acb);
  89 +
  90 +void qemu_aio_init(void);
  91 +void qemu_aio_poll(void);
  92 +void qemu_aio_flush(void);
  93 +void qemu_aio_wait_start(void);
  94 +void qemu_aio_wait(void);
  95 +void qemu_aio_wait_end(void);
  96 +
  97 +int qemu_key_check(BlockDriverState *bs, const char *name);
  98 +
  99 +/* Ensure contents are flushed to disk. */
  100 +void bdrv_flush(BlockDriverState *bs);
  101 +
  102 +#define BDRV_TYPE_HD 0
  103 +#define BDRV_TYPE_CDROM 1
  104 +#define BDRV_TYPE_FLOPPY 2
  105 +#define BIOS_ATA_TRANSLATION_AUTO 0
  106 +#define BIOS_ATA_TRANSLATION_NONE 1
  107 +#define BIOS_ATA_TRANSLATION_LBA 2
  108 +#define BIOS_ATA_TRANSLATION_LARGE 3
  109 +#define BIOS_ATA_TRANSLATION_RECHS 4
  110 +
  111 +void bdrv_set_geometry_hint(BlockDriverState *bs,
  112 + int cyls, int heads, int secs);
  113 +void bdrv_set_type_hint(BlockDriverState *bs, int type);
  114 +void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
  115 +void bdrv_get_geometry_hint(BlockDriverState *bs,
  116 + int *pcyls, int *pheads, int *psecs);
  117 +int bdrv_get_type_hint(BlockDriverState *bs);
  118 +int bdrv_get_translation_hint(BlockDriverState *bs);
  119 +int bdrv_is_removable(BlockDriverState *bs);
  120 +int bdrv_is_read_only(BlockDriverState *bs);
  121 +int bdrv_is_inserted(BlockDriverState *bs);
  122 +int bdrv_media_changed(BlockDriverState *bs);
  123 +int bdrv_is_locked(BlockDriverState *bs);
  124 +void bdrv_set_locked(BlockDriverState *bs, int locked);
  125 +void bdrv_eject(BlockDriverState *bs, int eject_flag);
  126 +void bdrv_set_change_cb(BlockDriverState *bs,
  127 + void (*change_cb)(void *opaque), void *opaque);
  128 +void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
  129 +BlockDriverState *bdrv_find(const char *name);
  130 +void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
  131 +int bdrv_is_encrypted(BlockDriverState *bs);
  132 +int bdrv_set_key(BlockDriverState *bs, const char *key);
  133 +void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
  134 + void *opaque);
  135 +const char *bdrv_get_device_name(BlockDriverState *bs);
  136 +int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
  137 + const uint8_t *buf, int nb_sectors);
  138 +int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
  139 +
  140 +void bdrv_get_backing_filename(BlockDriverState *bs,
  141 + char *filename, int filename_size);
  142 +int bdrv_snapshot_create(BlockDriverState *bs,
  143 + QEMUSnapshotInfo *sn_info);
  144 +int bdrv_snapshot_goto(BlockDriverState *bs,
  145 + const char *snapshot_id);
  146 +int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
  147 +int bdrv_snapshot_list(BlockDriverState *bs,
  148 + QEMUSnapshotInfo **psn_info);
  149 +char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
  150 +
  151 +char *get_human_readable_size(char *buf, int buf_size, int64_t size);
  152 +int path_is_absolute(const char *path);
  153 +void path_combine(char *dest, int dest_size,
  154 + const char *base_path,
  155 + const char *filename);
  156 +
  157 +#endif
block_int.h
@@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
24 #ifndef BLOCK_INT_H 24 #ifndef BLOCK_INT_H
25 #define BLOCK_INT_H 25 #define BLOCK_INT_H
26 26
  27 +#include "block.h"
  28 +
27 #define BLOCK_FLAG_ENCRYPT 1 29 #define BLOCK_FLAG_ENCRYPT 1
28 #define BLOCK_FLAG_COMPRESS 2 30 #define BLOCK_FLAG_COMPRESS 2
29 #define BLOCK_FLAG_COMPAT6 4 31 #define BLOCK_FLAG_COMPAT6 4
@@ -133,4 +135,6 @@ void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb, @@ -133,4 +135,6 @@ void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
133 void *opaque); 135 void *opaque);
134 void qemu_aio_release(void *p); 136 void qemu_aio_release(void *p);
135 137
  138 +BlockDriverState *bdrv_first;
  139 +
136 #endif /* BLOCK_INT_H */ 140 #endif /* BLOCK_INT_H */
cutils.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 25
26 void pstrcpy(char *buf, int buf_size, const char *str) 26 void pstrcpy(char *buf, int buf_size, const char *str)
27 { 27 {
qemu-common.h 0 โ†’ 100644
  1 +/* Common header file that is included by all of qemu. */
  2 +#ifndef QEMU_COMMON_H
  3 +#define QEMU_COMMON_H
  4 +
  5 +/* we put basic includes here to avoid repeating them in device drivers */
  6 +#include <stdlib.h>
  7 +#include <stdio.h>
  8 +#include <stdarg.h>
  9 +#include <string.h>
  10 +#include <inttypes.h>
  11 +#include <limits.h>
  12 +#include <time.h>
  13 +#include <ctype.h>
  14 +#include <errno.h>
  15 +#include <unistd.h>
  16 +#include <fcntl.h>
  17 +#include <sys/stat.h>
  18 +
  19 +#ifndef O_LARGEFILE
  20 +#define O_LARGEFILE 0
  21 +#endif
  22 +#ifndef O_BINARY
  23 +#define O_BINARY 0
  24 +#endif
  25 +
  26 +#ifndef ENOMEDIUM
  27 +#define ENOMEDIUM ENODEV
  28 +#endif
  29 +
  30 +#ifdef _WIN32
  31 +#include <windows.h>
  32 +#define fsync _commit
  33 +#define lseek _lseeki64
  34 +#define ENOTSUP 4096
  35 +extern int qemu_ftruncate64(int, int64_t);
  36 +#define ftruncate qemu_ftruncate64
  37 +
  38 +
  39 +static inline char *realpath(const char *path, char *resolved_path)
  40 +{
  41 + _fullpath(resolved_path, path, _MAX_PATH);
  42 + return resolved_path;
  43 +}
  44 +
  45 +#define PRId64 "I64d"
  46 +#define PRIx64 "I64x"
  47 +#define PRIu64 "I64u"
  48 +#define PRIo64 "I64o"
  49 +#endif
  50 +
  51 +/* FIXME: Remove NEED_CPU_H. */
  52 +#ifndef NEED_CPU_H
  53 +
  54 +#include "config-host.h"
  55 +#include <setjmp.h>
  56 +#include "osdep.h"
  57 +#include "bswap.h"
  58 +
  59 +#else
  60 +
  61 +#include "cpu.h"
  62 +
  63 +#endif /* !defined(NEED_CPU_H) */
  64 +
  65 +/* bottom halves */
  66 +typedef struct QEMUBH QEMUBH;
  67 +
  68 +typedef void QEMUBHFunc(void *opaque);
  69 +
  70 +QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
  71 +void qemu_bh_schedule(QEMUBH *bh);
  72 +void qemu_bh_cancel(QEMUBH *bh);
  73 +void qemu_bh_delete(QEMUBH *bh);
  74 +int qemu_bh_poll(void);
  75 +
  76 +/* cutils.c */
  77 +void pstrcpy(char *buf, int buf_size, const char *str);
  78 +char *pstrcat(char *buf, int buf_size, const char *s);
  79 +int strstart(const char *str, const char *val, const char **ptr);
  80 +int stristart(const char *str, const char *val, const char **ptr);
  81 +time_t mktimegm(struct tm *tm);
  82 +
  83 +#endif
qemu-img.c
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE. 22 * THE SOFTWARE.
23 */ 23 */
24 -#include "vl.h" 24 +#include "qemu-common.h"
25 #include "block_int.h" 25 #include "block_int.h"
26 #include <assert.h> 26 #include <assert.h>
27 27
@@ -24,66 +24,10 @@ @@ -24,66 +24,10 @@
24 #ifndef VL_H 24 #ifndef VL_H
25 #define VL_H 25 #define VL_H
26 26
27 -/* we put basic includes here to avoid repeating them in device drivers */  
28 -#include <stdlib.h>  
29 -#include <stdio.h>  
30 -#include <stdarg.h>  
31 -#include <string.h>  
32 -#include <inttypes.h>  
33 -#include <limits.h>  
34 -#include <time.h>  
35 -#include <ctype.h>  
36 -#include <errno.h>  
37 -#include <unistd.h>  
38 -#include <fcntl.h>  
39 -#include <sys/stat.h>  
40 -  
41 -#ifndef O_LARGEFILE  
42 -#define O_LARGEFILE 0  
43 -#endif  
44 -#ifndef O_BINARY  
45 -#define O_BINARY 0  
46 -#endif  
47 -  
48 -#ifndef ENOMEDIUM  
49 -#define ENOMEDIUM ENODEV  
50 -#endif  
51 -  
52 -#ifdef _WIN32  
53 -#include <windows.h>  
54 -#define fsync _commit  
55 -#define lseek _lseeki64  
56 -#define ENOTSUP 4096  
57 -extern int qemu_ftruncate64(int, int64_t);  
58 -#define ftruncate qemu_ftruncate64  
59 -  
60 -  
61 -static inline char *realpath(const char *path, char *resolved_path)  
62 -{  
63 - _fullpath(resolved_path, path, _MAX_PATH);  
64 - return resolved_path;  
65 -}  
66 -  
67 -#define PRId64 "I64d"  
68 -#define PRIx64 "I64x"  
69 -#define PRIu64 "I64u"  
70 -#define PRIo64 "I64o"  
71 -#endif  
72 -  
73 -#ifdef QEMU_TOOL  
74 -  
75 -/* we use QEMU_TOOL on code which does not depend on the target CPU  
76 - type */  
77 -#include "config-host.h"  
78 -#include <setjmp.h>  
79 -#include "osdep.h"  
80 -#include "bswap.h"  
81 -  
82 -#else  
83 -  
84 -#include "cpu.h" 27 +#include "qemu-common.h"
85 28
86 -#endif /* !defined(QEMU_TOOL) */ 29 +/* FIXME: Remove this. */
  30 +#include "block.h"
87 31
88 #ifndef glue 32 #ifndef glue
89 #define xglue(x, y) x ## y 33 #define xglue(x, y) x ## y
@@ -118,13 +62,6 @@ static inline char *realpath(const char *path, char *resolved_path) @@ -118,13 +62,6 @@ static inline char *realpath(const char *path, char *resolved_path)
118 62
119 #include "audio/audio.h" 63 #include "audio/audio.h"
120 64
121 -/* cutils.c */  
122 -void pstrcpy(char *buf, int buf_size, const char *str);  
123 -char *pstrcat(char *buf, int buf_size, const char *s);  
124 -int strstart(const char *str, const char *val, const char **ptr);  
125 -int stristart(const char *str, const char *val, const char **ptr);  
126 -time_t mktimegm(struct tm *tm);  
127 -  
128 /* vl.c */ 65 /* vl.c */
129 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); 66 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
130 67
@@ -297,8 +234,6 @@ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); @@ -297,8 +234,6 @@ int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
297 void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); 234 void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
298 #endif 235 #endif
299 236
300 -typedef struct QEMUBH QEMUBH;  
301 -  
302 /* character device */ 237 /* character device */
303 238
304 #define CHR_EVENT_BREAK 0 /* serial break char */ 239 #define CHR_EVENT_BREAK 0 /* serial break char */
@@ -604,166 +539,6 @@ void do_loadvm(const char *name); @@ -604,166 +539,6 @@ void do_loadvm(const char *name);
604 void do_delvm(const char *name); 539 void do_delvm(const char *name);
605 void do_info_snapshots(void); 540 void do_info_snapshots(void);
606 541
607 -/* bottom halves */  
608 -typedef void QEMUBHFunc(void *opaque);  
609 -  
610 -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);  
611 -void qemu_bh_schedule(QEMUBH *bh);  
612 -void qemu_bh_cancel(QEMUBH *bh);  
613 -void qemu_bh_delete(QEMUBH *bh);  
614 -int qemu_bh_poll(void);  
615 -  
616 -/* block.c */  
617 -typedef struct BlockDriverState BlockDriverState;  
618 -typedef struct BlockDriver BlockDriver;  
619 -  
620 -extern BlockDriver bdrv_raw;  
621 -extern BlockDriver bdrv_host_device;  
622 -extern BlockDriver bdrv_cow;  
623 -extern BlockDriver bdrv_qcow;  
624 -extern BlockDriver bdrv_vmdk;  
625 -extern BlockDriver bdrv_cloop;  
626 -extern BlockDriver bdrv_dmg;  
627 -extern BlockDriver bdrv_bochs;  
628 -extern BlockDriver bdrv_vpc;  
629 -extern BlockDriver bdrv_vvfat;  
630 -extern BlockDriver bdrv_qcow2;  
631 -extern BlockDriver bdrv_parallels;  
632 -  
633 -typedef struct BlockDriverInfo {  
634 - /* in bytes, 0 if irrelevant */  
635 - int cluster_size;  
636 - /* offset at which the VM state can be saved (0 if not possible) */  
637 - int64_t vm_state_offset;  
638 -} BlockDriverInfo;  
639 -  
640 -typedef struct QEMUSnapshotInfo {  
641 - char id_str[128]; /* unique snapshot id */  
642 - /* the following fields are informative. They are not needed for  
643 - the consistency of the snapshot */  
644 - char name[256]; /* user choosen name */  
645 - uint32_t vm_state_size; /* VM state info size */  
646 - uint32_t date_sec; /* UTC date of the snapshot */  
647 - uint32_t date_nsec;  
648 - uint64_t vm_clock_nsec; /* VM clock relative to boot */  
649 -} QEMUSnapshotInfo;  
650 -  
651 -#define BDRV_O_RDONLY 0x0000  
652 -#define BDRV_O_RDWR 0x0002  
653 -#define BDRV_O_ACCESS 0x0003  
654 -#define BDRV_O_CREAT 0x0004 /* create an empty file */  
655 -#define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */  
656 -#define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to  
657 - use a disk image format on top of  
658 - it (default for  
659 - bdrv_file_open()) */  
660 -  
661 -void bdrv_init(void);  
662 -BlockDriver *bdrv_find_format(const char *format_name);  
663 -int bdrv_create(BlockDriver *drv,  
664 - const char *filename, int64_t size_in_sectors,  
665 - const char *backing_file, int flags);  
666 -BlockDriverState *bdrv_new(const char *device_name);  
667 -void bdrv_delete(BlockDriverState *bs);  
668 -int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);  
669 -int bdrv_open(BlockDriverState *bs, const char *filename, int flags);  
670 -int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,  
671 - BlockDriver *drv);  
672 -void bdrv_close(BlockDriverState *bs);  
673 -int bdrv_read(BlockDriverState *bs, int64_t sector_num,  
674 - uint8_t *buf, int nb_sectors);  
675 -int bdrv_write(BlockDriverState *bs, int64_t sector_num,  
676 - const uint8_t *buf, int nb_sectors);  
677 -int bdrv_pread(BlockDriverState *bs, int64_t offset,  
678 - void *buf, int count);  
679 -int bdrv_pwrite(BlockDriverState *bs, int64_t offset,  
680 - const void *buf, int count);  
681 -int bdrv_truncate(BlockDriverState *bs, int64_t offset);  
682 -int64_t bdrv_getlength(BlockDriverState *bs);  
683 -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);  
684 -int bdrv_commit(BlockDriverState *bs);  
685 -void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);  
686 -/* async block I/O */  
687 -typedef struct BlockDriverAIOCB BlockDriverAIOCB;  
688 -typedef void BlockDriverCompletionFunc(void *opaque, int ret);  
689 -  
690 -BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,  
691 - uint8_t *buf, int nb_sectors,  
692 - BlockDriverCompletionFunc *cb, void *opaque);  
693 -BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,  
694 - const uint8_t *buf, int nb_sectors,  
695 - BlockDriverCompletionFunc *cb, void *opaque);  
696 -void bdrv_aio_cancel(BlockDriverAIOCB *acb);  
697 -  
698 -void qemu_aio_init(void);  
699 -void qemu_aio_poll(void);  
700 -void qemu_aio_flush(void);  
701 -void qemu_aio_wait_start(void);  
702 -void qemu_aio_wait(void);  
703 -void qemu_aio_wait_end(void);  
704 -  
705 -int qemu_key_check(BlockDriverState *bs, const char *name);  
706 -  
707 -/* Ensure contents are flushed to disk. */  
708 -void bdrv_flush(BlockDriverState *bs);  
709 -  
710 -#define BDRV_TYPE_HD 0  
711 -#define BDRV_TYPE_CDROM 1  
712 -#define BDRV_TYPE_FLOPPY 2  
713 -#define BIOS_ATA_TRANSLATION_AUTO 0  
714 -#define BIOS_ATA_TRANSLATION_NONE 1  
715 -#define BIOS_ATA_TRANSLATION_LBA 2  
716 -#define BIOS_ATA_TRANSLATION_LARGE 3  
717 -#define BIOS_ATA_TRANSLATION_RECHS 4  
718 -  
719 -void bdrv_set_geometry_hint(BlockDriverState *bs,  
720 - int cyls, int heads, int secs);  
721 -void bdrv_set_type_hint(BlockDriverState *bs, int type);  
722 -void bdrv_set_translation_hint(BlockDriverState *bs, int translation);  
723 -void bdrv_get_geometry_hint(BlockDriverState *bs,  
724 - int *pcyls, int *pheads, int *psecs);  
725 -int bdrv_get_type_hint(BlockDriverState *bs);  
726 -int bdrv_get_translation_hint(BlockDriverState *bs);  
727 -int bdrv_is_removable(BlockDriverState *bs);  
728 -int bdrv_is_read_only(BlockDriverState *bs);  
729 -int bdrv_is_inserted(BlockDriverState *bs);  
730 -int bdrv_media_changed(BlockDriverState *bs);  
731 -int bdrv_is_locked(BlockDriverState *bs);  
732 -void bdrv_set_locked(BlockDriverState *bs, int locked);  
733 -void bdrv_eject(BlockDriverState *bs, int eject_flag);  
734 -void bdrv_set_change_cb(BlockDriverState *bs,  
735 - void (*change_cb)(void *opaque), void *opaque);  
736 -void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);  
737 -void bdrv_info(void);  
738 -BlockDriverState *bdrv_find(const char *name);  
739 -void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);  
740 -int bdrv_is_encrypted(BlockDriverState *bs);  
741 -int bdrv_set_key(BlockDriverState *bs, const char *key);  
742 -void bdrv_iterate_format(void (*it)(void *opaque, const char *name),  
743 - void *opaque);  
744 -const char *bdrv_get_device_name(BlockDriverState *bs);  
745 -int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,  
746 - const uint8_t *buf, int nb_sectors);  
747 -int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);  
748 -  
749 -void bdrv_get_backing_filename(BlockDriverState *bs,  
750 - char *filename, int filename_size);  
751 -int bdrv_snapshot_create(BlockDriverState *bs,  
752 - QEMUSnapshotInfo *sn_info);  
753 -int bdrv_snapshot_goto(BlockDriverState *bs,  
754 - const char *snapshot_id);  
755 -int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);  
756 -int bdrv_snapshot_list(BlockDriverState *bs,  
757 - QEMUSnapshotInfo **psn_info);  
758 -char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);  
759 -  
760 -char *get_human_readable_size(char *buf, int buf_size, int64_t size);  
761 -int path_is_absolute(const char *path);  
762 -void path_combine(char *dest, int dest_size,  
763 - const char *base_path,  
764 - const char *filename);  
765 -  
766 -  
767 /* monitor.c */ 542 /* monitor.c */
768 void monitor_init(CharDriverState *hd, int show_banner); 543 void monitor_init(CharDriverState *hd, int show_banner);
769 void term_puts(const char *str); 544 void term_puts(const char *str);
@@ -804,7 +579,7 @@ void do_info_vnc(void); @@ -804,7 +579,7 @@ void do_info_vnc(void);
804 /* x_keymap.c */ 579 /* x_keymap.c */
805 extern uint8_t _translate_keycode(const int key); 580 extern uint8_t _translate_keycode(const int key);
806 581
807 -#ifndef QEMU_TOOL 582 +#ifdef NEED_CPU_H
808 583
809 typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, 584 typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
810 const char *boot_device, 585 const char *boot_device,
@@ -1759,5 +1534,5 @@ extern QEMUMachine dummy_m68k_machine; @@ -1759,5 +1534,5 @@ extern QEMUMachine dummy_m68k_machine;
1759 1534
1760 #include "gdbstub.h" 1535 #include "gdbstub.h"
1761 1536
1762 -#endif /* defined(QEMU_TOOL) */ 1537 +#endif /* defined(NEED_CPU_H) */
1763 #endif /* VL_H */ 1538 #endif /* VL_H */