Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
5efa9d5a
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5efa9d5a
编写于
5月 09, 2009
作者:
A
Anthony Liguori
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert block infrastructure to use new module init functionality
Signed-off-by:
N
Anthony Liguori
<
aliguori@us.ibm.com
>
上级
0bfe3ca5
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
141 addition
and
60 deletion
+141
-60
block-bochs.c
block-bochs.c
+9
-1
block-cloop.c
block-cloop.c
+9
-1
block-cow.c
block-cow.c
+9
-1
block-dmg.c
block-dmg.c
+10
-2
block-nbd.c
block-nbd.c
+9
-1
block-parallels.c
block-parallels.c
+9
-1
block-qcow.c
block-qcow.c
+9
-1
block-qcow2.c
block-qcow2.c
+9
-1
block-raw-posix.c
block-raw-posix.c
+11
-2
block-raw-win32.c
block-raw-win32.c
+11
-2
block-vmdk.c
block-vmdk.c
+9
-1
block-vpc.c
block-vpc.c
+9
-1
block-vvfat.c
block-vvfat.c
+10
-2
block.c
block.c
+11
-24
block.h
block.h
+2
-14
qemu-img.c
qemu-img.c
+5
-5
未找到文件。
block-bochs.c
浏览文件 @
5efa9d5a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
/**************************************************************/
/**************************************************************/
...
@@ -241,7 +242,7 @@ static void bochs_close(BlockDriverState *bs)
...
@@ -241,7 +242,7 @@ static void bochs_close(BlockDriverState *bs)
close
(
s
->
fd
);
close
(
s
->
fd
);
}
}
BlockDriver
bdrv_bochs
=
{
static
BlockDriver
bdrv_bochs
=
{
.
format_name
=
"bochs"
,
.
format_name
=
"bochs"
,
.
instance_size
=
sizeof
(
BDRVBochsState
),
.
instance_size
=
sizeof
(
BDRVBochsState
),
.
bdrv_probe
=
bochs_probe
,
.
bdrv_probe
=
bochs_probe
,
...
@@ -249,3 +250,10 @@ BlockDriver bdrv_bochs = {
...
@@ -249,3 +250,10 @@ BlockDriver bdrv_bochs = {
.
bdrv_read
=
bochs_read
,
.
bdrv_read
=
bochs_read
,
.
bdrv_close
=
bochs_close
,
.
bdrv_close
=
bochs_close
,
};
};
static
void
bdrv_bochs_init
(
void
)
{
bdrv_register
(
&
bdrv_bochs
);
}
block_init
(
bdrv_bochs_init
);
block-cloop.c
浏览文件 @
5efa9d5a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#include <zlib.h>
#include <zlib.h>
typedef
struct
BDRVCloopState
{
typedef
struct
BDRVCloopState
{
...
@@ -153,7 +154,7 @@ static void cloop_close(BlockDriverState *bs)
...
@@ -153,7 +154,7 @@ static void cloop_close(BlockDriverState *bs)
inflateEnd
(
&
s
->
zstream
);
inflateEnd
(
&
s
->
zstream
);
}
}
BlockDriver
bdrv_cloop
=
{
static
BlockDriver
bdrv_cloop
=
{
.
format_name
=
"cloop"
,
.
format_name
=
"cloop"
,
.
instance_size
=
sizeof
(
BDRVCloopState
),
.
instance_size
=
sizeof
(
BDRVCloopState
),
.
bdrv_probe
=
cloop_probe
,
.
bdrv_probe
=
cloop_probe
,
...
@@ -161,3 +162,10 @@ BlockDriver bdrv_cloop = {
...
@@ -161,3 +162,10 @@ BlockDriver bdrv_cloop = {
.
bdrv_read
=
cloop_read
,
.
bdrv_read
=
cloop_read
,
.
bdrv_close
=
cloop_close
,
.
bdrv_close
=
cloop_close
,
};
};
static
void
bdrv_cloop_init
(
void
)
{
bdrv_register
(
&
bdrv_cloop
);
}
block_init
(
bdrv_cloop_init
);
block-cow.c
浏览文件 @
5efa9d5a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#ifndef _WIN32
#ifndef _WIN32
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#include <sys/mman.h>
#include <sys/mman.h>
/**************************************************************/
/**************************************************************/
...
@@ -252,7 +253,7 @@ static void cow_flush(BlockDriverState *bs)
...
@@ -252,7 +253,7 @@ static void cow_flush(BlockDriverState *bs)
fsync
(
s
->
fd
);
fsync
(
s
->
fd
);
}
}
BlockDriver
bdrv_cow
=
{
static
BlockDriver
bdrv_cow
=
{
.
format_name
=
"cow"
,
.
format_name
=
"cow"
,
.
instance_size
=
sizeof
(
BDRVCowState
),
.
instance_size
=
sizeof
(
BDRVCowState
),
.
bdrv_probe
=
cow_probe
,
.
bdrv_probe
=
cow_probe
,
...
@@ -264,4 +265,11 @@ BlockDriver bdrv_cow = {
...
@@ -264,4 +265,11 @@ BlockDriver bdrv_cow = {
.
bdrv_flush
=
cow_flush
,
.
bdrv_flush
=
cow_flush
,
.
bdrv_is_allocated
=
cow_is_allocated
,
.
bdrv_is_allocated
=
cow_is_allocated
,
};
};
static
void
bdrv_cow_init
(
void
)
{
bdrv_register
(
&
bdrv_cow
);
}
block_init
(
bdrv_cow_init
);
#endif
#endif
block-dmg.c
浏览文件 @
5efa9d5a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "bswap.h"
#include "bswap.h"
#include "module.h"
#include <zlib.h>
#include <zlib.h>
typedef
struct
BDRVDMGState
{
typedef
struct
BDRVDMGState
{
...
@@ -92,7 +93,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
...
@@ -92,7 +93,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
dmg_close:
dmg_close:
close
(
s
->
fd
);
close
(
s
->
fd
);
/* open raw instead */
/* open raw instead */
bs
->
drv
=
&
bdrv_raw
;
bs
->
drv
=
bdrv_find_format
(
"raw"
)
;
return
bs
->
drv
->
bdrv_open
(
bs
,
filename
,
flags
);
return
bs
->
drv
->
bdrv_open
(
bs
,
filename
,
flags
);
}
}
info_begin
=
read_off
(
s
->
fd
);
info_begin
=
read_off
(
s
->
fd
);
...
@@ -283,7 +284,7 @@ static void dmg_close(BlockDriverState *bs)
...
@@ -283,7 +284,7 @@ static void dmg_close(BlockDriverState *bs)
inflateEnd
(
&
s
->
zstream
);
inflateEnd
(
&
s
->
zstream
);
}
}
BlockDriver
bdrv_dmg
=
{
static
BlockDriver
bdrv_dmg
=
{
.
format_name
=
"dmg"
,
.
format_name
=
"dmg"
,
.
instance_size
=
sizeof
(
BDRVDMGState
),
.
instance_size
=
sizeof
(
BDRVDMGState
),
.
bdrv_probe
=
dmg_probe
,
.
bdrv_probe
=
dmg_probe
,
...
@@ -291,3 +292,10 @@ BlockDriver bdrv_dmg = {
...
@@ -291,3 +292,10 @@ BlockDriver bdrv_dmg = {
.
bdrv_read
=
dmg_read
,
.
bdrv_read
=
dmg_read
,
.
bdrv_close
=
dmg_close
,
.
bdrv_close
=
dmg_close
,
};
};
static
void
bdrv_dmg_init
(
void
)
{
bdrv_register
(
&
bdrv_dmg
);
}
block_init
(
bdrv_dmg_init
);
block-nbd.c
浏览文件 @
5efa9d5a
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
#include "qemu-common.h"
#include "qemu-common.h"
#include "nbd.h"
#include "nbd.h"
#include "module.h"
#include <sys/types.h>
#include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -176,7 +177,7 @@ static int64_t nbd_getlength(BlockDriverState *bs)
...
@@ -176,7 +177,7 @@ static int64_t nbd_getlength(BlockDriverState *bs)
return
s
->
size
;
return
s
->
size
;
}
}
BlockDriver
bdrv_nbd
=
{
static
BlockDriver
bdrv_nbd
=
{
.
format_name
=
"nbd"
,
.
format_name
=
"nbd"
,
.
instance_size
=
sizeof
(
BDRVNBDState
),
.
instance_size
=
sizeof
(
BDRVNBDState
),
.
bdrv_open
=
nbd_open
,
.
bdrv_open
=
nbd_open
,
...
@@ -186,3 +187,10 @@ BlockDriver bdrv_nbd = {
...
@@ -186,3 +187,10 @@ BlockDriver bdrv_nbd = {
.
bdrv_getlength
=
nbd_getlength
,
.
bdrv_getlength
=
nbd_getlength
,
.
protocol_name
=
"nbd"
,
.
protocol_name
=
"nbd"
,
};
};
static
void
bdrv_nbd_init
(
void
)
{
bdrv_register
(
&
bdrv_nbd
);
}
block_init
(
bdrv_nbd_init
);
block-parallels.c
浏览文件 @
5efa9d5a
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
/**************************************************************/
/**************************************************************/
...
@@ -163,7 +164,7 @@ static void parallels_close(BlockDriverState *bs)
...
@@ -163,7 +164,7 @@ static void parallels_close(BlockDriverState *bs)
close
(
s
->
fd
);
close
(
s
->
fd
);
}
}
BlockDriver
bdrv_parallels
=
{
static
BlockDriver
bdrv_parallels
=
{
.
format_name
=
"parallels"
,
.
format_name
=
"parallels"
,
.
instance_size
=
sizeof
(
BDRVParallelsState
),
.
instance_size
=
sizeof
(
BDRVParallelsState
),
.
bdrv_probe
=
parallels_probe
,
.
bdrv_probe
=
parallels_probe
,
...
@@ -171,3 +172,10 @@ BlockDriver bdrv_parallels = {
...
@@ -171,3 +172,10 @@ BlockDriver bdrv_parallels = {
.
bdrv_read
=
parallels_read
,
.
bdrv_read
=
parallels_read
,
.
bdrv_close
=
parallels_close
,
.
bdrv_close
=
parallels_close
,
};
};
static
void
bdrv_parallels_init
(
void
)
{
bdrv_register
(
&
bdrv_parallels
);
}
block_init
(
bdrv_parallels_init
);
block-qcow.c
浏览文件 @
5efa9d5a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#include <zlib.h>
#include <zlib.h>
#include "aes.h"
#include "aes.h"
...
@@ -917,7 +918,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
...
@@ -917,7 +918,7 @@ static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
return
0
;
return
0
;
}
}
BlockDriver
bdrv_qcow
=
{
static
BlockDriver
bdrv_qcow
=
{
.
format_name
=
"qcow"
,
.
format_name
=
"qcow"
,
.
instance_size
=
sizeof
(
BDRVQcowState
),
.
instance_size
=
sizeof
(
BDRVQcowState
),
.
bdrv_probe
=
qcow_probe
,
.
bdrv_probe
=
qcow_probe
,
...
@@ -935,3 +936,10 @@ BlockDriver bdrv_qcow = {
...
@@ -935,3 +936,10 @@ BlockDriver bdrv_qcow = {
.
bdrv_write_compressed
=
qcow_write_compressed
,
.
bdrv_write_compressed
=
qcow_write_compressed
,
.
bdrv_get_info
=
qcow_get_info
,
.
bdrv_get_info
=
qcow_get_info
,
};
};
static
void
bdrv_qcow_init
(
void
)
{
bdrv_register
(
&
bdrv_qcow
);
}
block_init
(
bdrv_qcow_init
);
block-qcow2.c
浏览文件 @
5efa9d5a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#include <zlib.h>
#include <zlib.h>
#include "aes.h"
#include "aes.h"
...
@@ -2891,7 +2892,7 @@ static int qcow_get_buffer(BlockDriverState *bs, uint8_t *buf,
...
@@ -2891,7 +2892,7 @@ static int qcow_get_buffer(BlockDriverState *bs, uint8_t *buf,
return
ret
;
return
ret
;
}
}
BlockDriver
bdrv_qcow2
=
{
static
BlockDriver
bdrv_qcow2
=
{
.
format_name
=
"qcow2"
,
.
format_name
=
"qcow2"
,
.
instance_size
=
sizeof
(
BDRVQcowState
),
.
instance_size
=
sizeof
(
BDRVQcowState
),
.
bdrv_probe
=
qcow_probe
,
.
bdrv_probe
=
qcow_probe
,
...
@@ -2921,3 +2922,10 @@ BlockDriver bdrv_qcow2 = {
...
@@ -2921,3 +2922,10 @@ BlockDriver bdrv_qcow2 = {
.
bdrv_create2
=
qcow_create2
,
.
bdrv_create2
=
qcow_create2
,
.
bdrv_check
=
qcow_check
,
.
bdrv_check
=
qcow_check
,
};
};
static
void
bdrv_qcow2_init
(
void
)
{
bdrv_register
(
&
bdrv_qcow2
);
}
block_init
(
bdrv_qcow2_init
);
block-raw-posix.c
浏览文件 @
5efa9d5a
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "qemu-timer.h"
#include "qemu-timer.h"
#include "qemu-char.h"
#include "qemu-char.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#ifdef CONFIG_AIO
#ifdef CONFIG_AIO
#include "posix-aio-compat.h"
#include "posix-aio-compat.h"
#endif
#endif
...
@@ -845,7 +846,7 @@ static void raw_flush(BlockDriverState *bs)
...
@@ -845,7 +846,7 @@ static void raw_flush(BlockDriverState *bs)
fsync
(
s
->
fd
);
fsync
(
s
->
fd
);
}
}
BlockDriver
bdrv_raw
=
{
static
BlockDriver
bdrv_raw
=
{
.
format_name
=
"raw"
,
.
format_name
=
"raw"
,
.
instance_size
=
sizeof
(
BDRVRawState
),
.
instance_size
=
sizeof
(
BDRVRawState
),
.
bdrv_probe
=
NULL
,
/* no probe for protocols */
.
bdrv_probe
=
NULL
,
/* no probe for protocols */
...
@@ -1397,7 +1398,7 @@ static int hdev_create(const char *filename, int64_t total_size,
...
@@ -1397,7 +1398,7 @@ static int hdev_create(const char *filename, int64_t total_size,
}
}
#endif
#endif
BlockDriver
bdrv_host_device
=
{
static
BlockDriver
bdrv_host_device
=
{
.
format_name
=
"host_device"
,
.
format_name
=
"host_device"
,
.
instance_size
=
sizeof
(
BDRVRawState
),
.
instance_size
=
sizeof
(
BDRVRawState
),
.
bdrv_open
=
hdev_open
,
.
bdrv_open
=
hdev_open
,
...
@@ -1427,3 +1428,11 @@ BlockDriver bdrv_host_device = {
...
@@ -1427,3 +1428,11 @@ BlockDriver bdrv_host_device = {
.
bdrv_aio_ioctl
=
raw_aio_ioctl
,
.
bdrv_aio_ioctl
=
raw_aio_ioctl
,
#endif
#endif
};
};
static
void
bdrv_raw_init
(
void
)
{
bdrv_register
(
&
bdrv_raw
);
bdrv_register
(
&
bdrv_host_device
);
}
block_init
(
bdrv_raw_init
);
block-raw-win32.c
浏览文件 @
5efa9d5a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "qemu-common.h"
#include "qemu-common.h"
#include "qemu-timer.h"
#include "qemu-timer.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#include <windows.h>
#include <windows.h>
#include <winioctl.h>
#include <winioctl.h>
...
@@ -227,7 +228,7 @@ static int raw_create(const char *filename, int64_t total_size,
...
@@ -227,7 +228,7 @@ static int raw_create(const char *filename, int64_t total_size,
return
0
;
return
0
;
}
}
BlockDriver
bdrv_raw
=
{
static
BlockDriver
bdrv_raw
=
{
.
format_name
=
"raw"
,
.
format_name
=
"raw"
,
.
instance_size
=
sizeof
(
BDRVRawState
),
.
instance_size
=
sizeof
(
BDRVRawState
),
.
bdrv_open
=
raw_open
,
.
bdrv_open
=
raw_open
,
...
@@ -371,7 +372,7 @@ static int raw_set_locked(BlockDriverState *bs, int locked)
...
@@ -371,7 +372,7 @@ static int raw_set_locked(BlockDriverState *bs, int locked)
}
}
#endif
#endif
BlockDriver
bdrv_host_device
=
{
static
BlockDriver
bdrv_host_device
=
{
.
format_name
=
"host_device"
,
.
format_name
=
"host_device"
,
.
instance_size
=
sizeof
(
BDRVRawState
),
.
instance_size
=
sizeof
(
BDRVRawState
),
.
bdrv_open
=
hdev_open
,
.
bdrv_open
=
hdev_open
,
...
@@ -382,3 +383,11 @@ BlockDriver bdrv_host_device = {
...
@@ -382,3 +383,11 @@ BlockDriver bdrv_host_device = {
.
bdrv_write
=
raw_write
,
.
bdrv_write
=
raw_write
,
.
bdrv_getlength
=
raw_getlength
,
.
bdrv_getlength
=
raw_getlength
,
};
};
static
void
bdrv_raw_init
(
void
)
{
bdrv_register
(
&
bdrv_raw
);
bdrv_register
(
&
bdrv_host_device
);
}
block_init
(
bdrv_raw_init
);
block-vmdk.c
浏览文件 @
5efa9d5a
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
#define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
#define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
...
@@ -811,7 +812,7 @@ static void vmdk_flush(BlockDriverState *bs)
...
@@ -811,7 +812,7 @@ static void vmdk_flush(BlockDriverState *bs)
bdrv_flush
(
s
->
hd
);
bdrv_flush
(
s
->
hd
);
}
}
BlockDriver
bdrv_vmdk
=
{
static
BlockDriver
bdrv_vmdk
=
{
.
format_name
=
"vmdk"
,
.
format_name
=
"vmdk"
,
.
instance_size
=
sizeof
(
BDRVVmdkState
),
.
instance_size
=
sizeof
(
BDRVVmdkState
),
.
bdrv_probe
=
vmdk_probe
,
.
bdrv_probe
=
vmdk_probe
,
...
@@ -823,3 +824,10 @@ BlockDriver bdrv_vmdk = {
...
@@ -823,3 +824,10 @@ BlockDriver bdrv_vmdk = {
.
bdrv_flush
=
vmdk_flush
,
.
bdrv_flush
=
vmdk_flush
,
.
bdrv_is_allocated
=
vmdk_is_allocated
,
.
bdrv_is_allocated
=
vmdk_is_allocated
,
};
};
static
void
bdrv_vmdk_init
(
void
)
{
bdrv_register
(
&
bdrv_vmdk
);
}
block_init
(
bdrv_vmdk_init
);
block-vpc.c
浏览文件 @
5efa9d5a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
*/
*/
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
/**************************************************************/
/**************************************************************/
...
@@ -586,7 +587,7 @@ static void vpc_close(BlockDriverState *bs)
...
@@ -586,7 +587,7 @@ static void vpc_close(BlockDriverState *bs)
bdrv_delete
(
s
->
hd
);
bdrv_delete
(
s
->
hd
);
}
}
BlockDriver
bdrv_vpc
=
{
static
BlockDriver
bdrv_vpc
=
{
.
format_name
=
"vpc"
,
.
format_name
=
"vpc"
,
.
instance_size
=
sizeof
(
BDRVVPCState
),
.
instance_size
=
sizeof
(
BDRVVPCState
),
.
bdrv_probe
=
vpc_probe
,
.
bdrv_probe
=
vpc_probe
,
...
@@ -596,3 +597,10 @@ BlockDriver bdrv_vpc = {
...
@@ -596,3 +597,10 @@ BlockDriver bdrv_vpc = {
.
bdrv_close
=
vpc_close
,
.
bdrv_close
=
vpc_close
,
.
bdrv_create
=
vpc_create
,
.
bdrv_create
=
vpc_create
,
};
};
static
void
bdrv_vpc_init
(
void
)
{
bdrv_register
(
&
bdrv_vpc
);
}
block_init
(
bdrv_vpc_init
);
block-vvfat.c
浏览文件 @
5efa9d5a
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <dirent.h>
#include <dirent.h>
#include "qemu-common.h"
#include "qemu-common.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#ifndef S_IWGRP
#ifndef S_IWGRP
#define S_IWGRP 0
#define S_IWGRP 0
...
@@ -2776,7 +2777,7 @@ static int enable_write_target(BDRVVVFATState *s)
...
@@ -2776,7 +2777,7 @@ static int enable_write_target(BDRVVVFATState *s)
s
->
qcow_filename
=
qemu_malloc
(
1024
);
s
->
qcow_filename
=
qemu_malloc
(
1024
);
get_tmp_filename
(
s
->
qcow_filename
,
1024
);
get_tmp_filename
(
s
->
qcow_filename
,
1024
);
if
(
bdrv_create
(
&
bdrv_qcow
,
if
(
bdrv_create
(
bdrv_find_format
(
"qcow"
)
,
s
->
qcow_filename
,
s
->
sector_count
,
"fat:"
,
0
)
<
0
)
s
->
qcow_filename
,
s
->
sector_count
,
"fat:"
,
0
)
<
0
)
return
-
1
;
return
-
1
;
s
->
qcow
=
bdrv_new
(
""
);
s
->
qcow
=
bdrv_new
(
""
);
...
@@ -2806,7 +2807,7 @@ static void vvfat_close(BlockDriverState *bs)
...
@@ -2806,7 +2807,7 @@ static void vvfat_close(BlockDriverState *bs)
free
(
s
->
cluster_buffer
);
free
(
s
->
cluster_buffer
);
}
}
BlockDriver
bdrv_vvfat
=
{
static
BlockDriver
bdrv_vvfat
=
{
.
format_name
=
"vvfat"
,
.
format_name
=
"vvfat"
,
.
instance_size
=
sizeof
(
BDRVVVFATState
),
.
instance_size
=
sizeof
(
BDRVVVFATState
),
.
bdrv_open
=
vvfat_open
,
.
bdrv_open
=
vvfat_open
,
...
@@ -2817,6 +2818,13 @@ BlockDriver bdrv_vvfat = {
...
@@ -2817,6 +2818,13 @@ BlockDriver bdrv_vvfat = {
.
protocol_name
=
"fat"
,
.
protocol_name
=
"fat"
,
};
};
static
void
bdrv_vvfat_init
(
void
)
{
bdrv_register
(
&
bdrv_vvfat
);
}
block_init
(
bdrv_vvfat_init
);
#ifdef DEBUG
#ifdef DEBUG
static
void
checkpoint
(
void
)
{
static
void
checkpoint
(
void
)
{
assert
(((
mapping_t
*
)
array_get
(
&
(
vvv
->
mapping
),
0
))
->
end
==
2
);
assert
(((
mapping_t
*
)
array_get
(
&
(
vvv
->
mapping
),
0
))
->
end
==
2
);
...
...
block.c
浏览文件 @
5efa9d5a
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "qemu-common.h"
#include "qemu-common.h"
#include "monitor.h"
#include "monitor.h"
#include "block_int.h"
#include "block_int.h"
#include "module.h"
#ifdef HOST_BSD
#ifdef HOST_BSD
#include <sys/types.h>
#include <sys/types.h>
...
@@ -138,7 +139,7 @@ void path_combine(char *dest, int dest_size,
...
@@ -138,7 +139,7 @@ void path_combine(char *dest, int dest_size,
}
}
static
void
bdrv_register
(
BlockDriver
*
bdrv
)
void
bdrv_register
(
BlockDriver
*
bdrv
)
{
{
if
(
!
bdrv
->
bdrv_aio_readv
)
{
if
(
!
bdrv
->
bdrv_aio_readv
)
{
/* add AIO emulation layer */
/* add AIO emulation layer */
...
@@ -259,11 +260,11 @@ static BlockDriver *find_protocol(const char *filename)
...
@@ -259,11 +260,11 @@ static BlockDriver *find_protocol(const char *filename)
#ifdef _WIN32
#ifdef _WIN32
if
(
is_windows_drive
(
filename
)
||
if
(
is_windows_drive
(
filename
)
||
is_windows_drive_prefix
(
filename
))
is_windows_drive_prefix
(
filename
))
return
&
bdrv_raw
;
return
bdrv_find_format
(
"raw"
)
;
#endif
#endif
p
=
strchr
(
filename
,
':'
);
p
=
strchr
(
filename
,
':'
);
if
(
!
p
)
if
(
!
p
)
return
&
bdrv_raw
;
return
bdrv_find_format
(
"raw"
)
;
len
=
p
-
filename
;
len
=
p
-
filename
;
if
(
len
>
sizeof
(
protocol
)
-
1
)
if
(
len
>
sizeof
(
protocol
)
-
1
)
len
=
sizeof
(
protocol
)
-
1
;
len
=
sizeof
(
protocol
)
-
1
;
...
@@ -289,23 +290,23 @@ static BlockDriver *find_image_format(const char *filename)
...
@@ -289,23 +290,23 @@ static BlockDriver *find_image_format(const char *filename)
/* detect host devices. By convention, /dev/cdrom[N] is always
/* detect host devices. By convention, /dev/cdrom[N] is always
recognized as a host CDROM */
recognized as a host CDROM */
if
(
strstart
(
filename
,
"/dev/cdrom"
,
NULL
))
if
(
strstart
(
filename
,
"/dev/cdrom"
,
NULL
))
return
&
bdrv_host_device
;
return
bdrv_find_format
(
"host_device"
)
;
#ifdef _WIN32
#ifdef _WIN32
if
(
is_windows_drive
(
filename
))
if
(
is_windows_drive
(
filename
))
return
&
bdrv_host_device
;
return
bdrv_find_format
(
"host_device"
)
;
#else
#else
{
{
struct
stat
st
;
struct
stat
st
;
if
(
stat
(
filename
,
&
st
)
>=
0
&&
if
(
stat
(
filename
,
&
st
)
>=
0
&&
(
S_ISCHR
(
st
.
st_mode
)
||
S_ISBLK
(
st
.
st_mode
)))
{
(
S_ISCHR
(
st
.
st_mode
)
||
S_ISBLK
(
st
.
st_mode
)))
{
return
&
bdrv_host_device
;
return
bdrv_find_format
(
"host_device"
)
;
}
}
}
}
#endif
#endif
drv
=
find_protocol
(
filename
);
drv
=
find_protocol
(
filename
);
/* no need to test disk image formats for vvfat */
/* no need to test disk image formats for vvfat */
if
(
drv
==
&
bdrv_vvfat
)
if
(
strcmp
(
drv
->
format_name
,
"vvfat"
)
==
0
)
return
drv
;
return
drv
;
ret
=
bdrv_file_open
(
&
bs
,
filename
,
BDRV_O_RDONLY
);
ret
=
bdrv_file_open
(
&
bs
,
filename
,
BDRV_O_RDONLY
);
...
@@ -396,14 +397,14 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
...
@@ -396,14 +397,14 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
else
else
realpath
(
filename
,
backing_filename
);
realpath
(
filename
,
backing_filename
);
ret
=
bdrv_create2
(
&
bdrv_qcow2
,
tmp_filename
,
ret
=
bdrv_create2
(
bdrv_find_format
(
"qcow2"
)
,
tmp_filename
,
total_size
,
backing_filename
,
total_size
,
backing_filename
,
(
drv
?
drv
->
format_name
:
NULL
),
0
);
(
drv
?
drv
->
format_name
:
NULL
),
0
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
ret
;
return
ret
;
}
}
filename
=
tmp_filename
;
filename
=
tmp_filename
;
drv
=
&
bdrv_qcow2
;
drv
=
bdrv_find_format
(
"qcow2"
)
;
bs
->
is_temporary
=
1
;
bs
->
is_temporary
=
1
;
}
}
...
@@ -1494,21 +1495,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
...
@@ -1494,21 +1495,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
void
bdrv_init
(
void
)
void
bdrv_init
(
void
)
{
{
bdrv_register
(
&
bdrv_raw
);
module_call_init
(
MODULE_INIT_BLOCK
);
bdrv_register
(
&
bdrv_host_device
);
#ifndef _WIN32
bdrv_register
(
&
bdrv_cow
);
#endif
bdrv_register
(
&
bdrv_qcow
);
bdrv_register
(
&
bdrv_vmdk
);
bdrv_register
(
&
bdrv_cloop
);
bdrv_register
(
&
bdrv_dmg
);
bdrv_register
(
&
bdrv_bochs
);
bdrv_register
(
&
bdrv_vpc
);
bdrv_register
(
&
bdrv_vvfat
);
bdrv_register
(
&
bdrv_qcow2
);
bdrv_register
(
&
bdrv_parallels
);
bdrv_register
(
&
bdrv_nbd
);
}
}
void
aio_pool_init
(
AIOPool
*
pool
,
int
aiocb_size
,
void
aio_pool_init
(
AIOPool
*
pool
,
int
aiocb_size
,
...
...
block.h
浏览文件 @
5efa9d5a
...
@@ -7,20 +7,6 @@
...
@@ -7,20 +7,6 @@
/* block.c */
/* block.c */
typedef
struct
BlockDriver
BlockDriver
;
typedef
struct
BlockDriver
BlockDriver
;
extern
BlockDriver
bdrv_raw
;
extern
BlockDriver
bdrv_host_device
;
extern
BlockDriver
bdrv_cow
;
extern
BlockDriver
bdrv_qcow
;
extern
BlockDriver
bdrv_vmdk
;
extern
BlockDriver
bdrv_cloop
;
extern
BlockDriver
bdrv_dmg
;
extern
BlockDriver
bdrv_bochs
;
extern
BlockDriver
bdrv_vpc
;
extern
BlockDriver
bdrv_vvfat
;
extern
BlockDriver
bdrv_qcow2
;
extern
BlockDriver
bdrv_parallels
;
extern
BlockDriver
bdrv_nbd
;
typedef
struct
BlockDriverInfo
{
typedef
struct
BlockDriverInfo
{
/* in bytes, 0 if irrelevant */
/* in bytes, 0 if irrelevant */
int
cluster_size
;
int
cluster_size
;
...
@@ -87,6 +73,8 @@ int64_t bdrv_getlength(BlockDriverState *bs);
...
@@ -87,6 +73,8 @@ int64_t bdrv_getlength(BlockDriverState *bs);
void
bdrv_get_geometry
(
BlockDriverState
*
bs
,
uint64_t
*
nb_sectors_ptr
);
void
bdrv_get_geometry
(
BlockDriverState
*
bs
,
uint64_t
*
nb_sectors_ptr
);
void
bdrv_guess_geometry
(
BlockDriverState
*
bs
,
int
*
pcyls
,
int
*
pheads
,
int
*
psecs
);
void
bdrv_guess_geometry
(
BlockDriverState
*
bs
,
int
*
pcyls
,
int
*
pheads
,
int
*
psecs
);
int
bdrv_commit
(
BlockDriverState
*
bs
);
int
bdrv_commit
(
BlockDriverState
*
bs
);
void
bdrv_register
(
BlockDriver
*
bdrv
);
/* async block I/O */
/* async block I/O */
typedef
struct
BlockDriverAIOCB
BlockDriverAIOCB
;
typedef
struct
BlockDriverAIOCB
BlockDriverAIOCB
;
typedef
void
BlockDriverCompletionFunc
(
void
*
opaque
,
int
ret
);
typedef
void
BlockDriverCompletionFunc
(
void
*
opaque
,
int
ret
);
...
...
qemu-img.c
浏览文件 @
5efa9d5a
...
@@ -542,11 +542,11 @@ static int img_convert(int argc, char **argv)
...
@@ -542,11 +542,11 @@ static int img_convert(int argc, char **argv)
drv
=
bdrv_find_format
(
out_fmt
);
drv
=
bdrv_find_format
(
out_fmt
);
if
(
!
drv
)
if
(
!
drv
)
error
(
"Unknown file format '%s'"
,
out_fmt
);
error
(
"Unknown file format '%s'"
,
out_fmt
);
if
(
flags
&
BLOCK_FLAG_COMPRESS
&&
drv
!=
&
bdrv_qcow
&&
drv
!=
&
bdrv_qcow2
)
if
(
flags
&
BLOCK_FLAG_COMPRESS
&&
strcmp
(
drv
->
format_name
,
"qcow"
)
&&
strcmp
(
drv
->
format_name
,
"qcow2"
)
)
error
(
"Compression not supported for this file format"
);
error
(
"Compression not supported for this file format"
);
if
(
flags
&
BLOCK_FLAG_ENCRYPT
&&
drv
!=
&
bdrv_qcow
&&
drv
!=
&
bdrv_qcow2
)
if
(
flags
&
BLOCK_FLAG_ENCRYPT
&&
strcmp
(
drv
->
format_name
,
"qcow"
)
&&
strcmp
(
drv
->
format_name
,
"qcow2"
)
)
error
(
"Encryption not supported for this file format"
);
error
(
"Encryption not supported for this file format"
);
if
(
flags
&
BLOCK_FLAG_COMPAT6
&&
drv
!=
&
bdrv_vmdk
)
if
(
flags
&
BLOCK_FLAG_COMPAT6
&&
strcmp
(
drv
->
format_name
,
"vmdk"
)
)
error
(
"Alternative compatibility level not supported for this file format"
);
error
(
"Alternative compatibility level not supported for this file format"
);
if
(
flags
&
BLOCK_FLAG_ENCRYPT
&&
flags
&
BLOCK_FLAG_COMPRESS
)
if
(
flags
&
BLOCK_FLAG_ENCRYPT
&&
flags
&
BLOCK_FLAG_COMPRESS
)
error
(
"Compression and encryption not supported at the same time"
);
error
(
"Compression and encryption not supported at the same time"
);
...
@@ -655,7 +655,7 @@ static int img_convert(int argc, char **argv)
...
@@ -655,7 +655,7 @@ static int img_convert(int argc, char **argv)
if
(
n
>
bs_offset
+
bs_sectors
-
sector_num
)
if
(
n
>
bs_offset
+
bs_sectors
-
sector_num
)
n
=
bs_offset
+
bs_sectors
-
sector_num
;
n
=
bs_offset
+
bs_sectors
-
sector_num
;
if
(
drv
!=
&
bdrv_host_device
)
{
if
(
strcmp
(
drv
->
format_name
,
"host_device"
)
)
{
if
(
!
bdrv_is_allocated
(
bs
[
bs_i
],
sector_num
-
bs_offset
,
if
(
!
bdrv_is_allocated
(
bs
[
bs_i
],
sector_num
-
bs_offset
,
n
,
&
n1
))
{
n
,
&
n1
))
{
sector_num
+=
n1
;
sector_num
+=
n1
;
...
@@ -682,7 +682,7 @@ static int img_convert(int argc, char **argv)
...
@@ -682,7 +682,7 @@ static int img_convert(int argc, char **argv)
If the output is to a host device, we also write out
If the output is to a host device, we also write out
sectors that are entirely 0, since whatever data was
sectors that are entirely 0, since whatever data was
already there is garbage, not 0s. */
already there is garbage, not 0s. */
if
(
drv
==
&
bdrv_host_device
||
out_baseimg
||
if
(
strcmp
(
drv
->
format_name
,
"host_device"
)
==
0
||
out_baseimg
||
is_allocated_sectors
(
buf1
,
n
,
&
n1
))
{
is_allocated_sectors
(
buf1
,
n
,
&
n1
))
{
if
(
bdrv_write
(
out_bs
,
sector_num
,
buf1
,
n1
)
<
0
)
if
(
bdrv_write
(
out_bs
,
sector_num
,
buf1
,
n1
)
<
0
)
error
(
"error while writing"
);
error
(
"error while writing"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录