summaryrefslogtreecommitdiff
path: root/tools/virsh-domain.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/virsh-domain.c')
-rw-r--r--tools/virsh-domain.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e354e446f9..cc6640c052 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -299,14 +299,6 @@ static const vshCmdOptDef opts_attach_disk[] = {
.type = VSH_OT_STRING,
.help = N_("mode of device reading and writing")
},
- {.name = "persistent",
- .type = VSH_OT_ALIAS,
- .help = "config"
- },
- {.name = "config",
- .type = VSH_OT_BOOL,
- .help = N_("affect next boot")
- },
{.name = "sourcetype",
.type = VSH_OT_STRING,
.help = N_("type of source (block|file)")
@@ -335,7 +327,22 @@ static const vshCmdOptDef opts_attach_disk[] = {
.type = VSH_OT_BOOL,
.help = N_("print XML document rather than attach the disk")
},
-
+ {.name = "persistent",
+ .type = VSH_OT_BOOL,
+ .help = N_("make live change persistent")
+ },
+ {.name = "config",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect next boot")
+ },
+ {.name = "live",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect running domain")
+ },
+ {.name = "current",
+ .type = VSH_OT_BOOL,
+ .help = N_("affect current domain")
+ },
{.name = NULL}
};
@@ -496,15 +503,33 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
struct DiskAddress diskAddr;
bool isFile = false, functionReturn = false;
int ret;
- unsigned int flags;
+ unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *xml = NULL;
struct stat st;
+ bool current = vshCommandOptBool(cmd, "current");
+ bool config = vshCommandOptBool(cmd, "config");
+ bool live = vshCommandOptBool(cmd, "live");
+ bool persistent = vshCommandOptBool(cmd, "persistent");
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
+
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+ if (config || persistent)
+ flags |= VIR_DOMAIN_AFFECT_CONFIG;
+ if (live)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
+ if (persistent &&
+ virDomainIsActive(dom) == 1)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+
if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||
@@ -635,14 +660,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (vshCommandOptBool(cmd, "config")) {
- flags = VIR_DOMAIN_AFFECT_CONFIG;
- if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
+ if (flags)
ret = virDomainAttachDeviceFlags(dom, xml, flags);
- } else {
+ else
ret = virDomainAttachDevice(dom, xml);
- }
if (ret != 0) {
vshError(ctl, "%s", _("Failed to attach disk"));