[SYSREG2] Add support for newer libvirt XML output

This fixes querying console TTY with newer libvirt releases.
We keep old path for compatibility
This commit is contained in:
Pierre Schweitzer 2018-12-26 21:36:16 +01:00
parent f41c67e5de
commit 6b68b7dfba
No known key found for this signature in database
GPG Key ID: 7545556C3D585B0B

13
kvm.cpp
View File

@ -50,6 +50,19 @@ bool KVM::GetConsole(char* console)
if (obj)
xmlXPathFreeObject(obj);
if (!RetVal)
{
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/source/@path)", ctxt);
if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)))
{
strcpy(console, (char *)obj->stringval);
RetVal = true;
}
if (obj)
xmlXPathFreeObject(obj);
}
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
return RetVal;