Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a05b0fc1
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看板
提交
a05b0fc1
编写于
4月 05, 2013
作者:
O
Osier Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: New helper virDomainDiskSourceDefFormat to format the disk source
The code to format disk source is long enough to have a helper.
上级
f5a61087
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
92 addition
and
82 deletion
+92
-82
src/conf/domain_conf.c
src/conf/domain_conf.c
+92
-82
未找到文件。
src/conf/domain_conf.c
浏览文件 @
a05b0fc1
...
...
@@ -12848,6 +12848,7 @@ virDomainDiskGeometryDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
}
static void
virDomainDiskBlockIoDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def)
...
...
@@ -12869,6 +12870,95 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf,
}
}
static int
virDomainDiskSourceDefFormat(virBufferPtr buf,
virDomainDiskDefPtr def)
{
int n;
const char *startupPolicy = virDomainStartupPolicyTypeToString(def->startupPolicy);
if (def->src || def->nhosts > 0 ||
def->startupPolicy) {
switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE:
virBufferAddLit(buf," <source");
if (def->src)
virBufferEscapeString(buf, " file='%s'", def->src);
if (def->startupPolicy)
virBufferEscapeString(buf, " startupPolicy='%s'",
startupPolicy);
if (def->nseclabels) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8);
for (n = 0; n < def->nseclabels; n++)
virSecurityDeviceLabelDefFormat(buf, def->seclabels[n]);
virBufferAdjustIndent(buf, -8);
virBufferAddLit(buf, " </source>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
break;
case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " <source dev='%s'",
def->src);
if (def->nseclabels) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8);
for (n = 0; n < def->nseclabels; n++)
virSecurityDeviceLabelDefFormat(buf, def->seclabels[n]);
virBufferAdjustIndent(buf, -8);
virBufferAddLit(buf, " </source>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
break;
case VIR_DOMAIN_DISK_TYPE_DIR:
virBufferEscapeString(buf, " <source dir='%s'/>\n",
def->src);
break;
case VIR_DOMAIN_DISK_TYPE_NETWORK:
virBufferAsprintf(buf, " <source protocol='%s'",
virDomainDiskProtocolTypeToString(def->protocol));
if (def->src) {
virBufferEscapeString(buf, " name='%s'", def->src);
}
if (def->nhosts == 0) {
virBufferAddLit(buf, "/>\n");
} else {
int i;
virBufferAddLit(buf, ">\n");
for (i = 0; i < def->nhosts; i++) {
virBufferAddLit(buf, " <host");
if (def->hosts[i].name) {
virBufferEscapeString(buf, " name='%s'", def->hosts[i].name);
}
if (def->hosts[i].port) {
virBufferEscapeString(buf, " port='%s'",
def->hosts[i].port);
}
if (def->hosts[i].transport) {
virBufferAsprintf(buf, " transport='%s'",
virDomainDiskProtocolTransportTypeToString(def->hosts[i].transport));
}
if (def->hosts[i].socket) {
virBufferEscapeString(buf, " socket='%s'", def->hosts[i].socket);
}
virBufferAddLit(buf, "/>\n");
}
virBufferAddLit(buf, " </source>\n");
}
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected disk type %s"),
virDomainDiskTypeToString(def->type));
return -1;
}
}
return 0;
}
static int
virDomainDiskDefFormat(virBufferPtr buf,
...
...
@@ -12885,10 +12975,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
const char *ioeventfd = virDomainIoEventFdTypeToString(def->ioeventfd);
const char *event_idx = virDomainVirtioEventIdxTypeToString(def->event_idx);
const char *copy_on_read = virDomainVirtioEventIdxTypeToString(def->copy_on_read);
const char *startupPolicy = virDomainStartupPolicyTypeToString(def->startupPolicy);
const char *sgio = virDomainDiskSGIOTypeToString(def->sgio);
int n;
char uuidstr[VIR_UUID_STRING_BUFLEN];
if (!type) {
...
...
@@ -12987,86 +13075,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
virBufferAddLit(buf, " </auth>\n");
}
if (def->src || def->nhosts > 0 ||
def->startupPolicy) {
switch (def->type) {
case VIR_DOMAIN_DISK_TYPE_FILE:
virBufferAddLit(buf," <source");
if (def->src)
virBufferEscapeString(buf, " file='%s'", def->src);
if (def->startupPolicy)
virBufferEscapeString(buf, " startupPolicy='%s'",
startupPolicy);
if (def->nseclabels) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8);
for (n = 0; n < def->nseclabels; n++)
virSecurityDeviceLabelDefFormat(buf, def->seclabels[n]);
virBufferAdjustIndent(buf, -8);
virBufferAddLit(buf, " </source>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
break;
case VIR_DOMAIN_DISK_TYPE_BLOCK:
virBufferEscapeString(buf, " <source dev='%s'",
def->src);
if (def->nseclabels) {
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 8);
for (n = 0; n < def->nseclabels; n++)
virSecurityDeviceLabelDefFormat(buf, def->seclabels[n]);
virBufferAdjustIndent(buf, -8);
virBufferAddLit(buf, " </source>\n");
} else {
virBufferAddLit(buf, "/>\n");
}
break;
case VIR_DOMAIN_DISK_TYPE_DIR:
virBufferEscapeString(buf, " <source dir='%s'/>\n",
def->src);
break;
case VIR_DOMAIN_DISK_TYPE_NETWORK:
virBufferAsprintf(buf, " <source protocol='%s'",
virDomainDiskProtocolTypeToString(def->protocol));
if (def->src) {
virBufferEscapeString(buf, " name='%s'", def->src);
}
if (def->nhosts == 0) {
virBufferAddLit(buf, "/>\n");
} else {
int i;
virBufferAddLit(buf, ">\n");
for (i = 0; i < def->nhosts; i++) {
virBufferAddLit(buf, " <host");
if (def->hosts[i].name) {
virBufferEscapeString(buf, " name='%s'", def->hosts[i].name);
}
if (def->hosts[i].port) {
virBufferEscapeString(buf, " port='%s'",
def->hosts[i].port);
}
if (def->hosts[i].transport) {
virBufferAsprintf(buf, " transport='%s'",
virDomainDiskProtocolTransportTypeToString(def->hosts[i].transport));
}
if (def->hosts[i].socket) {
virBufferEscapeString(buf, " socket='%s'", def->hosts[i].socket);
}
virBufferAddLit(buf, "/>\n");
}
virBufferAddLit(buf, " </source>\n");
}
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected disk type %s"),
virDomainDiskTypeToString(def->type));
return -1;
}
}
if (virDomainDiskSourceDefFormat(buf, def) < 0)
return -1;
virDomainDiskGeometryDefFormat(buf, def);
virDomainDiskBlockIoDefFormat(buf, def);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录