Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b8635011
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看板
提交
b8635011
编写于
4月 20, 2016
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: disk: Split out parsing of disk <driver> element
上级
a309f575
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
154 addition
and
137 deletion
+154
-137
src/conf/domain_conf.c
src/conf/domain_conf.c
+154
-137
未找到文件。
src/conf/domain_conf.c
浏览文件 @
b8635011
...
...
@@ -6915,6 +6915,157 @@ virDomainDiskDefValidate(const virDomainDiskDef *def)
}
static int
virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
xmlNodePtr cur)
{
char *driverName = NULL;
char *driverType = NULL;
char *cachetag = NULL;
char *error_policy = NULL;
char *rerror_policy = NULL;
char *iotag = NULL;
char *ioeventfd = NULL;
char *event_idx = NULL;
char *copy_on_read = NULL;
char *discard = NULL;
char *driverIOThread = NULL;
int ret = -1;
driverName = virXMLPropString(cur, "name");
driverType = virXMLPropString(cur, "type");
if (STREQ_NULLABLE(driverType, "aio")) {
/* In-place conversion to "raw", for Xen back-compat */
driverType[0] = 'r';
driverType[1] = 'a';
driverType[2] = 'w';
}
cachetag = virXMLPropString(cur, "cache");
error_policy = virXMLPropString(cur, "error_policy");
rerror_policy = virXMLPropString(cur, "rerror_policy");
iotag = virXMLPropString(cur, "io");
ioeventfd = virXMLPropString(cur, "ioeventfd");
event_idx = virXMLPropString(cur, "event_idx");
copy_on_read = virXMLPropString(cur, "copy_on_read");
discard = virXMLPropString(cur, "discard");
driverIOThread = virXMLPropString(cur, "iothread");
def->src->driverName = driverName;
driverName = NULL;
if (cachetag &&
(def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk cache mode '%s'"), cachetag);
goto cleanup;
}
if (error_policy &&
(def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk error policy '%s'"), error_policy);
goto cleanup;
}
if (rerror_policy &&
(((def->rerror_policy
= virDomainDiskErrorPolicyTypeFromString(rerror_policy)) <= 0) ||
(def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk read error policy '%s'"),
rerror_policy);
goto cleanup;
}
if (iotag) {
if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) < 0 ||
def->iomode == VIR_DOMAIN_DISK_IO_DEFAULT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk io mode '%s'"), iotag);
goto cleanup;
}
}
if (ioeventfd) {
int val;
if ((val = virTristateSwitchTypeFromString(ioeventfd)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk ioeventfd mode '%s'"),
ioeventfd);
goto cleanup;
}
def->ioeventfd = val;
}
if (event_idx) {
int idx;
if ((idx = virTristateSwitchTypeFromString(event_idx)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk event_idx mode '%s'"),
event_idx);
goto cleanup;
}
def->event_idx = idx;
}
if (copy_on_read) {
int cor;
if ((cor = virTristateSwitchTypeFromString(copy_on_read)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk copy_on_read mode '%s'"),
copy_on_read);
goto cleanup;
}
def->copy_on_read = cor;
}
if (discard) {
if ((def->discard = virDomainDiskDiscardTypeFromString(discard)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk discard mode '%s'"), discard);
goto cleanup;
}
}
if (driverIOThread) {
if (virStrToLong_uip(driverIOThread, NULL, 10, &def->iothread) < 0 ||
def->iothread == 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid iothread attribute in disk driver "
"element: %s"), driverIOThread);
goto cleanup;
}
}
if (driverType) {
def->src->format = virStorageFileFormatTypeFromString(driverType);
if (def->src->format <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown driver format value '%s'"),
driverType);
goto cleanup;
}
}
ret = 0;
cleanup:
VIR_FREE(driverType);
VIR_FREE(driverName);
VIR_FREE(cachetag);
VIR_FREE(error_policy);
VIR_FREE(rerror_policy);
VIR_FREE(iotag);
VIR_FREE(ioeventfd);
VIR_FREE(event_idx);
VIR_FREE(copy_on_read);
VIR_FREE(discard);
VIR_FREE(driverIOThread);
return ret;
}
#define VENDOR_LEN 8
#define PRODUCT_LEN 16
...
...
@@ -6939,19 +7090,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
char *snapshot = NULL;
char *rawio = NULL;
char *sgio = NULL;
char *driverName = NULL;
char *driverType = NULL;
bool source = false;
char *target = NULL;
char *bus = NULL;
char *cachetag = NULL;
char *error_policy = NULL;
char *rerror_policy = NULL;
char *iotag = NULL;
char *ioeventfd = NULL;
char *event_idx = NULL;
char *copy_on_read = NULL;
char *driverIOThread = NULL;
char *devaddr = NULL;
virStorageEncryptionPtr encryption = NULL;
char *serial = NULL;
...
...
@@ -6964,7 +7105,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
char *wwn = NULL;
char *vendor = NULL;
char *product = NULL;
char *discard = NULL;
char *domain_name = NULL;
int expected_secret_usage = -1;
int auth_secret_usage = -1;
...
...
@@ -7050,25 +7190,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
physical_block_size);
goto error;
}
} else if (!driverName &&
} else if (!d
ef->src->d
riverName &&
xmlStrEqual(cur->name, BAD_CAST "driver")) {
driverName = virXMLPropString(cur, "name");
driverType = virXMLPropString(cur, "type");
if (STREQ_NULLABLE(driverType, "aio")) {
/* In-place conversion to "raw", for Xen back-compat */
driverType[0] = 'r';
driverType[1] = 'a';
driverType[2] = 'w';
}
cachetag = virXMLPropString(cur, "cache");
error_policy = virXMLPropString(cur, "error_policy");
rerror_policy = virXMLPropString(cur, "rerror_policy");
iotag = virXMLPropString(cur, "io");
ioeventfd = virXMLPropString(cur, "ioeventfd");
event_idx = virXMLPropString(cur, "event_idx");
copy_on_read = virXMLPropString(cur, "copy_on_read");
discard = virXMLPropString(cur, "discard");
driverIOThread = virXMLPropString(cur, "iothread");
if (virDomainDiskDefDriverParseXML(def, cur) < 0)
goto error;
} else if (!def->mirror &&
xmlStrEqual(cur->name, BAD_CAST "mirror") &&
!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) {
...
...
@@ -7350,91 +7475,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
if (cachetag &&
(def->cachemode = virDomainDiskCacheTypeFromString(cachetag)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk cache mode '%s'"), cachetag);
goto error;
}
if (error_policy &&
(def->error_policy = virDomainDiskErrorPolicyTypeFromString(error_policy)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk error policy '%s'"), error_policy);
goto error;
}
if (rerror_policy &&
(((def->rerror_policy
= virDomainDiskErrorPolicyTypeFromString(rerror_policy)) <= 0) ||
(def->rerror_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk read error policy '%s'"),
rerror_policy);
goto error;
}
if (iotag) {
if ((def->iomode = virDomainDiskIoTypeFromString(iotag)) < 0 ||
def->iomode == VIR_DOMAIN_DISK_IO_DEFAULT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk io mode '%s'"), iotag);
goto error;
}
}
if (ioeventfd) {
int val;
if ((val = virTristateSwitchTypeFromString(ioeventfd)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk ioeventfd mode '%s'"),
ioeventfd);
goto error;
}
def->ioeventfd = val;
}
if (event_idx) {
int idx;
if ((idx = virTristateSwitchTypeFromString(event_idx)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk event_idx mode '%s'"),
event_idx);
goto error;
}
def->event_idx = idx;
}
if (copy_on_read) {
int cor;
if ((cor = virTristateSwitchTypeFromString(copy_on_read)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk copy_on_read mode '%s'"),
copy_on_read);
goto error;
}
def->copy_on_read = cor;
}
if (discard) {
if ((def->discard = virDomainDiskDiscardTypeFromString(discard)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk discard mode '%s'"), discard);
goto error;
}
}
if (driverIOThread) {
if (virStrToLong_uip(driverIOThread, NULL, 10, &def->iothread) < 0 ||
def->iothread == 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid iothread attribute in disk driver "
"element: %s"), driverIOThread);
goto error;
}
}
if (devaddr) {
if (virDomainParseLegacyDeviceAddress(devaddr,
&def->info.addr.pci) < 0) {
...
...
@@ -7483,8 +7523,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
target = NULL;
def->src->auth = authdef;
authdef = NULL;
def->src->driverName = driverName;
driverName = NULL;
def->src->encryption = encryption;
encryption = NULL;
def->domain_name = domain_name;
...
...
@@ -7498,16 +7536,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
def->product = product;
product = NULL;
if (driverType) {
def->src->format = virStorageFileFormatTypeFromString(driverType);
if (def->src->format <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown driver format value '%s'"),
driverType);
goto error;
}
}
if (!(flags & VIR_DOMAIN_DEF_PARSE_DISK_SOURCE)) {
if (virDomainDiskBackingStoreParse(ctxt, def->src) < 0)
goto error;
...
...
@@ -7527,17 +7555,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
VIR_FREE(removable);
VIR_FREE(device);
virStorageAuthDefFree(authdef);
VIR_FREE(driverType);
VIR_FREE(driverName);
VIR_FREE(cachetag);
VIR_FREE(error_policy);
VIR_FREE(rerror_policy);
VIR_FREE(iotag);
VIR_FREE(ioeventfd);
VIR_FREE(event_idx);
VIR_FREE(copy_on_read);
VIR_FREE(discard);
VIR_FREE(driverIOThread);
VIR_FREE(devaddr);
VIR_FREE(serial);
virStorageEncryptionFree(encryption);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录