1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

hyperv: XML parsing of serial ports

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Matt Coleman 2021-02-01 19:48:36 -05:00 committed by Michal Privoznik
parent b5e267e8c5
commit 3550d11a79
5 changed files with 79 additions and 0 deletions

View File

@ -1253,6 +1253,52 @@ hypervDomainDefParseStorage(hypervPrivate *priv,
}
static int
hypervDomainDefParseSerial(virDomainDefPtr def, Msvm_ResourceAllocationSettingData *rasd)
{
for (; rasd; rasd = rasd->next) {
int port_num = 0;
char **conn = NULL;
const char *srcPath = NULL;
virDomainChrDefPtr serial = NULL;
if (rasd->data->ResourceType != MSVM_RASD_RESOURCETYPE_SERIAL_PORT)
continue;
/* get port number */
port_num = rasd->data->ElementName[4] - '0';
if (port_num < 1) {
continue;
}
serial = virDomainChrDefNew(NULL);
serial->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
serial->source->type = VIR_DOMAIN_CHR_TYPE_PIPE;
serial->target.port = port_num;
/* set up source */
if (rasd->data->Connection.count < 1) {
srcPath = "-1";
} else {
conn = rasd->data->Connection.data;
if (!*conn)
srcPath = "-1";
else
srcPath = *conn;
}
serial->source->data.file.path = g_strdup(srcPath);
if (VIR_APPEND_ELEMENT(def->serials, def->nserials, serial) < 0) {
virDomainChrDefFree(serial);
return -1;
}
}
return 0;
}
/*
* Driver functions
@ -2113,6 +2159,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
g_autoptr(Msvm_MemorySettingData) memorySettingData = NULL;
g_autoptr(Msvm_ResourceAllocationSettingData) rasd = NULL;
g_autoptr(Msvm_StorageAllocationSettingData) sasd = NULL;
g_autoptr(Msvm_SerialPortSettingData) spsd = NULL;
Msvm_ResourceAllocationSettingData *serialDevices = NULL;
virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
@ -2151,6 +2199,9 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
return NULL;
}
if (hypervGetSerialPortSD(priv, virtualSystemSettingData->data->InstanceID, &spsd) < 0)
return NULL;
/* Fill struct */
def->virtType = VIR_DOMAIN_VIRT_HYPERV;
@ -2215,6 +2266,14 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
if (hypervDomainDefParseStorage(priv, def, rasd, sasd) < 0)
return NULL;
if (g_str_has_prefix(priv->version, "6."))
serialDevices = rasd;
else
serialDevices = (Msvm_ResourceAllocationSettingData *)spsd;
if (hypervDomainDefParseSerial(def, serialDevices) < 0)
return NULL;
/* XXX xmlopts must be non-NULL */
return virDomainDefFormat(def, NULL, virDomainDefFormatConvertXMLFlags(flags));
}

View File

@ -1488,6 +1488,16 @@ hypervGetStorageAllocationSD(hypervPrivate *priv,
}
int
hypervGetSerialPortSD(hypervPrivate *priv,
const char *id,
Msvm_SerialPortSettingData **data)
{
hypervGetSettingData(Msvm_SerialPortSettingData, id, data);
return 0;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Msvm_VirtualSystemManagementService
*/

View File

@ -254,6 +254,10 @@ int hypervGetStorageAllocationSD(hypervPrivate *priv,
const char *id,
Msvm_StorageAllocationSettingData **data);
int hypervGetSerialPortSD(hypervPrivate *priv,
const char *id,
Msvm_SerialPortSettingData **data);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Msvm_VirtualSystemManagementService
*/

View File

@ -113,6 +113,7 @@ enum _Msvm_ResourceAllocationSettingData_ResourceType {
MSVM_RASD_RESOURCETYPE_DVD_DRIVE = 16,
MSVM_RASD_RESOURCETYPE_DISK_DRIVE = 17,
MSVM_RASD_RESOURCETYPE_STORAGE_EXTENT = 19,
MSVM_RASD_RESOURCETYPE_SERIAL_PORT = 21,
MSVM_RASD_RESOURCETYPE_LOGICAL_DISK = 31,
};

View File

@ -629,6 +629,11 @@ class Msvm_ResourceAllocationSettingData
end
class Msvm_SerialPortSettingData : Msvm_ResourceAllocationSettingData
boolean DebuggerMode
end
class Msvm_Keyboard
string InstanceID
string Caption