qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC PATCH v3 5/9] repagent: Changed repagent to be a block


From: Ori Mamluk
Subject: [Qemu-devel] [RFC PATCH v3 5/9] repagent: Changed repagent to be a block driver
Date: Thu, 5 Apr 2012 15:17:57 +0300

Driver functions are in repagent_drv.c, it is basd on raw.c

Qemu runs and is able to boot

---

block.c                       |   33 +++++--

block.h                       |    1 -

block/repagent/repagent.c     |   53 ++++++++----

block/repagent/repagent.h     |    6 ++

block/repagent/repagent_drv.c |  198 ++++++++++++++++++----------------------

block/repagent/rephub_cmds.h  |    2 +-

blockdev.c                    |    7 +--

vl.c                          |   17 +---

8 files changed, 160 insertions(+), 157 deletions(-)

 

diff --git a/block.c b/block.c

index 6612af1..8e11c03 100644

--- a/block.c

+++ b/block.c

@@ -57,6 +57,7 @@ typedef enum {

     BDRV_REQ_ZERO_WRITE   = 0x2,

} BdrvRequestFlags;

+

static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load);

static BlockDriverAIOCB *bdrv_aio_readv_em(BlockDriverState *bs,

         int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,

@@ -104,6 +105,9 @@ static BlockDriverState *bs_snapshots;

/* If non-zero, use only whitelisted block drivers */

static int use_bdrv_whitelist;

+/* orim temporary */

+int use_repagent;

+

#ifdef _WIN32

static int is_windows_drive_prefix(const char *filename)

{

@@ -607,8 +611,7 @@ static int bdrv_open_common(BlockDriverState *bs, const char *filename,

      * Clear flags that are internal to the block layer before opening the

      * image.

      */

-    open_flags = flags

-         & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_REPAGENT);

+    open_flags = flags & ~(BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);

     /*

      * Snapshots should be writable.

@@ -690,8 +693,10 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,

     int ret;

     char tmp_filename[PATH_MAX];

-    if (flags & BDRV_O_REPAGENT) {

-        drv = bdrv_find_format("repagent");

+    if (use_repagent && bs->device_name[0] != '\0' && strcmp(

+            bs->device_name, "pflash0") != 0) {

+        BlockDriver *bdrv_repagent = bdrv_find_format("repagent");

+        drv = bdrv_repagent;

     }

     if (flags & BDRV_O_SNAPSHOT) {

@@ -759,7 +764,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int flags,

     }

 #ifdef CONFIG_REPAGENT

-    repagent_register_drive(filename,  bs);

+/*    repagent_register_drive(filename,  bs); */

#endif

     /* Open the image */

     ret = bdrv_open_common(bs, filename, flags, drv);

@@ -1481,6 +1486,13 @@ static int bdrv_rw_co(BlockDriverState *bs, int64_t sector_num, uint8_t *buf,

             qemu_aio_wait();

         }

     }

+    /* orim todo remove */

+    printf("IO done. is_write %d sec %lld size %d ", is_write,

+            (long long int) sector_num, nb_sectors);

+    if (bs->drv != NULL) {

+        printf("Drv %s, ", bs->drv->format_name);

+    }

+    printf("file %s, ret %d\n", bs->filename, rwco.ret);

     return rwco.ret;

}

@@ -1861,8 +1873,9 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs,

            Currently we know that by checking device_name - only

            highest level (closest to the guest) has that name.

            */

-           repagent_handle_protected_write(bs, sector_num,

+/*           repagent_handle_protected_write(bs, sector_num,

                 nb_sectors, qiov, ret);

+*/

     }

#endif

     if (bs->dirty_bitmap) {

@@ -1942,16 +1955,20 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)

  */

int64_t bdrv_getlength(BlockDriverState *bs)

{

+    int64_t ret = 0;

     BlockDriver *drv = bs->drv;

     if (!drv)

         return -ENOMEDIUM;

+    ret = bs->total_sectors * BDRV_SECTOR_SIZE;

     if (bs->growable || bdrv_dev_has_removable_media(bs)) {

         if (drv->bdrv_getlength) {

-            return drv->bdrv_getlength(bs);

+            ret = drv->bdrv_getlength(bs);

         }

     }

-    return bs->total_sectors * BDRV_SECTOR_SIZE;

+    /* orim todo remove */

+    printf("bdrv_getlength returned %d", (int)ret);

+    return ret;

}

 /* return 0 as number of sectors if no device present or error */

