bochs.c (776efef32439a31cb13a6acfe8aab833687745ad) bochs.c (a65064816d64db463f4c24bd81dcaad62fee89eb)
1/*
2 * Block driver for the various disk image formats used by Bochs
3 * Currently only for "growing" type in read-only mode
4 *
5 * Copyright (c) 2005 Alex Beregszaszi
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 91 unchanged lines hidden (view full) ---

100 Error **errp)
101{
102 BDRVBochsState *s = bs->opaque;
103 uint32_t i;
104 struct bochs_header bochs;
105 int ret;
106
107 bs->read_only = 1; // no write support yet
1/*
2 * Block driver for the various disk image formats used by Bochs
3 * Currently only for "growing" type in read-only mode
4 *
5 * Copyright (c) 2005 Alex Beregszaszi
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

--- 91 unchanged lines hidden (view full) ---

100 Error **errp)
101{
102 BDRVBochsState *s = bs->opaque;
103 uint32_t i;
104 struct bochs_header bochs;
105 int ret;
106
107 bs->read_only = 1; // no write support yet
108 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */
109
110 ret = bdrv_pread(bs->file->bs, 0, &bochs, sizeof(bochs));
111 if (ret < 0) {
112 return ret;
113 }
114
115 if (strcmp(bochs.magic, HEADER_MAGIC) ||
116 strcmp(bochs.type, REDOLOG_TYPE) ||

--- 67 unchanged lines hidden (view full) ---

184 qemu_co_mutex_init(&s->lock);
185 return 0;
186
187fail:
188 g_free(s->catalog_bitmap);
189 return ret;
190}
191
108
109 ret = bdrv_pread(bs->file->bs, 0, &bochs, sizeof(bochs));
110 if (ret < 0) {
111 return ret;
112 }
113
114 if (strcmp(bochs.magic, HEADER_MAGIC) ||
115 strcmp(bochs.type, REDOLOG_TYPE) ||

--- 67 unchanged lines hidden (view full) ---

183 qemu_co_mutex_init(&s->lock);
184 return 0;
185
186fail:
187 g_free(s->catalog_bitmap);
188 return ret;
189}
190
191static void bochs_refresh_limits(BlockDriverState *bs, Error **errp)
192{
193 bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */
194}
195
192static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
193{
194 BDRVBochsState *s = bs->opaque;
195 uint64_t offset = sector_num * 512;
196 uint64_t extent_index, extent_offset, bitmap_offset;
197 char bitmap_entry;
198 int ret;
199

--- 78 unchanged lines hidden (view full) ---

278 g_free(s->catalog_bitmap);
279}
280
281static BlockDriver bdrv_bochs = {
282 .format_name = "bochs",
283 .instance_size = sizeof(BDRVBochsState),
284 .bdrv_probe = bochs_probe,
285 .bdrv_open = bochs_open,
196static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
197{
198 BDRVBochsState *s = bs->opaque;
199 uint64_t offset = sector_num * 512;
200 uint64_t extent_index, extent_offset, bitmap_offset;
201 char bitmap_entry;
202 int ret;
203

--- 78 unchanged lines hidden (view full) ---

282 g_free(s->catalog_bitmap);
283}
284
285static BlockDriver bdrv_bochs = {
286 .format_name = "bochs",
287 .instance_size = sizeof(BDRVBochsState),
288 .bdrv_probe = bochs_probe,
289 .bdrv_open = bochs_open,
290 .bdrv_refresh_limits = bochs_refresh_limits,
286 .bdrv_co_preadv = bochs_co_preadv,
287 .bdrv_close = bochs_close,
288};
289
290static void bdrv_bochs_init(void)
291{
292 bdrv_register(&bdrv_bochs);
293}
294
295block_init(bdrv_bochs_init);
291 .bdrv_co_preadv = bochs_co_preadv,
292 .bdrv_close = bochs_close,
293};
294
295static void bdrv_bochs_init(void)
296{
297 bdrv_register(&bdrv_bochs);
298}
299
300block_init(bdrv_bochs_init);