mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virDomainNetDefFormat: Simplify @sourceAttrBuf handling for some types of VIR_DOMAIN_NET
For VIR_DOMAIN_NET_TYPE_{SERVER,CLIENT,MCAST,UDP} we need to put (optionally) 'address' attribute and 'port' attributes of <source/> element. But the way we currently do that is particularly verbose. It can be shortened using virBufferEscapeString(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
95c5ff9890
commit
8a652c72b3
@ -23795,14 +23795,10 @@ virDomainNetDefFormat(virBuffer *buf,
|
||||
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
||||
case VIR_DOMAIN_NET_TYPE_MCAST:
|
||||
case VIR_DOMAIN_NET_TYPE_UDP:
|
||||
if (def->data.socket.address) {
|
||||
virBufferAsprintf(&sourceAttrBuf, " address='%s' port='%d'",
|
||||
def->data.socket.address,
|
||||
def->data.socket.port);
|
||||
} else {
|
||||
virBufferAsprintf(&sourceAttrBuf, " port='%d'",
|
||||
def->data.socket.port);
|
||||
}
|
||||
virBufferEscapeString(&sourceAttrBuf, " address='%s'",
|
||||
def->data.socket.address);
|
||||
virBufferAsprintf(&sourceAttrBuf, " port='%d'",
|
||||
def->data.socket.port);
|
||||
|
||||
if (def->type != VIR_DOMAIN_NET_TYPE_UDP)
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user