File 0005-run.py-Introduce-blk-disk-argument.patch of Package virtme
From 80b31bb76560df894fc72b08a9957cd8c9058828 Mon Sep 17 00:00:00 2001
From: Marcos Paulo de Souza <mpdesouza@suse.com>
Date: Mon, 20 Jul 2020 19:48:22 -0300
Subject: [PATCH 5/6] run.py: Introduce --blk-disk argument
This new argument will create a new virtio-blk device, instead of the
scsi-blk that can be created by using --disk argument, accepting the
same argument of --disk.
By using --disk-blk "disk2=file1" will create
/dev/disk/by-id/virtio-disk.
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
virtme/commands/run.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/virtme/commands/run.py b/virtme/commands/run.py
index 2734848..d4c3233 100644
--- a/virtme/commands/run.py
+++ b/virtme/commands/run.py
@@ -71,6 +71,8 @@ def make_parser() -> argparse.ArgumentParser:
help='Allow the host to ask the guest to release memory.')
g.add_argument('--disk', action='append', default=[], metavar='NAME=PATH',
help='Add a read/write virtio-scsi disk. The device node will be /dev/disk/by-id/scsi-0virtme_disk_NAME.')
+ g.add_argument('--blk-disk', action='append', default=[], metavar='NAME=PATH',
+ help='Add a read/write virtio-blk disk. The device nodes will be /dev/disk/by-id/virtio-virtme_disk_blk_NAME.')
g.add_argument('--memory', action='store', default=None,
help='Set guest memory and qemu -m flag.')
g.add_argument('--name', action='store', default=None,
@@ -410,6 +412,13 @@ def do_it() -> int:
if args.memory:
qemuargs.extend(['-m', args.memory])
+ if args.blk_disk:
+ for i,d in enumerate(args.blk_disk):
+ driveid = 'blk-disk%d' % i
+ name, fn = sanitize_disk_args('--blk-disk', d)
+ qemuargs.extend(['-drive', 'if=none,id=%s,file=%s' % (driveid, fn),
+ '-device', 'virtio-blk-pci,drive=%s,serial=%s' % (driveid, name)])
+
if args.disk:
qemuargs.extend(['-device', '%s,id=scsi' % arch.virtio_dev_type('scsi')])
--
2.27.0