浏览代码

qed: add migration blocker (v2)

Now when you try to migrate with qed, you get:

(qemu) migrate tcp:localhost:1025
Block format 'qed' used by device 'ide0-hd0' does not support feature 'live migration'
(qemu)

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Anthony Liguori 13 年之前
父节点
当前提交
1ed520c66e
共有 5 个文件被更改,包括 28 次插入0 次删除
  1. 10 0
      block/qed.c
  2. 2 0
      block/qed.h
  3. 9 0
      qemu-tool.c
  4. 4 0
      qerror.c
  5. 3 0
      qerror.h

+ 10 - 0
block/qed.c

@@ -16,6 +16,7 @@
 #include "trace.h"
 #include "trace.h"
 #include "qed.h"
 #include "qed.h"
 #include "qerror.h"
 #include "qerror.h"
+#include "migration.h"
 
 
 static void qed_aio_cancel(BlockDriverAIOCB *blockacb)
 static void qed_aio_cancel(BlockDriverAIOCB *blockacb)
 {
 {
@@ -504,6 +505,12 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)
     s->need_check_timer = qemu_new_timer_ns(vm_clock,
     s->need_check_timer = qemu_new_timer_ns(vm_clock,
                                             qed_need_check_timer_cb, s);
                                             qed_need_check_timer_cb, s);
 
 
+    error_set(&s->migration_blocker,
+              QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
+              "qed", bs->device_name, "live migration");
+    migrate_add_blocker(s->migration_blocker);
+
+
 out:
 out:
     if (ret) {
     if (ret) {
         qed_free_l2_cache(&s->l2_cache);
         qed_free_l2_cache(&s->l2_cache);
@@ -516,6 +523,9 @@ static void bdrv_qed_close(BlockDriverState *bs)
 {
 {
     BDRVQEDState *s = bs->opaque;
     BDRVQEDState *s = bs->opaque;
 
 
+    migrate_del_blocker(s->migration_blocker);
+    error_free(s->migration_blocker);
+
     qed_cancel_need_check_timer(s);
     qed_cancel_need_check_timer(s);
     qemu_free_timer(s->need_check_timer);
     qemu_free_timer(s->need_check_timer);
 
 

+ 2 - 0
block/qed.h

@@ -164,6 +164,8 @@ typedef struct {
 
 
     /* Periodic flush and clear need check flag */
     /* Periodic flush and clear need check flag */
     QEMUTimer *need_check_timer;
     QEMUTimer *need_check_timer;
+
+    Error *migration_blocker;
 } BDRVQEDState;
 } BDRVQEDState;
 
 
 enum {
 enum {

+ 9 - 0
qemu-tool.c

@@ -15,6 +15,7 @@
 #include "monitor.h"
 #include "monitor.h"
 #include "qemu-timer.h"
 #include "qemu-timer.h"
 #include "qemu-log.h"
 #include "qemu-log.h"
+#include "migration.h"
 
 
 #include <sys/time.h>
 #include <sys/time.h>
 
 
@@ -92,3 +93,11 @@ int64_t qemu_get_clock_ns(QEMUClock *clock)
 {
 {
     return 0;
     return 0;
 }
 }
+
+void migrate_add_blocker(Error *reason)
+{
+}
+
+void migrate_del_blocker(Error *reason)
+{
+}

+ 4 - 0
qerror.c

@@ -48,6 +48,10 @@ static const QErrorStringTable qerror_table[] = {
         .error_fmt = QERR_BAD_BUS_FOR_DEVICE,
         .error_fmt = QERR_BAD_BUS_FOR_DEVICE,
         .desc      = "Device '%(device)' can't go on a %(bad_bus_type) bus",
         .desc      = "Device '%(device)' can't go on a %(bad_bus_type) bus",
     },
     },
+    {
+        .error_fmt = QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,
+        .desc      = "Block format '%(format)' used by device '%(name)' does not support feature '%(feature)'",
+    },
     {
     {
         .error_fmt = QERR_BUS_NOT_FOUND,
         .error_fmt = QERR_BUS_NOT_FOUND,
         .desc      = "Bus '%(bus)' not found",
         .desc      = "Bus '%(bus)' not found",

+ 3 - 0
qerror.h

@@ -54,6 +54,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_BAD_BUS_FOR_DEVICE \
 #define QERR_BAD_BUS_FOR_DEVICE \
     "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
     "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }"
 
 
+#define QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED \
+    "{ 'class': 'BlockFormatFeatureNotSupported', 'data': { 'format': %s, 'name': %s, 'feature': %s } }"
+
 #define QERR_BUS_NOT_FOUND \
 #define QERR_BUS_NOT_FOUND \
     "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"
     "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }"