qemu: monitor: Properly configure backend for UDP chardevs

Since introduction of chardev hotplug the code was wrong for the UDP
case and basically created a TCP socket instead. Use proper objects and
type for UDP.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1377602
This commit is contained in:
Peter Krempa 2016-09-27 16:01:55 +02:00
parent 386fe237b2
commit 9bc4179dd4
2 changed files with 26 additions and 6 deletions

View File

@ -6204,12 +6204,20 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
backend_type = "socket";
backend_type = "udp";
addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.udp.connectHost,
chr->data.udp.connectService);
if (!addr ||
virJSONValueObjectAppend(data, "addr", addr) < 0)
virJSONValueObjectAppend(data, "remote", addr) < 0)
goto error;
if (chr->data.udp.bindHost) {
addr = qemuMonitorJSONBuildInetSocketAddress(chr->data.udp.bindHost,
chr->data.udp.bindService);
if (!addr ||
virJSONValueObjectAppend(data, "local", addr) < 0)
goto error;
}
addr = NULL;
break;

View File

@ -853,10 +853,22 @@ qemuMonitorJSONTestAttachChardev(virDomainXMLOptionPtr xmlopt)
chr.data.udp.connectService = (char *) "1234";
CHECK("udp", false,
"{'id':'alias',"
"'backend':{'type':'socket',"
"'data':{'addr':{'type':'inet',"
"'data':{'host':'example.com',"
"'port':'1234'}}}}}");
"'backend':{'type':'udp',"
"'data':{'remote':{'type':'inet',"
"'data':{'host':'example.com',"
"'port':'1234'}}}}}");
chr.data.udp.bindHost = (char *) "localhost";
chr.data.udp.bindService = (char *) "4321";
CHECK("udp", false,
"{'id':'alias',"
"'backend':{'type':'udp',"
"'data':{'remote':{'type':'inet',"
"'data':{'host':'example.com',"
"'port':'1234'}},"
"'local':{'type':'inet',"
"'data':{'host':'localhost',"
"'port':'4321'}}}}}");
memset(&chr, 0, sizeof(chr));
chr.type = VIR_DOMAIN_CHR_TYPE_UNIX;