mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Expose new virDomainFSFreeze and virDomainFSThaw API
These are exposed under domfsfreeze command and domfsthaw command. Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
This commit is contained in:
parent
4acccdf13c
commit
061c6347e4
@ -11397,6 +11397,120 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const vshCmdInfo info_domfsfreeze[] = {
|
||||||
|
{.name = "help",
|
||||||
|
.data = N_("Freeze domain's mounted filesystems.")
|
||||||
|
},
|
||||||
|
{.name = "desc",
|
||||||
|
.data = N_("Freeze domain's mounted filesystems.")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_domfsfreeze[] = {
|
||||||
|
{.name = "domain",
|
||||||
|
.type = VSH_OT_DATA,
|
||||||
|
.flags = VSH_OFLAG_REQ,
|
||||||
|
.help = N_("domain name, id or uuid")
|
||||||
|
},
|
||||||
|
{.name = "mountpoint",
|
||||||
|
.type = VSH_OT_ARGV,
|
||||||
|
.help = N_("mountpoint path to be frozen")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
static bool
|
||||||
|
cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
|
||||||
|
{
|
||||||
|
virDomainPtr dom = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
const vshCmdOpt *opt = NULL;
|
||||||
|
const char **mountpoints = NULL;
|
||||||
|
size_t nmountpoints = 0;
|
||||||
|
|
||||||
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while ((opt = vshCommandOptArgv(cmd, opt))) {
|
||||||
|
if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
|
||||||
|
vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
mountpoints[nmountpoints-1] = opt->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
vshError(ctl, _("Unable to freeze filesystems"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
vshPrint(ctl, _("Froze %d filesystem(s)\n"), ret);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(mountpoints);
|
||||||
|
virDomainFree(dom);
|
||||||
|
return ret >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const vshCmdInfo info_domfsthaw[] = {
|
||||||
|
{.name = "help",
|
||||||
|
.data = N_("Thaw domain's mounted filesystems.")
|
||||||
|
},
|
||||||
|
{.name = "desc",
|
||||||
|
.data = N_("Thaw domain's mounted filesystems.")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_domfsthaw[] = {
|
||||||
|
{.name = "domain",
|
||||||
|
.type = VSH_OT_DATA,
|
||||||
|
.flags = VSH_OFLAG_REQ,
|
||||||
|
.help = N_("domain name, id or uuid")
|
||||||
|
},
|
||||||
|
{.name = "mountpoint",
|
||||||
|
.type = VSH_OT_ARGV,
|
||||||
|
.help = N_("mountpoint path to be thawed")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
static bool
|
||||||
|
cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
|
||||||
|
{
|
||||||
|
virDomainPtr dom = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
const vshCmdOpt *opt = NULL;
|
||||||
|
const char **mountpoints = NULL;
|
||||||
|
size_t nmountpoints = 0;
|
||||||
|
|
||||||
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while ((opt = vshCommandOptArgv(cmd, opt))) {
|
||||||
|
if (VIR_EXPAND_N(mountpoints, nmountpoints, 1) < 0) {
|
||||||
|
vshError(ctl, _("%s: %d: failed to allocate mountpoints"),
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
mountpoints[nmountpoints-1] = opt->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = virDomainFSThaw(dom, mountpoints, nmountpoints, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
vshError(ctl, _("Unable to thaw filesystems"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
vshPrint(ctl, _("Thawed %d filesystem(s)\n"), ret);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(mountpoints);
|
||||||
|
virDomainFree(dom);
|
||||||
|
return ret >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
const vshCmdDef domManagementCmds[] = {
|
const vshCmdDef domManagementCmds[] = {
|
||||||
{.name = "attach-device",
|
{.name = "attach-device",
|
||||||
.handler = cmdAttachDevice,
|
.handler = cmdAttachDevice,
|
||||||
@ -11544,6 +11658,18 @@ const vshCmdDef domManagementCmds[] = {
|
|||||||
.info = info_domdisplay,
|
.info = info_domdisplay,
|
||||||
.flags = 0
|
.flags = 0
|
||||||
},
|
},
|
||||||
|
{.name = "domfsfreeze",
|
||||||
|
.handler = cmdDomFSFreeze,
|
||||||
|
.opts = opts_domfsfreeze,
|
||||||
|
.info = info_domfsfreeze,
|
||||||
|
.flags = 0
|
||||||
|
},
|
||||||
|
{.name = "domfsthaw",
|
||||||
|
.handler = cmdDomFSThaw,
|
||||||
|
.opts = opts_domfsthaw,
|
||||||
|
.info = info_domfsthaw,
|
||||||
|
.flags = 0
|
||||||
|
},
|
||||||
{.name = "domfstrim",
|
{.name = "domfstrim",
|
||||||
.handler = cmdDomFSTrim,
|
.handler = cmdDomFSTrim,
|
||||||
.opts = opts_domfstrim,
|
.opts = opts_domfstrim,
|
||||||
|
@ -941,6 +941,29 @@ Output a URI which can be used to connect to the graphical display of the
|
|||||||
domain via VNC, SPICE or RDP. If I<--include-password> is specified, the
|
domain via VNC, SPICE or RDP. If I<--include-password> is specified, the
|
||||||
SPICE channel password will be included in the URI.
|
SPICE channel password will be included in the URI.
|
||||||
|
|
||||||
|
=item B<domfsfreeze> I<domain> [[I<--mountpoint>] B<mountpoint>...]
|
||||||
|
|
||||||
|
Freeze mounted filesystems within a running domain to prepare for consistent
|
||||||
|
snapshots.
|
||||||
|
|
||||||
|
The I<--mountpoint> option takes a parameter B<mountpoint>, which is a
|
||||||
|
mount point path of the filesystem to be frozen. This option can occur
|
||||||
|
multiple times. If this is not specified, every mounted filesystem is frozen.
|
||||||
|
|
||||||
|
Note: B<snapshot-create> command has a I<--quiesce> option to freeze
|
||||||
|
and thaw the filesystems automatically to keep snapshots consistent.
|
||||||
|
B<domfsfreeze> command is only needed when a user wants to utilize the
|
||||||
|
native snapshot features of storage devices not supported by libvirt.
|
||||||
|
|
||||||
|
=item B<domfsthaw> I<domain> [[I<--mountpoint>] B<mountpoint>...]
|
||||||
|
|
||||||
|
Thaw mounted filesystems within a running domain, which have been frozen by
|
||||||
|
domfsfreeze command.
|
||||||
|
|
||||||
|
The I<--mountpoint> option takes a parameter B<mountpoint>, which is a
|
||||||
|
mount point path of the filesystem to be thawed. This option can occur
|
||||||
|
multiple times. If this is not specified, every mounted filesystem is thawed.
|
||||||
|
|
||||||
=item B<domfstrim> I<domain> [I<--minimum> B<bytes>]
|
=item B<domfstrim> I<domain> [I<--minimum> B<bytes>]
|
||||||
[I<--mountpoint mountPoint>]
|
[I<--mountpoint mountPoint>]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user