[RFC][PATCH 5/7] interface: expose to virsh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 tools/virsh.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 2b16714..60efa10 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -5048,6 +5048,64 @@ cmdInterfaceDestroy(vshControl *ctl, const vshCmd *cmd)
     return ret;
 }
 
+/*
+ * "iface-change" command
+ */
+static const vshCmdInfo info_interface_change[] = {
+    {"help", N_("manage interface changes by creating a restore point, "
+                "rollback to previous configuration, or removing restore "
+                "point")},
+    {"desc", N_("manage physical host interface changes")},
+    {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_interface_change[] = {
+    {"start", VSH_OT_BOOL, 0, N_("create a restore point")},
+    {"commit", VSH_OT_BOOL, 0, N_("commit changes to interface")},
+    {"rollback", VSH_OT_BOOL, 0, N_("cancel all changes and roll back to "
+                                    "known good configuration")},
+    {NULL, 0, 0, NULL}
+};
+
+static bool
+cmdInterfaceChnage(vshControl *ctl, const vshCmd *cmd)
+{
+    bool ret = false;
+    bool start = vshCommandOptBool(cmd, "start");
+    bool commit = vshCommandOptBool(cmd, "commit");
+    bool rollback = vshCommandOptBool(cmd, "rollback");
+    int num_opts = 0;
+    int func_ret = -1;
+
+    if (start)
+        num_opts++;
+    if (commit)
+        num_opts++;
+    if (rollback)
+        num_opts++;
+    if (num_opts != 1) {
+        vshError(ctl, _("Please specify exactly one option"));
+        goto end;
+    }
+
+    if (!vshConnectionUsability(ctl, ctl->conn))
+        goto end;
+
+    if (start)
+        func_ret = virInterfaceChangeStart(ctl->conn, 0);
+    else if (commit)
+        func_ret = virInterfaceChangeCommit(ctl->conn, 0);
+    else if (rollback)
+        func_ret = virInterfaceChangeRollback(ctl->conn, 0);
+    else {
+        /* This should really never happen */
+    }
+
+    ret = func_ret == 0 ? true : false;
+
+end:
+    return ret;
+}
 
 /*
  * "nwfilter-define" command
@@ -10826,6 +10884,7 @@ static const vshCmdDef ifaceCmds[] = {
     {"iface-name", cmdInterfaceName, opts_interface_name, info_interface_name},
     {"iface-start", cmdInterfaceStart, opts_interface_start, info_interface_start},
     {"iface-undefine", cmdInterfaceUndefine, opts_interface_undefine, info_interface_undefine},
+    {"iface-change", cmdInterfaceChnage, opts_interface_change, info_interface_change},
     {NULL, NULL, NULL, NULL}
 };
 
-- 
1.7.5.rc3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]