[libvirt] [PATCH] virsh: Use option alias for outmoded "--persistent"

Osier Yang jyang at redhat.com
Wed Mar 7 10:17:43 UTC 2012


Since VIR_DOMAIN_AFFECT_{LIVE,CONFIG,CURRENT} was created,
all new virsh commands use "--config" to represents the
persistent changing. This patch add "--config" option
for the old commands which still use "--persistent",
and "--persistent" is now alias of "--config".

tools/virsh.c: (use "--config", and "--persistent" is
    alias of "--config" now).
    cmdDomIfSetLink, cmdDomIfGetLink, cmdAttachDevice,
    cmdDetachDevice, cmdUpdateDevice, cmdAttachInterface,
    cmdDetachInterface, cmdAttachDisk, cmdDetachDisk

toos/virsh.pod: Update docs of the changed commands, and
    add some missed docs for "--config" (detach-interface,
    detach-disk, and detach-device).
---
 tools/virsh.c   |   51 ++++++++++++++++++++++++++++++---------------------
 tools/virsh.pod |   36 ++++++++++++++++++++++--------------
 2 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ba3ea1c..3535ad1 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1635,7 +1635,8 @@ static const vshCmdOptDef opts_domif_setlink[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface device (MAC Address)")},
     {"state", VSH_OT_DATA, VSH_OFLAG_REQ, N_("new state of the device")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist interface state")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {NULL, 0, 0, NULL}
 };
 
@@ -1650,7 +1651,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
     unsigned char macaddr[VIR_MAC_BUFLEN];
     const char *element;
     const char *attr;
-    bool persistent;
+    bool config;
     bool ret = false;
     unsigned int flags = 0;
     int i;
@@ -1672,7 +1673,7 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptString(cmd, "state", &state) <= 0)
         goto cleanup;
 
-    persistent = vshCommandOptBool(cmd, "persistent");
+    config = vshCommandOptBool(cmd, "config");
 
     if (STRNEQ(state, "up") && STRNEQ(state, "down")) {
         vshError(ctl, _("invalid link state '%s'"), state);
@@ -1680,13 +1681,13 @@ cmdDomIfSetLink (vshControl *ctl, const vshCmd *cmd)
     }
 
     /* get persistent or live description of network device */
-    desc = virDomainGetXMLDesc(dom, persistent?VIR_DOMAIN_XML_INACTIVE:0);
+    desc = virDomainGetXMLDesc(dom, config ? VIR_DOMAIN_XML_INACTIVE : 0);
     if (desc == NULL) {
         vshError(ctl, _("Failed to get domain description xml"));
         goto cleanup;
     }
 
-    if (persistent)
+    if (config)
         flags = VIR_DOMAIN_AFFECT_CONFIG;
     else
         flags = VIR_DOMAIN_AFFECT_LIVE;
@@ -1810,7 +1811,8 @@ static const vshCmdInfo info_domif_getlink[] = {
 static const vshCmdOptDef opts_domif_getlink[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"interface", VSH_OT_DATA, VSH_OFLAG_REQ, N_("interface device (MAC Address)")},
-    {"persistent", VSH_OT_BOOL, 0, N_("Get persistent interface state")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("Get persistent interface state")},
     {NULL, 0, 0, NULL}
 };
 
