Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6298f74d
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6298f74d
编写于
5月 16, 2013
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage: add support for creating qcow2 images with extensions
Add -o compat= and -o lazy_refcounts options for qemu-img.
上级
31d42506
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
166 addition
and
7 deletion
+166
-7
src/storage/storage_backend.c
src/storage/storage_backend.c
+56
-7
tests/storagevolxml2argvdata/qcow2-1.1.argv
tests/storagevolxml2argvdata/qcow2-1.1.argv
+1
-0
tests/storagevolxml2argvdata/qcow2-lazy.argv
tests/storagevolxml2argvdata/qcow2-lazy.argv
+1
-0
tests/storagevolxml2argvdata/vol-qcow2-0.10-lazy.xml
tests/storagevolxml2argvdata/vol-qcow2-0.10-lazy.xml
+35
-0
tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
+32
-0
tests/storagevolxml2argvdata/vol-qcow2-lazy.xml
tests/storagevolxml2argvdata/vol-qcow2-lazy.xml
+35
-0
tests/storagevolxml2argvtest.c
tests/storagevolxml2argvtest.c
+6
-0
未找到文件。
src/storage/storage_backend.c
浏览文件 @
6298f74d
...
@@ -633,9 +633,15 @@ static int
...
@@ -633,9 +633,15 @@ static int
virStorageBackendCreateQemuImgOpts
(
char
**
opts
,
virStorageBackendCreateQemuImgOpts
(
char
**
opts
,
const
char
*
backingType
,
const
char
*
backingType
,
bool
encryption
,
bool
encryption
,
bool
preallocate
)
bool
preallocate
,
int
format
,
const
char
*
compat
,
virBitmapPtr
features
)
{
{
virBuffer
buf
=
VIR_BUFFER_INITIALIZER
;
virBuffer
buf
=
VIR_BUFFER_INITIALIZER
;
bool
b
;
int
i
;
if
(
backingType
)
if
(
backingType
)
virBufferAsprintf
(
&
buf
,
"backing_fmt=%s,"
,
backingType
);
virBufferAsprintf
(
&
buf
,
"backing_fmt=%s,"
,
backingType
);
if
(
encryption
)
if
(
encryption
)
...
@@ -643,16 +649,46 @@ virStorageBackendCreateQemuImgOpts(char **opts,
...
@@ -643,16 +649,46 @@ virStorageBackendCreateQemuImgOpts(char **opts,
if
(
preallocate
)
if
(
preallocate
)
virBufferAddLit
(
&
buf
,
"preallocation=metadata,"
);
virBufferAddLit
(
&
buf
,
"preallocation=metadata,"
);
if
(
compat
)
virBufferAsprintf
(
&
buf
,
"compat=%s,"
,
compat
);
if
(
features
&&
format
==
VIR_STORAGE_FILE_QCOW2
)
{
for
(
i
=
0
;
i
<
VIR_STORAGE_FILE_FEATURE_LAST
;
i
++
)
{
ignore_value
(
virBitmapGetBit
(
features
,
i
,
&
b
));
if
(
b
)
{
switch
((
enum
virStorageFileFeature
)
i
)
{
case
VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS
:
if
(
STREQ_NULLABLE
(
compat
,
"0.10"
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"Feature %s not supported with compat"
" level %s"
),
virStorageFileFeatureTypeToString
(
i
),
compat
);
goto
error
;
}
break
;
case
VIR_STORAGE_FILE_FEATURE_NONE
:
case
VIR_STORAGE_FILE_FEATURE_LAST
:
;
}
virBufferAsprintf
(
&
buf
,
"%s,"
,
virStorageFileFeatureTypeToString
(
i
));
}
}
}
virBufferTrim
(
&
buf
,
","
,
-
1
);
virBufferTrim
(
&
buf
,
","
,
-
1
);
if
(
virBufferError
(
&
buf
))
{
if
(
virBufferError
(
&
buf
))
virBufferFreeAndReset
(
&
buf
);
goto
no_memory
;
virReportOOMError
();
return
-
1
;
}
*
opts
=
virBufferContentAndReset
(
&
buf
);
*
opts
=
virBufferContentAndReset
(
&
buf
);
return
0
;
return
0
;
no_memory:
virReportOOMError
();
error:
virBufferFreeAndReset
(
&
buf
);
return
-
1
;
}
}
virCommandPtr
virCommandPtr
...
@@ -695,6 +731,16 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
...
@@ -695,6 +731,16 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
_
(
"metadata preallocation only available with qcow2"
));
_
(
"metadata preallocation only available with qcow2"
));
return
NULL
;
return
NULL
;
}
}
if
(
vol
->
target
.
compat
&&
vol
->
target
.
format
!=
VIR_STORAGE_FILE_QCOW2
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"compatibility option only available with qcow2"
));
return
NULL
;
}
if
(
vol
->
target
.
features
&&
vol
->
target
.
format
!=
VIR_STORAGE_FILE_QCOW2
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"format features only available with qcow2"
));
return
NULL
;
}
if
(
inputvol
)
{
if
(
inputvol
)
{
if
(
!
(
inputPath
=
inputvol
->
target
.
path
))
{
if
(
!
(
inputPath
=
inputvol
->
target
.
path
))
{
...
@@ -816,7 +862,10 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
...
@@ -816,7 +862,10 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
if
(
imgformat
==
QEMU_IMG_BACKING_FORMAT_OPTIONS
)
{
if
(
imgformat
==
QEMU_IMG_BACKING_FORMAT_OPTIONS
)
{
if
(
virStorageBackendCreateQemuImgOpts
(
&
opts
,
if
(
virStorageBackendCreateQemuImgOpts
(
&
opts
,
backing
?
backingType
:
NULL
,
backing
?
backingType
:
NULL
,
do_encryption
,
preallocate
)
<
0
)
do_encryption
,
preallocate
,
vol
->
target
.
format
,
vol
->
target
.
compat
,
vol
->
target
.
features
)
<
0
)
return
NULL
;
return
NULL
;
if
(
opts
)
if
(
opts
)
virCommandAddArgList
(
cmd
,
"-o"
,
opts
,
NULL
);
virCommandAddArgList
(
cmd
,
"-o"
,
opts
,
NULL
);
...
...
tests/storagevolxml2argvdata/qcow2-1.1.argv
0 → 100644
浏览文件 @
6298f74d
qemu-img create -f qcow2 -b /dev/null -o backing_fmt=raw,encryption=on,compat=1.1 /var/lib/libvirt/images/OtherDemo.img 5242880K
tests/storagevolxml2argvdata/qcow2-lazy.argv
0 → 100644
浏览文件 @
6298f74d
qemu-img create -f qcow2 -b /dev/null -o backing_fmt=raw,encryption=on,compat=1.1,lazy_refcounts /var/lib/libvirt/images/OtherDemo.img 5242880K
tests/storagevolxml2argvdata/vol-qcow2-0.10-lazy.xml
0 → 100644
浏览文件 @
6298f74d
<volume>
<name>
OtherDemo.img
</name>
<key>
/var/lib/libvirt/images/OtherDemo.img
</key>
<source>
</source>
<capacity
unit=
"G"
>
5
</capacity>
<allocation>
294912
</allocation>
<target>
<path>
/var/lib/libvirt/images/OtherDemo.img
</path>
<format
type=
'qcow2'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
<encryption
format=
'qcow'
>
<secret
type=
'passphrase'
uuid=
'e78d4b51-a2af-485f-b0f5-afca709a80f4'
/>
</encryption>
<compat>
0.10
</compat>
<features>
<lazy_refcounts/>
</features>
</target>
<backingStore>
<path>
/dev/null
</path>
<format
type=
'raw'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
</backingStore>
</volume>
tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
0 → 100644
浏览文件 @
6298f74d
<volume>
<name>
OtherDemo.img
</name>
<key>
/var/lib/libvirt/images/OtherDemo.img
</key>
<source>
</source>
<capacity
unit=
"G"
>
5
</capacity>
<allocation>
294912
</allocation>
<target>
<path>
/var/lib/libvirt/images/OtherDemo.img
</path>
<format
type=
'qcow2'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
<encryption
format=
'qcow'
>
<secret
type=
'passphrase'
uuid=
'e78d4b51-a2af-485f-b0f5-afca709a80f4'
/>
</encryption>
<features/>
</target>
<backingStore>
<path>
/dev/null
</path>
<format
type=
'raw'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
</backingStore>
</volume>
tests/storagevolxml2argvdata/vol-qcow2-lazy.xml
0 → 100644
浏览文件 @
6298f74d
<volume>
<name>
OtherDemo.img
</name>
<key>
/var/lib/libvirt/images/OtherDemo.img
</key>
<source>
</source>
<capacity
unit=
"G"
>
5
</capacity>
<allocation>
294912
</allocation>
<target>
<path>
/var/lib/libvirt/images/OtherDemo.img
</path>
<format
type=
'qcow2'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
<encryption
format=
'qcow'
>
<secret
type=
'passphrase'
uuid=
'e78d4b51-a2af-485f-b0f5-afca709a80f4'
/>
</encryption>
<compat>
1.1
</compat>
<features>
<lazy_refcounts/>
</features>
</target>
<backingStore>
<path>
/dev/null
</path>
<format
type=
'raw'
/>
<permissions>
<mode>
0644
</mode>
<owner>
0
</owner>
<group>
0
</group>
<label>
unconfined_u:object_r:virt_image_t:s0
</label>
</permissions>
</backingStore>
</volume>
tests/storagevolxml2argvtest.c
浏览文件 @
6298f74d
...
@@ -188,6 +188,12 @@ mymain(void)
...
@@ -188,6 +188,12 @@ mymain(void)
"qcow2-nobacking-none"
,
0
,
FMT_NONE
);
"qcow2-nobacking-none"
,
0
,
FMT_NONE
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
"vol-file"
,
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-nobacking"
,
"vol-file"
,
"qcow2-nobacking-convert-none"
,
0
,
FMT_NONE
);
"qcow2-nobacking-convert-none"
,
0
,
FMT_NONE
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-lazy"
,
NULL
,
"qcow2-lazy"
,
0
,
FMT_OPTIONS
);
DO_TEST
(
false
,
"pool-dir"
,
"vol-qcow2-1.1"
,
NULL
,
"qcow2-1.1"
,
0
,
FMT_OPTIONS
);
DO_TEST
(
true
,
"pool-dir"
,
"vol-qcow2-0.10-lazy"
,
NULL
,
"qcow2-0.10-lazy"
,
0
,
FMT_OPTIONS
);
return
ret
==
0
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
return
ret
==
0
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录