mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 14:09:22 +00:00
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".
This commit is contained in:
parent
68fd6a3b34
commit
6227a220cc
@ -14428,6 +14428,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *stype = NULL;
|
const char *stype = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *xml;
|
char *xml;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -14458,8 +14459,12 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!stype) {
|
if (!stype) {
|
||||||
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
|
if (driver && (STREQ(driver, "file") || STREQ(driver, "tap"))) {
|
||||||
isFile = true;
|
isFile = true;
|
||||||
|
} else {
|
||||||
|
if (source && !stat(source, &st))
|
||||||
|
isFile = S_ISREG(st.st_mode) ? true : false;
|
||||||
|
}
|
||||||
} else if (STREQ(stype, "file")) {
|
} else if (STREQ(stype, "file")) {
|
||||||
isFile = true;
|
isFile = true;
|
||||||
} else if (STRNEQ(stype, "block")) {
|
} else if (STRNEQ(stype, "block")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user