@@ -1844,7 +1846,7 @@ cmdDomIfGetLink (vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (vshCommandOptBool(cmd, "persistent"))
+    if (vshCommandOptBool(cmd, "config"))
         flags = VIR_DOMAIN_XML_INACTIVE;
 
     desc = virDomainGetXMLDesc(dom, flags);
@@ -13439,7 +13441,8 @@ static const vshCmdInfo info_attach_device[] = {
 static const vshCmdOptDef opts_attach_device[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist device attachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {NULL, 0, 0, NULL}
 };
 
@@ -13469,7 +13472,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
            flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13750,7 +13753,8 @@ static const vshCmdInfo info_detach_device[] = {
 static const vshCmdOptDef opts_detach_device[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist device detachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {NULL, 0, 0, NULL}
 };
 
@@ -13778,7 +13782,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
            flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13814,7 +13818,8 @@ static const vshCmdInfo info_update_device[] = {
 static const vshCmdOptDef opts_update_device[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"file",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("XML file")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist device update")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {"force",  VSH_OT_BOOL, 0, N_("force device update")},
     {NULL, 0, 0, NULL}
 };
@@ -13845,7 +13850,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
            flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -13889,7 +13894,8 @@ static const vshCmdOptDef opts_attach_interface[] = {
     {"mac",    VSH_OT_DATA, 0, N_("MAC address")},
     {"script", VSH_OT_DATA, 0, N_("script used to bridge network interface")},
     {"model", VSH_OT_DATA, 0, N_("model type")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist interface attachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {"inbound", VSH_OT_DATA, VSH_OFLAG_NONE, N_("control domain's incoming traffics")},
     {"outbound", VSH_OT_DATA, VSH_OFLAG_NONE, N_("control domain's outgoing traffics")},
     {NULL, 0, 0, NULL}
@@ -14046,7 +14052,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 
     xml = virBufferContentAndReset(&buf);
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -14084,7 +14090,8 @@ static const vshCmdOptDef opts_detach_interface[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"type",   VSH_OT_DATA, VSH_OFLAG_REQ, N_("network interface type")},
     {"mac",    VSH_OT_STRING, 0, N_("MAC address")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist interface detachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {NULL, 0, 0, NULL}
 };
 
@@ -14178,7 +14185,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -14225,7 +14232,8 @@ static const vshCmdOptDef opts_attach_disk[] = {
     {"cache",     VSH_OT_STRING, 0, N_("cache mode of disk device")},
     {"type",    VSH_OT_STRING, 0, N_("target device type")},
     {"mode",    VSH_OT_STRING, 0, N_("mode of device reading and writing")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {"sourcetype", VSH_OT_STRING, 0, N_("type of source (block|file)")},
     {"serial", VSH_OT_STRING, 0, N_("serial of disk device")},
     {"shareable", VSH_OT_BOOL, 0, N_("shareable between domains")},
@@ -14534,7 +14542,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 
     xml = virBufferContentAndReset(&buf);
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
@@ -14784,7 +14792,8 @@ static const vshCmdInfo info_detach_disk[] = {
 static const vshCmdOptDef opts_detach_disk[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"target", VSH_OT_DATA, VSH_OFLAG_REQ, N_("target of disk device")},
-    {"persistent", VSH_OT_BOOL, 0, N_("persist disk detachment")},
+    {"persistent", VSH_OT_ALIAS, 0, "config"},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {NULL, 0, 0, NULL}
 };
 
@@ -14820,7 +14829,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
                                        VSH_PREPARE_DISK_XML_NONE)))
         goto cleanup;
 
-    if (vshCommandOptBool(cmd, "persistent")) {
+    if (vshCommandOptBool(cmd, "config")) {
         flags = VIR_DOMAIN_AFFECT_CONFIG;
         if (virDomainIsActive(dom) == 1)
             flags |= VIR_DOMAIN_AFFECT_LIVE;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 54aef05..e91a2bf 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -526,16 +526,16 @@ B<Explanation of fields> (fields appear in the folowing order):
 
 Get network interface stats for a running domain.
 
-=item B<domif-setlink> I<domain> I<interface-device> I<state> I<--persistent>
+=item B<domif-setlink> I<domain> I<interface-device> I<state> [I<--config>]
 
 Modify link state of the domain's virtual interface. Possible values for
-state are "up" and "down. If --persistent is specified, only the persistent
+state are "up" and "down. If I<--config> is specified, only the persistent
 configuration of the domain is modified.
 I<interface-device> can be the interface's target name or the MAC address.
 
-=item B<domif-getlink> I<domain> I<interface-device> I<--persistent>
+=item B<domif-getlink> I<domain> I<interface-device> [I<--config>]
 
-Query link state of the domain's virtual interface. If --persistent
+Query link state of the domain's virtual interface. If I<--config>
 is specified, query the persistent configuration.
 I<interface-device> can be the interface's target name or the MAC address.
 
@@ -1444,10 +1444,12 @@ format of the device sections to get the most accurate set of accepted values.
 
 =over 4
 
-=item B<attach-device> I<domain-id> I<FILE>
+=item B<attach-device> I<domain-id> I<FILE> [I<--config>]
 
 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.
+If I<--config> is specified, alter persistent configuration, effect observed
+on next boot.
 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
@@ -1455,7 +1457,7 @@ the device does not use managed mode.
 
 =item B<attach-disk> I<domain-id> I<source> I<target>
 [I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
-[I<--type type>] [I<--mode mode>] [I<--persistent>] [I<--sourcetype soucetype>]
+[I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
 [I<--serial serial>] [I<--shareable>] [I<--rawio>] [I<--address address>]
 [I<--multifunction>]
 
@@ -1467,7 +1469,7 @@ I<type> can indicate I<cdrom> or I<floppy> as alternative to the disk default,
 although this use only replaces the media 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<persistent> indicates the changes will affect the next boot of the domain.
+I<--config> indicates the changes will affect the next boot of the domain.
 I<sourcetype> can indicate the type of source (block|file)
 I<cache> can be one of "default", "none", "writethrough", "writeback",
 "directsync" or "unsafe".
@@ -1481,7 +1483,7 @@ address.
 
 =item B<attach-interface> I<domain-id> I<type> I<source>
 [I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>]
-[I<--persistent>] [I<--inbound average,peak,burst>] [I<--outbound average,peak,burst>]
+[I<--config>] [I<--inbound average,peak,burst>] [I<--outbound average,peak,burst>]
 
 Attach a new network interface to the domain.
 I<type> can be either I<network> to indicate a physical network device or
@@ -1492,7 +1494,7 @@ I<mac> allows to specify the MAC address of the network interface.
 I<script> allows to specify a path to a script handling a bridge instead of
 the default one.
 I<model> allows to specify the model type.
-I<persistent> indicates the changes will affect the next boot of the domain.
+I<--config> indicates the changes will affect the next boot of the domain.
 I<inbound> and I<outbound> control the bandwidth of the interface. I<peak>
 and I<burst> are optional, so "average,peak", "average,,burst" and
 "average" are also legal.
@@ -1501,30 +1503,36 @@ B<Note>: the optional target value is the name of a device to be created
 as the back-end on the node. If not provided a device named "vnetN" or "vifN"
 will be created automatically.
 
-=item B<detach-device> I<domain-id> I<FILE>
+=item B<detach-device> I<domain-id> I<FILE> [I<--config>]
 
 Detach a device from the domain, takes the same kind of XML descriptions
 as command B<attach-device>.
+If I<--config> is specified, alter persistent configuration, effect observed
+on next boot.
 For passthrough host devices, see also B<nodedev-reattach>, needed if
 the device does not use managed mode.
 
-=item B<detach-disk> I<domain-id> I<target>
+=item B<detach-disk> I<domain-id> I<target> [I<--config>]
 
 Detach a disk device from a domain. The I<target> is the device as seen
 from the domain.
+If I<--config> is specified, alter persistent configuration, effect observed
+on next boot.
 
-=item B<detach-interface> I<domain-id> I<type> [I<--mac mac>]
+=item B<detach-interface> I<domain-id> I<type> [I<--mac mac>] [I<--config>]
 
 Detach a network interface from a domain.
 I<type> can be either I<network> to indicate a physical network device or
 I<bridge> to indicate a bridge to a device. It is recommended to use the
 I<mac> option to distinguish between the interfaces if more than one are
 present on the domain.
+If I<--config> is specified, alter persistent configuration, effect observed
+on next boot.
 
-=item B<update-device> I<domain-id> I<file> [I<--persistent>] [I<--force>]
+=item B<update-device> I<domain-id> I<file> [I<--config>] [I<--force>]
 
 Update the characteristics of a device associated with I<domain-id>, based on
-the device definition in an XML I<file>.  If the I<--persistent> option is
+the device definition in an XML I<file>.  If the I<--config> option is
 used, the changes will affect the next boot of the domain. The I<--force>
 option can be used to force device update, e.g., to eject a CD-ROM even if it
 is locked/mounted in the domain. See the documentation to learn about libvirt
-- 
1.7.1




More information about the libvir-list mailing list