diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index eee26cc9..c6b022a9 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -165,6 +165,7 @@
+
@@ -179,6 +180,7 @@
+
diff --git a/tests/clitest.py b/tests/clitest.py
index c3180f6b..cfb430fc 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -461,9 +461,9 @@ c.add_compare(""" \
--disk vol=gluster-pool/test-gluster.raw,startup_policy=optional \
--disk %(DIR)s,device=floppy \
\
---network user,mac=12:34:56:78:11:22,portgroup=foo \
+--network user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down \
--network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3 \
---network bridge=ovsbr,virtualport_type=openvswitch,virtualport_profileid=demo,virtualport_interfaceid=09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b \
+--network bridge=ovsbr,virtualport_type=openvswitch,virtualport_profileid=demo,virtualport_interfaceid=09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b,link_state=yes \
--network type=direct,source=eth5,source_mode=vepa,target=mytap12,virtualport_type=802.1Qbg,virtualport_managerid=12,virtualport_typeid=1193046,virtualport_typeidversion=1,virtualport_instanceid=09b11c53-8b5c-4eeb-8f00-d84eaa0aaa3b,boot_order=1 \
\
--graphics sdl \
diff --git a/virtinst/cli.py b/virtinst/cli.py
index a0df0648..30e8637d 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -738,22 +738,23 @@ def add_disk_option(stog, editexample=False):
# (for options like --disk, --network, etc. #
#############################################
+def _raw_on_off_convert(s):
+ tvalues = ["y", "yes", "1", "true", "t", "on"]
+ fvalues = ["n", "no", "0", "false", "f", "off"]
+
+ s = (s or "").lower()
+ if s in tvalues:
+ return True
+ elif s in fvalues:
+ return False
+ return None
+
+
def _on_off_convert(key, val):
if val is None:
return None
- def _yes_no_convert(s):
- tvalues = ["y", "yes", "1", "true", "t", "on"]
- fvalues = ["n", "no", "0", "false", "f", "off"]
-
- s = (s or "").lower()
- if s in tvalues:
- return True
- elif s in fvalues:
- return False
- return None
-
- val = _yes_no_convert(val)
+ val = _raw_on_off_convert(val)
if val is not None:
return val
raise fail(_("%(key)s must be 'yes' or 'no'") % {"key": key})
@@ -1770,6 +1771,21 @@ class ParserNetwork(VirtCLIParser):
else:
inst.type = val
+ def set_link_state(opts, inst, cliname, val):
+ ignore = opts
+ ignore = cliname
+
+ if val in ["up", "down"]:
+ inst.link_state = val
+ return
+
+ ret = _raw_on_off_convert(val)
+ if ret is True:
+ val = "up"
+ elif ret is False:
+ val = "down"
+ inst.link_state = val
+
self.set_param("type", "type", setter_cb=set_type_cb)
self.set_param("source", "source")
self.set_param("source_mode", "source_mode")
@@ -1779,6 +1795,7 @@ class ParserNetwork(VirtCLIParser):
self.set_param("macaddr", "mac", setter_cb=set_mac_cb)
self.set_param("filterref", "filterref")
self.set_param("boot.order", "boot_order")
+ self.set_param("link_state", "link_state", setter_cb=set_link_state)
self.set_param("driver_name", "driver_name")
self.set_param("driver_queues", "driver_queues")
diff --git a/virtinst/deviceinterface.py b/virtinst/deviceinterface.py
index 40aaf68d..9f3ee9f6 100644
--- a/virtinst/deviceinterface.py
+++ b/virtinst/deviceinterface.py
@@ -232,6 +232,7 @@ class VirtualNetworkInterface(VirtualDevice):
model = XMLProperty("./model/@type")
target_dev = XMLProperty("./target/@dev")
filterref = XMLProperty("./filterref/@filter")
+ link_state = XMLProperty("./link/@state")
driver_name = XMLProperty("./driver/@name")
driver_queues = XMLProperty("./driver/@queues", is_int=True)