qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [Qemu-devel] [patch 5/5] block: enable in_use flag
Date: Wed, 26 Jan 2011 12:12:35 -0200	[thread overview]
Message-ID: <20110126141348.365483427@redhat.com> (raw)
In-Reply-To: 20110126141230.637895847@redhat.com

[-- Attachment #1: 04-driveinfo-use-inuse --]
[-- Type: text/plain, Size: 1880 bytes --]

Set block device in use during block migration, disallow drive_del and
bdrv_truncate for in use devices.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu/blockdev.c
===================================================================
--- qemu.orig/blockdev.c
+++ qemu/blockdev.c
@@ -690,6 +690,10 @@ int do_drive_del(Monitor *mon, const QDi
         qerror_report(QERR_DEVICE_NOT_FOUND, id);
         return -1;
     }
+    if (bdrv_in_use(bs)) {
+        qerror_report(QERR_DEVICE_IN_USE, id);
+        return -1;
+    }
 
     /* quiesce block driver; prevent further io */
     qemu_aio_flush();
Index: qemu/block-migration.c
===================================================================
--- qemu.orig/block-migration.c
+++ qemu/block-migration.c
@@ -301,6 +301,7 @@ static void init_blk_migration_it(void *
         bmds->shared_base = block_mig_state.shared_base;
         alloc_aio_bitmap(bmds);
         drive_get_ref(drive_get_by_blockdev(bs));
+        bdrv_set_in_use(bs, 1);
 
         block_mig_state.total_sector_sum += sectors;
 
@@ -534,6 +535,7 @@ static void blk_mig_cleanup(Monitor *mon
 
     while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
         QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
+        bdrv_set_in_use(bmds->bs, 0);
         drive_put_ref(drive_get_by_blockdev(bmds->bs));
         qemu_free(bmds->aio_bitmap);
         qemu_free(bmds);
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c
+++ qemu/block.c
@@ -1132,6 +1132,8 @@ int bdrv_truncate(BlockDriverState *bs, 
         return -ENOTSUP;
     if (bs->read_only)
         return -EACCES;
+    if (bdrv_in_use(bs))
+        return -EBUSY;
     ret = drv->bdrv_truncate(bs, offset);
     if (ret == 0) {
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);

  parent reply	other threads:[~2011-01-26 14:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26 14:12 [Qemu-devel] [patch 0/5] block migration interaction fixes Marcelo Tosatti
2011-01-26 14:12 ` [Qemu-devel] [patch 1/5] block-migration: actually disable dirty tracking on cleanup Marcelo Tosatti
2011-01-26 14:12 ` [Qemu-devel] [patch 2/5] blockdev: add refcount to DriveInfo Marcelo Tosatti
2011-01-26 14:12 ` [Qemu-devel] [patch 3/5] block-migration: add reference to target DriveInfo Marcelo Tosatti
2011-01-26 14:12 ` [Qemu-devel] [patch 4/5] Add flag to indicate external users to block device Marcelo Tosatti
2011-01-26 14:12 ` Marcelo Tosatti [this message]
2011-02-07 11:27 ` [Qemu-devel] Re: [patch 0/5] block migration interaction fixes Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110126141348.365483427@redhat.com \
    --to=mtosatti@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).