On 1/22/21 9:18 PM, Matt Coleman wrote:
Co-authored-by: Sri Ramanujam <sramanujam@xxxxxxxxx>
Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
src/hyperv/hyperv_driver.c | 68 +++++++++++++++++++++++++++
src/hyperv/hyperv_wmi.c | 10 ++++
src/hyperv/hyperv_wmi.h | 4 ++
src/hyperv/hyperv_wmi_classes.h | 1 +
src/hyperv/hyperv_wmi_generator.input | 5 ++
5 files changed, 88 insertions(+)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index bdc084790a..9bbbcfc88c 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1253,6 +1253,61 @@ hypervDomainDefParseStorage(hypervPrivate *priv,
}
+static int
+hypervDomainDefParseSerial(virDomainDefPtr def, Msvm_ResourceAllocationSettingData *rasd)
+{
+ int port_num = 0;
+ char **conn = NULL;
+ const char *srcPath = NULL;
+ Msvm_ResourceAllocationSettingData *entry = rasd;
+ virDomainChrDefPtr serial = NULL;
+
+ while (entry) {
+ if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_SERIAL_PORT) {
+ /* clear some vars */
+ serial = NULL;
+ port_num = 0;
+ conn = NULL;
+ srcPath = NULL;
Well, you don't need to clear them if they'd be declared inside the loop :-)
+
+ /* get port number */
+ port_num = entry->data->ElementName[4] - '0';
+ if (port_num < 1) {
+ entry = entry->next;
+ 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 (entry->data->Connection.count < 1) {
+ srcPath = "-1";
+ } else {
+ conn = entry->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;
+ }
+ }
+
+ entry = entry->next;
+ }
+
+ return 0;
+}
+
Michal