[virt-tools-list] [PATCH 2/5] virt-install: Add --disk removable option
Fred A. Kemp
anonym at riseup.net
Fri Oct 4 01:38:59 UTC 2013
From: "Fred A. Kemp" <anonym at riseup.net>
---
man/virt-install.pod | 5 +++++
tests/clitest.py | 5 +++++
virtinst/cli.py | 1 +
3 files changed, 11 insertions(+)
diff --git a/man/virt-install.pod b/man/virt-install.pod
index 406840b..522acf4 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -448,6 +448,11 @@ Disk bus type. Value can be 'ide', 'sata', 'scsi', 'usb', 'virtio' or 'xen'.
The default is hypervisor dependent since not all hypervisors support all
bus types.
+=item B<removable>
+
+Sets the removable flag (/sys/block/$dev/removable on Linux). Only
+used with QEMU and bus=usb. Value can be 'on' or 'off'.
+
=item B<perms>
Disk permissions. Value can be 'rw' (Read/Write), 'ro' (Readonly),
diff --git a/tests/clitest.py b/tests/clitest.py
index e44ec4c..3155383 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -639,6 +639,9 @@ c.add_valid("--disk %(DIR)s,device=floppy") # Dir with a floppy dev
c.add_valid("--disk %(EXISTIMG1)s,driver_name=qemu,driver_type=qcow2") # Driver name and type options
c.add_valid("--disk /dev/hda") # Using a storage pool source as a disk
c.add_valid("--disk pool=default,size=.00001") # Building 'default' pool
+c.add_valid("--disk path=%(EXISTIMG1)s,bus=usb") # Existing USB disk
+c.add_valid("--disk path=%(EXISTIMG1)s,bus=usb,removable=on") # Existing USB disk as removable
+c.add_valid("--disk path=%(EXISTIMG1)s,bus=usb,removable=off") # Existing USB disk as non-removable
c.add_invalid("--file %(NEWIMG1)s --file-size 100000 --nonsparse") # Nonexisting file, size too big
c.add_invalid("--file %(NEWIMG1)s --file-size 100000") # Huge file, sparse, but no prompting
c.add_invalid("--file %(NEWIMG1)s") # Nonexisting file, no size
@@ -657,6 +660,8 @@ c.add_invalid("--disk %(DIR)s,device=cdrom") # Dir without floppy
c.add_invalid("--disk %(EXISTIMG1)s,driver_name=foobar,driver_type=foobaz") # Unknown driver name and type options (as of 1.0.0)
c.add_valid("--disk path=%(EXISTIMG1)s,startup_policy=optional") # Existing disk, startupPolicy
c.add_invalid("--disk path=%(EXISTIMG1)s,startup_policy=Foo") # Existing disk, invalid startupPolicy
+c.add_invalid("--disk path=%(EXISTIMG1)s,bus=ide,removable=on") # removable only supported by USB disks
+c.add_invalid("--disk path=%(EXISTIMG1)s,bus=ide,removable=off") # removable only supported by USB disks
c = vinst.add_category("redirdev", "--noautoconsole --nographics --nodisks --pxe")
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 578ea83..45b31f4 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1455,6 +1455,7 @@ def parse_disk(guest, optstr, dev=None, validate=True):
set_param("device", "device")
set_param("bus", "bus")
+ set_param("removable", "removable", convert_cb=_on_off_convert)
set_param("driver_cache", "cache")
set_param("driver_name", "driver_name")
set_param("driver_type", "driver_type")
--
1.7.10.4
More information about the virt-tools-list
mailing list