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 <jan.schintag@de.ibm.com>
This commit is contained in:
Jan Schintag 2019-09-13 08:58:23 +02:00
parent ee460e3008
commit cb9f640b4e

View File

@ -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))