mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
vhost-user: add support reconnect for vhost-user ports
For vhost-user ports, Open vSwitch acts as the server and QEMU the client. When OVS crashed or restart, QEMU shoule be reconnect to OVS. Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b06521928c
commit
edaf4ebe95
@ -5673,7 +5673,7 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
</interface>
|
</interface>
|
||||||
<interface type='vhostuser'>
|
<interface type='vhostuser'>
|
||||||
<mac address='52:54:00:3b:83:1b'/>
|
<mac address='52:54:00:3b:83:1b'/>
|
||||||
<source type='unix' path='/tmp/vhost2.sock' mode='client'/>
|
<source type='unix' path='/tmp/vhost2.sock' mode='client' reconnect='10'/>
|
||||||
<model type='virtio'/>
|
<model type='virtio'/>
|
||||||
<driver queues='5'/>
|
<driver queues='5'/>
|
||||||
</interface>
|
</interface>
|
||||||
@ -5689,6 +5689,9 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
are supported.
|
are supported.
|
||||||
vhost-user requires the virtio model type, thus the
|
vhost-user requires the virtio model type, thus the
|
||||||
<code><model></code> element is mandatory.
|
<code><model></code> element is mandatory.
|
||||||
|
<span class="since">Since 3.7.0</span> the element has an optional
|
||||||
|
attribute <code>reconnect</code> which configures reconnect timeout
|
||||||
|
(in seconds) if the connection is lost.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h5><a id="elementNwfilter">Traffic filtering with NWFilter</a></h5>
|
<h5><a id="elementNwfilter">Traffic filtering with NWFilter</a></h5>
|
||||||
|
@ -2388,6 +2388,11 @@
|
|||||||
<value>client</value>
|
<value>client</value>
|
||||||
</choice>
|
</choice>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<optional>
|
||||||
|
<attribute name="reconnect">
|
||||||
|
<ref name='positiveInteger'/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
<empty/>
|
<empty/>
|
||||||
</element>
|
</element>
|
||||||
<ref name="interface-options"/>
|
<ref name="interface-options"/>
|
||||||
|
@ -10240,6 +10240,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
char *vhostuser_mode = NULL;
|
char *vhostuser_mode = NULL;
|
||||||
char *vhostuser_path = NULL;
|
char *vhostuser_path = NULL;
|
||||||
char *vhostuser_type = NULL;
|
char *vhostuser_type = NULL;
|
||||||
|
char *vhostuser_reconnect = NULL;
|
||||||
char *trustGuestRxFilters = NULL;
|
char *trustGuestRxFilters = NULL;
|
||||||
char *vhost_path = NULL;
|
char *vhost_path = NULL;
|
||||||
virNWFilterHashTablePtr filterparams = NULL;
|
virNWFilterHashTablePtr filterparams = NULL;
|
||||||
@ -10326,11 +10327,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (!vhostuser_path && !vhostuser_mode && !vhostuser_type
|
} else if (!vhostuser_path && !vhostuser_mode && !vhostuser_type
|
||||||
&& def->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER &&
|
&& !vhostuser_reconnect && def->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER
|
||||||
virXMLNodeNameEqual(cur, "source")) {
|
&& virXMLNodeNameEqual(cur, "source")) {
|
||||||
vhostuser_type = virXMLPropString(cur, "type");
|
vhostuser_type = virXMLPropString(cur, "type");
|
||||||
vhostuser_path = virXMLPropString(cur, "path");
|
vhostuser_path = virXMLPropString(cur, "path");
|
||||||
vhostuser_mode = virXMLPropString(cur, "mode");
|
vhostuser_mode = virXMLPropString(cur, "mode");
|
||||||
|
vhostuser_reconnect = virXMLPropString(cur, "reconnect");
|
||||||
} else if (!def->virtPortProfile
|
} else if (!def->virtPortProfile
|
||||||
&& virXMLNodeNameEqual(cur, "virtualport")) {
|
&& virXMLNodeNameEqual(cur, "virtualport")) {
|
||||||
if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
|
||||||
@ -10552,8 +10554,24 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
|
|
||||||
if (STREQ(vhostuser_mode, "server")) {
|
if (STREQ(vhostuser_mode, "server")) {
|
||||||
def->data.vhostuser->data.nix.listen = true;
|
def->data.vhostuser->data.nix.listen = true;
|
||||||
|
if (vhostuser_reconnect) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("'reconnect' attribute unsupported "
|
||||||
|
"'server' mode for <interface type='vhostuser'>"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
} else if (STREQ(vhostuser_mode, "client")) {
|
} else if (STREQ(vhostuser_mode, "client")) {
|
||||||
def->data.vhostuser->data.nix.listen = false;
|
def->data.vhostuser->data.nix.listen = false;
|
||||||
|
if (vhostuser_reconnect) {
|
||||||
|
def->data.vhostuser->data.nix.reconnect.enabled = true;
|
||||||
|
if (virStrToLong_ui(vhostuser_reconnect, NULL, 10,
|
||||||
|
&def->data.vhostuser->data.nix.reconnect.timeout) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("invalid vhostuser reconnect value %s"),
|
||||||
|
vhostuser_reconnect);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Wrong <source> 'mode' attribute "
|
_("Wrong <source> 'mode' attribute "
|
||||||
@ -10998,6 +11016,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
VIR_FREE(portgroup);
|
VIR_FREE(portgroup);
|
||||||
VIR_FREE(address);
|
VIR_FREE(address);
|
||||||
VIR_FREE(port);
|
VIR_FREE(port);
|
||||||
|
VIR_FREE(vhostuser_reconnect);
|
||||||
VIR_FREE(vhostuser_type);
|
VIR_FREE(vhostuser_type);
|
||||||
VIR_FREE(vhostuser_path);
|
VIR_FREE(vhostuser_path);
|
||||||
VIR_FREE(vhostuser_mode);
|
VIR_FREE(vhostuser_mode);
|
||||||
@ -22983,6 +23002,11 @@ virDomainNetDefFormat(virBufferPtr buf,
|
|||||||
virBufferAsprintf(buf, " mode='%s'",
|
virBufferAsprintf(buf, " mode='%s'",
|
||||||
def->data.vhostuser->data.nix.listen ?
|
def->data.vhostuser->data.nix.listen ?
|
||||||
"server" : "client");
|
"server" : "client");
|
||||||
|
if (def->data.vhostuser->data.nix.reconnect.enabled == true) {
|
||||||
|
virBufferAsprintf(buf, " reconnect='%u'",
|
||||||
|
def->data.vhostuser->data.nix.reconnect.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
sourceLines++;
|
sourceLines++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -32,7 +32,7 @@ addr=0x4 \
|
|||||||
-netdev socket,listen=:2015,id=hostnet2 \
|
-netdev socket,listen=:2015,id=hostnet2 \
|
||||||
-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\
|
-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\
|
||||||
addr=0x5 \
|
addr=0x5 \
|
||||||
-chardev socket,id=charnet3,path=/tmp/vhost2.sock \
|
-chardev socket,id=charnet3,path=/tmp/vhost2.sock,reconnect=10 \
|
||||||
-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \
|
-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \
|
||||||
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\
|
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\
|
||||||
mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6
|
mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</interface>
|
</interface>
|
||||||
<interface type='vhostuser'>
|
<interface type='vhostuser'>
|
||||||
<mac address='52:54:00:ee:96:6d'/>
|
<mac address='52:54:00:ee:96:6d'/>
|
||||||
<source type='unix' path='/tmp/vhost2.sock' mode='client'/>
|
<source type='unix' path='/tmp/vhost2.sock' mode='client' reconnect='10'/>
|
||||||
<model type='virtio'/>
|
<model type='virtio'/>
|
||||||
<driver queues='4'/>
|
<driver queues='4'/>
|
||||||
</interface>
|
</interface>
|
||||||
|
Loading…
Reference in New Issue
Block a user