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

[libvirt] [PATCHv3 02/10] qemu: support migration to fd



* src/qemu/qemu_monitor.h (qemuMonitorMigrateToFd): New
prototype.
* src/qemu/qemu_monitor_text.h (qemuMonitorTextMigrateToFd):
Likewise.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONMigrateToFd):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorMigrateToFd): New function.
* src/qemu/qemu_monitor_text.c (qemuMonitorTextMigrateToFd):
Likewise.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMigrateToFd):
Likewise.
---

no change in v3

 src/qemu/qemu_monitor.c      |   22 ++++++++++++++++++++++
 src/qemu/qemu_monitor.h      |    4 ++++
 src/qemu/qemu_monitor_json.c |   21 ++++++++++++++++++++-
 src/qemu/qemu_monitor_json.h |    6 +++++-
 src/qemu/qemu_monitor_text.c |   24 ++++++++++++++++++++++--
 src/qemu/qemu_monitor_text.h |    6 +++++-
 6 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index dfb1aad..312e797 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1384,6 +1384,28 @@ int qemuMonitorGetMigrationStatus(qemuMonitorPtr mon,
 }


+int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
+                           unsigned int flags,
+                           int fd)
+{
+    int ret;
+    VIR_DEBUG("mon=%p fd=%d flags=%u",
+          mon, fd, flags);
+
+    if (!mon) {
+        qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+                        _("monitor must not be NULL"));
+        return -1;
+    }
+
+    if (mon->json)
+        ret = qemuMonitorJSONMigrateToFd(mon, flags, fd);
+    else
+        ret = qemuMonitorTextMigrateToFd(mon, flags, fd);
+    return ret;
+}
+
+
 int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
                              unsigned int flags,
                              const char *hostname,
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 0ea1330..1a64ac0 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -260,6 +260,10 @@ typedef enum {
   QEMU_MONITOR_MIGRATION_FLAGS_LAST
 } QEMU_MONITOR_MIGRATE;

+int qemuMonitorMigrateToFd(qemuMonitorPtr mon,
+                           unsigned int flags,
+                           int fd);
+
 int qemuMonitorMigrateToHost(qemuMonitorPtr mon,
                              unsigned int flags,
                              const char *hostname,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e6903a1..81201ff 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_json.c: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1697,6 +1697,25 @@ static int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
 }


+int qemuMonitorJSONMigrateToFd(qemuMonitorPtr mon,
+                               unsigned int flags,
+                               int fd)
+{
+    int ret;
+
+    if (qemuMonitorJSONSendFileHandle(mon, "migrate", fd) < 0)
+        return -1;
+
+    ret = qemuMonitorJSONMigrate(mon, flags, "fd:migrate");
+
+    if (ret < 0) {
+        if (qemuMonitorJSONCloseFileHandle(mon, "migrate") < 0)
+            VIR_WARN0("failed to close migration handle");
+    }
+
+    return ret;
+}
+
 int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
                                  unsigned int flags,
                                  const char *hostname,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 4ae472a..c2b45f3 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_json.h: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2009, 2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -104,6 +104,10 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
                                       unsigned long long *remaining,
                                       unsigned long long *total);

+int qemuMonitorJSONMigrateToFd(qemuMonitorPtr mon,
+                               unsigned int flags,
+                               int fd);
+
 int qemuMonitorJSONMigrateToHost(qemuMonitorPtr mon,
                                  unsigned int flags,
                                  const char *hostname,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 0aed690..76e0ec0 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_text.c: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1256,7 +1256,8 @@ static int qemuMonitorTextMigrate(qemuMonitorPtr mon,
      * unknown command: migrate" */
     if (strstr(info, "unknown command:")) {
         qemuReportError(VIR_ERR_NO_SUPPORT,
-                        _("migration to '%s' not supported by this qemu: %s"), dest, info);
+                        _("migration to '%s' not supported by this qemu: %s"),
+                        dest, info);
         goto cleanup;
     }

@@ -1271,6 +1272,25 @@ cleanup:
     return ret;
 }

+int qemuMonitorTextMigrateToFd(qemuMonitorPtr mon,
+                               unsigned int flags,
+                               int fd)
+{
+    int ret;
+
+    if (qemuMonitorTextSendFileHandle(mon, "migrate", fd) < 0)
+        return -1;
+
+    ret = qemuMonitorTextMigrate(mon, flags, "fd:migrate");
+
+    if (ret < 0) {
+        if (qemuMonitorTextCloseFileHandle(mon, "migrate") < 0)
+            VIR_WARN0("failed to close migration handle");
+    }
+
+    return ret;
+}
+
 int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
                                  unsigned int flags,
                                  const char *hostname,
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index b29dbcc..f1b53fc 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_text.h: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2009, 2011 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -102,6 +102,10 @@ int qemuMonitorTextGetMigrationStatus(qemuMonitorPtr mon,
                                       unsigned long long *remaining,
                                       unsigned long long *total);

+int qemuMonitorTextMigrateToFd(qemuMonitorPtr mon,
+                               unsigned int flags,
+                               int fd);
+
 int qemuMonitorTextMigrateToHost(qemuMonitorPtr mon,
                                  unsigned int flags,
                                  const char *hostname,
-- 
1.7.4


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