1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-04-01 20:05:19 +00:00

conf: parse interface/source/@dev for all interface types (with backend type='passt')

The original implementation of the passt backend for vhost-user
interfaces erroneously forgot to parse:

  <source dev='blah'/>

for interface type='vhostuser', so it wasn't being added to the passt
commandline, and also wasn't being saved to the domain config. Now we
parse it whenever the <backend> type='passt', no matter what the
interface type, and then throw an error during validation if
source/@dev was specified for interface type = 'user|vhostuser' and
backend type != 'passt'.

Fixes: 1e9054b9c79d721a55f413c2983c5370044f8f60
Resolves: https://issues.redhat.com/browse/RHEL-82539
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Laine Stump 2025-03-06 19:19:12 -05:00
parent 902237664f
commit 4c979edaa5
3 changed files with 14 additions and 4 deletions

View File

@ -9940,9 +9940,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
break;
case VIR_DOMAIN_NET_TYPE_USER:
def->sourceDev = virXMLPropString(source_node, "dev");
break;
case VIR_DOMAIN_NET_TYPE_NULL:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
@ -10057,6 +10054,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
return NULL;
}
if (def->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
def->sourceDev = virXMLPropString(source_node, "dev");
}
def->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT;
if (linkstate != NULL) {
if ((def->linkstate = virDomainNetInterfaceLinkStateTypeFromString(linkstate)) <= 0) {

View File

@ -2190,12 +2190,18 @@ virDomainNetDefValidate(const virDomainNetDef *net)
if (net->type != VIR_DOMAIN_NET_TYPE_USER &&
net->type != VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
if (net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("The 'passt' backend can only be used with interface type='user' or type='vhostuser'"));
return -1;
}
}
if (net->sourceDev && net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("The 'dev' attribute of the <source> element can only be used with <interface> type='user' or type='vhostuser' if the <backend> type='passt'"));
return -1;
}
if (net->nPortForwards > 0) {
size_t p;

View File

@ -33,6 +33,7 @@
<controller type='pci' index='0' model='pci-root'/>
<interface type='vhostuser'>
<mac address='00:11:22:33:44:55'/>
<source dev='eth42'/>
<ip address='172.17.2.0' family='ipv4' prefix='24'/>
<ip address='2001:db8:ac10:fd01::feed' family='ipv6'/>
<portForward proto='tcp' address='2001:db8:ac10:fd01::1:10'>
@ -63,6 +64,7 @@
</interface>
<interface type='vhostuser'>
<mac address='00:11:22:33:44:11'/>
<source dev='eth43'/>
<model type='virtio'/>
<backend type='passt'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>