{"id":808983,"url":"http://patchwork.ozlabs.org/api/patches/808983/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170901201054.11738-1-briansteffens@gmail.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170901201054.11738-1-briansteffens@gmail.com>","list_archive_url":null,"date":"2017-09-01T20:10:54","name":"[1/1] block: add block device shared field","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"85984dcf5587301ffa8ff1d90b664fa38f3a2990","submitter":{"id":72281,"url":"http://patchwork.ozlabs.org/api/people/72281/?format=json","name":"Brian Steffens","email":"briansteffens@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170901201054.11738-1-briansteffens@gmail.com/mbox/","series":[{"id":1104,"url":"http://patchwork.ozlabs.org/api/series/1104/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1104","date":"2017-09-01T20:10:54","name":"[1/1] block: add block device shared field","version":1,"mbox":"http://patchwork.ozlabs.org/series/1104/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808983/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808983/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"P388bh3H\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkVlc3TZbz9sPt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  2 Sep 2017 06:12:28 +1000 (AEST)","from localhost ([::1]:58344 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnsIk-0001Ri-I5\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 16:12:26 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59216)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <briansteffens@gmail.com>) id 1dnsHc-0000z1-Du\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 16:11:17 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <briansteffens@gmail.com>) id 1dnsHb-0000eD-9g\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 16:11:16 -0400","from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:34636)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <briansteffens@gmail.com>)\n\tid 1dnsHb-0000dT-41\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 16:11:15 -0400","by mail-oi0-x242.google.com with SMTP id w10so1007195oie.1\n\tfor <qemu-devel@nongnu.org>; Fri, 01 Sep 2017 13:11:13 -0700 (PDT)","from bws.members.linode.com ([2600:3c00::f03c:91ff:fe91:19e2])\n\tby smtp.gmail.com with ESMTPSA id\n\ta9sm1322282oih.57.2017.09.01.13.11.12\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 01 Sep 2017 13:11:12 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=iYz14gp49a8TfNWsQLcDQc0FaM0CatizcXocRyHS/SA=;\n\tb=P388bh3HO9Ag6AW17MzaPR8vVB3pqnF20xWrPy8BYVOHdznHdYe4+aNeXfsi/CMDOK\n\tTkiZ87H9MI+f3ZS/MwaiILztpkS9q6SbLgrN4bbHoypQXojCoDPk3oBTW8OpoBUxChHL\n\teOjUxDDFTWtPQsqsOhlM/LgEatDCnQeAEIqhv0pyo0SGN9BePvdLxjH2y8cBplnjEu4E\n\tmNvJmaAPCjXDTQHrdV2rLyCdYgyTpS1as2rG1sClAF63tAX6QpSxYQ5jUIPd3PEz+oQ1\n\ttKZV4WjbTmqd2R62I1j1/4xy/n/crYHRfT1MVnH7kdM4plBxZ/vdgxWG+zcrO3+1R8+U\n\tEZwg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=iYz14gp49a8TfNWsQLcDQc0FaM0CatizcXocRyHS/SA=;\n\tb=RzQX3efWk5BJNHgfrM+2ng3CwhOUb6YswSztgmUUSKTTqNNRiOtRU4dYrlzRDrOSAb\n\tOy/o+Ss+PR639kn4L9i4UyZhYLizQO40edAb8vdETpgKE1dC3RAwYHgF65+W9xgQSzTY\n\tqorQsQThHlE/vXXV7536SnacuqrMumK4KH28e/jQte+h4mK8OcBMHO2f24ywSxrIoAY4\n\t1G90Jbi6nQ9KZMBZeaRvbfGoyuo0cyX/zdXfeA6SaEtisW+OO9xPrlGLLOne7wBVo8/z\n\tk6vMFmWpwpuc/p7Gb2bOfDYHbSmdNIIfcy3g+F9ZLEgp4wPIql78Y62rx7gbE8HUMeD+\n\ts5oQ==","X-Gm-Message-State":"AHPjjUiZgd6Vwrw3BD//MylKfNZm+URu60iX/ahBAh0E2U8i8Z+IOWhT\n\t9F0vrMnMEst1ntsG","X-Google-Smtp-Source":"ADKCNb6tyivvb+Mf9ZshE5L9c4rVwi1z6iK13gEm78TQW4ZtExYzSp5zBXfwgcqbYJEsnoPnNQr6Zg==","X-Received":"by 10.202.87.213 with SMTP id l204mr2996309oib.308.1504296672774;\n\tFri, 01 Sep 2017 13:11:12 -0700 (PDT)","From":"Brian Steffens <briansteffens@gmail.com>","To":"qemu-devel@nongnu.org","Date":"Fri,  1 Sep 2017 20:10:54 +0000","Message-Id":"<20170901201054.11738-1-briansteffens@gmail.com>","X-Mailer":"git-send-email 2.13.1","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:4003:c06::242","Subject":"[Qemu-devel] [PATCH 1/1] block: add block device shared field","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Brian Steffens <briansteffens@gmail.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"This adds a boolean option called 'shared' to block devices. It defaults\nto off/false. When enabled for a particular block device, the 'shared' option\ncauses the block migration code to skip over syncing of that device. This\nallows controlling exactly which block devices get synced during a migration.\n\nSigned-off-by: Brian Steffens <briansteffens@gmail.com>\n---\n block.c                   | 7 +++++++\n block/qapi.c              | 2 ++\n include/block/block.h     | 1 +\n include/block/block_int.h | 3 +++\n migration/block.c         | 4 ++++\n qapi/block-core.json      | 2 +-\n 6 files changed, 18 insertions(+), 1 deletion(-)","diff":"diff --git a/block.c b/block.c\nindex 3308814bba..6dafcce046 100644\n--- a/block.c\n+++ b/block.c\n@@ -2466,6 +2466,13 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,\n         bdrv_backing_options(&flags, options, flags, options);\n     }\n \n+    /* Check for shared flag */\n+    /* See cautionary note on accessing @options above */\n+    bs->shared =\n+        g_strcmp0(qdict_get_try_str(options, BDRV_OPT_SHARED), \"on\") == 0 ||\n+        qdict_get_try_bool(options, BDRV_OPT_SHARED, false);\n+    qdict_del(options, BDRV_OPT_SHARED);\n+\n     bs->open_flags = flags;\n     bs->options = options;\n     options = qdict_clone_shallow(options);\ndiff --git a/block/qapi.c b/block/qapi.c\nindex 5f1a71f5d2..42e2a33008 100644\n--- a/block/qapi.c\n+++ b/block/qapi.c\n@@ -66,6 +66,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,\n \n     info->detect_zeroes = bs->detect_zeroes;\n \n+    info->shared = bs->shared;\n+\n     if (blk && blk_get_public(blk)->throttle_state) {\n         ThrottleConfig cfg;\n \ndiff --git a/include/block/block.h b/include/block/block.h\nindex ab80195378..8f6ab743d2 100644\n--- a/include/block/block.h\n+++ b/include/block/block.h\n@@ -110,6 +110,7 @@ typedef struct HDGeometry {\n #define BDRV_OPT_READ_ONLY      \"read-only\"\n #define BDRV_OPT_DISCARD        \"discard\"\n #define BDRV_OPT_FORCE_SHARE    \"force-share\"\n+#define BDRV_OPT_SHARED         \"shared\"\n \n \n #define BDRV_SECTOR_BITS   9\ndiff --git a/include/block/block_int.h b/include/block/block_int.h\nindex 7571c0aaaf..6508c90ca9 100644\n--- a/include/block/block_int.h\n+++ b/include/block/block_int.h\n@@ -672,6 +672,9 @@ struct BlockDriverState {\n \n     /* Only read/written by whoever has set active_flush_req to true.  */\n     unsigned int flushed_gen;             /* Flushed write generation */\n+\n+    /* Shared devices are not migrated. */\n+    bool shared;\n };\n \n struct BlockBackendRootState {\ndiff --git a/migration/block.c b/migration/block.c\nindex 9171f60028..b347c3dc61 100644\n--- a/migration/block.c\n+++ b/migration/block.c\n@@ -402,6 +402,10 @@ static int init_blk_migration(QEMUFile *f)\n     bmds_bs = g_malloc0(num_bs * sizeof(*bmds_bs));\n \n     for (i = 0, bs = bdrv_first(&it); bs; bs = bdrv_next(&it), i++) {\n+        if (bs->shared) {\n+            continue;\n+        }\n+\n         if (bdrv_is_read_only(bs)) {\n             continue;\n         }\ndiff --git a/qapi/block-core.json b/qapi/block-core.json\nindex 833c602150..a52e10f9cd 100644\n--- a/qapi/block-core.json\n+++ b/qapi/block-core.json\n@@ -365,7 +365,7 @@\n             '*bps_wr_max_length': 'int', '*iops_max_length': 'int',\n             '*iops_rd_max_length': 'int', '*iops_wr_max_length': 'int',\n             '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',\n-            'write_threshold': 'int' } }\n+            'write_threshold': 'int', 'shared': 'bool' } }\n \n ##\n # @BlockDeviceIoStatus:\n","prefixes":["1/1"]}