Skip to content

Commit 53c7978

Browse files
committed
cli: --disk: Don't try to detect path opt collisions
The checking is hard to get right because there are many ways to specify storage. Rework it to try to determine if we should create storage from disk XML contents
1 parent 4d5f695 commit 53c7978

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

virtinst/cli.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,6 @@ def convert_perms(val):
27992799
else:
28002800
fail(_("Unknown '%s' value '%s'") % ("perms", val))
28012801

2802-
has_path = "path" in self.optdict
28032802
backing_store = self.optdict.pop("backing_store", None)
28042803
backing_format = self.optdict.pop("backing_format", None)
28052804
poolname = self.optdict.pop("pool", None)
@@ -2808,17 +2807,6 @@ def convert_perms(val):
28082807
fmt = self.optdict.pop("format", None)
28092808
sparse = _on_off_convert("sparse", self.optdict.pop("sparse", "yes"))
28102809
convert_perms(self.optdict.pop("perms", None))
2811-
has_type_volume = ("source_pool" in self.optdict or
2812-
"source_volume" in self.optdict)
2813-
has_type_network = ("source_protocol" in self.optdict)
2814-
2815-
optcount = sum([bool(p) for p in [has_path, poolname, volname,
2816-
has_type_volume, has_type_network]])
2817-
if optcount > 1:
2818-
fail(_("Cannot specify more than 1 storage path"))
2819-
if optcount == 0 and size:
2820-
# Saw something like --disk size=X, have it imply pool=default
2821-
poolname = "default"
28222810

28232811
if volname:
28242812
if volname.count("/") != 1:
@@ -2830,6 +2818,14 @@ def convert_perms(val):
28302818

28312819
super()._parse(inst)
28322820

2821+
if (size and
2822+
not volname and
2823+
not poolname and
2824+
not inst.path and
2825+
inst.type == inst.TYPE_FILE):
2826+
# Saw something like --disk size=X, have it imply pool=default
2827+
poolname = "default"
2828+
28332829
# Generate and fill in the disk source info
28342830
newvolname = None
28352831
poolobj = None

0 commit comments

Comments
 (0)