From cb9f640b4e6166c295e34f1ac4acea56e78940a6 Mon Sep 17 00:00:00 2001 From: Jan Schintag Date: Fri, 13 Sep 2019 08:58:23 +0200 Subject: [PATCH] virtio-blk: Add support for share-rw flag This allows multiple instances of qemu to share the same file for virtio-blk device. Fixes: #108 Signed-off-by: Jan Schintag --- qemu/qemu.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qemu/qemu.go b/qemu/qemu.go index daac268bd..f2b80ccd1 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -728,6 +728,9 @@ type BlockDevice struct { // DevNo identifies the ccw devices for s390x architecture DevNo string + + // ShareRW enables multiple qemu instances to share the File + ShareRW bool } // Valid returns true if the BlockDevice structure is valid and complete. @@ -766,6 +769,10 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string { deviceParams = append(deviceParams, fmt.Sprintf(",devno=%s", blkdev.DevNo)) } + if blkdev.ShareRW { + deviceParams = append(deviceParams, fmt.Sprintf(",share-rw=on")) + } + blkParams = append(blkParams, fmt.Sprintf("id=%s", blkdev.ID)) blkParams = append(blkParams, fmt.Sprintf(",file=%s", blkdev.File)) blkParams = append(blkParams, fmt.Sprintf(",aio=%s", blkdev.AIO))