diff --git a/block.h b/block.h

index d4a8257..48d0bf3 100644

--- a/block.h

+++ b/block.h

@@ -71,7 +71,6 @@ typedef struct BlockDevOps {

#define BDRV_O_NO_BACKING  0x0100 /* don't open the backing file */

#define BDRV_O_NO_FLUSH    0x0200 /* disable flushing on this disk */

#define BDRV_O_COPY_ON_READ 0x0400 /* copy read backing sectors into image */

-#define BDRV_O_REPAGENT    0x0800 /* Use replication - temporary flag */

 #define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH)

diff --git a/block/repagent/repagent.c b/block/repagent/repagent.c

index c291915..c3dd593 100644

--- a/block/repagent/repagent.c

+++ b/block/repagent/repagent.c

@@ -34,6 +34,8 @@ typedef struct RepagentReadVolIo {

     struct timeval start_time;

} RepagentReadVolIo;

+static int repagent_get_volume_by_driver(

+        BlockDriverState *bs);

static int repagent_get_volume_by_name(const char *name);

static void repagent_report_volumes_to_hub(void);

static void repagent_vol_read_done(void *opaque, int ret);

@@ -67,18 +69,16 @@ void repagent_init(const char *hubname, int port)

void repagent_register_drive(const char *drive_path,

         BlockDriverState *driver_ptr)

{

-    int i;

-    for (i = 0; i < g_rep_agent.num_volumes ; i++) {

-        RepagentVolume *vol = g_rep_agent.volumes[i];

-        if (vol != NULL) {

-            assert(

-                    strcmp(drive_path, vol->vol_path) != 0

-                    && driver_ptr != vol->driver_ptr);

-        }

-    }

+    /* Assert that the volume is not registered yet */

+    int i = repagent_get_volume_by_name(drive_path);

+    assert(i == -1);

+    /*Add the volume at the last place*/

     assert(g_rep_agent.num_volumes < REPAGENT_MAX_NUM_VOLUMES);

+    i = g_rep_agent.num_volumes;

+    g_rep_agent.num_volumes++;

+

     printf("zerto repagent: Registering drive. Num drives %d, path %s\n",

             g_rep_agent.num_volumes, drive_path);

     g_rep_agent.volumes[i] =

@@ -93,9 +93,25 @@ void repagent_register_drive(const char *drive_path,

     repagent_report_volumes_to_hub();

}

+void repagent_deregister_drive(const char *drive_path,

+        BlockDriverState *driver_ptr)

+{

+    /* Orim todo thread-safety? */

+    int i = repagent_get_volume_by_driver(driver_ptr);

+    assert(i != -1);

+

+    RepagentVolume *vol = g_rep_agent.volumes[i];

+    /* Put the last volume in the cell of the removed volume to maintain a

+     * contiguous array */

+    g_rep_agent.volumes[i] = g_rep_agent.volumes[g_rep_agent.num_volumes - 1];

+    g_rep_agent.volumes[g_rep_agent.num_volumes - 1] = NULL;

+    g_rep_agent.num_volumes--;

+    g_free(vol);

+

+}

/* orim todo destruction? */

-static RepagentVolume *repagent_get_protected_volume_by_driver(

+static int repagent_get_volume_by_driver(

         BlockDriverState *bs)

{

     /* orim todo optimize search */

@@ -103,10 +119,10 @@ static RepagentVolume *repagent_get_protected_volume_by_driver(

     for (i = 0; i < g_rep_agent.num_volumes ; i++) {

         RepagentVolume *p_vol = g_rep_agent.volumes[i];

         if (p_vol != NULL && p_vol->driver_ptr == (void *) bs) {

-            return p_vol;

+            return i;

         }

     }

-    return NULL;

+    return -1;

}

 void repagent_handle_protected_write(BlockDriverState *bs, int64_t sector_num,

@@ -120,13 +136,16 @@ void repagent_handle_protected_write(BlockDriverState *bs, int64_t sector_num,

     printf("\n");

-    RepagentVolume *p_vol = repagent_get_protected_volume_by_driver(bs);

-    if (p_vol == NULL || p_vol->vol_id == REPAGENT_VOLUME_ID_NONE) {

+    /* orim todo thread safety? */

+    int i = repagent_get_volume_by_driver(bs);

+    if (i == -1 || g_rep_agent.volumes[i]->vol_id == REPAGENT_VOLUME_ID_NONE) {

         /* Unprotected */

         printf("Got a write to an unprotected volume.\n");

         return;

     }

+    RepagentVolume *p_vol = g_rep_agent.volumes[i];

+

     /* Report IO to rephub */

     int data_size = qiov->size;

@@ -234,7 +253,7 @@ int repaget_read_vol(RepCmdReadVolReq *pcmd, uint8_t *pdata)

                 REPHUB_CMD_READ_VOL_RES, 0, NULL);

         p_res_cmd->req_id = pcmd->req_id;

         p_res_cmd->volume_id = pcmd->volume_id;

-        p_res_cmd->is_status_success = FALSE;

+        p_res_cmd->io_status = -1;

         repagent_client_send((RepCmd *) p_res_cmd);

         return TRUE;

     }

@@ -280,7 +299,7 @@ static void repagent_vol_read_done(void *opaque, int ret)

             &pdata);

     pcmd->req_id = read_xact->rep_cmd.req_id;

     pcmd->volume_id = read_xact->rep_cmd.volume_id;

-    pcmd->is_status_success = FALSE;

+    pcmd->io_status = -1;

     printf("Protected vol read - volId %llu, offset %llu, size %u\n",

             (unsigned long long int) read_xact->rep_cmd.volume_id,

@@ -294,7 +313,7 @@ static void repagent_vol_read_done(void *opaque, int ret)

         printf("Read prot vol done. Took %u seconds, %u us.",

                 (uint32_t) t2.tv_sec, (uint32_t) t2.tv_usec);

-        pcmd->is_status_success = TRUE;

+        pcmd->io_status = 0;    /* Success */

         /* orim todo optimize - don't copy, use the qiov buffer */

         qemu_iovec_to_buffer(&read_xact->qiov, pdata);

     } else {

diff --git a/block/repagent/repagent.h b/block/repagent/repagent.h

index 98ccbf2..310db0f 100644

--- a/block/repagent/repagent.h

+++ b/block/repagent/repagent.h

@@ -32,11 +32,17 @@ typedef struct RepCmdStartProtect RepCmdStartProtect;

typedef struct RepCmdDataStartProtect RepCmdDataStartProtect;

struct RepCmdReadVolReq;

+/* orim temporary */

+extern int use_repagent;

+

+

void repagent_init(const char *hubname, int port);

void repagent_handle_protected_write(BlockDriverState *bs,

         int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int ret_status);

void repagent_register_drive(const char *drive_path,

         BlockDriverState *driver_ptr);

+void repagent_deregister_drive(const char *drive_path,

+        BlockDriverState *driver_ptr);

int repaget_start_protect(RepCmdStartProtect *pcmd,

         RepCmdDataStartProtect *pcmd_data);

int repaget_read_vol(struct RepCmdReadVolReq *pcmd, uint8_t *pdata);

diff --git a/block/repagent/repagent_drv.c b/block/repagent/repagent_drv.c

index 49e110d..8c9f2b6 100644

--- a/block/repagent/repagent_drv.c

+++ b/block/repagent/repagent_drv.c

@@ -1,7 +1,6 @@

#include <string.h>

#include <stdlib.h>

#include <stdio.h>

-#include <pthread.h>

#include <stdint.h>

 #include "block.h"

@@ -10,183 +9,164 @@

#include "repagent_client.h"

#include "repagent.h"

#include "rephub_cmds.h"

+#include "module.h"

 #define ZERO_MEM_OBJ(pObj) memset(pObj, 0, sizeof(*pObj))

-typedef struct BDRVRepagentState {

-} BDRVRepagentState;

-

-static int repagent_probe(const uint8_t *buf, int buf_size,

-                 const char *filename)

-{

-    return 0;

-}

-

-

static int repagent_open(BlockDriverState *bs, int flags)

{

-    int ret;

-    /* BDRVRepagentState *s = bs->opaque */

-    bs->file = bdrv_new("repagent_file");

-    ret = bdrv_open(bs->file, bs->filename, flags, NULL);

-    if (ret < 0) {

-        printf("Error opening repagent inner file\n");

-        bdrv_delete(bs->file);

-    }

-

-    return ret;

-}

-

-static int repagent_set_key(BlockDriverState *bs, const char *key)

-{

-    return bs->file->drv->bdrv_set_key(bs->file, key);

-}

-

-static int coroutine_fn repagent_co_is_allocated(BlockDriverState *bs,

-        int64_t sector_num, int nb_sectors, int *pnum)

-{

-    return bs->file->drv->bdrv_co_is_allocated(bs->file, sector_num,

-                nb_sectors, pnum);

+    repagent_register_drive(bs->filename,  bs);

+    printf("%s\n", __func__);

+    bs->sg = bs->file->sg;

+    return 0;

}

-static coroutine_fn int repagent_co_readv(BlockDriverState *bs,

-          int64_t sector_num, int remaining_sectors, QEMUIOVector *qiov)

+static int coroutine_fn repagent_co_readv(BlockDriverState *bs,

+        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)

{

-    return bs->file->drv->bdrv_co_readv(bs->file, sector_num,

-                    remaining_sectors, qiov);

+    printf("%s\n", __func__);

+    return bdrv_co_readv(bs->file, sector_num, nb_sectors, qiov);

}

-static coroutine_fn int repagent_co_writev(BlockDriverState *bs,

-                           int64_t sector_num,

-                           int remaining_sectors,

-                           QEMUIOVector *qiov)

+static int coroutine_fn repagent_co_writev(BlockDriverState *bs,

+        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)

{

-    return bs->file->drv->bdrv_co_writev(bs->file, sector_num,

-            remaining_sectors, qiov);

+    printf("%s\n", __func__);

+    int ret = 0;

+    repagent_handle_protected_write(bs, sector_num,

+            nb_sectors, qiov, ret);

+    printf("Before write off %lld, size %d\n", (long long int) sector_num,

+            nb_sectors);

+    ret = bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov);

+    printf("After write ret %d\n", ret);

+    return ret;

}

 static void repagent_close(BlockDriverState *bs)

{

-    return bs->file->drv->bdrv_close(bs->file);

+    printf("%s\n", __func__);

}

-static void repagent_invalidate_cache(BlockDriverState *bs)

+static int coroutine_fn repagent_co_flush(BlockDriverState *bs)

{

-    bs->file->drv->bdrv_invalidate_cache(bs->file);

-}

-

-static int repagent_change_backing_file(BlockDriverState *bs,

-        const char *backing_file, const char *backing_fmt) {

-    return bs->file->drv->bdrv_change_backing_file(bs->file, backing_file,

-            backing_fmt);

+    printf("%s\n", __func__);

+    return bdrv_co_flush(bs->file);

}

-static int repagent_create(const char *filename, QEMUOptionParameter *options)

+static int64_t repagent_getlength(BlockDriverState *bs)

{

-    /*    return bs->file->drv->bdrv_create(const char *filename,

-     * QEMUOptionParameter *options);

-     orim - create?

-     */

-    return 0;

+    printf("%s\n", __func__);

+    return bdrv_getlength(bs->file);

}

-static int repagent_make_empty(BlockDriverState *bs)

+static int repagent_truncate(BlockDriverState *bs, int64_t offset)

{

-    return bs->file->drv->bdrv_make_empty(bs->file);

+    printf("%s\n", __func__);

+    return bdrv_truncate(bs->file, offset);

}

-static coroutine_fn int repagent_co_discard(BlockDriverState *bs,

-    int64_t sector_num, int nb_sectors)

+static int repagent_probe(const uint8_t *buf, int buf_size,

+        const char *filename)

{

-    return bs->file->drv->bdrv_make_empty(bs->file);

+    printf("%s\n", __func__);

+    return 1; /* everything can be opened as raw image */

}

-static int repagent_truncate(BlockDriverState *bs, int64_t offset)

+static int coroutine_fn repagent_co_discard(BlockDriverState *bs,

+                                       int64_t sector_num, int nb_sectors)

{

-    return bs->file->drv->bdrv_truncate(bs->file, offset);

+    return bdrv_co_discard(bs->file, sector_num, nb_sectors);

}

-static int repagent_write_compressed(BlockDriverState *bs, int64_t sector_num,

-                                  const uint8_t *buf, int nb_sectors)

+static int repagent_is_inserted(BlockDriverState *bs)

{

-    return bs->file->drv->bdrv_write_compressed(bs->file, sector_num,

-                    buf, nb_sectors);

+    printf("%s\n", __func__);

+    return bdrv_is_inserted(bs->file);

}

-static coroutine_fn int repagent_co_flush_to_os(BlockDriverState *bs)

+static int repagent_media_changed(BlockDriverState *bs)

{

-    return bs->file->drv->bdrv_co_flush_to_os(bs->file);

+    printf("%s\n", __func__);

+    return bdrv_media_changed(bs->file);

}

-static coroutine_fn int repagent_co_flush_to_disk(BlockDriverState *bs)

+static void repagent_eject(BlockDriverState *bs, bool eject_flag)

{

-    return bs->file->drv->bdrv_co_flush_to_disk(bs->file);

+    printf("%s\n", __func__);

+    bdrv_eject(bs->file, eject_flag);

}

-static int repagent_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)

+static void repagent_lock_medium(BlockDriverState *bs, bool locked)

{

-    return bs->file->drv->bdrv_get_info(bs->file, bdi);

+    printf("%s\n", __func__);

+    bdrv_lock_medium(bs->file, locked);

}

-

-static int repagent_check(BlockDriverState *bs, BdrvCheckResult *result)

+static int repagent_ioctl(BlockDriverState *bs, unsigned long int req,

+        void *buf)

{

-    return bs->file->drv->bdrv_check(bs->file, result);

+    printf("%s\n", __func__);

+   return bdrv_ioctl(bs->file, req, buf);

}

-static int repagent_save_vmstate(BlockDriverState *bs, const uint8_t *buf,

-                              int64_t pos, int size)

+static BlockDriverAIOCB *repagent_aio_ioctl(BlockDriverState *bs,

+        unsigned long int req, void *buf,

+        BlockDriverCompletionFunc *cb, void *opaque)

{

-    return bs->file->drv->bdrv_save_vmstate(bs->file, buf, pos, size);

+    printf("%s\n", __func__);

+   return bdrv_aio_ioctl(bs->file, req, buf, cb, opaque);

}

-static int repagent_load_vmstate(BlockDriverState *bs, uint8_t *buf,

-                              int64_t pos, int size)

+static int repagent_create(const char *filename, QEMUOptionParameter *options)

{

-    return bs->file->drv->bdrv_load_vmstate(bs->file, buf, pos, size);

+    printf("%s\n", __func__);

+    return bdrv_create_file(filename, options);

}

-

static QEMUOptionParameter repagent_create_options[] = {

+    {

+        .name = BLOCK_OPT_SIZE,

+        .type = OPT_SIZE,

+        .help = "Virtual disk size"

+    },

     { NULL }

};

+static int repagent_has_zero_init(BlockDriverState *bs)

+{

+    printf("%s\n", __func__);

+    return bdrv_has_zero_init(bs->file);

+}

+

static BlockDriver bdrv_repagent = {

     .format_name        = "repagent",

-    .instance_size      = sizeof(BDRVRepagentState),

-    .bdrv_probe         = repagent_probe,

+

+    /* It's really 0, but we need to make g_malloc() happy */

+    .instance_size      = 1,

+

     .bdrv_open          = repagent_open,

     .bdrv_close         = repagent_close,

-    .bdrv_create        = repagent_create,

-    .bdrv_co_is_allocated = repagent_co_is_allocated,

-    .bdrv_set_key       = repagent_set_key,

-    .bdrv_make_empty    = repagent_make_empty,

     .bdrv_co_readv          = repagent_co_readv,

     .bdrv_co_writev         = repagent_co_writev,

-    .bdrv_co_flush_to_os    = repagent_co_flush_to_os,

-    .bdrv_co_flush_to_disk  = repagent_co_flush_to_disk,

-

+    .bdrv_co_flush_to_disk  = repagent_co_flush,

     .bdrv_co_discard        = repagent_co_discard,

-    .bdrv_truncate          = repagent_truncate,

-    .bdrv_write_compressed  = repagent_write_compressed,

-

-    .bdrv_snapshot_create   = NULL,

-    .bdrv_snapshot_goto     = NULL,

-    .bdrv_snapshot_delete   = NULL,

-    .bdrv_snapshot_list     = NULL,

-    .bdrv_snapshot_load_tmp     = NULL,

-    .bdrv_get_info      = repagent_get_info,

-    .bdrv_save_vmstate    = repagent_save_vmstate,

-    .bdrv_load_vmstate    = repagent_load_vmstate,

+    .bdrv_probe         = repagent_probe,

+    .bdrv_getlength     = repagent_getlength,

+    .bdrv_truncate      = repagent_truncate,

-    .bdrv_change_backing_file   = repagent_change_backing_file,

+    .bdrv_is_inserted   = repagent_is_inserted,

+    .bdrv_media_changed = repagent_media_changed,

+    .bdrv_eject         = repagent_eject,

+    .bdrv_lock_medium   = repagent_lock_medium,

-    .bdrv_invalidate_cache      = repagent_invalidate_cache,

+    .bdrv_ioctl         = repagent_ioctl,

+    .bdrv_aio_ioctl     = repagent_aio_ioctl,

-    .create_options = repagent_create_options,

-    .bdrv_check = repagent_check,

+    .bdrv_create        = repagent_create,

+    .create_options     = repagent_create_options,

+    .bdrv_has_zero_init = repagent_has_zero_init,

};

 static void bdrv_repagent_init(void)

diff --git a/block/repagent/rephub_cmds.h b/block/repagent/rephub_cmds.h

index 3bd4eb4..d1bad06 100644

--- a/block/repagent/rephub_cmds.h

+++ b/block/repagent/rephub_cmds.h

@@ -128,7 +128,7 @@ typedef struct RepCmdReadVolReq {

typedef struct RepCmdReadVolRes {

     RepCmdHdr hdr;

     int req_id;

-    int is_status_success;

+    int io_status;

     uint64_t volume_id;

} RepCmdReadVolRes;

diff --git a/blockdev.c b/blockdev.c

index a75cee3..3c3afbc 100644

--- a/blockdev.c

+++ b/blockdev.c

@@ -20,6 +20,7 @@

#include "trace.h"

#include "arch_init.h"

+

static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);

 static const char *const if_name[IF_COUNT] = {

@@ -292,7 +293,6 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)

     DriveInfo *dinfo;

     BlockIOLimit io_limits;

     int snapshot = 0;

-    int repagent = 0;

     bool copy_on_read;

     int ret;

@@ -309,7 +309,6 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)

     secs  = qemu_opt_get_number(opts, "secs", 0);

     snapshot = qemu_opt_get_bool(opts, "snapshot", 0);

-    repagent = qemu_opt_get_bool(opts, "repagent", 0);

     ro = qemu_opt_get_bool(opts, "readonly", 0);

     copy_on_read = qemu_opt_get_bool(opts, "copy-on-read", false);

@@ -589,10 +588,6 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)

         bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);

     }

