On 10/09/2017 02:19 AM, ZhiPeng Lu wrote: > For vhost-user ports, Open vSwitch acts as the server and QEMU the client. > When OVS crashes or restarts, the QEMU process should be reconnected to > OVS. > > Signed-off-by: ZhiPeng Lu <lu.zhipeng@xxxxxxxxxx> > --- > docs/schemas/domaincommon.rng | 26 ++++++++------ > src/conf/domain_conf.c | 40 ++++++++++++++++++---- > src/conf/domain_conf.h | 10 +++--- > src/qemu/qemu_command.c | 2 +- > src/qemu/qemu_domain.c | 2 +- > src/qemu/qemu_monitor_json.c | 2 +- > .../qemuxml2argv-net-vhostuser-multiq.args | 4 +-- > .../qemuxml2argv-net-vhostuser-multiq.xml | 8 +++-- > 8 files changed, 65 insertions(+), 29 deletions(-) > > diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng > index 76852ab..3f4ed82 100644 > --- a/docs/schemas/domaincommon.rng > +++ b/docs/schemas/domaincommon.rng > @@ -2327,6 +2327,18 @@ > </attribute> > </optional> > </define> > + <define name="reconnect"> > + <element name="reconnect"> > + <attribute name="enabled"> > + <ref name="virYesNo"/> > + </attribute> > + <optional> > + <attribute name="timeout"> > + <ref name="unsignedInt"/> > + </attribute> > + </optional> > + </element> > + </define> > > <!-- > An interface description can either be of type bridge in which case > @@ -2388,6 +2400,9 @@ > <value>client</value> > </choice> > </attribute> > + <optional> > + <ref name="reconnect"/> > + </optional> Misaligned. > <empty/> > </element> > <ref name="interface-options"/> > @@ -3636,16 +3651,7 @@ > </attribute> > </optional> > <optional> > - <element name="reconnect"> > - <attribute name="enabled"> > - <ref name="virYesNo"/> > - </attribute> > - <optional> > - <attribute name="timeout"> > - <ref name="unsignedInt"/> > - </attribute> > - </optional> > - </element> > + <ref name="reconnect"/> > </optional> > <zeroOrMore> > <ref name='devSeclabel'/> > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index cc5e79b..b7fc3a5 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -83,6 +83,13 @@ struct _virDomainXMLOption { > /* Private data for save image stored in snapshot XML */ > virSaveCookieCallbacks saveCookie; > }; > +static int > +virDomainDeviceSourceReconnectDefParseXML(virDomainDeviceSourceReconnectDefPtr def, > + xmlNodePtr node, > + xmlXPathContextPtr ctxt); > +static void > +virDomainDeviceSourceReconnectDefFormat(virBufferPtr buf, > + virDomainDeviceSourceReconnectDefPtr def); We don't need these. Just move the function before their first call. > > #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ > (VIR_DOMAIN_DEF_FORMAT_SECURE | \ > @@ -10245,6 +10252,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, > virNWFilterHashTablePtr filterparams = NULL; > virDomainActualNetDefPtr actual = NULL; > xmlNodePtr oldnode = ctxt->node; > + virDomainDeviceSourceReconnectDef reconnect = {0}; > int rv, val; > > if (VIR_ALLOC(def) < 0) > @@ -10331,6 +10339,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, > vhostuser_type = virXMLPropString(cur, "type"); > vhostuser_path = virXMLPropString(cur, "path"); > vhostuser_mode = virXMLPropString(cur, "mode"); > + if (virDomainDeviceSourceReconnectDefParseXML(&reconnect, cur, ctxt) < 0) > + goto error; > } else if (!def->virtPortProfile > && virXMLNodeNameEqual(cur, "virtualport")) { > if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) { > @@ -10552,8 +10562,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, > > if (STREQ(vhostuser_mode, "server")) { > def->data.vhostuser->data.nix.listen = true; > + if (reconnect.enabled != VIR_TRISTATE_BOOL_ABSENT) { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > + _("'reconnect' attribute unsupported " > + "'server' mode for <interface type='vhostuser'>")); > + goto error; > + } > } else if (STREQ(vhostuser_mode, "client")) { > def->data.vhostuser->data.nix.listen = false; > + def->data.vhostuser->data.nix.reconnect.enabled = reconnect.enabled; > + def->data.vhostuser->data.nix.reconnect.timeout = reconnect.timeout; > + reconnect.enabled = VIR_TRISTATE_BOOL_ABSENT; I'm not quite sure what is the purpose of this line. > } else { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", > _("Wrong <source> 'mode' attribute " > @@ -11216,7 +11235,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def, > } > > static int > -virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def, > +virDomainDeviceSourceReconnectDefParseXML(virDomainDeviceSourceReconnectDefPtr def, > xmlNodePtr node, > xmlXPathContextPtr ctxt) Again, misaligned. And I'm not quite sure why are you renaming Reconnect? I mean, it is still related to ChrSource so I'd leave the name be as is. Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list