提交 af3f9aab 编写于 作者: E Eric Blake

virsh: add command aliases, and rename nodedev-detach

Just because our public API has a typo doesn't mean that virsh
has to keep the typo.

* tools/virsh.c (VSH_CMD_FLAG_ALIAS): New flag.
(nodedevCmds): Use it.
(cmdHelp): Omit alias commands.
(cmdNodeDeviceDettach): Rename...
(cmdNodeDeviceDetach): ...to this.
* tools/virsh.pod (nodedev-detach): Document it.
上级 3d150d32
......@@ -212,6 +212,7 @@ typedef struct vshCmdOpt {
*/
enum {
VSH_CMD_FLAG_NOCONNECT = (1 << 0), /* no prior connection needed */
VSH_CMD_FLAG_ALIAS = (1 << 1), /* command is an alias */
};
/*
......@@ -685,9 +686,12 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, _(" %s (help keyword '%s'):\n"), grp->name,
grp->keyword);
for (def = grp->commands; def->name; def++)
for (def = grp->commands; def->name; def++) {
if (def->flags & VSH_CMD_FLAG_ALIAS)
continue;
vshPrint(ctl, " %-30s %s\n", def->name,
_(vshCmddefGetInfo(def, "help")));
}
vshPrint(ctl, "\n");
}
......@@ -13093,22 +13097,22 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
}
/*
* "nodedev-dettach" command
* "nodedev-detach" command
*/
static const vshCmdInfo info_node_device_dettach[] = {
{"help", N_("dettach node device from its device driver")},
{"desc", N_("Dettach node device from its device driver before assigning to a domain.")},
static const vshCmdInfo info_node_device_detach[] = {
{"help", N_("detach node device from its device driver")},
{"desc", N_("Detach node device from its device driver before assigning to a domain.")},
{NULL, NULL}
};
static const vshCmdOptDef opts_node_device_dettach[] = {
static const vshCmdOptDef opts_node_device_detach[] = {
{"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("device key")},
{NULL, 0, 0, NULL}
};
static bool
cmdNodeDeviceDettach (vshControl *ctl, const vshCmd *cmd)
cmdNodeDeviceDetach (vshControl *ctl, const vshCmd *cmd)
{
const char *name = NULL;
virNodeDevicePtr device;
......@@ -13123,10 +13127,12 @@ cmdNodeDeviceDettach (vshControl *ctl, const vshCmd *cmd)
return false;
}
/* Yes, our public API is misspelled. At least virsh can accept
* either spelling. */
if (virNodeDeviceDettach(device) == 0) {
vshPrint(ctl, _("Device %s dettached\n"), name);
vshPrint(ctl, _("Device %s detached\n"), name);
} else {
vshError(ctl, _("Failed to dettach device %s"), name);
vshError(ctl, _("Failed to detach device %s"), name);
ret = false;
}
virNodeDeviceFree(device);
......@@ -17245,8 +17251,10 @@ static const vshCmdDef nodedevCmds[] = {
info_node_device_create, 0},
{"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy,
info_node_device_destroy, 0},
{"nodedev-dettach", cmdNodeDeviceDettach, opts_node_device_dettach,
info_node_device_dettach, 0},
{"nodedev-detach", cmdNodeDeviceDetach, opts_node_device_detach,
info_node_device_detach, 0},
{"nodedev-dettach", cmdNodeDeviceDetach, opts_node_device_detach,
info_node_device_detach, VSH_CMD_FLAG_ALIAS},
{"nodedev-dumpxml", cmdNodeDeviceDumpXML, opts_node_device_dumpxml,
info_node_device_dumpxml, 0},
{"nodedev-list", cmdNodeListDevices, opts_node_list_devices,
......
......@@ -1459,7 +1459,7 @@ Attach a device to the domain, using a device definition in an XML file.
See the documentation to learn about libvirt XML format for a device.
For cdrom and floppy devices, this command only replaces the media within
the single existing device; consider using B<update-device> for this usage.
For passthrough host devices, see also B<nodedev-dettach>, needed if
For passthrough host devices, see also B<nodedev-detach>, needed if
the device does not use managed mode.
=item B<attach-disk> I<domain-id> I<source> I<target>
......@@ -1588,7 +1588,7 @@ guest domains, nor by multiple active guests at once. If the
<hostdev> description includes the attribute B<managed='yes'>, and the
hypervisor driver supports it, then the device is in managed mode, and
attempts to use that passthrough device in an active guest will
automatically behave as if B<nodedev-dettach> (guest start, device
automatically behave as if B<nodedev-detach> (guest start, device
hot-plug) and B<nodedev-reattach> (guest stop, device hot-unplug) were
called at the right points (currently, qemu does this for PCI devices,
but not USB). If a device is not marked as managed, then it must
......@@ -1613,11 +1613,13 @@ Destroy (stop) a device on the host. Note that this makes libvirt
quit managing a host device, and may even make that device unusable
by the rest of the physical host until a reboot.
=item B<nodedev-dettach> I<nodedev>
=item B<nodedev-detach> I<nodedev>
Detach I<nodedev> from the host, so that it can safely be used by
guests via <hostdev> passthrough. This is reversed with
B<nodedev-reattach>, and is done automatically for managed devices.
For compatibility purposes, this command can also be spelled
B<nodedev-dettach>.
=item B<nodedev-dumpxml> I<nodedev>
......@@ -1638,7 +1640,7 @@ formatted in a tree representing parents of each node.
Declare that I<nodedev> is no longer in use by any guests, and that
the host can resume normal use of the device. This is done
automatically for devices in managed mode, but must be done explicitly
to match any explicit B<nodedev-dettach>.
to match any explicit B<nodedev-detach>.
=item B<nodedev-reset> I<nodedev>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册