mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user