-    if (repagent) {

-        bdrv_flags |= BDRV_O_REPAGENT;

-    }

-

     if (copy_on_read) {

         bdrv_flags |= BDRV_O_COPY_ON_READ;

     }

diff --git a/vl.c b/vl.c

index 7d381ea..0fe2cff 100644

--- a/vl.c

+++ b/vl.c

@@ -775,14 +775,6 @@ static int drive_enable_snapshot(QemuOpts *opts, void *opaque)

     return 0;

}

-static int drive_enable_repagent(QemuOpts *opts, void *opaque)

-{

-    if (NULL == qemu_opt_get(opts, "repagent")) {

-        qemu_opt_set(opts, "repagent", "on");

-    }

-    return 0;

-}

-

static void default_drive(int enable, int snapshot, int use_scsi,

                           BlockInterfaceType type, int index,

                           const char *optstr)

@@ -2295,7 +2287,6 @@ int main(int argc, char **argv, char **envp)

     const char *trace_events = NULL;

     const char *trace_file = NULL;

-    int enable_repagent = 0;

     atexit(qemu_run_exit_notifiers);

     error_set_progname(argv[0]);

@@ -2423,9 +2414,9 @@ int main(int argc, char **argv, char **envp)

                 break;

             case QEMU_OPTION_repagent:

#ifdef CONFIG_REPAGENT

+                use_repagent = 1;

                 repagent_init(optarg, 0);

-                enable_repagent = 1;

-

+                printf("Repagent enabled\n");

#else

                 fprintf(stderr, "Repagent support is disabled. "

                     "Don't use -repagent option.\n");

@@ -3411,10 +3402,6 @@ int main(int argc, char **argv, char **envp)

     blk_mig_init();

     /* open the virtual block devices */

-    if (enable_repagent) {

-        qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_repagent,

-            NULL, 0);

-    }

     if (snapshot)

         qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot, NULL, 0);

     if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, &machine->use_scsi, 1) != 0)

--

1.7.6.5


reply via email to

[Prev in Thread] Current Thread [Next in Thread]