提交 6227a220 编写于 作者: O Osier Yang

virsh: A bit smarter attach-disk

Detects the file type of source path if no "--sourcetype" and
"driver" is specified, instead of always set the disk type as
"block".
上级 68fd6a3b
......@@ -14428,6 +14428,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml;
struct stat st;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
......@@ -14458,8 +14459,12 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (!stype) {
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap"))) {
isFile = true;
} else {
if (source && !stat(source, &st))
isFile = S_ISREG(st.st_mode) ? true : false;
}
} else if (STREQ(stype, "file")) {
isFile = true;
} else if (STRNEQ(stype, "block")) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册