.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)")
.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}
};
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 ||
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"));
expected.
=item B<attach-disk> I<domain> I<source> I<target>
+[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
[I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
[I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
[I<--serial serial>] [I<--shareable>] [I<--rawio>] [I<--address address>]
within the existing virtual cdrom or floppy device; consider using
B<update-device> for this usage instead.
I<mode> can specify the two specific mode I<readonly> or I<shareable>.
-I<--config> indicates the changes will affect the next boot of the domain,
-for compatibility purposes, I<--persistent> is alias of I<--config>.
I<sourcetype> can indicate the type of source (block|file)
I<cache> can be one of "default", "none", "writethrough", "writeback",
"directsync" or "unsafe".
If I<--print-xml> is specified, then the XML of the disk that would be attached
is printed instead.
+If I<--live> is specified, affect a running domain.
+If I<--config> is specified, affect the next startup of a persistent domain.
+If I<--current> is specified, affect the current domain state.
+Both I<--live> and I<--config> flags may be given, but I<--current> is
+exclusive. When no flag is specified legacy API is used whose behavior depends
+on the hypervisor driver.
+
+For compatibility purposes, I<--persistent> behaves like I<--config> for
+an offline domain, and like I<--live> I<--config> for a running domain.
+
=item B<attach-interface> I<domain> I<type> I<source>
[I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>]
[I<--config>] [I<--inbound average,peak,burst>] [I<--outbound average,peak,burst>]