Signed-off-by: Ryan Gahagan <rgahagan@xxxxxxxxxxxxx> --- tools/virsh-domain.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 810e55fa53..5862993464 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -688,7 +688,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) if (source || source_protocol || source_name || host_name || host_transport || host_socket) { - virBufferAsprintf(&buf, "<source"); + virBufferAddLit(&buf, "<source"); if (source) virBufferAsprintf(&buf, " %s='%s'", @@ -699,26 +699,27 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) virBufferAsprintf(&buf, " name='%s'", source_name); if (host_name || host_transport || host_socket) { - virBufferAsprintf(">\n<host"); + virBufferAddLit(&buf, ">\n<host"); if (host_name) { host_port = strchr(host_name, ':'); - if (!host_port) - virBufferAsprintf(" name='%s'", host_name); - else { + if (!host_port) { + virBufferAsprintf(&buf, " name='%s'", host_name); + } else { host_name[(int)(host_port - host_name)] = '\0'; - virBufferAsprintf(" name='%s' port='%s'", host_name, host_port + 1); + virBufferAsprintf(&buf, " name='%s' port='%s'", host_name, host_port + 1); } } + if (host_transport) - virBufferAsprintf(" transport='%s'", host_transport); + virBufferAsprintf(&buf, " transport='%s'", host_transport); if (host_socket) - virBufferAsprintf(" socket='%s'", host_socket); + virBufferAsprintf(&buf, " socket='%s'", host_socket); - virBufferAsprintf(" />\n</source>\n"); + virBufferAddLit(&buf, " />\n</source>\n"); } else { - virBufferAsprintf(" />\n"); + virBufferAddLit(&buf, " />\n"); } } -- 2.29.0