cli: --smartcard: support database= and certificate[0-9]*=

For mode=host-certificates config
This commit is contained in:
Cole Robinson
2019-05-14 11:57:50 -04:00
parent c0ddb86918
commit f3fd6d200b
4 changed files with 27 additions and 1 deletions
@@ -256,6 +256,12 @@
<source mode="bind" host="1.2.3.4" service="5678"/>
<protocol type="telnet"/>
</smartcard>
<smartcard mode="host-certificates" type="spicevmc">
<database>/fake/path/to/database</database>
<certificate>/path/to/fake/cert0</certificate>
<certificate>/path/to/fake/cert1</certificate>
<certificate>/path/to/fake/cert2</certificate>
</smartcard>
<serial type="tcp">
<source mode="bind" host="127.0.0.1" service="2222"/>
<protocol type="telnet"/>
+1
View File
@@ -569,6 +569,7 @@ c.add_compare(""" \
--smartcard mode=host \
--smartcard default \
--smartcard passthrough,type=tcp,source.mode=bind,source.host=1.2.3.4,source.service=5678,protocol.type=telnet
--smartcard host-certificates,type=spicevmc,database=/fake/path/to/database,certificate0=/path/to/fake/cert0,certificate1=/path/to/fake/cert1,certificate2=/path/to/fake/cert2 \
\
--redirdev usb,type=spicevmc \
--redirdev usb,type=tcp,server=localhost:4000 \
+10
View File
@@ -3100,6 +3100,12 @@ class ParserSmartcard(VirtCLIParser):
guest_propname = "devices.smartcard"
remove_first = "mode"
def certificate_find_inst_cb(self, *args, **kwargs):
cliarg = "certificate" # certificate[0-9]*
list_propname = "certificates"
cb = self._make_find_inst_cb(cliarg, list_propname)
return cb(*args, **kwargs)
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
@@ -3108,6 +3114,10 @@ class ParserSmartcard(VirtCLIParser):
cls.add_arg("type", "type", ignore_default=True)
_add_char_source_args(cls)
cls.add_arg("database", "database", can_comma=True)
cls.add_arg("certificate[0-9]*", "value", can_comma=True,
find_inst_cb=cls.certificate_find_inst_cb)
######################
# --redirdev parsing #
+10 -1
View File
@@ -6,7 +6,13 @@
from .char import CharSource
from .device import Device
from ..xmlbuilder import XMLChildProperty, XMLProperty
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
class _Certificate(XMLBuilder):
XML_NAME = "certificate"
value = XMLProperty("./.")
class DeviceSmartcard(Device):
@@ -17,6 +23,9 @@ class DeviceSmartcard(Device):
type = XMLProperty("./@type")
source = XMLChildProperty(CharSource, is_single=True)
database = XMLProperty("./database")
certificates = XMLChildProperty(_Certificate)
##################
# Default config #