Re: [PATCH] virDomainMigrate version 4 (for discussion only!)

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

 



Attached is an updated patch which adds a "virsh migrate" subcommand.

I also rebuilt the API & Python binding using the generator.

Two known problems with the auto-generated Python binding at the moment:

(1) It's attached to the connection object (conn.migrate (...)) instead of the domain object (dom.migrate (...)). It looks like the generator is confused about a function which takes both a domain ptr and a connect ptr.

(2) I need to get the generator to export the VIR_MIGRATE_LIVE flag. At the moment you need to pass 0|1 for the flag parameter.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libvirt/src/virsh.c,v
retrieving revision 1.92
diff -u -p -r1.92 virsh.c
--- src/virsh.c	6 Jul 2007 15:05:19 -0000	1.92
+++ src/virsh.c	19 Jul 2007 16:49:36 -0000
@@ -2022,6 +2022,69 @@ cmdDomuuid(vshControl * ctl, vshCmd * cm
 }
 
 /*
+ * "migrate" command
+ */
+static vshCmdInfo info_migrate[] = {
+    {"syntax", "migrate [--live] <domain> <desturi> [<migrateuri>]"},
+    {"help", gettext_noop("migrate domain to another host")},
+    {"desc", gettext_noop("Migrate domain to another host.  Add --live for live migration.")},
+    {NULL, NULL}
+};
+
+static vshCmdOptDef opts_migrate[] = {
+    {"live", VSH_OT_BOOL, 0, gettext_noop("live migration")},
+    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
+    {"desturi", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("connection URI of the destination host")},
+    {"migrateuri", VSH_OT_DATA, 0, gettext_noop("migration URI, usually can be omitted")},
+    {NULL, 0, 0, NULL}
+};
+
+static int
+cmdMigrate (vshControl *ctl, vshCmd *cmd)
+{
+    virDomainPtr dom = NULL;
+    const char *desturi;
+    const char *migrateuri;
+    int flags = 0, found, ret = FALSE;
+    virConnectPtr dconn = NULL;
+    virDomainPtr ddom = NULL;
+
+    if (!vshConnectionUsability (ctl, ctl->conn, TRUE))
+        return FALSE;
+
+    if (!(dom = vshCommandOptDomain (ctl, cmd, "domain", NULL)))
+        return FALSE;
+
+    desturi = vshCommandOptString (cmd, "desturi", &found);
+    if (!found) {
+        vshError (ctl, FALSE, _("migrate: Missing desturi"));
+        goto done;
+    }
+
+    migrateuri = vshCommandOptString (cmd, "migrateuri", &found);
+    if (!found) migrateuri = NULL;
+
+    if (vshCommandOptBool (cmd, "live"))
+        flags |= VIR_MIGRATE_LIVE;
+
+    /* Temporarily connect to the destination host. */
+    dconn = virConnectOpen (desturi);
+    if (!dconn) goto done;
+
+    /* Migrate. */
+    ddom = virDomainMigrate (dom, dconn, flags, NULL, migrateuri, 0);
+    if (!ddom) goto done;
+
+    ret = TRUE;
+
+ done:
+    if (dom) virDomainFree (dom);
+    if (ddom) virDomainFree (ddom);
+    if (dconn) virConnectClose (dconn);
+    return ret;
+}
+
+/*
  * "net-autostart" command
  */
 static vshCmdInfo info_network_autostart[] = {
@@ -3405,6 +3468,7 @@ static vshCmdDef commands[] = {
     {"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml},
     {"hostname", cmdHostname, NULL, info_hostname},
     {"list", cmdList, opts_list, info_list},
+    {"migrate", cmdMigrate, opts_migrate, info_migrate},
     {"net-autostart", cmdNetworkAutostart, opts_network_autostart, info_network_autostart},
     {"net-create", cmdNetworkCreate, opts_network_create, info_network_create},
     {"net-define", cmdNetworkDefine, opts_network_define, info_network_define},

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
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]